Blender vs BJS angles

Hi there!

I have a problem with difference between blender and BJS angles.
In blender I have rotation of the object:

-0.754511
-1.02974
1.46608

I write this data to JSON following way:

"rotation": {
    "x": -0.7545109987258911,
    "y": 1.4660764932632446,
    "z": 1.029744267463684
},

Because in BabylonJS I use Right handled system

When I use rotation with single component x or y or z everything is fine and object in babylon rotates as it should be. But when I use 3 components something happening and rotation of the object in babylon are not corresponding to rotation of the object in blender.

I rotate babylon object by following way:

ret.rotate(new Vector3(0,1,0), place.rotation.y,Space.LOCAL);
ret.rotate(new Vector3(1,0,0), place.rotation.x,Space.LOCAL);
ret.rotate(new Vector3(0,0,1), place.rotation.z,Space.LOCAL);

where place.rotation is the rotation from JSON

I also tried to do it like that:

rotQ = Quaternion.RotationYawPitchRoll(place.rotation.y,place.rotation.x,place.rotation.z);

So I dont understand what happening. If somebody can please help me :pray:

I also notify that blender mode of rotaion is XYZ but in BJS YXZ. How i can convert it?

Problem was solved by transformation of euler angles from XYZ to YXZ on side of blender python. You can do it in following way:

current_rot = obj.rotation_euler
quat = current_rot.to_quaternion()
yxz_rotation = quat.to_euler('YXZ')
1 Like