threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {
  2. _testFinish, _testStart,
  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. _testStart()
  42. init().finally(_testFinish)