threepipe
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

script.ts 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. async function init() {
  11. const viewer = new ThreeViewer({
  12. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  13. msaa: true,
  14. plugins: [LoadingScreenPlugin, AssetExporterPlugin, SceneUiConfigPlugin],
  15. })
  16. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  17. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  18. setBackground: true,
  19. })
  20. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  21. autoCenter: true,
  22. autoScale: true,
  23. })
  24. ui.setupPluginUi(AssetExporterPlugin, {expanded: true})
  25. ui.setupPluginUi(SceneUiConfigPlugin)
  26. const model = result?.getObjectByName('node_damagedHelmet_-6514')
  27. const config = model?.uiConfig
  28. if (config) ui.appendChild(config)
  29. }
  30. init().finally(_testFinish)