From 9d3589feb0174c09d1c1bac405660f8900259c7d Mon Sep 17 00:00:00 2001
From: hwc487
Date: Wed, 22 Feb 2012 04:44:07 -0800
Subject: Adding bug fixes.

---
 js/helper-classes/RDGE/GLCircle.js                 |  10 +-
 js/helper-classes/RDGE/GLLine.js                   | 594 +++++++++++----------
 js/helper-classes/RDGE/GLRectangle.js              | 117 +---
 js/helper-classes/RDGE/GLWorld.js                  |  45 +-
 .../RDGE/src/core/script/precompiled.js            |  10 +-
 js/helper-classes/RDGE/src/core/script/runtime.js  |  14 +-
 .../RDGE/src/core/script/scenegraphNodes.js        |   8 +-
 .../RDGE/src/tools/compile-rdge-core.bat           |   4 +
 .../RDGE/src/tools/compile-rdge-core.sh            |   3 +
 js/helper-classes/RDGE/src/tools/compiler.jar      | Bin 0 -> 4927265 bytes
 js/helper-classes/RDGE/src/tools/rdge-compiled.js  | 454 ++++++++++++++++
 11 files changed, 824 insertions(+), 435 deletions(-)
 create mode 100644 js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
 create mode 100644 js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
 create mode 100644 js/helper-classes/RDGE/src/tools/compiler.jar
 create mode 100644 js/helper-classes/RDGE/src/tools/rdge-compiled.js

(limited to 'js/helper-classes/RDGE')

diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js
index 08057778..5b32547e 100755
--- a/js/helper-classes/RDGE/GLCircle.js
+++ b/js/helper-classes/RDGE/GLCircle.js
@@ -400,7 +400,10 @@ function GLCircle()
 			ctx.lineWidth = 0;
 			ctx.fillStyle   = "#990000";
 			if (this._fillColor)
-				ctx.fillStyle = MathUtils.colorToHex( this._fillColor );
+			{
+				var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")";  
+				ctx.fillStyle = c;
+			}
 
 			// draw the fill
 			ctx.beginPath();
@@ -460,7 +463,10 @@ function GLCircle()
 			ctx.lineWidth	= lineWidth;
 			ctx.strokeStyle = "#0000ff";
 			if (this._strokeColor)
-				ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor );
+			{
+				var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";  
+				ctx.strokeStyle = c;
+			}
 			
 			// draw the stroke
 			p = MathUtils.transformPoint( bezPts[0],   mat );
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index 5ec51230..0d815145 100755
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -11,74 +11,74 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
 ///////////////////////////////////////////////////////////////////////
 function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj)
 {
-    ///////////////////////////////////////////////////////////////////////
-    // Instance variables
-    ///////////////////////////////////////////////////////////////////////
-    this._width = 2.0;
-    this._height = 2.0;
-    this._xOffset = 0;
-    this._yOffset = 0;
-
-    // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side
-    this._xAdj = 0;
-    this._yAdj = 0;
-    
-    this._slope = 0;
+	///////////////////////////////////////////////////////////////////////
+	// Instance variables
+	///////////////////////////////////////////////////////////////////////
+	this._width = 2.0;
+	this._height = 2.0;
+	this._xOffset = 0;
+	this._yOffset = 0;
+
+	// If line doesn't fit in canvas world, we had to grow the canvas by this much on either side
+	this._xAdj = 0;
+	this._yAdj = 0;
+	
+	this._slope = 0;
 
-    this._strokeWidth = 0.25;
+	this._strokeWidth = 0.25;
 
-    this._strokeStyle = "Solid";
-    this._scaleX = 1.0;
-    this._scaleY = 1.0;
+	this._strokeStyle = "Solid";
+	this._scaleX = 1.0;
+	this._scaleY = 1.0;
 
-    if (arguments.length > 0)
-    {
-        this._width = width;
-        this._height = height;
-        this._xOffset = xOffset;
-        this._yOffset = yOffset;
+	if (arguments.length > 0)
+	{
+		this._width = width;
+		this._height = height;
+		this._xOffset = xOffset;
+		this._yOffset = yOffset;
 
-        this._xAdj = xAdj;
-        this._yAdj = yAdj;
+		this._xAdj = xAdj;
+		this._yAdj = yAdj;
 
-        this._slope = slope;
-        this._strokeWidth = strokeSize;
-        this._strokeColor = strokeColor;
+		this._slope = slope;
+		this._strokeWidth = strokeSize;
+		this._strokeColor = strokeColor;
 
-        this._strokeStyle = strokeStyle;
-        this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
-    }
+		this._strokeStyle = strokeStyle;
+		this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
+	}
 
-    this._strokeVerticesLen = 0;
+	this._strokeVerticesLen = 0;
 
-    this.m_world = world;
+	this.m_world = world;
 
 	this._materialAmbient  = [0.2, 0.2, 0.2,  1.0];
 	this._materialDiffuse  = [0.4, 0.4, 0.4,  1.0];
 	this._materialSpecular = [0.4, 0.4, 0.4,  1.0];
 
-    // initialize the inherited members
-    this.inheritedFrom = GLGeomObj;
-    this.inheritedFrom();
+	// initialize the inherited members
+	this.inheritedFrom = GLGeomObj;
+	this.inheritedFrom();
 
-    if(strokeMaterial)
-    {
-        this._strokeMaterial = strokeMaterial;
-    }
+	if(strokeMaterial)
+	{
+		this._strokeMaterial = strokeMaterial;
+	}
 
-    ///////////////////////////////////////////////////////////////////////
-    // Property Accessors
-    ///////////////////////////////////////////////////////////////////////
+	///////////////////////////////////////////////////////////////////////
+	// Property Accessors
+	///////////////////////////////////////////////////////////////////////
 	this.getStrokeWidth		= function()		{  return this._strokeWidth;	}
 	this.setStrokeWidth		= function(w)		{  this._strokeWidth = w;		}
 
 	this.getStrokeMaterial	= function()		{  return this._strokeMaterial;	}
 	this.setStrokeMaterial	= function(m)		{  this._strokeMaterial = m;	}
 
-    this.getStrokeColor		= function()		{  return this._strokeColor;	}
+	this.getStrokeColor		= function()		{  return this._strokeColor;	}
 	//this.setStrokeColor	= function(c)		{  this._strokeColor = c;		}
 
-    this.getStrokeStyle		= function()		{  return this._strokeStyle;	}
+	this.getStrokeStyle		= function()		{  return this._strokeStyle;	}
 	this.setStrokeStyle		= function(s)		{  this._strokeStyle = s;		}
 
 	this.getFillMaterial	= function()		{  return null;		}
@@ -86,24 +86,24 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
 	this.setStrokeMaterial  = function(m)		 {  this._strokeMaterial = m;		 }
 	this.getStrokeMaterial	= function()		{  return this._strokeMaterial;		}
 
-    this.getWidth			= function()		{  return this._width;				}
+	this.getWidth			= function()		{  return this._width;				}
 	this.setWidth			= function(w)		{  this._width = w;					}
 
 	this.getHeight			= function()		{  return this._height;				}
 	this.setHeight			= function(h)		{  this._height = h;				}
 
-    this.getXAdj			= function()		{  return this._xAdj;			}
+	this.getXAdj			= function()		{  return this._xAdj;			}
 	this.setXAdj            = function(x)		{  this._xAdj = x;				}
 
-    this.getYAdj			= function()		{  return this._yAdj;			}
+	this.getYAdj			= function()		{  return this._yAdj;			}
 	this.setYAdj            = function(y)		{  this._yAdj = y;				}
 
-    this.getSlope			= function()		{  return this._slope;			}
+	this.getSlope			= function()		{  return this._slope;			}
 	this.setSlope            = function(m)		{  this._slope = m;				}
 
-    this.geomType	= function()				{  return this.GEOM_TYPE_LINE;	}
+	this.geomType	= function()				{  return this.GEOM_TYPE_LINE;	}
 
-    	///////////////////////////////////////////////////////////////////////
+		///////////////////////////////////////////////////////////////////////
 	// Methods
 	///////////////////////////////////////////////////////////////////////
 	this.export = function()
@@ -137,14 +137,14 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
 		this._yOffset			= Number( this.getPropertyFromString( "yoff: ",			importStr )  );
 		this._width				= Number( this.getPropertyFromString( "width: ",		importStr )  );
 		this._height			= Number( this.getPropertyFromString( "height: ",		importStr )  );
-        this._xAdj			    = Number( this.getPropertyFromString( "xAdj: ",			importStr )  );
-        this._yAdj			    = Number( this.getPropertyFromString( "yAdj: ",			importStr )  );
+		this._xAdj			    = Number( this.getPropertyFromString( "xAdj: ",			importStr )  );
+		this._yAdj			    = Number( this.getPropertyFromString( "yAdj: ",			importStr )  );
 		this._strokeWidth		= Number( this.getPropertyFromString( "strokeWidth: ",	importStr )  );
 		var slope 		        = this.getPropertyFromString( "slope: ",	importStr );
-        if(isNaN(Number(slope)))
-            this._slope		    = slope;
-        else
-            this._slope         = Number(slope);
+		if(isNaN(Number(slope)))
+			this._slope		    = slope;
+		else
+			this._slope         = Number(slope);
 
 		var strokeMaterialName	= this.getPropertyFromString( "strokeMat: ",	importStr );
 		this._strokeStyle		= this.getPropertyFromString( "strokeStyle: ",	importStr );
@@ -160,28 +160,28 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
 
 	}
 
-    ///////////////////////////////////////////////////////////////////////
-    // Methods
-    ///////////////////////////////////////////////////////////////////////
-    this.buildBuffers = function()
-    {
-        // get the world
-        var world = this.getWorld();
-        if (!world)  throw( "null world in buildBuffers" );
+	///////////////////////////////////////////////////////////////////////
+	// Methods
+	///////////////////////////////////////////////////////////////////////
+	this.buildBuffers = function()
+	{
+		// get the world
+		var world = this.getWorld();
+		if (!world)  throw( "null world in buildBuffers" );
 		if (!world._useWebGL)  return;
 		
 		// make sure RDGE has the correct context
 		g_Engine.setContext( world.getCanvas().uuid );
 
-         // create the gl buffer
-        var gl = world.getGLContext();
+		 // create the gl buffer
+		var gl = world.getGLContext();
 
-        this._strokeVerticesLen = 0;
+		this._strokeVerticesLen = 0;
 
-        var strokeVertices = [];
-        var strokeTextures = [];
-        var strokeNormals = [];
-        var strokeColors = [];
+		var strokeVertices = [];
+		var strokeTextures = [];
+		var strokeNormals = [];
+		var strokeColors = [];
 
 //        var scaleMat = Matrix.I(3);
 //        scaleMat.elements[0][0] = this._scaleX;
@@ -193,7 +193,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
 		var	vpw = world.getViewportWidth(),  vph = world.getViewportHeight();
 		var	xNDC = 2*this._xOffset/vpw,  yNDC = 2*this._yOffset/vph,
 			xFillNDC = this._width/vpw,  yFillNDC = this._height/vph,
-            xAdjNDC = this._xAdj/vpw,  yAdjNDC = this._yAdj/vph,
+			xAdjNDC = this._xAdj/vpw,  yAdjNDC = this._yAdj/vph,
 			xStrokeNDC = this._strokeWidth/vpw,  yStrokeNDC = this._strokeWidth/vph;
 
 		var aspect = world.getAspect();
@@ -218,160 +218,180 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
 		var xStroke = -z*(r-l)/(2.0*zn)*xStrokeNDC,
 			yStroke = -z*(t-b)/(2.0*zn)*yStrokeNDC;
 
-        // get the x & y adjustments size
+		// get the x & y adjustments size
 		var xAdj = -z*(r-l)/(2.0*zn)*xAdjNDC*2,
 			yAdj = -z*(t-b)/(2.0*zn)*yAdjNDC*2;
 
 
-        this._primArray = [];
-        this._materialArray = [];
+		this._primArray = [];
+		this._materialArray = [];
 		this._materialTypeArray = [];
-	    this._materialNodeArray = [];
-        
-        this._scaleX = (world._viewportWidth)/(world._viewportHeight);
-        
-        var innerX = xFill-xStroke;
-        var innerY = yFill-yStroke;
-
-//        if( (this._strokeStyle === "Dashed") || (this._strokeStyle === "Dotted") )
-//        {
-//            var sLen = this.createStippledStrokes(strokeVertices, this._strokeWidth, this._slope, this._strokeStyle, innerX, innerY);
-//            this._strokeVerticesLen += sLen;
-//        }
-//        else
-	      {
-            if(this._slope === "vertical")
-            {
-                strokeVertices = [
-                    -xFill+x, yFill+y,  0.0,
-                    xFill+x, yFill+y,  0.0,
-                    -xFill+x, -yFill+y,  0.0,
-
-                    xFill+x, -yFill+y,  0.0,
-                    -xFill+x, -yFill+y,  0.0,
-                    xFill+x, yFill+y,  0.0
-                ];
-            }
-            else if(this._slope === "horizontal")
-            {
-                // right now, this is the same as vertical line because,
-                // our canvas is the same size as us.
-                // But, we will need to use this when drawing in an existing GLWorld with other shapes
-                strokeVertices = [
-                    -xFill+x, yFill+y,  0.0,
-                    xFill+x, yFill+y,  0.0,
-                    -xFill+x, -yFill+y,  0.0,
-
-                     xFill+x, -yFill+y,  0.0,
-                    -xFill+x, -yFill+y,  0.0,
-                    xFill+x, yFill+y,  0.0
-               ];
-            }
-            else if(this._slope > 0)
-            {
-                // if slope is positive, draw a line from top-left to bottom-right
-                strokeVertices = [
-                    -xFill+x, yFill-2*yAdj+y,  0.0,
-                    -xFill+2*xAdj+x, yFill+y,  0.0,
-                    xFill-2*xAdj+x, -yFill+y,  0.0,
-
-                    xFill+x, -yFill+2*yAdj+y,  0.0,
-                    xFill-2*xAdj+x, -yFill+y,  0.0,
-                    -xFill+2*xAdj+x, yFill+y,  0.0
-                ];
-            }
-            else
-            {
-                // else slope is negative, draw a line from bottom-left to top-right
-                strokeVertices = [
-                    -xFill+x, -yFill+2*yAdj+y,  0.0,
-                    -xFill+2*xAdj+x, -yFill+y,  0.0,
-                    xFill-2*xAdj+x, yFill+y,  0.0,
-
-                    xFill+x, yFill-2*yAdj+y,  0.0,
-                    xFill-2*xAdj+x, yFill+y,  0.0,
-                    -xFill+2*xAdj+x, -yFill+y,  0.0
-                ];
-            }
-        }
-        
-        var z = 0;
+		this._materialNodeArray = [];
+		
+		this._scaleX = (world._viewportWidth)/(world._viewportHeight);
+		
+		var innerX = xFill-xStroke;
+		var innerY = yFill-yStroke;
+
+		if(this._slope === "vertical")
+		{
+			strokeVertices = [
+				-xFill+x, yFill+y,  0.0,
+				xFill+x, yFill+y,  0.0,
+				-xFill+x, -yFill+y,  0.0,
+
+				xFill+x, -yFill+y,  0.0,
+				-xFill+x, -yFill+y,  0.0,
+				xFill+x, yFill+y,  0.0
+			];
+
+			strokeTextures = [
+				0, 1,
+				1, 1,
+				0, 0,
+
+				1, 0,
+				0, 0,
+				1, 1
+			];
+		}
+		else if(this._slope === "horizontal")
+		{
+			// right now, this is the same as vertical line because,
+			// our canvas is the same size as us.
+			// But, we will need to use this when drawing in an existing GLWorld with other shapes
+			strokeVertices = [
+				-xFill+x, yFill+y,  0.0,
+				xFill+x, yFill+y,  0.0,
+				-xFill+x, -yFill+y,  0.0,
+
+					xFill+x, -yFill+y,  0.0,
+				-xFill+x, -yFill+y,  0.0,
+				xFill+x, yFill+y,  0.0
+			];
+
+			strokeTextures = [
+				0, 1,
+				1, 1,
+				0, 0,
+
+				1, 0,
+				0, 0,
+				1, 1
+			];
+		}
+		else if(this._slope > 0)
+		{
+			// if slope is positive, draw a line from top-left to bottom-right
+			strokeVertices = [
+				-xFill+x, yFill-2*yAdj+y,  0.0,
+				-xFill+2*xAdj+x, yFill+y,  0.0,
+				xFill-2*xAdj+x, -yFill+y,  0.0,
+
+				xFill+x, -yFill+2*yAdj+y,  0.0,
+				xFill-2*xAdj+x, -yFill+y,  0.0,
+				-xFill+2*xAdj+x, yFill+y,  0.0
+			];
+
+			strokeTextures = [
+				0, 0,
+				0, 1,
+				1, 0,
+
+				1, 1,
+				1, 0,
+				0, 1
+			];
+		}
+		else
+		{
+			// else slope is negative, draw a line from bottom-left to top-right
+			strokeVertices = [
+				xFill-2*xAdj+x, yFill+y,  0.0,
+				-xFill+2*xAdj+x, -yFill+y,  0.0,
+				-xFill+x, -yFill+2*yAdj+y,  0.0,
+
+				-xFill+2*xAdj+x, -yFill+y,  0.0,
+				xFill-2*xAdj+x, yFill+y,  0.0,
+				xFill+x, yFill-2*yAdj+y,  0.0
+			];
+	
+			strokeTextures = [
+				1, 1,
+				0, 0,
+				0, 1,
+
+				0, 0,
+				1, 1,
+				1, 0
+			];
+		}
+		
+		var z = 0;
 		var indices = [];
-        var nVerts = strokeVertices.length/3;
-//        for(var i=0; i<nVerts; i++)
-//        {
-//            var vertex = Vector.create([strokeVertices[i], strokeVertices[i+1], strokeVertices[i+2]]);
-//            strokeTextures.push(vertex.e(1)*0.5 + 0.5);    strokeTextures.push(vertex.e(2)*0.5 + 0.5);
-//        }
-
-		strokeTextures = [
-			0, 1,
-			1, 1,
-			0, 0, 
-
-			1, 1,
-			0, 0,
-			1, 0
-		];
-
-        // stroke normals
+		var nVerts = strokeVertices.length/3;
+
+		// stroke normals
 		var index = 0;
-        for (var i=0;  i<nVerts;  i++)
-        {
-            // push a normal for each vertex in the stroke
-            strokeNormals.push(0.0);  strokeNormals.push(0.0);  strokeNormals.push(1);
+		for (var i=0;  i<nVerts;  i++)
+		{
+			// push a normal for each vertex in the stroke
+			strokeNormals.push(0.0);  strokeNormals.push(0.0);  strokeNormals.push(1);
 			indices.push( index );  index++;
-        }
+		}
 
 		var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, g_Engine.getContext().renderer.TRIANGLES, indices.length);
 
-        var strokeMaterial = this.makeStrokeMaterial();
+		var strokeMaterial = this.makeStrokeMaterial();
 
-        this._primArray.push( prim );
-        this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
+		this._primArray.push( prim );
+		this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
 
-        world.updateObject(this);
-    }
+		world.updateObject(this);
+	}
 
