@types/three 0.149.0 → 0.150.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 (40) hide show
  1. three/README.md +2 -2
  2. three/build/three.d.cts +2 -0
  3. three/build/three.d.ts +2 -0
  4. three/build/three.module.d.ts +2 -0
  5. three/examples/jsm/controls/OrbitControls.d.ts +8 -3
  6. three/examples/jsm/controls/TrackballControls.d.ts +2 -2
  7. three/examples/jsm/controls/TransformControls.d.ts +4 -4
  8. three/examples/jsm/helpers/OctreeHelper.d.ts +1 -1
  9. three/examples/jsm/libs/fflate.module.d.ts +1 -0
  10. three/examples/jsm/libs/lil-gui.module.min.d.ts +1 -0
  11. three/examples/jsm/libs/stats.module.d.ts +2 -23
  12. three/examples/jsm/nodes/shadernode/ShaderNode.d.ts +3 -4
  13. three/examples/jsm/objects/MarchingCubes.d.ts +1 -0
  14. three/examples/jsm/shaders/VelocityShader.d.ts +2 -2
  15. three/index.d.ts +1 -1
  16. three/package.json +19 -4
  17. three/src/Three.d.ts +0 -1
  18. three/src/constants.d.ts +394 -254
  19. three/src/core/BufferAttribute.d.ts +456 -85
  20. three/src/core/BufferGeometry.d.ts +235 -67
  21. three/src/core/Clock.d.ts +28 -20
  22. three/src/core/EventDispatcher.d.ts +20 -4
  23. three/src/core/GLBufferAttribute.d.ts +102 -8
  24. three/src/core/InstancedBufferAttribute.d.ts +13 -24
  25. three/src/core/InstancedBufferGeometry.d.ts +22 -4
  26. three/src/core/InstancedInterleavedBuffer.d.ts +10 -2
  27. three/src/core/InterleavedBuffer.d.ts +98 -14
  28. three/src/core/InterleavedBufferAttribute.d.ts +146 -7
  29. three/src/core/Layers.d.ts +61 -6
  30. three/src/core/Object3D.d.ts +236 -119
  31. three/src/core/Raycaster.d.ts +103 -27
  32. three/src/core/Uniform.d.ts +28 -11
  33. three/src/core/UniformsGroup.d.ts +10 -4
  34. three/src/extras/Earcut.d.ts +3 -4
  35. three/src/materials/MeshPhysicalMaterial.d.ts +13 -1
  36. three/src/math/Color.d.ts +157 -3
  37. three/src/math/ColorManagement.d.ts +13 -7
  38. three/src/renderers/WebGLRenderer.d.ts +2 -2
  39. three/src/utils.d.ts +5 -2
  40. three/examples/jsm/libs/fflate.module.min.d.ts +0 -1185
@@ -14,15 +14,21 @@ export interface Face {
14
14
  }
15
15
 
16
16
  export interface Intersection<TIntersected extends Object3D = Object3D> {
17
+ /** Distance between the origin of the ray and the intersection */
17
18
  distance: number;
18
19
  distanceToRay?: number | undefined;
20
+ /** Point of intersection, in world coordinates */
19
21
  point: Vector3;
20
22
  index?: number | undefined;
23
+ /** Intersected face */
21
24
  face?: Face | null | undefined;
25
+ /** Index of the intersected face */
22
26
  faceIndex?: number | undefined;
27
+ /** The intersected object */
23
28
  object: TIntersected;
24
29
  uv?: Vector2 | undefined;
25
30
  uv2?: Vector2 | undefined;
31
+ /** The index number of the instance where the ray intersects the {@link THREE.InstancedMesh | InstancedMesh } */
26
32
  instanceId?: number | undefined;
27
33
  }
28
34
 
@@ -34,52 +40,105 @@ export interface RaycasterParameters {
34
40
  Sprite?: any;
35
41
  }
36
42
 
