The Sun at the Center

You’re getting to be an expert with 3D objects, so you know the drill. Below the START CODING line, let’s create a cover and a shape, combine them in a mesh, and add it to the scene.

​ ​var​ cover = ​new​ THREE.MeshPhongMaterial({emissive: ​'yellow'​});
​ ​var​ shape = ​new​ THREE.SphereGeometry(50, 32, 16);
​ ​var​ sun = ​new​ THREE.Mesh(shape, cover);
​ scene.add(sun);

Now that we have a better understanding of these things from Chapter 12, ​Working with Lights and Materials​, we’re using a Phong material for the Sun. This lets the Sun emit yellow light—so it can glow yellow.

The Sun has to do more than glow. It has to shine light on everything else in the solar system. ...

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.