|
1 | 1 | import { LightShadow } from './LightShadow.js'; |
2 | 2 | import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; |
| 3 | +import { Matrix4 } from '../math/Matrix4.js'; |
3 | 4 | import { Vector2 } from '../math/Vector2.js'; |
4 | 5 | import { Vector3 } from '../math/Vector3.js'; |
5 | 6 | import { Vector4 } from '../math/Vector4.js'; |
6 | 7 |
|
| 8 | +const _projScreenMatrix = /*@__PURE__*/ new Matrix4(); |
| 9 | +const _lightPositionWorld = /*@__PURE__*/ new Vector3(); |
| 10 | +const _lookTarget = /*@__PURE__*/ new Vector3(); |
| 11 | + |
7 | 12 | class PointLightShadow extends LightShadow { |
8 | 13 |
|
9 | 14 | constructor() { |
@@ -59,24 +64,21 @@ class PointLightShadow extends LightShadow { |
59 | 64 | updateMatrices( light, viewportIndex = 0 ) { |
60 | 65 |
|
61 | 66 | const camera = this.camera; |
62 | | - const shadowMatrix = this.matrix; |
63 | | - const lightPositionWorld = this._lightPositionWorld; |
64 | | - const lookTarget = this._lookTarget; |
65 | | - const projScreenMatrix = this._projScreenMatrix; |
| 67 | + const shadowMatrix = this.matrix; |
66 | 68 |
|
67 | | - lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); |
68 | | - camera.position.copy( lightPositionWorld ); |
| 69 | + _lightPositionWorld.setFromMatrixPosition( light.matrixWorld ); |
| 70 | + camera.position.copy( _lightPositionWorld ); |
69 | 71 |
|
70 | | - lookTarget.copy( camera.position ); |
71 | | - lookTarget.add( this._cubeDirections[ viewportIndex ] ); |
| 72 | + _lookTarget.copy( camera.position ); |
| 73 | + _lookTarget.add( this._cubeDirections[ viewportIndex ] ); |
72 | 74 | camera.up.copy( this._cubeUps[ viewportIndex ] ); |
73 | | - camera.lookAt( lookTarget ); |
| 75 | + camera.lookAt( _lookTarget ); |
74 | 76 | camera.updateMatrixWorld(); |
75 | 77 |
|
76 | | - shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z ); |
| 78 | + shadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z ); |
77 | 79 |
|
78 | | - projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); |
79 | | - this._frustum.setFromProjectionMatrix( projScreenMatrix ); |
| 80 | + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); |
| 81 | + this._frustum.setFromProjectionMatrix( _projScreenMatrix ); |
80 | 82 |
|
81 | 83 | } |
82 | 84 |
|
|
0 commit comments