Rotation by world matrix

I can’t remember how all that code works any more. it was written in a rabbit hole refactoring moment.

But the general idea is,

You have an objectA in the scene, and you want it rotated x,y or z.
Create a new Object3D and attach your objectA to it.
Rotate the Object3D x,y or z.
Then detach the objectA, by attaching it back to the scene.
Reset the empty Object3D so it doesnt accumulate rotations and become gimbal locked in case you want to use it again.

if you want to rotate objectA again in some other rotation.
position the Object3D at desired center of rotation,
attach objectA to it
rotate the Object3D
detach objectA by attaching it back to the scene.

Object3D.attach → Adds object as a child of this, while maintaining the object’s world transform.

1 Like