Skip to content

Commit b9dd2b6

Browse files
committed
PointLightShadow: Convert to ES6 class
1 parent bb5cfde commit b9dd2b6

File tree

1 file changed

+57
-60
lines changed

1 file changed

+57
-60
lines changed

src/lights/PointLightShadow.js

Lines changed: 57 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,65 @@ import { Vector2 } from '../math/Vector2.js';
44
import { Vector3 } from '../math/Vector3.js';
55
import { Vector4 } from '../math/Vector4.js';
66

7-
function PointLightShadow() {
8-
9-
LightShadow.call( this, new PerspectiveCamera( 90, 1, 0.5, 500 ) );
10-
11-
this._frameExtents = new Vector2( 4, 2 );
12-
13-
this._viewportCount = 6;
14-
15-
this._viewports = [
16-
// These viewports map a cube-map onto a 2D texture with the
17-
// following orientation:
18-
//
19-
// xzXZ
20-
// y Y
21-
//
22-
// X - Positive x direction
23-
// x - Negative x direction
24-
// Y - Positive y direction
25-
// y - Negative y direction
26-
// Z - Positive z direction
27-
// z - Negative z direction
28-
29-
// positive X
30-
new Vector4( 2, 1, 1, 1 ),
31-
// negative X
32-
new Vector4( 0, 1, 1, 1 ),
33-
// positive Z
34-
new Vector4( 3, 1, 1, 1 ),
35-
// negative Z
36-
new Vector4( 1, 1, 1, 1 ),
37-
// positive Y
38-
new Vector4( 3, 0, 1, 1 ),
39-
// negative Y
40-
new Vector4( 1, 0, 1, 1 )
41-
];
42-
43-
this._cubeDirections = [
44-
new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ),
45-
new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 )
46-
];
47-
48-
this._cubeUps = [
49-
new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ),
50-
new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, - 1 )
51-
];
7+
class PointLightShadow extends LightShadow {
8+
9+
constructor() {
10+
11+
super( new PerspectiveCamera( 90, 1, 0.5, 500 ) );
12+
13+
Object.defineProperty( this, 'isPointLightShadow', { value: true } );
14+
15+
this._frameExtents = new Vector2( 4, 2 );
16+
17+
this._viewportCount = 6;
18+
19+
this._viewports = [
20+
// These viewports map a cube-map onto a 2D texture with the
21+
// following orientation:
22+
//
23+
// xzXZ
24+
// y Y
25+
//
26+
// X - Positive x direction
27+
// x - Negative x direction
28+
// Y - Positive y direction
29+
// y - Negative y direction
30+
// Z - Positive z direction
31+
// z - Negative z direction
32+
33+
// positive X
34+
new Vector4( 2, 1, 1, 1 ),
35+
// negative X
36+
new Vector4( 0, 1, 1, 1 ),
37+
// positive Z
38+
new Vector4( 3, 1, 1, 1 ),
39+
// negative Z
40+
new Vector4( 1, 1, 1, 1 ),
41+
// positive Y
42+
new Vector4( 3, 0, 1, 1 ),
43+
// negative Y
44+
new Vector4( 1, 0, 1, 1 )
45+
];
46+
47+
this._cubeDirections = [
48+
new Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ),
49+
new Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 )
50+
];
51+
52+
this._cubeUps = [
53+
new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ),
54+
new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 0, - 1 )
55+
];
5256

53-
}
54-
55-
PointLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {
56-
57-
constructor: PointLightShadow,
58-
59-
isPointLightShadow: true,
57+
}
6058

61-
updateMatrices: function ( light, viewportIndex = 0 ) {
59+
updateMatrices( light, viewportIndex = 0 ) {
6260

63-
const camera = this.camera,
64-
shadowMatrix = this.matrix,
65-
lightPositionWorld = this._lightPositionWorld,
66-
lookTarget = this._lookTarget,
67-
projScreenMatrix = this._projScreenMatrix;
61+
const camera = this.camera;
62+
const shadowMatrix = this.matrix;
63+
const lightPositionWorld = this._lightPositionWorld;
64+
const lookTarget = this._lookTarget;
65+
const projScreenMatrix = this._projScreenMatrix;
6866

6967
lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
7068
camera.position.copy( lightPositionWorld );
@@ -82,7 +80,6 @@ PointLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype
8280

8381
}
8482

85-
} );
86-
83+
}
8784

8885
export { PointLightShadow };

0 commit comments

Comments
 (0)