-    this.render = function()
-    {
-        // get the world
-        var world = this.getWorld();
-        if (!world)  throw( "null world in rectangle render" );
+	this.render = function()
+	{
+		// get the world
+		var world = this.getWorld();
+		if (!world)  throw( "null world in rectangle render" );
 
-         // get the context
+		 // get the context
 		var ctx = world.get2DContext();
 		if (!ctx)  return;
-    
+	
 		// set up the stroke style
 		var lineWidth = this._strokeWidth;
 		ctx.beginPath();
 		ctx.lineWidth	= lineWidth;
 		ctx.strokeStyle = "#0000ff";
 		if (this._strokeColor)
-			ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor );
+		{
+			var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";  
+			ctx.strokeStyle = c;
+		}
 
 		// get the points
 		var p0,  p1;
 		var  w = this._width,  h = this._height;
 		if(this._slope === "vertical")
-        {
+		{
 			p0 = [0.5*w, 0];
 			p1 = [0.5*w, h];
-        }
-        else if(this._slope === "horizontal")
-        {
+		}
+		else if(this._slope === "horizontal")
+		{
 			p0 = [0, 0.5*h];
 			p1 = [w, 0.5*h];
-        }
-        else if(this._slope > 0)
-        {
+		}
+		else if(this._slope > 0)
+		{
 			p0 = [this._xAdj, this._yAdj];
 			p1 = [w - this._xAdj,  h - this._yAdj];
-        }
-        else
-        {
- 			p0 = [this._xAdj, h - this._yAdj];
+		}
+		else
+		{
+			p0 = [this._xAdj, h - this._yAdj];
 			p1 = [w - this._xAdj,  this._yAdj];
 		}
 			
@@ -383,105 +403,105 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
 
 
 	/*
-    // type is Dotted or Dashed
-    this.createStippledStrokes = function(strokeVertices, strokeSize, slope, type, innerX, innerY)
-    {
-        var stippleLength = strokeSize;
-
-        if (type === "Dotted")
-        {
-            stippleLength = this.DOT_LENGTH;
-        }
-        else if(type === "Dashed")
-        {
-            stippleLength = this.DASH_LENGTH;
-        }
-
-        var numStrokes = 0;
-        var startPos = -innerX;
-        var endPos = innerX;
-
-        var gap = this.GAP_LENGTH;
-        if(slope === "horizontal")
-        {
-            gap *= this._scaleX;
-            stippleLength *= this._scaleX;
-        }
-        else if(slope === "vertical")
-        {
-            startPos = -innerY;
-            endPos = innerY;
-        }
-        else
-        {
-            if(this._scaleX < 1)
-            {
-                startPos = -innerY;
-                endPos = innerY;
-                strokeSize = (strokeSize*this._scaleX)/2;
+	// type is Dotted or Dashed
+	this.createStippledStrokes = function(strokeVertices, strokeSize, slope, type, innerX, innerY)
+	{
+		var stippleLength = strokeSize;
+
+		if (type === "Dotted")
+		{
+			stippleLength = this.DOT_LENGTH;
+		}
+		else if(type === "Dashed")
+		{
+			stippleLength = this.DASH_LENGTH;
+		}
+
+		var numStrokes = 0;
+		var startPos = -innerX;
+		var endPos = innerX;
+
+		var gap = this.GAP_LENGTH;
+		if(slope === "horizontal")
+		{
+			gap *= this._scaleX;
+			stippleLength *= this._scaleX;
+		}
+		else if(slope === "vertical")
+		{
+			startPos = -innerY;
+			endPos = innerY;
+		}
+		else
+		{
+			if(this._scaleX < 1)
+			{
+				startPos = -innerY;
+				endPos = innerY;
+				strokeSize = (strokeSize*this._scaleX)/2;
 //                strokeSize *= this._scaleX;
-                stippleLength *= this._scaleX;
-            }
-            else
-            {
-                strokeSize = strokeSize/2;
-                gap *= this._scaleX;
-                stippleLength *= this._scaleX;
-            }
-
-        }
-
-        while(startPos + stippleLength < endPos)
-        {
-            if(slope === "horizontal")
-            {
-                strokeVertices.push(startPos); strokeVertices.push(-strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0);
-
-                strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos+stippleLength); strokeVertices.push(strokeSize); strokeVertices.push(0);
-            }
-            else if(slope === "vertical")
-            {
-                strokeVertices.push(-strokeSize); strokeVertices.push(startPos); strokeVertices.push(0);
-                strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0);
-                strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0);
-
-                strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0);
-                strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0);
-                strokeVertices.push(strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0);
-            }
-            else
-            {
-                strokeVertices.push(startPos); strokeVertices.push(startPos*-slope-strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0);
-
-                strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0);
-                strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope+strokeSize); strokeVertices.push(0);
-            }
-
-            numStrokes += 6;
-
-            startPos += (stippleLength+gap);
-        }
+				stippleLength *= this._scaleX;
+			}
+			else
+			{
+				strokeSize = strokeSize/2;
+				gap *= this._scaleX;
+				stippleLength *= this._scaleX;
+			}
+
+		}
+
+		while(startPos + stippleLength < endPos)
+		{
+			if(slope === "horizontal")
+			{
+				strokeVertices.push(startPos); strokeVertices.push(-strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0);
+
+				strokeVertices.push(startPos); strokeVertices.push(strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos+stippleLength); strokeVertices.push(-strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos+stippleLength); strokeVertices.push(strokeSize); strokeVertices.push(0);
+			}
+			else if(slope === "vertical")
+			{
+				strokeVertices.push(-strokeSize); strokeVertices.push(startPos); strokeVertices.push(0);
+				strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0);
+				strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0);
+
+				strokeVertices.push(strokeSize); strokeVertices.push(startPos); strokeVertices.push(0);
+				strokeVertices.push(-strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0);
+				strokeVertices.push(strokeSize); strokeVertices.push(startPos+stippleLength); strokeVertices.push(0);
+			}
+			else
+			{
+				strokeVertices.push(startPos); strokeVertices.push(startPos*-slope-strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0);
+
+				strokeVertices.push(startPos); strokeVertices.push(startPos*-slope+strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope-strokeSize); strokeVertices.push(0);
+				strokeVertices.push(startPos+stippleLength); strokeVertices.push((startPos+stippleLength)*-slope+strokeSize); strokeVertices.push(0);
+			}
+
+			numStrokes += 6;
+
+			startPos += (stippleLength+gap);
+		}
 //
-        return numStrokes;
-    }
+		return numStrokes;
+	}
 	*/
 
-    this.collidesWithPoint = function( x, y )
-    {
-        if(x < this._xOffset) return false;
-        if(x > (this._xOffset + this._width)) return false;
-        if(y < this._yOffset) return false;
-        if(y > (this._yOffset + this._height)) return false;
+	this.collidesWithPoint = function( x, y )
+	{
+		if(x < this._xOffset) return false;
+		if(x > (this._xOffset + this._width)) return false;
+		if(y < this._yOffset) return false;
+		if(y > (this._yOffset + this._height)) return false;
 
-        return true;
-    }
+		return true;
+	}
 
  }
 
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js
index 4216fe53..5b6ff94f 100755
--- a/js/helper-classes/RDGE/GLRectangle.js
+++ b/js/helper-classes/RDGE/GLRectangle.js
@@ -404,12 +404,18 @@ function GLRectangle()
 		ctx.beginPath();
 		ctx.fillStyle   = "#990000";
 		if (this._fillColor)
-			ctx.fillStyle = MathUtils.colorToHex( this._fillColor );
+		{
+			var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")";  
+			ctx.fillStyle = c;
+		}
 
 		// set the stroke
 		ctx.strokeStyle = "#0000ff";
 		if (this._strokeColor)
-			ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor );
+		{
+			var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";  
+			ctx.strokeStyle = c;
+		}
 
 		ctx.lineWidth	= lw;
 		var inset = Math.ceil( 0.5*lw ) + 0.5;
@@ -1051,13 +1057,12 @@ RectangleStroke.create = function( rectCtr,  width, height, strokeWidth,  tlRad,
 		{
 			var paramRange = material.getVertexDeformationRange();
 			var tolerance = material.getVertexDeformationTolerance();
-			nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices,  paramRange,  tolerance );
+			//nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices,  paramRange,  tolerance );
 		}
 	}
 
 	// create the RDGE primitive
 	var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices);
-	//var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.LINES, nVertices);
 	return prim;
 }
 
@@ -1145,7 +1150,7 @@ RectangleGeometry.create = function( ctr,  width, height, material )
 		{
 			var paramRange = material.getVertexDeformationRange();
 			var tolerance = material.getVertexDeformationTolerance();
-			nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices,  paramRange,  tolerance );
+			//nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices,  paramRange,  tolerance );
 		}
 	}
 
@@ -1223,108 +1228,6 @@ ShapePrimitive.create = function(coords,  normals,  uvs,  indices, primType, ver
 }
 
 
-ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices,  paramRange,  tolerance )
-{
-	// get the param range
-	var pUMin = paramRange[0],  pVMin = paramRange[1],
-		pUMax = paramRange[2],  pVMax = paramRange[3];
-	var iTriangle = 0;
-	var nTriangles = indices.length/3;
-	var index = 0;
-	while (iTriangle < nTriangles)
-	{
-		// get the indices of the 3 vertices
-		var i0 = indices[index],
-			i1 = indices[index+1],
-			i2 = indices[index+2];
-
-		// get the uv values
-		//var vrtIndex = 3*iTriangle;
-		var iuv0 = 2 * i0,
-			iuv1 = 2 * i1,
-			iuv2 = 2 * i2;
-		var u0 = uvs[iuv0],  v0 = uvs[iuv0+1],
-			u1 = uvs[iuv1],  v1 = uvs[iuv1+1],
-			u2 = uvs[iuv2],  v2 = uvs[iuv2+1];
-
-		// find the u and v range
-		var uMin = u0,  vMin = v0;
-		if (u1 < uMin)  uMin = u1;  if (v1 < vMin)  vMin = v1;
-		if (u2 < uMin)  uMin = u2;  if (v2 < vMin)  vMin = v2;
-		var uMax = u0,  vMax = v0;
-		if (u1 > uMax)  uMax = u1;  if (v1 > vMax)  vMax = v1;
-		if (u2 > uMax)  uMax = u2;  if (v2 > vMax)  vMax = v2;
-
-		// if the parameter range of the triangle is outside the
-		// desired parameter range, advance to the next polygon and continue
-		if ((uMin > pUMax) || (uMax < pUMin) || (vMin > pVMax) || (vMax < pVMin))
-		{
-			// go to the next triangle
-			iTriangle++;
-			index += 3;
-		}
-		else
-		{
-			// check thesize of the triangle in uv space.  If small enough, advance
-			// to the next triangle.  If not small enough, split the triangle into 3;
-			var du = uMax - uMin,  dv = vMax - vMin;
-			if ((du < tolerance) && (dv < tolerance))
-			{
-				iTriangle++;
-				index += 3;
-			}
-			else	// split the triangle into 4 parts
-			{
-				//calculate the position of the new vertex
-				var iPt0 = 3 * i0,
-					iPt1 = 3 * i1,
-					iPt2 = 3 * i2;
-				var x0 = verts[iPt0],  y0 = verts[iPt0+1],  z0 = verts[iPt0+2],
-					x1 = verts[iPt1],  y1 = verts[iPt1+1],  z1 = verts[iPt1+2],
-					x2 = verts[iPt2],  y2 = verts[iPt2+1],  z2 = verts[iPt2+2];
-				
-				// calculate the midpoints of the edges
-				var xA = (x0 + x1)/2.0,  yA = (y0 + y1)/2.0,  zA = (z0 + z1)/2.0,
-					xB = (x1 + x2)/2.0,  yB = (y1 + y2)/2.0,  zB = (z1 + z2)/2.0,
-					xC = (x2 + x0)/2.0,  yC = (y2 + y0)/2.0,  zC = (z2 + z0)/2.0;
-
-				// calculate the uv values of the new coordinates
-				var uA = (u0 + u1)/2.0,  vA = (v0 + v1)/2.0,
-					uB = (u1 + u2)/2.0,  vB = (v1 + v2)/2.0,
-					uC = (u2 + u0)/2.0,  vC = (v2 + v0)/2.0;
-
-				// calculate the normals for the new points
-				var nx0 = norms[iPt0],  ny0 = norms[iPt0+1],  nz0 = norms[iPt0+2],
-					nx1 = norms[iPt1],  ny1 = norms[iPt1+1],  nz1 = norms[iPt1+2],
-					nx2 = norms[iPt2],  ny2 = norms[iPt2+1],  nz2 = norms[iPt2+2];
-				var nxA = (nx0 + nx1),  nyA = (ny0 + ny1),  nzA = (nz0 + nz1);  var nrmA = VecUtils.vecNormalize(3, [nxA, nyA, nzA], 1.0 ),
-					nxB = (nx1 + nx2),  nyB = (ny1 + ny2),  nzB = (nz1 + nz2);  var nrmB = VecUtils.vecNormalize(3, [nxB, nyB, nzB], 1.0 ),
-					nxC = (nx2 + nx0),  nyC = (ny2 + ny0),  nzC = (nz2 + nz0);  var nrmC = VecUtils.vecNormalize(3, [nxC, nyC, nzC], 1.0 );
-
-				// push everything
-				verts.push(xA);  verts.push(yA);  verts.push(zA);
-				verts.push(xB);  verts.push(yB);  verts.push(zB);
-				verts.push(xC);  verts.push(yC);  verts.push(zC);
-				uvs.push(uA),  uvs.push(vA);
-				uvs.push(uB),  uvs.push(vB);
-				uvs.push(uC),  uvs.push(vC);
-				norms.push(nrmA[0]);  norms.push(nrmA[1]);  norms.push(nrmA[2]);
-				norms.push(nrmB[0]);  norms.push(nrmB[1]);  norms.push(nrmB[2]);
-				norms.push(nrmC[0]);  norms.push(nrmC[1]);  norms.push(nrmC[2]);
-
-				// split the current triangle into 4
-				indices[index+1] = nVertices;  indices[index+2] = nVertices+2;
-				indices.push(nVertices);    indices.push(i1);           indices.push(nVertices+1);  nTriangles++;
-				indices.push(nVertices+1);  indices.push(i2);           indices.push(nVertices+2);  nTriangles++;
-				indices.push(nVertices);    indices.push(nVertices+1);  indices.push(nVertices+2);  nTriangles++;
-				nVertices += 3;
-
-				// by not advancing 'index', we examine the first of the 3 triangles generated above
-			}
-		}
-	}
-	return nVertices;
-}
 
 
 
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js
index c8327064..1edd5cff 100755
--- a/js/helper-classes/RDGE/GLWorld.js
+++ b/js/helper-classes/RDGE/GLWorld.js
@@ -163,7 +163,7 @@ function GLWorld( canvas, use3D )
 		this.renderer.cameraManager().setActiveCamera(cam);
 
 		// change clear color
-		this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT);
+		//this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT);
 		this.renderer.setClearColor([1.0, 1.0, 1.0, 0.0]);
 		//this.renderer.NinjaWorld = this;
         
@@ -206,6 +206,7 @@ function GLWorld( canvas, use3D )
     {
 		if (!dt)  dt = 0.2;
         
+		dt = 0.01;	// use our own internal throttle
 		this.elapsed += dt;
         
 		if (this._useWebGL)
@@ -232,39 +233,35 @@ function GLWorld( canvas, use3D )
 		{
 			g_Engine.setContext( this._canvas.uuid );
 			var ctx = g_Engine.getContext();
-			var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle);
-			if (ctx1 != ctx)
-				console.log( "***** different contexts (2) *****" );
-			var aRenderer = ctx1.renderer;
 			var renderer = ctx.renderer;
-			if (renderer != aRenderer)
-			{
-				console.log( "***** DIFFERENT RENDERERS *****" );
-				renderer = aRenderer;
-			}
-				
 			if (renderer.unloadedTextureCount <= 0)
 			{
 				renderer.disableCulling();
 				//console.log( "GLWorld.draw " + renderer._world._worldCount );
+				renderer._clear();
 				this.myScene.render();
 
 				if (this._firstRender)
 				{
-					this._firstRender = false;
-
-					if (!this.hasAnimatedMaterials())
+					if (this._canvas.task)
 					{
-						//this.myScene.render();
-						this._canvas.task.stop();
-						//this._renderCount = 10;
+						this._firstRender = false;
+
+						if (!this.hasAnimatedMaterials())
+						{
+							this._canvas.task.stop();
+							//this._renderCount = 10;
+						}
 					}
 				}
 				else if (this._renderCount >= 0)
 				{
-					this._renderCount--;
-					if (this._renderCount <= 0)
-						this._canvas.task.stop();
+					if (this._canvas.task)
+					{
+						this._renderCount--;
+						if (this._renderCount <= 0)
+							this._canvas.task.stop();
+					}
 				}
 			}
 		}
@@ -394,11 +391,9 @@ function GLWorld( canvas, use3D )
 	if (this._useWebGL)
 	{
 		rdgeStarted = true;
-
-        this._canvas.rdgeid = this._canvas.uuid;
-
-			g_Engine.registerCanvas(this._canvas, this);
-			RDGEStart( this._canvas );
+		this._canvas.rdgeid = this._canvas.uuid;
+		g_Engine.registerCanvas(this._canvas, this);
+		RDGEStart( this._canvas );
 
 		//this._canvas.fpsTracker = new fpsTracker( '0' );
 		//this._canvas.task = new RDGETask(this._canvas, false);
diff --git a/js/helper-classes/RDGE/src/core/script/precompiled.js b/js/helper-classes/RDGE/src/core/script/precompiled.js
index 7fd1a425..bed94e4e 100755
--- a/js/helper-classes/RDGE/src/core/script/precompiled.js
+++ b/js/helper-classes/RDGE/src/core/script/precompiled.js
@@ -48,11 +48,11 @@ rdgeGlobalParameters =
 	"u_light3Amb":			{'type': 'vec4',  'data': [0.5, 0.5, 0.5, 1.0]},
 	"u_light3Spec":			{'type': 'vec4',  'data': [1.0, 1.0, 1.0, 1.0]}},		
 	"colMap":				{'type': 'tex2d', 'data': "assets/images/white.png"},	
