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 tween.js, as shown: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access