3D Game Programming

(C. Jardin) #1
varshape =newTHREE.CubeGeometry(300, 100, 20);
varcover =newTHREE.MeshNormalMaterial();
varbox =newTHREE.Mesh(shape, cover);
scene.add(box);
box.position.set(250, 250, -250);

varshape =newTHREE.CylinderGeometry(110, 100, 100);
varcover =newTHREE.MeshNormalMaterial();
vartube =newTHREE.Mesh(shape, cover);
scene.add(tube);
tube.position.set(250, -250, -250);

varshape =newTHREE.PlaneGeometry(300, 100);
varcover =newTHREE.MeshNormalMaterial();
varground =newTHREE.Mesh(shape, cover);
scene.add(ground);
ground.position.set(-250, -250, -250);

varshape =newTHREE.TorusGeometry(100, 25, 8, 25);
varcover =newTHREE.MeshNormalMaterial();
vardonut =newTHREE.Mesh(shape, cover);
scene.add(donut);

varclock =newTHREE.Clock();

functionanimate() {
requestAnimationFrame(animate);
vart = clock.getElapsedTime();

ball.rotation.set(t, 2*t, 0);
box.rotation.set(t, 2*t, 0);
tube.rotation.set(t, 2*t, 0);
ground.rotation.set(t, 2*t, 0);
donut.rotation.set(t, 2*t, 0);

renderer.render(scene, camera);
}

animate();

// Now, show what the camera sees on the screen:
renderer.render(scene, camera);
</script>

A1.2 Code: Playing with the Console and Finding What’s Broken


There was no working code from Chapter 2, Playing with the Console and
Finding What’s Broken, on page 17. We wrote some broken code in ICE and
explored the JavaScript console.

Appendix 1. Project Code • 218


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf