@types/three 0.150.2 → 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.
- three/README.md +1 -1
- three/examples/jsm/controls/MapControls.d.ts +21 -0
- three/examples/jsm/controls/OrbitControls.d.ts +1 -5
- three/examples/jsm/controls/PointerLockControls.d.ts +3 -0
- three/examples/jsm/controls/TrackballControls.d.ts +2 -0
- three/examples/jsm/helpers/ViewHelper.d.ts +3 -4
- three/examples/jsm/loaders/GLTFLoader.d.ts +2 -4
- three/examples/jsm/loaders/SVGLoader.d.ts +15 -3
- three/examples/jsm/nodes/Nodes.d.ts +130 -226
- three/examples/jsm/nodes/{core → code}/CodeNode.d.ts +2 -3
- three/examples/jsm/nodes/{core → code}/ExpressionNode.d.ts +2 -2
- three/examples/jsm/nodes/{core → code}/FunctionCallNode.d.ts +2 -2
- three/examples/jsm/nodes/{core → code}/FunctionNode.d.ts +4 -4
- three/examples/jsm/nodes/core/InputNode.d.ts +4 -0
- three/examples/jsm/nodes/core/NodeBuilder.d.ts +1 -3
- three/examples/jsm/nodes/core/NodeUtils.d.ts +8 -2
- three/examples/jsm/nodes/core/{VaryNode.d.ts → VaryingNode.d.ts} +1 -1
- three/examples/jsm/nodes/fog/FogNode.d.ts +1 -1
- three/examples/jsm/nodes/geometry/RangeNode.d.ts +2 -1
- three/examples/jsm/nodes/lighting/PointLightNode.d.ts +10 -0
- three/examples/jsm/nodes/lighting/SpotLightNode.d.ts +15 -0
- three/examples/jsm/nodes/math/MathNode.d.ts +2 -2
- three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +2 -2
- three/examples/jsm/objects/{GroundProjectedEnv.d.ts → GroundProjectedSkybox.d.ts} +1 -1
- three/examples/jsm/postprocessing/Pass.d.ts +2 -0
- three/examples/jsm/renderers/CSS2DRenderer.d.ts +2 -1
- three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +0 -1
- three/examples/jsm/utils/BufferGeometryUtils.d.ts +12 -2
- three/index.d.ts +1 -1
- three/package.json +2 -2
- three/src/Three.d.ts +1 -0
- three/src/core/Raycaster.d.ts +1 -0
- three/src/extras/DataUtils.d.ts +13 -0
- three/src/extras/Earcut.d.ts +12 -0
- three/src/extras/ImageUtils.d.ts +20 -20
- three/src/extras/PMREMGenerator.d.ts +66 -0
- three/src/extras/ShapeUtils.d.ts +19 -1
- three/src/extras/core/Curve.d.ts +86 -31
- three/src/extras/core/CurvePath.d.ts +46 -4
- three/src/extras/core/Interpolations.d.ts +36 -0
- three/src/extras/core/Path.d.ts +122 -15
- three/src/extras/core/Shape.d.ts +56 -6
- three/src/extras/core/ShapePath.d.ts +73 -8
- three/src/extras/curves/ArcCurve.d.ts +35 -3
- three/src/extras/curves/CatmullRomCurve3.d.ts +62 -15
- three/src/extras/curves/CubicBezierCurve.d.ts +48 -7
- three/src/extras/curves/CubicBezierCurve3.d.ts +48 -7
- three/src/extras/curves/EllipseCurve.d.ts +73 -18
- three/src/extras/curves/LineCurve.d.ts +26 -5
- three/src/extras/curves/LineCurve3.d.ts +26 -5
- three/src/extras/curves/QuadraticBezierCurve.d.ts +44 -6
- three/src/extras/curves/QuadraticBezierCurve3.d.ts +44 -6
- three/src/extras/curves/SplineCurve.d.ts +39 -3
- three/src/helpers/ArrowHelper.d.ts +47 -16
- three/src/helpers/AxesHelper.d.ts +35 -3
- three/src/helpers/Box3Helper.d.ts +28 -4
- three/src/helpers/BoxHelper.d.ts +44 -4
- three/src/helpers/CameraHelper.d.ts +38 -19
- three/src/helpers/DirectionalLightHelper.d.ts +57 -10
- three/src/helpers/GridHelper.d.ts +32 -6
- three/src/helpers/HemisphereLightHelper.d.ts +56 -3
- three/src/helpers/PlaneHelper.d.ts +31 -8
- three/src/helpers/PointLightHelper.d.ts +54 -6
- three/src/helpers/PolarGridHelper.d.ts +35 -8
- three/src/helpers/SkeletonHelper.d.ts +56 -8
- three/src/helpers/SpotLightHelper.d.ts +59 -4
- three/src/lights/AmbientLight.d.ts +23 -10
- three/src/lights/AmbientLightProbe.d.ts +18 -0
- three/src/lights/DirectionalLight.d.ts +75 -20
- three/src/lights/DirectionalLightShadow.d.ts +68 -2
- three/src/lights/HemisphereLight.d.ts +45 -12
- three/src/lights/HemisphereLightProbe.d.ts +19 -0
- three/src/lights/Light.d.ts +40 -43
- three/src/lights/LightProbe.d.ts +32 -5
- three/src/lights/LightShadow.d.ts +100 -18
- three/src/lights/PointLight.d.ts +57 -12
- three/src/lights/PointLightShadow.d.ts +18 -2
- three/src/lights/RectAreaLight.d.ts +60 -8
- three/src/lights/SpotLight.d.ts +105 -20
- three/src/lights/SpotLightShadow.d.ts +63 -3
- three/src/materials/LineBasicMaterial.d.ts +7 -1
- three/src/materials/MeshDistanceMaterial.d.ts +0 -15
- three/src/math/Color.d.ts +23 -2
- three/src/math/Quaternion.d.ts +6 -0
- three/src/math/Triangle.d.ts +40 -0
- three/src/math/Vector2.d.ts +5 -0
- three/src/math/Vector3.d.ts +10 -3
- three/src/objects/InstancedMesh.d.ts +22 -30
- three/src/objects/LineSegments.d.ts +2 -0
- three/src/objects/Skeleton.d.ts +5 -1
- three/src/objects/SkinnedMesh.d.ts +37 -25
- three/src/renderers/WebGLRenderer.d.ts +16 -0
- three/src/renderers/shaders/ShaderChunk.d.ts +58 -37
- three/src/renderers/shaders/UniformsLib.d.ts +88 -57
- three/src/textures/Texture.d.ts +5 -22
- three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +0 -12
three/src/lights/LightProbe.d.ts
CHANGED
|
@@ -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
|
-
* @
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
}
|
three/src/lights/PointLight.d.ts
CHANGED
|
@@ -3,12 +3,30 @@ 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
|
-
*
|
|
8
|
-
* light.
|
|
9
|
-
*
|
|
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
|
-
*
|
|
21
|
-
*
|
|
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
|
-
*
|
|
27
|
-
*
|
|
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
|
-
*
|
|
35
|
-
*
|
|
64
|
+
* @see {@link THREE.PointLightShadow | PointLightShadow} for details.
|
|
65
|
+
* @defaultValue `false`
|
|
36
66
|
*/
|
|
37
67
|
castShadow: boolean;
|
|
38
68
|
|
|
39
69
|
/**
|
|
40
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
5
|
-
|
|
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
2
|
import { ColorRepresentation } from '../math/Color';
|
|
3
3
|
|
|
4
|
-
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
}
|
three/src/lights/SpotLight.d.ts
CHANGED
|
@@ -6,9 +6,36 @@ import { ColorRepresentation } from '../math/Color';
|
|
|
6
6
|
import { Texture } from '../textures/Texture';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
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}
|
|
10
28
|
*/
|
|
11
|
-
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
|
+
*/
|
|
12
39
|
constructor(
|
|
13
40
|
color?: ColorRepresentation,
|
|
14
41
|
intensity?: number,
|
|
@@ -19,61 +46,119 @@ export class SpotLight extends Light {
|
|
|
19
46
|
);
|
|
20
47
|
|
|
21
48
|
/**
|
|
22
|
-
* @
|
|
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`
|
|
23
52
|
*/
|
|
24
|
-
|
|
53
|
+
readonly isSpotLight: true;
|
|
25
54
|
|
|
26
55
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
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}`
|
|
30
65
|
*/
|
|
31
66
|
position: Vector3;
|
|
32
67
|
|
|
33
68
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
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)*._
|
|
36
87
|
*/
|
|
37
88
|
target: Object3D;
|
|
38
89
|
|
|
39
90
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
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`
|
|
42
103
|
*/
|
|
43
104
|
intensity: number;
|
|
44
105
|
|
|
45
106
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
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`
|
|
48
116
|
*/
|
|
49
117
|
distance: number;
|
|
50
118
|
|
|
51
119
|
/**
|
|
52
120
|
* Maximum extent of the spotlight, in radians, from its direction.
|
|
53
|
-
* @
|
|
121
|
+
* @remarks Should be no more than `Math.PI/2`.
|
|
122
|
+
* @remarks Expects a `Float`
|
|
123
|
+
* @defaultValue `Math.PI / 3`
|
|
54
124
|
*/
|
|
55
125
|
angle: number;
|
|
56
126
|
|
|
57
127
|
/**
|
|
58
|
-
*
|
|
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`
|
|
59
132
|
*/
|
|
60
133
|
decay: number;
|
|
61
134
|
|
|
62
135
|
/**
|
|
63
|
-
* @
|
|
136
|
+
* A {@link THREE.SpotLightShadow | SpotLightShadow} used to calculate shadows for this light.
|
|
137
|
+
* @defaultValue `new THREE.SpotLightShadow()`
|
|
64
138
|
*/
|
|
65
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
|
+
*/
|
|
66
147
|
power: number;
|
|
67
148
|
|
|
68
149
|
/**
|
|
69
|
-
* @
|
|
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`
|
|
70
154
|
*/
|
|
71
155
|
penumbra: number;
|
|
72
156
|
|
|
73
157
|
/**
|
|
74
|
-
* @
|
|
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`.
|
|
75
162
|
*/
|
|
76
163
|
map: Texture | null;
|
|
77
|
-
|
|
78
|
-
readonly isSpotLight: true;
|
|
79
164
|
}
|