threepipe
Version:
A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.
17 lines (16 loc) • 936 B
JavaScript
import { _testFinish, DepthBufferPlugin, LoadingScreenPlugin, ThreeViewer, TonemapPlugin, UnsignedByteType, } from 'threepipe';
import { TweakpaneUiPlugin } from '@threepipe/plugin-tweakpane';
async function init() {
const viewer = new ThreeViewer({
canvas: document.getElementById('mcanvas'),
tonemap: true, // this is true by default
plugins: [LoadingScreenPlugin],
});
// A GBuffer(depth buffer here) is required for the `tonemapBackground` flag in TonemapPlugin to work
viewer.addPluginSync(new DepthBufferPlugin(UnsignedByteType, true));
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');
const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true));
ui.setupPluginUi(TonemapPlugin);
}
init().finally(_testFinish);