import { LightShadow } from './LightShadow.js';
import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
import { Vector2 } from '../math/Vector2.js';
import { Vector3 } from '../math/Vector3.js';
import { Vector4 } from '../math/Vector4.js';

class PointLightShadow extends LightShadow {

	constructor() {

		super( new PerspectiveCamera( 90, 1, 0.5, 500 ) );

		Object.defineProperty( this, 'isPointLightShadow', { value: true } );

		this._frameExtents = new Vector2( 4, 2 );

		this._viewportCount = 6;

		this._viewports = [
			// These viewports map a cube-map onto a 2D texture with the
			// following orientation:
			//
			//  xzXZ
			//   y Y
			//
			// X - Positive x direction
			// x - Negative x direction
			// Y - Positive y direction
			// y - Negative y direction
			// Z - Positive z direction
			// z - Negative z direction

			// positive X
			new Vector4( 2, 1, 1, 1 ),
			// negative X
			new Vector4( 0, 1, 1, 1 ),
			// positive Z
			new Vector4( 3, 1, 1, 1 ),
			// negative Z
			new Vector4( 1, 1, 1, 1 ),
			// positive Y
			new Vector4( 3, 0, 1, 1 ),
			// negative Y
			new Vector4( 1, 0, 1, 1 )
		];

		this._cubeDirections = [
			new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ),
			new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 )
		];

		this._cubeUps = [
			new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ),
			new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ),	new Vector3( 0, 0, - 1 )
		];

	}

	updateMatrices( light, viewportIndex = 0 ) {

		const camera = this.camera;
		const	shadowMatrix = this.matrix;
		const	lightPositionWorld = this._lightPositionWorld;
		const	lookTarget = this._lookTarget;
		const	projScreenMatrix = this._projScreenMatrix;

		lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
		camera.position.copy( lightPositionWorld );

		lookTarget.copy( camera.position );
		lookTarget.add( this._cubeDirections[ viewportIndex ] );
		camera.up.copy( this._cubeUps[ viewportIndex ] );
		camera.lookAt( lookTarget );
		camera.updateMatrixWorld();

		shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z );

		projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
		this._frustum.setFromProjectionMatrix( projScreenMatrix );

	}

}

export { PointLightShadow };

@@ -106,24 +106,70 @@
 Camera.js';%0A
+import %7B Matrix4 %7D from '../math/Matrix4.js';%0A
 import %7B Vec
@@ -295,16 +295,178 @@
 4.js';%0A%0A
+const _projScreenMatrix = /*@__PURE__*/ new Matrix4();%0Aconst _lightPositionWorld = /*@__PURE__*/ new Vector3();%0Aconst _lookTarget = /*@__PURE__*/ new Vector3();%0A%0A
 class Po
@@ -1799,17 +1799,17 @@
 %0A%09%09const
-%09
+ 
 shadowMa
@@ -1832,156 +1832,12 @@
 ix;%0A
-%09%09const%09lightPositionWorld = this._lightPositionWorld;%0A%09%09const%09lookTarget = this._lookTarget;%0A%09%09const%09projScreenMatrix = this._projScreenMatrix;%0A
 %0A%09%09
+_
 ligh
@@ -1919,16 +1919,17 @@
 n.copy( 
+_
 lightPos
@@ -1945,16 +1945,17 @@
 d );%0A%0A%09%09
+_
 lookTarg
@@ -1984,16 +1984,17 @@
 on );%0A%09%09
+_
 lookTarg
@@ -2111,16 +2111,17 @@
 lookAt( 
+_
 lookTarg
@@ -2191,16 +2191,17 @@
 tion( - 
+_
 lightPos
@@ -2212,24 +2212,25 @@
 nWorld.x, - 
+_
 lightPositio
@@ -2241,16 +2241,17 @@
 ld.y, - 
+_
 lightPos
@@ -2269,16 +2269,17 @@
 z );%0A%0A%09%09
+_
 projScre
@@ -2400,16 +2400,17 @@
 Matrix( 
+_
 projScre

Use own private objects.