 # getWorldDirection() \ get vectors directed at 90 degrees

Hello!
This way I get the direction the camera is looking and move the element in the same vector.
const dir = new THREE.Vector3();
function moveForward() {
camera.getWorldDirection(dir);
}
The question is how to get a vectors directed at 90 degrees to the left and to the right?

You can compute the intended vectors in two steps. Since you already have the forward vector in world space (the look direction), you need the up vector in world space. If you don’t change `Object3D.up`, the value in local space is `(0,1,0)`. You can transform this vector with the world matrix of the object like so:

``````const up = new Vector3();
up.copy( object.up ).applyMatrix4( object.matrixWorld ).normalize();
``````

You can now compute the right vector with the cross product:

``````const right = new Vector3();
right.crossVectors( forward, up ).normalize();
``````

Negating this vector or changing the order of parameters will output the opposite direction.

2 Likes

Thanks a lot! perfectly working!