Rotating an object around its own axis
There are many ways in which you can change the appearance of a mesh. For example, you can change its position, scale, or material. Often, you'll also need to change the rotation of THREE.Mesh
. In this first recipe on rotation, we'll show you the simplest way to rotate an arbitrary mesh.
Getting ready
To rotate a mesh, we first need to create a scene that contains an object you can rotate. For this recipe, we provide an example, 02.01-rotate-around-axis.html
, that you can open in your browser. When you open this recipe, you'll see something similar to the following screenshot in your browser:
In this demo, you can see a 3D cube slowly rotating around its axis. Using the control GUI in the upper-right corner, you can change the speed at which the object rotates.
How to do it...
To rotate the cube from this example around its axis like we showed you in the previous screenshot, you have to take a couple of steps:
- For the first step in this recipe...