@types/three 0.184.1 → 0.185.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 (205) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/Addons.d.ts +2 -0
  3. three/examples/jsm/controls/FirstPersonControls.d.ts +9 -0
  4. three/examples/jsm/controls/OrbitControls.d.ts +2 -2
  5. three/examples/jsm/controls/TransformControls.d.ts +32 -1
  6. three/examples/jsm/csm/CSMFrustum.d.ts +73 -13
  7. three/examples/jsm/exporters/DRACOExporter.d.ts +1 -1
  8. three/examples/jsm/exporters/GLTFExporter.d.ts +2 -2
  9. three/examples/jsm/exporters/PLYExporter.d.ts +5 -4
  10. three/examples/jsm/exporters/USDZExporter.d.ts +5 -1
  11. three/examples/jsm/generators/CityGenerator.d.ts +75 -0
  12. three/examples/jsm/generators/ForestGenerator.d.ts +79 -0
  13. three/examples/jsm/generators/TerrainGenerator.d.ts +67 -0
  14. three/examples/jsm/generators/TreeGenerator.d.ts +97 -0
  15. three/examples/jsm/generators/city/SidewalkGenerator.d.ts +40 -0
  16. three/examples/jsm/generators/city/SkyscraperGenerator.d.ts +83 -0
  17. three/examples/jsm/geometries/LoftGeometry.d.ts +83 -0
  18. three/examples/jsm/inspector/tabs/Parameters.d.ts +5 -2
  19. three/examples/jsm/lighting/ClusteredLighting.d.ts +45 -0
  20. three/examples/jsm/lighting/LightProbeGrid.d.ts +131 -13
  21. three/examples/jsm/loaders/DRACOLoader.d.ts +20 -6
  22. three/examples/jsm/loaders/EXRLoader.d.ts +2 -12
  23. three/examples/jsm/loaders/GLTFLoader.d.ts +1 -1
  24. three/examples/jsm/loaders/HDRLoader.d.ts +2 -12
  25. three/examples/jsm/loaders/KTX2Loader.d.ts +1 -1
  26. three/examples/jsm/loaders/LWOLoader.d.ts +6 -0
  27. three/examples/jsm/loaders/RGBELoader.d.ts +1 -7
  28. three/examples/jsm/loaders/SVGLoader.d.ts +9 -6
  29. three/examples/jsm/loaders/TGALoader.d.ts +2 -2
  30. three/examples/jsm/loaders/TIFFLoader.d.ts +2 -11
  31. three/examples/jsm/loaders/USDLoader.d.ts +6 -1
  32. three/examples/jsm/misc/TileCreasedNormalsPlugin.d.ts +49 -0
  33. three/examples/jsm/objects/MarchingCubes.d.ts +2 -2
  34. three/examples/jsm/objects/Reflector.d.ts +38 -5
  35. three/examples/jsm/objects/SkyMesh.d.ts +1 -1
  36. three/examples/jsm/physics/RapierPhysics.d.ts +1 -0
  37. three/examples/jsm/tsl/display/BloomNode.d.ts +23 -6
  38. three/examples/jsm/tsl/display/ImportanceSampledEnvironment.d.ts +84 -0
  39. three/examples/jsm/tsl/display/RecurrentDenoiseNode.d.ts +89 -0
  40. three/examples/jsm/tsl/display/SSAAPassNode.d.ts +0 -2
  41. three/examples/jsm/tsl/display/SSGINode.d.ts +4 -1
  42. three/examples/jsm/tsl/display/SSRNode.d.ts +303 -30
  43. three/examples/jsm/tsl/display/TRAANode.d.ts +1 -1
  44. three/examples/jsm/tsl/display/TemporalReprojectNode.d.ts +64 -0
  45. three/examples/jsm/tsl/lighting/ClusteredLightsNode.d.ts +54 -0
  46. three/examples/jsm/tsl/math/curlNoise.d.ts +38 -0
  47. three/examples/jsm/tsl/utils/GroundedSkybox.d.ts +17 -0
  48. three/examples/jsm/tsl/utils/RNoise.d.ts +12 -0
  49. three/examples/jsm/tsl/utils/SpecularHelpers.d.ts +20 -0
  50. three/examples/jsm/webxr/WebGLXRFallback.d.ts +14 -0
  51. three/package.json +3 -3
  52. three/src/Three.TSL.d.ts +10 -3
  53. three/src/Three.WebGPU.Nodes.d.ts +2 -2
  54. three/src/Three.WebGPU.d.ts +5 -3
  55. three/src/animation/AnimationClip.d.ts +0 -10
  56. three/src/cameras/Camera.d.ts +1 -1
  57. three/src/core/InterleavedBuffer.d.ts +1 -1
  58. three/src/core/Object3D.d.ts +8 -4
  59. three/src/core/RenderTarget.d.ts +11 -0
  60. three/src/core/Timer.d.ts +1 -1
  61. three/src/core/UniformsGroup.d.ts +1 -1
  62. three/src/extras/Controls.d.ts +6 -5
  63. three/src/extras/core/ShapePath.d.ts +61 -65
  64. three/src/loaders/DataTextureLoader.d.ts +37 -3
  65. three/src/loaders/MaterialLoader.d.ts +8 -0
  66. three/src/materials/LineBasicMaterial.d.ts +5 -0
  67. three/src/materials/Material.d.ts +9 -1
  68. three/src/materials/MeshBasicMaterial.d.ts +30 -0
  69. three/src/materials/MeshDepthMaterial.d.ts +13 -0
  70. three/src/materials/MeshDistanceMaterial.d.ts +13 -0
  71. three/src/materials/MeshLambertMaterial.d.ts +50 -1
  72. three/src/materials/MeshMatcapMaterial.d.ts +31 -1
  73. three/src/materials/MeshNormalMaterial.d.ts +11 -1
  74. three/src/materials/MeshPhongMaterial.d.ts +50 -1
  75. three/src/materials/MeshPhysicalMaterial.d.ts +50 -0
  76. three/src/materials/MeshStandardMaterial.d.ts +53 -1
  77. three/src/materials/MeshToonMaterial.d.ts +43 -1
  78. three/src/materials/PointsMaterial.d.ts +9 -0
  79. three/src/materials/ShaderMaterial.d.ts +2 -0
  80. three/src/materials/SpriteMaterial.d.ts +9 -0
  81. three/src/materials/nodes/Line2NodeMaterial.d.ts +18 -13
  82. three/src/materials/nodes/NodeMaterial.d.ts +33 -13
  83. three/src/materials/nodes/manager/NodeMaterialObserver.d.ts +0 -84
  84. three/src/math/Box2.d.ts +3 -3
  85. three/src/math/Box3.d.ts +255 -19
  86. three/src/math/Color.d.ts +10 -10
  87. three/src/math/FrustumArray.d.ts +75 -16
  88. three/src/math/Interpolant.d.ts +111 -8
  89. three/src/math/Matrix3.d.ts +9 -0
  90. three/src/math/Matrix4.d.ts +329 -105
  91. three/src/math/Vector3.d.ts +2 -2
  92. three/src/math/interpolants/BezierInterpolant.d.ts +19 -3
  93. three/src/math/interpolants/CubicInterpolant.d.ts +18 -3
  94. three/src/math/interpolants/DiscreteInterpolant.d.ts +8 -3
  95. three/src/math/interpolants/LinearInterpolant.d.ts +7 -3
  96. three/src/math/interpolants/QuaternionLinearInterpolant.d.ts +7 -3
  97. three/src/nodes/Nodes.d.ts +4 -13
  98. three/src/nodes/TSL.d.ts +7 -5
  99. three/src/nodes/accessors/Batch.d.ts +19 -0
  100. three/src/nodes/accessors/Instance.d.ts +34 -0
  101. three/src/nodes/accessors/MaterialNode.d.ts +86 -79
  102. three/src/nodes/accessors/Morph.d.ts +11 -0
  103. three/src/nodes/accessors/Skinning.d.ts +23 -0
  104. three/src/nodes/accessors/StorageBufferNode.d.ts +22 -23
  105. three/src/nodes/accessors/StorageTexture3DNode.d.ts +17 -0
  106. three/src/nodes/accessors/StorageTextureNode.d.ts +6 -4
  107. three/src/nodes/accessors/TextureNode.d.ts +15 -10
  108. three/src/nodes/core/ArrayNode.d.ts +16 -8
  109. three/src/nodes/core/ContextNode.d.ts +5 -6
  110. three/src/nodes/core/LightingModel.d.ts +2 -0
  111. three/src/nodes/core/Node.d.ts +50 -51
  112. three/src/nodes/core/NodeBuilder.d.ts +1 -133
  113. three/src/nodes/core/OverrideContextNode.d.ts +92 -0
  114. three/src/nodes/core/PropertyNode.d.ts +13 -2
  115. three/src/nodes/core/StructNode.d.ts +0 -2
  116. three/src/nodes/core/StructTypeNode.d.ts +5 -4
  117. three/src/nodes/core/UniformNode.d.ts +48 -9
  118. three/src/nodes/display/BlendModes.d.ts +72 -11
  119. three/src/nodes/display/FrontFacingNode.d.ts +62 -3
  120. three/src/nodes/display/PassNode.d.ts +0 -2
  121. three/src/nodes/display/PremultiplyAlphaFunctions.d.ts +37 -0
  122. three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +53 -45
  123. three/src/nodes/lighting/LightingContextNode.d.ts +9 -2
  124. three/src/nodes/lighting/LightsNode.d.ts +4 -4
  125. three/src/nodes/math/MathNode.d.ts +358 -304
  126. three/src/nodes/math/OperatorNode.d.ts +253 -82
  127. three/src/nodes/tsl/TSLCore.d.ts +16 -9
  128. three/src/nodes/utils/ArrayElementNode.d.ts +5 -4
  129. three/src/nodes/utils/EquirectUV.d.ts +31 -1
  130. three/src/nodes/utils/Packing.d.ts +50 -3
  131. three/src/nodes/utils/RTTNode.d.ts +7 -12
  132. three/src/nodes/utils/Remap.d.ts +216 -29
  133. three/src/nodes/utils/SampleNode.d.ts +18 -8
  134. three/src/objects/BatchedMesh.d.ts +1 -1
  135. three/src/objects/InstancedMesh.d.ts +0 -8
  136. three/src/objects/Skeleton.d.ts +0 -2
  137. three/src/renderers/common/Backend.d.ts +0 -3
  138. three/src/renderers/common/CanvasTarget.d.ts +0 -49
  139. three/src/renderers/common/ClippingContext.d.ts +6 -1
  140. three/src/renderers/common/CubeRenderTarget.d.ts +2 -1
  141. three/src/renderers/common/Info.d.ts +26 -66
  142. three/src/renderers/common/InspectorBase.d.ts +0 -7
  143. three/src/renderers/common/Lighting.d.ts +49 -5
  144. three/src/renderers/common/Renderer.d.ts +34 -458
  145. three/src/renderers/common/RendererUtils.d.ts +1 -2
  146. three/src/renderers/common/TimestampQueryPool.d.ts +1 -1
  147. three/src/renderers/common/XRManager.d.ts +32 -299
  148. three/src/renderers/common/nodes/NodeLibrary.d.ts +0 -117
  149. three/src/renderers/webgl/WebGLPrograms.d.ts +2 -0
  150. three/src/renderers/webgl/WebGLRenderLists.d.ts +5 -1
  151. three/src/renderers/webgl/WebGLState.d.ts +2 -0
  152. three/src/renderers/webgl-fallback/WebGLBackend.d.ts +1 -1
  153. three/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.d.ts +0 -10
  154. three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +0 -1
  155. three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +5 -121
  156. three/src/textures/CubeDepthTexture.d.ts +2 -3
  157. three/src/textures/DataTexture.d.ts +2 -1
  158. three/src/textures/DepthTexture.d.ts +5 -5
  159. three/examples/jsm/lighting/TiledLighting.d.ts +0 -9
  160. three/examples/jsm/tsl/display/AnamorphicNode.d.ts +0 -31
  161. three/examples/jsm/tsl/lighting/TiledLightsNode.d.ts +0 -22
  162. three/src/nodes/accessors/BatchNode.d.ts +0 -12
  163. three/src/nodes/accessors/InstanceNode.d.ts +0 -30
  164. three/src/nodes/accessors/InstancedMeshNode.d.ts +0 -10
  165. three/src/nodes/accessors/MorphNode.d.ts +0 -14
  166. three/src/nodes/accessors/SkinningNode.d.ts +0 -32
  167. three/src/renderers/common/Animation.d.ts +0 -102
  168. three/src/renderers/common/Attributes.d.ts +0 -59
  169. three/src/renderers/common/Background.d.ts +0 -47
  170. three/src/renderers/common/BindGroup.d.ts +0 -39
  171. three/src/renderers/common/Binding.d.ts +0 -50
  172. three/src/renderers/common/Bindings.d.ts +0 -132
  173. three/src/renderers/common/Buffer.d.ts +0 -90
  174. three/src/renderers/common/ChainMap.d.ts +0 -49
  175. three/src/renderers/common/Color4.d.ts +0 -55
  176. three/src/renderers/common/ComputePipeline.d.ts +0 -34
  177. three/src/renderers/common/DataMap.d.ts +0 -42
  178. three/src/renderers/common/Geometries.d.ts +0 -111
  179. three/src/renderers/common/Pipeline.d.ts +0 -29
  180. three/src/renderers/common/Pipelines.d.ts +0 -186
  181. three/src/renderers/common/ProgrammableStage.d.ts +0 -73
  182. three/src/renderers/common/RenderBundle.d.ts +0 -25
  183. three/src/renderers/common/RenderBundles.d.ts +0 -34
  184. three/src/renderers/common/RenderContext.d.ts +0 -235
  185. three/src/renderers/common/RenderContexts.d.ts +0 -47
  186. three/src/renderers/common/RenderList.d.ts +0 -226
  187. three/src/renderers/common/RenderLists.d.ts +0 -46
  188. three/src/renderers/common/RenderObject.d.ts +0 -448
  189. three/src/renderers/common/RenderObjectPipeline.d.ts +0 -33
  190. three/src/renderers/common/RenderObjects.d.ts +0 -151
  191. three/src/renderers/common/SampledTexture.d.ts +0 -28
  192. three/src/renderers/common/Sampler.d.ts +0 -19
  193. three/src/renderers/common/Textures.d.ts +0 -125
  194. three/src/renderers/common/Uniform.d.ts +0 -262
  195. three/src/renderers/common/UniformBuffer.d.ts +0 -20
  196. three/src/renderers/common/UniformsGroup.d.ts +0 -152
  197. three/src/renderers/common/XRRenderTarget.d.ts +0 -67
  198. three/src/renderers/common/nodes/NodeBuilderState.d.ts +0 -121
  199. three/src/renderers/common/nodes/NodeManager.d.ts +0 -309
  200. three/src/renderers/common/nodes/NodeSampledTexture.d.ts +0 -29
  201. three/src/renderers/common/nodes/NodeSampler.d.ts +0 -12
  202. three/src/renderers/common/nodes/NodeUniform.d.ts +0 -250
  203. three/src/renderers/common/nodes/NodeUniformsGroup.d.ts +0 -41
  204. three/src/renderers/webgpu/nodes/WGSLNodeFunction.d.ts +0 -6
  205. three/src/renderers/webgpu/nodes/WGSLNodeParser.d.ts +0 -6
