UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

27 lines (26 loc) 1.29 kB
import { _testFinish, FullScreenPlugin, LoadingScreenPlugin, ThreeViewer } from 'threepipe'; import { createSimpleButtons } from '../examples-utils/simple-bottom-buttons.js'; import { TweakpaneUiPlugin } from '@threepipe/plugin-tweakpane'; async function init() { const viewer = new ThreeViewer({ canvas: document.getElementById('mcanvas'), renderScale: 'auto', plugins: [LoadingScreenPlugin], }); const fullScreenPlugin = viewer.addPluginSync(new FullScreenPlugin()); await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr'); await viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf'); createSimpleButtons({ ['Enter/Exit fullscreen']: () => { if (fullScreenPlugin.isFullScreen()) fullScreenPlugin.exit(); else fullScreenPlugin.enter(viewer.container); // parameter is optional, if not specified, the viewer canvas will be used // or just use // fullScreenPlugin.toggle(document.body) }, }, viewer.container); const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true)); ui.setupPluginUi(FullScreenPlugin); } init().finally(_testFinish);