3D Game Programming

(C. Jardin) #1
gameStep();

functionaddLights() {
scene.add(newTHREE.AmbientLight(0x999999));

varback_light =newTHREE.PointLight(0xffffff);
back_light.position.set(50, 50, -100);
scene.add(back_light);

varspot_light =newTHREE.SpotLight(0xffffff);
spot_light.position.set(-250, 250, 250);
spot_light.castShadow = true;
scene.add(spot_light);
}

functionaddBall() {
varball =newPhysijs.SphereMesh(
newTHREE.SphereGeometry(10, 25, 21),
newTHREE.MeshPhongMaterial({
color: 0x333333,
shininess: 100.0,
ambient: 0xff0000,
emissive: 0x111111,
specular: 0xbbbbbb
})
);
ball.castShadow = true;
scene.add(ball);
resetBall(ball);
returnball;
}

functionresetBall(ball) {
ball.__dirtyPosition = true;
ball.position.set(-33, 50, -65);
ball.setLinearVelocity(0,0,0);
ball.setAngularVelocity(0,0,0);
}

functionaddBoard() {
varmaterial =newTHREE.MeshPhongMaterial({
color: 0x333333,
shininess: 40,
ambient: 0xffd700,
emissive: 0x111111,
specular: 0xeeeeee
});

varbeam =newPhysijs.BoxMesh(
newTHREE.CubeGeometry(50, 2, 200),

Appendix 1. Project Code • 250


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf