The Sun, Earth, and Mars

Since we’re dealing with space, we need to adjust the usual camera and switch the renderer. We make these changes to the code that is above START CODING ON THE NEXT LINE.

Create the camera so that it can see as far away as 1e6, which is a short way of writing 1 with six zeros following it, or 1,000,000. Also, move the camera 1000 away from the center of the screen.

 
// This is what sees the stuff:
 
var​ aspect_ratio = window.innerWidth / window.innerHeight;
 
var​ camera = ​new​ THREE.PerspectiveCamera(75, aspect_ratio, 1, 1e6);
 
camera.position.z = 1000;
 
scene.add(camera);

One other change that we’ll make is to switch to the WebGLRenderer like we did in Chapter 12, Working with Lights and Materials.

 
// This will ...

Get 3D Game Programming for Kids now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.