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.