@@ -4,6 +4,7 @@ import LightingModel from "../../nodes/core/LightingModel.js";
4
4
  import MRTNode from "../../nodes/core/MRTNode.js";
5
5
  import Node from "../../nodes/core/Node.js";
6
6
  import NodeBuilder from "../../nodes/core/NodeBuilder.js";
7
+ import LightingNode from "../../nodes/lighting/LightingNode.js";
7
8
  import LightsNode from "../../nodes/lighting/LightsNode.js";
8
9
  import { MapColorPropertiesToColorRepresentations, Material, MaterialParameters } from "../Material.js";
9
10
  import NodeMaterialObserver from "./manager/NodeMaterialObserver.js";
@@ -21,14 +22,6 @@ export interface NodeMaterialNodeProperties {
21
22
  * @default false
22
23
  */
23
24
  lights: boolean;
24
- /**
25
- * Whether this material uses hardware clipping or not.
26
- * This property is managed by the engine and should not be
27
- * modified by apps.
28
- *
29
- * @default false
30
- */
31
- hardwareClipping: boolean;
32
25
  /**
33
26
  * Node materials which set their `lights` property to `true`
34
27
  * are affected by all lights of the scene. Sometimes selective
@@ -416,9 +409,16 @@ declare class NodeMaterial extends Material {
416
409
  * Setups the lights node based on the scene, environment and material.
417
410
  *
418
411
  * @param {NodeBuilder} builder - The current node builder.
419
- * @return {LightsNode} The lights node.
412
+ * @return {LightingNode<Array>} The lights node.
413
+ */
414
+ setupMaterialLightings(builder: NodeBuilder): LightingNode[];
415
+ /**
416
+ * Setups the ambient occlusion node from the material.
417
+ *
418
+ * @param {NodeBuilder} builder - The current node builder.
419
+ * @return {Node} The ambient occlusion node.
420
420
  */
421
- setupLights(builder: NodeBuilder): LightsNode;
421
+ setupAmbientOcclusion(builder: NodeBuilder): Node;
422
422
  /**
423
423
  * This method should be implemented by most derived materials
424
424
  * since it defines the material's lighting model.
@@ -454,6 +454,26 @@ declare class NodeMaterial extends Material {
454
454
  /**
455
455
  * Setups the output node.
456
456
  *
457
+ * This method can be implemented by derived materials to extend the functionality
458
+ * of the material's output or replace it altogether.
459
+ *
460
+ * ```js
461
+ * class ColoredShadowMaterial extends MeshPhongNodeMaterial {
462
+ * constructor( parameters ) {
463
+ * super( parameters );
464
+ * this._shadeColor = uniform( new Color( parameters.shadeColor ?? 0xff0000 ) );
465
+ * }
466
+ *
467
+ * setupOutput( builder, outputNode ) {
468
+ * // Modify the native output of the MeshPhongNodeMaterial fragment shader
469
+ * const brightness = min( outputNode.r, 1.0 );
470
+ * const mixedColor = mix( this._shadeColor, diffuseColor.rgb, brightness );
471
+ * // Return new output back into NodeMaterial flow
472
+ * return super.setupOutput( builder, vec4( mixedColor, outputNode.a ) );
473
+ * }
474
+ * }
475
+ * ```
476
+ *
457
477
  * @param {NodeBuilder} builder - The current node builder.
458
478
  * @param {Node<vec4>} outputNode - The existing output node.
459
479
  * @return {Node<vec4>} The output node.
@@ -468,12 +488,12 @@ declare class NodeMaterial extends Material {
468
488
  */
469
489
  setDefaultValues(material: Material): void;
470
490
  /**
471
- * Copies the properties of the given node material to this instance.
491
+ * Copies the common properties of the given material to this instance.
472
492
  *
473
- * @param {NodeMaterial} source - The material to copy.
493
+ * @param {Material} source - The material to copy.
474
494
  * @return {NodeMaterial} A reference to this node material.
475
495
  */
476
- copy(source: NodeMaterial): this;
496
+ copy(source: Material): this;
477
497
  }