43
+ /**
44
+ * This class is designed to assist with {@link https://en.wikipedia.org/wiki/Ray_casting | raycasting}
45
+ * @remarks
46
+ * Raycasting is used for mouse picking (working out what objects in the 3d space the mouse is over) amongst other things.
47
+ * @example
48
+ * ```typescript
49
+ * const raycaster = new THREE.Raycaster();
50
+ * const pointer = new THREE.Vector2();
51
+ *
52
+ * function onPointerMove(event) {
53
+ * // calculate pointer position in normalized device coordinates (-1 to +1) for both components
54
+ * pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
55
+ * pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
56
+ * }
57
+ *
58
+ * function render() {
59
+ * // update the picking ray with the camera and pointer position
60
+ * raycaster.setFromCamera(pointer, camera);
61
+ * // calculate objects intersecting the picking ray
62
+ * const intersects = raycaster.intersectObjects(scene.children);
63
+ * for (let i = 0; i & lt; intersects.length; i++) {
64
+ * intersects[i].object.material.color.set(0xff0000);
65
+ * }
66
+ * renderer.render(scene, camera);
67
+ * }
68
+ * window.addEventListener('pointermove', onPointerMove);
69
+ * window.requestAnimationFrame(render);
70
+ * ```
71
+ * @see Example: {@link https://threejs.org/examples/#webgl_interactive_cubes | Raycasting to a Mesh}
72
+ * @see Example: {@link https://threejs.org/examples/#webgl_interactive_cubes_ortho | Raycasting to a Mesh in using an OrthographicCamera}
73
+ * @see Example: {@link https://threejs.org/examples/#webgl_interactive_buffergeometry | Raycasting to a Mesh with BufferGeometry}
74
+ * @see Example: {@link https://threejs.org/examples/#webgl_instancing_raycast | Raycasting to a InstancedMesh}
75
+ * @see Example: {@link https://threejs.org/examples/#webgl_interactive_lines | Raycasting to a Line}
76
+ * @see Example: {@link https://threejs.org/examples/#webgl_interactive_raycasting_points | Raycasting to Points}
77
+ * @see Example: {@link https://threejs.org/examples/#webgl_geometry_terrain_raycast | Terrain raycasting}
78
+ * @see Example: {@link https://threejs.org/examples/#webgl_interactive_voxelpainter | Raycasting to paint voxels}
79
+ * @see Example: {@link https://threejs.org/examples/#webgl_raycaster_texture | Raycast to a Texture}
80
+ * @see {@link https://threejs.org/docs/index.html#api/en/core/Raycaster | Official Documentation}
81
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js | Source}
82
+ */
37
83
  export class Raycaster {
38
84
  /**
39
- * This creates a new raycaster object.
40
- * @param origin The origin vector where the ray casts from.
41
- * @param direction The direction vector that gives direction to the ray. Should be normalized.
42
- * @param near All results returned are further away than near. Near can't be negative. Default value is 0.
43
- * @param far All results returned are closer then far. Far can't be lower then near . Default value is Infinity.
85
+ * This creates a new {@link Raycaster} object.
86
+ * @param origin The origin vector where the ray casts from. Default `new Vector3()`
87
+ * @param direction The direction vector that gives direction to the ray. Should be normalized. Default `new Vector3(0, 0, -1)`
88
+ * @param near All results returned are further away than near. Near can't be negative. Expects a `Float`. Default `0`
89
+ * @param far All results returned are closer than far. Far can't be lower than near. Expects a `Float`. Default `Infinity`
44
90
  */
45
91
  constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number);
46
92
 
47
- /** The Ray used for the raycasting. */
93
+ /**
94
+ * The {@link THREE.RaycasterRay | Ray} used for the raycasting.
95
+ */
48
96
  ray: Ray;
49
97
 
