July 2018
Beginner to intermediate
374 pages
8h 54m
English
We’re going to make a new function to move and rotate the Earth. We could put this inside the animate() function, but separating game or simulation code from animation code will make our code more flexible. Game programmers often refer to this as separating game logic from animation code.
The properties that we’ll control in this simulation are the speed at which it runs, whether or not the simulation is paused, and the number of days that have passed inside the simulation. We’ll also need another internal clock to help track the time inside the simulation.
Add the following at the very end of our code, below the call to animate():
| | var speed = 10; |
| | var pause = false; |
| | var days = 0; |
| | var clock2 = new THREE.Clock(); ... |
Read now
Unlock full access