478
498
 
479
499
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -1,12 +1,5 @@
1
- import { BufferAttribute } from "../../../core/BufferAttribute.js";
2
- import { BufferGeometry } from "../../../core/BufferGeometry.js";
3
- import { Light } from "../../../lights/Light.js";
4
1
  import NodeBuilder from "../../../nodes/core/NodeBuilder.js";
5
- import NodeFrame from "../../../nodes/core/NodeFrame.js";
6
- import LightsNode from "../../../nodes/lighting/LightsNode.js";
7
2
  import Renderer from "../../../renderers/common/Renderer.js";
8
- import RenderObject from "../../../renderers/common/RenderObject.js";
9
- import { Material } from "../../Material.js";
10
3
 
11
4
  /**
12
5
  * This class is used by {@link WebGPURenderer} as management component.
@@ -20,13 +13,6 @@ declare class NodeMaterialObserver {
20
13
  * @param {NodeBuilder} builder - The node builder.
21
14
  */
22
15
  constructor(builder: NodeBuilder);
23
- /**
24
- * A node material can be used by more than one render object so the
25
- * monitor must maintain a list of render objects.
26
- *
27
- * @type {WeakMap<RenderObject,Object>}
28
- */
29
- renderObjects: WeakMap<RenderObject, unknown>;
30
16
  /**
31
17
  * Whether the material uses node objects or not.
32
18
  *
@@ -52,13 +38,6 @@ declare class NodeMaterialObserver {
52
38
  * @default 0
53
39
  */
