[Opengeoscience-developers] OpenGeoscience branch, enhance_map_api, updated. a882e6b5d1094a76cdc340f3967f1f5966fb2241

Aashish Chaudhary aashish.chaudhary at kitware.com
Sat Mar 2 18:56:55 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenGeoscience".

The branch, enhance_map_api has been updated
       via  a882e6b5d1094a76cdc340f3967f1f5966fb2241 (commit)
       via  9230d31c46f8963d4f9a8bb8c3589769fc31d076 (commit)
       via  93a69f52b63babe3e9642de2b7de5885f961ba6b (commit)
       via  ac5f6fe510bcb782ad39852048e4562440a5bf4b (commit)
       via  d1410c19b0c64d99e709ead16467e3466bd0b0e8 (commit)
       via  df4d6c04de3f0ba69968efd94ffafd5b459e40d9 (commit)
      from  47c6fdc45819e689355385a5b95d15500fe6b333 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=a882e6b5d1094a76cdc340f3967f1f5966fb2241
commit a882e6b5d1094a76cdc340f3967f1f5966fb2241
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 2 14:36:50 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 2 18:55:58 2013 -0500

    Implementing the layer opacity function

diff --git a/web/index.html b/web/index.html
index 91c88ea..09cd350 100644
--- a/web/index.html
+++ b/web/index.html
@@ -15,14 +15,14 @@
        $( "#slider-vertical" ).slider({
          orientation: "vertical",
          range: "min",
-         min: 0,
-         max: 100,
-         value: 60,
+         min: 0.0,
+         max: 1.0,
+         step: 0.01,
+         value: 0.5,
          slide: function( event, ui ) {
            $( "#amount" ).val( ui.value );
          }
        });
-       $( "#amount" ).val( $( "#slider-vertical" ).slider( "value" ) );
      });
   </script>
 	</head>
diff --git a/web/lib/app.js b/web/lib/app.js
index 5251051..0b3abb0 100644
--- a/web/lib/app.js
+++ b/web/lib/app.js
@@ -18,13 +18,11 @@
 
 // Disable console log
 // console.log = function() {}
