Permalink
Browse files

add three.js and implement the missing methods

  • Loading branch information...
1 parent 71fc98e commit b59bfe379744bd955bd8f5c4daf61ccc06b1c680 @tmpvar committed Aug 26, 2011
Showing with 27,496 additions and 30 deletions.
  1. +83 −0 example/threejs/getting-started.js
  2. +27,249 −0 example/threejs/three.js
  3. +164 −30 src/js/spidermonkey.cc
@@ -0,0 +1,83 @@
+var window = this;
+var $ = function() {};
+console.error = console.log;
+var document = {
+ createElement : function() {
+ return {
+ getContext : function() {
+ return new WebGLRenderingContext();
+ }
+
+ };
+ }
+};
+var navigator = {};
+
+var WebGLRenderingContext = require('../lib/webgl.js').WebGLRenderingContext;
+
+var THREE = require('../example/threejs/three.js');
+
+THREE.WebGLRenderer.prototype = {};
+// set the scene size
+var WIDTH = 400,
+ HEIGHT = 300;
+
+// set some camera attributes
+var VIEW_ANGLE = 45,
+ ASPECT = WIDTH / HEIGHT,
+ NEAR = 0.1,
+ FAR = 10000;
+
+// get the DOM element to attach to
+// - assume we've got jQuery to hand
+//var $container = $('#container');
+
+// create a WebGL renderer, camera
+// and a scene
+var renderer = new THREE.WebGLRenderer();
+var camera = new THREE.Camera( VIEW_ANGLE,
+ ASPECT,
+ NEAR,
+ FAR );
+var scene = new THREE.Scene();
+
+// the camera starts at 0,0,0 so pull it back
+camera.position.z = 300;
+
+// start the renderer
+renderer.setSize(WIDTH, HEIGHT);
+
+// attach the render-supplied DOM element
+//$container.append(renderer.domElement);
+
+// create the sphere's material
+var sphereMaterial = new THREE.MeshLambertMaterial(
+{
+ color: 0xCC0000
+});
+
+// set up the sphere vars
+var radius = 50, segments = 16, rings = 16;
+
+// create a new mesh with sphere geometry -
+// we will cover the sphereMaterial next!
+var sphere = new THREE.Mesh(
+ new THREE.SphereGeometry(radius, segments, rings),
+ sphereMaterial);
+
+// add the sphere to the scene
+scene.addChild(sphere);
+
+// create a point light
+var pointLight = new THREE.PointLight( 0xFFFFFF );
+
+// set its position
+pointLight.position.x = 10;
+pointLight.position.y = 50;
+pointLight.position.z = 130;
+
+// add to the scene
+scene.addLight(pointLight);
+
+// draw!
+renderer.render(scene, camera);
Oops, something went wrong.

0 comments on commit b59bfe3

Please sign in to comment.