threepipe
Version:
A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.
40 lines (33 loc) • 1.06 kB
text/typescript
import {
_testFinish,
GLTFMeshOptDecodePlugin,
IObject3D,
KTX2LoadPlugin,
LoadingScreenPlugin,
ThreeViewer,
} from 'threepipe'
async function init() {
const viewer = new ThreeViewer({
canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
msaa: true,
dropzone: {
addOptions: {
disposeSceneObjects: true,
},
},
plugins: [LoadingScreenPlugin, GLTFMeshOptDecodePlugin, KTX2LoadPlugin],
})
await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
const options = {
autoCenter: true,
autoScale: true,
};
(await Promise.all([
viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/coffeemat.glb', options),
viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/facecap.glb', options),
])).forEach((result, i) => {
if (!result) return
result.position.x = i * 2 - 1
})
}
init().finally(_testFinish)