@types/three 0.164.1 → 0.166.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 (181) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/controls/TransformControls.d.ts +8 -6
  3. three/examples/jsm/exporters/GLTFExporter.d.ts +6 -0
  4. three/examples/jsm/exporters/USDZExporter.d.ts +4 -2
  5. three/examples/jsm/geometries/TeapotGeometry.d.ts +24 -0
  6. three/examples/jsm/helpers/ViewHelper.d.ts +8 -6
  7. three/examples/jsm/lines/LineMaterial.d.ts +2 -4
  8. three/examples/jsm/loaders/DDSLoader.d.ts +8 -2
  9. three/examples/jsm/loaders/FontLoader.d.ts +1 -1
  10. three/examples/jsm/loaders/GLTFLoader.d.ts +12 -7
  11. three/examples/jsm/loaders/KTXLoader.d.ts +8 -2
  12. three/examples/jsm/loaders/LDrawLoader.d.ts +1 -1
  13. three/examples/jsm/loaders/PVRLoader.d.ts +2 -2
  14. three/examples/jsm/modifiers/EdgeSplitModifier.d.ts +17 -10
  15. three/examples/jsm/nodes/Nodes.d.ts +21 -57
  16. three/examples/jsm/nodes/accessors/BitangentNode.d.ts +4 -22
  17. three/examples/jsm/nodes/accessors/BufferAttributeNode.d.ts +50 -0
  18. three/examples/jsm/nodes/accessors/BufferNode.d.ts +3 -4
  19. three/examples/jsm/nodes/accessors/CameraNode.d.ts +11 -20
  20. three/examples/jsm/nodes/accessors/CubeTextureNode.d.ts +1 -1
  21. three/examples/jsm/nodes/accessors/MaterialNode.d.ts +4 -1
  22. three/examples/jsm/nodes/accessors/ModelNode.d.ts +3 -0
  23. three/examples/jsm/nodes/accessors/ModelViewProjectionNode.d.ts +1 -2
  24. three/examples/jsm/nodes/accessors/NormalNode.d.ts +9 -17
  25. three/examples/jsm/nodes/accessors/PositionNode.d.ts +6 -26
  26. three/examples/jsm/nodes/accessors/ReferenceNode.d.ts +3 -4
  27. three/examples/jsm/nodes/accessors/ReflectVectorNode.d.ts +3 -8
  28. three/examples/jsm/nodes/accessors/RendererReferenceNode.d.ts +2 -3
  29. three/examples/jsm/nodes/accessors/StorageBufferNode.d.ts +16 -4
  30. three/examples/jsm/nodes/accessors/StorageTextureNode.d.ts +40 -0
  31. three/examples/jsm/nodes/accessors/TangentNode.d.ts +8 -23
  32. three/examples/jsm/nodes/accessors/Texture3DNode.d.ts +16 -0
  33. three/examples/jsm/nodes/accessors/TextureNode.d.ts +1 -1
  34. three/examples/jsm/nodes/accessors/UVNode.d.ts +1 -8
  35. three/examples/jsm/nodes/accessors/UniformsNode.d.ts +0 -2
  36. three/examples/jsm/nodes/accessors/UserDataNode.d.ts +4 -3
  37. three/examples/jsm/nodes/code/CodeNode.d.ts +0 -1
  38. three/examples/jsm/nodes/code/ExpressionNode.d.ts +2 -3
  39. three/examples/jsm/nodes/core/AttributeNode.d.ts +11 -4
  40. three/examples/jsm/nodes/core/CacheNode.d.ts +4 -5
  41. three/examples/jsm/nodes/core/ConstNode.d.ts +1 -2
  42. three/examples/jsm/nodes/core/InputNode.d.ts +1 -2
  43. three/examples/jsm/nodes/core/LightingModel.d.ts +11 -0
  44. three/examples/jsm/nodes/core/Node.d.ts +102 -42
  45. three/examples/jsm/nodes/core/NodeAttribute.d.ts +7 -4
  46. three/examples/jsm/nodes/core/NodeBuilder.d.ts +30 -26
  47. three/examples/jsm/nodes/core/NodeCache.d.ts +48 -6
  48. three/examples/jsm/nodes/core/NodeFunction.d.ts +2 -2
  49. three/examples/jsm/nodes/core/NodeKeywords.d.ts +10 -7
  50. three/examples/jsm/nodes/core/NodeParser.d.ts +4 -4
  51. three/examples/jsm/nodes/core/NodeUniform.d.ts +8 -11
  52. three/examples/jsm/nodes/core/NodeVar.d.ts +5 -4
  53. three/examples/jsm/nodes/core/NodeVarying.d.ts +5 -6
  54. three/examples/jsm/nodes/core/PropertyNode.d.ts +4 -4
  55. three/examples/jsm/nodes/core/StackNode.d.ts +7 -1
  56. three/examples/jsm/nodes/core/StructTypeNode.d.ts +8 -0
  57. three/examples/jsm/nodes/core/TempNode.d.ts +1 -2
  58. three/examples/jsm/nodes/core/UniformGroup.d.ts +7 -0
  59. three/examples/jsm/nodes/core/UniformGroupNode.d.ts +21 -0
  60. three/examples/jsm/nodes/core/UniformNode.d.ts +16 -11
  61. three/examples/jsm/nodes/core/VarNode.d.ts +2 -0
  62. three/examples/jsm/nodes/core/VaryingNode.d.ts +4 -0
  63. three/examples/jsm/nodes/core/constants.d.ts +27 -79
  64. three/examples/jsm/nodes/display/DepthOfFieldNode.d.ts +30 -0
  65. three/examples/jsm/nodes/display/DotScreenNode.d.ts +32 -0
  66. three/examples/jsm/nodes/display/PassNode.d.ts +1 -1
  67. three/examples/jsm/nodes/display/RGBShiftNode.d.ts +24 -0
  68. three/examples/jsm/nodes/display/SobelOperatorNode.d.ts +17 -0
  69. three/examples/jsm/nodes/display/ViewportDepthNode.d.ts +4 -6
  70. three/examples/jsm/nodes/functions/BSDF/LTC.d.ts +9 -0
  71. three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts +2 -0
  72. three/examples/jsm/nodes/functions/ToonLightingModel.d.ts +4 -0
  73. three/examples/jsm/nodes/lighting/RectAreaLightNode.d.ts +10 -0
  74. three/examples/jsm/nodes/loaders/NodeLoader.d.ts +3 -3
  75. three/examples/jsm/nodes/loaders/NodeObjectLoader.d.ts +2 -3
  76. three/examples/jsm/nodes/materials/LineBasicNodeMaterial.d.ts +2 -0
  77. three/examples/jsm/nodes/materials/Materials.d.ts +3 -0
  78. three/examples/jsm/nodes/materials/MeshBasicNodeMaterial.d.ts +5 -1
  79. three/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.d.ts +28 -0
  80. three/examples/jsm/nodes/materials/MeshNormalNodeMaterial.d.ts +2 -0
  81. three/examples/jsm/nodes/materials/MeshPhongNodeMaterial.d.ts +7 -4
  82. three/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.d.ts +24 -17
  83. three/examples/jsm/nodes/materials/MeshSSSNodeMaterial.d.ts +6 -7
  84. three/examples/jsm/nodes/materials/MeshStandardNodeMaterial.d.ts +8 -5
  85. three/examples/jsm/nodes/materials/MeshToonNodeMaterial.d.ts +38 -0
  86. three/examples/jsm/nodes/materials/NodeMaterial.d.ts +41 -37
  87. three/examples/jsm/nodes/materials/PointsNodeMaterial.d.ts +1 -0
  88. three/examples/jsm/nodes/materials/ShadowNodeMaterial.d.ts +1 -0
  89. three/examples/jsm/nodes/materials/SpriteNodeMaterial.d.ts +3 -3
  90. three/examples/jsm/nodes/materials/VolumeNodeMaterial.d.ts +10 -0
  91. three/examples/jsm/nodes/materialx/lib/mx_hsv.d.ts +1 -0
  92. three/examples/jsm/nodes/materialx/lib/mx_noise.d.ts +230 -0
  93. three/examples/jsm/nodes/math/MathNode.d.ts +5 -1
  94. three/examples/jsm/nodes/shadernode/ShaderNode.d.ts +58 -36
  95. three/examples/jsm/nodes/utils/ConvertNode.d.ts +2 -3
  96. three/examples/jsm/nodes/utils/DiscardNode.d.ts +1 -0
  97. three/examples/jsm/nodes/utils/EquirectUVNode.d.ts +2 -2
  98. three/examples/jsm/nodes/utils/SplitNode.d.ts +1 -1
  99. three/examples/jsm/nodes/utils/TriplanarTexturesNode.d.ts +4 -5
  100. three/examples/jsm/objects/Sky.d.ts +18 -0
  101. three/examples/jsm/renderers/common/Animation.d.ts +14 -0
  102. three/examples/jsm/renderers/common/Attributes.d.ts +20 -0
  103. three/examples/jsm/renderers/common/Background.d.ts +22 -0
  104. three/examples/jsm/renderers/common/BindGroup.d.ts +9 -0
  105. three/examples/jsm/renderers/common/Binding.d.ts +8 -0
  106. three/examples/jsm/renderers/common/Bindings.d.ts +42 -0
  107. three/examples/jsm/renderers/common/Buffer.d.ts +11 -0
  108. three/examples/jsm/renderers/common/BufferUtils.d.ts +4 -0
  109. three/examples/jsm/renderers/common/ChainMap.d.ts +9 -0
  110. three/examples/jsm/renderers/common/ClippingContext.d.ts +18 -0
  111. three/examples/jsm/renderers/common/Color4.d.ts +6 -5
  112. three/examples/jsm/renderers/common/ComputePipeline.d.ts +8 -0
  113. three/examples/jsm/renderers/common/Constants.d.ts +9 -0
  114. three/examples/jsm/renderers/common/CubeRenderTarget.d.ts +7 -0
  115. three/examples/jsm/renderers/common/DataMap.d.ts +20 -0
  116. three/examples/jsm/renderers/common/Geometries.d.ts +28 -0
  117. three/examples/jsm/renderers/common/Info.d.ts +25 -13
  118. three/examples/jsm/renderers/common/Pipeline.d.ts +6 -0
  119. three/examples/jsm/renderers/common/Pipelines.d.ts +68 -0
  120. three/examples/jsm/renderers/common/PostProcessing.d.ts +2 -0
  121. three/examples/jsm/renderers/common/ProgrammableStage.d.ts +15 -0
  122. three/examples/jsm/renderers/common/RenderBundle.d.ts +8 -0
  123. three/examples/jsm/renderers/common/RenderBundles.d.ts +10 -0
  124. three/examples/jsm/renderers/common/RenderContext.d.ts +38 -0
  125. three/examples/jsm/renderers/common/RenderContexts.d.ts +13 -0
  126. three/examples/jsm/renderers/common/RenderList.d.ts +62 -0
  127. three/examples/jsm/renderers/common/RenderLists.d.ts +10 -0
  128. three/examples/jsm/renderers/common/RenderObject.d.ts +73 -0
  129. three/examples/jsm/renderers/common/RenderObjects.d.ts +59 -0
  130. three/examples/jsm/renderers/common/RenderPipeline.d.ts +8 -0
  131. three/examples/jsm/renderers/common/Renderer.d.ts +186 -208
  132. three/examples/jsm/renderers/common/SampledTexture.d.ts +27 -0
  133. three/examples/jsm/renderers/common/Sampler.d.ts +11 -0
  134. three/examples/jsm/renderers/common/StorageBufferAttribute.d.ts +7 -0
  135. three/examples/jsm/renderers/common/StorageInstancedBufferAttribute.d.ts +7 -0
  136. three/examples/jsm/renderers/common/Textures.d.ts +64 -0
  137. three/examples/jsm/renderers/common/Uniform.d.ts +40 -0
  138. three/examples/jsm/renderers/common/UniformBuffer.d.ts +6 -0
  139. three/examples/jsm/renderers/common/UniformsGroup.d.ts +32 -0
  140. three/examples/jsm/renderers/common/nodes/NodeBuilderState.d.ts +30 -0
  141. three/examples/jsm/renderers/common/nodes/NodeSampledTexture.d.ts +29 -0
  142. three/examples/jsm/renderers/common/nodes/NodeSampler.d.ts +12 -0
  143. three/examples/jsm/renderers/common/nodes/NodeUniform.d.ts +63 -0
  144. three/examples/jsm/renderers/common/nodes/NodeUniformsGroup.d.ts +11 -0
  145. three/examples/jsm/renderers/common/nodes/Nodes.d.ts +95 -0
  146. three/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +123 -0
  147. three/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.d.ts +6 -0
  148. three/examples/jsm/renderers/webgpu/nodes/WGSLNodeParser.d.ts +6 -0
  149. three/examples/jsm/renderers/webgpu/utils/WebGPUConstants.d.ts +328 -0
  150. three/examples/jsm/utils/SceneUtils.d.ts +9 -3
  151. three/package.json +4 -4
  152. three/src/Three.d.ts +1 -0
  153. three/src/animation/tracks/StringKeyframeTrack.d.ts +1 -2
  154. three/src/constants.d.ts +6 -0
  155. three/src/core/BufferGeometry.d.ts +19 -17
  156. three/src/core/InterleavedBuffer.d.ts +2 -0
  157. three/src/extras/ShapeUtils.d.ts +5 -8
  158. three/src/extras/TextureUtils.d.ts +42 -0
  159. three/src/lights/LightShadow.d.ts +5 -0
  160. three/src/loaders/LoaderUtils.d.ts +9 -6
  161. three/src/materials/Material.d.ts +21 -12
  162. three/src/math/Color.d.ts +1 -1
  163. three/src/math/Matrix3.d.ts +2 -0
  164. three/src/math/Matrix4.d.ts +2 -0
  165. three/src/math/Vector4.d.ts +6 -0
  166. three/src/objects/BatchedMesh.d.ts +66 -47
  167. three/src/objects/InstancedMesh.d.ts +3 -3
  168. three/src/renderers/WebGLRenderer.d.ts +41 -19
  169. three/src/renderers/shaders/UniformsLib.d.ts +3 -0
  170. three/src/renderers/webgl/WebGLPrograms.d.ts +1 -1
  171. three/src/renderers/webxr/WebXRDepthSensing.d.ts +3 -1
  172. three/src/renderers/webxr/WebXRManager.d.ts +33 -23
  173. three/src/textures/CompressedArrayTexture.d.ts +36 -19
  174. three/src/textures/CompressedTexture.d.ts +16 -8
  175. three/src/textures/DataArrayTexture.d.ts +37 -20
  176. three/src/textures/FramebufferTexture.d.ts +1 -1
  177. three/src/textures/Texture.d.ts +3 -1
  178. three/src/utils.d.ts +2 -0
  179. three/examples/jsm/renderers/webgl/nodes/SlotNode.d.ts +0 -17
  180. three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +0 -37
  181. three/examples/jsm/renderers/webgl/nodes/WebGLNodes.d.ts +0 -3
