Skip to content

Instantly share code, notes, and snippets.

@steveturner
Created March 12, 2013 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveturner/5144990 to your computer and use it in GitHub Desktop.
Save steveturner/5144990 to your computer and use it in GitHub Desktop.
three.js and coffeescript
class window.ThreeJSDemo
init: () ->
@renderer = new THREE.WebGLRenderer()
@renderer.setSize( window.innerWidth, window.innerHeight )
document.body.appendChild( @renderer.domElement )
@camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1000 )
@camera.position.z = 400
@scene = new THREE.Scene()
@geometry = new THREE.IcosahedronGeometry( 200, 1 );
@material = new THREE.MeshBasicMaterial( { color: 0x333, wireframe: true, wireframeLinewidth: 6
} )
@mesh = new THREE.Mesh( @geometry, @material )
@scene.add( @mesh );
animate: () ->
requestAnimationFrame( @animate )
@mesh.rotation.x = Date.now() * 0.0005
@mesh.rotation.y = Date.now() * 0.001
@renderer.render( @scene, @camera );
testWebGL = new window.ThreeJSDemo()
testWebGL.init()
testWebGL.animate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment