Hello!
I’ve been learning about skeletal animation and while trying to implement it in Babylon, I’m facing a strange issue: I was able to create a skeleton and assign it to some meshes, but as soon as I do this the geometry seems to “explode” (for lack of a better word).
Here is a Playground to demonstrate what I mean: After 5 seconds it will begin the animation, but you can disable this to see just the mesh geometry on its own (it looks right).
As a side note, I wasn’t able to import all the animations so it’s expected to look a little bit off, but not THAT much. For me locally it looks very similar; here’s a short video showing both my rendition and how it is supposed to look when animated. The same “repositioning” problem is still present, however, and I’m unsure what’s causing it.
As soon as skeletons are disabled, the mesh looks “almost right” so it must be the bone influences messing it up. Since the skeleton and bone animation itself looks correct, the geometry must be mapped incorrectly or use the bone weights wrongly perhaps. The values themselves should be correct, as I have verified them manually (head attaches to head bone etc, checking boneWeights with the inspector), and they were also exported as-is on my end.
My guess is that the bone’s initial position isn’t filtered: If the “head” geometry is attached to the “head” bone (second from the top), I would expect the geometry to move only very slightly if that is the only bone influence. Instead, the individual parts move all over the place.
I’ve spent several days trying to find the root cause of this issue, but I can’t seem to get anywhere. It feels like I don’t understand enough about how the skeleton/bone/mesh interaction is supposed to work in BJS, since it clearly doesn’t quite do what I expected it to.
Here’s just a few things I’ve tried (that I can think of):
-
skeleton.setCurrentPoseAsRest()
(no discernible effect) -
mesh.applySkeleton()
(messes it up even more) -
skeleton.needsSkinMatrix
(no effect) - Creating a
parentMesh
and anchoring the others to it (does nothing) -
MergeMeshes
(didn’t help)
Perhaps you’ve seen something similar before or could point out some ways how to better debug this kind of problem? As always, thank you for your time and expertise!