Moving a Hand

Let’s start with a hand. Recall from previous chapters that hands and feet are just balls that stick out from the head. We built the right hand in JavaScript with this:

 var​ rightHand = ​new​ THREE.Mesh(hand, cover);
 rightHand.position.​set​(-150, 0, 0);
 avatar.add(rightHand);

As you know, the three numbers we use to set the position of the hand are the X position (left/right), the Y position (up/down), and the Z position (in/out). In the case of the right hand, we placed it –150 from the center of the avatar.

In addition to setting all three numbers for the position, we can change just one of the positions by updating position.x, position.y, or position.z. To move the right hand forward (toward the viewer), add the position.z ...

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