|
@@ -8,40 +8,39 @@ function PointLightShadow() {
|
|
|
|
|
|
LightShadow.call( this, new PerspectiveCamera( 90, 1, 0.5, 500 ) );
|
|
LightShadow.call( this, new PerspectiveCamera( 90, 1, 0.5, 500 ) );
|
|
|
|
|
|
|
|
+ this._frameExtents = new Vector2( 4, 2 );
|
|
|
|
+
|
|
|
|
+ this._viewportCount = 6;
|
|
|
|
+
|
|
|
|
+ this._viewports = [
|
|
|
|
+ // These viewports map a cube-map onto a 2D texture with the
|
|
|
|
+ // following orientation:
|
|
|
|
+ //
|
|
|
|
+ // xzXZ
|
|
|
|
+ // y Y
|
|
|
|
+ //
|
|
|
|
+ // X - Positive x direction
|
|
|
|
+ // x - Negative x direction
|
|
|
|
+ // Y - Positive y direction
|
|
|
|
+ // y - Negative y direction
|
|
|
|
+ // Z - Positive z direction
|
|
|
|
+ // z - Negative z direction
|
|
|
|
+
|
|
|
|
+ // positive X
|
|
|
|
+ new Vector4( 2, 1, 1, 1 ),
|
|
|
|
+ // negative X
|
|
|
|
+ new Vector4( 0, 1, 1, 1 ),
|
|
|
|
+ // positive Z
|
|
|
|
+ new Vector4( 3, 1, 1, 1 ),
|
|
|
|
+ // negative Z
|
|
|
|
+ new Vector4( 1, 1, 1, 1 ),
|
|
|
|
+ // positive Y
|
|
|
|
+ new Vector4( 3, 0, 1, 1 ),
|
|
|
|
+ // negative Y
|
|
|
|
+ new Vector4( 1, 0, 1, 1 )
|
|
|
|
+ ];
|
|
|
|
|
|
- this._frameExtents = new Vector2( 4, 2 );
|
|
|
|
-
|
|
|
|
- this._viewportCount = 6;
|
|
|
|
-
|
|
|
|
- this._viewports = [
|
|
|
|
- // These viewports map a cube-map onto a 2D texture with the
|
|
|
|
- // following orientation:
|
|
|
|
- //
|
|
|
|
- // xzXZ
|
|
|
|
- // y Y
|
|
|
|
- //
|
|
|
|
- // X - Positive x direction
|
|
|
|
- // x - Negative x direction
|
|
|
|
- // Y - Positive y direction
|
|
|
|
- // y - Negative y direction
|
|
|
|
- // Z - Positive z direction
|
|
|
|
- // z - Negative z direction
|
|
|
|
-
|
|
|
|
- // positive X
|
|
|
|
- new Vector4( 2, 1, 1, 1 ),
|
|
|
|
- // negative X
|
|
|
|
- new Vector4( 0, 1, 1, 1 ),
|
|
|
|
- // positive Z
|
|
|
|
- new Vector4( 3, 1, 1, 1 ),
|
|
|
|
- // negative Z
|
|
|
|
- new Vector4( 1, 1, 1, 1 ),
|
|
|
|
- // positive Y
|
|
|
|
- new Vector4( 3, 0, 1, 1 ),
|
|
|
|
- // negative Y
|
|
|
|
- new Vector4( 1, 0, 1, 1 )
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- this._cubeDirections = [
|
|
|
|
|
|
+ this._cubeDirections = [
|
|
new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ),
|
|
new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ),
|
|
new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 )
|
|
new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 )
|
|
];
|
|
];
|
|
@@ -59,30 +58,30 @@ PointLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype
|
|
|
|
|
|
isPointLightShadow: true,
|
|
isPointLightShadow: true,
|
|
|
|
|
|
- updateMatrices: function ( light, viewCamera, viewportIndex ) {
|
|
|
|
|
|
+ updateMatrices: function ( light, viewCamera, viewportIndex ) {
|
|
|
|
|
|
- var camera = this.camera,
|
|
|
|
- shadowMatrix = this.matrix,
|
|
|
|
- lightPositionWorld = this._lightPositionWorld,
|
|
|
|
- lookTarget = this._lookTarget,
|
|
|
|
- shadowMatrix = this.matrix,
|
|
|
|
- projScreenMatrix = this._projScreenMatrix;
|
|
|
|
|
|
+ var camera = this.camera,
|
|
|
|
+ shadowMatrix = this.matrix,
|
|
|
|
+ lightPositionWorld = this._lightPositionWorld,
|
|
|
|
+ lookTarget = this._lookTarget,
|
|
|
|
+ shadowMatrix = this.matrix,
|
|
|
|
+ projScreenMatrix = this._projScreenMatrix;
|
|
|
|
|
|
- lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
|
|
|
+ lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
camera.position.copy( lightPositionWorld );
|
|
camera.position.copy( lightPositionWorld );
|
|
|
|
|
|
- lookTarget.copy( camera.position );
|
|
|
|
|
|
+ lookTarget.copy( camera.position );
|
|
lookTarget.add( this._cubeDirections[ viewportIndex ] );
|
|
lookTarget.add( this._cubeDirections[ viewportIndex ] );
|
|
camera.up.copy( this._cubeUps[ viewportIndex ] );
|
|
camera.up.copy( this._cubeUps[ viewportIndex ] );
|
|
camera.lookAt( lookTarget );
|
|
camera.lookAt( lookTarget );
|
|
camera.updateMatrixWorld();
|
|
camera.updateMatrixWorld();
|
|
|
|
|
|
- shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z );
|
|
|
|
|
|
+ shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z );
|
|
|
|
|
|
- projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
|
|
|
|
+ projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
this._frustum.setFromMatrix( projScreenMatrix );
|
|
this._frustum.setFromMatrix( projScreenMatrix );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|