How does one get the duration of an animation in three.js?
Let's say we have a sample like this one,
var mixer = new THREE.AnimationMixer(gltf.scene)
gltf.animations.forEach((clip)) => {
let animation = mixer.clipAction(clip)
animation.setLoop(THREE.LoopOnce)
animation.clampWhenFinished = true
animation.play()
}
The duration of your animation can be returned by clip.duration
, inside of the forEach loop. You can find out more about this on the three.js docs on the AnimationClip. Keep in mind that this is returned in seconds. https://threejs.org/docs/#api/en/animation/AnimationClip.duration
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.