UNPKG

4.53 kBTypeScriptView Raw
1import { ColorRepresentation } from "../math/Color.js";
2import { Light } from "./Light.js";
3import { PointLightShadow } from "./PointLightShadow.js";
4
5/**
6 * A light that gets emitted from a single point in all directions
7 * @remarks
8 * A common use case for this is to replicate the light emitted from a bare lightbulb.
9 * @example
10 * ```typescript
11 * const light = new THREE.PointLight(0xff0000, 1, 100);
12 * light.position.set(50, 50, 50);
13 * scene.add(light);
14 * ```
15 * @see Example: {@link https://threejs.org/examples/#webgl_lights_pointlights | lights / pointlights }
16 * @see Example: {@link https://threejs.org/examples/#webgl_effects_anaglyph | effects / anaglyph }
17 * @see Example: {@link https://threejs.org/examples/#webgl_geometry_text | geometry / text }
18 * @see Example: {@link https://threejs.org/examples/#webgl_lensflares | lensflares }
19 * @see {@link https://threejs.org/docs/index.html#api/en/lights/PointLight | Official Documentation}
20 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/PointLight.js | Source}
21 */
22export class PointLight extends Light<PointLightShadow> {
23 /**
24 * Creates a new PointLight.
25 * @param color Hexadecimal color of the light. Default is 0xffffff (white). Expects a `Integer`
26 * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1`
27 * @param distance Maximum range of the light. Default is 0 (no limit).
28 * @param decay The amount the light dims along the distance of the light. Expects a `Float`. Default `2`
29 */
30 constructor(color?: ColorRepresentation, intensity?: number, distance?: number, decay?: number);
31
32 /**
33 * Read-only flag to check if a given object is of type {@link PointLight}.
34 * @remarks This is a _constant_ value
35 * @defaultValue `true`
36 */
37 readonly isPointLight: true;
38
39 /**
40 * @default 'PointLight'
41 */
42 type: string;
43
44 /**
45 * The light's intensity.
46 *
47 * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — intensity is the luminous intensity of the light measured in candela (cd).
48 * @remarks Changing the intensity will also change the light's power.
49 * @remarks Expects a `Float`
50 * @defaultValue `1`
51 */
52 intensity: number;
53
54 /**
55 * When **Default mode** — When distance is zero, light does not attenuate. When distance is non-zero,
56 * light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light.
57 *
58 * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — When distance is zero,
59 * light will attenuate according to inverse-square law to infinite distance.
60 * When distance is non-zero, light will attenuate according to inverse-square law until near the distance cutoff,
61 * where it will then attenuate quickly and smoothly to 0. Inherently, cutoffs are not physically correct.
62 *
63 * @defaultValue `0.0`
64 * @remarks Expects a `Float`
65 */
66 distance: number;
67
68 /**
69 * If set to `true` light will cast dynamic shadows.
70 * **Warning**: This is expensive and requires tweaking to get shadows looking right.
71 * @see {@link THREE.PointLightShadow | PointLightShadow} for details.
72 * @defaultValue `false`
73 */
74 castShadow: boolean;
75
76 /**
77 * The amount the light dims along the distance of the light.
78 * In context of physically-correct rendering the default value should not be changed.
79 * @remarks Expects a `Float`
80 * @defaultValue `2`
81 */
82 decay: number;
83
84 /**
85 * A {@link THREE.PointLightShadow | PointLightShadow} used to calculate shadows for this light.
86 * The lightShadow's {@link LightShadow.camera | camera} is set to
87 * a {@link THREE.PerspectiveCamera | PerspectiveCamera} with {@link PerspectiveCamera.fov | fov} of 90,
88 * {@link PerspectiveCamera.aspect | aspect} of 1,
89 * {@link PerspectiveCamera.near | near} clipping plane at 0.5
90 * and {@link PerspectiveCamera.far | far} clipping plane at 500.
91 * @defaultValue new THREE.PointLightShadow()
92 */
93 shadow: PointLightShadow;
94
95 /**
96 * The light's power.
97 * When **{@link WebGLRenderer.useLegacyLights | legacy lighting mode} is disabled** — power is the luminous power of the light measured in lumens (lm).
98 * @remarks Changing the power will also change the light's intensity.
99 * @remarks Expects a `Float`
100 */
101 power: number;
102}