Breaking It Down

Let’s take a quick look at why we used those numbers for the hands. If you’re impatient, skip ahead to Adding Feet for Walking, to keep building our game avatar.

When anything is added to a scene, it starts off in the very center. So when we add the body and a hand, it starts off something like this:

images/building_an_avatar/two_spheres_start.jpg

In 3D programming and mathematics, left and right are called the X direction. Up and down are called the Y direction.

This is why we change the X position of the hands:

 
var​ left_hand = ​new​ THREE.Mesh(hand, cover);
 
left_hand.position.set(150, 0, 0);
 
scene.add(left_hand);

The numbers inside left_hand.position.set(150, 0, 0) ...

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.