Animating the Spin

When we turn our avatar, it immediately faces a new direction. Let’s make it a little more realistic by animating a turn to the new direction. For that, we’ll need a new JavaScript code collection. We’ll talk more about code collections in the next chapter, Chapter 9, ​ What’s All That Other Code?​. For now, just think of them as a way to use code from somewhere else.

The code collection that we’re going to use will help us animate between different positions and rotations. The code collection is called Tween. It gets its name from its ability to change between values over time.

For this, go to the top of your code (the very top, not just to the START CODING ON THE NEXT LINE line). Add the <script> tag for

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.