3D Game Programming

(C. Jardin) #1
functiontilt(dir, amount) {
board.__dirtyRotation = true;
board.rotation[dir] = board.rotation[dir] + amount;
}

functionaddGoal() {
varlight =newTHREE.Mesh(
newTHREE.CylinderGeometry(20, 20, 1000),
newTHREE.MeshPhongMaterial({
transparent:true,
opacity: 0.15,
shininess: 0,
ambient: 0xffffff,
emissive: 0xffffff
})
);
scene.add(light);

varscore =newPhysijs.ConvexMesh(
newTHREE.PlaneGeometry(20, 20),
newTHREE.MeshNormalMaterial({wireframe: true})
);
score.position.y = -50;
score.rotation.x = -Math.PI/2;
scene.add(score);

score.addEventListener('collision',function() {
flashGoalLight(light);
resetBall(ball);
});
}

functionaddBackground() {
document.body.style.backgroundColor ='black';
varstars =newTHREE.Geometry();
while(stars.vertices.length < 1000) {
varlat = Math.PI * Math.random() - Math.PI/2;
varlon = 2*Math.PI * Math.random();
stars.vertices.push(newTHREE.Vector3(
1000 * Math.cos(lon) * Math.cos(lat),
1000 * Math.sin(lon) * Math.cos(lat),
1000 * Math.sin(lat)
));
}
varstar_stuff =newTHREE.ParticleBasicMaterial({size: 5});
varstar_system =newTHREE.ParticleSystem(stars, star_stuff);
scene.add(star_system);
}

Appendix 1. Project Code • 252


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf