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