4
votes

I created an animation in Blender with armature rigging. When I test it in Blender by pressing Alt-A, it works perfectly fine. However, when I export it as a .glb using the KhronosGroup GLTF exporter, the resulting animation is distorted (e.g., limbs are disconnected and moving in a weird way).

Why is this happening (and how can I fix it)?

For the past two days, I have been trying solutions from similar questions (such as applying location/rotation/scale with Ctrl-A, or deleting the Armature modifier on the mesh) but none of them have worked for me.

Links:

Here is a link to a screen-recording of what the animation should look like (this is me playing it in Blender): https://github.com/kylejlin/hosting-for-my-stackoverflow-questions/blob/master/correct-animation.mov

Here is a link to a screen-recording of what the animation actually looks like (this is me testing the exported .glb in the browser with Three.js): https://github.com/kylejlin/hosting-for-my-stackoverflow-questions/blob/master/distorted-animation.mov

Here is the .blend file: https://github.com/kylejlin/hosting-for-my-stackoverflow-questions/blob/master/soldier.blend

Here is the exported .glb file: https://github.com/kylejlin/hosting-for-my-stackoverflow-questions/blob/master/soldier.glb

2
What version of Blender are you exporting with? I just attempted to export via 2.79 but get some errors that look like they are related to custom properties or something.. but 2.79 isn't neccesarily the latest... The only other red flag that stands out to me is that your mesh is using a mirror modifier to mirror the halves of the mesh... Sometimes the act of applying that modifier during export, doesn't work. Other than that, I can't see anything super obvious, but I would just advise patience because animation can be a nightmare to get working :Dmanthrax
Also, in the "related questions" on the right... i saw this: stackoverflow.com/questions/13518856/… Which suggests inserting a full keyframe for the armature at the beginning of the animation. Not sure if that implies that the key frame should be the bind post or not, but maybe there is some useful hints in there. It also suggests removing the armature modifier before exporting.. but then I don't really understand how the loader will know how to bind it again, so ymmvmanthrax

2 Answers

5
votes

I looked at your setup a bit more.. I see you have a few IK bones that are partially driving the animation. Those won't translate correctly, and will have to have the IK baked into the animation. I also investigated the mirror modifier and realize the problem there.. to get the mirrored object to export, you have to click the "apply modifiers" checkbox, but that ALSO applies the Armature modifier, which distorts the mesh so you get the wrong mesh out. To fix that you have to apply the mirror modifier manually in blender, then export Without "apply modifiers" checked. Once you do that, and once you bake the IK into the animation, you might get it to work.

I've done the IK baking in the past but forget exactly how it works, but here's a starting point: https://blenderartists.org/t/bake-ik-to-fk/587226

fwiw Here is the .glb when I pre-applied the mirror modifier.. notice the arms animate correctly now, but the legs/feet are still screwy because of the IK. I didn't figure out how to bake that yet...

https://drive.google.com/open?id=1zeA-mMirOWYZHlzdURqNnykgh_g10kbr

0
votes

enter image description h`ere

Set Object's transformation values:0 before Rig.