Browse Source

Merge remote branch 'empaempa/master'

Mr.doob 14 years ago
parent
commit
d4d9e1f956
1 changed files with 20 additions and 12 deletions
  1. 20 12
      src/renderers/WebGLRenderer.js

+ 20 - 12
src/renderers/WebGLRenderer.js

@@ -2244,8 +2244,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		var attributes = material.program.attributes;
 		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.color >= 0 ) _gl.enableVertexAttribArray( attributes.color );
 		if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal );
 		if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal );
 		if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent );
 		if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent );
@@ -2261,13 +2260,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 ) {
 		if ( material.morphTargets ) {
 
 
 			material.numSupportedMorphTargets = 0;
 			material.numSupportedMorphTargets = 0;
@@ -2536,12 +2540,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			for( a in material.attributes ) {
 			for( a in material.attributes ) {
 
 
-				if( attributes[ a ] >= 0 ) {
+				if( attributes[ a ] !== undefined && attributes[ a ] >= 0 ) {
 
 
 					attribute = material.attributes[ a ];
 					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 );
+
+					}
 
 
 				}
 				}
 
 
@@ -3376,7 +3384,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		// draw darkening polygon
 		// draw darkening polygon
 
 
-		_oldBlending = "";
+		_oldBlending = -1;
 		_currentProgram = _stencilShadow.program;
 		_currentProgram = _stencilShadow.program;
 
 
 		_gl.useProgram( _stencilShadow.program );
 		_gl.useProgram( _stencilShadow.program );
@@ -3425,7 +3433,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		_gl.useProgram( _sprite.program );
 		_gl.useProgram( _sprite.program );
 		_currentProgram = _sprite.program;
 		_currentProgram = _sprite.program;
-		_oldBlending = "";
+		_oldBlending = -1;
 
 
 		if ( !_spriteAttributesEnabled ) {
 		if ( !_spriteAttributesEnabled ) {
 
 
@@ -3589,7 +3597,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		_gl.useProgram( _lensFlare.program );
 		_gl.useProgram( _lensFlare.program );
 		_currentProgram = _lensFlare.program;
 		_currentProgram = _lensFlare.program;
-		_oldBlending = "";
+		_oldBlending = -1;
 
 
 
 
 		if ( ! _lensFlareAttributesEnabled ) {
 		if ( ! _lensFlareAttributesEnabled ) {