54
40
  renderId: number;
55
- /**
56
- * Returns `true` if the given render object is verified for the first time of this observer.
57
- *
58
- * @param {RenderObject} renderObject - The render object.
59
- * @return {boolean} Whether the given render object is verified for the first time of this observer.
60
- */
61
- firstInitialization(renderObject: RenderObject): boolean;
62
41
  /**
63
42
  * Returns `true` if the current rendering produces motion vectors.
64
43
  *
@@ -66,21 +45,6 @@ declare class NodeMaterialObserver {
66
45
  * @return {boolean} Whether the current rendering produces motion vectors or not.
67
46
  */
68
47
  needsVelocity(renderer: Renderer): boolean;
69
- /**
70
- * Returns monitoring data for the given render object.
71
- *
72
- * @param {RenderObject} renderObject - The render object.
73
- * @return {Object} The monitoring data.
74
- */
75
- getRenderObjectData(renderObject: RenderObject): unknown;
76
- /**
77
- * Returns an attribute data structure holding the attributes versions for
78
- * monitoring.
79
- *
80
- * @param {Object} attributes - The geometry attributes.
81
- * @return {Object} An object for monitoring the versions of attributes.
82
- */
83
- getAttributesData(attributes: Record<string, BufferAttribute>): unknown;
84
48
  /**
85
49
  * Returns `true` if the node builder's material uses
86
50
  * node properties.
@@ -89,54 +53,6 @@ declare class NodeMaterialObserver {
89
53
  * @return {boolean} Whether the node builder's material uses node properties or not.
90
54
  */
