|
@@ -4,73 +4,68 @@ import { Vector3 } from '../math/Vector3.js';
|
|
|
import { Vector4 } from '../math/Vector4.js';
|
|
|
import { Frustum } from '../math/Frustum.js';
|
|
|
|
|
|
-function LightShadow( camera ) {
|
|
|
+const _projScreenMatrix = /*@__PURE__*/ new Matrix4();
|
|
|
+const _lightPositionWorld = /*@__PURE__*/ new Vector3();
|
|
|
+const _lookTarget = /*@__PURE__*/ new Vector3();
|
|
|
|
|
|
- this.camera = camera;
|
|
|
+class LightShadow {
|
|
|
|
|
|
- this.bias = 0;
|
|
|
- this.normalBias = 0;
|
|
|
- this.radius = 1;
|
|
|
+ constructor( camera ) {
|
|
|
|
|
|
- this.mapSize = new Vector2( 512, 512 );
|
|
|
+ this.camera = camera;
|
|
|
|
|
|
- this.map = null;
|
|
|
- this.mapPass = null;
|
|
|
- this.matrix = new Matrix4();
|
|
|
+ this.bias = 0;
|
|
|
+ this.normalBias = 0;
|
|
|
+ this.radius = 1;
|
|
|
|
|
|
- this.autoUpdate = true;
|
|
|
- this.needsUpdate = false;
|
|
|
+ this.mapSize = new Vector2( 512, 512 );
|
|
|
|
|
|
- this._frustum = new Frustum();
|
|
|
- this._frameExtents = new Vector2( 1, 1 );
|
|
|
+ this.map = null;
|
|
|
+ this.mapPass = null;
|
|
|
+ this.matrix = new Matrix4();
|
|
|
|
|
|
- this._viewportCount = 1;
|
|
|
+ this.autoUpdate = true;
|
|
|
+ this.needsUpdate = false;
|
|
|
|
|
|
- this._viewports = [
|
|
|
+ this._frustum = new Frustum();
|
|
|
+ this._frameExtents = new Vector2( 1, 1 );
|
|
|
|
|
|
- new Vector4( 0, 0, 1, 1 )
|
|
|
+ this._viewportCount = 1;
|
|
|
|
|
|
- ];
|
|
|
+ this._viewports = [
|
|
|
|
|
|
-}
|
|
|
-
|
|
|
-Object.assign( LightShadow.prototype, {
|
|
|
+ new Vector4( 0, 0, 1, 1 )
|
|
|
|
|
|
- _projScreenMatrix: new Matrix4(),
|
|
|
+ ];
|
|
|
|
|
|
- _lightPositionWorld: new Vector3(),
|
|
|
-
|
|
|
- _lookTarget: new Vector3(),
|
|
|
+ }
|
|
|
|
|
|
- getViewportCount: function () {
|
|
|
+ getViewportCount() {
|
|
|
|
|
|
return this._viewportCount;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- getFrustum: function () {
|
|
|
+ getFrustum() {
|
|
|
|
|
|
return this._frustum;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- updateMatrices: function ( light ) {
|
|
|
+ updateMatrices( light ) {
|
|
|
|
|
|
- const shadowCamera = this.camera,
|
|
|
- shadowMatrix = this.matrix,
|
|
|
- projScreenMatrix = this._projScreenMatrix,
|
|
|
- lookTarget = this._lookTarget,
|
|
|
- lightPositionWorld = this._lightPositionWorld;
|
|
|
+ const shadowCamera = this.camera;
|
|
|
+ const shadowMatrix = this.matrix;
|
|
|
|
|
|
- lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
- shadowCamera.position.copy( lightPositionWorld );
|
|
|
+ _lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
|
+ shadowCamera.position.copy( _lightPositionWorld );
|
|
|
|
|
|
- lookTarget.setFromMatrixPosition( light.target.matrixWorld );
|
|
|
- shadowCamera.lookAt( lookTarget );
|
|
|
+ _lookTarget.setFromMatrixPosition( light.target.matrixWorld );
|
|
|
+ shadowCamera.lookAt( _lookTarget );
|
|
|
shadowCamera.updateMatrixWorld();
|
|
|
|
|
|
- projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
|
|
|
- this._frustum.setFromProjectionMatrix( projScreenMatrix );
|
|
|
+ _projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
|
|
|
+ this._frustum.setFromProjectionMatrix( _projScreenMatrix );
|
|
|
|
|
|
shadowMatrix.set(
|
|
|
0.5, 0.0, 0.0, 0.5,
|
|
@@ -82,21 +77,21 @@ Object.assign( LightShadow.prototype, {
|
|
|
shadowMatrix.multiply( shadowCamera.projectionMatrix );
|
|
|
shadowMatrix.multiply( shadowCamera.matrixWorldInverse );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- getViewport: function ( viewportIndex ) {
|
|
|
+ getViewport( viewportIndex ) {
|
|
|
|
|
|
return this._viewports[ viewportIndex ];
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- getFrameExtents: function () {
|
|
|
+ getFrameExtents() {
|
|
|
|
|
|
return this._frameExtents;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- copy: function ( source ) {
|
|
|
+ copy( source ) {
|
|
|
|
|
|
this.camera = source.camera.clone();
|
|
|
|
|
@@ -107,15 +102,15 @@ Object.assign( LightShadow.prototype, {
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clone: function () {
|
|
|
+ clone() {
|
|
|
|
|
|
return new this.constructor().copy( this );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- toJSON: function () {
|
|
|
+ toJSON() {
|
|
|
|
|
|
const object = {};
|
|
|
|
|
@@ -131,7 +126,6 @@ Object.assign( LightShadow.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
-} );
|
|
|
-
|
|
|
+}
|
|
|
|
|
|
export { LightShadow };
|