Zooming the camera to an object
Usually, when you position a camera in your scene, you might move it around a bit or let it focus on different objects. In this recipe, we'll show you how you can zoom in to an object so that it almost fills the rendered view.
Getting ready
To zoom in, we use the standard functionality from the THREE.PerspectiveCamera
object. We've provided an example that demonstrates the result you'll get at the end of this recipe. To experiment with this example, open 03.02-zoom-camera-to-object.html
in your browser. You will see something similar to the following screenshot:
Initially, you'll see a small rotating cube in the center ...
Get Three.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.