Earth-Cam!

Let’s add the ability to watch the planet Mars from Earth. As you watch Mars from Earth over several months, Mars’s position in the sky changes in a pretty strange way. It’s so strange that ancient astronomers couldn’t explain it. But we’ll be able to.

To watch Mars from Earth, we’ll need another camera besides the one looking down on our solar system. So the first thing we need to do is give our above-the-solar-system camera a better name. Let’s call it above_cam. Change camera to above_cam at the top of your code:

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

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