Animating the Spin

When we turn our avatar, it’s immediately facing the 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 library. This library will help us animate between different positions and rotations. The library is called Tween.

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:

 
<body>​​</body>
 
<script​ src=​"http://gamingJS.com/Three.js"​​>​​</script>
 
<script​ src=​"http://gamingJS.com/Tween.js"​​>​​</script>
 
<script​ src=​"http://gamingJS.com/ChromeFixes.js"​​>​​</script>

The Tween library animates changes between a start and end. Here we want ...

Get 3D Game Programming for Kids 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.