![]() Press the "Run" button again and you should see the torus and cube rotating in the Replit window: To kick off the animation for the first time, we call the animate() function ourselves. We call this function so that we can keep the animation running. Each time animate() is called, requestAnimationFrame will call it again for the next frame. The requestAnimationFrame function is a built-in browser API call that will fire the animate() function on the next frame. This will cause the scene to be redrawn every frame, with the updated rotations. This is a handy method that saves us from calculating the rotation ourselves.Īfter we rotate the objects, we call the renderer.render(scene, camera) method to draw the scene. We rotate the torus and cube by 0.01 radians around the objects' x and y axes using the rotation property of each mesh. This creates a new function, animate(), that will be called on every frame.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |