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ů.

script.ts 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {_testFinish, CameraViewPlugin, HDRiGroundPlugin, ThreeViewer} from 'threepipe'
  2. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  3. async function init() {
  4. const viewer = new ThreeViewer({
  5. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  6. msaa: true,
  7. dropzone: {
  8. allowedExtensions: ['gltf', 'glb', 'hdr', 'bin', 'png', 'jpeg', 'webp', 'jpg', 'exr'],
  9. addOptions: {
  10. disposeSceneObjects: true,
  11. autoSetEnvironment: true, // when hdr is dropped
  12. autoSetBackground: true,
  13. },
  14. },
  15. plugins: [CameraViewPlugin],
  16. })
  17. const hdriGround = viewer.addPluginSync(HDRiGroundPlugin)
  18. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  19. setBackground: true,
  20. })
  21. await viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  22. autoCenter: true,
  23. autoScale: true,
  24. autoScaleRadius: 10,
  25. })
  26. viewer.scene.background = 'environment' // this is not really required since setBackground is also set to true above
  27. hdriGround.worldRadius = 50
  28. hdriGround.tripodHeight = 10
  29. const bounds = viewer.scene.getBounds(true, true)
  30. bounds.getCenter(hdriGround.originPosition)
  31. hdriGround.originPosition.y -= (bounds.max.y - bounds.min.y) / 2
  32. hdriGround.enabled = true
  33. console.log(hdriGround)
  34. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  35. ui.setupPluginUi(HDRiGroundPlugin)
  36. await viewer.fitToView(undefined, 2.5)
  37. }
  38. init().then(_testFinish)