html - 播放一次动画而不是循环播放 three.js

标签 html animation three.js blender

我已经将 blender JSON 动画导出到 THREE.js 中, 一切正常,但我只想播放一次动画然后停止而不是循环播放动画。

最佳答案

老问题,但如果有人需要它,解决方案是设置 animation.setLoop(THREE.LoopOnce)

let objLoader = new THREE.ObjectLoader();

objLoader.load('./your.json', function(obj)
{
  scene.add(obj);

  let animationMixer = new THREE.AnimationMixer(obj);
  let animation = animationMixer.clipAction(obj.animations[0]);
  animation.setLoop(THREE.LoopOnce);
  animation.clampWhenFinished = true;
  animation.enable = true;

  animation.play();
})

我指的是 ThreeJS r84

关于html - 播放一次动画而不是循环播放 three.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33959167/

相关文章:

javascript - 联络表格无法正常运作

javascript - 如何隐藏所有内容,直到用户搜索此表中的特定元素?

android - 如何在 Unity 中制作二维动画

jquery 过境动画和 .stop() fx 队列

html - 为什么我的 CSS 菜单在下拉菜单上有重叠的文字

javascript - Chrome 自动填充值无法反射(reflect)在 jQuery 中

android - Espresso 测试禁用动画

javascript - 球体对象的 three.js 外发光?

three.js - 在three.js中模型导入后智能居中和缩放

javascript - 三.js中node.applyMatrix4不是函数