Graphics Reference
In-Depth Information
Rotating an object around its own axis
There are many ways in which you can change the appearance of a mesh. For ex-
ample, 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 ro-
tate. 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 previ-
ous screenshot, you have to take a couple of steps:
1. For the first step in this recipe, we'll set up the control GUI, as we've shown in
Chapter 1 , Getting Started , in the Controlling the variables used in the scene
recipe, which you can see in the top-right corner. This time, we'll use the fol-
lowing as the control object:
Search WWH ::




Custom Search