Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 7 commits
  • 19 files changed
  • 0 comments
  • 1 contributor
4  .gitignore
... ...
@@ -0,0 +1,4 @@
  1
+
  2
+GLOW.sublime-project
  3
+
  4
+GLOW.sublime-workspace
12  src/core/Cache.js
@@ -78,6 +78,18 @@ GLOW.Cache = (function() {
78 78
         return false;
79 79
     };
80 80
 
  81
+    GLOWCache.prototype.interleavedAttributeCached = function( interleavedAttribtue ) {
  82
+        if( this.active ) {
  83
+            var a = 0, al = interleavedAttribtue.attributes.length, attribute;
  84
+            for( ; a < al; a++ ) {
  85
+                attribute = interleavedAttribtue.attributes[ a ];
  86
+                if( this.attributeByLocation[ attribute.locationNumber ] === attribute.id ) return true;
  87
+                this.attributeByLocation[ attribute.locationNumber ] = attribute.id;
  88
+            }
  89
+        }
  90
+        return false;
  91
+    }
  92
+
81 93
     GLOWCache.prototype.invalidateAttribute = function( attribute ) {
82 94
         this.attributeByLocation[ attribute.locationNumber ] = undefined;
83 95
     }
20  src/core/Compiler.js
@@ -156,9 +156,10 @@ GLOW.Compiler = (function() {
156 156
 		var uniforms = {};
157 157
 		var uniform;
158 158
 		var locationNumber = 0;
  159
+		var numLocations = GL.getProgramParameter( program, GL.ACTIVE_UNIFORMS );
159 160
 		var result;
160 161
 
161  
-		while( true ) {
  162
+		for( ; locationNumber < numLocations; locationNumber++ ) {
162 163
 			result = GL.getActiveUniform( program, locationNumber );
163 164
 			if( result !== null && result !== -1 && result !== undefined ) {
164 165
                 uniform = {
@@ -170,7 +171,6 @@ GLOW.Compiler = (function() {
170 171
                 };
171 172
 				uniforms[ uniform.name ] = uniform;
172 173
 			} else break;
173  
-			locationNumber++;
174 174
 		}
175 175
 
176 176
 		return uniforms;
@@ -180,11 +180,13 @@ GLOW.Compiler = (function() {
180 180
 	//--- extract attributes ---
181 181
 	
182 182
 	compiler.extractAttributes = function( program ) {
183  
-		var attribute, locationNumber = 0;
184 183
 		var attributes = {};
185  
-        var result;
  184
+		var attribute;
  185
+		var locationNumber = 0;
  186
+		var numLocations = GL.getProgramParameter( program, GL.ACTIVE_ATTRIBUTES );
  187
+		var result;
186 188
 
187  
-		while( true ) {
  189
+		for( ; locationNumber < numLocations; locationNumber++ ) {
188 190
 			result = GL.getActiveAttrib( program, locationNumber );
189 191
 			if( result !== null && result !== -1 && result !== undefined ) {
190 192
                 attribute = {
@@ -196,7 +198,6 @@ GLOW.Compiler = (function() {
196 198
                 }
197 199
 				attributes[ attribute.name ] = attribute;
198 200
 			} else break;
199  
-			locationNumber++;
200 201
 		}
201 202
 
202 203
 		program.highestAttributeNumber = locationNumber - 1;
@@ -221,9 +222,10 @@ GLOW.Compiler = (function() {
221 222
 				uniforms[ name ] = data[ name ];
222 223
 			} else {
223 224
 				uniforms[ name ] = new GLOW.Uniform( uniform, data[ name ] );
224  
-				if( uniforms[ name ].type === GL.SAMPLER_2D || uniforms[ name ].type === GL.SAMPLER_CUBE ) {
  225
+				if( uniforms[ name ].type === GL.SAMPLER_2D || uniforms[ name ].type === GL.SAMPLER_CUBE ) {
225 226
 					uniforms[ name ].textureUnit = textureUnit++;
226  
-					uniforms[ name ].data.init();
  227
+					if( uniforms[ name ].data !== undefined )
  228
+						uniforms[ name ].data.init();
227 229
 				}
228 230
 			}
229 231
 		}
@@ -316,7 +318,7 @@ GLOW.Compiler = (function() {
316 318
  	    // create interleaved attributes
317 319
 	    var name, interleavedAttributes = {};
318 320
 	    for( a = 0, al = attributeByIndex.length; a < al; a++ ) {
319  
-	        if( attributeByIndex[ a ] !== undefined ) {
  321
+	        if( attributeByIndex[ a ] !== undefined ) {
320 322
 	            name = "";
321 323
 	            for( b = 0, bl = attributeByIndex[ a ].length; b < bl; b++ ) {
322 324
 	                name += b !== bl - 1 ? attributeByIndex[ a ][ b ].name + "_" : attributeByIndex[ a ][ b ].name;
2  src/core/Context.js
@@ -170,7 +170,7 @@ GLOW.Context = (function() {
170 170
     GLOWContext.prototype.setupStencilTest = function( setup ) {
171 171
         if( setup.func && setup.funcFace ) {
172 172
             GL.stencilFuncSeparate( setup.funcFace, setup.func, setup.funcRef, setup.funcMask );
173  
-        } else if( setup.func ) {
  173
+        } else if( setup.func ) {
174 174
             GL.stencilFunc( setup.func, setup.funcRef, setup.funcMask );
175 175
         }
176 176
         
6  src/core/FBO.js
@@ -69,7 +69,11 @@ GLOW.FBO = (function() {
69 69
     	GL.texParameteri( this.textureType, GL.TEXTURE_MIN_FILTER, minFilter );
70 70
 
71 71
         if( this.textureType === GL.TEXTURE_2D ) {
72  
-        	GL.texImage2D( this.textureType, 0, internalFormat, this.width, this.height, 0, format, type, data );
  72
+            if( data === null || data instanceof Uint8Array ) {
  73
+                GL.texImage2D( this.textureType, 0, internalFormat, this.width, this.height, 0, format, type, data );
  74
+            } else {
  75
+                GL.texImage2D( this.textureType, 0, internalFormat, format, type, data );
  76
+            }
73 77
         } else {
74 78
             for( var c in cubeSideOffsets ) {
75 79
             	GL.texImage2D( GL.TEXTURE_CUBE_MAP_POSITIVE_X + cubeSideOffsets[ c ], 0, internalFormat, this.width, this.height, 0, format, type, data[ c ] );
2  src/core/InterleavedAttributes.js
@@ -7,7 +7,7 @@ GLOW.InterleavedAttributes = (function() {
7 7
         this.attributes = attributes;
8 8
         
9 9
         // interleave data from the attributes
10  
-        var l, ll = attributes[ 0 ].data.length / attributes[ 0 ].size;
  10
+        var l, ll = attributes[ 0 ].data.length / attributes[ 0 ].size;
11 11
         var a, al = attributes.length;
12 12
         var b, bl;
13 13
         var i, indices = [];
4  src/core/Shader.js
@@ -96,7 +96,9 @@ GLOW.Shader = (function() {
96 96
         }
97 97
 
98 98
         for( var a in compiledData.interleavedAttributes ) {
99  
-            compiledData.interleavedAttributes[ a ].bind();
  99
+            if( !cache.interleavedAttributeCached( compiledData.interleavedAttributes[ a ] )) {
  100
+                compiledData.interleavedAttributes[ a ].bind();
  101
+            }
100 102
         }
101 103
         
102 104
         for( var u in compiledData.uniforms ) {
20  src/core/Texture.js
@@ -27,6 +27,8 @@ GLOW.Texture = (function() {
27 27
 
28 28
 	// methods
29 29
     GLOWTexture.prototype.init = function() {
  30
+        if( this.texture !== undefined ) return;
  31
+
30 32
         if( this.data === undefined && 
31 33
             this.width !== undefined && 
32 34
             this.height !== undefined ) {
@@ -112,6 +114,7 @@ GLOW.Texture = (function() {
112 114
     };
113 115
     
114 116
     GLOWTexture.prototype.createTexture = function() {
  117
+
115 118
        	this.texture = GL.createTexture();
116 119
     	GL.bindTexture( this.textureType, this.texture );
117 120
 
@@ -128,15 +131,15 @@ GLOW.Texture = (function() {
128 131
         	}
129 132
     	} else {
130 133
     	    for( var c in cubeSideOffsets ) {
131  
-    	        if( this.data[ c ] instanceof Uint8Array || this.data[ c ] instanceof Float32Array ) {
132  
-            	    if( this.width !== undefined && this.height !== undefined ) {
133  
-                    	GL.texImage2D( GL.TEXTURE_CUBE_MAP_POSITIVE_X + cubeSideOffsets[ c ], 0, this.internalFormat, this.width, this.height, 0, this.format, this.type, this.data[ c ] );
  134
+                if( this.data[ c ] instanceof Uint8Array || this.data[ c ] instanceof Float32Array ) {
  135
+                    if( this.width !== undefined && this.height !== undefined ) {
  136
+                        GL.texImage2D( GL.TEXTURE_CUBE_MAP_POSITIVE_X + cubeSideOffsets[ c ], 0, this.internalFormat, this.width, this.height, 0, this.format, this.type, this.data[ c ] );
134 137
             	    } else {
135 138
             	        console.error( "GLOW.Texture.createTexture: Textures of type Uint8Array/Float32Array requires width and height parameters. Quitting." );
136  
-            	        return;
137  
-            	    }
138  
-    	        } else {
139  
-                	GL.texImage2D( GL.TEXTURE_CUBE_MAP_POSITIVE_X + cubeSideOffsets[ c ], 0, this.internalFormat, this.format, this.type, this.data[ c ] );
  139
+                        return;
  140
+                    }
  141
+                } else {
  142
+                    GL.texImage2D( GL.TEXTURE_CUBE_MAP_POSITIVE_X + cubeSideOffsets[ c ], 0, this.internalFormat, this.format, this.type, this.data[ c ] );
140 143
     	        }
141 144
     	    }
142 145
     	}
@@ -152,6 +155,9 @@ GLOW.Texture = (function() {
152 155
     };
153 156
     
154 157
     GLOWTexture.prototype.updateTexture = function( parameters ) {
  158
+
  159
+        if( this.texture === undefined ) return;
  160
+
155 161
         parameters = parameters !== undefined ? parameters : {};
156 162
         
157 163
         var level = parameters.level !== undefined ? parameters.level : 0;
10  src/extras/geometry/Cube.js
@@ -77,7 +77,11 @@ GLOW.Geometry.Cube = {
77 77
 
78 78
 		return a;
79 79
 	},
80  
-	
  80
+
  81
+	primitives: function() {
  82
+	    return GL.TRIANGLES;
  83
+	},
  84
+
81 85
 	uvs: function() {
82 86
 		
83 87
 		var a = new Float32Array( 6 * 4 * 2 );
@@ -116,8 +120,8 @@ GLOW.Geometry.Cube = {
116 120
 		return a;
117 121
 	},
118 122
 	
119  
-	primitives: function() {
120  
-	    return GL.TRIANGLES;
  123
+	normals: function() {
  124
+		return GLOW.Geometry.faceNormals( GLOW.Geometry.Cube.vertices(), GLOW.Geometry.Cube.indices());
121 125
 	}
122 126
 }
123 127
 
124  src/extras/geometry/Cylinder.js
... ...
@@ -0,0 +1,124 @@
  1
+GLOW.Geometry.Cylinder = {
  2
+	
  3
+	vertices: function( numSegs, topRad, botRad, height ) {
  4
+
  5
+		numSegs = numSegs | 7;
  6
+		topRad  = topRad  | 1;
  7
+		botRad  = botRad  | 1;
  8
+		height  = height  | 1;
  9
+
  10
+		var vertices = [];
  11
+		var s, PI2 = Math.PI * 2, halfHeight = height * 0.5;
  12
+
  13
+		for( s = 0; s < numSegs; s++ ) {
  14
+			vertices.push( Math.sin( PI2 * s / numSegs ) * topRad );
  15
+			vertices.push( halfHeight );
  16
+			vertices.push( Math.cos( PI2 * s / numSegs ) * topRad );
  17
+		}
  18
+
  19
+		for( s = 0; s < numSegs; s++ ) {
  20
+			vertices.push( Math.sin( PI2 * s / numSegs ) * botRad );
  21
+			vertices.push( -halfHeight );
  22
+			vertices.push( Math.cos( PI2 * s / numSegs ) * botRad );
  23
+		}
  24
+
  25
+		vertices.push( 0 );
  26
+		vertices.push( halfHeight );
  27
+		vertices.push( 0 );
  28
+
  29
+		vertices.push( 0 );
  30
+		vertices.push( -halfHeight );
  31
+		vertices.push( 0 );
  32
+
  33
+		return vertices;
  34
+	},
  35
+
  36
+	indices: function( numSegs ) {
  37
+
  38
+		numSegs = numSegs | 7;
  39
+		var a, b, c, d, s, indices = [];
  40
+
  41
+		for( s = 0; s < numSegs; s++ ) {
  42
+			a = s;
  43
+			b = s + numSegs;
  44
+			c = numSegs + ( s + 1 ) % numSegs;
  45
+			d = ( s + 1 ) % numSegs;
  46
+
  47
+			indices.push( a );
  48
+			indices.push( b );
  49
+			indices.push( c );
  50
+
  51
+			indices.push( a );
  52
+			indices.push( c );
  53
+			indices.push( d );
  54
+		}
  55
+
  56
+		for( s = numSegs; s < numSegs + numSegs * 0.5; s++ ) {
  57
+			a = 2 * numSegs;
  58
+			b = ( 2 * s - 2 * numSegs + 0 ) % numSegs;
  59
+			c = ( 2 * s - 2 * numSegs + 1 ) % numSegs;
  60
+			d = ( 2 * s - 2 * numSegs + 2 ) % numSegs;
  61
+
  62
+			indices.push( a );
  63
+			indices.push( b );
  64
+			indices.push( c );
  65
+
  66
+			indices.push( a );
  67
+			indices.push( c );
  68
+			indices.push( d );
  69
+		}
  70
+
  71
+		for( s = numSegs + numSegs * 0.5; s < 2 * numSegs; s ++ ) {
  72
+			a = 2 * numSegs + 1;
  73
+			b = ( 2 * s - 2 * numSegs + 2 ) % numSegs + numSegs;
  74
+			c = ( 2 * s - 2 * numSegs + 1 ) % numSegs + numSegs;
  75
+			d = ( 2 * s - 2 * numSegs + 0 ) % numSegs + numSegs;
  76
+
  77
+			indices.push( a );
  78
+			indices.push( b );
  79
+			indices.push( c );
  80
+
  81
+			indices.push( a );
  82
+			indices.push( c );
  83
+			indices.push( d );
  84
+		}
  85
+
  86
+		return indices;
  87
+	},
  88
+
  89
+	uvs: function() {
  90
+/*
  91
+		for ( var i = 0, il = this.faces.length; i < il; i ++ ) {
  92
+
  93
+			var uvs = [], face = this.faces[ i ],
  94
+			a = this.vertices[ face.a ],
  95
+			b = this.vertices[ face.b ],
  96
+			c = this.vertices[ face.c ],
  97
+			d = this.vertices[ face.d ];
  98
+
  99
+			uvs.push( new THREE.UV( 0.5 + Math.atan2( a.position.x, a.position.y ) / PI2, 0.5 + ( a.position.z / height ) ) );
  100
+			uvs.push( new THREE.UV( 0.5 + Math.atan2( b.position.x, b.position.y ) / PI2, 0.5 + ( b.position.z / height ) ) );
  101
+			uvs.push( new THREE.UV( 0.5 + Math.atan2( c.position.x, c.position.y ) / PI2, 0.5 + ( c.position.z / height ) ) );
  102
+
  103
+			if ( face instanceof THREE.Face4 ) {
  104
+
  105
+				uvs.push( new THREE.UV( 0.5 + ( Math.atan2( d.position.x, d.position.y ) / PI2 ), 0.5 + ( d.position.z / height ) ) );
  106
+
  107
+			}
  108
+
  109
+			this.faceVertexUvs[ 0 ].push( uvs );
  110
+
  111
+		}
  112
+*/		
  113
+	},
  114
+
  115
+	primitives: function() {
  116
+	    return GL.TRIANGLES;
  117
+	},
  118
+
  119
+	normals: function( numSegs ) {
  120
+		return GLOW.Geometry.faceNormals( GLOW.Geometry.Cylinder.vertices( numSegs ), GLOW.Geometry.Cylinder.indices( numSegs ));
  121
+	}
  122
+}
  123
+
  124
+
6  src/extras/geometry/Geometry.js
@@ -41,7 +41,7 @@ GLOW.Geometry = {
41 41
 	},
42 42
 	
43 43
 	faceNormals: function( vertices, elements ) {
44  
-		var normals = new Float32Array( vertices.length );
  44
+		var normals = new Array( vertices.length );
45 45
 		var e, el = elements.length;
46 46
 		var a, b, c;
47 47
 		var av = new GLOW.Vector3();
@@ -61,7 +61,7 @@ GLOW.Geometry = {
61 61
 			bv.subSelf( av );
62 62
 			cv.subSelf( av );
63 63
 			
64  
-			nv.cross( cv, bv ).normalize();
  64
+			nv.cross( bv, cv ).normalize();
65 65
 			
66 66
 			normals[ a + 0 ] = nv.value[ 0 ]; normals[ a + 1 ] = nv.value[ 1 ]; normals[ a + 2 ] = nv.value[ 2 ];
67 67
 			normals[ b + 0 ] = nv.value[ 0 ]; normals[ b + 1 ] = nv.value[ 1 ]; normals[ b + 2 ] = nv.value[ 2 ];
@@ -105,7 +105,7 @@ GLOW.Geometry = {
105 105
 	    
106 106
 	    for( d in attributeSizes ) {
107 107
 	        if( vertexShadedData[ d ] ) {
108  
-    	        vertexShadedAttribute = vertexShadedData[ d ];
  108
+    	        vertexShadedAttribute = vertexShadedData[ d ];
109 109
     	        flatShadedAttribute   = [];
110 110
     	        size                  = attributeSizes[ d ];
111 111
 
14  src/extras/graph/Camera.js
@@ -10,17 +10,17 @@ GLOW.Camera = function( parameters ) {
10 10
 
11 11
 	parameters = parameters !== undefined ? parameters : {};
12 12
 
13  
-	var fov    = parameters.fov    !== undefined ? parameters.fov    : 40;
14  
-	var aspect = parameters.aspect !== undefined ? parameters.aspect : window.innerWidth / window.innerHeight;
15  
-	var near   = parameters.near   !== undefined ? parameters.near   : 0.1;
16  
-	var far    = parameters.far    !== undefined ? parameters.far    : 10000;
  13
+	this.fov    = parameters.fov    !== undefined ? parameters.fov    : 40;
  14
+	this.aspect = parameters.aspect !== undefined ? parameters.aspect : window.innerWidth / window.innerHeight;
  15
+	this.near   = parameters.near   !== undefined ? parameters.near   : 0.1;
  16
+	this.far    = parameters.far    !== undefined ? parameters.far    : 10000;
17 17
 
18  
-	this.useTarget  = parameters.useTarget !== undefined ? parameters.useTarget : true;
  18
+	this.useTarget = parameters.useTarget !== undefined ? parameters.useTarget : true;
19 19
 	
20 20
 	if( parameters.ortho !== undefined )
21  
-	    this.projection = GLOW.Matrix4.makeOrtho( parameters.ortho.left, parameters.ortho.right, parameters.ortho.top, parameters.ortho.bottom, near, far );
  21
+	    this.projection = GLOW.Matrix4.makeOrtho( parameters.ortho.left, parameters.ortho.right, parameters.ortho.top, parameters.ortho.bottom, this.near, this.far );
22 22
 	else
23  
-	    this.projection = GLOW.Matrix4.makeProjection( fov, aspect, near, far );
  23
+	    this.projection = GLOW.Matrix4.makeProjection( this.fov, this.aspect, this.near, this.far );
24 24
 
25 25
 	this.inverse    = new GLOW.Matrix4();
26 26
 	this.target     = new GLOW.Vector3( 0, 0, -100 );
26  src/extras/graph/Node.js
@@ -7,9 +7,12 @@ GLOW.Node = function( shader ) {
7 7
 	
8 8
 	"use strict";
9 9
 	
10  
-	this.localMatrix  = new GLOW.Matrix4();
11  
-	this.globalMatrix = new GLOW.Matrix4();
12  
-	this.viewMatrix   = new GLOW.Matrix4();
  10
+	this.localMatrix    = new GLOW.Matrix4();
  11
+	this.globalMatrix   = new GLOW.Matrix4();
  12
+	this.viewMatrix     = new GLOW.Matrix4();
  13
+	
  14
+	this.updateRotationMatrix = false;
  15
+	this.rotationMatrix = new GLOW.Matrix3(); 
13 16
 	
14 17
 	this.useXYZStyleTransform = false;
15 18
 	this.position = { x: 0, y: 0, z: 0 };
@@ -32,32 +35,27 @@ GLOW.Node = function( shader ) {
32 35
 GLOW.Node.prototype.update = function( parentGlobalMatrix, cameraInverseMatrix ) {
33 36
 	
34 37
 	if( this.useXYZStyleTransform ) {
35  
-		
36 38
 		this.localMatrix.setPosition( this.position.x, this.position.y, this.position.z );
37 39
 		this.localMatrix.setRotation( this.rotation.x, this.rotation.y, this.rotation.z );
38 40
 		this.localMatrix.scale( this.scale.x, this.scale.y, this.scale.z );
39 41
 	}
40 42
 	
41 43
 	if( parentGlobalMatrix ) {
42  
-
43 44
 		this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
44  
-
45 45
 	} else {
46  
-
47 46
 		this.globalMatrix.copy( this.localMatrix );
48 47
 	}
49 48
 	
  49
+	if( this.updateRotationMatrix ) {
  50
+		this.rotationMatrix.extractFromMatrix4( this.globalMatrix );
  51
+	}
50 52
 	
51 53
 	if( cameraInverseMatrix ) {
52  
-		
53 54
 		this.viewMatrix.multiply( cameraInverseMatrix, this.globalMatrix );
54 55
 	}
55 56
 	
56  
-
57 57
 	var c, cl = this.children.length;
58  
-
59 58
 	for( c = 0; c < cl; c++ ) {
60  
-		
61 59
 		this.children[ c ].update( this.globalMatrix, cameraInverseMatrix );
62 60
 	}
63 61
 	
@@ -67,14 +65,10 @@ GLOW.Node.prototype.update = function( parentGlobalMatrix, cameraInverseMatrix )
67 65
 GLOW.Node.prototype.addChild = function( child ) {
68 66
 	
69 67
 	if( this.children.indexOf( child ) === -1 ) {
70  
-		
71 68
 		this.children.push( child );
72  
-		
73 69
 		if( child.parent ) {
74  
-			
75 70
 			child.parent.removeChild( child );
76 71
 		}
77  
-		
78 72
 		child.parent = this;
79 73
 	}
80 74
 	
@@ -85,9 +79,7 @@ GLOW.Node.prototype.addChild = function( child ) {
85 79
 GLOW.Node.prototype.removeChild = function( child ) {
86 80
 	
87 81
 	var index = this.children.indexOf( child );
88  
-	
89 82
 	if( index !== -1 ) {
90  
-		
91 83
 		this.children.splice( 1, index );
92 84
 		child.parent = undefined;
93 85
 	}
8  src/extras/io/Load.js
@@ -47,10 +47,10 @@ GLOW.Load = (function() {
47 47
                     parameters[ p ].onreadystatechange = this.onLoadJSON;
48 48
                     parameters[ p ].send();
49 49
                 } else {
50  
-                    parameters[ p ] = document.createElement( "video" );
51  
-        	        parameters[ p ].scope = this;
52  
-            		parameters[ p ].addEventListener( "loadeddata", this.onLoadVideo, false );
53  
-            	    parameters[ p ].src = originalURL;
  50
+                    parameters[ p ] = document.createElement( "video" );
  51
+                    parameters[ p ].scope = this;
  52
+                    parameters[ p ].addEventListener( "loadeddata", this.onLoadVideo, false );
  53
+                    parameters[ p ].src = originalURL;
54 54
                 }
55 55
             } 
56 56
         }
8  src/extras/math/Float.js
@@ -9,8 +9,12 @@ GLOW.Float = (function() {
9 9
 	
10 10
     // constructor
11 11
 	function float( value ) {
12  
-    	this.value = new Float32Array( 1 );
13  
-    	this.value[ 0 ] = value !== undefined ? value : 0;
  12
+        if( value.length ) {
  13
+            this.value = new Float32Array( value );
  14
+       } else {
  15
+            this.value = new Float32Array( 1 );
  16
+            this.value[ 0 ] = value !== undefined ? value : 0;
  17
+        }
14 18
 	}
15 19
 
16 20
     // methods
12  src/extras/math/Int.js
@@ -3,14 +3,18 @@
3 3
 * @author: Mikael Emtinger, gomo.se
4 4
 */
5 5
 
6  
-GLOW.Int = (function() {
  6
+GLOW.Int = function( value ) {
7 7
 
8 8
 	"use strict";
9 9
 	
10 10
     // constructor
11 11
 	function int( value ) {
12  
-    	this.value = new Int32Array( 1 );
13  
-    	this.value[ 0 ] = value !== undefined ? value : 0;
  12
+        if( value.length ) {
  13
+            this.value = new int32Array( value );
  14
+        } else {
  15
+            this.value = new int32Array( 1 );
  16
+            this.value[ 0 ] = value !== undefined ? value : 0;
  17
+        }
14 18
 	}
15 19
 
16 20
     // methods
@@ -45,4 +49,4 @@ GLOW.Int = (function() {
45 49
     }
46 50
     	
47 51
 	return int;
48  
-})();
  52
+}
20  src/extras/math/Matrix3.js
@@ -25,20 +25,14 @@ GLOW.Matrix3 = (function() {
25 25
     	this.set( 1, 0, 0, 0, 1, 0, 0, 0, 1	);
26 26
     	return this;
27 27
     }
28  
-    
29  
-    matrix3.prototype.getValueAsFloat32Array = function() {
30  
-        this.float32Array[ 0 ] = this.value[ 0 ];
31  
-        this.float32Array[ 1 ] = this.value[ 1 ];
32  
-        this.float32Array[ 2 ] = this.value[ 2 ];
33  
-        this.float32Array[ 3 ] = this.value[ 3 ];
34  
-        this.float32Array[ 4 ] = this.value[ 4 ];
35  
-        this.float32Array[ 5 ] = this.value[ 5 ];
36  
-        this.float32Array[ 6 ] = this.value[ 6 ];
37  
-        this.float32Array[ 7 ] = this.value[ 7 ];
38  
-        this.float32Array[ 8 ] = this.value[ 8 ];
39  
-        return this.float32Array;
40  
-    }
41 28
 
  29
+    matrix3.prototype.extractFromMatrix4 = function( matrix4 ) {
  30
+        this.set( matrix4.value[ 0 ], matrix4.value[ 4 ], matrix4.value[ 8  ],
  31
+                  matrix4.value[ 1 ], matrix4.value[ 5 ], matrix4.value[ 9  ],
  32
+                  matrix4.value[ 2 ], matrix4.value[ 6 ], matrix4.value[ 10 ] );
  33
+        return this;
  34
+    }
  35
+    
42 36
     return matrix3;
43 37
 })();
44 38
 
6  src/extras/math/Matrix4.js
@@ -418,9 +418,9 @@ GLOW.Matrix4.makeOrtho = function( left, right, top, bottom, near, far ) {
418 418
 	var m, mv, x, y, z, w, h, p;
419 419
 
420 420
 	m = new GLOW.Matrix4();
421  
-	w = right - left;
422  
-	h = top - bottom;
423  
-	p = far - near;
  421
+	w = Math.abs( right - left );
  422
+	h = Math.abs( top - bottom );
  423
+	p = Math.abs( far - near );
424 424
 	x = ( right + left ) / w;
425 425
 	y = ( top + bottom ) / h;
426 426
 	z = ( far + near ) / p;
4  src/extras/math/Vector3.js
@@ -86,7 +86,7 @@ GLOW.Vector3 = (function( x, y, z ) {
86 86
     	a = a.value;
87 87
     	var ax = a[ 0 ], ay = a[ 1 ], az = a[ 2 ];
88 88
     	var vx = this.value[ 0 ], vy = this.value[ 1 ], vz = this.value[ 2 ];
89  
-    	this.value[ 0 ] = ay * vz - az * vy;
  89
+    	this.value[ 0 ] = ay * vz - az * vy;
90 90
     	this.value[ 1 ] = az * vx - ax * vz;
91 91
     	this.value[ 2 ] = ax * vy - ay * vx;
92 92
     	return this;
@@ -173,7 +173,7 @@ GLOW.Vector3 = (function( x, y, z ) {
173 173
 
174 174
     vector3.prototype.setPositionFromMatrix = function( m ) {
175 175
     	m = m.value;
176  
-    	this.value[ 0 ] = m[ 12 ];
  176
+    	this.value[ 0 ] = m[ 12 ];
177 177
     	this.value[ 1 ] = m[ 13 ];
178 178
     	this.value[ 2 ] = m[ 14 ];
179 179
     }

No commit comments for this range

Something went wrong with that request. Please try again.