Unexpected bone rotations of skeleton from glb

Hi everyone,

I am getting weird rotations when importing a skeleton via glb into Babylon.

Actual problem

untitled.zip (163.3 KB)

This glb gets me different results when loaded into Blender and Babylon. The model does look the same on immediate import. But the bones, when zeroed, are completely different:


Why does this hapen?


It is not a bug in the inspector or so. I selected the gltf root node and closed the inspector. Then I ran this code in dev console:

debugNode.getDescendants().forEach((node)=>{
    node.rotationQuaternion = BABYLON.Quaternion.Identity()

})

Same result.


Background info (in case it is relevant)

  • Start: non-skeletal (unrigged) mesh in t-pose. Location, rotating, scaling all normalised.

  • Upload to mixamo**, re-rigged by them, download as new base fbx

    • **scale: 1, forward: -Z Forward, up: Y Up
  • Import new base fbx in Blender:

    • Meshes: root node is scaled and rotated, child mesh has inverse rotation and scaling of parent.
    • Bones: edit bones have arbitrary role. Pose bones all slightly rotated but at least close to zero. Zeroing the pose bones gets me back to original t-pose.
  • Export new base fbx to glb: normalise (bake tansforms) mesh transformations to 0-rotation and 1-scaling. This requires edit in hips bone (root) on location. This file is included above.

  • Import new glb into Blender: Meshes still normalised, bones with slight rotations. Zeroing the bones gets me back to original t-pose.

  • Import exact same new glb into Sandbox.Babylon: Except gltf root node, meshes still normalised, but bone rotation values completely different (n.b. “values”, visually the skeleton looks fine). Also, there are position changes as well now.

Best wishes
Joe

1 Like

There are significant rotation values for some bones, so you can expect their zeroing to completely change the pose :

I see the same thing in the PlayCanvas viewer, for example for the left shoulder bone:

(not the same values as us because of a different coordinate system, I think)

Can you check the rotation of the left shoulder bone? Is it really close to zero after importing the glb file? Given my observations above, it seems that the large values are really inside the file…

1 Like

Thanks @Evgeni_Popov for looking into this.

That was the important clue. And yes, indeed (json from glb):

These values coincide with the Sanbox values. So Babylon does it right. I would prefer the wrong Blender way though :grin:


FYI: While double checking, I at least figured out how to get to the “zeroed state”: in Babylon Inspector select the skeleton and hit the button “Return to rest”. This will get to the state in Babylon as it is in Blender with all bones zeroed. I think I can work with that.


For the sake of completeness.

import bpy
import mathutils
import math

print("============= CLS =========")

for pb in bpy.context.object.pose.bones:
    ea = mathutils.Quaternion.to_axis_angle(pb.rotation_quaternion)
    if ea[0][0] > 10 or ea[0][1] > 10 or ea[0][2] > 10:
        print(pb.name)
1 Like