threepipe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

script.ts 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {_testFinish, _testStart, GLTFAnimationPlugin, ICamera, LoadingScreenPlugin, ThreeViewer} from 'threepipe'
  2. async function init() {
  3. const viewer = new ThreeViewer({
  4. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  5. msaa: true,
  6. dropzone: {
  7. allowedExtensions: ['gltf', 'glb', 'hdr', 'bin', 'png', 'jpeg', 'webp', 'jpg', 'exr'],
  8. addOptions: {
  9. disposeSceneObjects: true,
  10. autoSetEnvironment: true, // when hdr is dropped
  11. },
  12. },
  13. plugins: [LoadingScreenPlugin],
  14. })
  15. const gltfAnimation = viewer.addPluginSync(GLTFAnimationPlugin)
  16. gltfAnimation.autoplayOnLoad = false
  17. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  18. const result = await viewer.load('https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Blender-Exporter@master/polly/project_polly.gltf', {
  19. autoCenter: true,
  20. autoScale: true,
  21. })
  22. console.log(result)
  23. const fileCamera = viewer.scene.getObjectByName<ICamera>('Correction__MovingCamera')
  24. if (!fileCamera) return
  25. fileCamera.autoAspect = true
  26. fileCamera.userData.autoLookAtTarget = false
  27. fileCamera.activateMain()
  28. gltfAnimation.loopAnimations = true
  29. gltfAnimation.playAnimation() // note no await here.
  30. console.log(gltfAnimation)
  31. }
  32. _testStart()
  33. init().finally(_testFinish)