Using Cameras to Capture the Scene

Scenes do a great job of keeping track of everything, but they don’t show us what’s happening. To see anything in the scene, we need a camera. Notice the following code in 3DE:

​ ​// The "camera" is what sees the stuff:​
​ ​var​ aspectRatio = window.innerWidth / window.innerHeight;
​ ​var​ camera = ​new​ THREE.PerspectiveCamera(75, aspectRatio, 1, 10000);
​ camera.position.z = 500;
​ scene.add(camera);

This takes what’s in the scene and shows it on our computer screens.

The purpose of the aspectRatio is to determine the shape of the browser window. This is the same thing as aspect ratios for movie screens and TV sets. A large TV with a 4:3 aspect ratio might be four meters wide ...

Get 3D Game Programming for Kids, 2nd Edition 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.