threepipe
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

script.ts 1.6KB

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