GLTF/GLB skeletal Bone setRotationQuaternion in world space

Hello there, I have recently started coding in babylon.js and I think it is a fantastic engine.

I have a question regarding loaded GLTF/GLB files and the setting Quaternion rotation on the bones.

I have read enough to understand that these calls do not work as each bone is actually driven by a TransformNode, but I am unable to find the correct way to set the rotation of the TransformNode from a world space quaternion.
My understanding is that calling element.getTransformNode().rotationQuaternion = new Quaternion Value, is setting the Transform rotation in local space and not world space. Is this correct?
How would I go about rotating the underlying bones in various spaces?

Welcome aboard!

Yes, the transformation of a bone is in local space. If you have a world matrix W for a transform node and want to convert it to local, you need to do something like Wparent_inv*W where Wparent_inv is the inverse world matrix of the parent node of this transform node (or maybe it is W*Wparent_inv, never know which is the right one…). Note that If you have a quaternion, you should convert it first to a matrix.

1 Like

Cool, thanks for the info. I am only dealing with the rotations rather than the full transformation matrix, but I believe the principle of multiplying by the inverse quaternion of the parent still stands.
Thanks :+1: