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

script.ts 1.3KB

12345678910111213141516171819202122232425262728293031323334
  1. import {_testFinish, FullScreenPlugin, IObject3D, LoadingScreenPlugin, ThreeViewer} from 'threepipe'
  2. import {createSimpleButtons} from '../examples-utils/simple-bottom-buttons.js'
  3. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  4. async function init() {
  5. const viewer = new ThreeViewer({
  6. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  7. renderScale: 'auto',
  8. plugins: [LoadingScreenPlugin],
  9. })
  10. const fullScreenPlugin = viewer.addPluginSync(new FullScreenPlugin())
  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. createSimpleButtons({
  14. ['Enter/Exit fullscreen']: () => {
  15. if (fullScreenPlugin.isFullScreen()) fullScreenPlugin.exit()
  16. else fullScreenPlugin.enter(viewer.container) // parameter is optional, if not specified, the viewer canvas will be used
  17. // or just use
  18. // fullScreenPlugin.toggle(document.body)
  19. },
  20. }, viewer.container)
  21. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  22. ui.setupPluginUi(FullScreenPlugin)
  23. }
  24. init().finally(_testFinish)