right_hand.position.set(-150, 0, 0);
avatar.add(right_hand);
varleft_hand =newTHREE.Mesh(hand, cover);
left_hand.position.set(150, 0, 0);
avatar.add(left_hand);
varfoot =newTHREE.SphereGeometry(50);
varright_foot =newTHREE.Mesh(foot, cover);
right_foot.position.set(-75, -125, 0);
avatar.add(right_foot);
varleft_foot =newTHREE.Mesh(foot, cover);
left_foot.position.set(75, -125, 0);
avatar.add(left_foot);
marker.add(camera);
// Trees
makeTreeAt( 500, 0);
makeTreeAt(-500, 0);
makeTreeAt( 750, -1000);
makeTreeAt(-750, -1000);
functionmakeTreeAt(x, z) {
vartrunk =newTHREE.Mesh(
newTHREE.CylinderGeometry(50, 50, 200),
newTHREE.MeshBasicMaterial({color: 0xA0522D})
);
vartop =newTHREE.Mesh(
newTHREE.SphereGeometry(150),
newTHREE.MeshBasicMaterial({color: 0x228B22})
);
top.position.y = 175;
trunk.add(top);
trunk.position.set(x, -75, z);
scene.add(trunk);
}
// Now, animate what the camera sees on the screen:
varis_cartwheeling = false;
varis_flipping = false;
functionanimate() {
requestAnimationFrame(animate);
if(is_cartwheeling) {
avatar.rotation.z = avatar.rotation.z + 0.05;
}
report erratum • discuss
Code: Moving Avatars • 221
Prepared exclusively for Michael Powell