播放动画一次而不是循环three.js [英] play animation once instead of looping three.js

查看:1725
本文介绍了播放动画一次而不是循环three.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Blender JSON动画导出到THREE.js中,
一切正常,但是我只希望播放一次动画并停止而不是循环播放动画。

I have exported blender JSON animation into THREE.js, everything works fine, but I want to play the animation only once and stop instead of looping the animation.

推荐答案

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

Old question, but in case anyone needs it the solution is to set animation.setLoop( THREE.LoopOnce )

let objLoader = new THREE.ObjectLoader()

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

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

  animation.play()
})

我指的是ThreeJS r84

I'm referring to ThreeJS r84.

这篇关于播放动画一次而不是循环three.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