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​ right_hand = ​new​ THREE.Mesh(hand, cover);
 
right_hand.position.set(-150, 0, 0);
 
avatar.add(right_hand);

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 have 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 ...

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