Change coordinate origin

Hi all,

Now I have an object: position[world coordinate] = {a, b, c}
rotation[world coordinate] = {x, y, z}
And If I want to move the coordinate origin from{0,0,0} to {1,2, 3}, I need to get the new {a’, b’, c’} and {x’, y’, z’}.
Is there any method that I can use?

Thanks for your help!!

You could add the object to an instance of THREE.Group, put this group to (1,2,3) and then use Object3D.getWorldPosition() and Object3D.getWorldQuaternion() on your object to retrieve the position and orientation in world space.

Another, a bit more performant option is to grap the world matrix of your object (after adding it to your translated group) and use Matrix4.decompose().

In both cases, you have to ensure the world matrices of the object hierarchy are up-to-date. You can always enforce this by calling group.updateMatrixWorld().

1 Like