threepipe
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {
  2. _testFinish,
  3. AssetExporterPlugin,
  4. IObject3D,
  5. LoadingScreenPlugin,
  6. SceneUiConfigPlugin,
  7. ThreeViewer,
  8. } from 'threepipe'
  9. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  10. import {GLTFDracoExportPlugin} from '@threepipe/plugin-gltf-transform'
  11. async function init() {
  12. const viewer = new ThreeViewer({
  13. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  14. msaa: true,
  15. plugins: [LoadingScreenPlugin, AssetExporterPlugin, SceneUiConfigPlugin, GLTFDracoExportPlugin],
  16. })
  17. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  18. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  19. setBackground: true,
  20. })
  21. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  22. autoCenter: true,
  23. autoScale: true,
  24. })
  25. ui.setupPluginUi(AssetExporterPlugin, {expanded: true})
  26. ui.setupPluginUi(SceneUiConfigPlugin)
  27. const model = result?.getObjectByName('node_damagedHelmet_-6514')
  28. const config = model?.uiConfig
  29. if (config) ui.appendChild(config)
  30. }
  31. init().finally(_testFinish)