@@ -2,32 +2,43 @@ import { Camera } from "../cameras/Camera.js";
2
2
  import { BufferGeometry } from "../core/BufferGeometry.js";
3
3
  import { Material } from "../materials/Material.js";
4
4
  import { Box3 } from "../math/Box3.js";
5
+ import { Color } from "../math/Color.js";
5
6
  import { Matrix4 } from "../math/Matrix4.js";
6
7
  import { Sphere } from "../math/Sphere.js";
7
8
  import { Mesh } from "./Mesh.js";
8
9
 
9
10
  /**
10
11
  * A special version of {@link Mesh} with multi draw batch rendering support. Use {@link BatchedMesh} if you have to
11
- * render a large number of objects with the same material but with different world transformations and geometry. The
12
- * usage of {@link BatchedMesh} will help you to reduce the number of draw calls and thus improve the overall rendering
12
+ * render a large number of objects with the same material but with different world transformations. The usage of
13
+ * {@link BatchedMesh} will help you to reduce the number of draw calls and thus improve the overall rendering
13
14
  * performance in your application.
14
15
  *
15
16
  * If the {@link https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_multi_draw WEBGL_multi_draw extension} is not
16
- * supported then a less performant callback is used.
17
+ * supported then a less performant fallback is used.
17
18
  *
18
19
  * @example
19
20
  * const box = new THREE.BoxGeometry( 1, 1, 1 );
20
- * const sphere = new THREE.BoxGeometry( 1, 1, 1 );
21
+ * const sphere = new THREE.SphereGeometry( 1, 12, 12 );
21
22
  * const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
22
23
  *
23
24
  * // initialize and add geometries into the batched mesh
24
25
  * const batchedMesh = new BatchedMesh( 10, 5000, 10000, material );
25
- * const boxId = batchedMesh.addGeometry( box );
26
- * const sphereId = batchedMesh.addGeometry( sphere );
26
+ * const boxGeometryId = batchedMesh.addGeometry( box );
27
+ * const sphereGeometryId = batchedMesh.addGeometry( sphere );
28
+ *
29
+ * // create instances of those geometries
30
+ * const boxInstancedId1 = batchedMesh.addInstance( boxGeometryId );
31
+ * const boxInstancedId2 = batchedMesh.addInstance( boxGeometryId );
32
+ *
33
+ * const sphereInstancedId1 = batchedMesh.addInstance( sphereGeometryId );
34
+ * const sphereInstancedId2 = batchedMesh.addInstance( sphereGeometryId );
27
35
  *
28
36
  * // position the geometries
29
- * batchedMesh.setMatrixAt( boxId, boxMatrix );
30
- * batchedMesh.setMatrixAt( sphereId, sphereMatrix );
37
+ * batchedMesh.setMatrixAt( boxInstancedId1, boxMatrix1 );
38
+ * batchedMesh.setMatrixAt( boxInstancedId2, boxMatrix2 );
39
+ *
40
+ * batchedMesh.setMatrixAt( sphereInstancedId1, sphereMatrix1 );
41
+ * batchedMesh.setMatrixAt( sphereInstancedId2, sphereMatrix2 );
31
42
  *
32
43
  * scene.add( batchedMesh );
33
44
  *
@@ -67,20 +78,20 @@ declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
67
78
  /**
68
79
  * The maximum number of individual geometries that can be stored in the {@link BatchedMesh}. Read only.
69
80
  */
