In Chapter 2, Geometries and Meshes, we already showed you a number of recipes that explained how to rotate objects. In this recipe, we'll show you how to rotate the camera around a scene while the camera will keep looking at the center of the scene.
For this recipe, we'll use the standard THREE.PerspectiveCamera
object, which we rotate around a simple scene. To see the final result, open the 03.08-rotate-camera-around-scene-y-axis.html
example in your browser.
On this web page, you can see that the camera rotates around the scene while the floor, box, and lights stay at the same position.
To accomplish this, we only need to perform a couple of very simple steps:
The first thing we need to do is create
THREE.PerspectiveCamera
and position it somewhere in the scene:// create a camera, which defines where we're looking at. camera = new THREE.PerspectiveCamera(45,window.innerWidth / window.innerHeight, 0.1, 1000); // position...