-
 ///////////////////////////////////////////////////////////////////////////////
 //
 // main program
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 function main() {
 
   var mapOptions = {
@@ -33,14 +31,23 @@ function main() {
   };
 
   var myMap = ogs.geo.map(document.getElementById("glcanvas"), mapOptions);
-  var planeLayer = ogs.geo.featureLayer(
-    {"opacity":1, "showAttribution":1, "visible":1},
-      ogs.geo.planeFeature(ogs.geo.latlng(-90.0, 0.0), ogs.geo.latlng(90.0, 180.0)));
+  var planeLayer = ogs.geo.featureLayer({
+    "opacity" : 1,
+    "showAttribution" : 1,
+    "visible" : 1
+  }, ogs.geo.planeFeature(ogs.geo.latlng(-90.0, 0.0), ogs.geo.latlng(90.0,
+  180.0)));
 
   myMap.addLayer(planeLayer);
 
-  $(myMap).on('CameraEvent', function() {
+  $(myMap).on('mapUpdated', function() {
     // For test purposes only
     console.log("Yohoo.....camera has been moved or something");
   });
+
+  // / Listen for slider slidechange event
+  $('#slider-vertical').slider().bind('slide', function(event, ui) {
+    planeLayer.setOpacity(ui.value);
+    myMap.redraw();
+  });
 }
diff --git a/web/lib/geo/layer.js b/web/lib/geo/layer.js
index 5eead2b..93baa9c 100644
--- a/web/lib/geo/layer.js
+++ b/web/lib/geo/layer.js
@@ -21,7 +21,6 @@
 // Layer base class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 /**
  * Layer options object specification
  *
@@ -33,7 +32,7 @@ geoModule.layerOptions = function() {
     return new geoModule.layerOptions();
   }
 
-  this.opacity  = 1;
+  this.opacity = 1;
   this.showAttribution = true;
   this.visible = true;
 
@@ -49,27 +48,35 @@ geoModule.layerOptions = function() {
  */
 geoModule.layer = function(options) {
 
+  this.signals = {
+    "opacityChanged" : "opacityChanged",
+    "layerUpdated" : "layerUpdated"
+  };
+
   if (!(this instanceof geoModule.layer)) {
     return new geoModule.layer(options);
   }
 
   ogs.vgl.object.call(this);
 
-  /// Member variables
+  /** Member variables */
+  var m_that = this;
   var m_opacity = options.opacity || 1.0;
+
+  /** TODO Write a function for this */
   if (m_opacity > 1.0) {
     m_opacity = 1.0;
-    console.log("[warning] Opacity cannot be greater than 1.0");
+    console.log("[WARNING] Opacity cannot be greater than 1.0");
   }
   else if (m_opacity < 0.0) {
-    console.log("[warning] Opacity cannot be less than 1.0");
+    console.log("[WARNING] Opacity cannot be less than 1.0");
   }
 
   var m_showAttribution = options.showAttribution || true;
   var m_visible = options.visible || true;
 
   /**
-   * Return the underlying renderable entity
+   * Return the underlying drawable entity
    *
    * This function should be implemented by the derived classes
    */
@@ -77,22 +84,56 @@ geoModule.layer = function(options) {
     return null;
   };
 
+  /**
+   * Query opacity of the layer (range[0.0, 1.0])
+   *
+   */
+  this.opacity = function() {
+    return m_opacity;
+  };
+
+  /**
+   * Set opacity of the layer in the range of [0.0, 1.0]
+   *
+   */
+  this.setOpacity = function(val) {
+    m_opacity = val;
+    $(m_that).trigger({
+      type : this.signals.opacityChanged,
+      opacity : m_opacity
+    });
+  };
+
+  /**
+   * Virtual function to update the layer *
+   */
+  this.update = function() {
+  };
+
+  /**
+   * Virtual slot to handle opacity change
+   *
+   * Concrete class should implement this method.
+   */
+  this.updateLayerOpacity = function(event) {
+  };
+
   return this;
 };
 
 inherit(geoModule.layer, ogs.vgl.object);
 
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
 //
 // featureLayer class
 //
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
 
 /**
  * Layer to draw points, lines, and polygons on the map
  *
- * The polydata layer provide mechanisms to create and draw geometrical
- * shapes such as points, lines, and polygons.
+ * The polydata layer provide mechanisms to create and draw geometrical shapes
+ * such as points, lines, and polygons.
  *
  */
 geoModule.featureLayer = function(options, feature) {
@@ -101,13 +142,12 @@ geoModule.featureLayer = function(options, feature) {
     return new geoModule.featureLayer(options, feature);
   }
 
-  /// Register with base class
+  // / Register with base class
   geoModule.layer.call(this, options);
 
-  /// Initialize member variables
-  var m_opacity = options.opacity || 1.0;
+  // / Initialize member variables
+  var m_that = this;
   var m_actor = feature;
-
   /**
    * Return the underlying renderable entity
    *
@@ -122,9 +162,28 @@ geoModule.featureLayer = function(options, feature) {
    *
    */
   this.setFeature = function(feature) {
-    this.m_actor = feature;
+    m_actor = feature;
   };
 
+  /**
+   * Slot to handle opacity change
+   *
+   */
+  this.updateLayerOpacity = function(event) {
+    console.log('updated layer opacity');
+
+    var mat = m_actor.material();
+    var opacityUniform = mat.shaderProgram().uniform('opacity');
+
+    if (opacityUniform != null) {
+      opacityUniform.set(event.opacity);
+      $(m_that).trigger(this.signals.layerUpdated);
+    }
+  };
+
+  /** Signal-slot connection */
+  $(m_that).on(this.signals.opacityChanged, m_that.updateLayerOpacity);
+
   return this;
 };
 
diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 5fac2e1..8910630 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -90,7 +90,7 @@ geoModule.map = function(node, options) {
   }
 
   // TODO For now using the JQuery
-  $(this).on('CameraEvent', draw);
+  $(this).on('mapUpdated', draw);
 
   var m_renderer = new ogs.vgl.renderer();
   var m_camera = m_renderer.camera();
@@ -210,13 +210,13 @@ geoModule.map = function(node, options) {
 
       // Move the scene in the direction of movement of mouse;
       m_camera.pan(-dx, -dy);
-      $(m_that).trigger('CameraEvent');
+      $(m_that).trigger('mapUpdated');
     }
 
     if (m_rightMouseButtonDown) {
       zTrans = currentMousePos.y - m_mouseLastPos.y;
       m_camera.zoom(zTrans * 0.5);
-      $(m_that).trigger('CameraEvent');
+      $(m_that).trigger('mapUpdated');
     }
 
     m_mouseLastPos.x = currentMousePos.x;
@@ -347,5 +347,13 @@ geoModule.map = function(node, options) {
     return false;
   };
 
+  /**
+   * Manually force to render map
+   *
+   */
+  this.redraw = function() {
+    m_renderer.render();
+  };
+
   return this;
 };
diff --git a/web/lib/vgl/actor.js b/web/lib/vgl/actor.js
index 0226f86..c5e794c 100644
--- a/web/lib/vgl/actor.js
+++ b/web/lib/vgl/actor.js
@@ -21,7 +21,6 @@
 // actor class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.actor = function() {
 
   if (!(this instanceof vglModule.actor)) {
@@ -30,7 +29,7 @@ vglModule.actor = function() {
 
   vglModule.node.call(this);
 
-  /// Initialize member variables
+  // / Initialize member variables
   var m_center = new Array(3);
   var m_rotation = new Array(4);
   var m_scale = new Array(3);
@@ -42,7 +41,7 @@ vglModule.actor = function() {
    * Get center of transformations
    *
    */
-  this.center  = function() {
+  this.center = function() {
     return m_center;
   };
 
@@ -99,16 +98,16 @@ vglModule.actor = function() {
   };
 
   /**
-   * Get reference frame for the transformations. Possible values
-   * are Absolute and Relative.
+   * Get reference frame for the transformations. Possible values are Absolute
+   * and Relative.
    *
    */
   this.referenceFrame = function() {
   };
 
   /**
-   * Set reference frame for the transformations. Possible values
-   * are Absolute and Relative.
+   * Set reference frame for the transformations. Possible values are Absolute
+   * and Relative.
    *
    */
   this.setReferenceFrame = function(referenceFrame) {
diff --git a/web/lib/vgl/shaderProgram.js b/web/lib/vgl/shaderProgram.js
index 8fd840a..8fbc3d9 100644
--- a/web/lib/vgl/shaderProgram.js
+++ b/web/lib/vgl/shaderProgram.js
@@ -21,7 +21,6 @@
 // shaderProgram class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.shaderProgram = function() {
 
   if (!(this instanceof vglModule.shaderProgram)) {
@@ -29,7 +28,7 @@ vglModule.shaderProgram = function() {
   }
   vglModule.materialAttribute.call(this, materialAttributeType.ShaderProgram);
 
-  /// Private member variables
+  // / Private member variables
   var m_programHandle = 0;
   var m_shaders = [];
   var m_uniforms = [];
@@ -38,7 +37,7 @@ vglModule.shaderProgram = function() {
   var m_uniformNameToLocation = {};
   var m_vertexAttributeNameToLocation = {};
 
-  /// Public member methods
+  // / Public member methods
   this.queryUniformLocation = function(name) {
     return gl.getUniformLocation(m_programHandle, name);
   };
@@ -48,11 +47,11 @@ vglModule.shaderProgram = function() {
   };
 
   this.addShader = function(shader) {
-    if (m_shaders.indexOf(shader) > -1)   {
+    if (m_shaders.indexOf(shader) > -1) {
       return false;
     }
 
-    for (var i = 0; i < m_shaders.length; ++i) {
+    for ( var i = 0; i < m_shaders.length; ++i) {
       if (m_shaders[i].shaderType() === shader.shaderType()) {
         m_shaders.splice(m_shaders.indexOf(shader), 1);
       }
@@ -91,10 +90,19 @@ vglModule.shaderProgram = function() {
     // TODO
   };
 
+  this.uniform = function(name) {
+    for ( var i = 0; i < m_uniforms.length; ++i) {
+      if (m_uniforms[i].name() === name) {
+        return m_uniforms[i];
+      }
+    }
+
+    return null;
+  };
+
   this.updateUniforms = function() {
-    for (var i = 0; i < m_uniforms.length; ++i) {
-      m_uniforms[i].callGL(
-        m_uniformNameToLocation[m_uniforms[i].name()]);
+    for ( var i = 0; i < m_uniforms.length; ++i) {
+      m_uniforms[i].callGL(m_uniformNameToLocation[m_uniforms[i].name()]);
     }
   };
 
@@ -128,7 +136,7 @@ vglModule.shaderProgram = function() {
   };
 
   this.deleteVertexAndFragment = function() {
-    for (var i = 0; i < m_shaders.length; ++i) {
+    for ( var i = 0; i < m_shaders.length; ++i) {
       gl.deleteShader(m_shaders[i].shaderHandle());
     }
   };
@@ -192,9 +200,9 @@ vglModule.shaderProgram = function() {
   };
 
   this.bindUniforms = function() {
-    for (var i = 0; i < m_uniforms.length; ++i) {
-      m_uniformNameToLocation[m_uniforms[i].name()] =
-        this.queryUniformLocation(m_uniforms[i].name());
+    for ( var i = 0; i < m_uniforms.length; ++i) {
+      m_uniformNameToLocation[m_uniforms[i].name()] = this
+      .queryUniformLocation(m_uniforms[i].name());
 
       console.log(m_uniforms[i].name());
       console.log(this.queryUniformLocation(m_uniforms[i].name()));
@@ -203,7 +211,7 @@ vglModule.shaderProgram = function() {
 
   this.bindAttributes = function() {
     var index = 0;
-    for (var i in m_vertexAttributes) {
+    for ( var i in m_vertexAttributes) {
       var name = m_vertexAttributes[i].name();
       gl.bindAttribLocation(m_programHandle, index, name);
       m_vertexAttributeNameToLocation[name] = index++;

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=9230d31c46f8963d4f9a8bb8c3589769fc31d076
commit 9230d31c46f8963d4f9a8bb8c3589769fc31d076
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 2 13:39:31 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 2 13:39:31 2013 -0500

    Added slider to control opacity

diff --git a/web/index.html b/web/index.html
index 19c5baf..91c88ea 100644
--- a/web/index.html
+++ b/web/index.html
@@ -1,13 +1,33 @@
 <html>
 	<head>
-    <script src="lib/sylvester.js" type="text/javascript"></script>
-    <script src="lib/glUtils.js" type="text/javascript"></script>
-    <script src="lib/gl-matrix.js" type="text/javascript"></script>
-    <script type="text/javascript" src="lib/ogs.min.js"></script>
-    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
-    <script src="lib/app.js" type="text/javascript"></script>
+  <script src="lib/sylvester.js" type="text/javascript"></script>
+  <script src="lib/glUtils.js" type="text/javascript"></script>
+  <script src="lib/gl-matrix.js" type="text/javascript"></script>
+  <script type="text/javascript" src="lib/ogs.min.js"></script>
+  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
+  <script src="lib/app.js" type="text/javascript"></script>
+
+  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
+  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
+  <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
+  <script>
+     $(function() {
+       $( "#slider-vertical" ).slider({
+         orientation: "vertical",
+         range: "min",
+         min: 0,
+         max: 100,
+         value: 60,
+         slide: function( event, ui ) {
+           $( "#amount" ).val( ui.value );
+         }
+       });
+       $( "#amount" ).val( $( "#slider-vertical" ).slider( "value" ) );
+     });
+  </script>
 	</head>
 	<body onload="main()">
-		<canvas id="glcanvas" width="800" height="600"></canvas>
+	  <canvas id="glcanvas" width="800" height="600"></canvas>
+    <div id="slider-vertical" style="height: 600px; display: inline-block;"></div>
 	</body>
-</html>
+  </html>
diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 5a5cd76..5fac2e1 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -27,13 +27,13 @@ geoModule.latlng = function(lat, lng) {
     return new geoModule.latlng(lat, lng);
   }
 
-  /// Member variables
+  // / Member variables
   var m_lat = lat;
   var m_lng = lng;
 
-  /// Member methods
+  // / Member methods
   this.lat = function() {
-      return m_lat;
+    return m_lat;
   };
 
   this.lng = function() {
@@ -52,8 +52,8 @@ geoModule.mapOptions = function() {
     return new geoModule.mapOptions();
   }
 
-  /// Member variables
-  this.zoom  = 10;
+  // / Member variables
+  this.zoom = 10;
   this.center = geoModule.latlng(0.0, 0.0);
 };
 
@@ -67,13 +67,16 @@ geoModule.map = function(node, options) {
     return new geoModule.map(node, options);
   }
 
-  /// Member variables
+  // / Member variables
   var m_that = this;
   var m_node = node;
   var m_leftMouseButtonDown = false;
   var m_rightMouseButtonDown = false;
   var m_initialized = false;
-  var m_mouseLastPos = {x : 0, y : 0};
+  var m_mouseLastPos = {
+    x : 0,
+    y : 0
+  };
 
   initWebGL(node);
 
@@ -101,12 +104,9 @@ geoModule.map = function(node, options) {
     var distance = 600;
     distance = 600 - (600 - (60 * m_options.zoom)) + 1;
 
-    m_camera.setPosition(m_options.center.lng(),
-                         m_options.center.lat(),
-                         distance);
-    m_camera.setFocalPoint(m_options.center.lng(),
-                           m_options.center.lat(),
-                           0.0);
+    m_camera.setPosition(m_options.center.lng(), m_options.center.lat(),
+    distance);
+    m_camera.setFocalPoint(m_options.center.lng(), m_options.center.lat(), 0.0);
 
     m_initialized = true;
   }
@@ -138,12 +138,15 @@ geoModule.map = function(node, options) {
     do {
       totalOffsetX += currentElement.offsetLeft;
       totalOffsetY += currentElement.offsetTop;
-    } while(currentElement === currentElement.offsetParent);
+    } while (currentElement === currentElement.offsetParent);
 
     canvasX = event.pageX - totalOffsetX;
     canvasY = event.pageY - totalOffsetY;
 
-    return {x:canvasX, y:canvasY};
+    return {
+      x : canvasX,
+      y : canvasY
+    };
   }
 
   /**
@@ -152,21 +155,30 @@ geoModule.map = function(node, options) {
    */
   function handleMouseMove(event) {
     var canvas = m_node;
+
+    var height = $(canvas).height();
+    var width = $(canvas).width();
+
     var outsideCanvas = false;
     var coords = canvas.relMouseCoords(event);
 
-    var currentMousePos = {x : 0, y : 0};
-    if (coords.x < 0) {
+    var currentMousePos = {
+      x : 0,
+      y : 0
+    };
+    if ((coords.x < 0) || (coords.x > width)) {
       currentMousePos.x = 0;
       outsideCanvas = true;
-    } else {
+    }
+    else {
       currentMousePos.x = coords.x;
     }
 
-    if (coords.y < 0) {
+    if ((coords.y < 0) || (coords.y > height)) {
       currentMousePos.y = 0;
       outsideCanvas = true;
-    } else {
+    }
+    else {
       currentMousePos.y = coords.y;
     }
 
@@ -177,23 +189,21 @@ geoModule.map = function(node, options) {
     if (m_leftMouseButtonDown) {
 
       var focalPoint = m_camera.focalPoint();
-      var focusWorldPt = vec4.createFrom(
-        focalPoint[0], focalPoint[1], focalPoint[2], 1);
+      var focusWorldPt = vec4.createFrom(focalPoint[0], focalPoint[1],
+      focalPoint[2], 1);
 
       var focusDisplayPt = ogs.vgl.renderer.worldToDisplay(focusWorldPt,
-        m_camera.viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
+      m_camera.viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
 
-      var displayPt1 = vec4.createFrom(
-        currentMousePos.x, currentMousePos.y, focusDisplayPt[2], 1.0);
-      var displayPt2 = vec4.createFrom(
-        m_mouseLastPos.x, m_mouseLastPos.y, focusDisplayPt[2], 1.0);
+      var displayPt1 = vec4.createFrom(currentMousePos.x, currentMousePos.y,
+      focusDisplayPt[2], 1.0);
+      var displayPt2 = vec4.createFrom(m_mouseLastPos.x, m_mouseLastPos.y,
+      focusDisplayPt[2], 1.0);
 
-      var worldPt1 = ogs.vgl.renderer.displayToWorld(
-        displayPt1, m_camera.viewMatrix(),
-        m_camera.projectionMatrix(), 1680, 1050);
-      var worldPt2 = ogs.vgl.renderer.displayToWorld(
-        displayPt2, m_camera.viewMatrix(),
-        m_camera.projectionMatrix(), 1680, 1050);
+      var worldPt1 = ogs.vgl.renderer.displayToWorld(displayPt1, m_camera
+      .viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
+      var worldPt2 = ogs.vgl.renderer.displayToWorld(displayPt2, m_camera
+      .viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
 
       dx = worldPt1[0] - worldPt2[0];
       dy = worldPt1[1] - worldPt2[1];
@@ -225,21 +235,23 @@ geoModule.map = function(node, options) {
     if (event.button === 2) {
       m_rightMouseButtonDown = true;
     }
-    if (event.button === 4)  {
-//        middileMouseButtonDown = true;
+    if (event.button === 4) {
+      // middileMouseButtonDown = true;
     }
 
     coords = canvas.relMouseCoords(event);
 
     if (coords.x < 0) {
       m_mouseLastPos.x = 0;
-    } else  {
+    }
+    else {
       m_mouseLastPos.x = coords.x;
     }
 
     if (coords.y < 0) {
       m_mouseLastPos.y = 0;
-    } else {
+    }
+    else {
       m_mouseLastPos.y = coords.y;
     }
 
@@ -258,7 +270,7 @@ geoModule.map = function(node, options) {
       m_rightMouseButtonDown = false;
     }
     if (event.button === 4) {
-//      middileMouseButtonDown = false;
+      // middileMouseButtonDown = false;
     }
 
     return false;
@@ -267,10 +279,8 @@ geoModule.map = function(node, options) {
   // TODO use zoom and center options
 
   var m_baseLayer = (function() {
-    var mapActor = ogs.vgl.utils.createTexturePlane(
-                      -180.0, -90.0, 0.0,
-                       180.0, -90.0, 0.0,
-                      -180.0, 90.0, 0.0);
+    var mapActor = ogs.vgl.utils.createTexturePlane(-180.0, -90.0, 0.0, 180.0,
+    -90.0, 0.0, -180.0, 90.0, 0.0);
 
     // Setup texture
     worldImage = new Image();
@@ -287,7 +297,9 @@ geoModule.map = function(node, options) {
     document.onmousedown = handleMouseDown;
     document.onmouseup = handleMouseUp;
     document.onmousemove = handleMouseMove;
-    document.oncontextmenu = function() {return false;};
+    document.oncontextmenu = function() {
+      return false;
+    };
     HTMLCanvasElement.prototype.relMouseCoords = relMouseCoords;
 
     draw();
@@ -299,7 +311,8 @@ geoModule.map = function(node, options) {
    * Add layer to the map
    *
    * @method addLayer
-   * @param {geo.layer} layer to be added to the map
+   * @param {geo.layer}
+   *          layer to be added to the map
    * @return {Boolean}
    */
   this.addLayer = function(layer) {
@@ -320,7 +333,8 @@ geoModule.map = function(node, options) {
    * Remove layer from the map
    *
    * @method removeLayer
-   * @param {geo.layer} layer that should be removed from the map
+   * @param {geo.layer}
+   *          layer that should be removed from the map
    * @return {Boolean}
    */
   this.removeLayer = function(layer) {

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=93a69f52b63babe3e9642de2b7de5885f961ba6b
commit 93a69f52b63babe3e9642de2b7de5885f961ba6b
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 2 13:20:59 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 2 13:20:59 2013 -0500

    Improving test interface

diff --git a/web/index.html b/web/index.html
index 25e35dc..19c5baf 100644
--- a/web/index.html
+++ b/web/index.html
@@ -8,7 +8,6 @@
     <script src="lib/app.js" type="text/javascript"></script>
 	</head>
 	<body onload="main()">
-		<canvas id="glcanvas" width="1280" height="1024">
-		</canvas>
+		<canvas id="glcanvas" width="800" height="600"></canvas>
 	</body>
 </html>

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=ac5f6fe510bcb782ad39852048e4562440a5bf4b
commit ac5f6fe510bcb782ad39852048e4562440a5bf4b
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 2 13:09:15 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 2 13:14:12 2013 -0500

    Some more fixes

diff --git a/web/lib/geo/layer.js b/web/lib/geo/layer.js
index 938a33d..5eead2b 100644
--- a/web/lib/geo/layer.js
+++ b/web/lib/geo/layer.js
@@ -75,7 +75,7 @@ geoModule.layer = function(options) {
    */
   this.actor = function() {
     return null;
-  }
+  };
 
   return this;
 };
@@ -115,7 +115,7 @@ geoModule.featureLayer = function(options, feature) {
    */
   this.actor = function() {
     return m_actor;
-  }
+  };
 
   /**
    * Set feature (points, lines, or polygons)
@@ -123,7 +123,7 @@ geoModule.featureLayer = function(options, feature) {
    */
   this.setFeature = function(feature) {
     this.m_actor = feature;
-  }
+  };
 
   return this;
 };
diff --git a/web/lib/vgl/blend.js b/web/lib/vgl/blend.js
index 4b20dca..7c04038 100644
--- a/web/lib/vgl/blend.js
+++ b/web/lib/vgl/blend.js
@@ -41,7 +41,7 @@ vglModule.blendFunction = function(source, destination) {
   };
 
   return this;
-}
+};
 
 //////////////////////////////////////////////////////////////////////////////
 //
diff --git a/web/lib/vgl/camera.js b/web/lib/vgl/camera.js
index 1584491..3bd87bf 100644
--- a/web/lib/vgl/camera.js
+++ b/web/lib/vgl/camera.js
@@ -224,7 +224,7 @@ vglModule.camera = function() {
     if(vec3.dot(temp, m_cache) < 0.0)
     {
       m_viewUp[0] = -m_viewUp[0];
-      m_viewUp[1] = -m_viewUp[1];s
+      m_viewUp[1] = -m_viewUp[1];
       m_viewUp[2] = -m_viewUp[2];
       mat4.lookAt(m_position, m_focalPoint, m_viewUp, m_viewMatrix);
     }
diff --git a/web/lib/vgl/geomData.js b/web/lib/vgl/geomData.js
index ae7c721..c0f1d71 100644
--- a/web/lib/vgl/geomData.js
+++ b/web/lib/vgl/geomData.js
@@ -223,17 +223,30 @@ inherit(vglModule.triangles, vglModule.primitive);
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.vertexDataP3f = function() {
-    this.m_position = [];
+  if (!(this instanceof vglModule.vertexDataP3f)) {
+    return new vglModule.vertexDataP3f();
+  }
+
+  this.m_position = [];
 };
 
 vglModule.vertexDataP3N3f = function() {
-    this.m_position = [];
-    this.m_normal = [];
+
+  if (!(this instanceof vglModule.vertexDataP3N3f)) {
+    return new vglModule.vertexDataP3N3f();
+  }
+
+  this.m_position = [];
+  this.m_normal = [];
 };
 
 vglModule.vertexDataP3T3f = function() {
-    this.m_position = [];
-    this.m_texCoordinate = [];
+  if (!(this instanceof vglModule.vertexDataP3T3f)) {
+    return new vglModule.vertexDataP3T3f();
+  }
+
+  this.m_position = [];
+  this.m_texCoordinate = [];
 };
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/web/lib/vgl/mapper.js b/web/lib/vgl/mapper.js
index 4ae6fb9..62398cf 100644
--- a/web/lib/vgl/mapper.js
+++ b/web/lib/vgl/mapper.js
@@ -36,7 +36,7 @@
 vglModule.mapper = function() {
 
   if (!(this instanceof vglModule.mapper)) {
-    return new mapper();
+    return new vglModule.mapper();
   }
   vglModule.boundingObject.call(this);
 
diff --git a/web/lib/vgl/materialAttribute.js b/web/lib/vgl/materialAttribute.js
index 969b5f5..a8e13c5 100644
--- a/web/lib/vgl/materialAttribute.js
+++ b/web/lib/vgl/materialAttribute.js
@@ -48,7 +48,7 @@ vglModule.materialAttribute = function(type) {
 
   this.enabled = function() {
     return m_enabled;
-  }
+  };
 
   this.setup = function(renderState) {
     return false;
diff --git a/web/lib/vgl/object.js b/web/lib/vgl/object.js
index ca606c5..34e2615 100644
--- a/web/lib/vgl/object.js
+++ b/web/lib/vgl/object.js
@@ -39,11 +39,11 @@ vglModule.object = function() {
 
   this.modifiedOn = function() {
     m_modified = true;
-  }
+  };
 
   this.modifiedOff = function() {
     m_modified = false;
-  }
+  };
 
   return this;
 };
\ No newline at end of file
diff --git a/web/lib/vgl/planeSource.js b/web/lib/vgl/planeSource.js
index cb7d509..62e3baa 100644
--- a/web/lib/vgl/planeSource.js
+++ b/web/lib/vgl/planeSource.js
@@ -39,7 +39,7 @@ vglModule.planeSource = function() {
     m_origin[0] = x;
     m_origin[1] = y;
     m_origin[2] = z;
-  }
+  };
 
   /**
    * Set point that defines the first axis of the plane
@@ -49,7 +49,7 @@ vglModule.planeSource = function() {
     m_point1[0] = x;
     m_point1[1] = y;
     m_point1[2] = z;
-  }
+  };
 
   /**
    * Set point that defines the first axis of the plane
@@ -59,7 +59,7 @@ vglModule.planeSource = function() {
     m_point2[0] = x;
     m_point2[1] = y;
     m_point2[2] = z;
-  }
+  };
 
   /**
    * Create a plane geometry given input parameters
@@ -72,7 +72,7 @@ vglModule.planeSource = function() {
     x.length = 3, tc.length = 2, v1.length = 3, v2.length = 3;
 
     var  pts = []; pts.length = 3;
-    var i, j, k, ii;
+    var i, j, ii;
     var numPts;
     var numPolys;
     var posIndex = 0, normIndex = 0, colorIndex = 0, texCoordIndex = 0;
diff --git a/web/lib/vgl/source.js b/web/lib/vgl/source.js
index 0774996..4de956c 100644
--- a/web/lib/vgl/source.js
+++ b/web/lib/vgl/source.js
@@ -29,7 +29,7 @@ vglModule.source = function() {
    *
    */
   this.create = function() {
-  }
+  };
 
   return this;
 };

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=d1410c19b0c64d99e709ead16467e3466bd0b0e8
commit d1410c19b0c64d99e709ead16467e3466bd0b0e8
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 2 09:26:00 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 2 12:40:43 2013 -0500

    Consistent code style

diff --git a/web/lib/app.js b/web/lib/app.js
index 59c6738..5251051 100644
--- a/web/lib/app.js
+++ b/web/lib/app.js
@@ -17,9 +17,14 @@
  ========================================================================*/
 
 // Disable console log
-//  console.log = function() {}
+// console.log = function() {}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// main program
+//
+///////////////////////////////////////////////////////////////////////////////
 
-///---------------------------------------------------------------------------
 function main() {
 
   var mapOptions = {
@@ -38,5 +43,4 @@ function main() {
     // For test purposes only
     console.log("Yohoo.....camera has been moved or something");
   });
-
 }
diff --git a/web/lib/vgl/actor.js b/web/lib/vgl/actor.js
index 4027c5e..0226f86 100644
--- a/web/lib/vgl/actor.js
+++ b/web/lib/vgl/actor.js
@@ -57,15 +57,14 @@ vglModule.actor = function() {
   };
 
   /**
-   * Get rotation defined by angle (radians) and axis (axis(x, y, z), angle)
+   * Get rotation defined by axis-angle (axis(x, y, z), angle)
    *
    */
-
   this.rotation = function() {
   };
 
   /**
-   * Set rotation defined by angle (radians) and axis (axis(x, y, z), angle)
+   * Set rotation defined by axis-angle (angle in radians)
    *
    */
   this.setRotation = function(angle, x, y, z) {
@@ -116,7 +115,7 @@ vglModule.actor = function() {
   };
 
   /**
-   * Evaluate the transform associated with the vtkvglModule.actor.
+   * Evaluate the transform associated with the actor.
    *
    * @returns Affine transformation for the vglModule.actor.
    */
@@ -127,23 +126,25 @@ vglModule.actor = function() {
   };
 
   /**
+   * Return modelview matrix for the actor
    *
-   *
+   * @returns mat4
    */
   this.matrix = function() {
     return this.modelViewMatrix();
   };
 
   /**
-   * Get mapper of the actor
+   * Return mapper where actor gets it behavior and data
    *
+   * @returns vglModule.mapper
    */
   this.mapper = function() {
     return m_mapper;
   };
 
   /**
-   * Set mapper on the actor
+   * Connect an actor to its data source (mapper)
    *
    */
   this.setMapper = function(mapper) {
@@ -167,6 +168,8 @@ vglModule.actor = function() {
   /**
    * Compute object space to world space matrix
    *
+   * TODO Implement this
+   *
    */
   this.computeLocalToWorldMatrix = function(matrix, visitor) {
   };
@@ -174,6 +177,8 @@ vglModule.actor = function() {
   /**
    * Compute world space to object space matrix
    *
+   * TODO Implement this
+   *
    */
   this.computeWorldToLocalMatrix = function(matrix, visitor) {
   };
@@ -184,6 +189,8 @@ vglModule.actor = function() {
    */
   this.computeBounds = function() {
   };
+
+  return this;
 };
 
 inherit(vglModule.actor, vglModule.node);
diff --git a/web/lib/vgl/boundingObject.js b/web/lib/vgl/boundingObject.js
index 8e5f2bf..ebddde5 100644
--- a/web/lib/vgl/boundingObject.js
+++ b/web/lib/vgl/boundingObject.js
@@ -23,53 +23,56 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.boundingObject = function() {
+
+  if (!(this instanceof vglModule.boundingObject)) {
+    return new vglModule.boundingObject();
+  }
   vglModule.object.call(this);
 
-  this.m_boundsDirty = true;
-  this.m_bounds = new Array(6);
-};
+  var m_boundsDirty = true;
+  var m_bounds = new Array(6);
 
-inherit(vglModule.boundingObject, vglModule.object);
+  /// Return dirty state of bounds
+  this.boundsDirty = function() {
+    return m_boundsDirty;
+  };
+
+  /// Set bounds dirty
+  this.setBoundsDirty = function(flag) {
+    if (m_boundsDirty !== flag) {
+      m_boundsDirty = flag;
+      this.modifiedOn();
+      return true;
+    }
+
+    return false;
+  };
+
+  /// Return current bounds
+  this.bounds  = function() {
+    return m_bounds;
+  };
+
+  /// Set current bounds
+  this.setBounds = function(minX, maxX, minY, maxY,
+                                                    minZ, maxZ) {
+    m_bounds[0] = minX;
+    m_bounds[1] = maxX;
+    m_bounds[2] = minY;
+    m_bounds[3] = maxY;
+    m_bounds[4] = minZ;
+    m_bounds[5] = maxZ;
 
-/// Return dirty state of bounds
-//----------------------------------------------------------------------------
-vglModule.boundingObject.prototype.boundsDirty = function() {
-  return this.m_boundsDirty;
-};
-/// Set bounds dirty
-//----------------------------------------------------------------------------
-vglModule.boundingObject.prototype.setBoundsDirty = function(flag) {
-  if (this.m_boundsDirty !== flag) {
-    this.m_boundsDirty = flag;
     this.modifiedOn();
+
     return true;
-  }
+  };
 
-  return false;
-};
+  /// Request computing bounds. Should be implemented by the concrete class
+  this.computeBounds = function() {
+  };
 
-/// Return current bounds
-//----------------------------------------------------------------------------
-vglModule.boundingObject.prototype.bounds  = function() {
-  return this.m_bounds;
-};
-/// Set current bounds
-//----------------------------------------------------------------------------
-vglModule.boundingObject.prototype.setBounds = function(minX, maxX, minY, maxY,
-                                                  minZ, maxZ) {
-  this.m_bounds[0] = minX;
-  this.m_bounds[1] = maxX;
-  this.m_bounds[2] = minY;
-  this.m_bounds[3] = maxY;
-  this.m_bounds[4] = minZ;
-  this.m_bounds[5] = maxZ;
-
-  this.modifiedOn();
-
-  return true;
+  return this;
 };
 
-/// Request computing bounds. Should be implemented by the concrete class
-//----------------------------------------------------------------------------
-vglModule.boundingObject.prototype.computeBounds = function() {
-};
+inherit(vglModule.boundingObject, vglModule.object);
diff --git a/web/lib/vgl/camera.js b/web/lib/vgl/camera.js
index 6abe165..1584491 100644
--- a/web/lib/vgl/camera.js
+++ b/web/lib/vgl/camera.js
@@ -23,6 +23,10 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.camera = function() {
+
+  if (!(this instanceof vglModule.camera)) {
+    return new vglModule.camera();
+  }
   vglModule.groupNode.call(this);
 
   /// Private member variables
@@ -144,7 +148,7 @@ vglModule.camera = function() {
 
 
   /**
-   * Perform yaw on the camera give rotation in degrees
+   * Perform yaw on the camera give a rotation angle (in degrees)
    *
    */
   this.yaw = function(degrees) {
@@ -173,7 +177,7 @@ vglModule.camera = function() {
   };
 
   /**
-   * Perform pitch on the camera give rotation in degrees
+   * Perform pitch on the camera give a rotation (in degrees)
    *
    */
   this.pitch = function(degrees) {
@@ -235,16 +239,22 @@ vglModule.camera = function() {
   };
 
   /**
+   * Return view-matrix for the camera
+   *
+   * This method does not compute the view-matrix for the camera. It is
+   * assumed that a call to computeViewMatrix has been made earlier.
    *
+   * @returns mat4
    *
    */
   this.viewMatrix = function() {
     return m_viewMatrix;
-  }
+  };
 
   /**
    * Compute camera projection matrix
    *
+   *
    */
   this.computeProjectionMatrix = function(aspect, near, far) {
 
@@ -259,10 +269,14 @@ vglModule.camera = function() {
   /**
    * Return camera projection matrix
    *
+   * This method does not compute the projection-matrix for the camera. It is
+   * assumed that a call to computeProjectionMatrix has been made earlier.
    */
   this.projectionMatrix = function() {
     return m_projectionMatrix;
-  }
+  };
+
+  return this;
 };
 
-inherit(vglModule.camera, vglModule.groupNode);
\ No newline at end of file
+inherit(vglModule.camera, vglModule.groupNode);
diff --git a/web/lib/vgl/geomData.js b/web/lib/vgl/geomData.js
index f7e92fe..ae7c721 100644
--- a/web/lib/vgl/geomData.js
+++ b/web/lib/vgl/geomData.js
@@ -80,64 +80,99 @@ var vesPrimitiveIndicesValueType = {
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.primitive = function() {
-  this.m_indexCount = 0;
-  this.m_primitiveType = 0;
-  this.m_indicesValueType = 0;
-  this.m_indices = 0;
-};
 
-/// Data
-vglModule.primitive.prototype.indices = function() {
-  return this.m_indices;
-};
+  if (!(this instanceof vglModule.primitive)) {
+    return new vglModule.primitive();
+  }
 
-///
-vglModule.primitive.prototype.createIndices = function(type) {
-  // TODO Check for the type
-  this.m_indices = new Uint16Array();
-};
+  /// Private member variables
+  var m_indexCount = 0;
+  var m_primitiveType = 0;
+  var m_indicesValueType = 0;
+  var m_indices = 0;
 
-/// Return the number of indices
-vglModule.primitive.prototype.numberOfIndices = function() {
-  return this.m_indices.length;
-};
+  this.indices = function() {
+    return m_indices;
+  };
 
-/// Return size of indices in bytes
-vglModule.primitive.prototype.sizeInBytes = function() {
-  return this.m_indices.length * Uint16Array.BYTES_PER_ELEMENT;
-};
+  this.createIndices = function(type) {
+    // TODO Check for the type
+    m_indices = new Uint16Array();
+  };
 
-/// Return primitive type
-vglModule.primitive.prototype.primitiveType = function() {
-  return this.m_primitiveType;
-};
-/// Set primitive type
-vglModule.primitive.prototype.setPrimitiveType = function(type) {
-  this.m_primitiveType = type;
-};
+  /**
+   * Return the number of indices
+   *
+   */
+  this.numberOfIndices = function() {
+    return m_indices.length;
+  };
 
-///
-vglModule.primitive.prototype.indexCount = function() {
-  return this.m_indexCount;
-};
-/// Set index count (how many indices form a primitive)
-vglModule.primitive.prototype.setIndexCount = function(count) {
-  this.m_indexCount = count;
-};
+  /**
+   * Return size of indices in bytes
+   *
+   */
+  this.sizeInBytes = function() {
+    return m_indices.length * Uint16Array.BYTES_PER_ELEMENT;
+  };
 
-/// Return indices value type
-vglModule.primitive.prototype.indicesValueType = function() {
-  return this.m_indicesValueType;
-};
-/// Set indices value type
-vglModule.primitive.prototype.setIndicesValueType = function(type) {
-  this.m_indicesValueType  = type;
-};
+  /*
+   * Return primitive type
+   *
+   */
+  this.primitiveType = function() {
+    return m_primitiveType;
+  };
+
+  /**
+   * Set primitive type
+   *
+   */
+  this.setPrimitiveType = function(type) {
+    m_primitiveType = type;
+  };
+
+  /**
+   * Return index count ((how many indices form a primitive) of the primitive
+   *
+   */
+  this.indexCount = function() {
+    return m_indexCount;
+  };
+
+  /**
+   * Set index count (how many indices form a primitive)
+   *
+   */
+  this.setIndexCount = function(count) {
+    m_indexCount = count;
+  };
+
+  /**
+   * Return indices value type
+   *
+   */
+  this.indicesValueType = function() {
+    return m_indicesValueType;
+  };
+  /*
+   * Set indices value type
+   *
+   */
+  this.setIndicesValueType = function(type) {
+    m_indicesValueType  = type;
+  };
+
+  /**
+   * Set indices from a array
+   *
+   */
+  this.setIndices = function(indicesArray) {
+    // TODO Check for the type
+    m_indices = new Uint16Array(indicesArray);
+  };
 
-/// Set indices from a array
-vglModule.primitive.prototype.setIndices = function(indicesArray) {
-  // TODO Check for the type
-  this.m_indices = new Uint16Array(indicesArray);
+  return this;
 };
 
 //////////////////////////////////////////////////////////////////////////////
@@ -147,6 +182,11 @@ vglModule.primitive.prototype.setIndices = function(indicesArray) {
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.triangleStrip = function() {
+
+  if (!(this instanceof vglModule.triangleStrip)) {
+    return new vglModule.triangleStrip();
+  }
+
   vglModule.primitive.call(this);
 
   this.setPrimitiveType(gl.TRIANGLE_STRIP);
@@ -163,6 +203,10 @@ inherit(vglModule.triangleStrip, vglModule.primitive);
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.triangles = function() {
+
+  if (!(this instanceof vglModule.triangles)) {
+    return new vglModule.triangles();
+  }
   vglModule.primitive.call(this);
 
   this.setPrimitiveType(gl.TRIANGLES);
@@ -200,16 +244,11 @@ vglModule.vertexDataP3T3f = function() {
 
 vglModule.sourceData = function() {
 
-  /**
-   * Check against no use of new()
-   */
   if (!(this instanceof vglModule.sourceData)) {
     return new vglModule.sourceData();
   }
 
-  /**
-   * Private variables
-   */
+  /// Private member variables
   var m_attributesMap = {};
   var m_data = [];
   var m_glData = null;
@@ -236,13 +275,18 @@ vglModule.sourceData = function() {
     this.m_offset = 0;
   };
 
-  /// Return data
+  /**
+   * Return raw data for this source
+   *
+   * @returns {Float32Array}
+   */
   this.data = function() {
     this.m_glData = new Float32Array(m_data);
     return this.m_glData;
   };
 
   /**
+   * Add new attribute data to the source
    *
    */
   this.addAttribute =
@@ -262,14 +306,16 @@ vglModule.sourceData = function() {
   };
 
   /**
-   * Return size of the data
+   * Return size of the source data
+   *
    */
   this.sizeOfArray = function() {
     return Object.size(m_data);
   };
 
   /**
-   * Return size of the data in bytes
+   * Return size of the source data in bytes
+   *
    */
   this.sizeInBytes = function() {
     var sizeInBytes = 0;
@@ -287,6 +333,7 @@ vglModule.sourceData = function() {
 
   /**
    * Check if there is attribute exists of a given key type
+   *
    */
   this.hasKey = function(key) {
     return (key in m_attributesMap);
@@ -294,12 +341,14 @@ vglModule.sourceData = function() {
 
   /**
    * Return keys of all attributes
+   *
    */
   this.keys = function() {
     return Object.keys(m_attributesMap);
   };
 
   /**
+   * Return number of attributes of source data
    *
    */
   this.numberOfAttributes = function() {
@@ -307,6 +356,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Return number of components of the attribute data
    *
    */
   this.attributeNumberOfComponents = function(key) {
@@ -318,6 +368,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Return if the attribute data is normalized
    *
    */
   this.normalized = function(key) {
@@ -329,6 +380,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Return size of the attribute data type
    *
    */
   this.sizeOfAttributeDataType = function(key) {
@@ -340,6 +392,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Return attribute data type
    *
    */
   this.attributeDataType = function(key) {
@@ -351,6 +404,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Return attribute offset
    *
    */
   this.attributeOffset = function(key) {
@@ -362,6 +416,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Return attribute stride
    *
    */
   this.attributeStride = function(key) {
@@ -373,6 +428,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Virtual function to insert new vertex data at the end
    *
    */
   this.pushBack = function(vertexData) {
@@ -380,6 +436,7 @@ vglModule.sourceData = function() {
   };
 
   /**
+   * Insert new data block to the raw data
    *
    */
   this.insert = function(data) {
@@ -396,13 +453,10 @@ vglModule.sourceData = function() {
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.sourceDataP3T3f = function() {
-  /**
-   * Check against no use of new()
-   */
+
   if (!(this instanceof vglModule.sourceDataP3T3f)) {
     return new vglModule.sourceDataP3T3f();
   }
-
   vglModule.sourceData.call(this);
 
   this.addAttribute(vertexAttributeKeys.Position,
@@ -410,9 +464,6 @@ vglModule.sourceDataP3T3f = function() {
   this.addAttribute(vertexAttributeKeys.TextureCoordinate,
                     gl.FLOAT, 4, 12, 6 * 4, 3, false);
 
-  /**
-   *
-   */
   this.pushBack = function(value) {
     this.insert(value.m_position);
     this.insert(value.m_texCoordinate);
@@ -430,9 +481,7 @@ inherit(vglModule.sourceDataP3T3f, vglModule.sourceData);
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.sourceDataP3N3f = function() {
-  /**
-   * Check against no use of new()
-   */
+
   if (!(this instanceof sourceDataP3N3f)) {
     return new sourceDataP3N3f();
   }
@@ -445,9 +494,6 @@ vglModule.sourceDataP3N3f = function() {
                     gl.FLOAT, 4, 12, 6 * 4, 3, false);
 
 
-  /**
-   *
-   */
   this.pushBack = function(value) {
     this.insert(value.m_position);
     this.insert(value.m_normal);
@@ -463,10 +509,7 @@ vglModule.sourceDataP3N3f = function() {
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.sourceDataP3fv = function() {
-  /**
-   * Check
-   *
-   */
+
   if (!(this instanceof vglModule.sourceDataP3fv)) {
     return new vglModule.sourceDataP3fv();
   }
@@ -477,10 +520,6 @@ vglModule.sourceDataP3fv = function() {
                     gl.FLOAT, 4,  0, 3 * 4, 3, false);
 
 
-  /**
-   *
-   *
-   */
   this.pushBack = function(value) {
     this.insert(value);
   };
diff --git a/web/lib/vgl/groupNode.js b/web/lib/vgl/groupNode.js
index 703ab94..6f930ef 100644
--- a/web/lib/vgl/groupNode.js
+++ b/web/lib/vgl/groupNode.js
@@ -16,113 +16,111 @@
   limitations under the License.
  ========================================================================*/
 
-//////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 //
 // groupNode class
 //
-//////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 
 vglModule.groupNode = function() {
-  vglModule.node.call(this);
-  this.m_children = [];
-};
-
-inherit(vglModule.groupNode, vglModule.node);
-
-///
-vglModule.groupNode.prototype.setVisible = function(flag) {
-  if (node.prototype.setVisible.call(this, flag) !== true) {
-    return false;
-  }
 
-  for (var i = 0; i < this.m_children.length; ++i) {
-    this.m_children[i].setVisible(flag);
+  if (!(this instanceof vglModule.groupNode)) {
+    return new vglModule.groupNode();
   }
+  vglModule.node.call(this);
 
-  return true;
-};
+  var m_children = [];
 
-///
-vglModule.groupNode.prototype.addChild = function(childNode) {
-  if (childNode instanceof vglModule.node) {
-    if (this.m_children.indexOf(childNode) === -1) {
-      childNode.setParent(this);
-      this.m_children.push(childNode);
-      this.setBoundsDirty(true);
-
-      return true;
+  this.setVisible = function(flag) {
+    if (node.prototype.setVisible.call(this, flag) !== true) {
+      return false;
     }
-    return false;
-  }
 
-  return false;
-};
+    for (var i = 0; i < m_children.length; ++i) {
+      m_children[i].setVisible(flag);
+    }
 
-///
-vglModule.groupNode.prototype.removeChild = function(childNode) {
-  if (childNode.parent() === this) {
-    var index = this.m_children.indexof(childNode);
-    this.m_children.splice(index, 1);
-    this.setBoundsDirty(true);
     return true;
-  }
-};
-
-///
-vglModule.groupNode.prototype.children = function() {
-  return this.m_children;
-};
+  };
+
+  this.addChild = function(childNode) {
+    if (childNode instanceof vglModule.node) {
+      if (m_children.indexOf(childNode) === -1) {
+        childNode.setParent(this);
+        m_children.push(childNode);
+        this.setBoundsDirty(true);
+
+        return true;
+      }
+      return false;
+    }
 
-///
-vglModule.groupNode.prototype.accept = function(visitor) {
-  visitor.visit(this);
-};
+    return false;
+  };
 
-///
-vglModule.groupNode.prototype.traverse = function(visitor) {
-  switch (visitor.type()) {
-  case visitor.UpdateVisitor:
-    this.traverseChildrenAndUpdateBounds(visitor);
-    break;
-  case visitor.CullVisitor:
-    this.traverseChildren(visitor);
-    break;
-  default:
-    break;
-  }
-};
+  this.removeChild = function(childNode) {
+    if (childNode.parent() === this) {
+      var index = m_children.indexof(childNode);
+      m_children.splice(index, 1);
+      this.setBoundsDirty(true);
+      return true;
+    }
+  };
+
+  this.children = function() {
+    return m_children;
+  };
+
+  this.accept = function(visitor) {
+    visitor.visit(this);
+  };
+
+  this.traverse = function(visitor) {
+    switch (visitor.type()) {
+    case visitor.UpdateVisitor:
+      this.traverseChildrenAndUpdateBounds(visitor);
+      break;
+    case visitor.CullVisitor:
+      this.traverseChildren(visitor);
+      break;
+    default:
+      break;
+    }
+  };
 
-///
-vglModule.groupNode.prototype.traverseChildrenAndUpdateBounds = function(visitor) {
-  this.computeBounds();
+  this.traverseChildrenAndUpdateBounds = function(visitor) {
+    this.computeBounds();
 
-  if (visitor.mode() === visitor.TraverseAllChildren) {
-    for (var i = 0; i < this.m_children.length(); ++i) {
-      this.m_children[i].accept(visitor);
-      this.updateBounds(this.m_children[i]);
+    if (visitor.mode() === visitor.TraverseAllChildren) {
+      for (var i = 0; i < m_children.length(); ++i) {
+        m_children[i].accept(visitor);
+        this.updateBounds(m_children[i]);
+      }
     }
-  }
 
-  if (this.m_parent && this.boundsDirty()) {
-    // Flag parents bounds dirty.
-    this.m_parent.setBoundsDirty(true);
-  }
+    if (this.m_parent && this.boundsDirty()) {
+      // Flag parents bounds dirty.
+      this.m_parent.setBoundsDirty(true);
+    }
 
-  // Since by now, we have updated the node bounds it is
-  // safe to mark that bounds are no longer dirty anymore
-  this.setBoundsDirty(false);
-};
+    // Since by now, we have updated the node bounds it is
+    // safe to mark that bounds are no longer dirty anymore
+    this.setBoundsDirty(false);
+  };
 
-///
-vglModule.groupNode.prototype.traverseChildren = function(visitor) {
-  if (visitor.mode() == vesVisitor.TraverseAllChildren) {
-    for (var i = 0; i < this.m_children.length(); ++i) {
-      this.m_children[i].accept(visitor);
+  this.traverseChildren = function(visitor) {
+    if (visitor.mode() == vesVisitor.TraverseAllChildren) {
+      for (var i = 0; i < m_children.length(); ++i) {
+        m_children[i].accept(visitor);
+      }
     }
-  }
-};
+  };
+
+  this.updateBounds = function(childNode) {
+    // TODO: Compute bounds here
+  };
 
-///
-vglModule.groupNode.prototype.updateBounds = function(childNode) {
-  // TODO: Compute bounds here
+  return this;
 };
+
+inherit(vglModule.groupNode, vglModule.node);
diff --git a/web/lib/vgl/mapper.js b/web/lib/vgl/mapper.js
index df78e68..4ae6fb9 100644
--- a/web/lib/vgl/mapper.js
+++ b/web/lib/vgl/mapper.js
@@ -45,17 +45,25 @@ vglModule.mapper = function() {
   var m_buffers = [];
   var m_bufferVertexAttributeMap = {};
 
-  /// Compute bounds of the data
+  /**
+   * Compute bounds of the data
+   *
+   */
   this.computeBounds = function() {
   };
 
-  /// Return stored geometry data if any
-
+  /**
+   * Return stored geometry data if any
+   *
+   */
   this.geometryData = function() {
     return m_geomData;
   };
 
-  /// Set geometry data for the mapper
+  /**
+   * Connect mapper to its geometry data
+   *
+   */
   this.setGeometryData = function(geom) {
     if (m_geomData !== geom )   {
       m_geomData = geom;
@@ -65,28 +73,21 @@ vglModule.mapper = function() {
     }
   };
 
-  /// Render
-
+  /**
+   * Render the mapper
+   *
+   */
   this.render = function(renderState) {
-    // Bind material
-
-    console.log('render 0');
-
     if (m_dirty) {
-
       this.setupDrawObjects(renderState);
     }
 
-    console.log('render 1');
-
     // TODO Use renderState
     var bufferIndex = 0;
     var i = null;
     var j = 0;
     for (i in m_bufferVertexAttributeMap) {
-      console.log('render 2');
       if (m_bufferVertexAttributeMap.hasOwnProperty(i)) {
-        console.log("foo1");
         gl.bindBuffer(gl.ARRAY_BUFFER, m_buffers[bufferIndex]);
         for (j = 0; j < m_bufferVertexAttributeMap[i].length; ++j) {
           renderState.m_material.bindVertexData(
@@ -96,38 +97,31 @@ vglModule.mapper = function() {
       }
     }
 
-    console.log('render 3');
     var noOfPrimitives = m_geomData.numberOfPrimitives();
     for (j = 0; j < noOfPrimitives; ++j) {
-      console.log('render 4');
       gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, m_buffers[bufferIndex++]);
-      console.log('render 5');
       var primitive = m_geomData.primitive(j);//
       gl.drawElements(primitive.primitiveType(), primitive.numberOfIndices(),
                       primitive.indicesValueType(),  0);
     }
-
-    // Unbind material
   };
 
-  ///
-  /// Internal methods
-  //
-  ///////////////////////////////////////////////////////////////////////////////
-
-  /// Delete previously created buffers
-
+  /**
+   * Delete cached VBO if any
+   *
+   */
   this.deleteVertexBufferObjects = function() {
     for (var i = 0 ; i < m_buffers.length; ++i)   {
       gl.deleteBuffer(m_buffers[i]);
     }
   };
 
-  /// Create new buffers
-
+  /**
+   * Create new VBO for all its geometryData sources and primitives
+   *
+   */
   this.createVertexBufferObjects = function() {
     if (m_geomData) {
-      console.log("creting buffer objects");
       var numberOfSources = m_geomData.numberOfSources();
       var i = 0;
       var bufferId = null;
@@ -137,8 +131,6 @@ vglModule.mapper = function() {
         gl.bufferData(gl.ARRAY_BUFFER, m_geomData.source(i).data(),
                       gl.STATIC_DRAW);
 
-        console.log("creting buffer objects 2");
-
         keys = m_geomData.source(i).keys();
         ks = [];
         for (var j = 0; j < keys.length; ++j) {
@@ -151,30 +143,28 @@ vglModule.mapper = function() {
 
       var numberOfPrimitives = m_geomData.numberOfPrimitives();
       for (var k = 0; k < numberOfPrimitives; ++k) {
-        console.log("creting buffer objects 3");
-
         bufferId = gl.createBuffer();
         gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferId);
         gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, m_geomData.primitive(k).indices(),
                      gl.STATIC_DRAW);
-
-        console.log("creting buffer objects 4");
         m_buffers[i++] = bufferId;
       }
     }
-
-    console.log("creting buffer objects 5");
   };
 
-  /// Clear cache related to buffers
-
+  /**
+   * Clear cache related to buffers
+   *
+   */
   this.cleanUpDrawObjects = function() {
   m_bufferVertexAttributeMap = {};
     m_buffers = [];
   };
 
-  /// Setup draw objects; Delete old ones and create new ones
-
+  /**
+   * Setup draw objects; Delete old ones and create new ones
+   *
+   */
   this.setupDrawObjects = function(renderState) {
     // Delete buffer objects from past if any.
     this.deleteVertexBufferObjects();
@@ -191,4 +181,4 @@ vglModule.mapper = function() {
   return this;
 };
 
-inherit(vglModule.mapper, vglModule.boundingObject);
\ No newline at end of file
+inherit(vglModule.mapper, vglModule.boundingObject);
diff --git a/web/lib/vgl/material.js b/web/lib/vgl/material.js
index 43a7ec0..48a05c9 100644
--- a/web/lib/vgl/material.js
+++ b/web/lib/vgl/material.js
@@ -52,7 +52,6 @@ vglModule.material = function() {
     this.modifiedOn();
   };
 
-
   this.exists = function(attr) {
     if (attr.type() === vglModule.materialAttribute.Texture) {
       return m_textureAttributes.hasOwnProperty(attr);
@@ -61,7 +60,6 @@ vglModule.material = function() {
     }
   };
 
-
   this.addAttribute = function(attr) {
 
     if (this.exists(attr)) {
@@ -85,22 +83,18 @@ vglModule.material = function() {
     return false;
   };
 
-
   this.shaderProgram = function() {
     return m_shaderProgram;
   };
 
-
   this.render = function(renderState) {
     this.bind(renderState);
   };
 
-
   this.remove = function(renderState) {
     this.undoBind(renderState);
   };
 
-
   this.bind = function(renderState) {
 
     for (var key in m_attributes) {
@@ -131,7 +125,6 @@ vglModule.material = function() {
     }
   };
 
-
   this.bindVertexData = function(renderState, key) {
 
     for (var i in m_attributes) {
diff --git a/web/lib/vgl/materialAttribute.js b/web/lib/vgl/materialAttribute.js
index 77f63b9..969b5f5 100644
--- a/web/lib/vgl/materialAttribute.js
+++ b/web/lib/vgl/materialAttribute.js
@@ -54,7 +54,6 @@ vglModule.materialAttribute = function(type) {
     return false;
   };
 
-
   this.bind  = function(renderState) {
     return false;
   };
@@ -63,12 +62,10 @@ vglModule.materialAttribute = function(type) {
     return false;
   };
 
-
   this.setupVertexData = function(renderState, key) {
     return false;
   };
 
-
   this.bindVertexData = function(renderState, key) {
     return false;
   };
diff --git a/web/lib/vgl/modelViewMatrixStack.js b/web/lib/vgl/modelViewMatrixStack.js
index 1e1fac4..31e83f4 100644
--- a/web/lib/vgl/modelViewMatrixStack.js
+++ b/web/lib/vgl/modelViewMatrixStack.js
@@ -15,14 +15,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  ========================================================================*/
-
-
-
-/**
- * Not used right now
- */
-function modelViewMatrixStack()
-{
+/// Not used now
+function modelViewMatrixStack() {
   var mvMatrixStack = [];
 
   this.pushMatrix = function(mat) {
@@ -40,4 +34,4 @@ function modelViewMatrixStack()
 
     return mat;
   };
-}
\ No newline at end of file
+}
diff --git a/web/lib/vgl/node.js b/web/lib/vgl/node.js
index e15e239..82b42ae 100644
--- a/web/lib/vgl/node.js
+++ b/web/lib/vgl/node.js
@@ -23,109 +23,145 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.node = function() {
-  vglModule.boundingObject.call(this);
-
-  this.m_parent = null;
-  this.m_material = null;
-  this.m_visible = true;
-  this.m_overlay = false;
-};
-
-inherit(vglModule.node, vglModule.boundingObject);
-
-/// Accept visitor for scene traversal
-//----------------------------------------------------------------------------
-vglModule.node.prototype.accept = function(visitor) {
-  visitor.visit(this);
-};
 
-/// Return active material
-//----------------------------------------------------------------------------
-vglModule.node.prototype.material = function() {
-  return this.m_material;
-};
-/// Set current material
-//----------------------------------------------------------------------------
-vglModule.node.prototype.setMaterial = function(material) {
-  if (material !== this.m_material)
-  {
-    this.m_material = material;
-    this.modifiedOn();
-    return true;
+  if (!(this instanceof vglModule.node)) {
+    return new vglModule.node();
   }
+  vglModule.boundingObject.call(this);
 
-  return false;
-};
-
-/// Return node's visibility
-//----------------------------------------------------------------------------
-vglModule.node.prototype.visible = function() {
-  return this.m_visible;
-};
-/// Set visibility of the node
-//----------------------------------------------------------------------------
-vglModule.node.prototype.setVisible = function(flag) {
-  if (flag !== this.m_visible)   {
-    this.m_visible = flag;
-    this.modifiedOn();
-    return true;
-  }
-
-  return false;
-};
-
-/// Return parent of the node
-//----------------------------------------------------------------------------
-vglModule.node.prototype.parent = function() {
-  return this.m_parent;
-};
-/// Set parent of the node
-//----------------------------------------------------------------------------
-vglModule.node.prototype.setParent = function(parent) {
-  if (parent !== this.m_parent) {
-    if (this.m_parent !== null) {
-      this.m_parent.removeChild(this);
+  /// Private member variables
+  var m_parent = null;
+  var m_material = null;
+  var m_visible = true;
+  var m_overlay = false;
+
+  /// Public member methods
+
+  /**
+   * Accept visitor for scene traversal
+   *
+   */
+  this.accept = function(visitor) {
+    visitor.visit(this);
+  };
+
+  /**
+   * Return active material
+   *
+   */
+  this.material = function() {
+    return m_material;
+  };
+
+  /**
+   * Set current material
+   *
+   */
+  this.setMaterial = function(material) {
+    if (material !== m_material)
+    {
+      m_material = material;
+      this.modifiedOn();
+      return true;
     }
-    this.m_parent = parent;
-    this.modifiedOn();
-    return true;
-  }
 
-  return false;
-};
+    return false;
+  };
+
+  /**
+   * Return node's visibility
+   *
+   */
+  this.visible = function() {
+    return m_visible;
+  };
+
+  /**
+   * Set visibility of the node
+   *
+   */
+  this.setVisible = function(flag) {
+    if (flag !== m_visible)   {
+      m_visible = flag;
+      this.modifiedOn();
+      return true;
+    }
 
-/// Return if node is an overlay or not
-//----------------------------------------------------------------------------
-vglModule.node.prototype.overlay = function() {
-  return this.m_overlay;
-};
-/// Set node overlay state
-//----------------------------------------------------------------------------
-vglModule.node.prototype.setOverlay = function(flag) {
-  if (this.m_overlay !== flag)   {
-    this.m_overlay = flag;
-    this.modifiedOn();
-    return true;
-  }
+    return false;
+  };
+
+  /**
+   * Return parent of the node
+   *
+   */
+  this.parent = function() {
+    return m_parent;
+  };
+
+  /**
+   * Set parent of the node
+   *
+   */
+  this.setParent = function(parent) {
+    if (parent !== m_parent) {
+      if (m_parent !== null) {
+        m_parent.removeChild(this);
+      }
+      m_parent = parent;
+      this.modifiedOn();
+      return true;
+    }
 
-  return false;
-};
+    return false;
+  };
+
+  /**
+   * Return if node is an overlay or not
+   *
+   */
+  this.overlay = function() {
+    return m_overlay;
+  };
+
+  /**
+   * Set node overlay state
+   *
+   */
+  this.setOverlay = function(flag) {
+    if (m_overlay !== flag)   {
+      m_overlay = flag;
+      this.modifiedOn();
+      return true;
+    }
 
-///  Traverse parent and their parent and so on
-//----------------------------------------------------------------------------
-vglModule.node.prototype.ascend = function(visitor) {
-};
+    return false;
+  };
+
+  /*
+   * Traverse parent and their parent and so on
+   *
+   */
+  this.ascend = function(visitor) {
+  };
+
+  /**
+   * Traverse children
+   *
+   */
+  this.traverse = function(visitor) {
+  };
+
+  /**
+   * Virtual function to compute bounds of the node
+   *
+   */
+  this.computeBounds = function() {
+    if (this.boundsDirty())   {
+      this.resetBounds();
+    }
+  };
 
-/// Traverse children
-//----------------------------------------------------------------------------
-vglModule.node.prototype.traverse = function(visitor) {
+  return this;
 };
 
-/// Reset bounds of the vglModule.node. Actual bound calculation
-/// should be done in the concrete class.
-//----------------------------------------------------------------------------
-vglModule.node.prototype.computeBounds = function() {
-  if (this.boundsDirty())   {
-    this.resetBounds();
-  }
-};
+inherit(vglModule.node, vglModule.boundingObject);
diff --git a/web/lib/vgl/planeSource.js b/web/lib/vgl/planeSource.js
index f04d4ef..cb7d509 100644
--- a/web/lib/vgl/planeSource.js
+++ b/web/lib/vgl/planeSource.js
@@ -41,7 +41,6 @@ vglModule.planeSource = function() {
     m_origin[2] = z;
   }
 
-  /////////////////////////////////////////////////////////////////////////////
   /**
    * Set point that defines the first axis of the plane
    *
@@ -52,7 +51,6 @@ vglModule.planeSource = function() {
     m_point1[2] = z;
   }
 
-  /////////////////////////////////////////////////////////////////////////////
   /**
    * Set point that defines the first axis of the plane
    *
@@ -63,7 +61,6 @@ vglModule.planeSource = function() {
     m_point2[2] = z;
   }
 
-  /////////////////////////////////////////////////////////////////////////////
   /**
    * Create a plane geometry given input parameters
    *
@@ -129,7 +126,7 @@ vglModule.planeSource = function() {
       }
     }
 
-    // Generate polygon connectivity
+    /// Generate polygon connectivity
     for (i = 0; i < m_yresolution; i++) {
       for (j = 0; j < m_xresolution; j++) {
         pts[0] = j + i*(m_xresolution+1);
diff --git a/web/lib/vgl/renderer.js b/web/lib/vgl/renderer.js
index 78b4892..7e77e5b 100644
--- a/web/lib/vgl/renderer.js
+++ b/web/lib/vgl/renderer.js
@@ -118,6 +118,7 @@ vglModule.renderer = function() {
       renSt.m_mapper = actor.mapper();
 
       // TODO Fix this shortcut
+
       renSt.m_material.render(renSt);
       renSt.m_mapper.render(renSt);
       renSt.m_material.remove(renSt);
diff --git a/web/lib/vgl/shader.js b/web/lib/vgl/shader.js
index 785b24d..af81f21 100644
--- a/web/lib/vgl/shader.js
+++ b/web/lib/vgl/shader.js
@@ -23,69 +23,68 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.shader = function(type) {
-  vglModule.object.call(this);
-
-  this.m_shaderHandle = null;
-  this.m_shaderType =  type;
-  this.m_shaderSource = "";
-  this.m_fileName = "";
-};
-
-inherit(vglModule.shader, vglModule.object);
-
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.shaderHandle = function() {
-};
-
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.shaderType = function() {
-  return this.m_shaderType;
-};
-
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.fileName = function() {
-  return this.m_fileName;
-};
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.setFileName = function(fileName) {
-  this.m_fileName = fileName;
-};
-
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.shaderSource = function() {
-  return this.m_shaderSource;
-};
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.setShaderSource = function(source) {
-  this.m_shaderSource = source;
-
-  this.modifiedOn(true);
-};
-
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.compile = function() {
 
-  if (this.modified() === false) {
-    return null;
-  }
-
-  gl.deleteShader(this.m_shaderHandle);
-  this.m_shaderHandle = gl.createShader(this.m_shaderType);
-  gl.shaderSource(this.m_shaderHandle, this.m_shaderSource);
-  gl.compileShader(this.m_shaderHandle);
-
-  // See if it compiled successfully
-  if (!gl.getShaderParameter(this.m_shaderHandle, gl.COMPILE_STATUS)) {
-    console.log("[ERROR] An error occurred compiling the shaders: " +
-                gl.getShaderInfoLog(this.m_shaderHandle));
-    gl.deleteShader(this.m_shaderHandle);
-    return null;
+  if (!(this instanceof vglModule.shader)) {
+    return new vglModule.shader(type);
   }
+  vglModule.object.call(this);
 
-  return this.m_shaderHandle;
+  var m_shaderHandle = null;
+  var m_shaderType =  type;
+  var m_shaderSource = "";
+  var m_fileName = "";
+
+  this.shaderHandle = function() {
+  };
+
+  this.shaderType = function() {
+    return m_shaderType;
+  };
+
+  this.fileName = function() {
+    return m_fileName;
+  };
+
+  this.setFileName = function(fileName) {
+    m_fileName = fileName;
+    this.modifiedOn();
+  };
+
+  this.shaderSource = function() {
+    return m_shaderSource;
+  };
+
+  this.setShaderSource = function(source) {
+    m_shaderSource = source;
+    this.modifiedOn();
+  };
+
+  this.compile = function() {
+    if (this.modified() === false) {
+      return m_shaderHandle;
+    }
+
+    gl.deleteShader(m_shaderHandle);
+    m_shaderHandle = gl.createShader(m_shaderType);
+    gl.shaderSource(m_shaderHandle, m_shaderSource);
+    gl.compileShader(m_shaderHandle);
+
+    // See if it compiled successfully
+    if (!gl.getShaderParameter(m_shaderHandle, gl.COMPILE_STATUS)) {
+      console.log("[ERROR] An error occurred compiling the shaders: " +
+                  gl.getShaderInfoLog(m_shaderHandle));
+      gl.deleteShader(m_shaderHandle);
+      return null;
+    }
+
+    this.modifiedOff();
+
+    return m_shaderHandle;
+  };
+
+  this.attachShader = function(programHandle) {
+    gl.attachShader(programHandle, m_shaderHandle);
+  };
 };
 
-///---------------------------------------------------------------------------
-vglModule.shader.prototype.attachShader = function(programHandle) {
-  gl.attachShader(programHandle, this.m_shaderHandle);
-};
+inherit(vglModule.shader, vglModule.object);
diff --git a/web/lib/vgl/shaderProgram.js b/web/lib/vgl/shaderProgram.js
index 4cd633a..8fd840a 100644
--- a/web/lib/vgl/shaderProgram.js
+++ b/web/lib/vgl/shaderProgram.js
@@ -43,12 +43,10 @@ vglModule.shaderProgram = function() {
     return gl.getUniformLocation(m_programHandle, name);
   };
 
-
   this.queryAttributeLocation = function(name) {
     return gl.getAttribLocation(m_programHandle, name);
   };
 
-
   this.addShader = function(shader) {
     if (m_shaders.indexOf(shader) > -1)   {
       return false;
@@ -63,29 +61,24 @@ vglModule.shaderProgram = function() {
     m_shaders.push(shader);
 
     this.modifiedOn();
-
     return true;
   };
 
-
   this.addUniform = function(uniform) {
     if (m_uniforms.indexOf(uniform) > -1) {
       return false;
     }
 
     m_uniforms.push(uniform);
-
     this.modifiedOn();
   };
 
-
   this.addVertexAttribute = function(attr, key) {
     m_vertexAttributes[key] = attr;
 
     this.modifiedOn();
   };
 
-
   this.uniformLocation = function(name) {
     return m_uniformNameToLocation[name];
   };
@@ -94,12 +87,10 @@ vglModule.shaderProgram = function() {
     return m_vertexAttributeNameToLocation[name];
   };
 
-
   this.uniformExist = function() {
     // TODO
   };
 
-
   this.updateUniforms = function() {
     for (var i = 0; i < m_uniforms.length; ++i) {
       m_uniforms[i].callGL(
@@ -107,7 +98,6 @@ vglModule.shaderProgram = function() {
     }
   };
 
-
   this.link = function() {
     gl.linkProgram(m_programHandle);
 
@@ -120,35 +110,29 @@ vglModule.shaderProgram = function() {
     return true;
   };
 
-
   this.validate = function() {
     // TODO
   };
 
-
   this.use = function() {
     gl.useProgram(m_programHandle);
   };
 
-
   this.cleanUp = function() {
     this.deleteVertexAndFragment();
     this.deleteProgram();
   };
 
-
   this.deleteProgram = function() {
     gl.deleteProgram(m_programHandle);
   };
 
-
   this.deleteVertexAndFragment = function() {
     for (var i = 0; i < m_shaders.length; ++i) {
       gl.deleteShader(m_shaders[i].shaderHandle());
     }
   };
 
-
   this.bind = function(renderState) {
     var i = 0;
 
@@ -175,9 +159,7 @@ vglModule.shaderProgram = function() {
       }
 
       this.use();
-
       this.bindUniforms();
-
       this.modifiedOff();
     }
     else {
@@ -197,7 +179,6 @@ vglModule.shaderProgram = function() {
     // Do nothing
   };
 
-
   this.bindVertexData = function(renderState, key) {
     if (m_vertexAttributes.hasOwnProperty(key)) {
       m_vertexAttributes[key].bindVertexData(renderState, key);
@@ -210,7 +191,6 @@ vglModule.shaderProgram = function() {
     }
   };
 
-
   this.bindUniforms = function() {
     for (var i = 0; i < m_uniforms.length; ++i) {
       m_uniformNameToLocation[m_uniforms[i].name()] =
@@ -229,6 +209,8 @@ vglModule.shaderProgram = function() {
       m_vertexAttributeNameToLocation[name] = index++;
     }
   };
+
+  return this;
 };
 
 inherit(vglModule.shaderProgram, vglModule.materialAttribute);
diff --git a/web/lib/vgl/source.js b/web/lib/vgl/source.js
index 5d476bf..0774996 100644
--- a/web/lib/vgl/source.js
+++ b/web/lib/vgl/source.js
@@ -17,6 +17,7 @@
  ========================================================================*/
 
 vglModule.source = function() {
+
   if (!(this instanceof vglModule.source)) {
     return new vglModule.source();
   }
@@ -24,7 +25,7 @@ vglModule.source = function() {
   vglModule.object.call(this);
 
   /**
-   * Derived class should implement this method
+   * Virtual function to create a source instance
    *
    */
   this.create = function() {
diff --git a/web/lib/vgl/texture.js b/web/lib/vgl/texture.js
index ceaadac..fb17d95 100644
--- a/web/lib/vgl/texture.js
+++ b/web/lib/vgl/texture.js
@@ -48,7 +48,6 @@ vglModule.texture = function() {
 
   /// Public member methods
   this.setup = function(renderState) {
-
     gl.deleteTexture(this.m_textureHandle);
     this.m_textureHandle = gl.createTexture();
     gl.bindTexture(gl.TEXTURE_2D, this.m_textureHandle);
@@ -80,9 +79,7 @@ vglModule.texture = function() {
     this.modifiedOff();
   };
 
-
   this.bind = function(renderState) {
-
     // TODO Call setup via material setup
     if (this.modified()) {
       this.setup(renderState);
@@ -96,14 +93,12 @@ vglModule.texture = function() {
     gl.bindTexture(gl.TEXTURE_2D, null);
   };
 
-
   this.handleTextureLoaded = function(image) {
     this.m_image = image;
     this.updateDimensions();
     this.modifiedOn(true);
   };
 
-
   this.image = function() {
     return this.m_image;
   };
@@ -117,7 +112,6 @@ vglModule.texture = function() {
     return false;
   };
 
-
   this.textureUnit = function() {
     return this.m_textureUnit;
   };
@@ -132,7 +126,6 @@ vglModule.texture = function() {
     return true;
   };
 
-
   this.width = function() {
     return this.m_width;
   };
@@ -143,12 +136,11 @@ vglModule.texture = function() {
     }
 
     this.m_width = width;
-    this.modifiedOn(true);
+    this.modifiedOn();
 
     return true;
   };
 
-
   this.depth = function() {
     return this.m_depth;
   };
@@ -159,17 +151,14 @@ vglModule.texture = function() {
     }
 
     this.m_depth = depth;
-    this.modifiedOn(true);
-
+    this.modifiedOn();
     return true;
   };
 
-
   this.textureHandle = function() {
     return this.m_textureHandle;
   };
 
-
   this.internalFormat = function() {
     return this.m_internalFormat;
   };
@@ -196,7 +185,7 @@ vglModule.texture = function() {
     }
 
     this.m_pixelFormat = pixelFormat;
-    this.modifiedOn(true);
+    this.modifiedOn();
     return true;
   };
 
@@ -212,12 +201,11 @@ vglModule.texture = function() {
 
     this.m_pixelDataTYpe = pixelDataType;
 
-    this.modifiedOn(true);
+    this.modifiedOn();
 
     return true;
   };
 
-
   this.computeInternalFormatUsingImage = function() {
     // Currently image does not define internal format
     // and hence it's pixel format is the only way to query
@@ -246,7 +234,6 @@ vglModule.texture = function() {
     this.m_pixelDataType = gl.UNSIGNED_BYTE;
   };
 
-
   this.updateDimensions = function() {
     if (this.m_image !== null) {
       this.m_width = this.m_image.width;
diff --git a/web/lib/vgl/uniform.js b/web/lib/vgl/uniform.js
index eb737d9..cc984e2 100644
--- a/web/lib/vgl/uniform.js
+++ b/web/lib/vgl/uniform.js
@@ -23,6 +23,11 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.uniform = function(type, name) {
+
+  if (!(this instanceof vglModule.uniform)) {
+    return new vglModule.uniform();
+  }
+
   this.getTypeNumberOfComponents = function(type) {
     switch (type) {
       case gl.FLOAT:
@@ -56,92 +61,95 @@ vglModule.uniform = function(type, name) {
     }
   };
 
-  this.m_type = type;
-  this.m_name = name;
-  this.m_dataArray = [this.getTypeNumberOfComponents(this.m_type)];
-  this.m_numberOfElements = 1;
-};
+  var m_type = type;
+  var m_name = name;
+  var m_dataArray = [this.getTypeNumberOfComponents(m_type)];
+  var m_numberOfElements = 1;
 
-vglModule.uniform.prototype.name = function() {
-  return this.m_name;
-};
+  this.name = function() {
+    return m_name;
+  };
 
-vglModule.uniform.prototype.type = function() {
-  return this.m_type;
-};
+  this.type = function() {
+    return m_type;
+  };
 
-vglModule.uniform.prototype.get = function() {
-  // TODO
-};
+  this.get = function() {
+    // TODO
+  };
 
-vglModule.uniform.prototype.set = function(value) {
-  var i = 0;
-  if (value instanceof mat4.constructor) {
-    for (i = 0; i < 16; ++i) {
-      this.m_dataArray[i] = value[i];
+  this.set = function(value) {
+    var i = 0;
+    if (value instanceof mat4.constructor) {
+      for (i = 0; i < 16; ++i) {
+        m_dataArray[i] = value[i];
+      }
     }
-  }
-  else if (value instanceof mat3.constructor) {
-    for (i = 0; i < 9; ++i) {
-      this.m_dataArray[i] = value[i];
+    else if (value instanceof mat3.constructor) {
+      for (i = 0; i < 9; ++i) {
+        m_dataArray[i] = value[i];
+      }
     }
-  }
-  else if (value instanceof vec4.constructor) {
-    for (i = 0; i < 4; ++i) {
-      this.m_dataArray[i] = value[i];
+    else if (value instanceof vec4.constructor) {
+      for (i = 0; i < 4; ++i) {
+        m_dataArray[i] = value[i];
+      }
     }
-  }
-  else if (value instanceof vec3.constructor) {
-    for (i = 0; i < 3; ++i) {
-      this.m_dataArray[i] = value[i];
+    else if (value instanceof vec3.constructor) {
+      for (i = 0; i < 3; ++i) {
+        m_dataArray[i] = value[i];
+      }
     }
-  }
-  else if (value instanceof vec2.constructor) {
-    for (i = 0; i < 2; ++i) {
-      this.m_dataArray[i] = value[i];
+    else if (value instanceof vec2.constructor) {
+      for (i = 0; i < 2; ++i) {
+        m_dataArray[i] = value[i];
+      }
     }
-  }
-  else {
-    this.m_dataArray[0] = value;
-  }
-};
+    else {
+      m_dataArray[0] = value;
+    }
+  };
+
+  this.callGL = function(location) {
+    if (this.m_numberElements < 1)
+      return;
 
-vglModule.uniform.prototype.callGL = function(location) {
-  if (this.m_numberElements < 1)
-    return;
-
-  switch (this.m_type) {
-    case gl.BOOL:
-    case gl.INT:
-      gl.uniform1iv(location, this.m_dataArray);
-      break;
-    case gl.FLOAT:
-      gl.uniform1fv(location, this.m_dataArray);
-      break;
-    case gl.FLOAT_VEC2:
-      gl.uniform2fv(location, this.m_dataArray);
-      break;
-    case gl.FLOAT_VEC3:
-      gl.uniform3fv(location, this.m_dataArray);
-      break;
-    case gl.FLOAT_VEC4:
-      gl.uniform4fv(location, this.m_dataArray);
-      break;
-    case gl.FLOAT_MAT3:
-      gl.uniformMatrix3fv(location, gl.FALSE, this.m_dataArray);
-      break;
-    case gl.FLOAT_MAT4:
-      gl.uniformMatrix4fv(location, gl.FALSE, this.m_dataArray);
-      break;
-    default:
+    switch (m_type) {
+      case gl.BOOL:
+      case gl.INT:
+        gl.uniform1iv(location, m_dataArray);
         break;
-  }
-};
+      case gl.FLOAT:
+        gl.uniform1fv(location, m_dataArray);
+        break;
+      case gl.FLOAT_VEC2:
+        gl.uniform2fv(location, m_dataArray);
+        break;
+      case gl.FLOAT_VEC3:
+        gl.uniform3fv(location, m_dataArray);
+        break;
+      case gl.FLOAT_VEC4:
+        gl.uniform4fv(location, m_dataArray);
+        break;
+      case gl.FLOAT_MAT3:
+        gl.uniformMatrix3fv(location, gl.FALSE, m_dataArray);
+        break;
+      case gl.FLOAT_MAT4:
+        gl.uniformMatrix4fv(location, gl.FALSE, m_dataArray);
+        break;
+      default:
+          break;
+    }
+  };
 
-vglModule.uniform.prototype.update = function(renderState, program) {
-  // Should be implemented by the derived class
+  this.update = function(renderState, program) {
+    // Should be implemented by the derived class
+  };
+
+  return this;
 };
 
+
 //////////////////////////////////////////////////////////////////////////////
 //
 // modelViewUniform class
@@ -150,20 +158,27 @@ vglModule.uniform.prototype.update = function(renderState, program) {
 
 vglModule.modelViewUniform = function(name) {
 
+  if (!(this instanceof vglModule.modelViewUniform)) {
+    return new vglModule.modelViewUniform(name);
+  }
+
   if (name.length === 0) {
     name = "modelViewMatrix";
   }
 
   vglModule.uniform.call(this, gl.FLOAT_MAT4, name);
+
   this.set(mat4.create());
-};
 
-inherit(vglModule.modelViewUniform, vglModule.uniform);
+  this.update = function(renderState, program) {
+    this.set(renderState.m_modelViewMatrix);
+  };
 
-vglModule.modelViewUniform.prototype.update = function(renderState, program) {
-  this.set(renderState.m_modelViewMatrix);
+  return this;
 };
 
+inherit(vglModule.modelViewUniform, vglModule.uniform);
+
 //////////////////////////////////////////////////////////////////////////////
 //
 // projectionUniform class
@@ -171,19 +186,28 @@ vglModule.modelViewUniform.prototype.update = function(renderState, program) {
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.projectionUniform  = function(name) {
+
+  if (!(this instanceof vglModule.projectionUniform)) {
+    return new vglModule.projectionUniform(name);
+  }
+
   if (name.length === 0) {
     name = "projectionMatrix";
   }
 
   vglModule.uniform.call(this, gl.FLOAT_MAT4, name);
+
   this.set(mat4.create());
+
+  this.update = function(renderState, program) {
+    this.set(renderState.m_projectionMatrix);
+  };
+
+  return this;
 };
 
 inherit(vglModule.projectionUniform, vglModule.uniform);
 
-vglModule.projectionUniform.prototype.update = function(renderState, program) {
-  this.set(renderState.m_projectionMatrix);
-};
 
 //////////////////////////////////////////////////////////////////////////////
 //
@@ -192,11 +216,17 @@ vglModule.projectionUniform.prototype.update = function(renderState, program) {
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.floatUniform  = function(name) {
+
+  if (!(this instanceof vglModule.floatUniform)) {
+    return new vglModule.floatUniform(name);
+  }
+
   if (name.length === 0) {
     name = "floatUniform";
   }
 
   vglModule.uniform.call(this, gl.FLOAT, name);
+
   this.set(1.0);
 };
 
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index b6c265d..144e051 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -27,10 +27,10 @@
  *
  */
 vglModule.utils = function() {
+
   if (!(this instanceof vglModule.utils)) {
     return new vglModule.utils();
   }
-
   vglModule.object.call(this);
 
   return this;
diff --git a/web/lib/vgl/vertexAttribute.js b/web/lib/vgl/vertexAttribute.js
index c2f8210..bd066fa 100644
--- a/web/lib/vgl/vertexAttribute.js
+++ b/web/lib/vgl/vertexAttribute.js
@@ -31,34 +31,39 @@ vglModule.vertexAttributeKeys = {
   "CountAttributeIndex" : 5
 };
 
-///---------------------------------------------------------------------------
+
 vglModule.vertexAttribute = function (name) {
-  this.m_name = name;
-};
 
-///---------------------------------------------------------------------------
-vglModule.vertexAttribute.prototype.name = function() {
-  return this.m_name;
-};
+  if (!(this instanceof vglModule.vertexAttribute)) {
+    return new vglModule.vertexAttribute(name);
+  }
 
-///---------------------------------------------------------------------------
-vglModule.vertexAttribute.prototype.bindVertexData = function(renderState, key) {
-  var geometryData = renderState.m_mapper.geometryData();
-  var sourceData = geometryData.sourceData(key);
-  var program = renderState.m_material.shaderProgram();
+  /// Private member variables
+  var m_name = name;
 
-  gl.vertexAttribPointer(program.attributeLocation(this.m_name),
-                        sourceData.attributeNumberOfComponents(key),
-                        sourceData.attributeDataType(key),
-                        sourceData.normalized(key),
-                        sourceData.attributeStride(key),
-                        sourceData.attributeOffset(key));
+  /// Public member methods
+  this.name = function() {
+    return m_name;
+  };
 
-  gl.enableVertexAttribArray(program.attributeLocation(this.m_name));
-};
-///---------------------------------------------------------------------------
-vglModule.vertexAttribute.prototype.undoBindVertexData = function(renderState, key) {
-  var program = renderState.m_material.shaderProgram();
+  this.bindVertexData = function(renderState, key) {
+    var geometryData = renderState.m_mapper.geometryData();
+    var sourceData = geometryData.sourceData(key);
+    var program = renderState.m_material.shaderProgram();
 
-  gl.disableVertexAttribArray(program.attributeLocation(this.m_name));
-};
\ No newline at end of file
+    gl.vertexAttribPointer(program.attributeLocation(m_name),
+                          sourceData.attributeNumberOfComponents(key),
+                          sourceData.attributeDataType(key),
+                          sourceData.normalized(key),
+                          sourceData.attributeStride(key),
+                          sourceData.attributeOffset(key));
+
+    gl.enableVertexAttribArray(program.attributeLocation(m_name));
+  };
+
+  this.undoBindVertexData = function(renderState, key) {
+    var program = renderState.m_material.shaderProgram();
+
+    gl.disableVertexAttribArray(program.attributeLocation(m_name));
+  };
+};

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=df4d6c04de3f0ba69968efd94ffafd5b459e40d9
commit df4d6c04de3f0ba69968efd94ffafd5b459e40d9
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Fri Mar 1 18:33:53 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Fri Mar 1 18:33:53 2013 -0500

    Some more improvements

diff --git a/web/lib/app.js b/web/lib/app.js
index eb34b6f..59c6738 100644
--- a/web/lib/app.js
+++ b/web/lib/app.js
@@ -30,7 +30,7 @@ function main() {
   var myMap = ogs.geo.map(document.getElementById("glcanvas"), mapOptions);
   var planeLayer = ogs.geo.featureLayer(
     {"opacity":1, "showAttribution":1, "visible":1},
-     ogs.geo.planeFeature(ogs.geo.latlng(-90.0, 0.0), ogs.geo.latlng(90.0, 180.0)));
+      ogs.geo.planeFeature(ogs.geo.latlng(-90.0, 0.0), ogs.geo.latlng(90.0, 180.0)));
 
   myMap.addLayer(planeLayer);
 
diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 05d8b4a..5a5cd76 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -175,12 +175,13 @@ geoModule.map = function(node, options) {
     }
 
     if (m_leftMouseButtonDown) {
+
       var focalPoint = m_camera.focalPoint();
       var focusWorldPt = vec4.createFrom(
         focalPoint[0], focalPoint[1], focalPoint[2], 1);
 
       var focusDisplayPt = ogs.vgl.renderer.worldToDisplay(focusWorldPt,
-        m_camera.m_viewMatrix, m_camera.m_projectionMatrix, 1680, 1050);
+        m_camera.viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
 
       var displayPt1 = vec4.createFrom(
         currentMousePos.x, currentMousePos.y, focusDisplayPt[2], 1.0);
@@ -188,11 +189,11 @@ geoModule.map = function(node, options) {
         m_mouseLastPos.x, m_mouseLastPos.y, focusDisplayPt[2], 1.0);
 
       var worldPt1 = ogs.vgl.renderer.displayToWorld(
-        displayPt1, m_camera.m_viewMatrix,
-        m_camera.m_projectionMatrix, 1680, 1050);
+        displayPt1, m_camera.viewMatrix(),
+        m_camera.projectionMatrix(), 1680, 1050);
       var worldPt2 = ogs.vgl.renderer.displayToWorld(
-        displayPt2, m_camera.m_viewMatrix,
-        m_camera.m_projectionMatrix, 1680, 1050);
+        displayPt2, m_camera.viewMatrix(),
+        m_camera.projectionMatrix(), 1680, 1050);
 
       dx = worldPt1[0] - worldPt2[0];
       dy = worldPt1[1] - worldPt2[1];
@@ -303,8 +304,6 @@ geoModule.map = function(node, options) {
    */
   this.addLayer = function(layer) {
 
-    console.log('layer is ' + layer);
-
     if (layer != null) {
       // TODO Check if the layer already exists
       // TODO Set the rendering order correctly
diff --git a/web/lib/vgl/actor.js b/web/lib/vgl/actor.js
index e454d53..4027c5e 100644
--- a/web/lib/vgl/actor.js
+++ b/web/lib/vgl/actor.js
@@ -31,12 +31,12 @@ vglModule.actor = function() {
   vglModule.node.call(this);
 
   /// Initialize member variables
-  this.m_center = new Array(3);
-  this.m_rotation = new Array(4);
-  this.m_scale = new Array(3);
-  this.m_translation = new Array(3);
-  this.m_referenceFrame = 0;
-  this.m_mapper = 0;
+  var m_center = new Array(3);
+  var m_rotation = new Array(4);
+  var m_scale = new Array(3);
+  var m_translation = new Array(3);
+  var m_referenceFrame = 0;
+  var m_mapper = 0;
 
   /**
    * Get center of transformations
@@ -51,9 +51,9 @@ vglModule.actor = function() {
    *
    */
   this.setCenter = function(x, y, z) {
-    this.m_center[0] = x;
-    this.m_center[1] = y;
-    this.m_center[2] = z;
+    m_center[0] = x;
+    m_center[1] = y;
+    m_center[2] = z;
   };
 
   /**
@@ -139,7 +139,7 @@ vglModule.actor = function() {
    *
    */
   this.mapper = function() {
-    return this.m_mapper;
+    return m_mapper;
   };
 
   /**
@@ -147,7 +147,7 @@ vglModule.actor = function() {
    *
    */
   this.setMapper = function(mapper) {
-    this.m_mapper = mapper;
+    m_mapper = mapper;
   };
 
   /**
diff --git a/web/lib/vgl/boundingObject.js b/web/lib/vgl/boundingObject.js
index a698615..8e5f2bf 100644
--- a/web/lib/vgl/boundingObject.js
+++ b/web/lib/vgl/boundingObject.js
@@ -41,7 +41,7 @@ vglModule.boundingObject.prototype.boundsDirty = function() {
 vglModule.boundingObject.prototype.setBoundsDirty = function(flag) {
   if (this.m_boundsDirty !== flag) {
     this.m_boundsDirty = flag;
-    this.setModified();
+    this.modifiedOn();
     return true;
   }
 
@@ -64,7 +64,7 @@ vglModule.boundingObject.prototype.setBounds = function(minX, maxX, minY, maxY,
   this.m_bounds[4] = minZ;
   this.m_bounds[5] = maxZ;
 
-  this.setModified();
+  this.modifiedOn();
 
   return true;
 };
diff --git a/web/lib/vgl/camera.js b/web/lib/vgl/camera.js
index 5d1ab17..6abe165 100644
--- a/web/lib/vgl/camera.js
+++ b/web/lib/vgl/camera.js
@@ -25,182 +25,244 @@
 vglModule.camera = function() {
   vglModule.groupNode.call(this);
 
-  this.m_viewAngle = 30;
-  this.m_position = vec3.create([0.0, 0.0, 5.0]);
-  this.m_focalPoint = vec3.create([0.0, 0.0, 0.0]);
-  this.m_viewUp = vec3.create([0.0, 1.0, 0.0]);
-  this.m_right = vec3.create([1.0, 0.0, 0.0]);
-  this.m_pitchMatrix = mat4.create();
-  this.m_directionOfProjection = vec3.createFrom(0.0, 0.0, -1.0);
-  this.m_cache = vec3.create([1.0, 0.0, 0.0]);
-
-  this.m_viewMatrix = mat4.create();
-  this.m_projectionMatrix = mat4.create();
-
-  mat4.identity(this.m_pitchMatrix);
-};
-
-inherit(vglModule.camera, vglModule.groupNode);
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.setPosition = function(x, y, z) {
-  this.m_position = vec3.create([x, y, z]);
-};
-///---------------------------------------------------------------------------
-vglModule.camera.prototype.position = function() {
-  return this.m_position;
-};
-
-///---------------------------------------------------------------------------
-vglModule.camera.prototype.setFocalPoint = function(x, y, z) {
-  this.m_focalPoint = vec3.create([x, y, z]);
-};
-//////---------------------------------------------------------------------------
-vglModule.camera.prototype.focalPoint = function() {
-  return this.m_focalPoint;
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.setViewUpDirection = function(x, y, z) {
-  this.m_viewUp = vec3.create([x, y, z]);
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.zoom  = function(dz) {
-  // Since our direction vector is changed, we need to first
-  // calculate this new direction
-  var lastPosition = vec3.createFrom(this.m_position[0], this.m_position[1],
-                                     this.m_position[2]);
-
-  var deltaX =  this.m_directionOfProjection[0] * dz;
-  var deltaY =  this.m_directionOfProjection[1] * dz;
-  var deltaZ =  this.m_directionOfProjection[2] * dz;
-
-  this.m_position[0] += deltaX;
-  this.m_position[1] += deltaY;
-  this.m_position[2] += deltaZ;
-
-  var distance = vec3.create();
-  var directionOfProjection = vec3.create();
-  vec3.subtract(this.m_focalPoint, this.m_position, distance);
-  vec3.normalize(distance, directionOfProjection);
-
-  if (vec3.dot(directionOfProjection, this.m_directionOfProjection) <= 0) {
-    // We are on the other side of the focal point
-    this.m_position[0] = lastPosition[0];
-    this.m_position[1] = lastPosition[1];
-    this.m_position[2] = lastPosition[2];
+  /// Private member variables
+  var m_viewAngle = 30;
+  var m_position = vec3.create([0.0, 0.0, 5.0]);
+  var m_focalPoint = vec3.create([0.0, 0.0, 0.0]);
+  var m_viewUp = vec3.create([0.0, 1.0, 0.0]);
+  var m_right = vec3.create([1.0, 0.0, 0.0]);
+  var m_pitchMatrix = mat4.create();
+  var m_directionOfProjection = vec3.createFrom(0.0, 0.0, -1.0);
+  var m_cache = vec3.create([1.0, 0.0, 0.0]);
+
+  var m_viewMatrix = mat4.create();
+  var m_projectionMatrix = mat4.create();
+
+  mat4.identity(m_pitchMatrix);
+
+  /**
+   * Set position of the camera
+   *
+   */
+  this.setPosition = function(x, y, z) {
+    m_position = vec3.create([x, y, z]);
+  };
+
+  /**
+   * Get position of the camera
+   *
+   */
+  this.position = function() {
+    return m_position;
+  };
+
+  /**
+   * Set focal point of the camera
+   *
+   */
+  this.setFocalPoint = function(x, y, z) {
+    m_focalPoint = vec3.create([x, y, z]);
+  };
+
+  /**
+   * Get focal point of the camera
+   *
+   */
+  this.focalPoint = function() {
+    return m_focalPoint;
+  };
+
+  /**
+   * Set view-up direction of the camera
+   *
+   */
+  this.setViewUpDirection = function(x, y, z) {
+    m_viewUp = vec3.create([x, y, z]);
+  };
+
+
+  /**
+   * Move camera closer or further away from the scene
+   *
+   */
+  this.zoom  = function(dz) {
+    // Since our direction vector is changed, we need to first
+    // calculate this new direction
+    var lastPosition = vec3.createFrom(m_position[0], m_position[1],
+                                       m_position[2]);
+
+    var deltaX =  m_directionOfProjection[0] * dz;
+    var deltaY =  m_directionOfProjection[1] * dz;
+    var deltaZ =  m_directionOfProjection[2] * dz;
+
+    m_position[0] += deltaX;
+    m_position[1] += deltaY;
+    m_position[2] += deltaZ;
+
+    var distance = vec3.create();
+    var directionOfProjection = vec3.create();
+    vec3.subtract(m_focalPoint, m_position, distance);
+    vec3.normalize(distance, directionOfProjection);
+
+    if (vec3.dot(directionOfProjection, m_directionOfProjection) <= 0) {
+      // We are on the other side of the focal point
+      m_position[0] = lastPosition[0];
+      m_position[1] = lastPosition[1];
+      m_position[2] = lastPosition[2];
+    }
+
+//      m_focalPoint[0] += dir[0] * dz;
+//      m_focalPoint[1] += dir[1] * dz;
+//      m_focalPoint[2] += dir[2] * dz;
+
+    // TODO: If the distance between focal point and the camera position
+    // goes really low then we run into issues
+  };
+
+  /**
+   * Move camera sideways
+   *
+   */
+  this.pan = function(dx, dy) {
+    m_position[0] += dx;
+    m_position[1] += dy;
+    m_focalPoint[0] += dx;
+    m_focalPoint[1] += dy;
+  };
+
+  /**
+   * Compute camera coordinate axes
+   *
+   */
+  this.computeOrthogonalAxes = function() {
+    dir = new vec3.create();
+    vec3.direction(m_focalPoint, m_position, dir);
+    vec3.normalize(dir);
+    vec3.cross(dir, m_viewUp, m_right);
+    vec3.normalize(m_right);
+  };
+
+
+  /**
+   * Perform yaw on the camera give rotation in degrees
+   *
+   */
+  this.yaw = function(degrees) {
+    radians = degrees * (3.14 / 180.0);
+
+    mat = mat4.create();
+    mat4.identity(mat);
+
+    // We would like to rotate about focal point and to do so
+    // and since our rotation is calculated assuming that rotation point or
+    // axis is at origin, we need to inverse transte, rotate and again translate
+    // to calculate the complete transformation matrix.
+    invDir = new vec3.create();
+    invDir[0] = -m_focalPoint[0];
+    invDir[1] = -m_focalPoint[1];
+    invDir[2] = -m_focalPoint[2];
+
+    mat4.translate(mat, m_focalPoint, mat);
+    mat4.rotate(mat, radians, m_viewUp, mat);
+    mat4.translate(mat, invDir, mat);
+
+//      console.log(m_viewUp);
+    mat4.multiplyVec3(mat, m_position, m_position);
+
+    this.computeOrthogonalAxes();
+  };
+
+  /**
+   * Perform pitch on the camera give rotation in degrees
+   *
+   */
+  this.pitch = function(degrees) {
+    radians = degrees * (3.14 / 180.0);
+
+    mat = mat4.create();
+    mat4.identity(mat);
+
+    // We would like to rotate about focal point and to do so
+    // and since our rotation is calculated assuming that rotation point or
+    // axis is at origin, we need to inverse transte, rotate and again translate
+    // to calculate the complete transformation matrix.
+    invDir = new vec3.create();
+    invDir[0] = -m_focalPoint[0];
+    invDir[1] = -m_focalPoint[1];
+    invDir[2] = -m_focalPoint[2];
+
+    mat4.translate(mat, m_focalPoint, mat);
+    mat4.rotate(mat, radians, m_right, mat);
+    mat4.translate(mat, invDir, mat);
+
+    dir = vec3.create();
+    vec3.direction(m_position, m_focalPoint, dir);
+
+    // Now update the position
+    mat4.multiplyVec3(mat, m_position, m_position);
+  };
+
+
+  /**
+   * Compute camera view matrix
+   *
+   */
+  this.computeViewMatrix = function() {
+
+    this.computeOrthogonalAxes();
+
+    mat4.lookAt(m_position, m_focalPoint, m_viewUp, m_viewMatrix);
+
+    temp = vec3.create([m_viewMatrix[0], m_viewMatrix[1], m_viewMatrix[2]]);
+
+    // If we realize a flip in x axis, then we need to flip our vertical axis since
+    // we don't want to look upside down.
+    if(vec3.dot(temp, m_cache) < 0.0)
+    {
+      m_viewUp[0] = -m_viewUp[0];
+      m_viewUp[1] = -m_viewUp[1];s
+      m_viewUp[2] = -m_viewUp[2];
+      mat4.lookAt(m_position, m_focalPoint, m_viewUp, m_viewMatrix);
+    }
+
+    temp = vec3.create([m_viewMatrix[0], m_viewMatrix[1], m_viewMatrix[2]]);
+    vec3.set(temp, m_cache);
+
+    vec3.subtract(m_focalPoint, m_position, m_directionOfProjection);
+    vec3.normalize(m_directionOfProjection, m_directionOfProjection);
+
+    return m_viewMatrix;
+  };
+
+  /**
+   *
+   *
+   */
+  this.viewMatrix = function() {
+    return m_viewMatrix;
   }
 
-//    this.m_focalPoint[0] += dir[0] * dz;
-//    this.m_focalPoint[1] += dir[1] * dz;
-//    this.m_focalPoint[2] += dir[2] * dz;
-
-  // TODO: If the distance between focal point and the camera position
-  // goes really low then we run into issues
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.pan = function(dx, dy) {
-  this.m_position[0] += dx;
-  this.m_position[1] += dy;
-  this.m_focalPoint[0] += dx;
-  this.m_focalPoint[1] += dy;
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.computeOrthogonalAxes = function() {
-  dir = new vec3.create();
-  vec3.direction(this.m_focalPoint, this.m_position, dir);
-  vec3.normalize(dir);
-  vec3.cross(dir, this.m_viewUp, this.m_right);
-  vec3.normalize(this.m_right);
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.yaw = function(degrees) {
-  radians = degrees * (3.14 / 180.0);
-
-  mat = mat4.create();
-  mat4.identity(mat);
-
-  // We would like to rotate about focal point and to do so
-  // and since our rotation is calculated assuming that rotation point or
-  // axis is at origin, we need to inverse transte, rotate and again translate
-  // to calculate the complete transformation matrix.
-  invDir = new vec3.create();
-  invDir[0] = -this.m_focalPoint[0];
-  invDir[1] = -this.m_focalPoint[1];
-  invDir[2] = -this.m_focalPoint[2];
-
-  mat4.translate(mat, this.m_focalPoint, mat);
-  mat4.rotate(mat, radians, this.m_viewUp, mat);
-  mat4.translate(mat, invDir, mat);
-
-//    console.log(this.m_viewUp);
-  mat4.multiplyVec3(mat, this.m_position, this.m_position);
-
-  this.computeOrthogonalAxes();
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.pitch = function(degrees) {
-  radians = degrees * (3.14 / 180.0);
-
-  mat = mat4.create();
-  mat4.identity(mat);
+  /**
+   * Compute camera projection matrix
+   *
+   */
+  this.computeProjectionMatrix = function(aspect, near, far) {
 
-  // We would like to rotate about focal point and to do so
-  // and since our rotation is calculated assuming that rotation point or
-  // axis is at origin, we need to inverse transte, rotate and again translate
-  // to calculate the complete transformation matrix.
-  invDir = new vec3.create();
-  invDir[0] = -this.m_focalPoint[0];
-  invDir[1] = -this.m_focalPoint[1];
-  invDir[2] = -this.m_focalPoint[2];
+    mat4.identity(m_projectionMatrix);
+    mat4.perspective(m_viewAngle, aspect, near, far,
+                     m_projectionMatrix);
 
-  mat4.translate(mat, this.m_focalPoint, mat);
-  mat4.rotate(mat, radians, this.m_right, mat);
-  mat4.translate(mat, invDir, mat);
+    return m_projectionMatrix;
+  };
 
-  dir = vec3.create();
-  vec3.direction(this.m_position, this.m_focalPoint, dir);
 
-  // Now update the position
-  mat4.multiplyVec3(mat, this.m_position, this.m_position);
-};
-
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.viewMatrix = function() {
-  this.computeOrthogonalAxes();
-
-  mat4.lookAt(this.m_position, this.m_focalPoint, this.m_viewUp, this.m_viewMatrix);
-
-  temp = vec3.create([this.m_viewMatrix[0], this.m_viewMatrix[1], this.m_viewMatrix[2]]);
-
-  // If we realize a flip in x axis, then we need to flip our vertical axis since
-  // we don't want to look upside down.
-  if(vec3.dot(temp, this.m_cache) < 0.0)
-  {
-    this.m_viewUp[0] = -this.m_viewUp[0];
-    this.m_viewUp[1] = -this.m_viewUp[1];
-    this.m_viewUp[2] = -this.m_viewUp[2];
-    mat4.lookAt(this.m_position, this.m_focalPoint, this.m_viewUp, this.m_viewMatrix);
+  /**
+   * Return camera projection matrix
+   *
+   */
+  this.projectionMatrix = function() {
+    return m_projectionMatrix;
   }
-
-  temp = vec3.create([this.m_viewMatrix[0], this.m_viewMatrix[1], this.m_viewMatrix[2]]);
-  vec3.set(temp, this.m_cache);
-
-  vec3.subtract(this.m_focalPoint, this.m_position, this.m_directionOfProjection);
-  vec3.normalize(this.m_directionOfProjection, this.m_directionOfProjection);
-
-  return this.m_viewMatrix;
 };
 
-//----------------------------------------------------------------------------
-vglModule.camera.prototype.projectionMatrix = function(aspect, near, far) {
-  mat4.identity(this.m_projectionMatrix);
-  mat4.perspective(this.m_viewAngle, aspect, near, far,
-                   this.m_projectionMatrix);
-  return this.m_projectionMatrix;
-};
\ No newline at end of file
+inherit(vglModule.camera, vglModule.groupNode);
\ No newline at end of file
diff --git a/web/lib/vgl/geomData.js b/web/lib/vgl/geomData.js
index 39bb380..f7e92fe 100644
--- a/web/lib/vgl/geomData.js
+++ b/web/lib/vgl/geomData.js
@@ -550,19 +550,19 @@ inherit(vglModule.sourceDataC3fv, vglModule.sourceData);
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.geometryData = function() {
-    this.m_name = "";
-    this.m_primitives = [];
-    this.m_sources = [];
-    this.m_bounds = [];
-    this.m_computeBounds = true;
+    var m_name = "";
+    var m_primitives = [];
+    var m_sources = [];
+    var m_bounds = [];
+    var m_computeBounds = true;
 
     /// Return ID of the geometry data
     this.name = function()     {
-      return this.m_name;
+      return m_name;
     };
     /// Set name of the geometry data
     this.setName = function(name) {
-      this.m_name = name;
+      m_name = name;
     };
 
     /// Add new source
@@ -570,8 +570,8 @@ vglModule.geometryData = function() {
       // TODO Check if the incoming source has duplicate keys
 
       // NOTE This might not work on IE8 or lower
-      if (this.m_sources.indexOf(source) == -1) {
-        this.m_sources.push(source);
+      if (m_sources.indexOf(source) == -1) {
+        m_sources.push(source);
         return true;
       }
 
@@ -579,21 +579,21 @@ vglModule.geometryData = function() {
     };
     /// Return source for a given index. Returns 0 if not found.
     this.source = function(index) {
-      if (index < this.m_sources.length) {
-        return this.m_sources[index];
+      if (index < m_sources.length) {
+        return m_sources[index];
       }
 
       return 0;
     };
     /// Return number of sources
     this.numberOfSources = function() {
-      return this.m_sources.length;
+      return m_sources.length;
     };
     /// Return source data given a key
     this.sourceData = function(key) {
-      for (var i = 0; i < this.m_sources.length; ++i) {
-        if (this.m_sources[i].hasKey(key)) {
-          return this.m_sources[i];
+      for (var i = 0; i < m_sources.length; ++i) {
+        if (m_sources[i].hasKey(key)) {
+          return m_sources[i];
         }
       }
 
@@ -602,8 +602,8 @@ vglModule.geometryData = function() {
 
     /// Add new primitive
     this.addPrimitive = function(primitive) {
-      if (this.m_primitives.indexOf(primitive) == -1) {
-        this.m_primitives.push(primitive);
+      if (m_primitives.indexOf(primitive) == -1) {
+        m_primitives.push(primitive);
         return true;
       }
 
@@ -611,28 +611,28 @@ vglModule.geometryData = function() {
     };
     /// Return primitive for a given index. Returns 0 if not found.
     this.primitive = function(index) {
-      if (index < this.m_primitives.length) {
-        return this.m_primitives[index];
+      if (index < m_primitives.length) {
+        return m_primitives[index];
       }
 
       return null;
     };
     /// Return number of primitives
     this.numberOfPrimitives = function() {
-      return this.m_primitives.length;
+      return m_primitives.length;
     };
 
     /// Return bounds [minX, maxX, minY, maxY, minZ, maxZ]
     this.bounds = function() {
-      return this.m_bounds;
+      return m_bounds;
     };
     /// Set bounds
     this.setBounds = function(minX, maxX, minY, maxY, minZ, maxZ) {
-      this.m_bounds[0] = minX;
-      this.m_bounds[1] = maxX;
-      this.m_bounds[2] = minY;
-      this.m_bounds[3] = maxY;
-      this.m_bounds[4] = minZ;
-      this.m_bounds[5] = maxZ;
+      m_bounds[0] = minX;
+      m_bounds[1] = maxX;
+      m_bounds[2] = minY;
+      m_bounds[3] = maxY;
+      m_bounds[4] = minZ;
+      m_bounds[5] = maxZ;
     };
 };
diff --git a/web/lib/vgl/mapper.js b/web/lib/vgl/mapper.js
index d73bc09..df78e68 100644
--- a/web/lib/vgl/mapper.js
+++ b/web/lib/vgl/mapper.js
@@ -34,138 +34,161 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.mapper = function() {
-  vglModule.boundingObject.call(this);
 
-  this.m_dirty = true;
-  this.m_geomData = 0;
-  this.m_buffers = [];
-  this.m_bufferVertexAttributeMap = {};
-};
+  if (!(this instanceof vglModule.mapper)) {
+    return new mapper();
+  }
+  vglModule.boundingObject.call(this);
 
-inherit(vglModule.mapper, vglModule.boundingObject);
+  var m_dirty = true;
+  var m_geomData = 0;
+  var m_buffers = [];
+  var m_bufferVertexAttributeMap = {};
 
-/// Compute bounds of the data
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.computeBounds = function() {
-};
+  /// Compute bounds of the data
+  this.computeBounds = function() {
+  };
 
-/// Return stored geometry data if any
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.geometryData = function() {
-  return this.m_geomData;
-};
-/// Set geometry data for the mapper
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.setGeometryData = function(geom) {
-  if (this.m_geomData !== geom )   {
-    this.m_geomData = geom;
-
-    // TODO we need
-    this.m_dirty = true;
-  }
-};
+  /// Return stored geometry data if any
 
-/// Render
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.render = function(renderState) {
-  // Bind material
+  this.geometryData = function() {
+    return m_geomData;
+  };
 
-  if (this.m_dirty) {
-    this.setupDrawObjects(renderState);
-  }
+  /// Set geometry data for the mapper
+  this.setGeometryData = function(geom) {
+    if (m_geomData !== geom )   {
+      m_geomData = geom;
 
-  // TODO Use renderState
-  var bufferIndex = 0;
-  var i = null;
-  var j = 0;
-  for (i in this.m_bufferVertexAttributeMap) {
-    if (this.m_bufferVertexAttributeMap.hasOwnProperty(i)) {
-      gl.bindBuffer(gl.ARRAY_BUFFER, this.m_buffers[bufferIndex]);
-      for (j = 0; j < this.m_bufferVertexAttributeMap[i].length; ++j) {
-        renderState.m_material.bindVertexData(
-          renderState, this.m_bufferVertexAttributeMap[i][j]);
-      }
-      ++bufferIndex;
+      // TODO we need
+      m_dirty = true;
     }
-  }
+  };
 
-  var noOfPrimitives = this.m_geomData.numberOfPrimitives();
-  for (j = 0; j < noOfPrimitives; ++j) {
+  /// Render
 
-    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.m_buffers[bufferIndex++]);
-    var primitive = this.m_geomData.primitive(j);//
-    gl.drawElements(primitive.primitiveType(), primitive.numberOfIndices(),
-                    primitive.indicesValueType(),  0);
-  }
+  this.render = function(renderState) {
+    // Bind material
 
-  // Unbind material
-};
+    console.log('render 0');
 
-///
-/// Internal methods
-//
-///////////////////////////////////////////////////////////////////////////////
+    if (m_dirty) {
 
-/// Delete previously created buffers
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.deleteVertexBufferObjects = function() {
-  for (var i = 0 ; i < this.m_buffers.length; ++i)   {
-    gl.deleteBuffer(this.m_buffers[i]);
-  }
-};
+      this.setupDrawObjects(renderState);
+    }
 
-/// Create new buffers
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.createVertexBufferObjects = function() {
-  if (this.m_geomData) {
-    var numberOfSources = this.m_geomData.numberOfSources();
-    var i = 0;
-    var bufferId = null;
-    for (; i < numberOfSources; ++i) {
-      bufferId = gl.createBuffer();
-      gl.bindBuffer(gl.ARRAY_BUFFER, bufferId);
-      gl.bufferData(gl.ARRAY_BUFFER, this.m_geomData.source(i).data(),
-                    gl.STATIC_DRAW);
-
-      keys = this.m_geomData.source(i).keys();
-      ks = [];
-      for (var j = 0; j < keys.length; ++j) {
-        ks.push(keys[j]);
+    console.log('render 1');
+
+    // TODO Use renderState
+    var bufferIndex = 0;
+    var i = null;
+    var j = 0;
+    for (i in m_bufferVertexAttributeMap) {
+      console.log('render 2');
+      if (m_bufferVertexAttributeMap.hasOwnProperty(i)) {
+        console.log("foo1");
+        gl.bindBuffer(gl.ARRAY_BUFFER, m_buffers[bufferIndex]);
+        for (j = 0; j < m_bufferVertexAttributeMap[i].length; ++j) {
+          renderState.m_material.bindVertexData(
+            renderState, m_bufferVertexAttributeMap[i][j]);
+        }
+        ++bufferIndex;
       }
+    }
 
-      this.m_bufferVertexAttributeMap[i] = ks;
-      this.m_buffers[i] = bufferId;
+    console.log('render 3');
+    var noOfPrimitives = m_geomData.numberOfPrimitives();
+    for (j = 0; j < noOfPrimitives; ++j) {
+      console.log('render 4');
+      gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, m_buffers[bufferIndex++]);
+      console.log('render 5');
+      var primitive = m_geomData.primitive(j);//
+      gl.drawElements(primitive.primitiveType(), primitive.numberOfIndices(),
+                      primitive.indicesValueType(),  0);
     }
 
-    var numberOfPrimitives = this.m_geomData.numberOfPrimitives();
-    for (var k = 0; k < numberOfPrimitives; ++k) {
-      bufferId = gl.createBuffer();
-      gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferId);
-      gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.m_geomData.primitive(k).indices(),
-                   gl.STATIC_DRAW);
-      this.m_buffers[i++] = bufferId;
+    // Unbind material
+  };
+
+  ///
+  /// Internal methods
+  //
+  ///////////////////////////////////////////////////////////////////////////////
+
+  /// Delete previously created buffers
+
+  this.deleteVertexBufferObjects = function() {
+    for (var i = 0 ; i < m_buffers.length; ++i)   {
+      gl.deleteBuffer(m_buffers[i]);
     }
-  }
-};
+  };
+
+  /// Create new buffers
+
+  this.createVertexBufferObjects = function() {
+    if (m_geomData) {
+      console.log("creting buffer objects");
+      var numberOfSources = m_geomData.numberOfSources();
+      var i = 0;
+      var bufferId = null;
+      for (; i < numberOfSources; ++i) {
+        bufferId = gl.createBuffer();
+        gl.bindBuffer(gl.ARRAY_BUFFER, bufferId);
+        gl.bufferData(gl.ARRAY_BUFFER, m_geomData.source(i).data(),
+                      gl.STATIC_DRAW);
+
+        console.log("creting buffer objects 2");
+
+        keys = m_geomData.source(i).keys();
+        ks = [];
+        for (var j = 0; j < keys.length; ++j) {
+          ks.push(keys[j]);
+        }
+
+      m_bufferVertexAttributeMap[i] = ks;
+        m_buffers[i] = bufferId;
+      }
 
-/// Clear cache related to buffers
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.cleanUpDrawObjects = function() {
-  this.m_bufferVertexAttributeMap = {};
-  this.m_buffers = [];
-};
+      var numberOfPrimitives = m_geomData.numberOfPrimitives();
+      for (var k = 0; k < numberOfPrimitives; ++k) {
+        console.log("creting buffer objects 3");
+
+        bufferId = gl.createBuffer();
+        gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferId);
+        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, m_geomData.primitive(k).indices(),
+                     gl.STATIC_DRAW);
+
+        console.log("creting buffer objects 4");
+        m_buffers[i++] = bufferId;
+      }
+    }
+
+    console.log("creting buffer objects 5");
+  };
+
+  /// Clear cache related to buffers
+
+  this.cleanUpDrawObjects = function() {
+  m_bufferVertexAttributeMap = {};
+    m_buffers = [];
+  };
 
-/// Setup draw objects; Delete old ones and create new ones
-//----------------------------------------------------------------------------
-vglModule.mapper.prototype.setupDrawObjects = function(renderState) {
-  // Delete buffer objects from past if any.
-  this.deleteVertexBufferObjects();
+  /// Setup draw objects; Delete old ones and create new ones
 
-  // Clear any cache related to buffers
-  this.cleanUpDrawObjects();
+  this.setupDrawObjects = function(renderState) {
+    // Delete buffer objects from past if any.
+    this.deleteVertexBufferObjects();
 
-  // Now construct the new ones.
-  this.createVertexBufferObjects();
+    // Clear any cache related to buffers
+    this.cleanUpDrawObjects();
+
+    // Now construct the new ones.
+    this.createVertexBufferObjects();
+
+    m_dirty = false;
+  };
+
+  return this;
+};
 
-  this.m_dirty = false;
-};
\ No newline at end of file
+inherit(vglModule.mapper, vglModule.boundingObject);
\ No newline at end of file
diff --git a/web/lib/vgl/material.js b/web/lib/vgl/material.js
index 32a53b1..43a7ec0 100644
--- a/web/lib/vgl/material.js
+++ b/web/lib/vgl/material.js
@@ -22,8 +22,8 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-///---------------------------------------------------------------------------
 vglModule.material = function() {
+
   this.RenderBin = {
     "Default"     : 0,
     "Opaque"      : 1,
@@ -31,118 +31,125 @@ vglModule.material = function() {
     "Overlay"     : 20
   };
 
+  if (!(this instanceof vglModule.material)) {
+    return new vglModule.material();
+  }
   vglModule.object.call(this);
-  this.m_shaderProgram = new vglModule.shaderProgram();
-  this.m_binNumber = 0;
-  this.m_textureAttributes = {};
-  this.m_attributes = {};
-};
 
-inherit(vglModule.material, vglModule.object);
+  /// Private member variables
+  var m_shaderProgram = new vglModule.shaderProgram();
+  var m_binNumber = 0;
+  var m_textureAttributes = {};
+  var m_attributes = {};
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.binNumber = function() {
-  return this.m_binNumber;
-};
-///---------------------------------------------------------------------------
-vglModule.material.prototype.setBinNumber = function(binNo) {
-  this.m_binNumber = binNo;
-  this.setModified();
-};
+  /// Public member methods
+  this.binNumber = function() {
+    return m_binNumber;
+  };
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.exists = function(attr) {
-  if (attr.type() === vglModule.materialAttribute.Texture) {
-    return this.m_textureAttributes.hasOwnProperty(attr);
-  } else {
-    return this.m_attributes.hasOwnProperty(attr);
-  }
-};
+  this.setBinNumber = function(binNo) {
+    m_binNumber = binNo;
+    this.modifiedOn();
+  };
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.addAttribute = function(attr) {
 
-  if (this.exists(attr)) {
-    return false;
-  }
+  this.exists = function(attr) {
+    if (attr.type() === vglModule.materialAttribute.Texture) {
+      return m_textureAttributes.hasOwnProperty(attr);
+    } else {
+      return m_attributes.hasOwnProperty(attr);
+    }
+  };
+
+
+  this.addAttribute = function(attr) {
 
-  if (attr.type() === materialAttributeType.Texture) {
-    this.m_textureAttributes[attr.textureUnit()] = attr;
-    this.setModified(true);
-    return true;
-  } else {
-    // Shader is a very special attribute
-    if (attr.type() === materialAttributeType.ShaderProgram) {
-      this.m_shaderProgram = attr;
+    if (this.exists(attr)) {
+      return false;
     }
 
-    this.m_attributes[attr.type()] = attr;
-    return true;
-  }
+    if (attr.type() === materialAttributeType.Texture) {
+      m_textureAttributes[attr.textureUnit()] = attr;
+      this.modifiedOn();
+      return true;
+    } else {
+      // Shader is a very special attribute
+      if (attr.type() === materialAttributeType.ShaderProgram) {
+        m_shaderProgram = attr;
+      }
+
+      m_attributes[attr.type()] = attr;
+      return true;
+    }
 
-  return false;
-};
+    return false;
+  };
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.shaderProgram = function() {
-  return this.m_shaderProgram;
-};
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.render = function(renderState) {
-  this.bind(renderState);
-};
+  this.shaderProgram = function() {
+    return m_shaderProgram;
+  };
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.remove = function(renderState) {
-  this.undoBind(renderState);
-};
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.bind = function(renderState) {
+  this.render = function(renderState) {
+    this.bind(renderState);
+  };
+
+
+  this.remove = function(renderState) {
+    this.undoBind(renderState);
+  };
 
-  for (var key in this.m_attributes) {
-    if (this.m_attributes.hasOwnProperty(key)) {
-      this.m_attributes[key].bind(renderState);
+
+  this.bind = function(renderState) {
+
+    for (var key in m_attributes) {
+      if (m_attributes.hasOwnProperty(key)) {
+        m_attributes[key].bind(renderState);
+      }
     }
-  }
 
-  for (var key in this.m_textureAttributes) {
-    if (this.m_textureAttributes.hasOwnProperty(key)) {
-      this.m_textureAttributes[key].bind(renderState);
+    for (var key in m_textureAttributes) {
+      if (m_textureAttributes.hasOwnProperty(key)) {
+        m_textureAttributes[key].bind(renderState);
+      }
     }
-  }
-};
-///---------------------------------------------------------------------------
-vglModule.material.prototype.undoBind = function(renderState) {
-  var key = null;
-  for (key in this.m_attributes) {
-    if (this.m_attributes.hasOwnProperty(key)) {
-      this.m_attributes[key].undoBind(renderState);
+  };
+
+  this.undoBind = function(renderState) {
+    var key = null;
+    for (key in m_attributes) {
+      if (m_attributes.hasOwnProperty(key)) {
+        m_attributes[key].undoBind(renderState);
+      }
     }
-  }
 
-  for (key in this.m_textureAttributes) {
-    if (this.m_textureAttributes.hasOwnProperty(key)) {
-      this.m_textureAttributes[key].undoBind(renderState);
+    for (key in m_textureAttributes) {
+      if (m_textureAttributes.hasOwnProperty(key)) {
+        m_textureAttributes[key].undoBind(renderState);
+      }
     }
-  }
-};
+  };
+
 
-///---------------------------------------------------------------------------
-vglModule.material.prototype.bindVertexData = function(renderState, key) {
+  this.bindVertexData = function(renderState, key) {
 
-  for (var i in this.m_attributes) {
-    if (this.m_attributes.hasOwnProperty(i)) {
-      this.m_attributes[i].bindVertexData(renderState, key);
+    for (var i in m_attributes) {
+      if (m_attributes.hasOwnProperty(i)) {
+        m_attributes[i].bindVertexData(renderState, key);
+      }
     }
-  }
-};
-///---------------------------------------------------------------------------
-vglModule.material.prototype.undoBindVertexData = function(renderState, key) {
-  for (var i in this.m_attributes) {
-    if (this.m_attributes.hasOwnProperty(i)) {
-      this.m_attributes.undoBindVertexData(renderState, key);
+  };
+
+  this.undoBindVertexData = function(renderState, key) {
+    for (var i in m_attributes) {
+      if (m_attributes.hasOwnProperty(i)) {
+        m_attributes.undoBindVertexData(renderState, key);
+      }
     }
-  }
+  };
+
+  return this;
 };
+
+inherit(vglModule.material, vglModule.object);
diff --git a/web/lib/vgl/node.js b/web/lib/vgl/node.js
index 90a68c0..e15e239 100644
--- a/web/lib/vgl/node.js
+++ b/web/lib/vgl/node.js
@@ -50,7 +50,7 @@ vglModule.node.prototype.setMaterial = function(material) {
   if (material !== this.m_material)
   {
     this.m_material = material;
-    this.setModified();
+    this.modifiedOn();
     return true;
   }
 
@@ -67,7 +67,7 @@ vglModule.node.prototype.visible = function() {
 vglModule.node.prototype.setVisible = function(flag) {
   if (flag !== this.m_visible)   {
     this.m_visible = flag;
-    this.setModified();
+    this.modifiedOn();
     return true;
   }
 
@@ -87,7 +87,7 @@ vglModule.node.prototype.setParent = function(parent) {
       this.m_parent.removeChild(this);
     }
     this.m_parent = parent;
-    this.setModified();
+    this.modifiedOn();
     return true;
   }
 
@@ -104,7 +104,7 @@ vglModule.node.prototype.overlay = function() {
 vglModule.node.prototype.setOverlay = function(flag) {
   if (this.m_overlay !== flag)   {
     this.m_overlay = flag;
-    this.setModified();
+    this.modifiedOn();
     return true;
   }
 
@@ -128,4 +128,4 @@ vglModule.node.prototype.computeBounds = function() {
   if (this.boundsDirty())   {
     this.resetBounds();
   }
-};
\ No newline at end of file
+};
diff --git a/web/lib/vgl/object.js b/web/lib/vgl/object.js
index b1a55de..ca606c5 100644
--- a/web/lib/vgl/object.js
+++ b/web/lib/vgl/object.js
@@ -23,16 +23,27 @@
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.object = function() {
-  this.m_modified = false;
-};
-
-///
-///---------------------------------------------------------------------------
-vglModule.object.prototype.modified = function() {
-  return this.m_modified;
-};
-/// Set dirty
-///---------------------------------------------------------------------------
-vglModule.object.prototype.setModified = function(flag) {
-  this.m_modified = flag;
+  /// TODO Switch to time based modifications
+
+  if (!(this instanceof vglModule.object)) {
+    return new vglModule.object();
+  }
+
+  /// Private variables
+  var m_modified = false;
+
+  /// Public member methods
+  this.modified = function() {
+    return m_modified;
+  };
+
+  this.modifiedOn = function() {
+    m_modified = true;
+  }
+
+  this.modifiedOff = function() {
+    m_modified = false;
+  }
+
+  return this;
 };
\ No newline at end of file
diff --git a/web/lib/vgl/renderer.js b/web/lib/vgl/renderer.js
index ab00b83..78b4892 100644
--- a/web/lib/vgl/renderer.js
+++ b/web/lib/vgl/renderer.js
@@ -48,22 +48,23 @@ vglModule.renderer = function() {
 
   vglModule.object.call(this);
 
-  /// Member variables
-  this.m_width = 1280;
-  this.m_height = 1024;
-  this.m_clippingRange = [0.1, 1000.0];
-  this.m_sceneRoot = new vglModule.groupNode();
-  this.m_camera = new vglModule.camera();
+  /// Private member variables
+  var m_width = 1280;
+  var m_height = 1024;
+  var m_clippingRange = [0.1, 1000.0];
+  var m_sceneRoot = new vglModule.groupNode();
+  var m_camera = new vglModule.camera();
 
-  this.m_camera.addChild(this.m_sceneRoot);
+  m_camera.addChild(m_sceneRoot);
+
+  /// Public member methods
 
-  /// Member methods
   /**
    * Get scene root
    *
    */
   this.sceneRoot = function() {
-    return this.m_sceneRoot;
+    return m_sceneRoot;
   };
 
   /**
@@ -71,7 +72,7 @@ vglModule.renderer = function() {
    *
    */
   this.camera = function() {
-    return this.m_camera;
+    return m_camera;
   };
 
   /**
@@ -79,7 +80,7 @@ vglModule.renderer = function() {
    *
    */
   this.width = function() {
-    return this.m_width;
+    return m_width;
   };
 
   /**
@@ -87,7 +88,7 @@ vglModule.renderer = function() {
    *
    */
   this.height = function() {
-    return this.m_height;
+    return m_height;
   };
 
   /**
@@ -103,15 +104,16 @@ vglModule.renderer = function() {
     // TODO Call it only once
     this.resize();
 
-    perspectiveMatrix = this.m_camera.projectionMatrix(
-      (this.m_width / this.m_height), 0.1, 10000.0);
+    perspectiveMatrix = m_camera.computeProjectionMatrix(
+      (m_width / m_height), 0.1, 10000.0);
 
     var renSt = new vglModule.renderState();
     renSt.m_projectionMatrix = perspectiveMatrix;
-    var children = this.m_sceneRoot.children();
+    var children = m_sceneRoot.children();
     for (var i = 0; i < children.length; ++i) {
+      console.log('actor index ' + i);
       var actor = children[i];
-      mat4.multiply(this.m_camera.viewMatrix(), actor.matrix(), renSt.m_modelViewMatrix);
+      mat4.multiply(m_camera.computeViewMatrix(), actor.matrix(), renSt.m_modelViewMatrix);
       renSt.m_material = actor.material();
       renSt.m_mapper = actor.mapper();
 
@@ -135,7 +137,7 @@ vglModule.renderer = function() {
    *
    */
   this.resize = function() {
-    gl.viewport(0, 0, this.m_width, this.m_height);
+    gl.viewport(0, 0, m_width, m_height);
   };
 
   /**
@@ -144,7 +146,7 @@ vglModule.renderer = function() {
    */
   this.addActor = function(actor) {
     if (actor instanceof vglModule.actor) {
-      this.m_sceneRoot.addChild(actor);
+      m_sceneRoot.addChild(actor);
       return true;
     }
 
@@ -156,8 +158,8 @@ vglModule.renderer = function() {
    *
    */
   this.removeActor = function(actor) {
-    if (actor in this.m_sceneRoot.children()) {
-      this.m_sceneRoot.removeChild(actor);
+    if (actor in m_sceneRoot.children()) {
+      m_sceneRoot.removeChild(actor);
       return true;
     }
 
@@ -224,4 +226,4 @@ vglModule.renderer = function() {
   return this;
 };
 
-inherit(vglModule.renderer, vglModule.object);
\ No newline at end of file
+inherit(vglModule.renderer, vglModule.object);
diff --git a/web/lib/vgl/shader.js b/web/lib/vgl/shader.js
index d7a2ac4..785b24d 100644
--- a/web/lib/vgl/shader.js
+++ b/web/lib/vgl/shader.js
@@ -59,7 +59,7 @@ vglModule.shader.prototype.shaderSource = function() {
 vglModule.shader.prototype.setShaderSource = function(source) {
   this.m_shaderSource = source;
 
-  this.setModified(true);
+  this.modifiedOn(true);
 };
 
 ///---------------------------------------------------------------------------
diff --git a/web/lib/vgl/shaderProgram.js b/web/lib/vgl/shaderProgram.js
index c00329e..4cd633a 100644
--- a/web/lib/vgl/shaderProgram.js
+++ b/web/lib/vgl/shaderProgram.js
@@ -30,68 +30,68 @@ vglModule.shaderProgram = function() {
   vglModule.materialAttribute.call(this, materialAttributeType.ShaderProgram);
 
   /// Private member variables
-  this.m_programHandle = 0;
-  this.m_shaders = [];
-  this.m_uniforms = [];
-  this.m_vertexAttributes = {};
+  var m_programHandle = 0;
+  var m_shaders = [];
+  var m_uniforms = [];
+  var m_vertexAttributes = {};
 
-  this.m_uniformNameToLocation = {};
-  this.m_vertexAttributeNameToLocation = {};
+  var m_uniformNameToLocation = {};
+  var m_vertexAttributeNameToLocation = {};
 
   /// Public member methods
   this.queryUniformLocation = function(name) {
-    return gl.getUniformLocation(this.m_programHandle, name);
+    return gl.getUniformLocation(m_programHandle, name);
   };
 
 
   this.queryAttributeLocation = function(name) {
-    return gl.getAttribLocation(this.m_programHandle, name);
+    return gl.getAttribLocation(m_programHandle, name);
   };
 
 
   this.addShader = function(shader) {
-    if (this.m_shaders.indexOf(shader) > -1)   {
+    if (m_shaders.indexOf(shader) > -1)   {
       return false;
     }
 
-    for (var i = 0; i < this.m_shaders.length; ++i) {
-      if (this.m_shaders[i].shaderType() === shader.shaderType()) {
-        this.m_shaders.splice(this.m_shaders.indexOf(shader), 1);
+    for (var i = 0; i < m_shaders.length; ++i) {
+      if (m_shaders[i].shaderType() === shader.shaderType()) {
+        m_shaders.splice(m_shaders.indexOf(shader), 1);
       }
     }
 
-    this.m_shaders.push(shader);
+    m_shaders.push(shader);
 
-    this.setModified();
+    this.modifiedOn();
 
     return true;
   };
 
 
   this.addUniform = function(uniform) {
-    if (this.m_uniforms.indexOf(uniform) > -1) {
+    if (m_uniforms.indexOf(uniform) > -1) {
       return false;
     }
 
-    this.m_uniforms.push(uniform);
+    m_uniforms.push(uniform);
 
-    this.setModified();
+    this.modifiedOn();
   };
 
 
   this.addVertexAttribute = function(attr, key) {
-    this.m_vertexAttributes[key] = attr;
+    m_vertexAttributes[key] = attr;
 
-    this.setModified();
+    this.modifiedOn();
   };
 
 
   this.uniformLocation = function(name) {
-    return this.m_uniformNameToLocation[name];
+    return m_uniformNameToLocation[name];
   };
 
   this.attributeLocation = function(name) {
-    return this.m_vertexAttributeNameToLocation[name];
+    return m_vertexAttributeNameToLocation[name];
   };
 
 
@@ -101,18 +101,18 @@ vglModule.shaderProgram = function() {
 
 
   this.updateUniforms = function() {
-    for (var i = 0; i < this.m_uniforms.length; ++i) {
-      this.m_uniforms[i].callGL(
-        this.m_uniformNameToLocation[this.m_uniforms[i].name()]);
+    for (var i = 0; i < m_uniforms.length; ++i) {
+      m_uniforms[i].callGL(
+        m_uniformNameToLocation[m_uniforms[i].name()]);
     }
   };
 
 
   this.link = function() {
-    gl.linkProgram(this.m_programHandle);
+    gl.linkProgram(m_programHandle);
 
     // If creating the shader program failed, alert
-    if (!gl.getProgramParameter(this.m_programHandle, gl.LINK_STATUS)) {
+    if (!gl.getProgramParameter(m_programHandle, gl.LINK_STATUS)) {
       console.log("[ERROR] Unable to initialize the shader program.");
       return false;
     }
@@ -127,7 +127,7 @@ vglModule.shaderProgram = function() {
 
 
   this.use = function() {
-    gl.useProgram(this.m_programHandle);
+    gl.useProgram(m_programHandle);
   };
 
 
@@ -138,13 +138,13 @@ vglModule.shaderProgram = function() {
 
 
   this.deleteProgram = function() {
-    gl.deleteProgram(this.m_programHandle);
+    gl.deleteProgram(m_programHandle);
   };
 
 
   this.deleteVertexAndFragment = function() {
-    for (var i = 0; i < this.m_shaders.length; ++i) {
-      gl.deleteShader(this.m_shaders[i].shaderHandle());
+    for (var i = 0; i < m_shaders.length; ++i) {
+      gl.deleteShader(m_shaders[i].shaderHandle());
     }
   };
 
@@ -152,18 +152,18 @@ vglModule.shaderProgram = function() {
   this.bind = function(renderState) {
     var i = 0;
 
-    if (this.m_programHandle === 0 || this.modified()) {
-      this.m_programHandle = gl.createProgram();
+    if (m_programHandle === 0 || this.modified()) {
+      m_programHandle = gl.createProgram();
 
-      if (this.m_programHandle === 0) {
+      if (m_programHandle === 0) {
         console.log("[ERROR] Cannot create Program Object");
         return false;
       }
 
       // Compile shaders
-      for (i = 0; i < this.m_shaders.length; ++i) {
-        this.m_shaders[i].compile();
-        this.m_shaders[i].attachShader(this.m_programHandle);
+      for (i = 0; i < m_shaders.length; ++i) {
+        m_shaders[i].compile();
+        m_shaders[i].attachShader(m_programHandle);
       }
 
       this.bindAttributes();
@@ -178,15 +178,15 @@ vglModule.shaderProgram = function() {
 
       this.bindUniforms();
 
-      this.setModified(false);
+      this.modifiedOff();
     }
     else {
       this.use();
     }
 
     // Call update callback.
-    for (i = 0; i < this.m_uniforms.length; ++i) {
-      this.m_uniforms[i].update(renderState, this);
+    for (i = 0; i < m_uniforms.length; ++i) {
+      m_uniforms[i].update(renderState, this);
     }
 
     // Now update values to GL.
@@ -199,34 +199,34 @@ vglModule.shaderProgram = function() {
 
 
   this.bindVertexData = function(renderState, key) {
-    if (this.m_vertexAttributes.hasOwnProperty(key)) {
-      this.m_vertexAttributes[key].bindVertexData(renderState, key);
+    if (m_vertexAttributes.hasOwnProperty(key)) {
+      m_vertexAttributes[key].bindVertexData(renderState, key);
     }
   };
 
   this.undoBindVertexData = function(renderState, key) {
-    if (this.m_vertexAttributes.hasOwnProperty(key)) {
-      this.m_vertexAttributes[key].undoBindVertexData(renderState, key);
+    if (m_vertexAttributes.hasOwnProperty(key)) {
+      m_vertexAttributes[key].undoBindVertexData(renderState, key);
     }
   };
 
 
   this.bindUniforms = function() {
-    for (var i = 0; i < this.m_uniforms.length; ++i) {
-      this.m_uniformNameToLocation[this.m_uniforms[i].name()] =
-        this.queryUniformLocation(this.m_uniforms[i].name());
+    for (var i = 0; i < m_uniforms.length; ++i) {
+      m_uniformNameToLocation[m_uniforms[i].name()] =
+        this.queryUniformLocation(m_uniforms[i].name());
 
-      console.log(this.m_uniforms[i].name());
-      console.log(this.queryUniformLocation(this.m_uniforms[i].name()));
+      console.log(m_uniforms[i].name());
+      console.log(this.queryUniformLocation(m_uniforms[i].name()));
     }
   };
 
   this.bindAttributes = function() {
     var index = 0;
-    for (var i in this.m_vertexAttributes) {
-      var name = this.m_vertexAttributes[i].name();
-      gl.bindAttribLocation(this.m_programHandle, index, name);
-      this.m_vertexAttributeNameToLocation[name] = index++;
+    for (var i in m_vertexAttributes) {
+      var name = m_vertexAttributes[i].name();
+      gl.bindAttribLocation(m_programHandle, index, name);
+      m_vertexAttributeNameToLocation[name] = index++;
     }
   };
 };
diff --git a/web/lib/vgl/texture.js b/web/lib/vgl/texture.js
index b5159d2..ceaadac 100644
--- a/web/lib/vgl/texture.js
+++ b/web/lib/vgl/texture.js
@@ -44,43 +44,45 @@ vglModule.texture = function() {
 
   this.m_image = null;
 
+  this.modifiedOn();
+
   /// Public member methods
   this.setup = function(renderState) {
-    if (this.modified()) {
-      gl.deleteTexture(this.m_textureHandle);
-      this.m_textureHandle = gl.createTexture();
-      gl.bindTexture(gl.TEXTURE_2D, this.m_textureHandle);
-      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
-      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
-      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-      gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
-      gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
-
-      if (this.m_image !== null) {
-        this.updateDimensions();
-        this.computeInternalFormatUsingImage();
-
-        //console.log("m_internalFormat " + this.m_internalFormat);
-        //console.log("m_pixelFormat " + this.m_pixelFormat);
-        //console.log("m_pixelDataType " + this.m_pixelDataType);
-
-        // FOR now support only 2D textures
-        gl.texImage2D(gl.TEXTURE_2D, 0, this.m_internalFormat,
-                      this.m_pixelFormat, this.m_pixelDataType, this.m_image);
-      }
-      else {
-        gl.texImage2D(gl.TEXTURE_2D, 0, this.m_internalFormat,
-                      this.m_pixelFormat, this.m_pixelDataType, null);
-      }
-
-      gl.bindTexture(gl.TEXTURE_2D, null);
-      this.setModified(false);
+
+    gl.deleteTexture(this.m_textureHandle);
+    this.m_textureHandle = gl.createTexture();
+    gl.bindTexture(gl.TEXTURE_2D, this.m_textureHandle);
+    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+    gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
+    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
+
+    if (this.m_image !== null) {
+      this.updateDimensions();
+      this.computeInternalFormatUsingImage();
+
+      //console.log("m_internalFormat " + this.m_internalFormat);
+      //console.log("m_pixelFormat " + this.m_pixelFormat);
+      //console.log("m_pixelDataType " + this.m_pixelDataType);
+
+      // FOR now support only 2D textures
+      gl.texImage2D(gl.TEXTURE_2D, 0, this.m_internalFormat,
+                    this.m_pixelFormat, this.m_pixelDataType, this.m_image);
+    }
+    else {
+      gl.texImage2D(gl.TEXTURE_2D, 0, this.m_internalFormat,
+                    this.m_pixelFormat, this.m_pixelDataType, null);
     }
+
+    gl.bindTexture(gl.TEXTURE_2D, null);
+    this.modifiedOff();
   };
 
 
   this.bind = function(renderState) {
+
     // TODO Call setup via material setup
     if (this.modified()) {
       this.setup(renderState);
@@ -98,7 +100,7 @@ vglModule.texture = function() {
   this.handleTextureLoaded = function(image) {
     this.m_image = image;
     this.updateDimensions();
-    this.setModified(true);
+    this.modifiedOn(true);
   };
 
 
@@ -126,7 +128,7 @@ vglModule.texture = function() {
     }
 
     this.m_textureUnit = unit;
-    this.setModified(true);
+    this.modifiedOn(true);
     return true;
   };
 
@@ -141,7 +143,7 @@ vglModule.texture = function() {
     }
 
     this.m_width = width;
-    this.setModified(true);
+    this.modifiedOn(true);
 
     return true;
   };
@@ -157,7 +159,7 @@ vglModule.texture = function() {
     }
 
     this.m_depth = depth;
-    this.setModified(true);
+    this.modifiedOn(true);
 
     return true;
   };
@@ -175,7 +177,7 @@ vglModule.texture = function() {
   this.setInternalFormat = function(internalFormat) {
     if (this.m_internalFormat !== internalFormat) {
       this.m_internalFormat = internalFormat;
-      this.setModified(true);
+      this.modifiedOn(true);
 
       return true;
     }
@@ -194,7 +196,7 @@ vglModule.texture = function() {
     }
 
     this.m_pixelFormat = pixelFormat;
-    this.setModified(true);
+    this.modifiedOn(true);
     return true;
   };
 
@@ -210,7 +212,7 @@ vglModule.texture = function() {
 
     this.m_pixelDataTYpe = pixelDataType;
 
-    this.setModified(true);
+    this.modifiedOn(true);
 
     return true;
   };
@@ -253,7 +255,7 @@ vglModule.texture = function() {
     }
   };
 
-  return;
+  return this;
 };
 
 inherit(vglModule.texture, vglModule.materialAttribute);
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index 289fbcc..b6c265d 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -111,25 +111,25 @@ vglModule.utils.createTextureVertexShader = function(context) {
  * @returns {vglModule.shader}
  */
 vglModule.utils.createVertexShader = function(context) {
- var vertexShaderSource = [
-   'attribute vec3 vertexPosition;',
-   'attribute vec3 textureCoord;',
-   'attribute vec3 vertexColor;',
-   'uniform mat4 modelViewMatrix;',
-   'uniform mat4 projectionMatrix;',
-   'varying mediump vec3 iVertexColor;',
-   'varying highp vec3 iTextureCoord;',
-   'void main(void)',
-   '{',
-   'gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);',
-   ' iTextureCoord = textureCoord;',
-   ' iVertexColor = vertexColor;',
-   '}'
- ].join('\n');
-
- var shader = new vglModule.shader(gl.VERTEX_SHADER);
- shader.setShaderSource(vertexShaderSource);
- return shader;
+   var vertexShaderSource = [
+     'attribute vec3 vertexPosition;',
+     'attribute vec3 textureCoord;',
+     'attribute vec3 vertexColor;',
+     'uniform mat4 modelViewMatrix;',
+     'uniform mat4 projectionMatrix;',
+     'varying mediump vec3 iVertexColor;',
+     'varying highp vec3 iTextureCoord;',
+     'void main(void)',
+     '{',
+     'gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);',
+     ' iTextureCoord = textureCoord;',
+     ' iVertexColor = vertexColor;',
+     '}'
+   ].join('\n');
+
+   var shader = new vglModule.shader(gl.VERTEX_SHADER);
+   shader.setShaderSource(vertexShaderSource);
+   return shader;
 };
 
 /**

-----------------------------------------------------------------------

Summary of changes:
 web/index.html                      |   37 +++-
 web/lib/app.js                      |   25 ++-
 web/lib/geo/layer.js                |   95 +++++++--
 web/lib/geo/map.js                  |  121 ++++++----
 web/lib/vgl/actor.js                |   56 +++--
 web/lib/vgl/blend.js                |    2 +-
 web/lib/vgl/boundingObject.js       |   85 ++++----
 web/lib/vgl/camera.js               |  428 ++++++++++++++++++++--------------
 web/lib/vgl/geomData.js             |  276 +++++++++++++---------
 web/lib/vgl/groupNode.js            |  170 +++++++-------
 web/lib/vgl/mapper.js               |  259 +++++++++++----------
 web/lib/vgl/material.js             |  180 ++++++++--------
 web/lib/vgl/materialAttribute.js    |    5 +-
 web/lib/vgl/modelViewMatrixStack.js |   12 +-
 web/lib/vgl/node.js                 |  226 +++++++++++--------
 web/lib/vgl/object.js               |   35 ++-
 web/lib/vgl/planeSource.js          |   13 +-
 web/lib/vgl/renderer.js             |   45 ++--
 web/lib/vgl/shader.js               |  121 +++++-----
 web/lib/vgl/shaderProgram.js        |  138 ++++++------
 web/lib/vgl/source.js               |    5 +-
 web/lib/vgl/texture.js              |   87 +++----
 web/lib/vgl/uniform.js              |  188 +++++++++-------
 web/lib/vgl/utils.js                |   40 ++--
 web/lib/vgl/vertexAttribute.js      |   55 +++--
 25 files changed, 1507 insertions(+), 1197 deletions(-)


hooks/post-receive
-- 
OpenGeoscience



More information about the Opengeoscience-developers mailing list