Created
May 15, 2014 22:49
-
-
Save drobertduke/37949ee257ef157ee583 to your computer and use it in GitHub Desktop.
3d rendering fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <meta charset="utf-8"> | |
| <style> | |
| body { | |
| background: #000; | |
| } | |
| </style> | |
| <body> | |
| <script src="http://threejs.org/build/three.min.js"></script> | |
| <script src="http://threejs.org/examples/js/controls/TrackballControls.js"></script> | |
| <script src="http://threejs.org/examples/js/renderers/CSS3DRenderer.js"></script> | |
| <script> | |
| var scene, camera, renderer; | |
| var geometry, material, mesh; | |
| init(); | |
| animate(); | |
| function init() { | |
| scene = new THREE.Scene(); | |
| camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 ); | |
| camera.position.z = 1000; | |
| geometry = new THREE.BoxGeometry( 200, 200, 200 ); | |
| material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); | |
| 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() { | |
| // note: three.js includes requestAnimationFrame shim | |
| requestAnimationFrame( animate ); | |
| mesh.rotation.x += 0.01; | |
| mesh.rotation.y += 0.02; | |
| renderer.render( scene, camera ); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment