UNPKG

891 BJavaScriptView Raw
1import { LightShadow } from './LightShadow.js';
2import { _Math } from '../math/Math.js';
3import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
4
5/**
6 * @author mrdoob / http://mrdoob.com/
7 */
8
9function SpotLightShadow() {
10
11 LightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );
12
13}
14
15SpotLightShadow.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
43export { SpotLightShadow };