70
- get maxGeometryCount(): number;
81
+ get maxInstanceCount(): number;
71
82
 
72
83
  /**
73
84
  * Read-only flag to check if a given object is of type {@link BatchedMesh}.
74
85
  */
75
- isBatchedMesh: true;
86
+ readonly isBatchedMesh: true;
76
87
 
77
88
  /**
78
- * @param maxGeometryCount the max number of individual geometries planned to be added.
89
+ * @param maxInstanceCount the max number of individual geometries planned to be added.
79
90
  * @param maxVertexCount the max number of vertices to be used by all geometries.
80
91
  * @param maxIndexCount the max number of indices to be used by all geometries.
81
- * @param material an instance of [page:Material]. Default is a new {@link MeshBasicMaterial}.
92
+ * @param material an instance of {@link Material}. Default is a new {@link MeshBasicMaterial}.
82
93
  */
83
- constructor(maxGeometryCount: number, maxVertexCount: number, maxIndexCount?: number, material?: Material);
94
+ constructor(maxInstanceCount: number, maxVertexCount: number, maxIndexCount?: number, material?: Material);
84
95
 
85
96
  /**
86
97
  * Computes the bounding box, updating {@link .boundingBox} attribute.
@@ -101,40 +112,55 @@ declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
101
112
  dispose(): this;
102
113
 
103
114
  /**
104
- * Takes a sort a function that is run before render. The function takes a list of items to sort and a camera. The
105
- * objects in the list include a "z" field to perform a depth-ordered sort with.
115
+ * Takes a sort a function that is run before render. The function takes a list of instances to sort and a camera.
116
+ * The objects in the list include a "z" field to perform a depth-ordered sort with.
106
117
  */
