1 | import { LightShadow } from './LightShadow.js';
|
2 | import { _Math } from '../math/Math.js';
|
3 | import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function SpotLightShadow() {
|
10 |
|
11 | LightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );
|
12 |
|
13 | }
|
14 |
|
15 | SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {
|
16 |
|
17 | constructor: SpotLightShadow,
|
18 |
|
19 | isSpotLightShadow: true,
|
20 |
|
21 | update: function ( light ) {
|
22 |
|
23 | var camera = this.camera;
|
24 |
|
25 | var fov = _Math.RAD2DEG * 2 * light.angle;
|
26 | var aspect = this.mapSize.width / this.mapSize.height;
|
27 | var far = light.distance || camera.far;
|
28 |
|
29 | if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
|
30 |
|
31 | camera.fov = fov;
|
32 | camera.aspect = aspect;
|
33 | camera.far = far;
|
34 | camera.updateProjectionMatrix();
|
35 |
|
36 | }
|
37 |
|
38 | }
|
39 |
|
40 | } );
|
41 |
|
42 |
|
43 | export { SpotLightShadow };
|