Procházet zdrojové kódy

Use the frustum diagonal

Garrett Johnson před 5 roky
rodič
revize
d527e1b7e4
1 změnil soubory, kde provedl 1 přidání a 2 odebrání
  1. 1 2
      examples/jsm/csm/CSM.js

+ 1 - 2
examples/jsm/csm/CSM.js

@@ -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.
@@ -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;