threepipe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

script.ts 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {
  2. _testFinish, _testStart,
  3. FrameFadePlugin,
  4. IObject3D,
  5. LoadingScreenPlugin,
  6. PickingPlugin,
  7. SSAAPlugin,
  8. ThreeViewer,
  9. } from 'threepipe'
  10. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  11. import {SwitchNodePlugin} from '@threepipe/plugin-configurator'
  12. async function init() {
  13. const viewer = new ThreeViewer({
  14. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  15. msaa: true,
  16. plugins: [LoadingScreenPlugin, PickingPlugin, FrameFadePlugin, SSAAPlugin],
  17. dropzone: {
  18. addOptions: {
  19. disposeSceneObjects: true,
  20. },
  21. },
  22. })
  23. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  24. const configurator = viewer.addPluginSync(new SwitchNodePlugin())
  25. configurator.enableEditContextMenus = true
  26. // await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  27. // This model is already setup in the editor.
  28. // You can use the editor to setup the switch-nodes in the UI and then load the model here.
  29. // Another way to load the switch node variation details is to export a json file of the plugin from the editor and load it in the same way after loading the model.
  30. await viewer.load<IObject3D>(
  31. 'https://demo-assets.pixotronics.com/pixo/gltf/product_configurator.glb',
  32. // 'https://demo-assets.pixotronics.com/pixo/gltf/classic-watch.glb',
  33. {
  34. autoCenter: true,
  35. autoScale: true,
  36. })
  37. viewer.scene.mainCamera.controls!.enableDamping = true // since its disabled in the file for some reason
  38. ui.setupPluginUi(SwitchNodePlugin)
  39. ui.setupPluginUi(PickingPlugin)
  40. }
  41. _testStart()
  42. init().finally(_testFinish)