Skip to content

Commit

Permalink
Use the frustum diagonal
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Feb 28, 2020
1 parent 6c687f4 commit d527e1b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions examples/jsm/csm/CSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default class CSM {
_bbox.getCenter( _center );
_center.z = _bbox.max.z + this.lightMargin;

let squaredBBWidth = _lightSpaceFrustum.vertices.far[ 0 ].distanceTo( _lightSpaceFrustum.vertices.far[ 2 ] );
let squaredBBWidth = _lightSpaceFrustum.vertices.far[ 0 ].distanceTo( _lightSpaceFrustum.vertices.near[ 2 ] );
if ( this.fade ) {

// expand the shadow extents by the fade margin if fade is enabled.
Expand All @@ -198,7 +198,6 @@ export default class CSM {
const texelSize = squaredBBWidth / this.shadowMapSize;
_center.x = Math.floor( _center.x / texelSize ) * texelSize;
_center.y = Math.floor( _center.y / texelSize ) * texelSize;
_center.z = Math.floor( _center.z / texelSize ) * texelSize;
_center.applyMatrix4( light.shadow.camera.matrixWorld );

light.shadow.camera.left = - squaredBBWidth / 2;
Expand Down

0 comments on commit d527e1b

Please sign in to comment.