threepipe
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

script.ts 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. import {_testFinish, EditorViewWidgetPlugin, IObject3D, LoadingScreenPlugin, ThreeViewer, timeout} from 'threepipe'
  2. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  3. async function init() {
  4. const viewer = new ThreeViewer({
  5. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  6. msaa: true,
  7. plugins: [LoadingScreenPlugin],
  8. })
  9. viewer.scene.setBackgroundColor(0x151822)
  10. const plugin = viewer.addPluginSync(new EditorViewWidgetPlugin('bottom-left', 256))
  11. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  12. await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf')
  13. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  14. ui.setupPluginUi(EditorViewWidgetPlugin)
  15. // look at the model from left
  16. plugin.setOrientation('-z')
  17. await timeout(1000) // wait for 1 sec
  18. // look at the model from back
  19. plugin.setOrientation('-x')
  20. await timeout(1000) // wait for 1 sec
  21. // look at the model from front
  22. plugin.setOrientation('+z')
  23. }
  24. init().finally(_testFinish)