Bladeren bron

Remove need to pass camera matrix world to update

Garrett Johnson 5 jaren geleden
bovenliggende
commit
3beb92a363
2 gewijzigde bestanden met toevoegingen van 4 en 4 verwijderingen
  1. 3 3
      examples/jsm/csm/CSM.js
  2. 1 1
      examples/webgl_shadowmap_csm.html

+ 3 - 3
examples/jsm/csm/CSM.js

@@ -23,7 +23,6 @@ const _cameraToLightMatrix = new Matrix4();
 const _lightSpaceFrustum = new Frustum();
 const _frustum = new Frustum();
 const _center = new Vector3();
-const _size = new Vector3();
 const _bbox = new Box3();
 const _uniformArray = [];
 const _logArray = [];
@@ -207,8 +206,9 @@ export default class CSM {
 
 	}
 
-	update( cameraMatrix ) {
+	update() {
 
+		const camera = this.camera;
 		const frustums = this.frustums;
 		for ( let i = 0; i < frustums.length; i ++ ) {
 
@@ -217,7 +217,7 @@ export default class CSM {
 			const texelWidth = ( shadowCam.right - shadowCam.left ) / this.shadowMapSize;
 			const texelHeight = ( shadowCam.top - shadowCam.bottom ) / this.shadowMapSize;
 			light.shadow.camera.updateMatrixWorld( true );
-			_cameraToLightMatrix.multiplyMatrices( light.shadow.camera.matrixWorldInverse, cameraMatrix );
+			_cameraToLightMatrix.multiplyMatrices( light.shadow.camera.matrixWorldInverse, camera.matrixWorld );
 			frustums[ i ].toSpace( _cameraToLightMatrix, _lightSpaceFrustum );
 
 			const nearVerts = _lightSpaceFrustum.vertices.near;

+ 1 - 1
examples/webgl_shadowmap_csm.html

@@ -224,7 +224,7 @@
 				requestAnimationFrame( animate );
 
 				camera.updateMatrixWorld();
-				csm.update( camera.matrixWorld );
+				csm.update();
 				controls.update();
 
 				if ( params.orthographic ) {