3

I would like to rotate my camera 90 degrees around the scene. I have tried using

cosole.log(camera.position);

and setting the camera to my desired position that I have seen in the log but this simply won't work.

This is how the camera is initialized (for the first image):

var width  = window.innerWidth,
    height = window.innerHeight;
var camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 1000);
camera.position.set(0, -22, 22);

That's what I have:

enter image description here

That's what I would like to have (90 degrees counter-clockwise camera turn):

enter image description here

EDIT

I have noticed that I can rotate the object itself (: doing this :

plane.rotation.z = 90 * Math.PI / 180;

but I am still curious how to achieve the same effect with rotating the camera.

1 Answer 1

2

You have to move the camera position in a circle, the lookAt position should be the object or scene:

var rotSpeed = .02 
camera.position.x = x * Math.cos(rotSpeed) - z * Math.sin(rotSpeed);
camera.position.z = z * Math.cos(rotSpeed) + x * Math.sin(rotSpeed);
camera.lookAt(scene.position);

That's clockwise, for the other direction swap the plus and minus.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.