How to get the current frame number of model animation?

I have a model with sequential frame animation, such as 0-100 frames.
Now when I play 50 frames with AnimationAction.play(), then it stop.

How to get 50 by attributes or methods?

image

This is my code with AnimationAction.


image

frames aren’t really all that useful, because the animation system works with curves instead of frames. In other words, the animation system is not working in discrete time (frames) but in continuous time instead.

That being said - you can approximate the frame index from the current animation time.

Let’s say that your animation has 100 frames, and lets say that you exported your animations with 24FPS setting, this means that 1 second of animation would cover 24 frames. So when you play the animation in three.js, you can check the current time and derive the frame number from that, like so:

const FRAME_RATE = 24;

cosnt animationTime = animationMixer.time;

const frameIndex = Math.floor(animationTime*FRAME_RATE);
1 Like

Thank you very much. It helps me a lot.

1 Like