107
118
  setCustomSort(
108
- func: ((this: this, list: Array<{ start: number; count: number; z: number }>, camera: Camera) => void) | null,
119
+ sortFunction:
120
+ | ((this: this, list: Array<{ start: number; count: number; z: number }>, camera: Camera) => void)
121
+ | null,
109
122
  ): this;
110
123
 
124
+ /**
125
+ * Get the color of the defined geometry.
126
+ * @param instanceId The id of an instance to get the color of.
127
+ * @param target The target object to copy the color in to.
128
+ */
129
+ getColorAt(instanceId: number, target: Color): void;
130
+
111
131
  /**
112
132
  * Get the local transformation matrix of the defined instance.
113
- * @param index The index of an instance. Values have to be in the range [0, count].
114
- * @param matrix This 4x4 matrix will be set to the local transformation matrix of the defined instance.
133
+ * @param instanceId The id of an instance to get the matrix of.
134
+ * @param target This 4x4 matrix will be set to the local transformation matrix of the defined instance.
115
135
  */
116
- getMatrixAt(index: number, matrix: Matrix4): Matrix4;
136
+ getMatrixAt(instanceId: number, target: Matrix4): Matrix4;
117
137
 
118
138
  /**
119
139
  * Get whether the given instance is marked as "visible" or not.
120
- * @param index The index of an instance. Values have to be in the range [0, count].
140
+ * @param instanceId The id of an instance to get the visibility state of.
121
141
  */
122
- getVisibleAt(index: number): boolean;
142
+ getVisibleAt(instanceId: number): boolean;
123
143
 
124
144
  /**
125
- * Sets the given local transformation matrix to the defined instance. Make sure you set {@link .instanceMatrix}
126
- * {@link BufferAttribute.needsUpdate} to true after updating all the matrices.
127
- * @param index The index of an instance. Values have to be in the range [0, count].
145
+ * Sets the given color to the defined geometry instance.
146
+ * @param instanceId The id of the instance to set the color of.
147
+ * @param color The color to set the instance to.
148
+ */
149
+ setColorAt(instanceId: number, color: Color): void;
150
+
151
+ /**
152
+ * Sets the given local transformation matrix to the defined instance.
153
+ * @param instanceId The id of an instance to set the matrix of.
128
154
  * @param matrix A 4x4 matrix representing the local transformation of a single instance.
129
155
  */
130
- setMatrixAt(index: number, matrix: Matrix4): this;
156
+ setMatrixAt(instanceId: number, matrix: Matrix4): this;
131
157
 
132
158
  /**
133
- * Sets the visibility of the object at the given index.
134
- * @param index The index of an instance. Values have to be in the range [0, count].
159
+ * Sets the visibility of the instance at the given index.
160
+ * @param instanceId The id of the instance to set the visibility of.
135
161
  * @param visible A boolean value indicating the visibility state.
136
162
  */
