|
@@ -137,6 +137,9 @@ function WebGLShadowMap( _renderer, _lights, _objects, capabilities ) {
|
|
|
var shadowCamera = shadow.camera;
|
|
|
var shadowMatrix = shadow.matrix;
|
|
|
|
|
|
+ _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
+ shadowCamera.position.copy( _lightPositionWorld );
|
|
|
+
|
|
|
_shadowMapSize.copy( shadow.mapSize );
|
|
|
_shadowMapSize.min( _maxShadowMapSize );
|
|
|
|
|
@@ -181,14 +184,17 @@ function WebGLShadowMap( _renderer, _lights, _objects, capabilities ) {
|
|
|
// for point lights we set the shadow matrix to be a translation-only matrix
|
|
|
// equal to inverse of the light's position
|
|
|
|
|
|
- var elements = light.matrixWorld.elements;
|
|
|
- shadowMatrix.makeTranslation( - elements[ 12 ], - elements[ 13 ], - elements[ 14 ] );
|
|
|
+ shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
faceCount = 1;
|
|
|
isPointLight = false;
|
|
|
|
|
|
+ _lookTarget.setFromMatrixPosition( light.target.matrixWorld );
|
|
|
+ shadowCamera.lookAt( _lookTarget );
|
|
|
+ shadowCamera.updateMatrixWorld();
|
|
|
+ shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
|
|
|
|
|
|
// compute shadow matrix
|
|
|
|
|
@@ -223,9 +229,6 @@ function WebGLShadowMap( _renderer, _lights, _objects, capabilities ) {
|
|
|
|
|
|
var shadowMap = shadow.map;
|
|
|
|
|
|
- _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
- shadowCamera.position.copy( _lightPositionWorld );
|
|
|
-
|
|
|
_renderer.setRenderTarget( shadowMap );
|
|
|
_renderer.clear();
|
|
|
|
|
@@ -240,20 +243,14 @@ function WebGLShadowMap( _renderer, _lights, _objects, capabilities ) {
|
|
|
_lookTarget.add( cubeDirections[ face ] );
|
|
|
shadowCamera.up.copy( cubeUps[ face ] );
|
|
|
shadowCamera.lookAt( _lookTarget );
|
|
|
+ shadowCamera.updateMatrixWorld();
|
|
|
+ shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
|
|
|
|
|
|
var vpDimensions = cube2DViewPorts[ face ];
|
|
|
_state.viewport( vpDimensions );
|
|
|
|
|
|
- } else {
|
|
|
-
|
|
|
- _lookTarget.setFromMatrixPosition( light.target.matrixWorld );
|
|
|
- shadowCamera.lookAt( _lookTarget );
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- shadowCamera.updateMatrixWorld();
|
|
|
- shadowCamera.matrixWorldInverse.getInverse( shadowCamera.matrixWorld );
|
|
|
-
|
|
|
// update camera matrices and frustum
|
|
|
|
|
|
_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
|