Skip to content

Commit

Permalink
Beautified usage example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Oct 13, 2011
1 parent 77d7a99 commit 3433b49
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,57 +82,60 @@ More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=thre

Download the [minified library](http://mrdoob.github.com/three.js/build/Three.js) and include it in your html.

<script src="js/Three.js"></script>
```html
<script src="js/Three.js"></script>
```

This code creates a camera, then creates a scene, adds a cube on it, creates a &lt;canvas&gt; renderer and adds its viewport in the document.body element.

<script>
```html
<script>
var camera, scene, renderer,
geometry, material, mesh;
var camera, scene, renderer,
geometry, material, mesh;
init();
animate();
init();
animate();
function init() {
function init() {
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene = new THREE.Scene();
scene = new THREE.Scene();
geometry = new THREE.CubeGeometry( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
geometry = new THREE.CubeGeometry( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
document.body.appendChild( renderer.domElement );
}
}
function animate() {
function animate() {
// Include examples/js/RequestAnimationFrame.js for cross-browser compatibility.
requestAnimationFrame( animate );
render();
// Include examples/js/RequestAnimationFrame.js for cross-browser compatibility.
requestAnimationFrame( animate );
render();
}
}
function render() {
function render() {
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render( scene, camera );
renderer.render( scene, camera );
}

</script>
}
</script>
```

### Change Log ###

Expand Down

0 comments on commit 3433b49

Please sign in to comment.