3D Game Programming
varavatar =newTHREE.Mesh(body, cover); marker.add(avatar); varhand =newTHREE.SphereGeometry(50); varright_hand =newTHREE.Mesh(ha ...
boundary.position.y = -100; boundary.rotation.x = -Math.PI/2; trunk.add(boundary); not_allowed.push(boundary); trunk.position.se ...
vardirection = 0; if(is_moving_forward) direction = Math.PI; if(is_moving_back) direction = 0; if(is_moving_right) direction = M ...
} if(code == 39) { // right marker.position.x = marker.position.x+5; is_moving_right = true; } if(code == 40) { // down marker.p ...
(p1.x - p2.x)*(p1.x - p2.x) + (p1.z - p2.z)*(p1.z - p2.z) ); if(distance < 500) { scorePoints(); } } functionscorePoints() { ...
.Tween({jump: 0}) .to({jump: Math.PI}, 500) .onUpdate(function() { marker.position.y = 200* Math.sin(this.jump); }) .start(); } ...
varsunlight =newTHREE.DirectionalLight(); sunlight.intensity = 0.5; sunlight.position.set(100, 100, 100); scene.add(sunlight); s ...
renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // ******** START CODIN ...
renderer.render(scene, camera); } animate(); varstars =newTHREE.Geometry(); while(stars.vertices.length < 1e4) { varlat = Mat ...
varearth_cam =newTHREE.PerspectiveCamera(75, aspect_ratio, 1, 1e6); varcamera = above_cam; // This will draw what the camera see ...
vare_angle = time * 0.001; earth.position.set(250* Math.cos(e_angle), 250* Math.sin(e_angle), 0); varm_angle = time * 0.02; moon ...
Physijs.scripts.ammo = 'http://gamingJS.com/ammo.js'; Physijs.scripts.worker = 'http://gamingJS.com/physijs_worker.js'; var scen ...
avatar.position.set(-50, 50, 0); scene.add(avatar); avatar.setAngularFactor(new THREE.Vector3( 0, 0, 0 )); // no rotation avatar ...
map: THREE.ImageUtils.loadTexture('/images/fruit.png'), transparent: true }); var picture = new THREE.Mesh(new THREE.PlaneGeomet ...
if (game_over) { game_over = false; animate(); gameStep(); } } </script> A1.16Code: Tilt-a-Board This is the final version ...
gameStep(); functionaddLights() { scene.add(newTHREE.AmbientLight(0x999999)); varback_light =newTHREE.PointLight(0xffffff); back ...
material, 0 ); beam.position.set(-37, 0, 0); beam.receiveShadow = true; varbeam2 =newPhysijs.BoxMesh( newTHREE.CubeGeometry(50, ...
functiontilt(dir, amount) { board.__dirtyRotation = true; board.rotation[dir] = board.rotation[dir] + amount; } functionaddGoal( ...
functionanimate() { requestAnimationFrame(animate); scene.simulate();// run physics renderer.render(scene, camera); } functionga ...
// This will draw what the camera sees onto the screen: varrenderer =newTHREE.CanvasRenderer(); renderer.setSize(window.innerWid ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf