1 | import { Light } from './Light.js';
|
2 | import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
|
3 | import { LightShadow } from './LightShadow.js';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function PointLight( color, intensity, distance, decay ) {
|
11 |
|
12 | Light.call( this, color, intensity );
|
13 |
|
14 | this.type = 'PointLight';
|
15 |
|
16 | Object.defineProperty( this, 'power', {
|
17 | get: function () {
|
18 |
|
19 |
|
20 |
|
21 | return this.intensity * 4 * Math.PI;
|
22 |
|
23 | },
|
24 | set: function ( power ) {
|
25 |
|
26 |
|
27 |
|
28 | this.intensity = power / ( 4 * Math.PI );
|
29 |
|
30 | }
|
31 | } );
|
32 |
|
33 | this.distance = ( distance !== undefined ) ? distance : 0;
|
34 | this.decay = ( decay !== undefined ) ? decay : 1;
|
35 |
|
36 | this.shadow = new LightShadow( new PerspectiveCamera( 90, 1, 0.5, 500 ) );
|
37 |
|
38 | }
|
39 |
|
40 | PointLight.prototype = Object.assign( Object.create( Light.prototype ), {
|
41 |
|
42 | constructor: PointLight,
|
43 |
|
44 | isPointLight: true,
|
45 |
|
46 | copy: function ( source ) {
|
47 |
|
48 | Light.prototype.copy.call( this, source );
|
49 |
|
50 | this.distance = source.distance;
|
51 | this.decay = source.decay;
|
52 |
|
53 | this.shadow = source.shadow.clone();
|
54 |
|
55 | return this;
|
56 |
|
57 | }
|
58 |
|
59 | } );
|
60 |
|
61 |
|
62 | export { PointLight };
|