I am loading an animation on to a base model which is in a standard position. The animation file contains some bones which are static and thus have no animation frames, however they are posed in different positions/rotations.
As I’m only applying the animation when loading the animation, the bones without an animation will not get moved into place. The animation file contains the correct position for those bones but they are not being applied as it’s not part of the animation.
Is there a way to set the initial position of bones from the animation file before playing the animation? Or is there another way to approach this? My animator has already tried to bake all keys for each bone in Maya however I think that is getting lost in the conversion between that output from FBX to GLB.
Maybe something like this?:
baseAnimationScene.traverse(e=>e.isBone && bones.push(e)) //Find all the bones
//For each bone, find the same bone in the target scene, and copy the transform
let targetBone = targetAnimationScene.getObjectByName(bone.name);
Hey @manthrax , thank you so much for your help. I was able to get it working with your suggestion (with a few tweaks)!
What is strange is that I found out my model file which contains the mesh does not have the bones in the scene so I was unable to find the target bone in the model. I had to instead iterate through the nodes and map the matrixes like in your code to the corresponding node. Now I wonder how the animation is being played in the first place–is there a bug in the scene object causing it to miss the bones or is the animations just being ran on the nodes.
Cool! Glad you got it working! Yeah that’s a little odd… but… the vertex->bone weights are stored on the mesh, so maybe that’s all the data needed to re-bind to the new skeleton?
I’m a bit surprised actually because in the past when I’ve tried to export a skinned mesh without its armature, the vertex weights didn’t alway export, so… glad that isn’t an issue for you!