|
@@ -139,8 +139,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
pointShadowMatrix: [],
|
|
pointShadowMatrix: [],
|
|
hemi: [],
|
|
hemi: [],
|
|
|
|
|
|
- shadows: 0,
|
|
|
|
- shadowsPointLight: 0
|
|
|
|
|
|
+ shadows: []
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -303,7 +302,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
// shadow map
|
|
// shadow map
|
|
|
|
|
|
- var shadowMap = new THREE.WebGLShadowMap( this, lights, objects );
|
|
|
|
|
|
+ var shadowMap = new THREE.WebGLShadowMap( this, _lights, objects );
|
|
|
|
|
|
this.shadowMap = shadowMap;
|
|
this.shadowMap = shadowMap;
|
|
|
|
|
|
@@ -1160,6 +1159,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
//
|
|
//
|
|
|
|
|
|
|
|
+ setupShadows( lights );
|
|
|
|
+
|
|
shadowMap.render( scene, camera );
|
|
shadowMap.render( scene, camera );
|
|
|
|
|
|
setupLights( lights, camera );
|
|
setupLights( lights, camera );
|
|
@@ -1625,7 +1626,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ( materialProperties.lightsHash !== _lights.hash ) {
|
|
|
|
|
|
+ if ( materialProperties.lightsHash !== undefined &&
|
|
|
|
+ materialProperties.lightsHash !== _lights.hash ) {
|
|
|
|
|
|
material.needsUpdate = true;
|
|
material.needsUpdate = true;
|
|
|
|
|
|
@@ -2588,6 +2590,26 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function setupShadows ( lights ) {
|
|
|
|
+
|
|
|
|
+ var lightShadowsLength = 0;
|
|
|
|
+
|
|
|
|
+ for ( var i = 0, l = lights.length; i < l; i ++ ) {
|
|
|
|
+
|
|
|
|
+ var light = lights[ i ];
|
|
|
|
+
|
|
|
|
+ if ( light.castShadow ) {
|
|
|
|
+
|
|
|
|
+ _lights.shadows[ lightShadowsLength ++ ] = light;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _lights.shadows.length = lightShadowsLength;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
function setupLights ( lights, camera ) {
|
|
function setupLights ( lights, camera ) {
|
|
|
|
|
|
var l, ll, light,
|
|
var l, ll, light,
|
|
@@ -2603,9 +2625,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
spotLength = 0,
|
|
spotLength = 0,
|
|
hemiLength = 0;
|
|
hemiLength = 0;
|
|
|
|
|
|
- _lights.shadows = 0;
|
|
|
|
- _lights.shadowsPointLight = 0;
|
|
|
|
-
|
|
|
|
for ( l = 0, ll = lights.length; l < ll; l ++ ) {
|
|
for ( l = 0, ll = lights.length; l < ll; l ++ ) {
|
|
|
|
|
|
light = lights[ l ];
|
|
light = lights[ l ];
|
|
@@ -2638,8 +2657,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
uniforms.shadowRadius = light.shadow.radius;
|
|
uniforms.shadowRadius = light.shadow.radius;
|
|
uniforms.shadowMapSize = light.shadow.mapSize;
|
|
uniforms.shadowMapSize = light.shadow.mapSize;
|
|
|
|
|
|
- _lights.shadows ++;
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
_lights.directionalShadowMap[ directionalLength ] = light.shadow.map;
|
|
_lights.directionalShadowMap[ directionalLength ] = light.shadow.map;
|
|
@@ -2673,8 +2690,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
uniforms.shadowRadius = light.shadow.radius;
|
|
uniforms.shadowRadius = light.shadow.radius;
|
|
uniforms.shadowMapSize = light.shadow.mapSize;
|
|
uniforms.shadowMapSize = light.shadow.mapSize;
|
|
|
|
|
|
- _lights.shadows ++;
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
_lights.spotShadowMap[ spotLength ] = light.shadow.map;
|
|
_lights.spotShadowMap[ spotLength ] = light.shadow.map;
|
|
@@ -2700,8 +2715,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
uniforms.shadowRadius = light.shadow.radius;
|
|
uniforms.shadowRadius = light.shadow.radius;
|
|
uniforms.shadowMapSize = light.shadow.mapSize;
|
|
uniforms.shadowMapSize = light.shadow.mapSize;
|
|
|
|
|
|
- _lights.shadows ++;
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
_lights.pointShadowMap[ pointLength ] = light.shadow.map;
|
|
_lights.pointShadowMap[ pointLength ] = light.shadow.map;
|
|
@@ -2745,7 +2758,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
_lights.point.length = pointLength;
|
|
_lights.point.length = pointLength;
|
|
_lights.hemi.length = hemiLength;
|
|
_lights.hemi.length = hemiLength;
|
|
|
|
|
|
- _lights.hash = directionalLength + ',' + pointLength + ',' + spotLength + ',' + hemiLength + ',' + _lights.shadows;
|
|
|
|
|
|
+ _lights.hash = directionalLength + ',' + pointLength + ',' + spotLength + ',' + hemiLength + ',' + _lights.shadows.length;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|