137
- setVisibleAt(index: number, visible: boolean): this;
163
+ setVisibleAt(instanceId: number, visible: boolean): this;
138
164
 
139
165
  /**
140
166
  * Adds the given geometry to the {@link BatchedMesh} and returns the associated index referring to it.
@@ -149,30 +175,23 @@ declare class BatchedMesh extends Mesh<BufferGeometry, Material> {
149
175
  addGeometry(geometry: BufferGeometry, reservedVertexRange?: number, reservedIndexRange?: number): number;
150
176
 
151
177
  /**
152
- * Replaces the geometry at `index` with the provided geometry. Throws an error if there is not enough space
153
- * reserved for geometry at the index.
154
- * @param index Which geometry index to replace with this geometry.
155
- * @param geometry The geometry to substitute at the given geometry index.
156
- */
157
- setGeometryAt(index: number, geometry: BufferGeometry): number;
158
-
159
- /**
160
- * Gets the instance count of the geometry at `index`. Returns `null` if instance counts are not configured.
161
- * @param index The index of an instance. Values have to be in the range [0, count].
178
+ * Adds a new instance to the {@link BatchedMesh} using the geometry of the given geometryId and returns a new id
179
+ * referring to the new instance to be used by other functions.
180
+ * @param geometryId The id of a previously added geometry via "addGeometry" to add into the {@link BatchedMesh} to
181
+ * render.
162
182
  */
163
- getInstanceCountAt(index: number): number | null;
183
+ addInstance(geometryId: number): number;
164
184
 
165
185
  /**
166
- * Sets an instance count of the geometry at `index`.
167
- * @param index Which geometry index to configure an instance count for.
168
- * @param instanceCount The number of instances to render of the given geometry index.
186
+ * Replaces the geometry at `geometryId` with the provided geometry. Throws an error if there is not enough space
187
+ * reserved for geometry. Calling this will change all instances that are rendering that geometry.
188
+ * @param geometryId Which geometry id to replace with this geometry.
189
+ * @param geometry The geometry to substitute at the given geometry id.
169
190
  */
170
- setInstanceCountAt(index: number, instanceCount: number): number;
171
-
172
- deleteGeometry(index: number): this;
191
+ setGeometryAt(geometryId: number, geometry: BufferGeometry): number;
173
192
 
174
- getBoundingBoxAt(index: number, target: Box3): Box3 | null;
175
- getBoundingSphereAt(index: number, target: Sphere): Sphere | null;
193
+ getBoundingBoxAt(geometryId: number, target: Box3): Box3 | null;
194
+ getBoundingSphereAt(geometryId: number, target: Sphere): Sphere | null;
176
195
  }
177
196
 
178
197
  export { BatchedMesh };
