When you are creating games or visualizations with many moving objects, you might want to have the camera follow an object around. Normally, when you create a camera, it points to a single position and shows you the scene that falls within its field of view. In this recipe, we'll explain how you can create a camera that can follow any of your objects around.
This recipe only makes use of core Three.js functions, so there isn't any need to include external JavaScript libraries in your source code. If you want to see the final result of this recipe, you can open 03.01-camera-follow-object.html
in your browser, and you'll see something similar to what is shown in the following screenshot:
In this example, you can see that the camera is focused on the sphere. As the sphere moves across the scene, the camera moves around to stay focused on the position of the sphere.