Browse Source

WebGLShadowMap: Added layers support.

Mr.doob 9 years ago
parent
commit
3460f25114
2 changed files with 7 additions and 7 deletions
  1. 1 1
      src/renderers/WebGLRenderer.js
  2. 6 6
      src/renderers/webgl/WebGLShadowMap.js

+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -1119,7 +1119,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		//
 		//
 
 
-		shadowMap.render( scene );
+		shadowMap.render( scene, camera );
 
 
 		//
 		//
 
 

+ 6 - 6
src/renderers/webgl/WebGLShadowMap.js

@@ -94,7 +94,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 	this.type = THREE.PCFShadowMap;
 	this.type = THREE.PCFShadowMap;
 	this.cullFace = THREE.CullFaceFront;
 	this.cullFace = THREE.CullFaceFront;
 
 
-	this.render = function ( scene ) {
+	this.render = function ( scene, camera ) {
 
 
 		var faceCount, isPointLight;
 		var faceCount, isPointLight;
 
 
@@ -246,7 +246,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 					_renderList.length = 0;
 					_renderList.length = 0;
 
 
-					projectObject( scene, shadowCamera );
+					projectObject( scene, camera, shadowCamera );
 
 
 					// render shadow map
 					// render shadow map
 					// render regular objects
 					// render regular objects
@@ -365,11 +365,11 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 	}
 	}
 
 
-	function projectObject( object, camera ) {
+	function projectObject( object, camera, shadowCamera ) {
 
 
 		if ( object.visible === false ) return;
 		if ( object.visible === false ) return;
 
 
-		if ( object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Points ) {
+		if ( object.layers.test( camera.layers ) && ( object instanceof THREE.Mesh || object instanceof THREE.Line || object instanceof THREE.Points ) ) {
 
 
 			if ( object.castShadow && ( object.frustumCulled === false || _frustum.intersectsObject( object ) === true ) ) {
 			if ( object.castShadow && ( object.frustumCulled === false || _frustum.intersectsObject( object ) === true ) ) {
 
 
@@ -377,7 +377,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 				if ( material.visible === true ) {
 				if ( material.visible === true ) {
 
 
-					object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
+					object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );
 					_renderList.push( object );
 					_renderList.push( object );
 
 
 				}
 				}
@@ -390,7 +390,7 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
 
 
 		for ( var i = 0, l = children.length; i < l; i ++ ) {
 		for ( var i = 0, l = children.length; i < l; i ++ ) {
 
 
-			projectObject( children[ i ], camera );
+			projectObject( children[ i ], camera, shadowCamera );
 
 
 		}
 		}