50
98
  /**
51
- * The near factor of the raycaster. This value indicates which objects can be discarded based on the
52
- * distance. This value shouldn't be negative and should be smaller than the far property.
53
- * @default 0
99
+ * The near factor of the raycaster. This value indicates which objects can be discarded based on the distance.
100
+ * This value shouldn't be negative and should be smaller than the far property.
101
+ * @remarks Expects a `Float`
102
+ * @defaultValue `0`
54
103
  */
55
104
  near: number;
56
105
 
57
106
  /**
58
- * The far factor of the raycaster. This value indicates which objects can be discarded based on the
59
- * distance. This value shouldn't be negative and should be larger than the near property.
60
- * @default Infinity
107
+ * The far factor of the raycaster. This value indicates which objects can be discarded based on the distance.
108
+ * This value shouldn't be negative and should be larger than the near property.
109
+ * @remarks Expects a `Float`
110
+ * @defaultValue `Infinity`
61
111
  */
62
112
  far: number;
63
113
 
64
114
  /**
65
- * The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field
66
- * can be set manually or is set when calling "setFromCamera".
115
+ * The camera to use when raycasting against view-dependent objects such as billboarded objects like {@link THREE.Sprites | Sprites}.
116
+ * This field can be set manually or is set when calling {@link setFromCamera}.
117
+ * @defaultValue `null`
67
118
  */
68
119
  camera: Camera;
69
120
 
70
121
  /**
71
- * Used by Raycaster to selectively ignore 3D objects when performing intersection tests.
72
- * @default new THREE.Layers()
122
+ * Used by {@link Raycaster} to selectively ignore 3D objects when performing intersection tests.
123
+ * The following code example ensures that only 3D objects on layer `1` will be honored by the instance of Raycaster.
124
+ * ```
125
+ * raycaster.layers.set( 1 );
126
+ * object.layers.enable( 1 );
127
+ * ```
128
+ * @defaultValue `new THREE.Layers()` - See {@link THREE.Layers | Layers}.
73
129
  */
74
130
  layers: Layers;
75
131
 
76
132
  /**
77
- * @default { Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} }
133
+ * An data object where threshold is the precision of the {@link Raycaster} when intersecting objects, in world units.
134
+ * @defaultValue `{ Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} }`
78
135
  */
79
136
  params: RaycasterParameters;
80
137
 
81
138
  /**
82
- * Updates the ray with a new origin and direction.
139
+ * Updates the ray with a new origin and direction
140
+ * @remarks
141
+ * Please note that this method only copies the values from the arguments.
83
142
  * @param origin The origin vector where the ray casts from.
84
143
  * @param direction The normalized direction vector that gives direction to the ray.
85
144
  */
