 # How to make the camera face 90 degrees to left/right/up/down

Hello, I’m trying to rotate my camera 90 degrees to any direction, but so far I couldnt find anything that works… I`ve tried using vectors and quarternions, also used the lookat method…

If you could please give me some help.

Could you describe what you tried and what the issue for you is? You might didn’t converted degrees to radians
`camera.rotation.y = 90 * THREE.Math.DEG2RAD;`

2 Likes

First I get the camera where I want on the model:

``````    var targetVector = new THREE.Vector3(20.05189148109836, 0.8128237235370566, -1.0318133098417155);
var positionVector = new THREE.Vector3(9.492252384559986, 0.8128237235370566, -1.0318133098417155);
var upVector = new THREE.Vector3(0, 0, 1);
nav.setTarget(targetVector);
nav.setPosition(positionVector);
nav.setCameraUpVector(upVector);
``````

This works fine, the camera goes to where I want.

Here are some const:

``````      const angle = 90;
const theta =  angle * Math.PI / 180; //Angle in radians
``````

Now I need to rotate the camera 90 degrees to the right…

``````    var posX = new THREE.Vector3(1, 0, 0);
setTimeout(function () { //Start the timer
//var axis = new THREE.Vector3(1, 0, 1);
const matrix = new THREE.Matrix4().makeRotationAxis(posX, theta);
targetVector.setX(targetVector.x + 45);
targetVector.applyMatrix4(matrix);
nav.setTarget(targetVector);
//nav.

}.bind(this), 1000);
``````

This doesn`t work… I tried your code too, but it does nothing… Probably because of the Forge encapsulation of the camera…

Now I’m trying something with quartenions… Oh my god why this is so hard?

Im not sure what is going on in your code, what is `nav`? Did you tried
`camera.rotateY( 90 * THREE.Math.DEG2RAD )`

4 Likes

That`s a navigation object used by the forge viewer (the forge viewer uses threejs), that`s why i need to use their object structure and probably that`s why your code doesn`t work with me =/

Trying this:

``````const angle = 90;
const theta = 5* angle * (Math.PI / 180);
var posX = new THREE.Vector3(-1, 0, 0).normalize();
var quaternion = new THREE.Quaternion();
quaternion.setFromAxisAngle(posX, theta);
targetVector.applyQuaternion(quaternion);