91
55
  containsNode(builder: NodeBuilder): boolean;
92
- /**
93
- * Returns a geometry data structure holding the geometry property values for
94
- * monitoring.
95
- *
96
- * @param {BufferGeometry} geometry - The geometry.
97
- * @return {Object} An object for monitoring geometry properties.
98
- */
99
- getGeometryData(geometry: BufferGeometry): unknown;
100
- /**
101
- * Returns a material data structure holding the material property values for
102
- * monitoring.
103
- *
104
- * @param {Material} material - The material.
105
- * @return {Object} An object for monitoring material properties.
106
- */
107
- getMaterialData(material: Material): unknown;
108
- /**
109
- * Returns `true` if the given render object has not changed its state.
110
- *
111
- * @param {RenderObject} renderObject - The render object.
112
- * @param {Array<Light>} lightsData - The current material lights.
113
- * @param {number} renderId - The current render ID.
114
- * @return {boolean} Whether the given render object has changed its state or not.
115
- */
116
- equals(renderObject: RenderObject, lightsData: Light[], renderId: number): boolean;
117
- /**
118
- * Returns the lights data for the given material lights.
119
- *
120
- * @param {Array<Light>} materialLights - The material lights.
121
- * @return {Array<Object>} The lights data for the given material lights.
122
- */
123
- getLightsData(materialLights: Light[]): unknown[];
124
- /**
125
- * Returns the lights for the given lights node and render ID.
126
- *
127
- * @param {LightsNode} lightsNode - The lights node.
128
- * @param {number} renderId - The render ID.
129
- * @return {Array<Object>} The lights for the given lights node and render ID.
130
- */
131
- getLights(lightsNode: LightsNode, renderId: number): unknown[];
132
- /**
133
- * Checks if the given render object requires a refresh.
134
- *
135
- * @param {RenderObject} renderObject - The render object.
136
- * @param {NodeFrame} nodeFrame - The current node frame.
137
- * @return {boolean} Whether the given render object requires a refresh or not.
138
- */
139
- needsRefresh(renderObject: RenderObject, nodeFrame: NodeFrame): boolean;
140
56
  }
141
57
 
142
58
  export default NodeMaterialObserver;
three/src/math/Box2.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Vector2 } from "./Vector2.js";
1
+ import { Vector2, Vector2Like } from "./Vector2.js";
2
2
 
3
3
  // Math //////////////////////////////////////////////////////////////////////////////////
4
4
 
