# How to set world rotation for a transformNode with multiple hierarchy nodes?

Hi everyone, a gltf file has numbers of node , and some meshes inside transformNodes. One of those i want to set it to one world rotation. That mesh has parent, and the parent has parent…
I think it need to set world rotation zero first, then Mesh.rotation = WorldRotation. How can i solve it?

Assuming the mesh you want to set rotation starts with (0, 0, 0), if not you would need to add the rotation offset.

First you can get absoluteRotation as Quaternion:

``````var worldRotationQuat = mesh.absoluteRotationQuaternion
``````

Now you can convert to euler angles (rotation-Vector3):

``````var worldRotation = worldRotationQuat.toEulerAngles()
``````

Then set rotation of mesh to your calculated rotation difference/delta:

``````var wantedRotation = ... // set your wanted world rotation
mesh.rotation = wantedRotation.subtract(worldRotation) // local rotation
``````

It would also work to multiply worldRotationQuat.invert() onto BABYLON.Quaternion.FromEulerVector(wantedRotation). Then convert back to euler vector.

Or do this via world matrix of mesh and TransformNormal, when you are into the math, to localize wanted rotation:

4 Likes