Getting Started

Create a new project in the 3DE Code Editor. Use the 3D starter project template and call it Planet Functions.

The first step in creating 100 planets is to create one planet. After the line that says START CODING ON THE NEXT LINE, add the following:

​ ​var​ shape = ​new​ THREE.SphereGeometry(50);
​ ​var​ cover = ​new​ THREE.MeshBasicMaterial({color: ​'blue'​});
​ ​var​ planet = ​new​ THREE.Mesh(shape, cover);
​ planet.position.​set​(-300, 0, 0);
​ scene.add(planet);

At this point in the book, we have a good idea what that code will do before we even start typing. It creates a somewhat large ball, wraps it in blue material, and moves it off to the left side of the screen.

That’s one ...

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.