threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

script.ts 1.1KB

12345678910111213141516171819202122232425262728293031
  1. import {_testFinish, FullScreenPlugin, IObject3D, ThreeViewer, TweakpaneUiPlugin} from 'threepipe'
  2. import {createSimpleButtons} from '../examples-utils/simple-bottom-buttons.js'
  3. async function init() {
  4. const viewer = new ThreeViewer({
  5. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  6. })
  7. const fullScreenPlugin = viewer.addPluginSync(new FullScreenPlugin())
  8. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  9. await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf')
  10. createSimpleButtons({
  11. ['Enter/Exit fullscreen']: () => {
  12. if (fullScreenPlugin.isFullScreen()) fullScreenPlugin.exit()
  13. else fullScreenPlugin.enter(document.body) // parameter is optional, if not specified, the viewer canvas will be used
  14. // or just use
  15. // fullScreenPlugin.toggle(document.body)
  16. },
  17. })
  18. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  19. ui.setupPluginUi(FullScreenPlugin)
  20. }
  21. init().then(_testFinish)