Graphics Reference
In-Depth Information
Rotating the camera around a scene
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.
Getting ready
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.
How to do it...
To accomplish this, we only need to perform a couple of very simple steps:
1. The first thing we need to do is create THREE.PerspectiveCamera and po-
sition it somewhere in the scene:
// create a camera, which defines where
we're looking at.
camera = new
THREE.PerspectiveCamera(45,window.innerWidth
Search WWH ::




Custom Search