3D Game Programming

(C. Jardin) #1
-width/2, width/2, height/2, -height/2, 1, 10000
);

camera.position.z = 500;
scene.add(camera);

// This will draw what the camera sees onto the screen:
varrenderer =newTHREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
document.body.style.backgroundColor ='#9999aa';

// ******** START CODING ON THE NEXT LINE ********

/*
// Perspective camera border
function makeBorder(x, y, w, h) {
var border = new Physijs.BoxMesh(
new THREE.CubeGeometry(1.2*w, 1.2*h, 100),
Physijs.createMaterial(
new THREE.MeshBasicMaterial({color: 0x000000}), 0.2, 1.0
),
0
);
border.position.set(1.2*x, 1.2*y, 0);
return border;
}
*/
functionmakeBorder(x, y, w, h) {
varborder =newPhysijs.BoxMesh(
newTHREE.CubeGeometry(w, h, 100),
Physijs.createMaterial(
newTHREE.MeshBasicMaterial({color: 0x000000}), 0.2, 1.0
),
0
);
border.position.set(x, y, 0);
returnborder;
}
scene.add(makeBorder(width/-2, 0, 50, height));
scene.add(makeBorder(width/2, 0, 50, height));
scene.add(makeBorder(0, height/2, width, 50));
scene.add(makeBorder(0, height/-2, width, 50));

varavatar =newPhysijs.ConvexMesh(

newTHREE.CylinderGeometry(30, 30, 5, 16),
Physijs.createMaterial(

newTHREE.MeshBasicMaterial({color:0xbb0000}), 0.2, 0.5

Appendix 1. Project Code • 256


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf