Initial positions of joints not applied when GLB bone animation is played on model from separate file

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?:

let bones=[]
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
bones.forEach(bone=>{
bone.updateMatrix();
let targetBone = targetAnimationScene.getObjectByName(bone.name);
targetBone.matrix.copy(bone.matrix);
bone.matrix.decompose(targetBone.position,targetBone.quaternion,targetBone.scale);
})

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.

1 Like

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!