July 2018
Beginner to intermediate
374 pages
8h 54m
English
We have a nice simulation of the Sun, Earth, and Moon from above the solar system. Let’s add a second camera to the scene so that we can switch the view from above the solar system to a view from the Earth. This will help us better understand the phases of the Moon.
Remember from the Getting Started part of this chapter that we named our current camera aboveCam. Let’s add moonCam, which will show the Moon from the Earth. Add the following code below the code for the Moon:
| | var moonCam = new THREE.PerspectiveCamera(70, aspectRatio, 1, 10000); |
| | moonCam.position.z = 25; |
| | moonCam.rotation.y = Math.PI; |
| | moonOrbit.add(moonCam); |
| | |
| | camera = moonCam; |
That last line assigns camera to our new moonCam. The animate() function uses ...
Read now
Unlock full access