Commits

ravipinto committed 5bdee33

Initial revision

  • Participants
  • Parent commits 3e0c322

Comments (0)

Files changed (1)

+/**
+ * 
+ * Three.js is a 3D rendering engine build on top of WebGL apis. Here is a simple helloWorld:
+ * @see https://github.com/mrdoob/three.js/
+ * 
+ */
+ 
+var camera, scene, renderer, geometry, material, mesh;
+
+function init()
+{
+    camera = new THREE.Camera(75, 600/600, 1, 10000);
+    camera.position.z = 600;
+
+    scene = new THREE.Scene();
+
+    var tex = new THREE.ImageUtils.loadTexture("http://www.w3.org/html/logo/img/class-header-3d.jpg");
+    geometry = new THREE.CubeGeometry(200, 200, 200);
+    material = new THREE.MeshBasicMaterial({map: tex});
+    
+    mesh = new THREE.Mesh(geometry, material);
+    scene.addObject( mesh );
+
+    renderer = new THREE.CanvasRenderer();
+    renderer.setSize(600, 600);
+
+    document.body.appendChild(renderer.domElement);
+}
+
+function render()
+{
+    mesh.rotation.x += 0.03;
+    mesh.rotation.y += 0.03;
+
+    renderer.render(scene, camera);
+}
+
+
+function main()
+{
+    init();
+    setInterval(function(){render();}, 1000/30);
+}
+