threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {_testFinish, GLTFAnimationPlugin, ICamera, 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. })
  14. const gltfAnimation = viewer.addPluginSync(GLTFAnimationPlugin)
  15. gltfAnimation.autoplayOnLoad = false
  16. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  17. const result = await viewer.load('https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Blender-Exporter@master/polly/project_polly.gltf', {
  18. autoCenter: true,
  19. autoScale: true,
  20. })
  21. console.log(result)
  22. const fileCamera = viewer.scene.getObjectByName<ICamera>('Correction__MovingCamera')
  23. if (!fileCamera) return
  24. fileCamera.autoAspect = true
  25. fileCamera.userData.autoLookAtTarget = false
  26. fileCamera.activateMain()
  27. gltfAnimation.loopAnimations = true
  28. gltfAnimation.playAnimation() // note no await here.
  29. console.log(gltfAnimation)
  30. }
  31. init().finally(_testFinish)