Browse Source

WebGLRenderer: Using Uint32Array only when needed.

Mr.doob 11 years ago
parent
commit
85a72c533f
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/renderers/WebGLRenderer.js

+ 5 - 5
src/renderers/WebGLRenderer.js

@@ -899,7 +899,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		var UintArray = _glExtensionElementIndexUint ? Uint32Array : Uint16Array;
+		var UintArray = _glExtensionElementIndexUint !== null && ntris > 21845 ? Uint32Array : Uint16Array; // 65535 / 3
 
 		geometryGroup.__typeArray = UintArray;
 		geometryGroup.__faceArray = new UintArray( ntris * 3 );
@@ -2581,7 +2581,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			var type, size;
 			
-			if ( _glExtensionElementIndexUint !== null && index.array instanceof Uint32Array ) {
+			if ( index.array instanceof Uint32Array ) {
 				
 				type = _gl.UNSIGNED_INT;
 				size = 4;
@@ -2840,7 +2840,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					// render indexed lines
 					var type, size;
 					
-					if ( _glExtensionElementIndexUint !== null && index.array instanceof Uint32Array ){
+					if ( index.array instanceof Uint32Array ){
 						
 						type = _gl.UNSIGNED_INT;
 						size = 4;
@@ -3062,9 +3062,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( object instanceof THREE.Mesh ) {
 
-			// wireframe
+			var type = geometryGroup.__typeArray instanceof Uint32Array ? _gl.UNSIGNED_INT : _gl.UNSIGNED_SHORT;
 
-			var type = _glExtensionElementIndexUint !== null && geometryGroup.__typeArray instanceof Uint32Array ? _gl.UNSIGNED_INT : _gl.UNSIGNED_SHORT;
+			// wireframe
 			
 			if ( material.wireframe ) {