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

script.ts 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {
  2. _testFinish,
  3. AssetExporterPlugin,
  4. getUrlQueryParam,
  5. IObject3D,
  6. LoadingScreenPlugin,
  7. SceneUiConfigPlugin,
  8. ThreeViewer,
  9. } from 'threepipe'
  10. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  11. import {TransfrSharePlugin} from '@threepipe/plugin-network'
  12. async function init() {
  13. const viewer = new ThreeViewer({
  14. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  15. msaa: true,
  16. plugins: [SceneUiConfigPlugin, LoadingScreenPlugin],
  17. })
  18. viewer.getPlugin(LoadingScreenPlugin)!.minimizeOnSceneObjectLoad = false
  19. const sharePlugin = viewer.addPluginSync(new TransfrSharePlugin())
  20. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  21. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  22. setBackground: true,
  23. })
  24. const modelUrlParam = 'm' // this is the default in TransfrSharePlugin
  25. sharePlugin.queryParam = modelUrlParam
  26. sharePlugin.baseUrls.viewer = 'https://threepipe.org/examples/model-viewer/index.html'
  27. sharePlugin.baseUrls.editor = 'https://threepipe.org/examples/tweakpane-editor/index.html'
  28. const modelUrl = getUrlQueryParam(modelUrlParam) ??
  29. 'https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf'
  30. const result = await viewer.load<IObject3D>(modelUrl, {
  31. autoCenter: true,
  32. autoScale: true,
  33. })
  34. ui.setupPluginUi(AssetExporterPlugin, {expanded: true})
  35. ui.setupPluginUi(TransfrSharePlugin, {expanded: true})
  36. ui.setupPluginUi(SceneUiConfigPlugin)
  37. const model = result?.getObjectByName('node_damagedHelmet_-6514')
  38. const config = model?.uiConfig
  39. if (config) ui.appendChild(config)
  40. }
  41. init().finally(_testFinish)