@@ -16,7 +16,7 @@ export interface InstancedMeshEventMap extends Object3DEventMap {
16
16
  /**
17
17
  * A special version of {@link THREE.Mesh | Mesh} with instanced rendering support
18
18
  * @remarks
19
- * Use {@link InstancedMesh} if you have to render a large number of objects with the same geometry and material but with different world transformations
19
+ * Use {@link InstancedMesh} if you have to render a large number of objects with the same geometry and material(s) but with different world transformations
20
20
  * @remarks
21
21
  * The usage of {@link InstancedMesh} will help you to reduce the number of draw calls and thus improve the overall rendering performance in your application.
22
22
  * @see Example: {@link https://threejs.org/examples/#webgl_instancing_dynamic | WebGL / instancing / dynamic}
@@ -33,8 +33,8 @@ export class InstancedMesh<
33
33
  > extends Mesh<TGeometry, TMaterial, TEventMap> {
34
34
  /**
35
35
  * Create a new instance of {@link InstancedMesh}
36
- * @param geometry An instance of {@link THREE.BufferGeometry | BufferGeometry}.
37
- * @param material A single or an array of {@link THREE.Material | Material}. Default {@link THREE.MeshBasicMaterial | `new THREE.MeshBasicMaterial()`}.
36
+ * @param geometry An instance of {@link BufferGeometry}.
37
+ * @param material A single or an array of {@link Material}. Default is a new {@link MeshBasicMaterial}.
38
38
  * @param count The **maximum** number of instances of this Mesh. Expects a `Integer`
39
39
  */
40
40
  constructor(geometry: TGeometry | undefined, material: TMaterial | undefined, count: number);
@@ -1,8 +1,10 @@
1
1
  import { Camera } from "../cameras/Camera.js";
2
2
  import { ColorSpace, CullFace, ShadowMapType, ToneMapping, WebGLCoordinateSystem } from "../constants.js";
3
+ import { TypedArray } from "../core/BufferAttribute.js";
3
4
  import { BufferGeometry } from "../core/BufferGeometry.js";
4
5
  import { Object3D } from "../core/Object3D.js";
5
6
  import { Material } from "../materials/Material.js";
7
+ import { Box2 } from "../math/Box2.js";
6
8
  import { Box3 } from "../math/Box3.js";
7
9
  import { Color, ColorRepresentation } from "../math/Color.js";
8
10
  import { Plane } from "../math/Plane.js";
@@ -125,7 +127,7 @@ export interface WebGLDebug {
125
127
  */
126
128
  export class WebGLRenderer implements Renderer {
127
129
  /**
128
- * parameters is an optional object with properties defining the renderer's behaviour.
130
+ * parameters is an optional object with properties defining the renderer's behavior.
129
131
  * The constructor also accepts no parameters at all.
130
132
  * In all cases, it will assume sane defaults when parameters are missing.
131
133
  */
@@ -196,13 +198,6 @@ export class WebGLRenderer implements Renderer {
196
198
 
197
199
  get coordinateSystem(): typeof WebGLCoordinateSystem;
198
200
 
199
- /**
200
- * @deprecated Migrate your lighting according to the following guide:
201
- * https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.
202
- * @default true
203
- */
204
- useLegacyLights: boolean;
205
-
206
201
  /**
207
202
  * @default THREE.NoToneMapping
208
203
  */
@@ -421,46 +416,73 @@ export class WebGLRenderer implements Renderer {
421
416
  y: number,
422
417
  width: number,
423
418
  height: number,
424
- buffer: any,
419
+ buffer: TypedArray,
425
420
  activeCubeFaceIndex?: number,
426
421
  ): void;
427
422
 
423
+ readRenderTargetPixelsAsync(
424
+ renderTarget: WebGLRenderTarget | WebGLRenderTarget<Texture[]>,
425
+ x: number,
426
+ y: number,
427
+ width: number,
428
+ height: number,
429
+ buffer: TypedArray,
430
+ activeCubeFaceIndex?: number,
431
+ ): Promise<TypedArray>;
432
+
428
433
  /**
429
434
  * Copies a region of the currently bound framebuffer into the selected mipmap level of the selected texture.
430
435
  * This region is defined by the size of the destination texture's mip level, offset by the input position.
431
436
  *
432
- * @param position Specifies the pixel offset from which to copy out of the framebuffer.
433
437
  * @param texture Specifies the destination texture.
438
+ * @param position Specifies the pixel offset from which to copy out of the framebuffer.
434
439
  * @param level Specifies the destination mipmap level of the texture.
435
440
  */
436
- copyFramebufferToTexture(position: Vector2, texture: Texture, level?: number): void;
441
+ copyFramebufferToTexture(texture: Texture, position?: Vector2 | null, level?: number): void;
437
442
 
438
443
  /**
439
- * Copies srcTexture to the specified level of dstTexture, offset by the input position.
444
+ * Copies the pixels of a texture in the bounds `srcRegion` in the destination texture starting from the given
445
+ * position.
440
446
  *
441
- * @param position Specifies the pixel offset into the dstTexture where the copy will occur.
442
447
  * @param srcTexture Specifies the source texture.
443
448
  * @param dstTexture Specifies the destination texture.
449
+ * @param srcRegion Specifies the bounds
450
+ * @param dstPosition Specifies the pixel offset into the dstTexture where the copy will occur.
444
451
  * @param level Specifies the destination mipmap level of the texture.
445
452
  */
446
- copyTextureToTexture(position: Vector2, srcTexture: Texture, dstTexture: Texture, level?: number): void;
453
+ copyTextureToTexture(
454
+ srcTexture: Texture,
455
+ dstTexture: Texture,
456
+ srcRegion?: Box2 | null,
457
+ dstPosition?: Vector2 | null,
458
+ level?: number,
459
+ ): void;
447
460
 
448
461
  /**
449
- * Copies the pixels of a texture in the bounds sourceBox in the desination texture starting from the given position.
450
- * @param sourceBox Specifies the bounds
451
- * @param position Specifies the pixel offset into the dstTexture where the copy will occur.
462
+ * Copies the pixels of a texture in the bounds `srcRegion` in the destination texture starting from the given
463
+ * position.
464
+ *
452
465
  * @param srcTexture Specifies the source texture.
453
466
  * @param dstTexture Specifies the destination texture.
467
+ * @param srcRegion Specifies the bounds
468
+ * @param dstPosition Specifies the pixel offset into the dstTexture where the copy will occur.
454
469
  * @param level Specifies the destination mipmap level of the texture.
455
470
  */
456
471
  copyTextureToTexture3D(
457
- sourceBox: Box3,
458
- position: Vector3,
459
472
  srcTexture: Texture,
460
473
  dstTexture: Data3DTexture | DataArrayTexture,
474
+ srcRegion?: Box3 | null,
475
+ dstPosition?: Vector3 | null,
461
476
  level?: number,
462
477
  ): void;
463
478
 
479
+ /**
480
+ * Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data can be copied
481
+ * into it using {@link WebGLRenderer.copyTextureToTexture} before it has been rendered to.
482
+ * @param target
483
+ */
484
+ initRenderTarget(target: WebGLRenderTarget): void;
485
+
464
486
  /**
465
487
  * Initializes the given texture. Can be used to preload a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead).
466
488
  *
@@ -89,6 +89,7 @@ export const UniformsLib: {
89
89
  directionalLightShadows: {
90
90
  value: unknown[];
91
91
  properties: {
92
+ shadowIntensity: number;
92
93
  shadowBias: {};
93
94
  shadowNormalBias: {};
94
95
  shadowRadius: {};
@@ -112,6 +113,7 @@ export const UniformsLib: {
112
113
  spotLightShadows: {
113
114
  value: unknown[];
114
115
  properties: {
116
+ shadowIntensity: number;
115
117
  shadowBias: {};
116
118
  shadowNormalBias: {};
117
119
  shadowRadius: {};
@@ -133,6 +135,7 @@ export const UniformsLib: {
133
135
  pointLightShadows: {
134
136
  value: unknown[];
135
137
  properties: {
138
+ shadowIntensity: number;
136
139
  shadowBias: {};
137
140
  shadowNormalBias: {};
138
141
  shadowRadius: {};
@@ -39,6 +39,7 @@ export interface WebGLProgramParameters {
39
39
  precision: "lowp" | "mediump" | "highp";
40
40
 
41
41
  batching: boolean;
42
+ batchingColor: boolean;
42
43
  instancing: boolean;
43
44
  instancingColor: boolean;
44
45
  instancingMorph: boolean;
@@ -186,7 +187,6 @@ export interface WebGLProgramParameters {
186
187
  shadowMapType: ShadowMapType;
187
188
 
188
189
  toneMapping: ToneMapping;
189
- useLegacyLights: boolean;
190
190
 
191
191
  decodeVideoTexture: boolean;
192
192
 
@@ -21,7 +21,9 @@ export class WebXRDepthSensing {
21
21
 
22
22
  init(renderer: WebGLRenderer, depthData: XRWebGLDepthInformation, renderState: XRRenderState): void;
23
23
 
24
- render(renderer: WebGLRenderer, cameraXR: WebXRArrayCamera): void;
24
+ getMesh(cameraXR: WebXRArrayCamera): Mesh | null;
25
25
 
26
26
  reset(): void;
27
+
28
+ getDepthTexture(): Texture | null;
27
29
  }
@@ -6,6 +6,8 @@ import { ArrayCamera } from "../../cameras/ArrayCamera.js";
6
6
  import { PerspectiveCamera } from "../../cameras/PerspectiveCamera.js";
7
7
  import { EventDispatcher } from "../../core/EventDispatcher.js";
8
8
  import { Vector4 } from "../../math/Vector4.js";
9
+ import { Mesh } from "../../objects/Mesh.js";
10
+ import { Texture } from "../../textures/Texture.js";
9
11
  import { WebGLRenderer } from "../WebGLRenderer.js";
10
12
  import { XRGripSpace, XRHandSpace, XRTargetRaySpace } from "./WebXRController.js";
11
13
 
@@ -22,7 +24,10 @@ export interface WebXRManagerEventMap {
22
24
  }
23
25
 
24
26
  export class WebXRManager extends EventDispatcher<WebXRManagerEventMap> {
25
- constructor(renderer: WebGLRenderer, gl: WebGLRenderingContext);
27
+ /**
28
+ * @default true
29
+ */
30
+ cameraAutoUpdate: boolean;
26
31
 
27
32
  /**
28
33
  * @default false
@@ -34,44 +39,49 @@ export class WebXRManager extends EventDispatcher<WebXRManagerEventMap> {
34
39
  */
35
40
  isPresenting: boolean;
36
41
 
37
- /**
38
- * @default true
39
- */
40
- cameraAutoUpdate: boolean;
42
+ constructor(renderer: WebGLRenderer, gl: WebGLRenderingContext);
43
+
44
+ getController: (index: number) => XRTargetRaySpace;
45
+
46
+ getControllerGrip: (index: number) => XRGripSpace;
47
+
48
+ getHand: (index: number) => XRHandSpace;
49
+
50
+ setFramebufferScaleFactor: (value: number) => void;
41
51
 
42
- getController(index: number): XRTargetRaySpace;
52
+ setReferenceSpaceType: (value: XRReferenceSpaceType) => void;
43
53
 
44
- getControllerGrip(index: number): XRGripSpace;
54
+ getReferenceSpace: () => XRReferenceSpace | null;
45
55
 
46
- getHand(index: number): XRHandSpace;
56
+ setReferenceSpace: (value: XRReferenceSpace) => void;
47
57
 
48
- setFramebufferScaleFactor(value: number): void;
58
+ getBaseLayer: () => XRWebGLLayer | XRProjectionLayer;
49
59
 
50
- setReferenceSpaceType(value: XRReferenceSpaceType): void;
60
+ getBinding: () => XRWebGLBinding;
51
61
 
52
- getReferenceSpace(): XRReferenceSpace | null;
62
+ getFrame: () => XRFrame;
53
63
 
54
- setReferenceSpace(value: XRReferenceSpace): void;
64
+ getSession: () => XRSession | null;
55
65
 
56
- getBaseLayer(): XRWebGLLayer | XRProjectionLayer;
66
+ setSession: (value: XRSession | null) => Promise<void>;
57
67
 
58
- getBinding(): XRWebGLBinding;
68
+ getEnvironmentBlendMode: () => XREnvironmentBlendMode | undefined;
59
69
 
60
- getFrame(): XRFrame;
70
+ getDepthTexture: () => Texture | null;
61
71
 
62
- getSession(): XRSession | null;
72
+ updateCamera: (camera: PerspectiveCamera) => void;
63
73
 
64
- setSession(value: XRSession | null): Promise<void>;
74
+ getCamera: () => WebXRArrayCamera;
65
75
 
66
- getCamera(): WebXRArrayCamera;
76
+ getFoveation: () => number | undefined;
67
77
 
68
- updateCamera(camera: PerspectiveCamera): void;
78
+ setFoveation: (value: number) => void;
69
79
 
70
- setAnimationLoop(callback: XRFrameRequestCallback | null): void;
80
+ hasDepthSensing: () => boolean;
71
81
 
72
- getFoveation(): number | undefined;
82
+ getDepthSensingMesh: () => Mesh | null;
73
83
 
74
- setFoveation(value: number): void;
84
+ setAnimationLoop: (callback: XRFrameRequestCallback | null) => void;
75
85
 
76
- dispose(): void;
86
+ dispose: () => void;
77
87
  }
@@ -1,5 +1,5 @@
1
1
  import { CompressedPixelFormat, TextureDataType, Wrapping } from "../constants.js";
2
- import { CompressedTexture } from "./CompressedTexture.js";
2
+ import { CompressedTexture, CompressedTextureMipmap } from "./CompressedTexture.js";
3
3
 
4
4
  /**
5
5
  * Creates an texture 2D array based on data in compressed form, for example from a
@@ -9,10 +9,36 @@ import { CompressedTexture } from "./CompressedTexture.js";
9
9
  * @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/CompressedArrayTexture.js | Source}
10
10
  */
11
11
  export class CompressedArrayTexture extends CompressedTexture {
12
+ /**
13
+ * Read-only flag to check if a given object is of type {@link CompressedArrayTexture}.
14
+ * @remarks This is a _constant_ value
15
+ * @defaultValue `true`
16
+ */
17
+ readonly isCompressedArrayTexture: true;
18
+
19
+ /**
20
+ * Overridden with a object containing width and height.
21
+ * @override
22
+ */
23
+ get image(): { width: number; height: number; depth: number };
24
+ set image(value: { width: number; height: number; depth: number });
25
+
26
+ /**
27
+ * This defines how the texture is wrapped in the depth direction.
28
+ * @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
29
+ * @defaultValue {@link THREE.ClampToEdgeWrapping}
30
+ */
31
+ wrapR: Wrapping;
32
+
33
+ /**
34
+ * A set of all layers which need to be updated in the texture. See {@link CompressedArrayTexture.addLayerUpdate}.
35
+ */
36
+ layerUpdates: Set<number>;
37
+
12
38
  /**
13
39
  * Create a new instance of {@link CompressedArrayTexture}
14
- * @param mipmaps The mipmaps array should contain objects with data, width and height.
15
- * The mipmaps should be of the correct {@link format} and {@link type}. See {@link THREE.mipmaps}.
40
+ * @param mipmaps The mipmaps array should contain objects with data, width and height. The mipmaps should be of the
41
+ * correct format and type.
16
42
  * @param width The width of the biggest mipmap.
17
43
  * @param height The height of the biggest mipmap.
18
44
  * @param depth The number of layers of the 2D array texture
@@ -20,7 +46,7 @@ export class CompressedArrayTexture extends CompressedTexture {
20
46
  * @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
21
47
  */
22
48
  constructor(
23
- mipmaps: ImageData[],
49
+ mipmaps: CompressedTextureMipmap[],
24
50
  width: number,
25
51
  height: number,
26
52
  depth: number,
@@ -29,23 +55,14 @@ export class CompressedArrayTexture extends CompressedTexture {
29
55
  );
30
56
 
31
57
  /**
32
- * Read-only flag to check if a given object is of type {@link CompressedArrayTexture}.
33
- * @remarks This is a _constant_ value
34
- * @defaultValue `true`
58
+ * Describes that a specific layer of the texture needs to be updated. Normally when {@link Texture.needsUpdate} is
59
+ * set to true, the entire compressed texture array is sent to the GPU. Marking specific layers will only transmit
60
+ * subsets of all mipmaps associated with a specific depth in the array which is often much more performant.
35
61
  */
36
- readonly isCompressedArrayTexture: true;
62
+ addLayerUpdate(layerIndex: number): void;
37
63
 
38
64
  /**
39
- * Overridden with a object containing width and height.
40
- * @override
65
+ * Resets the layer updates registry. See {@link CompressedArrayTexture.addLayerUpdate}.
41
66
  */
42
- get image(): { width: number; height: number; depth: number };
43
- set image(value: { width: number; height: number; depth: number });
44
-
45
- /**
46
- * This defines how the texture is wrapped in the depth direction.
47
- * @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
48
- * @defaultValue {@link THREE.ClampToEdgeWrapping}
49
- */
50
- wrapR: Wrapping;
67
+ clearLayoutUpdates(): void;
51
68
  }
@@ -7,8 +7,15 @@ import {
7
7
  TextureDataType,
8
8
  Wrapping,
9
9
  } from "../constants.js";
10
+ import { TypedArray } from "../core/BufferAttribute.js";
10
11
  import { Texture } from "./Texture.js";
11
12
 
13
+ export interface CompressedTextureMipmap {
14
+ data: TypedArray;
15
+ width: number;
16
+ height: number;
17
+ }
18
+
12
19
  /**
13
20
  * Creates a texture based on data in compressed form, for example from a {@link https://en.wikipedia.org/wiki/DirectDraw_Surface | DDS} file.
14
21
  * @remarks For use with the {@link THREE.CompressedTextureLoader | CompressedTextureLoader}.
@@ -18,8 +25,8 @@ import { Texture } from "./Texture.js";
18
25
  export class CompressedTexture extends Texture {
19
26
  /**
20
27
  * This creates a new {@link THREE.CompressedTexture | CompressedTexture} object.
21
- * @param mipmaps The mipmaps array should contain objects with data, width and height.
22
- * The mipmaps should be of the correct {@link format} and {@link type}. See {@link THREE.mipmaps}.
28
+ * @param mipmaps The mipmaps array should contain objects with data, width and height. The mipmaps should be of the
29
+ * correct format and type.
23
30
  * @param width The width of the biggest mipmap.
24
31
  * @param height The height of the biggest mipmap.
25
32
  * @param format The format used in the mipmaps. See {@link THREE.CompressedPixelFormat}.
@@ -33,10 +40,10 @@ export class CompressedTexture extends Texture {
33
40
  * @param colorSpace See {@link Texture.colorSpace .colorSpace}. Default {@link NoColorSpace}
34
41
  */
35
42
  constructor(
36
- mipmaps: ImageData[],
37
- width: number,
38
- height: number,
39
- format: CompressedPixelFormat,
43
+ mipmaps?: CompressedTextureMipmap[],
44
+ width?: number,
45
+ height?: number,
46
+ format?: CompressedPixelFormat,
40
47
  type?: TextureDataType,
41
48
  mapping?: Mapping,
42
49
  wrapS?: Wrapping,
@@ -62,9 +69,10 @@ export class CompressedTexture extends Texture {
62
69
  set image(value: { width: number; height: number });
63
70
 
64
71
  /**
65
- * The mipmaps array should contain objects with data, width and height. The mipmaps should be of the correct {@link format} and {@link type}.
72
+ * The mipmaps array should contain objects with data, width and height. The mipmaps should be of the correct
73
+ * format and type.
66
74
  */
67
- mipmaps: ImageData[];
75
+ mipmaps: CompressedTextureMipmap[] | undefined;
68
76
 
69
77
  /**
70
78
  * @override