UNPKG

threepipe

Version:

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

26 lines (25 loc) 1.19 kB
import { _testFinish, AssetExporterPlugin, LoadingScreenPlugin, SceneUiConfigPlugin, ThreeViewer, } from 'threepipe'; import { TweakpaneUiPlugin } from '@threepipe/plugin-tweakpane'; import { GLTFDracoExportPlugin } from '@threepipe/plugin-gltf-transform'; async function init() { const viewer = new ThreeViewer({ canvas: document.getElementById('mcanvas'), msaa: true, plugins: [LoadingScreenPlugin, AssetExporterPlugin, SceneUiConfigPlugin, GLTFDracoExportPlugin], }); const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true)); await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', { setBackground: true, }); const result = await viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', { autoCenter: true, autoScale: true, }); ui.setupPluginUi(AssetExporterPlugin, { expanded: true }); ui.setupPluginUi(SceneUiConfigPlugin); const model = result?.getObjectByName('node_damagedHelmet_-6514'); const config = model?.uiConfig; if (config) ui.appendChild(config); } init().finally(_testFinish);