Code: Build Your Own Solar System

This is the final version of the solar-system code from Chapter 13, Project: Build Your Own Solar System.

 
<body>​</body>
 
<script src="http://gamingJS.com/Three.js​"></script>
 
<script src="​http:​//gamingJS.com/ChromeFixes.js"></script>
 
<script>
 
// This is where stuff in our game will happen:
 
var​ scene = ​new​ THREE.Scene();
 
 
// 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);
 
 
var​ earth_cam = ​new​ THREE.PerspectiveCamera(75, aspect_ratio, 1, 1e6);
 
scene.add(earth_cam);
 
 
var​ camera = 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.