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);varboundary =newTHREE.Mesh(
newTHREE.CircleGeometry(300),
newTHREE.MeshNormalMaterial()
);
boundary.position.y = -100;
boundary.rotation.x = -Math.PI/2;
trunk.add(boundary);not_allowed.push(boundary);trunk.position.set(x, -75, z);
scene.add(trunk);
}// Now, animate what the camera sees on the screen:
varclock =newTHREE.Clock(true);
functionanimate() {
requestAnimationFrame(animate);
TWEEN.update();
walk();
turn();
acrobatics();
renderer.render(scene, camera);
}report erratum • discussCode: Collisions • 231
Prepared exclusively for Michael Powell
