How to find the total number of frames of a skeleton animation?

Ah, now I get your idea. But I think it’s not the case, and here’s my reasoning.

If you were right the final VAT animation would be jerky, since say frame 29 will be almost identical to frame 30, since beginAnimation takes a frame number and not time. At least visually I can’t see something this effect. Unless I got exceptionally unlucky, since I’m exporting a GLB with blender with default settings just like a lot of people must have done so far, this would have been an issue with any code using beginAnimation() and people would have noticed the issue before.

Of course something is wrong, and hopefully it’s just me and not a bug. But I still need to find what is going on.

Unless the beginAnimation frames are tied to a specific time each, instead of being sampled at a uniform 30fps? If so, is there a better way to sample animations with another method?

Let see if our rockstar @Evgeni_Popov would have a better idea ?

I think your problem is that there are no animations directly on the mesh, it is instead an animation group which is defined on the scene which holds the anims. So mesh.beginAnimation() won’t work, you must use scene.animationGroups[0].start(true, 1, 0, 40); instead:


I see. So those 91 frames are just a random number essentially, with VertexAnimationBaker capturing frames animated by the group and not beginAnimation. Thank you @Evgeni_Popov, you’re always saving me.

Since this needs a proper fix on VertexAnimationBaker.bakeVertexData() (I’ll write a PR for it), is there a standard way to handle animations? If this baffled you Jedis here, it’ll be confusing for users to provide two bakers, one for animation groups and one for skeletons. Any suggestions on a general solution/API for the baker?

1 Like

I’m not knowledgeable enough on the animation front to know how to best handle the different cases…

It does seem we would need the baker to also be able to take an animation group / a list of animation groups.

1 Like

Who could I bother to learn more about animations? I could also see if it’d be possible to integrate VAT with the animation code.

I can probably help if you want to summarize your questions here :wink:

Of course! Context: I want to make sure that VertexAnimationBaker works properly. The current code assumed that mesh.beginAnimation() would always work, but from this thread and the PG it also needs to handle animation groups. As an user it’s confusing to know which one I have – I just want to load the model, bake the animation and use it.


  1. Is there a standard to get the total number of frames of an animation, independent of it being an animationGroup or a mesh animation? Are these the two only possible ways to animate a mesh? Getting the total number of frames is useful to “just bake that model I loaded”.
  2. Is there a standard way to play animations? scene.animationGroups[0].start() handles animation groups, and mesh.beginAnimation() handles animations on the mesh. Is there a unified API?
  3. If there’s no unified API, I think it might be possible to have both animation groups and a mesh animation, right? What would be a good approach to handle the animation for both scenarios?

PR will come for the Baker once I understand this. Thanks a lot for the patience :slight_smile:

Alright! Let me try to step back a bit

Animation groups are a set/an array of targetedAnimations. A targetedAnimation is an Animation with a target (Captain obvious) meaning it is an animation with something to animate

An animation is by essence a simple list of key/values. It is not functional by itself. It requires a target to apply its values to

When you start an animation on a mesh for instance, an Animatable is started. It will keep track of all the RuntimeAnimations running on the mesh (it will make them in sync, etc…). A RuntimeAnimation is referring to an animation, a target and all the info regarding the animation state (active key, interpolation, etc…)

That being said, to your questions :wink:

  1. For a given mesh, you can check scene.animatables array looking for the animatables aiming your mesh (in animatable.getAnimations() which returns a list of RuntimeAnimation where the target is on It could be something you can consider convoluted but if you think about it we need the animation template (The Animation class), the Animatable (list of all the runtime animation running from a user call) and then the active interpolation system (the RuntimeAnimation)
  2. No unified APi because they are not doing the same. An animation group is a group of animations, meaning that an animation group can execute animation of several targets. mesh.beginAnimation() will only start the animations stored on the mesh (in mesh.animations)
  3. Yes totally, you can have some animations for your mesh in an animation group and also some animations attached to a mesh. I would recommend that you build your Baker with a requriement: THis is up to the user to give you the animations they want to bake. Because I may have several animations in my animation groups but I may not want to bake all of them anyway

Hope this helps