1 | import { Object3D } from '../core/Object3D.js';
|
2 | import { Color } from '../math/Color.js';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function Light( color, intensity ) {
|
10 |
|
11 | Object3D.call( this );
|
12 |
|
13 | this.type = 'Light';
|
14 |
|
15 | this.color = new Color( color );
|
16 | this.intensity = intensity !== undefined ? intensity : 1;
|
17 |
|
18 | this.receiveShadow = undefined;
|
19 |
|
20 | }
|
21 |
|
22 | Light.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
23 |
|
24 | constructor: Light,
|
25 |
|
26 | isLight: true,
|
27 |
|
28 | copy: function ( source ) {
|
29 |
|
30 | Object3D.prototype.copy.call( this, source );
|
31 |
|
32 | this.color.copy( source.color );
|
33 | this.intensity = source.intensity;
|
34 |
|
35 | return this;
|
36 |
|
37 | },
|
38 |
|
39 | toJSON: function ( meta ) {
|
40 |
|
41 | var data = Object3D.prototype.toJSON.call( this, meta );
|
42 |
|
43 | data.object.color = this.color.getHex();
|
44 | data.object.intensity = this.intensity;
|
45 |
|
46 | if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
|
47 |
|
48 | if ( this.distance !== undefined ) data.object.distance = this.distance;
|
49 | if ( this.angle !== undefined ) data.object.angle = this.angle;
|
50 | if ( this.decay !== undefined ) data.object.decay = this.decay;
|
51 | if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
|
52 |
|
53 | if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
|
54 |
|
55 | return data;
|
56 |
|
57 | }
|
58 |
|
59 | } );
|
60 |
|
61 |
|
62 | export { Light };
|