Browse Source

WebGLRenderer: Simplified refreshUniformsShadow().

Mr.doob 9 years ago
parent
commit
ef2a85cf04
1 changed files with 18 additions and 26 deletions
  1. 18 26
      src/renderers/WebGLRenderer.js

+ 18 - 26
src/renderers/WebGLRenderer.js

@@ -864,7 +864,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 				}
 				}
 
 
 			}
 			}
-			
+
 
 
 		} else if ( object instanceof THREE.Line ) {
 		} else if ( object instanceof THREE.Line ) {
 
 
@@ -889,7 +889,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			renderer.setMode( _gl.POINTS );
 			renderer.setMode( _gl.POINTS );
 
 
 		}
 		}
-		
+
 		if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
 		if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
 
 
 			renderer.renderInstances( geometry, drawStart, drawCount );
 			renderer.renderInstances( geometry, drawStart, drawCount );
@@ -2123,42 +2123,34 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		if ( uniforms.shadowMatrix ) {
 		if ( uniforms.shadowMatrix ) {
 
 
-			var j = 0;
 			var shadows = _lights.shadows;
 			var shadows = _lights.shadows;
 
 
-			for ( var i = 0, il = shadows.length; i < il; i ++ ) {
+			for ( var i = 0, l = shadows.length; i < l; i ++ ) {
 
 
 				var light = shadows[ i ];
 				var light = shadows[ i ];
+				var shadow = light.shadow;
 
 
-				if ( light instanceof THREE.PointLight || light instanceof THREE.SpotLight || light instanceof THREE.DirectionalLight ) {
-
-					var shadow = light.shadow;
+				if ( light instanceof THREE.PointLight ) {
 
 
-					if ( light instanceof THREE.PointLight ) {
+					// for point lights we set the shadow matrix to be a translation-only matrix
+					// equal to inverse of the light's position
+					_vector3.setFromMatrixPosition( light.matrixWorld ).negate();
+					shadow.matrix.identity().setPosition( _vector3 );
 
 
-						// for point lights we set the shadow matrix to be a translation-only matrix
-						// equal to inverse of the light's position
-						_vector3.setFromMatrixPosition( light.matrixWorld ).negate();
-						shadow.matrix.identity().setPosition( _vector3 );
-
-						// for point lights we set the sign of the shadowDarkness uniform to be negative
-						uniforms.shadowDarkness.value[ j ] = - shadow.darkness;
-
-					} else {
+					// for point lights we set the sign of the shadowDarkness uniform to be negative
+					uniforms.shadowDarkness.value[ i ] = - shadow.darkness;
 
 
-						uniforms.shadowDarkness.value[ j ] = shadow.darkness;
-
-					}
-
-					uniforms.shadowMatrix.value[ j ] = shadow.matrix;
-					uniforms.shadowMap.value[ j ] = shadow.map;
-					uniforms.shadowMapSize.value[ j ] = shadow.mapSize;
-					uniforms.shadowBias.value[ j ] = shadow.bias;
+				} else {
 
 
-					j ++;
+					uniforms.shadowDarkness.value[ i ] = shadow.darkness;
 
 
 				}
 				}
 
 
+				uniforms.shadowBias.value[ i ] = shadow.bias;
+				uniforms.shadowMap.value[ i ] = shadow.map;
+				uniforms.shadowMapSize.value[ i ] = shadow.mapSize;
+				uniforms.shadowMatrix.value[ i ] = shadow.matrix;
+
 			}
 			}
 
 
 		}
 		}