Question

Say I have a big cube with some objects on each of the faces (a bit like the google maps cube http://www.playmapscube.com/). I would like to be able to use the arrow keys to rotate the camera around the cube, instead of rotating all the objects individually.

So the left arrow will move the camera to the left, thus the cube would be turning right, and so on.

I've looked all over and didn't find anything about doing it with the keyboard.

Was it helpful?

Solution

Based on your comment, I am assuming this is just a math question.

Use the arrow keys to change the value of a variable theta, then in your render loop do something like this:

camera.position.x = 15 * Math.cos( theta );
camera.position.y = 10;
camera.position.z = 15 * Math.sin( theta );

camera.lookAt( scene.position );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top