How to set child object rotation using quaternion in world coordinates using ThreeJS



I am a newbie to ThreeJS and i am trying to set the rotation of the child objects by using Quaternion like the following.

But this rotation applies to the object in local coordinates. What i want is to apply rotation globally(in world coordinates).Any help would be much appreciated.


It seems you’ve missed some important aspects of scene graph hierarchy and nested coordinate systems. As you mentioned in your post you can only change the transformation (position, rotation, scale) of objects in their (local) coordinate space. The combined transformations along the object hierarchy gives the world transformation. So applying rotation “globally” to child objects makes no sense.


But you can still do it if you update the object’s matrixWorld yourself. You can look at the code for the setRotationFromQuaternion method to start learning how. But this is complicated. Object are transformed relative to parents. If you want the object transformed relative to the world, just make the object a child of the scene (scene.add(childObject)) and go from there, that’s easiest.