Graphics Reference
In-Depth Information
Tip
To best demonstrate the rotation of an object around another one, you should ro-
tate around that object's y axis. To do this, change the rotationSpeedY property.
How to do it...
Rotating an object around another object takes a couple of additional steps com-
pared to the rotation we showed in the previous recipe:
1. Let's first create the central blue sphere you can see in the screenshot. This
is the object that we'll rotate the little red box around:
// create a simple sphere
var sphere = new
THREE.SphereGeometry(6.5, 20, 20);
var sphereMaterial = new
THREE.MeshLambertMaterial({
color: 0x5555ff
});
var sphereMesh = new THREE.Mesh(sphere,
spherMaterial);
sphereMesh.receiveShadow = true;
sphereMesh.position.set(0, 1, 0);
scene.add(sphereMesh);
So far, there's nothing special in this code snippet. You can see a standard
THREE.Sphere object from which we create THREE.Mesh and add it to the
scene.
2. The next step is to define a separate object, which we'll use as the pivot point
for our box:
// add an object as pivot point to the
sphere
Search WWH ::




Custom Search