Hello, I’m trying to figure out how to access/play/stop an AnimationGroup directly from a .glb mesh object, rather than the scene.AnimationGroups object.
The end goal is to write something like scene.beginDirectAnimation(importedMesh, attackAnim1, 0, 25, false)
and play the animation on that specific mesh. Later, I will need a different animation, so I would do scene.beginDirectAnimation(importedMesh, defendAnim1, 0, 25, false)
and so on.
PG example using AnimationGroups so you can see what sort of mesh/mesh construction I’m referring to:
I have the following constraints:
-
The .glb is exported via Blender. Each animation is on a different NLA track in Blender.
-
In my final app, I will have multiple humanoid meshes, and they will have different animations. It is unlikely that any raw animation data will be shared across meshes. However, NLA tracks will have the same name on different humanoid meshes, so filtering AnimationGroups by name is probably a lost cause?
-
Since these are humanoid figures, each AnimationGroup contains numerous targetedAnimations that move individual parts of the parent mesh. I watched a tutorial here: Demystifying Animation Groups - YouTube about combining these, but for my use case it seems infeasible to collapse all targetedAnimations into one AnimationGroup, for the aforementioned reason that they need to play separately at different times. A humanoid mesh will sometimes attack, sometimes defend, etc. and there are several hundred targetedAnimations in a single group.
-
Assigning individual animations to the .glb with something like
importedMesh.animations[0].setKeys(myKeyArray)
also seems infeasible, as there are a lot of meshes+values manipulated for every animation, and I won’t really be able to keep track of the individual lengths/frames in a larger scale scene. -
Animations will need to blend together smoothly, most likely accomplished with animation weights like shown here: https://playground.babylonjs.com/#IQN716#9 . However, with multiple humanoid meshes each with individual skeletons, it doesn’t appear it would be possible to tell them all apart. Skeletons will necessarily have generic/shared names.
Is there any strategy that allows for accessing these animations simply from the imported parent mesh? Perhaps I’m understanding something incorrectly in BabylonJS or even Blender, but I haven’t been able to find a solution. Thanks for your attention on this.