@@ -90,13 +149,22 @@ export class Raycaster {
90
149
  * @param coords 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1.
91
150
  * @param camera camera from which the ray should originate
92
151
  */
93
- setFromCamera(coords: { x: number; y: number }, camera: Camera): void;
152
+ setFromCamera(coords: Vector2, camera: Camera): void;
94
153
 
95
154
  /**
96
- * Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first.
155
+ * Checks all intersection between the ray and the object with or without the descendants
156
+ * @remarks Intersections are returned sorted by distance, closest first
157
+ * @remarks {@link Raycaster} delegates to the {@link Object3D.raycast | raycast} method of the passed object, when evaluating whether the ray intersects the object or not
158
+ * This allows {@link THREE.Mesh | meshes} to respond differently to ray casting than {@link THREE.Line | lines} and {@link THREE.Points | pointclouds}.
159
+ * **Note** that for meshes, faces must be pointed towards the origin of the {@link Raycaster.ray | ray} in order to be detected;
160
+ * intersections of the ray passing through the back of a face will not be detected
161
+ * To raycast against both faces of an object, you'll want to set the {@link Mesh.material | material}'s {@link Material.side | side} property to `THREE.DoubleSide`.
162
+ * @see {@link intersectObjects | .intersectObjects()}.
97
163
  * @param object The object to check for intersection with the ray.
98
- * @param recursive If true, it also checks all descendants. Otherwise it only checks intersecton with the object. Default is true.
99
- * @param optionalTarget (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
164
+ * @param recursive If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default `true`
165
+ * @param optionalTarget Target to set the result. Otherwise a new {@link Array | Array} is instantiated.
166
+ * If set, you must clear this array prior to each call (i.e., array.length = 0;). Default `[]`
167
+ * @returns An array of intersections is returned.
100
168
  */
101
169
  intersectObject<TIntersected extends Object3D>(
102
170
  object: Object3D,
@@ -105,12 +173,20 @@ export class Raycaster {
105
173
  ): Array<Intersection<TIntersected>>;
106
174
 
107
175
  /**
108
- * Checks all intersection between the ray and the objects with or without the descendants.
109
- * Intersections are returned sorted by distance, closest first.
110
- * Intersections are of the same form as those returned by .intersectObject.
176
+ * Checks all intersection between the ray and the objects with or without the descendants
177
+ * @remarks Intersections are returned sorted by distance, closest first
178
+ * @remarks Intersections are of the same form as those returned by {@link intersectObject | .intersectObject()}.
179
+ * @remarks {@link Raycaster} delegates to the {@link Object3D.raycast | raycast} method of the passed object, when evaluating whether the ray intersects the object or not
180
+ * This allows {@link THREE.Mesh | meshes} to respond differently to ray casting than {@link THREE.Line | lines} and {@link THREE.Points | pointclouds}.
181
+ * **Note** that for meshes, faces must be pointed towards the origin of the {@link Raycaster.ray | ray} in order to be detected;
182
+ * intersections of the ray passing through the back of a face will not be detected
183
+ * To raycast against both faces of an object, you'll want to set the {@link Mesh.material | material}'s {@link Material.side | side} property to `THREE.DoubleSide`.
184
+ * @see {@link intersectObject | .intersectObject()}.
111
185
  * @param objects The objects to check for intersection with the ray.
112
- * @param recursive If true, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects. Default is true.
113
- * @param optionalTarget (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
186
+ * @param recursive If true, it also checks all descendants of the objects. Otherwise it only checks intersection with the objects. Default `true`
187
+ * @param optionalTarget Target to set the result. Otherwise a new {@link Array | Array} is instantiated.
188
+ * If set, you must clear this array prior to each call (i.e., array.length = 0;). Default `[]`
189
+ * @returns An array of intersections is returned.
114
190
  */
115
191
  intersectObjects<TIntersected extends Object3D>(
116
192
  objects: Object3D[],
@@ -1,21 +1,38 @@
1
+ /**
2
+ * Uniforms are global GLSL variables.
3
+ * They are passed to shader programs.
4
+ * @example
5
+ * When declaring a uniform of a {@link THREE.ShaderMaterial | ShaderMaterial}, it is declared by value or by object.
6
+ * ```typescript
7
+ * uniforms: {
8
+ * time: {
9
+ * value: 1.0
10
+ * },
11
+ * resolution: new Uniform(new Vector2())
12
+ * };
13
+ * ```
14
+ * @see Example: {@link https://threejs.org/examples/#webgl_nodes_materials_instance_uniform | WebGL2 / nodes / materials / instance / uniform}
15
+ * @see Example: {@link https://threejs.org/examples/#webgpu_instance_uniform| WebGPU / instance / uniform}
16
+ * @see {@link https://threejs.org/docs/index.html#api/en/core/Uniform | Official Documentation}
17
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Uniform.js | Source}
18
+ */
1
19
  export class Uniform<T = any> {
2
- constructor(value: T);
3
20
  /**
4
- * @deprecated
21
+ * Create a new instance of {@link THREE.Uniform | Uniform}
22
+ * @param value An object containing the value to set up the uniform. It's type must be one of the Uniform Types described above.
5
23
  */
6
- constructor(type: string, value: T);
24
+ constructor(value: T);
25
+
7
26
  /**
8
- * @deprecated
27
+ * Current value of the uniform.
9
28
  */
10
- type: string;
11
29
  value: T;
12
- /**
13
- * @deprecated Use {@link Object3D#onBeforeRender object.onBeforeRender()} instead.
14
- */
15
- dynamic: boolean;
16
30
 
17
31
  /**
18
- * @deprecated Use {@link Object3D#onBeforeRender object.onBeforeRender()} instead.
32
+ * Returns a clone of this uniform.
33
+ * @remarks
34
+ * If the uniform's {@link value} property is an {@link Object | Object} with a `clone()` method, this is used,
35
+ * otherwise the value is copied by assignment Array values are **shared** between cloned {@link THREE.UniformUniform | Uniform}s.
19
36
  */
20
- onUpdate(callback: () => void): Uniform<T>;
37
+ clone(): Uniform<T>;
21
38
  }
@@ -1,15 +1,21 @@
1
1
  import { EventDispatcher } from './EventDispatcher';
2
2
  import { Uniform } from './Uniform';
3
-
4
3
  import { Usage } from '../constants';
5
4
 
5
+ /**
6
+ * @see Example: {@link https://threejs.org/examples/#webgl2_ubo | WebGL2 / UBO}
7
+ * @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/UniformsGroup.js | Source}
8
+ */
6
9
  export class UniformsGroup extends EventDispatcher {
7
- isUniformsGroup: true;
10
+ constructor();
11
+
12
+ readonly isUniformsGroup: true;
13
+
8
14
  id: number;
15
+
9
16
  usage: Usage;
10
- uniforms: Uniform[];
11
17
 
12
- constructor();
18
+ uniforms: Uniform[];
13
19
 
14
20
  add(uniform: Uniform): this;
15
21
 
@@ -1,4 +1,3 @@
1
- import { Triangle } from '../Three';
2
- export namespace Earcut {
3
- function triangulate(data: number[], holeIndices: number[], dim: number): Triangle[];
4
- }
1
+ export const Earcut: {
2
+ triangulate(data: number[], holeIndices?: number[], dim?: number): number[];
3
+ };
@@ -16,10 +16,16 @@ export interface MeshPhysicalMaterialParameters extends MeshStandardMaterialPara
16
16
 
17
17
  sheen?: number | undefined;
18
18
  sheenColor?: Color | undefined;
19
+ sheenColorMap?: Texture | null | undefined;
19
20
  sheenRoughness?: number | undefined;
21
+ sheenRoughnessMap?: Texture | null | undefined;
20
22
 
21
23
  transmission?: number | undefined;
22
24
  transmissionMap?: Texture | null | undefined;
25
+
26
+ thickness?: number | undefined;
27
+ thicknessMap?: Texture | null | undefined;
28
+
23
29
  attenuationDistance?: number | undefined;
24
30
  attenuationColor?: Color | undefined;
25
31
 
@@ -27,6 +33,12 @@ export interface MeshPhysicalMaterialParameters extends MeshStandardMaterialPara
27
33
  specularColor?: Color | undefined;
28
34
  specularIntensityMap?: Texture | null | undefined;
29
35
  specularColorMap?: Texture | null | undefined;
36
+
37
+ iridescenceMap?: Texture | null | undefined;
38
+ iridescenceIOR?: number | undefined;
39
+ iridescence?: number | undefined;
40
+ iridescenceThicknessRange?: [number, number] | undefined;
41
+ iridescenceThicknessMap?: Texture | null | undefined;
30
42
  }
31
43
 
32
44
  export class MeshPhysicalMaterial extends MeshStandardMaterial {
@@ -175,7 +187,7 @@ export class MeshPhysicalMaterial extends MeshStandardMaterial {
175
187
  /**
176
188
  * @default [100, 400]
177
189
  */
178
- iridescenceThicknessRange: number[];
190
+ iridescenceThicknessRange: [number, number];
179
191
 
180
192
  /**
181
193
  * @default null
three/src/math/Color.d.ts CHANGED
@@ -2,9 +2,163 @@ import { ColorSpace } from '../constants';
2
2
  import { ColorRepresentation } from '../utils';
3
3
 
4
4
  import { BufferAttribute } from './../core/BufferAttribute';
5
+ import { InterleavedBufferAttribute } from './../core/InterleavedBufferAttribute';
5
6
 
6
7
  export { SRGBToLinear } from './ColorManagement';
7
8
 
9
+ declare const _colorKeywords: {
10
+ aliceblue: 0xf0f8ff;
11
+ antiquewhite: 0xfaebd7;
12
+ aqua: 0x00ffff;
13
+ aquamarine: 0x7fffd4;
14
+ azure: 0xf0ffff;
15
+ beige: 0xf5f5dc;
16
+ bisque: 0xffe4c4;
17
+ black: 0x000000;
18
+ blanchedalmond: 0xffebcd;
19
+ blue: 0x0000ff;
20
+ blueviolet: 0x8a2be2;
21
+ brown: 0xa52a2a;
22
+ burlywood: 0xdeb887;
23
+ cadetblue: 0x5f9ea0;
24
+ chartreuse: 0x7fff00;
25
+ chocolate: 0xd2691e;
26
+ coral: 0xff7f50;
27
+ cornflowerblue: 0x6495ed;
28
+ cornsilk: 0xfff8dc;
29
+ crimson: 0xdc143c;
30
+ cyan: 0x00ffff;
31
+ darkblue: 0x00008b;
32
+ darkcyan: 0x008b8b;
33
+ darkgoldenrod: 0xb8860b;
34
+ darkgray: 0xa9a9a9;
35
+ darkgreen: 0x006400;
36
+ darkgrey: 0xa9a9a9;
37
+ darkkhaki: 0xbdb76b;
38
+ darkmagenta: 0x8b008b;
39
+ darkolivegreen: 0x556b2f;
40
+ darkorange: 0xff8c00;
41
+ darkorchid: 0x9932cc;
42
+ darkred: 0x8b0000;
43
+ darksalmon: 0xe9967a;
44
+ darkseagreen: 0x8fbc8f;
45
+ darkslateblue: 0x483d8b;
46
+ darkslategray: 0x2f4f4f;
47
+ darkslategrey: 0x2f4f4f;
48
+ darkturquoise: 0x00ced1;
49
+ darkviolet: 0x9400d3;
50
+ deeppink: 0xff1493;
51
+ deepskyblue: 0x00bfff;
52
+ dimgray: 0x696969;
53
+ dimgrey: 0x696969;
54
+ dodgerblue: 0x1e90ff;
55
+ firebrick: 0xb22222;
56
+ floralwhite: 0xfffaf0;
57
+ forestgreen: 0x228b22;
58
+ fuchsia: 0xff00ff;
59
+ gainsboro: 0xdcdcdc;
60
+ ghostwhite: 0xf8f8ff;
61
+ gold: 0xffd700;
62
+ goldenrod: 0xdaa520;
63
+ gray: 0x808080;
64
+ green: 0x008000;
65
+ greenyellow: 0xadff2f;
66
+ grey: 0x808080;
67
+ honeydew: 0xf0fff0;
68
+ hotpink: 0xff69b4;
69
+ indianred: 0xcd5c5c;
70
+ indigo: 0x4b0082;
71
+ ivory: 0xfffff0;
72
+ khaki: 0xf0e68c;
73
+ lavender: 0xe6e6fa;
74
+ lavenderblush: 0xfff0f5;
75
+ lawngreen: 0x7cfc00;
76
+ lemonchiffon: 0xfffacd;
77
+ lightblue: 0xadd8e6;
78
+ lightcoral: 0xf08080;
79
+ lightcyan: 0xe0ffff;
80
+ lightgoldenrodyellow: 0xfafad2;
81
+ lightgray: 0xd3d3d3;
82
+ lightgreen: 0x90ee90;
83
+ lightgrey: 0xd3d3d3;
84
+ lightpink: 0xffb6c1;
85
+ lightsalmon: 0xffa07a;
86
+ lightseagreen: 0x20b2aa;
87
+ lightskyblue: 0x87cefa;
88
+ lightslategray: 0x778899;
89
+ lightslategrey: 0x778899;
90
+ lightsteelblue: 0xb0c4de;
91
+ lightyellow: 0xffffe0;
92
+ lime: 0x00ff00;
93
+ limegreen: 0x32cd32;
94
+ linen: 0xfaf0e6;
95
+ magenta: 0xff00ff;
96
+ maroon: 0x800000;
97
+ mediumaquamarine: 0x66cdaa;
98
+ mediumblue: 0x0000cd;
99
+ mediumorchid: 0xba55d3;
100
+ mediumpurple: 0x9370db;
101
+ mediumseagreen: 0x3cb371;
102
+ mediumslateblue: 0x7b68ee;
103
+ mediumspringgreen: 0x00fa9a;
104
+ mediumturquoise: 0x48d1cc;
105
+ mediumvioletred: 0xc71585;
106
+ midnightblue: 0x191970;
107
+ mintcream: 0xf5fffa;
108
+ mistyrose: 0xffe4e1;
109
+ moccasin: 0xffe4b5;
110
+ navajowhite: 0xffdead;
111
+ navy: 0x000080;
112
+ oldlace: 0xfdf5e6;
113
+ olive: 0x808000;
114
+ olivedrab: 0x6b8e23;
115
+ orange: 0xffa500;
116
+ orangered: 0xff4500;
117
+ orchid: 0xda70d6;
118
+ palegoldenrod: 0xeee8aa;
119
+ palegreen: 0x98fb98;
120
+ paleturquoise: 0xafeeee;
121
+ palevioletred: 0xdb7093;
122
+ papayawhip: 0xffefd5;
123
+ peachpuff: 0xffdab9;
124
+ peru: 0xcd853f;
125
+ pink: 0xffc0cb;
126
+ plum: 0xdda0dd;
127
+ powderblue: 0xb0e0e6;
128
+ purple: 0x800080;
129
+ rebeccapurple: 0x663399;
130
+ red: 0xff0000;
131
+ rosybrown: 0xbc8f8f;
132
+ royalblue: 0x4169e1;
133
+ saddlebrown: 0x8b4513;
134
+ salmon: 0xfa8072;
135
+ sandybrown: 0xf4a460;
136
+ seagreen: 0x2e8b57;
137
+ seashell: 0xfff5ee;
138
+ sienna: 0xa0522d;
139
+ silver: 0xc0c0c0;
140
+ skyblue: 0x87ceeb;
141
+ slateblue: 0x6a5acd;
142
+ slategray: 0x708090;
143
+ slategrey: 0x708090;
144
+ snow: 0xfffafa;
145
+ springgreen: 0x00ff7f;
146
+ steelblue: 0x4682b4;
147
+ tan: 0xd2b48c;
148
+ teal: 0x008080;
149
+ thistle: 0xd8bfd8;
150
+ tomato: 0xff6347;
151
+ turquoise: 0x40e0d0;
152
+ violet: 0xee82ee;
153
+ wheat: 0xf5deb3;
154
+ white: 0xffffff;
155
+ whitesmoke: 0xf5f5f5;
156
+ yellow: 0xffff00;
157
+ yellowgreen: 0x9acd32;
158
+ };
159
+
160
+ export type ColorKeyword = keyof typeof _colorKeywords;
161
+
8
162
  export interface HSL {
9
163
  h: number;
10
164
  s: number;
@@ -82,7 +236,7 @@ export class Color {
82
236
  * Faster than {@link Color#setStyle .setStyle()} method if you don't need the other CSS-style formats.
83
237
  * @param style Color name in X11 format.
84
238
  */
85
- setColorName(style: string, colorSpace?: ColorSpace): Color;
239
+ setColorName(style: ColorKeyword, colorSpace?: ColorSpace): Color;
86
240
 
87
241
  /**
88
242
  * Clones this color.
@@ -173,12 +327,12 @@ export class Color {
173
327
  */
174
328
  toArray(xyz: ArrayLike<number>, offset?: number): ArrayLike<number>;
175
329
 
176
- fromBufferAttribute(attribute: BufferAttribute, index: number): this;
330
+ fromBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, index: number): this;
177
331
 
178
332
  [Symbol.iterator](): Generator<number, void>;
179
333
 
180
334
  /**
181
335
  * List of X11 color names.
182
336
  */
183
- static NAMES: Record<string, number>;
337
+ static NAMES: typeof _colorKeywords;
184
338
  }
@@ -1,4 +1,4 @@
1
- import { ColorSpace, LinearSRGBColorSpace, SRGBColorSpace } from '../constants';
1
+ import { ColorSpace, DisplayP3ColorSpace, LinearSRGBColorSpace, SRGBColorSpace } from '../constants';
2
2
  import { Color } from './Color';
3
3
 
4
4
  export function SRGBToLinear(c: number): number;
@@ -7,9 +7,9 @@ export function LinearToSRGB(c: number): number;
7
7
 
8
8
  export namespace ColorManagement {
9
9
  /**
10
- * @default true
10
+ * @default false
11
11
  */
12
- let legacyMode: boolean;
12
+ let enabled: boolean;
13
13
 
14
14
  /**
15
15
  * @default LinearSRGBColorSpace
@@ -18,11 +18,17 @@ export namespace ColorManagement {
18
18
 
19
19
  function convert(
20
20
  color: Color,
21
- sourceColorSpace: SRGBColorSpace | LinearSRGBColorSpace,
22
- targetColorSpace: SRGBColorSpace | LinearSRGBColorSpace,
21
+ sourceColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace | typeof DisplayP3ColorSpace,
22
+ targetColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace | typeof DisplayP3ColorSpace,
23
23
  ): Color;
24
24
 
25
- function fromWorkingColorSpace(color: Color, targetColorSpace: SRGBColorSpace | LinearSRGBColorSpace): Color;
25
+ function fromWorkingColorSpace(
26
+ color: Color,
27
+ targetColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace,
28
+ ): Color;
26
29
 
27
- function toWorkingColorSpace(color: Color, sourceColorSpace: SRGBColorSpace | LinearSRGBColorSpace): Color;
30
+ function toWorkingColorSpace(
31
+ color: Color,
32
+ sourceColorSpace: typeof SRGBColorSpace | typeof LinearSRGBColorSpace,
33
+ ): Color;
28
34
  }
@@ -178,9 +178,9 @@ export class WebGLRenderer implements Renderer {
178
178
  outputEncoding: TextureEncoding;
179
179
 
180
180
  /**
181
- * @default false
181
+ * @default true
182
182
  */
183
- physicallyCorrectLights: boolean;
183
+ useLegacyLights: boolean;
184
184
 
185
185
  /**
186
186
  * @default THREE.NoToneMapping
three/src/utils.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- import { Color } from './math/Color';
1
+ import { Color, ColorKeyword } from './math/Color';
2
2
 
3
- export type ColorRepresentation = Color | string | number;
3
+ export type ColorModelString = `${'rgb' | 'hsl'}(${string})`;
4
+ export type HexColorString = `#${string}`;
5
+
6
+ export type ColorRepresentation = Color | ColorKeyword | ColorModelString | HexColorString | number;