|
@@ -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 <canvas> 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 ###
|
|
|
|