Outline the Game

In addition to lights, this game will have a ball, a game board, and a goal. Let’s start with the following code outline, including the double slashes:

​ ​//var lights = addLights();​
​ ​//var ball = addBall();​
​ ​//var board = addBoard();​
​ ​//var goal = addGoal();​

Just as we did in Chapter 14, ​Project: The Purple Fruit Monster Game​, we’ll uncomment these function calls as we define the functions.

Add Lights

Before doing anything else, let’s add some lights to the scene.

Below the commented-out code outline, add the following function definition of addLights:

​ ​function​ addLights() {
​  ​var​ lights = ​new​ THREE.Object3D();
​ 
​  ​var​ light1 = ​new​ THREE.PointLight(​ ...

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.