@@ -16,7 +16,7 @@ export class Box2 {
16
16
  max: Vector2;
17
17
 
18
18
  set(min: Vector2, max: Vector2): Box2;
19
- setFromPoints(points: Vector2[]): Box2;
19
+ setFromPoints(points: Vector2Like[]): Box2;
20
20
  setFromCenterAndSize(center: Vector2, size: Vector2): Box2;
21
21
  clone(): this;
22
22
  copy(box: Box2): this;
@@ -24,7 +24,7 @@ export class Box2 {
24
24
  isEmpty(): boolean;
25
25
  getCenter(target: Vector2): Vector2;
26
26
  getSize(target: Vector2): Vector2;
27
- expandByPoint(point: Vector2): Box2;
27
+ expandByPoint(point: Vector2Like): Box2;
28
28
  expandByVector(vector: Vector2): Box2;
29
29
  expandByScalar(scalar: number): Box2;
30
30
  containsPoint(point: Vector2): boolean;
three/src/math/Box3.d.ts CHANGED
@@ -4,67 +4,303 @@ import { Matrix4 } from "./Matrix4.js";
4
4
  import { Plane } from "./Plane.js";
5
5
  import { Sphere } from "./Sphere.js";
6
6
  import { Triangle } from "./Triangle.js";
7
- import { Vector3 } from "./Vector3.js";
7
+ import { Vector3, type Vector3Like } from "./Vector3.js";
8
8
 
9
+ /**
10
+ * Represents an axis-aligned bounding box (AABB) in 3D space.
11
+ */
9
12
  export class Box3 {
13
+ /**
14
+ * Constructs a new bounding box.
15
+ *
16
+ * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.
17
+ * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.
18
+ */
10
19
  constructor(min?: Vector3, max?: Vector3);
11
-
12
20
  /**
13
- * @default new THREE.Vector3( + Infinity, + Infinity, + Infinity )
21
+ * This flag can be used for type testing.
22
+ *
23
+ * @type {boolean}
24
+ * @readonly
25
+ * @default true
26
+ */
27
+ readonly isBox3: boolean;
28
+ /**
29
+ * The lower boundary of the box.
30
+ *
31
+ * @type {Vector3}
14
32
  */
15
33
  min: Vector3;
16
-
17
34
  /**
18
- * @default new THREE.Vector3( - Infinity, - Infinity, - Infinity )
35
+ * The upper boundary of the box.
36
+ *
37
+ * @type {Vector3}
19
38
  */
20
39
  max: Vector3;
21
- readonly isBox3: true;
22
-
40
+ /**
41
+ * Sets the lower and upper boundaries of this box.
42
+ * Please note that this method only copies the values from the given objects.
43
+ *
44
+ * @param {Vector3} min - The lower boundary of the box.
45
+ * @param {Vector3} max - The upper boundary of the box.
46
+ * @return {Box3} A reference to this bounding box.
47
+ */
23
48
  set(min: Vector3, max: Vector3): this;
49
+ /**
50
+ * Sets the upper and lower bounds of this box so it encloses the position data
51
+ * in the given array.
52
+ *
53
+ * @param {Array<number>} array - An array holding 3D position data.
54
+ * @return {Box3} A reference to this bounding box.
55
+ */
24
56
  setFromArray(array: ArrayLike<number>): this;
25
- setFromBufferAttribute(bufferAttribute: BufferAttribute): this;
26
- setFromPoints(points: Vector3[]): this;
57
+ /**
58
+ * Sets the upper and lower bounds of this box so it encloses the position data
59
+ * in the given buffer attribute.
60
+ *
61
+ * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.
62
+ * @return {Box3} A reference to this bounding box.
63
+ */
64
+ setFromBufferAttribute(attribute: BufferAttribute): this;
65
+ /**
66
+ * Sets the upper and lower bounds of this box so it encloses the position data
67
+ * in the given array.
68
+ *
69
+ * @param {Array<Vector3>} points - An array holding 3D position data as instances of {@link Vector3}.
70
+ * @return {Box3} A reference to this bounding box.
71
+ */
72
+ setFromPoints(points: Array<Vector3Like>): this;
73
+ /**
74
+ * Centers this box on the given center vector and sets this box's width, height and
75
+ * depth to the given size values.
76
+ *
77
+ * @param {Vector3} center - The center of the box.
78
+ * @param {Vector3} size - The x, y and z dimensions of the box.
79
+ * @return {Box3} A reference to this bounding box.
80
+ */
27
81
  setFromCenterAndSize(center: Vector3, size: Vector3): this;
82
+ /**
83
+ * Computes the world-axis-aligned bounding box for the given 3D object
84
+ * (including its children), accounting for the object's, and children's,
85
+ * world transforms. The function may result in a larger box than strictly necessary.
86
+ *
87
+ * Note: To compute the correct bounding box, make sure the given 3D object
88
+ * has an up-to-date world matrix that reflects the current transformation of its
89
+ * ancestor nodes. Call `object.updateWorldMatrix( true, false )` beforehand if
90
+ * you're unsure.
91
+ *
92
+ * @param {Object3D} object - The 3D object to compute the bounding box for.
93
+ * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest
94
+ * world-axis-aligned bounding box at the expense of more computation.
95
+ * @return {Box3} A reference to this bounding box.
96
+ */
28
97
  setFromObject(object: Object3D, precise?: boolean): this;
98
+ /**
99
+ * Returns a new box with copied values from this instance.
100
+ *
101
+ * @return {Box3} A clone of this instance.
102
+ */
29
103
  clone(): this;
104
+ /**
105
+ * Copies the values of the given box to this instance.
106
+ *
107
+ * @param {Box3} box - The box to copy.
108
+ * @return {Box3} A reference to this bounding box.
109
+ */
30
110
  copy(box: Box3): this;
111
+ /**
112
+ * Makes this box empty which means in encloses a zero space in 3D.
113
+ *
114
+ * @return {Box3} A reference to this bounding box.
115
+ */
31
116
  makeEmpty(): this;
117
+ /**
118
+ * Returns true if this box includes zero points within its bounds.
119
+ * Note that a box with equal lower and upper bounds still includes one
120
+ * point, the one both bounds share.
121
+ *
122
+ * @return {boolean} Whether this box is empty or not.
123
+ */
32
124
  isEmpty(): boolean;
125
+ /**
126
+ * Returns the center point of this box.
127
+ *
128
+ * @param {Vector3} target - The target vector that is used to store the method's result.
129
+ * @return {Vector3} The center point.
130
+ */
33
131
  getCenter(target: Vector3): Vector3;
132
+ /**
133
+ * Returns the dimensions of this box.
134
+ *
135
+ * @param {Vector3} target - The target vector that is used to store the method's result.
136
+ * @return {Vector3} The size.
137
+ */
34
138
  getSize(target: Vector3): Vector3;
35
- expandByPoint(point: Vector3): this;
139
+ /**
140
+ * Expands the boundaries of this box to include the given point.
141
+ *
142
+ * @param {Vector3} point - The point that should be included by the bounding box.
143
+ * @return {Box3} A reference to this bounding box.
144
+ */
145
+ expandByPoint(point: Vector3Like): this;
146
+ /**
147
+ * Expands this box equilaterally by the given vector. The width of this
148
+ * box will be expanded by the x component of the vector in both
149
+ * directions. The height of this box will be expanded by the y component of
150
+ * the vector in both directions. The depth of this box will be
151
+ * expanded by the z component of the vector in both directions.
152
+ *
153
+ * @param {Vector3} vector - The vector that should expand the bounding box.
154
+ * @return {Box3} A reference to this bounding box.
155
+ */
36
156
  expandByVector(vector: Vector3): this;
157
+ /**
158
+ * Expands each dimension of the box by the given scalar. If negative, the
159
+ * dimensions of the box will be contracted.
160
+ *
161
+ * @param {number} scalar - The scalar value that should expand the bounding box.
162
+ * @return {Box3} A reference to this bounding box.
163
+ */
37
164
  expandByScalar(scalar: number): this;
165
+ /**
166
+ * Expands the boundaries of this box to include the given 3D object and
167
+ * its children, accounting for the object's, and children's, world
168
+ * transforms. The function may result in a larger box than strictly
169
+ * necessary (unless the precise parameter is set to true).
170
+ *
171
+ * @param {Object3D} object - The 3D object that should expand the bounding box.
172
+ * @param {boolean} precise - If set to `true`, the method expands the bounding box
173
+ * as little as necessary at the expense of more computation.
174
+ * @return {Box3} A reference to this bounding box.
175
+ */
38
176
  expandByObject(object: Object3D, precise?: boolean): this;
177
+ /**
178
+ * Returns `true` if the given point lies within or on the boundaries of this box.
179
+ *
180
+ * @param {Vector3} point - The point to test.
181
+ * @return {boolean} Whether the bounding box contains the given point or not.
182
+ */
39
183
  containsPoint(point: Vector3): boolean;
184
+ /**
185
+ * Returns `true` if this bounding box includes the entirety of the given bounding box.
186
+ * If this box and the given one are identical, this function also returns `true`.
187
+ *
188
+ * @param {Box3} box - The bounding box to test.
189
+ * @return {boolean} Whether the bounding box contains the given bounding box or not.
190
+ */
40
191
  containsBox(box: Box3): boolean;
192
+ /**
193
+ * Returns a point as a proportion of this box's width, height and depth.
194
+ *
195
+ * @param {Vector3} point - A point in 3D space.
196
+ * @param {Vector3} target - The target vector that is used to store the method's result.
197
+ * @return {Vector3} A point as a proportion of this box's width, height and depth.
198
+ */
41
199
  getParameter(point: Vector3, target: Vector3): Vector3;
200
+ /**
201
+ * Returns `true` if the given bounding box intersects with this bounding box.
202
+ *
203
+ * @param {Box3} box - The bounding box to test.
204
+ * @return {boolean} Whether the given bounding box intersects with this bounding box.
205
+ */
42
206
  intersectsBox(box: Box3): boolean;
207
+ /**
208
+ * Returns `true` if the given bounding sphere intersects with this bounding box.
209
+ *
210
+ * @param {Sphere} sphere - The bounding sphere to test.
211
+ * @return {boolean} Whether the given bounding sphere intersects with this bounding box.
212
+ */
43
213
  intersectsSphere(sphere: Sphere): boolean;
214
+ /**
215
+ * Returns `true` if the given plane intersects with this bounding box.
216
+ *
217
+ * @param {Plane} plane - The plane to test.
218
+ * @return {boolean} Whether the given plane intersects with this bounding box.
219
+ */
44
220
  intersectsPlane(plane: Plane): boolean;
221
+ /**
222
+ * Returns `true` if the given triangle intersects with this bounding box.
223
+ *
224
+ * @param {Triangle} triangle - The triangle to test.
225
+ * @return {boolean} Whether the given triangle intersects with this bounding box.
226
+ */
45
227
  intersectsTriangle(triangle: Triangle): boolean;
228
+ /**
229
+ * Clamps the given point within the bounds of this box.
230
+ *
231
+ * @param {Vector3} point - The point to clamp.
232
+ * @param {Vector3} target - The target vector that is used to store the method's result.
233
+ * @return {Vector3} The clamped point.
234
+ */
46
235
  clampPoint(point: Vector3, target: Vector3): Vector3;
236
+ /**
237
+ * Returns the euclidean distance from any edge of this box to the specified point. If
238
+ * the given point lies inside of this box, the distance will be `0`.
239
+ *
240
+ * @param {Vector3} point - The point to compute the distance to.
241
+ * @return {number} The euclidean distance.
242
+ */
47
243
  distanceToPoint(point: Vector3): number;
244
+ /**
245
+ * Returns a bounding sphere that encloses this bounding box.
246
+ *
247
+ * @param {Sphere} target - The target sphere that is used to store the method's result.
248
+ * @return {Sphere} The bounding sphere that encloses this bounding box.
249
+ */
48
250
  getBoundingSphere(target: Sphere): Sphere;
251
+ /**
252
+ * Computes the intersection of this bounding box and the given one, setting the upper
253
+ * bound of this box to the lesser of the two boxes' upper bounds and the
254
+ * lower bound of this box to the greater of the two boxes' lower bounds. If
255
+ * there's no overlap, makes this box empty.
256
+ *
257
+ * @param {Box3} box - The bounding box to intersect with.
258
+ * @return {Box3} A reference to this bounding box.
259
+ */
49
260
  intersect(box: Box3): this;
261
+ /**
262
+ * Computes the union of this box and another and the given one, setting the upper
263
+ * bound of this box to the greater of the two boxes' upper bounds and the
264
+ * lower bound of this box to the lesser of the two boxes' lower bounds.
265
+ *
266
+ * @param {Box3} box - The bounding box that will be unioned with this instance.
267
+ * @return {Box3} A reference to this bounding box.
268
+ */
50
269
  union(box: Box3): this;
270
+ /**
271
+ * Transforms this bounding box by the given 4x4 transformation matrix.
272
+ *
273
+ * @param {Matrix4} matrix - The transformation matrix.
274
+ * @return {Box3} A reference to this bounding box.
275
+ */
51
276
  applyMatrix4(matrix: Matrix4): this;
52
- translate(offset: Vector3): this;
53
- equals(box: Box3): boolean;
54
277
  /**
55
- * @deprecated Use {@link Box3#isEmpty .isEmpty()} instead.
278
+ * Adds the given offset to both the upper and lower bounds of this bounding box,
279
+ * effectively moving it in 3D space.
280
+ *
281
+ * @param {Vector3} offset - The offset that should be used to translate the bounding box.
282
+ * @return {Box3} A reference to this bounding box.
56
283
  */
57
- empty(): any;
284
+ translate(offset: Vector3): this;
58
285
  /**
59
- * @deprecated Use {@link Box3#intersectsBox .intersectsBox()} instead.
286
+ * Returns `true` if this bounding box is equal with the given one.
287
+ *
288
+ * @param {Box3} box - The box to test for equality.
289
+ * @return {boolean} Whether this bounding box is equal with the given one.
60
290
  */
61
- isIntersectionBox(b: any): any;
291
+ equals(box: Box3): boolean;
62
292
  /**
63
- * @deprecated Use {@link Box3#intersectsSphere .intersectsSphere()} instead.
293
+ * Returns a serialized structure of the bounding box.
294
+ *
295
+ * @return {Object} Serialized structure with fields representing the object state.
64
296
  */
65
- isIntersectionSphere(s: any): any;
66
-
67
297
  toJSON(): Box3JSON;
298
+ /**
299
+ * Returns a serialized structure of the bounding box.
300
+ *
301
+ * @param {Object} json - The serialized json to set the box from.
302
+ * @return {Box3} A reference to this bounding box.
303
+ */
68
304
  fromJSON(json: Box3JSON): this;
69
305
  }
70
306
 
three/src/math/Color.d.ts CHANGED
@@ -230,8 +230,8 @@ export class Color {
230
230
  */
231
231
  setFromVector3(vector: Vector3): this;
232
232
 
233
- setScalar(scalar: number): Color;
234
- setHex(hex: number, colorSpace?: string): Color;
233
+ setScalar(scalar: number): this;
234
+ setHex(hex: number, colorSpace?: string): this;
235
235
 
236
236
  /**
237
237
  * Sets this color from RGB values.
@@ -239,7 +239,7 @@ export class Color {
239
239
  * @param g Green channel value between 0 and 1.
240
240
  * @param b Blue channel value between 0 and 1.
241
241
  */
242
- setRGB(r: number, g: number, b: number, colorSpace?: string): Color;
242
+ setRGB(r: number, g: number, b: number, colorSpace?: string): this;
243
243
 
244
244
  /**
245
245
  * Sets this color from HSL values.
@@ -249,20 +249,20 @@ export class Color {
249
249
  * @param s Saturation value channel between 0 and 1.
250
250
  * @param l Value channel value between 0 and 1.
251
251
  */
252
- setHSL(h: number, s: number, l: number, colorSpace?: string): Color;
252
+ setHSL(h: number, s: number, l: number, colorSpace?: string): this;
253
253
 
254
254
  /**
255
255
  * Sets this color from a CSS context style string.
256
256
  * @param contextStyle Color in CSS context style format.
257
257
  */
258
- setStyle(style: string, colorSpace?: string): Color;
258
+ setStyle(style: string, colorSpace?: string): this;
259
259
 
260
260
  /**
261
261
  * Sets this color from a color name.
262
262
  * Faster than {@link Color#setStyle .setStyle()} method if you don't need the other CSS-style formats.
263
263
  * @param style Color name in X11 format.
264
264
  */
265
- setColorName(style: string, colorSpace?: string): Color;
265
+ setColorName(style: string, colorSpace?: string): this;
266
266
 
267
267
  /**
268
268
  * Clones this color.
@@ -279,23 +279,23 @@ export class Color {
279
279
  * Copies given color making conversion from `SRGBColorSpace` to `LinearSRGBColorSpace`.
280
280
  * @param color Color to copy.
281
281
  */
282
- copySRGBToLinear(color: Color): Color;
282
+ copySRGBToLinear(color: Color): this;
283
283
 
284
284
  /**
285
285
  * Copies given color making conversion from `LinearSRGBColorSpace` to `SRGBColorSpace`.
286
286
  * @param color Color to copy.
287
287
  */
288
- copyLinearToSRGB(color: Color): Color;
288
+ copyLinearToSRGB(color: Color): this;
289
289
 
290
290
  /**
291
291
  * Converts this color from `SRGBColorSpace` to `LinearSRGBColorSpace`.
292
292
  */
293
- convertSRGBToLinear(): Color;
293
+ convertSRGBToLinear(): this;
294
294
 
295
295
  /**
296
296
  * Converts this color from `LinearSRGBColorSpace` to `SRGBColorSpace`.
297
297
  */
298
- convertLinearToSRGB(): Color;
298
+ convertLinearToSRGB(): this;
299
299
 
300
300
  /**
301
301
  * Returns the hexadecimal value of this color.