1 | import { Light } from './Light.js';
|
2 | import { SpotLightShadow } from './SpotLightShadow.js';
|
3 | import { Object3D } from '../core/Object3D.js';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function SpotLight( color, intensity, distance, angle, penumbra, decay ) {
|
10 |
|
11 | Light.call( this, color, intensity );
|
12 |
|
13 | this.type = 'SpotLight';
|
14 |
|
15 | this.position.copy( Object3D.DefaultUp );
|
16 | this.updateMatrix();
|
17 |
|
18 | this.target = new Object3D();
|
19 |
|
20 | Object.defineProperty( this, 'power', {
|
21 | get: function () {
|
22 |
|
23 |
|
24 |
|
25 | return this.intensity * Math.PI;
|
26 |
|
27 | },
|
28 | set: function ( power ) {
|
29 |
|
30 |
|
31 |
|
32 | this.intensity = power / Math.PI;
|
33 |
|
34 | }
|
35 | } );
|
36 |
|
37 | this.distance = ( distance !== undefined ) ? distance : 0;
|
38 | this.angle = ( angle !== undefined ) ? angle : Math.PI / 3;
|
39 | this.penumbra = ( penumbra !== undefined ) ? penumbra : 0;
|
40 | this.decay = ( decay !== undefined ) ? decay : 1;
|
41 |
|
42 | this.shadow = new SpotLightShadow();
|
43 |
|
44 | }
|
45 |
|
46 | SpotLight.prototype = Object.assign( Object.create( Light.prototype ), {
|
47 |
|
48 | constructor: SpotLight,
|
49 |
|
50 | isSpotLight: true,
|
51 |
|
52 | copy: function ( source ) {
|
53 |
|
54 | Light.prototype.copy.call( this, source );
|
55 |
|
56 | this.distance = source.distance;
|
57 | this.angle = source.angle;
|
58 | this.penumbra = source.penumbra;
|
59 | this.decay = source.decay;
|
60 |
|
61 | this.target = source.target.clone();
|
62 |
|
63 | this.shadow = source.shadow.clone();
|
64 |
|
65 | return this;
|
66 |
|
67 | }
|
68 |
|
69 | } );
|
70 |
|
71 |
|
72 | export { SpotLight };
|