UNPKG

2.48 kBTypeScriptView Raw
1import { JSONMeta, Object3D, Object3DJSON } from "../core/Object3D.js";
2import { Color, ColorRepresentation } from "../math/Color.js";
3import { LightShadow, LightShadowJSON } from "./LightShadow.js";
4
5export interface LightJSON extends Object3DJSON {
6 color: number;
7 intensity: number;
8
9 groundColor?: number;
10
11 distance?: number;
12 angle?: number;
13 decay?: number;
14 penumbra?: number;
15
16 shadow?: LightShadowJSON;
17 target?: string;
18}
19
20/**
21 * Abstract base class for lights.
22 * @remarks All other light types inherit the properties and methods described here.
23 */
24export abstract class Light<TShadowSupport extends LightShadow | undefined = LightShadow | undefined> extends Object3D {
25 /**
26 * Creates a new {@link Light}
27 * @remarks
28 * **Note** that this is not intended to be called directly (use one of derived classes instead).
29 * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_.
30 * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1`.
31 */
32 constructor(color?: ColorRepresentation, intensity?: number);
33
34 /**
35 * Read-only flag to check if a given object is of type {@link HemisphereLight}.
36 * @remarks This is a _constant_ value
37 * @defaultValue `true`
38 */
39 readonly isLight: true;
40
41 /**
42 * A Read-only _string_ to check if `this` object type.
43 * @remarks Sub-classes will update this value.
44 * @defaultValue `Light`
45 */
46 override readonly type: string | "Light";
47
48 /**
49 * Color of the light. \
50 * @defaultValue `new THREE.Color(0xffffff)` _(white)_.
51 */
52 color: Color;
53
54 /**
55 * The light's intensity, or strength.
56 * The units of intensity depend on the type of light.
57 * @defaultValue `1`
58 */
59 intensity: number;
60
61 /**
62 * A {@link THREE.LightShadow | LightShadow} used to calculate shadows for this light.
63 * @remarks Available only on Light's that support shadows.
64 */
65 shadow: TShadowSupport;
66
67 /**
68 * Copies value of all the properties from the {@link Light | source} to this instance.
69 * @param source
70 * @param recursive
71 */
72 copy(source: this, recursive?: boolean): this;
73
74 /**
75 * Frees the GPU-related resources allocated by this instance
76 * @remarks
77 * Call this method whenever this instance is no longer used in your app.
78 */
79 dispose(): void;
80
81 toJSON(meta?: JSONMeta): LightJSON;
82}