Graphics Reference
In-Depth Information
How to do it...
To zoom the camera to an object, we need to take the following steps:
1. The first thing we need to do is create and position the camera that we use
to zoom in:
camera = new
THREE.PerspectiveCamera(45,
window.innerWidth / window.innerHeight,
0.1, 1000);
// position and point the camera to the
center of the scene
camera.position.x = 15;
camera.position.y = 15;
camera.position.z = 15;
camera.lookAt(scene.position);
As you can see, this is a standard THREE.PerspectiveCamera object, to
which we give a position and add to the scene.
2. To zoom in with the camera, we first need to determine the distance from the
camera to the object and its height:
// create an helper
var helper = new
Search WWH ::




Custom Search