I’ve been fighting with getting a player character animated and, as always, there are complications. I get that Blender often does things in its own special way but it’s quite frustrating that the process to export an animated character from Blender to glTF and import it into THREE.js is still flaky. Specifically, here’s what’s happening.
I made a character, based heavily on a model I found on opengameart.org. The model was not rigged so I rigged it in Blender and created a basic idle and run animation. As far as I can tell, the export to glTF and import into THREE.js in this simple case is perfect. The guy runs, I can see the animation names in the console, all is grand. I thought, though, “It would be nice if I could model equipment separately then just parent the equipment to different bones on the model and eventually I could change the parented equipment programmatically.” This is going to be necessary eventually, but for now I have punted and simply modeled a sword as part of the character’s base mesh. This is because parenting separate objects to a bone works perfectly inside Blender. The sword, in this case, moves right along with the hand to which it is parented with no issue but when I export the animation to glTF, things go funky. The sword’s orientation goes crazy and it becomes difficult to predict where the sword will actually appear in THREE.js.
I honestly believe this is just something I’m not grasping about Blender but it’s frustrating nonetheless for the animations to work great until I add in the twist of parented objects, then it goes wild. In order to move forward what I have now is good enough. You can tell the guy has a sword and once I create the attack animation you’ll be able to tell he’s swinging it with the intention of doing great violence. Eventually I’ll need to spend some real time with this, and possibly bring in some outside expertise to get everything working correctly, but for now I’m just going to move forward with what works and not worry about it.