@types/three 0.150.1 → 0.151.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/controls/MapControls.d.ts +21 -0
  3. three/examples/jsm/controls/OrbitControls.d.ts +1 -5
  4. three/examples/jsm/controls/PointerLockControls.d.ts +3 -0
  5. three/examples/jsm/controls/TrackballControls.d.ts +2 -0
  6. three/examples/jsm/helpers/ViewHelper.d.ts +3 -4
  7. three/examples/jsm/loaders/GLTFLoader.d.ts +2 -4
  8. three/examples/jsm/loaders/SVGLoader.d.ts +15 -3
  9. three/examples/jsm/nodes/Nodes.d.ts +130 -226
  10. three/examples/jsm/nodes/{core → code}/CodeNode.d.ts +2 -3
  11. three/examples/jsm/nodes/{core → code}/ExpressionNode.d.ts +2 -2
  12. three/examples/jsm/nodes/{core → code}/FunctionCallNode.d.ts +2 -2
  13. three/examples/jsm/nodes/{core → code}/FunctionNode.d.ts +4 -4
  14. three/examples/jsm/nodes/core/InputNode.d.ts +4 -0
  15. three/examples/jsm/nodes/core/NodeBuilder.d.ts +1 -3
  16. three/examples/jsm/nodes/core/NodeUtils.d.ts +8 -2
  17. three/examples/jsm/nodes/core/{VaryNode.d.ts → VaryingNode.d.ts} +1 -1
  18. three/examples/jsm/nodes/fog/FogNode.d.ts +1 -1
  19. three/examples/jsm/nodes/geometry/RangeNode.d.ts +2 -1
  20. three/examples/jsm/nodes/lighting/PointLightNode.d.ts +10 -0
  21. three/examples/jsm/nodes/lighting/SpotLightNode.d.ts +15 -0
  22. three/examples/jsm/nodes/math/MathNode.d.ts +2 -2
  23. three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +2 -2
  24. three/examples/jsm/objects/{GroundProjectedEnv.d.ts → GroundProjectedSkybox.d.ts} +1 -1
  25. three/examples/jsm/postprocessing/Pass.d.ts +2 -0
  26. three/examples/jsm/renderers/CSS2DRenderer.d.ts +2 -1
  27. three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +0 -1
  28. three/examples/jsm/utils/BufferGeometryUtils.d.ts +12 -2
  29. three/index.d.ts +1 -1
  30. three/package.json +2 -2
  31. three/src/Three.d.ts +1 -1
  32. three/src/core/Raycaster.d.ts +1 -0
  33. three/src/extras/DataUtils.d.ts +13 -0
  34. three/src/extras/Earcut.d.ts +12 -0
  35. three/src/extras/ImageUtils.d.ts +20 -20
  36. three/src/extras/PMREMGenerator.d.ts +66 -0
  37. three/src/extras/ShapeUtils.d.ts +19 -1
  38. three/src/extras/core/Curve.d.ts +86 -31
  39. three/src/extras/core/CurvePath.d.ts +46 -4
  40. three/src/extras/core/Interpolations.d.ts +36 -0
  41. three/src/extras/core/Path.d.ts +122 -15
  42. three/src/extras/core/Shape.d.ts +56 -6
  43. three/src/extras/core/ShapePath.d.ts +73 -8
  44. three/src/extras/curves/ArcCurve.d.ts +35 -3
  45. three/src/extras/curves/CatmullRomCurve3.d.ts +62 -15
  46. three/src/extras/curves/CubicBezierCurve.d.ts +48 -7
  47. three/src/extras/curves/CubicBezierCurve3.d.ts +48 -7
  48. three/src/extras/curves/EllipseCurve.d.ts +73 -18
  49. three/src/extras/curves/LineCurve.d.ts +26 -5
  50. three/src/extras/curves/LineCurve3.d.ts +26 -5
  51. three/src/extras/curves/QuadraticBezierCurve.d.ts +44 -6
  52. three/src/extras/curves/QuadraticBezierCurve3.d.ts +44 -6
  53. three/src/extras/curves/SplineCurve.d.ts +39 -3
  54. three/src/helpers/ArrowHelper.d.ts +48 -17
  55. three/src/helpers/AxesHelper.d.ts +35 -3
  56. three/src/helpers/Box3Helper.d.ts +28 -4
  57. three/src/helpers/BoxHelper.d.ts +45 -5
  58. three/src/helpers/CameraHelper.d.ts +38 -19
  59. three/src/helpers/DirectionalLightHelper.d.ts +58 -11
  60. three/src/helpers/GridHelper.d.ts +33 -7
  61. three/src/helpers/HemisphereLightHelper.d.ts +57 -5
  62. three/src/helpers/PlaneHelper.d.ts +31 -8
  63. three/src/helpers/PointLightHelper.d.ts +55 -7
  64. three/src/helpers/PolarGridHelper.d.ts +36 -9
  65. three/src/helpers/SkeletonHelper.d.ts +56 -8
  66. three/src/helpers/SpotLightHelper.d.ts +60 -5
  67. three/src/lights/AmbientLight.d.ts +24 -11
  68. three/src/lights/AmbientLightProbe.d.ts +19 -1
  69. three/src/lights/DirectionalLight.d.ts +76 -21
  70. three/src/lights/DirectionalLightShadow.d.ts +68 -2
  71. three/src/lights/HemisphereLight.d.ts +46 -14
  72. three/src/lights/HemisphereLightProbe.d.ts +20 -1
  73. three/src/lights/Light.d.ts +40 -43
  74. three/src/lights/LightProbe.d.ts +32 -5
  75. three/src/lights/LightShadow.d.ts +100 -18
  76. three/src/lights/PointLight.d.ts +58 -13
  77. three/src/lights/PointLightShadow.d.ts +18 -2
  78. three/src/lights/RectAreaLight.d.ts +61 -9
  79. three/src/lights/SpotLight.d.ts +106 -22
  80. three/src/lights/SpotLightShadow.d.ts +63 -3
  81. three/src/materials/LineBasicMaterial.d.ts +7 -2
  82. three/src/materials/MeshBasicMaterial.d.ts +1 -2
  83. three/src/materials/MeshDistanceMaterial.d.ts +0 -15
  84. three/src/materials/MeshLambertMaterial.d.ts +1 -2
  85. three/src/materials/MeshMatcapMaterial.d.ts +1 -2
  86. three/src/materials/MeshPhongMaterial.d.ts +1 -2
  87. three/src/materials/MeshStandardMaterial.d.ts +1 -2
  88. three/src/materials/MeshToonMaterial.d.ts +1 -2
  89. three/src/materials/PointsMaterial.d.ts +1 -2
  90. three/src/materials/ShadowMaterial.d.ts +1 -2
  91. three/src/materials/SpriteMaterial.d.ts +1 -2
  92. three/src/math/Color.d.ts +25 -5
  93. three/src/math/Quaternion.d.ts +6 -0
  94. three/src/math/Triangle.d.ts +40 -0
  95. three/src/math/Vector2.d.ts +5 -0
  96. three/src/math/Vector3.d.ts +10 -3
  97. three/src/objects/InstancedMesh.d.ts +22 -30
  98. three/src/objects/LineSegments.d.ts +2 -0
  99. three/src/objects/Skeleton.d.ts +5 -1
  100. three/src/objects/SkinnedMesh.d.ts +37 -25
  101. three/src/renderers/WebGLRenderer.d.ts +17 -2
  102. three/src/renderers/shaders/ShaderChunk.d.ts +58 -37
  103. three/src/renderers/shaders/UniformsLib.d.ts +88 -57
  104. three/src/scenes/Fog.d.ts +1 -2
  105. three/src/scenes/FogExp2.d.ts +1 -2
  106. three/src/textures/Texture.d.ts +5 -22
  107. three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +0 -12
  108. three/src/utils.d.ts +0 -6
