PageSourceSearch

https://planetazip.ru/wp-content/plugins/3d-scene-viewer/assets/js/3js/src/lights/Light.js

js planetazip.ru collected 2026-10-07 09:35:30 UTC 1,991 bytes, 95 lines download raw bytes

vendor: 1,991 bytes, lines 1-95
1import { Object3D } from '../core/Object3D.js';
2import { Color } from '../math/Color.js';
3
4/**
5 * Abstract base class for lights - all other light types inherit the
6 * properties and methods described here.
7 *
8 * @abstract
9 * @augments Object3D
10 */
11class Light extends Object3D {
12
13	/**
14	 * Constructs a new light.
15	 *
16	 * @param {(number|Color|string)} [color=0xffffff] - The light's color.
17	 * @param {number} [intensity=1] - The light's strength/intensity.
18	 */
19	constructor( color, intensity = 1 ) {
20
21		super();
22
23		/**
24		 * This flag can be used for type testing.
25		 *
26		 * @type {boolean}
27		 * @readonly
28		 * @default true
29		 */
30		this.isLight = true;
31
32		this.type = 'Light';
33
34		/**
35		 * The light's color.
36		 *
37		 * @type {Color}
38		 */
39		this.color = new Color( color );
40
41		/**
42		 * The light's intensity.
43		 *
44		 * @type {number}
45		 * @default 1
46		 */
47		this.intensity = intensity;
48
49	}
50
51	/**
52	 * Frees the GPU-related resources allocated by this instance. Call this
53	 * method whenever this instance is no longer used in your app.
54	 */
55	dispose() {
56
57		// Empty here in base class; some subclasses override.
58
59	}
60
61	copy( source, recursive ) {
62
63		super.copy( source, recursive );
64
65		this.color.copy( source.color );
66		this.intensity = source.intensity;
67
68		return this;
69
70	}
71
72	toJSON( meta ) {
73
74		const data = super.toJSON( meta );
75
76		data.object.color = this.color.getHex();
77		data.object.intensity = this.intensity;
78
79		if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
80
81		if ( this.distance !== undefined ) data.object.distance = this.distance;
82		if ( this.angle !== undefined ) data.object.angle = this.angle;
83		if ( this.decay !== undefined ) data.object.decay = this.decay;
84		if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
85
86		if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
87		if ( this.target !== undefined ) data.object.target = this.target.uuid;
88
89		return data;
90
91	}
92
93}
94
95export { Light };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.