Browse Source

Removed bugs related to custom attributes and buffers. Removed bug related to attributes.position

Mikael Emtinger 14 years ago
parent
commit
cdcc530b0e
1 changed files with 17 additions and 9 deletions
  1. 17 9
      src/renderers/WebGLRenderer.js

+ 17 - 9
src/renderers/WebGLRenderer.js

@@ -2217,8 +2217,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		var attributes = material.program.attributes;
 
-		_gl.enableVertexAttribArray( attributes.position );
-
+		if ( attributes.position >= 0 ) _gl.enableVertexAttribArray( attributes.position );
 		if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color );
 		if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal );
 		if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent );
@@ -2234,13 +2233,18 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		for ( a in material.attributes ) {
-
-			if( attributes[ a ] >= 0 ) _gl.enableVertexAttribArray( attributes[ a ] );
-
+		if ( material.attributes ) {
+			
+			for ( a in material.attributes ) {
+	
+				if( attributes[ a ] !== undefined && attributes[ a ] >= 0 ) _gl.enableVertexAttribArray( attributes[ a ] );
+	
+			}
+			
 		}
 
 
+
 		if ( material.morphTargets ) {
 
 			material.numSupportedMorphTargets = 0;
@@ -2509,12 +2513,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			for( a in material.attributes ) {
 
-				if( attributes[ a ] >= 0 ) {
+				if( attributes[ a ] !== undefined && attributes[ a ] >= 0 ) {
 
 					attribute = material.attributes[ a ];
 
-					_gl.bindBuffer( _gl.ARRAY_BUFFER, attribute.buffer );
-					_gl.vertexAttribPointer( attributes[ a ], attribute.size, _gl.FLOAT, false, 0, 0 );
+					if( attribute.buffer ) {
+						
+						_gl.bindBuffer( _gl.ARRAY_BUFFER, attribute.buffer );
+						_gl.vertexAttribPointer( attributes[ a ], attribute.size, _gl.FLOAT, false, 0, 0 );
+
+					}
 
 				}