@@ -1,20 +1,47 @@
1
1
  import { SphericalHarmonics3 } from './../math/SphericalHarmonics3';
2
2
  import { Light } from './Light';
3
3
 
4
+ /**
5
+ * Light probes are an alternative way of adding light to a 3D scene.
6
+ * @remarks
7
+ * Unlike classical light sources (e.g
8
+ * directional, point or spot lights), light probes do not emit light
9
+ * Instead they store information about light passing through 3D space
10
+ * During rendering, the light that hits a 3D object is approximated by using the data from the light probe.
11
+ * Light probes are usually created from (radiance) environment maps
12
+ * The class {@link THREE.LightProbeGenerator | LightProbeGenerator} can be used to create light probes from
13
+ * instances of {@link THREE.CubeTexture | CubeTexture} or {@link THREE.WebGLCubeRenderTarget | WebGLCubeRenderTarget}
14
+ * However, light estimation data could also be provided in other forms e.g
15
+ * by WebXR
16
+ * This enables the rendering of augmented reality content that reacts to real world lighting.
17
+ * The current probe implementation in three.js supports so-called diffuse light probes
18
+ * This type of light probe is functionally equivalent to an irradiance environment map.
19
+ * @see Example: {@link https://threejs.org/examples/#webgl_lightprobe | WebGL / light probe }
20
+ * @see Example: {@link https://threejs.org/examples/#webgl_lightprobe_cubecamera | WebGL / light probe / cube camera }
21
+ * @see {@link https://threejs.org/docs/index.html#api/en/lights/LightProbe | Official Documentation}
22
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/LightProbe.js | Source}
23
+ */
4
24
  export class LightProbe extends Light {
25
+ /**
26
+ * Creates a new LightProbe.
27
+ * @param sh An instance of {@link THREE.SphericalHarmonics3 | SphericalHarmonics3}. Default `new THREE.SphericalHarmonics3()``.
28
+ * @param intensity Numeric value of the light probe's intensity. Expects a `Float`. Default `1`.
29
+ */
5
30
  constructor(sh?: SphericalHarmonics3, intensity?: number);
6
31
 
7
32
  /**
8
- * @default 'LightProbe'
33
+ * Read-only flag to check if a given object is of type {@link DirectionalLight}.
34
+ * @remarks This is a _constant_ value
35
+ * @defaultValue `true`
9
36
  */
10
- type: string;
11
-
12
37
  readonly isLightProbe: true;
13
38
 
14
39
  /**
15
- * @default new THREE.SphericalHarmonics3()
40
+ * A light probe uses spherical harmonics to encode lighting information.
41
+ * @defaultValue `new THREE.SphericalHarmonics3()`
16
42
  */
17
43
  sh: SphericalHarmonics3;
18
44
 
19
- fromJSON(json: object): LightProbe;
45
+ /** @internal */
46
+ fromJSON(json: {}): LightProbe;
20
47
  }
