3D Game Programming

(C. Jardin) #1
holder.style.overflow ='auto';
holder.style.border ='1px solid #666';
holder.style.backgroundColor ='#ccc';
holder.style.padding ='8px';
holder.style.position ='absolute';
holder.style.bottom ='10px';
holder.style.right ='20px';
document.body.appendChild(holder);

returnholder;
}

functionlogMessage(message, log) {
varholder = document.createElement('div');
holder.textContent = message;
log.appendChild(holder);
}
</script>

A1.6 Code: Moving Hands and Feet


This is the code from Chapter 6, Project: Moving Hands and Feet, on page 59.


<body></body>
<script src="http://gamingJS.com/Three.js"></script>
<script src="http://gamingJS.com/ChromeFixes.js"></script>
<script>
// This is where stuff in our game will happen:
varscene =newTHREE.Scene();

// This is what sees the stuff:
varaspect_ratio = window.innerWidth / window.innerHeight;
varcamera =newTHREE.PerspectiveCamera(75, aspect_ratio, 1, 10000);
camera.position.z = 500;
//scene.add(camera);

// This will draw what the camera sees onto the screen:
varrenderer =newTHREE.CanvasRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// ******** START CODING ON THE NEXT LINE ********
varmarker =newTHREE.Object3D();
scene.add(marker);

varcover =newTHREE.MeshNormalMaterial();
varbody =newTHREE.SphereGeometry(100);
varavatar =newTHREE.Mesh(body, cover);
marker.add(avatar);

varhand =newTHREE.SphereGeometry(50);

report erratum • discuss

Code: Moving Hands and Feet • 223


Prepared exclusively for Michael Powell

Free download pdf