|
@@ -1,9 +1,14 @@
|
|
|
import { LightShadow } from './LightShadow.js';
|
|
|
import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
|
|
|
+import { Matrix4 } from '../math/Matrix4.js';
|
|
|
import { Vector2 } from '../math/Vector2.js';
|
|
|
import { Vector3 } from '../math/Vector3.js';
|
|
|
import { Vector4 } from '../math/Vector4.js';
|
|
|
|
|
|
+const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
|
|
|
+const _lightPositionWorld = /*@__PURE__*/ new Vector3();
|
|
|
+const _lookTarget = /*@__PURE__*/ new Vector3();
|
|
|
+
|
|
|
class PointLightShadow extends LightShadow {
|
|
|
|
|
|
constructor() {
|
|
@@ -59,24 +64,21 @@ class PointLightShadow extends LightShadow {
|
|
|
updateMatrices( light, viewportIndex = 0 ) {
|
|
|
|
|
|
const camera = this.camera;
|
|
|
- const shadowMatrix = this.matrix;
|
|
|
- const lightPositionWorld = this._lightPositionWorld;
|
|
|
- const lookTarget = this._lookTarget;
|
|
|
- const projScreenMatrix = this._projScreenMatrix;
|
|
|
+ const shadowMatrix = this.matrix;
|
|
|
|
|
|
- lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
- camera.position.copy( lightPositionWorld );
|
|
|
+ _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
+ camera.position.copy( _lightPositionWorld );
|
|
|
|
|
|
- lookTarget.copy( camera.position );
|
|
|
- lookTarget.add( this._cubeDirections[ viewportIndex ] );
|
|
|
+ _lookTarget.copy( camera.position );
|
|
|
+ _lookTarget.add( this._cubeDirections[ viewportIndex ] );
|
|
|
camera.up.copy( this._cubeUps[ viewportIndex ] );
|
|
|
- camera.lookAt( lookTarget );
|
|
|
+ camera.lookAt( _lookTarget );
|
|
|
camera.updateMatrixWorld();
|
|
|
|
|
|
- shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z );
|
|
|
+ shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );
|
|
|
|
|
|
- projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
|
- this._frustum.setFromProjectionMatrix( projScreenMatrix );
|
|
|
+ _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
|
|
|
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix );
|
|
|
|
|
|
}
|
|
|
|