@@ -4,68 +4,150 @@ import { Vector2 } from './../math/Vector2';
4
4
  import { Vector4 } from './../math/Vector4';
5
5
  import { Matrix4 } from './../math/Matrix4';
6
6
  import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget';
7
+ import { Frustum } from '../Three';
7
8
 
8
- export class LightShadow {
9
- constructor(camera: Camera);
9
+ /**
10
+ * Serves as a base class for the other shadow classes.
11
+ * @see {@link https://threejs.org/docs/index.html#api/en/lights/shadows/LightShadow | Official Documentation}
12
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/LightShadow.js | Source}
13
+ */
14
+ export class LightShadow<TCamera extends Camera = Camera> {
15
+ /**
16
+ * Create a new instance of {@link LightShadow}
17
+ * @param camera The light's view of the world.
18
+ */
19
+ constructor(camera: TCamera);
10
20
 
11
- camera: Camera;
21
+ /**
22
+ * The light's view of the world.
23
+ * @remark This is used to generate a depth map of the scene; objects behind other objects from the light's perspective will be in shadow.
24
+ */
25
+ camera: TCamera;
12
26
 
13
27
  /**
14
- * @default 0
28
+ * Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.
29
+ * @remark The Very tiny adjustments here (in the order of 0.0001) may help reduce artifacts in shadows.
30
+ * @remarks Expects a `Float`
31
+ * @defaultValue `0`
15
32
  */
16
33
  bias: number;
17
34
 
18
35
  /**
19
- * @default 0
36
+ * Defines how much the position used to query the shadow map is offset along the object normal.
37
+ * @remark The Increasing this value can be used to reduce shadow acne especially in large scenes where light shines onto geometry at a shallow angle.
38
+ * @remark The cost is that shadows may appear distorted.
39
+ * @remarks Expects a `Float`
40
+ * @defaultValue `0`
20
41
  */
21
42
  normalBias: number;
22
43
 
23
44
  /**
24
- * @default 1
45
+ * Setting this to values greater than 1 will blur the edges of the shadow.toi
46
+ * @remark High values will cause unwanted banding effects in the shadows - a greater {@link LightShadow.mapSize | mapSize
47
+ * will allow for a higher value to be used here before these effects become visible.
48
+ * @remark If {@link THREE.WebGLRenderer.shadowMap.type | WebGLRenderer.shadowMap.type} is set to {@link Renderer | PCFSoftShadowMap},
49
+ * radius has no effect and it is recommended to increase softness by decreasing {@link LightShadow.mapSize | mapSize} instead.
50
+ * @remark Note that this has no effect if the {@link THREE.WebGLRenderer.shadowMap | WebGLRenderer.shadowMap}.{@link THREE.WebGLShadowMap.type | type}
51
+ * is set to {@link THREE.BasicShadowMap | BasicShadowMap}.
52
+ * @remarks Expects a `Float`
53
+ * @defaultValue `1`
25
54
  */
26
55
  radius: number;
27
56
 
28
57
  /**
29
- * @default 8
58
+ * The amount of samples to use when blurring a VSM shadow map.
59
+ * @remarks Expects a `Integer`
60
+ * @defaultValue `8`
30
61
  */
31
62
  blurSamples: number;
32
63
 
33
64
  /**
34
- * @default new THREE.Vector2( 512, 512 )
65
+ * A {@link THREE.Vector2 | Vector2} defining the width and height of the shadow map.
66
+ * @remarks Higher values give better quality shadows at the cost of computation time.
67
+ * @remarks Values must be powers of 2, up to the {@link THREE.WebGLRenderer.capabilities | WebGLRenderer.capabilities}.maxTextureSize for a given device,
68
+ * although the width and height don't have to be the same (so, for example, (512, 1024) is valid).
69
+ * @defaultValue `new THREE.Vector2(512, 512)`
35
70
  */
36
71
  mapSize: Vector2;
37
72
 
38
73
  /**
39
- * @default null
74
+ * The depth map generated using the internal camera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
75
+ * @defaultValue null
40
76
  */
41
- map: WebGLRenderTarget;
77
+ map: WebGLRenderTarget | null;
42
78
 
43
79
  /**
44
- * @default null
80
+ * The distribution map generated using the internal camera; an occlusion is calculated based on the distribution of depths. Computed internally during rendering.
81
+ * @defaultValue null
45
82
  */
46
- mapPass: WebGLRenderTarget;
83
+ mapPass: WebGLRenderTarget | null;
47
84
 
48
85
  /**
49
- * @default new THREE.Matrix4()
86
+ * Model to shadow camera space, to compute location and depth in shadow map.
87
+ * Stored in a {@link Matrix4 | Matrix4}.
88
+ * @remarks This is computed internally during rendering.
89
+ * @defaultValue new THREE.Matrix4()
50
90
  */
51
91
  matrix: Matrix4;
52
92
 
53
93
  /**
54
- * @default true
94
+ * Enables automatic updates of the light's shadow. If you do not require dynamic lighting / shadows, you may set this to `false`.
95
+ * @defaultValue `true`
55
96
  */
56
97
  autoUpdate: boolean;
57
98
 
58
99
  /**
59
- * @default false
100
+ * When set to `true`, shadow maps will be updated in the next `render` call.
101
+ * If you have set {@link autoUpdate} to `false`, you will need to set this property to `true` and then make a render call to update the light's shadow.
102
+ * @defaultValue `false`
60
103
  */
61
104
  needsUpdate: boolean;
62
105
 
106
+ /**
107
+ * Used internally by the renderer to get the number of viewports that need to be rendered for this shadow.
108
+ */
109
+ getViewportCount(): number;
110
+
111
+ /**
112
+ * Copies value of all the properties from the {@link {@link LightShadow} | source} to this Light.
113
+ * @param source
114
+ */
63
115
  copy(source: LightShadow): this;
116
+
117
+ /**
118
+ * Creates a new {@link LightShadow} with the same properties as this one.
119
+ */
64
120
  clone(recursive?: boolean): this;
65
- toJSON(): any;
66
- getFrustum(): number;
67
- updateMatrices(light: Light, viewportIndex?: number): void;
121
+
122
+ /**
123
+ * Serialize this LightShadow.
124
+ */
125
+ toJSON(): {};
126
+
127
+ /**
128
+ * Gets the shadow cameras frustum
129
+ * @remarks
130
+ * Used internally by the renderer to cull objects.
131
+ */
132
+ getFrustum(): Frustum;
133
+
134
+ /**
135
+ * Update the matrices for the camera and shadow, used internally by the renderer.
136
+ * @param light The light for which the shadow is being rendered.
137
+ */
138
+ updateMatrices(light: Light): void;
139
+
68
140
  getViewport(viewportIndex: number): Vector4;
141
+
142
+ /**
143
+ * Used internally by the renderer to extend the shadow map to contain all viewports
144
+ */
69
145
  getFrameExtents(): Vector2;
146
+
147
+ /**
148
+ * Frees the GPU-related resources allocated by this instance
149
+ * @remarks
150
+ * Call this method whenever this instance is no longer used in your app.
151
+ */
70
152
  dispose(): void;
71
153
  }
@@ -1,14 +1,32 @@
1
- import { ColorRepresentation } from '../utils';
1
+ import { ColorRepresentation } from '../math/Color';
2
2
  import { Light } from './Light';
3
3
  import { PointLightShadow } from './PointLightShadow';
4
4
 
5
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.
6
9
  * @example
7
- * const light = new THREE.PointLight( 0xff0000, 1, 100 );
8
- * light.position.set( 50, 50, 50 );
9
- * scene.add( light );
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}
10
21
  */