-	"envMap":				{'type': 'tex2d', 'data': null},	
-	"normalMap":			{'type': 'tex2d', 'data': null},	
-	"glowMap":				{'type': 'tex2d', 'data': "assets/images/black.png"},	
-	"u_shadowDepthMap":		{'type': 'tex2d', 'data': null},	
-	"u_depthMap":			{'type': 'tex2d', 'data': null},	
+	//"envMap":				{'type': 'tex2d', 'data': null},	
+	//"normalMap":			{'type': 'tex2d', 'data': null},	
+	//"glowMap":				{'type': 'tex2d', 'data': "assets/images/black.png"},	
+	//"u_shadowDepthMap":		{'type': 'tex2d', 'data': null},	
+	//"u_depthMap":			{'type': 'tex2d', 'data': null},	
 	"u_matAmbient":			{'type': 'vec4',  'data': [1.00,1.00,1.00, 1]},		
 	"u_matDiffuse":			{'type': 'vec4',  'data': [1.0, 1.0, 1.0, 1.0]},		
 	"u_matSpecular":		{'type': 'vec4',  'data': [1.0, 1.0, 1.0, 1.0]},		
diff --git a/js/helper-classes/RDGE/src/core/script/runtime.js b/js/helper-classes/RDGE/src/core/script/runtime.js
index 18b9b223..3d824faf 100755
--- a/js/helper-classes/RDGE/src/core/script/runtime.js
+++ b/js/helper-classes/RDGE/src/core/script/runtime.js
@@ -206,11 +206,15 @@ RDGETask = (function() {
             self.lastTime = self.currTime;
         }
 
-        this.start = function() {
-            this.running = true;
-            this.currTime = new Date().getTime();
-            this.lastTime = this.currTime;
-            tasks[this.id]();
+        this.start = function()
+		{
+			if (!this.running)
+			{
+				this.running = true;
+				this.currTime = new Date().getTime();
+				this.lastTime = this.currTime;
+				tasks[this.id]();
+			}
         }
 
         this.stop = function() {
diff --git a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
index 48f0aab9..e80a14fb 100755
--- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
+++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
@@ -321,10 +321,10 @@ materialNodeTemplate = function(matNode)
 		var renderer = g_Engine.getContext().renderer;
 	    matNode.textureList = 
 	    [
-	        {'name':"colMap",	'handle':renderer.getTextureByName("assets/images/white"),         'unit': TEX_DIF,    "type":UNIFORMTYPE.TEXTURE2D},
-		    {'name':"envMap",	'handle':renderer.getTextureByName("assets/images/material_paint"),'unit': TEX_SPEC,   "type":UNIFORMTYPE.TEXTURE2D},
-		    {'name':"normalMap",'handle':renderer.getTextureByName("assets/images/blue"),          'unit': TEX_NORM,   "type":UNIFORMTYPE.TEXTURE2D},
-		    {'name':"glowMap",	'handle':renderer.getTextureByName("assets/images/black"),         'unit': TEX_GLOW,   "type":UNIFORMTYPE.TEXTURE2D}
+//	        {'name':"colMap",	'handle':renderer.getTextureByName("assets/images/white"),         'unit': TEX_DIF,    "type":UNIFORMTYPE.TEXTURE2D},
+//		    {'name':"envMap",	'handle':renderer.getTextureByName("assets/images/material_paint"),'unit': TEX_SPEC,   "type":UNIFORMTYPE.TEXTURE2D},
+//		    {'name':"normalMap",'handle':renderer.getTextureByName("assets/images/blue"),          'unit': TEX_NORM,   "type":UNIFORMTYPE.TEXTURE2D},
+//		    {'name':"glowMap",	'handle':renderer.getTextureByName("assets/images/black"),         'unit': TEX_GLOW,   "type":UNIFORMTYPE.TEXTURE2D}
 	    ];
 	}
 	
diff --git a/js/helper-classes/RDGE/src/tools/compile-rdge-core.bat b/js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
new file mode 100644
index 00000000..b2933fa9
--- /dev/null
+++ b/js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
@@ -0,0 +1,4 @@
+java -jar ./compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --manage_closure_dependencies --js ../core/script/math/vec2.js --js ../core/script/math/vec3.js --js ../core/script/math/vec4.js --js ../core/script/math/mat4.js --js ../core/script/math/quat.js --js ../core/script/util/statTracker.js --js ../core/script/util/fpsTracker.js --js ../core/script/objectManager.js --js ../core/script/precompiled.js --js ../core/script/renderer.js --js ../core/script/renderUtils.js --js ../core/script/jshader.js --js ../core/script/jpass.js --js ../core/script/RenderProcs.js --js ../core/script/RenderInitProcs.js --js ../core/script/MeshManager.js --js ../core/script/TextureManager.js --js ../core/script/ShaderManager.js --js ../core/script/fx/blur.js --js ../core/script/fx/ssao.js --js ../core/script/ScreenQuad.js --js ../core/script/box.js --js ../core/script/camera.js --js ../core/script/shadowLight.js --js ../core/script/utilities.js --js ../core/script/input.js --js ../core/script/engine.js --js ../core/script/scenegraphNodes.js --js ../core/script/scenegraph.js --js ../core/script/lightmanager.js --js ../core/script/rendercontext.js --js ../core/script/animation.js --js ../core/script/particle.js --js ../core/script/run_state.js --js ../core/script/init_state.js --js ../core/script/runtime.js --js ../core/script/util/dbgpanel.js --js_output_file rdge-compiled.js
+cd ../core/script
+type precompiled.js >> ../../tools/rdge-compiled.js
+pause
diff --git a/js/helper-classes/RDGE/src/tools/compile-rdge-core.sh b/js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
new file mode 100644
index 00000000..1a2c4676
--- /dev/null
+++ b/js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
@@ -0,0 +1,3 @@
+java -jar ./compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --manage_closure_dependencies --js ../core/script/math/vec2.js --js ../core/script/math/vec3.js --js ../core/script/math/vec4.js --js ../core/script/math/mat4.js --js ../core/script/math/quat.js --js ../core/script/util/statTracker.js --js ../core/script/util/fpsTracker.js --js ../core/script/objectManager.js --js ../core/script/precompiled.js --js ../core/script/renderer.js --js ../core/script/renderUtils.js --js ../core/script/jshader.js --js ../core/script/jpass.js --js ../core/script/RenderProcs.js --js ../core/script/RenderInitProcs.js --js ../core/script/MeshManager.js --js ../core/script/TextureManager.js --js ../core/script/ShaderManager.js --js ../core/script/fx/blur.js --js ../core/script/fx/ssao.js --js ../core/script/ScreenQuad.js --js ../core/script/box.js --js ../core/script/camera.js --js ../core/script/shadowLight.js --js ../core/script/utilities.js --js ../core/script/input.js --js ../core/script/engine.js --js ../core/script/scenegraphNodes.js --js ../core/script/scenegraph.js --js ../core/script/lightmanager.js --js ../core/script/rendercontext.js --js ../core/script/animation.js --js ../core/script/particle.js --js ../core/script/run_state.js --js ../core/script/init_state.js --js ../core/script/runtime.js --js ../core/script/util/dbgpanel.js --js ../core/script/ubershader.js --js_output_file rdge-compiled.js
+
+cat ../core/script/precompiled.js >> ./rdge-compiled.js
diff --git a/js/helper-classes/RDGE/src/tools/compiler.jar b/js/helper-classes/RDGE/src/tools/compiler.jar
new file mode 100644
index 00000000..f361e9cd
Binary files /dev/null and b/js/helper-classes/RDGE/src/tools/compiler.jar differ
diff --git a/js/helper-classes/RDGE/src/tools/rdge-compiled.js b/js/helper-classes/RDGE/src/tools/rdge-compiled.js
new file mode 100644
index 00000000..4301200f
--- /dev/null
+++ b/js/helper-classes/RDGE/src/tools/rdge-compiled.js
@@ -0,0 +1,454 @@
+vec2={string:function(a){return"{ "+a[0]+", "+a[1]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<2?!1:typeof a[0]!="number"||typeof a[1]!="number"?!1:!0},copy:function(a){return a.length==void 0?[a,a]:[a[0],a[1]]},inplace_copy:function(a,b){a[0]=b[0];a[1]=b[1]},zero:function(){return[0,0]},up:function(){return[0,1]},right:function(){return[1,0]},add:function(a,b){return[a[0]+b[0],a[1]+b[1]]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1]]},mul:function(a,b){return[a[0]*b[0],
+a[1]*b[1]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=2?[a[0]+b[0]*f[0],a[1]+b[1]*f[1]]:[a[0]+b[0]*f,a[1]+b[1]*f]},scale:function(a,b){return b.length!=void 0&&b.length>=2?[a[0]*b[0],a[1]*b[1]]:[a[0]*b,a[1]*b]},negate:function(a){return[-a[0],-a[1]]},normalize:function(a){var b=Math.sqrt(a[0]*a[0],a[1]*a[1]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b]):a},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]},perp:function(a){return[a[1],-a[0]]},lengthSq:function(a){return a[0]*a[0]+
+a[1]*a[1]},length:function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])},min:function(a,b){return[Math.min(a[0],b[0]),Math.min(a[1],b[1])]},max:function(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1])]}};vec2.clamp=function(a,b,f){return vec2.min(f,vec2.max(a,b))};vec3={string:function(a){return"{ "+a[0]+", "+a[1]+", "+a[2]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<3?!1:typeof a[0]!="number"||typeof a[1]!="number"||typeof a[2]!="number"?!1:!0},inplace_copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2]},copy:function(a){return a.length==void 0?[a,a,a]:[a[0],a[1],a[2]]},translation:function(a){return[a[12],a[13],a[14]]},basisX:function(a){return[a[0],a[1],a[2]]},basisY:function(a){return[a[4],a[5],a[6]]},basisZ:function(a){return[a[8],
+a[9],a[10]]},zero:function(){return[0,0,0]},up:function(){return[0,1,0]},forward:function(){return[0,0,1]},right:function(){return[1,0,0]},random:function(a,b){return[a[0]+(b[0]-a[0])*Math.random(),a[1]+(b[1]-a[1])*Math.random(),a[2]+(b[2]-a[2])*Math.random()]},xy:function(a){return[a[0],a[1]]},xz:function(a){return[a[0],a[2]]},add:function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2]]},plusEqual:function(a,b){a[0]+=b[0];a[1]+=b[1];a[2]+=b[2]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2]]},
+mul:function(a,b){return[a[0]*b[0],a[1]*b[1],a[2]*b[2]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=3?[a[0]+b[0]*f[0],a[1]+b[1]*f[1],a[2]+b[2]*f[2]]:[a[0]+b[0]*f,a[1]+b[1]*f,a[2]+b[2]*f]},plusEqualMul:function(a,b,f){f.length!==void 0&&f.length>=3?(a[0]+=b[0]*f[0],a[1]+=b[1]*f[1],a[2]+=b[2]*f[2]):(a[0]+=b[0]*f,a[1]+=b[1]*f,a[2]+=b[2]*f)},scale:function(a,b){return b.length!==void 0&&b.length>=3?[a[0]*b[0],a[1]*b[1],a[2]*b[2]]:[a[0]*b,a[1]*b,a[2]*b]},inplace_scale:function(a,b){b.length!==
+void 0&&b.length>=3?(a[0]*=b[0],a[1]*=b[1],a[2]*=b[2]):(a[0]*=b,a[1]*=b,a[2]*=b)},negate:function(a){return[-a[0],-a[1],-a[2]]},inplace_negate:function(a){a[0]=-a[0];a[1]=-a[1];a[2]=-a[2]},normalize:function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b,a[2]*b]):a},cross:function(a,b){return[a[1]*b[2]-b[1]*a[2],a[2]*b[0]-b[2]*a[0],a[0]*b[1]-b[0]*a[1]]},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},lengthSq:function(a){return a[0]*a[0]+
+a[1]*a[1]+a[2]*a[2]},length:function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2])},distanceSq:function(a,b){var f=[a[0]-b[0],a[1]-b[1],a[2]-b[2]];return f[0]*f[0]+f[1]*f[1]+f[2]*f[2]},distance:function(a,b){var f=[a[0]-b[0],a[1]-b[1],a[2]-b[2]];return Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2])}};vec3.angle=function(a,b){return Math.acos(vec3.dot(a,b))/(vec3.length(a)*vec3.length(b))};vec3.direction=function(a,b){return vec3.normalize(vec3.sub(b,a))};
+vec3.abs=function(a){return[Math.abs(a[0]),Math.abs(a[1]),Math.abs(a[2])]};vec3.min=function(a,b){return[Math.min(a[0],b[0]),Math.min(a[1],b[1]),Math.min(a[2],b[2])]};vec3.max=function(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1]),Math.max(a[2],b[2])]};vec3.clamp=function(a,b,f){return vec3.min(f,vec3.max(a,b))};vec3.equal=function(a,b,f){f||(f=0.0010);return vec3.distanceSq(a,b)<f*f};vec3.lerp=function(a,b,f){return[a[0]+(b[0]-a[0])*f,a[1]+(b[1]-a[1])*f,a[2]+(b[2]-a[2])*f]};vec4={string:function(a){return"{ "+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<4?!1:typeof a[0]!="number"||typeof a[1]!="number"||typeof a[2]!="number"||typeof a[3]!="number"?!1:!0},inplace_copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3]},copy:function(a){return a.length==void 0?[a,a,a,a]:a.length==3?[a[0],a[1],a[2],1]:[a[0],a[1],a[2],a[3]]},zero:function(){return[0,0,0,0]},identity:function(){return[0,0,0,1]},up:function(){return[0,
+1,0,0]},forward:function(){return[0,0,1,0]},right:function(){return[1,0,0,0]},random:function(a,b){return[a[0]+(b[0]-a[0])*Math.random(),a[1]+(b[1]-a[1])*Math.random(),a[2]+(b[2]-a[2])*Math.random(),a[3]+(b[3]-a[3])*Math.random()]},add:function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2],a[3]+b[3]]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2],a[3]-b[3]]},mul:function(a,b){return[a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=4?[a[0]+b[0]*
+f[0],a[1]+b[1]*f[1],a[2]+b[2]*f[2],a[3]+b[3]*f[3]]:[a[0]+b[0]*f,a[1]+b[1]*f,a[2]+b[2]*f,a[3]+b[3]*f]},scale:function(a,b){return b.length!=void 0&&b.length>=4?[a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]]:[a[0]*b,a[1]*b,a[2]*b,a[3]*b]},negate:function(a){return[-a[0],-a[1],-a[2],-a[3]]},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},normalize:function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b,a[2]*b,a[3]*b]):a},lengthSq:function(a){return a[0]*
+a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]},length:function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3])},abs:function(a){return[Math.abs(a[0]),Math.abs(a[1]),Math.abs(a[2]),Math.abs(a[3])]},min:function(a,b){return[Math.min(a[0],b[0]),Math.min(a[1],b[1]),Math.min(a[2],b[2]),Math.min(a[3],b[3])]},max:function(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1]),Math.max(a[2],b[2]),Math.min(a[3],b[3])]}};vec4.clamp=function(a,b,f){return vec4.min(f,vec4.max(a,b))};
+vec4.equal=function(a,b,f){f||(f=0.0010);return vec4.distanceSq(a,b)<f*f};vec4.lerp=function(a,b,f){return[a[0]+(b[0]-a[0])*f,a[1]+(b[1]-a[1])*f,a[2]+(b[2]-a[2])*f,a[3]+(b[3]-a[3])*f]};float3=function(){data=[3]};float4=function(){data=[4]};
+mat4={string:function(a){var b="{ ";b+=a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", ";b+=a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", ";b+=a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", ";b+=a[12]+", "+a[13]+", "+a[14]+", "+a[15]+" }";return b},toCSSString:function(a,b){var f=10;b&&(f=b);var g="matrix3d(";g+=a[0].toFixed(10)+", "+a[1].toFixed(10)+", "+a[2].toFixed(10)+", "+a[3].toFixed(10)+", ";g+=a[4].toFixed(10)+", "+a[5].toFixed(10)+", "+a[6].toFixed(10)+", "+a[7].toFixed(10)+", ";g+=a[8].toFixed(10)+", "+a[9].toFixed(10)+
+", "+a[10].toFixed(10)+", "+a[11].toFixed(10)+", ";g+=a[12].toFixed(10)*f+", "+(600-a[13].toFixed(10)*f)+", "+a[14].toFixed(10)*f+", "+a[15].toFixed(10)+")";return g},verify:function(a){if(a==void 0||a.length==void 0||a.length<16)return!1;for(var b=16;b--;)if(typeof a[b]!="number")return!1;return!0},copy:function(a){return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]},inplace_copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=
+b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15]},identity:function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]},zero:function(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},basis:function(a,b,f,g){return g==null||g==void 0?[a[0],a[1],a[2],0,b[0],b[1],b[2],0,f[0],f[1],f[2],0,0,0,0,1]:[a[0],a[1],a[2],a.length==4?a[3]:0,b[0],b[1],b[2],b.length==4?b[3]:0,f[0],f[1],f[2],f.length==4?f[3]:0,g[0],g[1],g[2],g.length==4?g[3]:1]},angleAxis:function(a,b){a*=
+Math.PI/180;a/=2;var f=Math.sin(a),g=Math.cos(a),h=f*f;vec3.normalize(b);vec3.lengthSq(b)<=0&&(b=[0,0,0,1]);var l=mat4.identity();if(b[0]==1&&b[1]==0&&b[2]==0)l[5]=1-2*h,l[6]=2*f*g,l[9]=-2*f*g,l[10]=1-2*h;else if(b[0]==0&&b[1]==1&&b[2]==0)l[0]=1-2*h,l[2]=-2*f*g,l[8]=2*f*g,l[10]=1-2*h;else if(b[0]==0&&b[1]==0&&b[2]==1)l[0]=1-2*h,l[1]=2*f*g,l[4]=-2*f*g,l[5]=1-2*h;else{var n=b[0],o=b[1],p=b[2],q=n*n,r=o*o,s=p*p;l[0]=1-2*(r+s)*h;l[1]=2*(n*o*h+p*f*g);l[2]=2*(n*p*h-o*f*g);l[4]=2*(o*n*h-p*f*g);l[5]=1-2*
+(s+q)*h;l[6]=2*(o*p*h+n*f*g);l[8]=2*(p*n*h+o*f*g);l[9]=2*(p*o*h-n*f*g);l[10]=1-2*(q+r)*h}return l}};mat4.lookAt=function(a,b,f){b=vec3.normalize(vec3.sub(a,b));vec3.length(b)<1.0E-4&&(b=[0,0,1]);var f=vec3.normalize(vec3.cross(f,b)),g=vec3.normalize(vec3.cross(b,f)),h=mat4.identity();mat4.setRow(h,0,f);mat4.setRow(h,1,g);mat4.setRow(h,2,b);mat4.setRow(h,3,a);return h};
+mat4.frustum=function(a,b,f,g,h,l){var n=b-a,o=g-f,p=l-h,q=2*h,r=mat4.zero();r[0]=q/n;r[5]=q/o;r[8]=(b+a)/n;r[9]=(g+f)/o;r[10]=-(l+h)/p;r[11]=-1;r[14]=-(q*l)/p;return r};mat4.perspective=function(a,b,f,g){var a=Math.tan(a*Math.PI/360)*f,h=-a;return mat4.frustum(b*h,b*a,h,a,f,g)};mat4.orthographic=function(a,b,f,g,h,l){var n=(a+b)/(a-b),o=(f+g)/(f-g),p=(l+h)/(l-h),q=mat4.zero();q[0]=2/(a-b);q[5]=2/(f-g);q[10]=-2/(l-h);q[12]=n;q[13]=o;q[14]=p;q[15]=1;return q};
+mat4.mul=function(a,b){var f=a[0],g=a[1],h=a[2],l=a[3],n=a[4],o=a[5],p=a[6],q=a[7],r=a[8],s=a[9],u=a[10],v=a[11],x=a[12],w=a[13],y=a[14],z=a[15],A=b[0],C=b[1],D=b[2],B=b[3],E=b[4],F=b[5],G=b[6],H=b[7],I=b[8],J=b[9],K=b[10],L=b[11],M=b[12],N=b[13],O=b[14],P=b[15];return[f*A+g*E+h*I+l*M,f*C+g*F+h*J+l*N,f*D+g*G+h*K+l*O,f*B+g*H+h*L+l*P,n*A+o*E+p*I+q*M,n*C+o*F+p*J+q*N,n*D+o*G+p*K+q*O,n*B+o*H+p*L+q*P,r*A+s*E+u*I+v*M,r*C+s*F+u*J+v*N,r*D+s*G+u*K+v*O,r*B+s*H+u*L+v*P,x*A+w*E+y*I+z*M,x*C+w*F+y*J+z*N,x*D+w*G+
+y*K+z*O,x*B+w*H+y*L+z*P]};mat4.mul4x3=function(a,b){var f=a[0],g=a[1],h=a[2],l=a[4],n=a[5],o=a[6],p=a[8],q=a[9],r=a[10],s=a[12],u=a[13],v=a[14],x=b[0],w=b[1],y=b[2],z=b[4],A=b[5],C=b[6],D=b[8],B=b[9],E=b[10];return[f*x+g*z+h*D,f*w+g*A+h*B,f*y+g*C+h*E,0,l*x+n*z+o*D,l*w+n*A+o*B,l*y+n*C+o*E,0,p*x+q*z+r*D,p*w+q*A+r*B,p*y+q*C+r*E,0,s*x+u*z+v*D+b[12],s*w+u*A+v*B+b[13],s*y+u*C+v*E+b[14],1]};mat4._det2x2=function(a,b,f,g){return a*g-b*f};
+mat4._det3x3=function(a,b,f,g,h,l,n,o,p){return a*mat4._det2x2(h,l,o,p)-g*mat4._det2x2(b,f,o,p)+n*mat4._det2x2(b,f,h,l)};mat4._det4x4=function(a){var b=a[1],f=a[2],g=a[3],h=a[4],l=a[5],n=a[6],o=a[7],p=a[8],q=a[9],r=a[10],s=a[11],u=a[12],v=a[13],x=a[14],w=a[15];return a[0]*mat4._det3x3(l,q,v,n,r,x,o,s,w)-b*mat4._det3x3(h,p,u,n,r,x,o,s,w)+f*mat4._det3x3(h,p,u,l,q,v,o,s,w)-g*mat4._det3x3(h,p,u,l,q,v,n,r,x)};
+mat4._adjoint=function(a){var b=a[0],f=a[1],g=a[2],h=a[3],l=a[4],n=a[5],o=a[6],p=a[7],q=a[8],r=a[9],s=a[10],u=a[11],v=a[12],x=a[13],w=a[14],a=a[15];return[mat4._det3x3(n,r,x,o,s,w,p,u,a),-mat4._det3x3(f,r,x,g,s,w,h,u,a),mat4._det3x3(f,n,x,g,o,w,h,p,a),-mat4._det3x3(f,n,r,g,o,s,h,p,u),-mat4._det3x3(l,q,v,o,s,w,p,u,a),mat4._det3x3(b,q,v,g,s,w,h,u,a),-mat4._det3x3(b,l,v,g,o,w,h,p,a),mat4._det3x3(b,l,q,g,o,s,h,p,u),mat4._det3x3(l,q,v,n,r,x,p,u,a),-mat4._det3x3(b,q,v,f,r,x,h,u,a),mat4._det3x3(b,l,v,f,
+n,x,h,p,a),-mat4._det3x3(b,l,q,f,n,r,h,p,u),-mat4._det3x3(l,q,v,n,r,x,o,s,w),mat4._det3x3(b,q,v,f,r,x,g,s,w),-mat4._det3x3(b,l,v,f,n,x,g,o,w),mat4._det3x3(b,l,q,f,n,r,g,o,s)]};mat4.inverse=function(a){var b=mat4._det4x4(a);if(Math.abs(b)<1.0E-8)return null;a=mat4._adjoint(a);b=1/b;return[a[0]*b,a[1]*b,a[2]*b,a[3]*b,a[4]*b,a[5]*b,a[6]*b,a[7]*b,a[8]*b,a[9]*b,a[10]*b,a[11]*b,a[12]*b,a[13]*b,a[14]*b,a[15]*b]};
+mat4.rigidInverse=function(a){out=mat4.transpose3x3(a);out[12]=-vec3.dot([out[0],out[4],out[8]],[a[12],a[13],a[14]]);out[13]=-vec3.dot([out[1],out[5],out[9]],[a[12],a[13],a[14]]);out[14]=-vec3.dot([out[2],out[6],out[10]],[a[12],a[13],a[14]]);return out};mat4.transpose=function(a){return[a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]]};mat4.transpose3x3=function(a){return[a[0],a[4],a[8],a[3],a[1],a[5],a[9],a[7],a[2],a[6],a[10],a[11],a[12],a[13],a[14],a[15]]};
+mat4.transformPoint=function(a,b){var f=b[0],g=b[1],h=b[2],l=b.length>=4?b[3]:1;return[a[0]*f+a[4]*g+a[8]*h+a[12]*l,a[1]*f+a[5]*g+a[9]*h+a[13]*l,a[2]*f+a[6]*g+a[10]*h+a[14]*l,a[3]*f+a[7]*g+a[11]*h+a[15]*l]};mat4.transformVector=function(a,b){var a=mat4.inverse(a),f=b[0],g=b[1],h=b[2],l=b.length>=4?b[3]:0;return[a[0]*f+a[1]*g+a[2]*h+a[3]*l,a[4]*f+a[5]*g+a[6]*h+a[7]*l,a[8]*f+a[9]*g+a[10]*h+a[11]*l,a[12]*f+a[13]*g+a[14]*h+a[15]*l]};
+mat4.transformPoint4x3=function(a,b){var f=b[0],g=b[1],h=b[2];return[a[0]*f+a[4]*g+a[8]*h+a[12],a[1]*f+a[5]*g+a[9]*h+a[13],a[2]*f+a[6]*g+a[10]*h+a[14],1]};mat4.transformVector4x3=function(a,b){var a=mat4.inverse(a),f=b[0],g=b[1],h=b[2];return[a[0]*f+a[1]*g+a[2]*h,a[4]*f+a[5]*g+a[6]*h,a[8]*f+a[9]*g+a[10]*h,0]};mat4.getRow=function(a,b){b*=4;return[a[b],a[b+1],a[b+2],a[b+3]]};mat4.getCol=function(a,b){return[a[b],a[b+4],a[b+8],a[b+12]]};
+mat4.setRow=function(a,b,f){b*=4;a[b+0]=f[0];a[b+1]=f[1];a[b+2]=f[2];f.length>=4&&(a[b+3]=f[3]);return a};mat4.setCol=function(a,b,f){a[b+0]=f[0];a[b+4]=f[1];a[b+8]=f[2];f.length>=4&&(a[b+12]=f[3]);return a};mat4.rotate=function(a,b,f){return mat4.mul(a,mat4.angleAxis(b,f))};mat4.rotateX=function(a,b){return mat4.mul(a,mat4.angleAxis(b,vec3.basisX(a)))};mat4.rotateY=function(a,b){return mat4.mul(a,mat4.angleAxis(b,vec3.basisY(a)))};mat4.rotateZ=function(a,b){return mat4.mul(a,mat4.angleAxis(b,vec3.basisZ(a)))};
+mat4.scale=function(a,b){var f=mat4.identity();b.length==void 0&&(b=[b,b,b]);f[0]=b[0];f[5]=b[1];f[10]=b[2];return mat4.mul(a,f)};mat4.scaleX=function(a,b){return mat4.scale(a,[b,1,1])};mat4.scaleY=function(a,b){return mat4.scale(a,[1,b,1])};mat4.scaleZ=function(a,b){return mat4.scale(a,[1,1,b])};mat4.translate=function(a,b){matT=mat4.identity();matT[12]=b[0];matT[13]=b[1];matT[14]=b[2];return mat4.mul(a,matT)};mat4.translateX=function(a,b){return mat4.translate(a,[b,0,0])};
+mat4.translateY=function(a,b){return mat4.translate(a,[0,b,0])};mat4.translateZ=function(a,b){return mat4.translate(a,[0,0,b])};quat={string:function(a){return"{ "+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<4?!1:typeof a[0]!="number"||typeof a[1]!="number"||typeof a[2]!="number"||typeof a[3]!="number"?!1:!0},identity:function(){return[0,0,0,1]},add:function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2],a[3]+b[3]]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2],a[3]-b[3]]},mul:function(a,b){return[a[3]*b[3]-a[0]*b[0]-a[1]*b[1]-a[2]*b[2],a[3]*b[0]+a[0]*b[3]+a[1]*
+b[2]-a[2]*b[1],a[3]*b[1]-a[0]*b[2]+a[1]*b[3]+a[2]*b[0],a[3]*b[2]+a[0]*b[1]-a[1]*b[0]+a[2]*b[3]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=4?[a[0]+b[0]*f[0],a[1]+b[1]*f[1],a[2]+b[2]*f[2],a[3]+b[3]*f[3]]:[a[0]+b[0]*f,a[1]+b[1]*f,a[2]+b[2]*f,a[3]+b[3]*f]},scale:function(a,b){return b.length!=void 0&&b.length>=4?[a[0]*b[0],a[1]*a[1],a[2]*b[2],a[3]*b[3]]:[a[0]*b,a[1]*b,a[2]*b,a[3]*b]},lengthSq:function(a){return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]},length:function(a){return Math.sqrt(a[0]*
+a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3])},normalize:function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b,a[2]*b,a[3]*b]):a},inverse:function(a){var b=vec4.lengthSq(a);return b>1.0E-5?(b=1/b,[a[0]*-b,a[1]*-b,a[2]*-b,a[3]]):a},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}};quat.applyRotation=function(a,b){return mat4.transformPoint(quat.toMatrix(a),b)};
+quat.lerp=function(a,b,f){return quat.normalize([a[0]+(b[0]-a[0])*f,a[1]+(b[1]-a[1])*f,a[2]+(b[2]-a[2])*f,a[3]+(b[3]-a[3])*f])};quat.slerp=function(a,b,f){var g=quat.dot(a,b);if(g>=0.9)return quat.lerp(a,b,f);var h=Math.sqrt(Math.abs(1-g*g));if(h<0.0010)return a;var g=g<0?-1:1,l=Math.asin(h),n=1/h,h=Math.sin((1-f)*l)*n,f=Math.sin(f*l)*n*g;quat.scale(a,h);quat.scale(b,f);return quat.normalize(quat.add(a,b))};
+quat.toMatrix=function(a){var b=2*a[0],f=2*a[1],g=2*a[2],h=b*a[3],l=f*a[3],n=g*a[3];b*=a[0];var o=f*a[0],p=g*a[0];f*=a[1];var q=g*a[1],a=g*a[2];return[1-(f+a),o+n,p-l,0,o-n,1-(b+a),q+h,0,p+l,q-h,1-(b+f),0,0,0,0,1]};var stat=function(){pages={};dlgId="";self=function(a,b,f,g,h){h==void 0&&(h=!0);category=!a?"default":a;pages[category]||(pages[category]=[]);pages[category].push(this);this.name=b;this.value=this.defValue=f;this.func=g;this.reset=h;this.reportInterval=500;stat.dirty=!0;stat.find=function(a,b){var f=pages[a];for(i=0;i<f.length;++i)if(f[i].name==b)return f[i];return null};stat.closePage=function(a){pages[a]=null;stat.dirty=!0};stat.reportAll=function(b){if(stat.dirty==!0){var f=document.getElementById(b);
+if(!f)return;var g='<div id="stat_tabs">';g+="<ul>";for(a in pages)pages[a]&&(g+='<li><a href="#'+a+'">'+a+"</a></li>");g+="</ul>";for(a in pages)pages[a]&&(g+='<div id="'+a+'">',g+="</div>");g+="</div>";f.innerHTML=g;$("#stat_tabs").tabs();stat.dirty=!1}for(a in pages)f=document.getElementById(a),stat.report(f,a,b)};stat.report=function(a,b){b||(b="default");var f=pages[b];if(f){outputHTML='<table width="100%" cellspacing = 1 border = 0><tr>';var g=0;for(i=0;i<f.length;++i)if(outputHTML+='<td width=200 align=center bgcolor="#3F3F3F">',
+outputHTML+=f[i].func?f[i].name+" : "+f[i].func(f[i].value):f[i].name+" : "+f[i].value,outputHTML+="</td>",g++>=3&&(outputHTML+="</tr><tr>",g=0),f[i].reset)f[i].value=f[i].defValue;outputHTML+="</tr></table>";a.innerHTML=outputHTML}}};setInterval(function(){self.reportAll("RDGE_STATS")},500);return self}();
+dbCanvas=function(a,b){this.front=document.createElement("canvas");this.front.setAttribute("width",a);this.front.setAttribute("height",b);this.front.setAttribute("style","position:absolute; margin: 0.0em; padding: 0.0em;");this.front.ctx=this.front.getContext("2d");this.back=document.createElement("canvas");this.back.setAttribute("width",a);this.back.setAttribute("height",b);this.front.setAttribute("style","position:absolute; margin: 0.0em; padding: 0.0em;");this.back.ctx=this.back.getContext("2d");
+this.swap=function(){var a=this.front;this.front=this.back;this.back=a;this.front.style.visibility="visible";this.back.style.visibility="hidden"}};function getCanvasDimensions(a){var b={x:0,y:0};b.width=a.width;b.height=a.height;if(a.offsetParent){do b.x+=a.offsetLeft,b.y+=a.offsetTop;while(a=a.offsetParent)}return b}
+graph2D=function(a,b,f,g,h,l,n){this.style=n||{bgcolor:"#000"};this.sampleRes=512;this.scale=1;this.rangeMin=h;this.rangeMax=l;this.offsetY=0;this.canvas=document.createElement("canvas");this.canvas.setAttribute("width",f);this.canvas.setAttribute("height",g-32);this.canvas.setAttribute("style","position:absolute; margin: 0.0em; padding: 0.0em;");o=this;this.onclick=function(a){for(var b=getCanvasDimensions(o.canvas),f=a.clientX-b.x,a=a.clientY-b.y,b=0;b<o.tracked.length;++b){var g=o.tracked[b].checkbox;
+if(!(f<g.x)&&!(f>g.x+g.w)&&!(a>g.y+g.h)&&!(a<g.y)){o.tracked[b].hide=!o.tracked[b].hide;break}}};this.canvas.onclick=this.onclick;this.ctx=this.canvas.getContext("2d");this.tracked=[];this.addStat=function(a,b,f,g){this.tracked.push({label:a,stat:b,color:f,samples:[],hide:g,checkbox:{x:0,y:0,w:12,h:12}})};this.markers=[];this.addMarker=function(a,b,f){if(b.slice&&typeof b.slice==="function")for(i=0;i<b.length;++i)this.markers.push({label:a+i,value:b[i],color:f});else if(typeof b==="object"){var g=
+(b.max-b.min)/b.interval,h=b.interval;for(i=0;i<=g;++i)this.markers.push({label:a+i,value:i*h-b.min,color:f})}else this.markers.push({label:a,value:b,color:f})};this.update=function(){for(var a=0;a<this.tracked.length;++a){var b=this.tracked[a];b.samples.length>this.sampleRes&&b.samples.shift();b.samples.push(b.stat.value)}};this.draw=function(){var a=this.canvas,b=this.ctx,f=a.width,g=a.height,h=this.rangeMin*this.scale,l=1/(this.rangeMax*this.scale-h),n=16+Math.floor(this.tracked.length/4+0.5)*
+16;b.fillStyle=this.style.bgcolor;b.strokeStyle=this.style.bgcolor;b.fillRect(0,0,f,g-n);for(a=0;a<this.markers.length;++a){var o=this.markers[a];b.fillStyle=o.color;b.strokeStyle=o.color;var y=g-(n+(o.value-h)*l*g),z=b.measureText(o.value);b.lineWidth=1;b.beginPath();b.moveTo(0,Math.round(y));b.lineTo(f,Math.round(y));b.stroke();b.closePath()}b.lineWidth=1;for(a=0;a<this.tracked.length;++a)if(o=this.tracked[a],!o.hide){z=f/this.sampleRes;b.fillStyle=o.color;b.beginPath();y=(o.samples[0]-h)*l*g;b.moveTo(0,
+g-(n+y));for(var A=1;A<o.samples.length;A++)y=(o.samples[A]-h)*l*g,b.lineTo(A*z,g-(n+y));b.strokeStyle=o.color;b.stroke();b.closePath()}b.globalAlpha=0.25;A=f*0.125/this.scale;b.fillStyle="#044";b.fillRect(f-A,0,A,g);for(a=0;a<this.markers.length;++a)o=this.markers[a],b.fillStyle=o.color,b.strokeStyle=o.color,y=g-(n+(o.value-h)*l*g),b.font=Math.round(10/this.scale)+"pt courier",z=b.measureText(o.value),b.globalAlpha=1,b.fillText(o.value,f-z.width-5,y-2,A),b.globalAlpha=0.25;b.globalAlpha=1;b.lineWidth=
+1;b.fillStyle="#0A0A0A";b.strokeStyle="#8F8F8F";b.fillRect(0,g-n,f,n);b.translate([0.5,0.5]);f/=4;g=g