File size: 1,119 Bytes
2b7aae2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Object3D } from '../core/Object3D.js';
import { Color } from '../math/Color.js';

class Light extends Object3D {
	constructor(color, intensity = 1) {
		super();

		this.type = 'Light';

		this.color = new Color(color);
		this.intensity = intensity;
	}

	dispose() {
		// Empty here in base class; some subclasses override.
	}

	copy(source) {
		super.copy(source);

		this.color.copy(source.color);
		this.intensity = source.intensity;

		return this;
	}

	toJSON(meta) {
		const data = super.toJSON(meta);

		data.object.color = this.color.getHex();
		data.object.intensity = this.intensity;

		if (this.groundColor !== undefined) data.object.groundColor = this.groundColor.getHex();

		if (this.distance !== undefined) data.object.distance = this.distance;
		if (this.angle !== undefined) data.object.angle = this.angle;
		if (this.decay !== undefined) data.object.decay = this.decay;
		if (this.penumbra !== undefined) data.object.penumbra = this.penumbra;

		if (this.shadow !== undefined) data.object.shadow = this.shadow.toJSON();

		return data;
	}
}

Light.prototype.isLight = true;

export { Light };