11
- export class PointLight extends Light {
22
+ export 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
+ */
12
30
  constructor(color?: ColorRepresentation, intensity?: number, distance?: number, decay?: number);
13
31
 
14
32
  /**
@@ -17,34 +35,61 @@ export class PointLight extends Light {
17
35
  type: string;
18
36
 
19
37
  /**
20
- * Light's intensity.
21
- * @default 2
38
+ * The light's intensity.
39
+ *
40
+ * When **{@link WebGLRenderer.physicallyCorrectLights | physically correct} mode** — intensity is the luminous intensity of the light measured in candela (cd).
41
+ * @remarks Changing the intensity will also change the light's power.
42
+ * @remarks Expects a `Float`
43
+ * @defaultValue `1`
22
44
  */
23
45
  intensity: number;
24
46
 
25
47
  /**
26
- * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance.
27
- * @default 0
48
+ * When **Default mode** When distance is zero, light does not attenuate. When distance is non-zero,
49
+ * light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light.
50
+ *
51
+ * When **{@link WebGLRenderer.physicallyCorrectLights | Physically correct} rendering mode** — When distance is zero,
52
+ * light will attenuate according to inverse-square law to infinite distance.
53
+ * When distance is non-zero, light will attenuate according to inverse-square law until near the distance cutoff,
54
+ * where it will then attenuate quickly and smoothly to 0. Inherently, cutoffs are not physically correct.
55
+ *
56
+ * @defaultValue `0.0`
57
+ * @remarks Expects a `Float`
28
58
  */
29
59
  distance: number;
30
60
 
31
61
  /**
32
62
  * If set to `true` light will cast dynamic shadows.
33
63
  * **Warning**: This is expensive and requires tweaking to get shadows looking right.
34
- * See the {@link PointLightShadow} for details.
35
- * The default is `false`.
64
+ * @see {@link THREE.PointLightShadow | PointLightShadow} for details.
65
+ * @defaultValue `false`
36
66
  */
37
67
  castShadow: boolean;
38
68
 
39
69
  /**
40
- * @default 1
70
+ * The amount the light dims along the distance of the light.
71
+ * In **{@link WebGLRenderer.physicallyCorrectLights | physically correct} rendering mode** — the default value **should not** be changed.
72
+ * @remarks Expects a `Float`
73
+ * @defaultValue `2`
41
74
  */
42
75
  decay: number;
43
76
 
44
77
  /**
45
- * @default new THREE.PointLightShadow()
78
+ * A {@link THREE.PointLightShadow | PointLightShadow} used to calculate shadows for this light.
79
+ * The lightShadow's {@link LightShadow.camera | camera} is set to
80
+ * a {@link THREE.PerspectiveCamera | PerspectiveCamera} with {@link PerspectiveCamera.fov | fov} of 90,
81
+ * {@link PerspectiveCamera.aspect | aspect} of 1,
82
+ * {@link PerspectiveCamera.near | near} clipping plane at 0.5
83
+ * and {@link PerspectiveCamera.far | far} clipping plane at 500.
84
+ * @defaultValue new THREE.PointLightShadow()
46
85
  */
47
86
  shadow: PointLightShadow;
48
87
 
88
+ /**
89
+ * The light's power.
90
+ * When **{@link WebGLRenderer.physicallyCorrectLights | physically correct} rendering mode** — power is the luminous power of the light measured in lumens (lm).
91
+ * @remarks Changing the power will also change the light's intensity.
92
+ * @remarks Expects a `Float`
93
+ */
49
94
  power: number;
50
95
  }
