Game Development Reference
In-Depth Information
Putting it all together (and also wrapping our setup code in a function for clarity),
we get:
var camera, scene, renderer;
var geometry, material, mesh;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 75, window.innerWidth /
window.innerHeight, 1, 1000 );
camera.position.z = 500;
scene = new THREE.Scene();
geometry = new THREE.IcosahedronGeometry( 200, 1 );
material = new THREE.MeshBasicMaterial( { color: 0x000000,
wireframe: true, wireframeLinewidth: 2 } );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
requestAnimationFrame( animate );
mesh.rotation.x = Date.now() * 0.00005;
mesh.rotation.y = Date.now() * 0.0001;
renderer.render( scene, camera );
}
 
Search WWH ::




Custom Search