Adding a global timescale

Presently, you might have already noticed that both our scripts, Spin and Orbit, have a gametimePerDay variable that does the same thing--defines the number of game seconds that correspond to an earth hour.

No one writes code without expecting to change it. Programming is a dynamic art as you rethink how to do things, as requirements grow, and problems get fixed. Sometimes, these changes are not necessarily to add a new feature or fix a bug but to make the code cleaner, easier to use, and easier to maintain. This is called refactoring, when you change or rewrite parts of a program but do not necessarily change what it does, that is, its behavior.

Let's refactor our code to remove this duplication and put this variable ...

Get Augmented Reality for Developers 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.