@@ -1,6 +1,22 @@
1
1
  import { PerspectiveCamera } from './../cameras/PerspectiveCamera';
2
+ import { Light } from './Light';
2
3
  import { LightShadow } from './LightShadow';
3
4
 
4
- export class PointLightShadow extends LightShadow {
5
- camera: PerspectiveCamera;
5
+ /**
6
+ * Shadow for {@link THREE.PointLight | PointLight}
7
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/PointLightShadow.js | Source}
8
+ */
9
+ export class PointLightShadow extends LightShadow<PerspectiveCamera> {
10
+ /**
11
+ * Read-only flag to check if a given object is of type {@link PointLightShadow}.
12
+ * @remarks This is a _constant_ value
13
+ * @defaultValue `true`
14
+ */
15
+ readonly isPointLightShadow = true;
16
+
17
+ /**
18
+ * Update the matrices for the camera and shadow, used internally by the renderer.
19
+ * @param light The light for which the shadow is being rendered.
20
+ */
21
+ override updateMatrices(light: Light, viewportIndex?: number): void;
6
22
  }
@@ -1,30 +1,82 @@
1
1
  import { Light } from './Light';
2
- import { ColorRepresentation } from '../utils';
2
+ import { ColorRepresentation } from '../math/Color';
3
3
 
4
- export class RectAreaLight extends Light {
4
+ /**
5
+ * {@link RectAreaLight} emits light uniformly across the face a rectangular plane
6
+ * @remarks
7
+ * This light type can be used to simulate light sources such as bright windows or strip lighting.
8
+ * Important Notes:
9
+ * - There is no shadow support.
10
+ * - Only {@link MeshStandardMaterial | MeshStandardMaterial} and {@link MeshPhysicalMaterial | MeshPhysicalMaterial} are supported.
11
+ * - You have to include {@link https://threejs.org/examples/jsm/lights/RectAreaLightUniformsLib.js | RectAreaLightUniformsLib} into your scene and call `init()`.
12
+ * @example
13
+ * ```typescript
14
+ * const width = 10;
15
+ * const height = 10;
16
+ * const intensity = 1;
17
+ * const rectLight = new THREE.RectAreaLight(0xffffff, intensity, width, height);
18
+ * rectLight.position.set(5, 5, 0);
19
+ * rectLight.lookAt(0, 0, 0);
20
+ * scene.add(rectLight)
21
+ * const rectLightHelper = new RectAreaLightHelper(rectLight);
22
+ * rectLight.add(rectLightHelper);
23
+ * ```
24
+ * @see Example: {@link https://threejs.org/examples/#webgl_lights_rectarealight | WebGL / {@link RectAreaLight} }
25
+ * @see {@link https://threejs.org/docs/index.html#api/en/lights/RectAreaLight | Official Documentation}
26
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/RectAreaLight.js | Source}
27
+ */
28
+ export class RectAreaLight extends Light<undefined> {
29
+ /**
30
+ * Creates a new {@link RectAreaLight}.
31
+ * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_.
32
+ * @param intensity The light's intensity, or brightness. Expects a `Float`. Default `1`
33
+ * @param width Width of the light. Expects a `Float`. Default `10`
34
+ * @param height Height of the light. Expects a `Float`. Default `10`
35
+ */
5
36
  constructor(color?: ColorRepresentation, intensity?: number, width?: number, height?: number);
6
37
 
7
38
  /**
8
- * @default 'RectAreaLight'
39
+ * Read-only flag to check if a given object is of type {@link RectAreaLight}.
40
+ * @remarks This is a _constant_ value
41
+ * @defaultValue `true`
42
+ */
43
+ readonly isRectAreaLight: true;
44
+
45
+ /**
46
+ * A Read-only _string_ to check if `this` object type.
47
+ * @remarks Sub-classes will update this value.
48
+ * @defaultValue `RectAreaLight`
9
49
  */
10
- type: string;
50
+ override readonly type: string | 'RectAreaLight';
11
51
 
12
52
  /**
13
- * @default 10
53
+ * The width of the light.
54
+ * @remarks Expects a `Float`
55
+ * @defaultValue `10`
14
56
  */
15
57
  width: number;
16
58
 
17
59
  /**
18
- * @default 10
60
+ * The height of the light.
61
+ * @remarks Expects a `Float`
62
+ * @defaultValue `10`
19
63
  */
20
64
  height: number;
21
65
 
22
66
  /**
23
- * @default 1
67
+ * The light's intensity.
68
+ * @remarks Changing the intensity will also change the light's power.
69
+ * In **{@link WebGLRenderer.physicallyCorrectLights | physically correct} rendering mode** — intensity is the luminance (brightness) of the light measured in nits (cd/m^2).
70
+ * @remarks Expects a `Float`
71
+ * @defaultValue `1`
24
72
  */
25
73
  intensity: number;
26
74
 
75
+ /**
76
+ * The light's power.
77
+ * @remarks Changing the power will also change the light's intensity.
78
+ * In **{@link WebGLRenderer.physicallyCorrectLights | physically correct} rendering mode** — power is the luminous power of the light measured in lumens (lm).
79
+ * @remarks Expects a `Float`
80
+ */
27
81
  power: number;
28
-
29
- readonly isRectAreaLight: true;
30
82
  }
@@ -1,15 +1,41 @@
1
- import { Color } from './../math/Color';
2
1
  import { Vector3 } from '../math/Vector3';
3
2
  import { Object3D } from './../core/Object3D';
4
3
  import { SpotLightShadow } from './SpotLightShadow';
5
4
  import { Light } from './Light';
6
- import { ColorRepresentation } from '../utils';
5
+ import { ColorRepresentation } from '../math/Color';
7
6
  import { Texture } from '../textures/Texture';
8
7
 
9
8
  /**
10
- * A point light that can cast shadow in one direction.
9
+ * This light gets emitted from a single point in one direction, along a cone that increases in size the further from the light it gets.
10
+ * @example
11
+ * ```typescript
12
+ * // white {@link SpotLight} shining from the side, modulated by a texture, casting a shadow
13
+ * const {@link SpotLight} = new THREE.SpotLight(0xffffff);
14
+ * spotLight.position.set(100, 1000, 100);
15
+ * spotLight.map = new THREE.TextureLoader().load(url);
16
+ * spotLight.castShadow = true;
17
+ * spotLight.shadow.mapSize.width = 1024;
18
+ * spotLight.shadow.mapSize.height = 1024;
19
+ * spotLight.shadow.camera.near = 500;
20
+ * spotLight.shadow.camera.far = 4000;
21
+ * spotLight.shadow.camera.fov = 30;
22
+ * scene.add(spotLight);
23
+ * ```
24
+ * @see Example: {@link https://threejs.org/examples/#webgl_lights_spotlight | lights / {@link SpotLight} }
25
+ * @see Example: {@link https://threejs.org/examples/#webgl_lights_spotlights | lights / spotlights }
26
+ * @see {@link https://threejs.org/docs/index.html#api/en/lights/SpotLight | Official Documentation}
27
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/SpotLight.js | Source}
11
28
  */
12
- export class SpotLight extends Light {
29
+ export class SpotLight extends Light<SpotLightShadow> {
30
+ /**
31
+ * Creates a new SpotLight.
32
+ * @param color Hexadecimal color of the light. Default `0xffffff` _(white)_.
33
+ * @param intensity Numeric value of the light's strength/intensity. Expects a `Float`. Default `1`.
34
+ * @param distance Maximum range of the light. Default is 0 (no limit). Expects a `Float`.
35
+ * @param angle Maximum angle of light dispersion from its direction whose upper bound is Math.PI/2.
36
+ * @param penumbra Percent of the {@link SpotLight} cone that is attenuated due to penumbra. Takes values between zero and 1. Expects a `Float`. Default `0`.
37
+ * @param decay The amount the light dims along the distance of the light. Expects a `Float`. Default `2`.
38
+ */
13
39
  constructor(
14
40
  color?: ColorRepresentation,
15
41
  intensity?: number,
@@ -20,61 +46,119 @@ export class SpotLight extends Light {
20
46
  );
21
47
 
22
48
  /**
23
- * @default 'SpotLight'
49
+ * Read-only flag to check if a given object is of type {@link SpotLight}.
50
+ * @remarks This is a _constant_ value
51
+ * @defaultValue `true`
24
52
  */
25
- type: string;
53
+ readonly isSpotLight: true;
26
54
 
27
55
  /**
28
- * This is set equal to {@link Object3D.DEFAULT_UP} (0, 1, 0), so that the light shines from the top down.
29
- *
30
- * @default {@link Object3D.DEFAULT_UP}
56
+ * A Read-only _string_ to check if `this` object type.
57
+ * @remarks Sub-classes will update this value.
58
+ * @defaultValue `SpotLight`
59
+ */
60
+ override readonly type: string | 'SpotLight';
61
+
62
+ /**
63
+ * This is set equal to {@link THREE.Object3D.DEFAULT_UP | Object3D.DEFAULT_UP} (0, 1, 0), so that the light shines from the top down.
64
+ * @defaultValue `{@link Object3D.DEFAULT_UP}`
31
65
  */
32
66
  position: Vector3;
33
67
 
34
68
  /**
35
- * Spotlight focus points at target.position.
36
- * @default new THREE.Object3D()
69
+ * The {@link SpotLight} points from its {@link SpotLight.position | position} to target.position.
70
+ * @remarks
71
+ * **Note**: For the target's position to be changed to anything other than the default,
72
+ * it must be added to the {@link Scene | scene} using
73
+ *
74
+ * ```typescript
75
+ * scene.add( light.target );
76
+ * ```
77
+ *
78
+ * This is so that the target's {@link Object3D.matrixWorld | matrixWorld} gets automatically updated each frame.
79
+ * It is also possible to set the target to be another object in the scene (anything with a {@link THREE.Object3D.position | position} property), like so:
80
+ * ```typescript
81
+ * const targetObject = new THREE.Object3D();
82
+ * scene.add(targetObject);
83
+ * light.target = targetObject;
84
+ * ```
85
+ * The {@link SpotLight} will now track the target object.
86
+ * @defaultValue `new THREE.Object3D()` _The default position of the target is *(0, 0, 0)*._
37
87
  */
38
88
  target: Object3D;
39
89
 
40
90
  /**
41
- * Light's intensity.
42
- * @default 2
91
+ * If set to `true` light will cast dynamic shadows.
92
+ * @remarks **Warning**: This is expensive and requires tweaking to get shadows looking right. the {@link THREE.SpotLightShadow | SpotLightShadow} for details.
93
+ * @defaultValue `false`
94
+ */
95
+ override castShadow: boolean;
96
+
97
+ /**
98
+ * The light's intensity.
99
+ * @remarks Changing the intensity will also change the light's power.
100
+ * When **{@link WebGLRenderer.physicallyCorrectLights | Physically correct} rendering mode** — intensity is the luminous intensity of the light measured in candela (cd).
101
+ * @remarks Expects a `Float`
102
+ * @defaultValue `1`
43
103
  */
44
104
  intensity: number;
45
105
 
46
106
  /**
47
- * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance.
48
- * @default 0
107
+ * When **Default mode** When distance is zero, light does not attenuate. When distance is non-zero,
108
+ * light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light.
109
+ *
110
+ * When **{@link WebGLRenderer.physicallyCorrectLights | Physically correct} rendering mode** — When distance is zero,
111
+ * light will attenuate according to inverse-square law to infinite distance.
112
+ * When distance is non-zero, light will attenuate according to inverse-square law until near the distance cutoff,
113
+ * where it will then attenuate quickly and smoothly to `0`. Inherently, cutoffs are not physically correct.
114
+ * @remarks Expects a `Float`
115
+ * @defaultValue `0.0`
49
116
  */
50
117
  distance: number;
51
118
 
52
119
  /**
53
120
  * Maximum extent of the spotlight, in radians, from its direction.
54
- * @default Math.PI / 3.
121
+ * @remarks Should be no more than `Math.PI/2`.
122
+ * @remarks Expects a `Float`
123
+ * @defaultValue `Math.PI / 3`
55
124
  */
56
125
  angle: number;
57
126
 
58
127
  /**
59
- * @default 1
128
+ * The amount the light dims along the distance of the light.
129
+ * In **{@link WebGLRenderer.physicallyCorrectLights | physically correct} rendering mode** — the default value should not be changed.
130
+ * @remarks Expects a `Float`
131
+ * @defaultValue `2`
60
132
  */
61
133
  decay: number;
62
134
 
63
135
  /**
64
- * @default new THREE.SpotLightShadow()
136
+ * A {@link THREE.SpotLightShadow | SpotLightShadow} used to calculate shadows for this light.
137
+ * @defaultValue `new THREE.SpotLightShadow()`
65
138
  */
66
139
  shadow: SpotLightShadow;
140
+
141
+ /**
142
+ * The light's power.
143
+ * @remarks Changing the power will also change the light's intensity.
144
+ * In **{@link WebGLRenderer.physicallyCorrectLights | physically correct} rendering mode** — power is the luminous power of the light measured in lumens (lm).
145
+ * @remarks Expects a `Float`
146
+ */
67
147
  power: number;
68
148
 
69
149
  /**
70
- * @default 0
150
+ * Percent of the {@link SpotLight} cone that is attenuated due to penumbra.
151
+ * @remarks Takes values between zero and 1.
152
+ * @remarks Expects a `Float`
153
+ * @defaultValue `0.0`
71
154
  */
72
155
  penumbra: number;
73
156
 
74
157
  /**
75
- * @default null
158
+ * A {@link THREE.Texture | Texture} used to modulate the color of the light.
159
+ * The spot light color is mixed with the _RGB_ value of this texture, with a ratio corresponding to its alpha value.
160
+ * The cookie-like masking effect is reproduced using pixel values (0, 0, 0, 1-cookie_value).
161
+ * @remarks **Warning**: {@link SpotLight.map} is disabled if {@link SpotLight.castShadow} is `false`.
76
162
  */
77
163
  map: Texture | null;
78
-
79
- readonly isSpotLight: true;
80
164
  }