Bonus #2: Flight Controls

Where’s the fun in scattering a bunch of planets around if you can’t fly through them, right?

Fly controls are much more complicated than they might seem—very much more complex than the controls we’re building for our avatar. So we’ll load in new controls instead of writing our own. All the way at the top of our code, add a new <script> tag to load in FlyControls.js.

​ <body></body>
​ <script src=​"/three.js"​></script>
»<script src=​"/controls/FlyControls.js"​></script>

We’ll talk more about loading code like that in Chapter 9, ​ What’s All That Other Code?​.

Loading the code is only half of the job. The other half is using it. To do that, add the following below the rColor() function, ...

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.