@types/three 0.184.0 → 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 (208) 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/Matrix2.d.ts +1 -1
  90. three/src/math/Matrix3.d.ts +10 -1
  91. three/src/math/Matrix4.d.ts +329 -105
  92. three/src/math/Vector2.d.ts +1 -2
  93. three/src/math/Vector3.d.ts +3 -4
  94. three/src/math/Vector4.d.ts +1 -2
  95. three/src/math/interpolants/BezierInterpolant.d.ts +19 -3
  96. three/src/math/interpolants/CubicInterpolant.d.ts +18 -3
  97. three/src/math/interpolants/DiscreteInterpolant.d.ts +8 -3
  98. three/src/math/interpolants/LinearInterpolant.d.ts +7 -3
  99. three/src/math/interpolants/QuaternionLinearInterpolant.d.ts +7 -3
  100. three/src/nodes/Nodes.d.ts +4 -13
  101. three/src/nodes/TSL.d.ts +7 -5
  102. three/src/nodes/accessors/Batch.d.ts +19 -0
  103. three/src/nodes/accessors/Instance.d.ts +34 -0
  104. three/src/nodes/accessors/MaterialNode.d.ts +86 -79
  105. three/src/nodes/accessors/Morph.d.ts +11 -0
  106. three/src/nodes/accessors/Skinning.d.ts +23 -0
  107. three/src/nodes/accessors/StorageBufferNode.d.ts +22 -23
  108. three/src/nodes/accessors/StorageTexture3DNode.d.ts +17 -0
  109. three/src/nodes/accessors/StorageTextureNode.d.ts +6 -4
  110. three/src/nodes/accessors/TextureNode.d.ts +15 -10
  111. three/src/nodes/core/ArrayNode.d.ts +16 -8
  112. three/src/nodes/core/ContextNode.d.ts +5 -6
  113. three/src/nodes/core/LightingModel.d.ts +2 -0
  114. three/src/nodes/core/Node.d.ts +50 -51
  115. three/src/nodes/core/NodeBuilder.d.ts +1 -133
  116. three/src/nodes/core/OverrideContextNode.d.ts +92 -0
  117. three/src/nodes/core/PropertyNode.d.ts +13 -2
  118. three/src/nodes/core/StructNode.d.ts +0 -2
  119. three/src/nodes/core/StructTypeNode.d.ts +5 -4
  120. three/src/nodes/core/UniformNode.d.ts +48 -9
  121. three/src/nodes/display/BlendModes.d.ts +72 -11
  122. three/src/nodes/display/FrontFacingNode.d.ts +62 -3
  123. three/src/nodes/display/PassNode.d.ts +0 -2
  124. three/src/nodes/display/PremultiplyAlphaFunctions.d.ts +37 -0
  125. three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +53 -45
  126. three/src/nodes/lighting/LightingContextNode.d.ts +9 -2
  127. three/src/nodes/lighting/LightsNode.d.ts +4 -4
  128. three/src/nodes/math/MathNode.d.ts +358 -304
  129. three/src/nodes/math/OperatorNode.d.ts +253 -82
  130. three/src/nodes/tsl/TSLCore.d.ts +16 -9
  131. three/src/nodes/utils/ArrayElementNode.d.ts +5 -4
  132. three/src/nodes/utils/EquirectUV.d.ts +31 -1
  133. three/src/nodes/utils/Packing.d.ts +50 -3
  134. three/src/nodes/utils/RTTNode.d.ts +7 -12
  135. three/src/nodes/utils/Remap.d.ts +216 -29
  136. three/src/nodes/utils/SampleNode.d.ts +18 -8
  137. three/src/objects/BatchedMesh.d.ts +1 -1
  138. three/src/objects/InstancedMesh.d.ts +0 -8
  139. three/src/objects/Skeleton.d.ts +0 -2
  140. three/src/renderers/common/Backend.d.ts +0 -3
  141. three/src/renderers/common/CanvasTarget.d.ts +0 -49
  142. three/src/renderers/common/ClippingContext.d.ts +6 -1
  143. three/src/renderers/common/CubeRenderTarget.d.ts +2 -1
  144. three/src/renderers/common/Info.d.ts +26 -66
  145. three/src/renderers/common/InspectorBase.d.ts +0 -7
  146. three/src/renderers/common/Lighting.d.ts +49 -5
  147. three/src/renderers/common/Renderer.d.ts +34 -458
  148. three/src/renderers/common/RendererUtils.d.ts +1 -2
  149. three/src/renderers/common/TimestampQueryPool.d.ts +1 -1
  150. three/src/renderers/common/XRManager.d.ts +32 -299
  151. three/src/renderers/common/nodes/NodeLibrary.d.ts +0 -117
  152. three/src/renderers/webgl/WebGLPrograms.d.ts +2 -0
  153. three/src/renderers/webgl/WebGLRenderLists.d.ts +5 -1
  154. three/src/renderers/webgl/WebGLState.d.ts +2 -0
  155. three/src/renderers/webgl-fallback/WebGLBackend.d.ts +1 -1
  156. three/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.d.ts +0 -10
  157. three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +0 -1
  158. three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +5 -121
  159. three/src/textures/CubeDepthTexture.d.ts +2 -3
  160. three/src/textures/DataTexture.d.ts +2 -1
  161. three/src/textures/DepthTexture.d.ts +5 -5
  162. three/examples/jsm/lighting/TiledLighting.d.ts +0 -9
  163. three/examples/jsm/tsl/display/AnamorphicNode.d.ts +0 -31
  164. three/examples/jsm/tsl/lighting/TiledLightsNode.d.ts +0 -22
  165. three/src/nodes/accessors/BatchNode.d.ts +0 -12
  166. three/src/nodes/accessors/InstanceNode.d.ts +0 -30
  167. three/src/nodes/accessors/InstancedMeshNode.d.ts +0 -10
  168. three/src/nodes/accessors/MorphNode.d.ts +0 -14
  169. three/src/nodes/accessors/SkinningNode.d.ts +0 -32
  170. three/src/renderers/common/Animation.d.ts +0 -102
  171. three/src/renderers/common/Attributes.d.ts +0 -59
  172. three/src/renderers/common/Background.d.ts +0 -47
  173. three/src/renderers/common/BindGroup.d.ts +0 -39
  174. three/src/renderers/common/Binding.d.ts +0 -50
  175. three/src/renderers/common/Bindings.d.ts +0 -132
  176. three/src/renderers/common/Buffer.d.ts +0 -90
  177. three/src/renderers/common/ChainMap.d.ts +0 -49
  178. three/src/renderers/common/Color4.d.ts +0 -55
  179. three/src/renderers/common/ComputePipeline.d.ts +0 -34
  180. three/src/renderers/common/DataMap.d.ts +0 -42
  181. three/src/renderers/common/Geometries.d.ts +0 -111
  182. three/src/renderers/common/Pipeline.d.ts +0 -29
  183. three/src/renderers/common/Pipelines.d.ts +0 -186
  184. three/src/renderers/common/ProgrammableStage.d.ts +0 -73
  185. three/src/renderers/common/RenderBundle.d.ts +0 -25
  186. three/src/renderers/common/RenderBundles.d.ts +0 -34
  187. three/src/renderers/common/RenderContext.d.ts +0 -235
  188. three/src/renderers/common/RenderContexts.d.ts +0 -47
  189. three/src/renderers/common/RenderList.d.ts +0 -226
  190. three/src/renderers/common/RenderLists.d.ts +0 -46
  191. three/src/renderers/common/RenderObject.d.ts +0 -448
  192. three/src/renderers/common/RenderObjectPipeline.d.ts +0 -33
  193. three/src/renderers/common/RenderObjects.d.ts +0 -151
  194. three/src/renderers/common/SampledTexture.d.ts +0 -28
  195. three/src/renderers/common/Sampler.d.ts +0 -19
  196. three/src/renderers/common/Textures.d.ts +0 -125
  197. three/src/renderers/common/Uniform.d.ts +0 -262
  198. three/src/renderers/common/UniformBuffer.d.ts +0 -20
  199. three/src/renderers/common/UniformsGroup.d.ts +0 -152
  200. three/src/renderers/common/XRRenderTarget.d.ts +0 -67
  201. three/src/renderers/common/nodes/NodeBuilderState.d.ts +0 -121
  202. three/src/renderers/common/nodes/NodeManager.d.ts +0 -309
  203. three/src/renderers/common/nodes/NodeSampledTexture.d.ts +0 -29
  204. three/src/renderers/common/nodes/NodeSampler.d.ts +0 -12
  205. three/src/renderers/common/nodes/NodeUniform.d.ts +0 -250
  206. three/src/renderers/common/nodes/NodeUniformsGroup.d.ts +0 -41
  207. three/src/renderers/webgpu/nodes/WGSLNodeFunction.d.ts +0 -6
  208. three/src/renderers/webgpu/nodes/WGSLNodeParser.d.ts +0 -6
@@ -1,25 +1,33 @@
1
1
  import Node from "./Node.js";
2
2
  import TempNode from "./TempNode.js";
3
3
 
4
- declare class ArrayNode extends TempNode {
4
+ export interface ArrayNodeInterface<TNodeType> {
5
5
  count: number;
6
- values: Node[];
6
+ values: Node<TNodeType>[] | null;
7
7
  readonly isArrayNode: true;
8
-
9
- constructor(nodeType: string, count: number, values: Node[]);
10
8
  }
11
9
 
10
+ declare const ArrayNode: {
11
+ new<TNodeType>(
12
+ nodeType: TNodeType | null,
13
+ count: number,
14
+ values?: Node<TNodeType>[] | null,
15
+ ): ArrayNode<TNodeType>;
16
+ };
17
+
18
+ type ArrayNode<TNodeType> = TempNode<TNodeType> & ArrayNodeInterface<TNodeType>;
19
+
12
20
  export default ArrayNode;
13
21
 
14
22
  interface ArrayFunction {
15
- (values: Node[]): ArrayNode;
16
- (nodeType: string, count: number): ArrayNode;
23
+ <TNodeType>(values: Node<TNodeType>[]): ArrayNode<TNodeType>;
24
+ <TNodeType extends string>(nodeType: TNodeType, count: number): ArrayNode<TNodeType>;
17
25
  }
18
26
 
19
27
  export const array: ArrayFunction;
20
28
 
21
29
  declare module "./Node.js" {
22
- interface NodeElements {
23
- toArray: (count: number) => ArrayNode;
30
+ interface NodeExtensions<TNodeType> {
31
+ toArray: (count: number) => ArrayNode<TNodeType>;
24
32
  }
25
33
  }
@@ -1,16 +1,15 @@
1
1
  import { Light } from "../../lights/Light.js";
2
2
  import Node from "./Node.js";
3
- import { NodeBuilderContext } from "./NodeBuilder.js";
4
3
 
5
4
  declare class ContextNodeInterface<TNodeType> extends Node {
6
5
  readonly isContextNode: true;
7
6
 
8
7
  node: Node<TNodeType> | null;
9
- value: NodeBuilderContext;
8
+ value: unknown;
10
9
  }
11
10
 
12
11
  declare const ContextNode: {
13
- new<TNodeType>(node?: Node<TNodeType> | null, value?: NodeBuilderContext): ContextNode<TNodeType>;
12
+ new<TNodeType>(node?: Node<TNodeType> | null, value?: unknown): ContextNode<TNodeType>;
14
13
  };
15
14
 
16
15
  type ContextNode<TNodeType> = ContextNodeInterface<TNodeType> & Node<TNodeType>;
@@ -18,8 +17,8 @@ type ContextNode<TNodeType> = ContextNodeInterface<TNodeType> & Node<TNodeType>;
18
17
  export default ContextNode;
19
18
 
20
19
  interface ContextFunction {
21
- (value?: NodeBuilderContext): ContextNode<unknown>;
22
- <TNodeType>(node: Node<TNodeType>, value?: NodeBuilderContext): ContextNode<TNodeType>;
20
+ (value?: unknown): ContextNode<unknown>;
21
+ <TNodeType>(node: Node<TNodeType>, value?: unknown): ContextNode<TNodeType>;
23
22
  }
24
23
 
25
24
  export const context: ContextFunction;
@@ -39,7 +38,7 @@ export function label<TNodeType>(node: Node<TNodeType>, label: string): Node<TNo
39
38
 
40
39
  declare module "./Node.js" {
41
40
  interface NodeExtensions<TNodeType> {
42
- context: (context?: NodeBuilderContext) => ContextNode<TNodeType>;
41
+ context: (context?: unknown) => ContextNode<TNodeType>;
43
42
 
44
43
  /**
45
44
  * @deprecated "label()" has been deprecated. Use "setName()" instead.
@@ -25,6 +25,8 @@ declare class LightingModel {
25
25
  direct(lightData: LightingModelDirectInput, builder: NodeBuilder): void;
26
26
  directRectArea(lightData: LightingModelDirectRectAreaInput, builder: NodeBuilder): void;
27
27
  indirect(builder: NodeBuilder): void;
28
+ indirectDiffuse(builder: NodeBuilder): void;
29
+ indirectSpecular(builder: NodeBuilder): void;
28
30
  ambientOcclusion(builder: NodeBuilder): void;
29
31
  }
30
32
 
@@ -154,30 +154,6 @@ declare class NodeClass<TEventMap extends NodeClassEventMap = NodeClassEventMap>
154
154
  * @default true
155
155
  */
156
156
  readonly isNode: boolean;
157
- /**
158
- * The cache key of this node.
159
- *
160
- * @private
161
- * @type {?number}
162
- * @default null
163
- */
164
- private _cacheKey;
165
- /**
166
- * The UUID of the node.
167
- *
168
- * @type {string}
169
- * @default null
170
- * @private
171
- */
172
- private _uuid;
173
- /**
174
- * The cache key's version.
175
- *
176
- * @private
177
- * @type {number}
178
- * @default 0
179
- */
180
- private _cacheKeyVersion;
181
157
  /**
182
158
  * The unique ID of the node.
183
159
  *
@@ -238,7 +214,7 @@ declare class NodeClass<TEventMap extends NodeClassEventMap = NodeClassEventMap>
238
214
  * @param {Function} callback - The update method.
239
215
  * @return {Node} A reference to this node.
240
216
  */
241
- onFrameUpdate(callback: (this: this, frame: NodeFrame) => void): this;
217
+ onFrameUpdate(callback: (this: this, frame: NodeFrame) => unknown): this;
242
218
  /**
243
219
  * Convenient method for defining {@link Node#update}. Similar to {@link Node#onUpdate}, but
244
220
  * this method automatically sets the update type to `RENDER`.
@@ -246,7 +222,7 @@ declare class NodeClass<TEventMap extends NodeClassEventMap = NodeClassEventMap>
246
222
  * @param {Function} callback - The update method.
247
223
  * @return {Node} A reference to this node.
248
224
  */
249
- onRenderUpdate(callback: (this: this, frame: NodeFrame) => void): this;
225
+ onRenderUpdate(callback: (this: this, frame: NodeFrame) => unknown): this;
250
226
  /**
251
227
  * Convenient method for defining {@link Node#update}. Similar to {@link Node#onUpdate}, but
252
228
  * this method automatically sets the update type to `OBJECT`.
@@ -254,7 +230,7 @@ declare class NodeClass<TEventMap extends NodeClassEventMap = NodeClassEventMap>
254
230
  * @param {Function} callback - The update method.
255
231
  * @return {Node} A reference to this node.
256
232
  */
257
- onObjectUpdate(callback: (this: this, frame: NodeFrame) => void): this;
233
+ onObjectUpdate(callback: (this: this, frame: NodeFrame) => unknown): this;
258
234
  /**
259
235
  * Convenient method for defining {@link Node#updateReference}.
260
236
  *
@@ -297,14 +273,6 @@ declare class NodeClass<TEventMap extends NodeClassEventMap = NodeClassEventMap>
297
273
  * @param {traverseCallback} callback - A callback that is executed per node.
298
274
  */
299
275
  traverse(callback: (node: Node) => void): void;
300
- /**
301
- * Returns the child nodes of this node.
302
- *
303
- * @private
304
- * @param {Set<Node>} [ignores=new Set()] - A set of nodes to ignore during the search to avoid circular references.
305
- * @returns {Array<Object>} An array of objects describing the child nodes.
306
- */
307
- private _getChildren;
308
276
  /**
309
277
  * Returns the cache key for this node.
310
278
  *
@@ -389,7 +357,8 @@ declare class NodeClass<TEventMap extends NodeClassEventMap = NodeClassEventMap>
389
357
  * This method is used during the build process of a node and ensures
390
358
  * equal nodes are not built multiple times but just once. For example if
391
359
  * `attribute( 'uv' )` is used multiple times by the user, the build
392
- * process makes sure to process just the first node.
360
+ * process makes sure to process just the first node. It also handles
361
+ * node overrides if an override context is set.
393
362
  *
394
363
  * @param {NodeBuilder} builder - The current node builder.
395
364
  * @return {Node} The shared node if possible. Otherwise `this` is returned.
@@ -563,6 +532,18 @@ export interface ColorExtensions {
563
532
  export interface FloatVecExtensions<TVec extends FloatVecType> {
564
533
  }
565
534
 
535
+ export interface FloatOrVecExtensions<TNodeType> {
536
+ }
537
+
538
+ export interface IntOrVecExtensions<TNodeType> {
539
+ }
540
+
541
+ export interface UintOrVecExtensions<TNodeType> {
542
+ }
543
+
544
+ export interface BoolOrVecExtensions<TNodeType> {
545
+ }
546
+
566
547
  export interface Mat2Extensions {
567
548
  }
568
549
 
@@ -579,36 +560,54 @@ type Node<TNodeType = unknown> =
579
560
  & NodeClass
580
561
  & NodeElements
581
562
  & (unknown extends TNodeType ? {} : NodeExtensions<TNodeType>)
582
- & (TNodeType extends "float" ? NumOrBoolExtensions<"float"> & FloatExtensions & NumExtensions<"float">
583
- : TNodeType extends "int"
584
- ? NumOrBoolExtensions<"int"> & IntExtensions & NumExtensions<"int"> & IntegerExtensions<"int">
585
- : TNodeType extends "uint"
586
- ? NumOrBoolExtensions<"uint"> & UintExtensions & NumExtensions<"uint"> & IntegerExtensions<"uint">
587
- : TNodeType extends "bool" ? NumOrBoolExtensions<"bool"> & BoolExtensions
563
+ & (TNodeType extends "float"
564
+ ? NumOrBoolExtensions<"float"> & FloatExtensions & NumExtensions<"float"> & FloatOrVecExtensions<"float">
565
+ : TNodeType extends "int" ?
566
+ & NumOrBoolExtensions<"int">
567
+ & IntExtensions
568
+ & NumExtensions<"int">
569
+ & IntegerExtensions<"int">
570
+ & IntOrVecExtensions<"int">
571
+ : TNodeType extends "uint" ?
572
+ & NumOrBoolExtensions<"uint">
573
+ & UintExtensions
574
+ & NumExtensions<"uint">
575
+ & IntegerExtensions<"uint">
576
+ & IntOrVecExtensions<"uint">
577
+ : TNodeType extends "bool" ? NumOrBoolExtensions<"bool"> & BoolExtensions & BoolOrVecExtensions<"bool">
588
578
  : TNodeType extends "vec2" ?
589
579
  & NumOrBoolVec2Extensions<"float">
590
580
  & Vec2Extensions
591
581
  & NumVec2Extensions<"float">
592
582
  & FloatVecExtensions<"vec2">
593
- : TNodeType extends "ivec2" ? NumOrBoolVec2Extensions<"int"> & NumVec2Extensions<"int">
594
- : TNodeType extends "uvec2" ? NumOrBoolVec2Extensions<"uint"> & NumVec2Extensions<"uint">
595
- : TNodeType extends "bvec2" ? NumOrBoolVec2Extensions<"bool">
583
+ & FloatOrVecExtensions<"vec2">
584
+ : TNodeType extends "ivec2"
585
+ ? NumOrBoolVec2Extensions<"int"> & NumVec2Extensions<"int"> & IntOrVecExtensions<"ivec2">
586
+ : TNodeType extends "uvec2"
587
+ ? NumOrBoolVec2Extensions<"uint"> & NumVec2Extensions<"uint"> & IntOrVecExtensions<"uvec2">
588
+ : TNodeType extends "bvec2" ? NumOrBoolVec2Extensions<"bool"> & BoolOrVecExtensions<"bvec2">
596
589
  : TNodeType extends "vec3" ?
597
590
  & NumOrBoolVec3Extensions<"float">
598
591
  & Vec3Extensions
599
592
  & NumVec3Extensions<"float">
600
593
  & FloatVecExtensions<"vec3">
601
- : TNodeType extends "ivec3" ? NumOrBoolVec3Extensions<"int"> & NumVec3Extensions<"int">
602
- : TNodeType extends "uvec3" ? NumOrBoolVec3Extensions<"uint"> & NumVec3Extensions<"uint">
603
- : TNodeType extends "bvec3" ? NumOrBoolVec3Extensions<"bool">
594
+ & FloatOrVecExtensions<"vec3">
595
+ : TNodeType extends "ivec3"
596
+ ? NumOrBoolVec3Extensions<"int"> & NumVec3Extensions<"int"> & IntOrVecExtensions<"ivec3">
597
+ : TNodeType extends "uvec3"
598
+ ? NumOrBoolVec3Extensions<"uint"> & NumVec3Extensions<"uint"> & IntOrVecExtensions<"uvec3">
599
+ : TNodeType extends "bvec3" ? NumOrBoolVec3Extensions<"bool"> & BoolOrVecExtensions<"bvec3">
604
600
  : TNodeType extends "vec4" ?
605
601
  & NumOrBoolVec4Extensions<"float">
606
602
  & Vec4Extensions
607
603
  & NumVec4Extensions<"float">
608
604
  & FloatVecExtensions<"vec4">
609
- : TNodeType extends "ivec4" ? NumOrBoolVec4Extensions<"int"> & NumVec4Extensions<"int">
610
- : TNodeType extends "uvec4" ? NumOrBoolVec4Extensions<"uint"> & NumVec4Extensions<"uint">
611
- : TNodeType extends "bvec4" ? NumOrBoolVec4Extensions<"bool">
605
+ & FloatOrVecExtensions<"vec4">
606
+ : TNodeType extends "ivec4"
607
+ ? NumOrBoolVec4Extensions<"int"> & NumVec4Extensions<"int"> & IntOrVecExtensions<"ivec4">
608
+ : TNodeType extends "uvec4"
609
+ ? NumOrBoolVec4Extensions<"uint"> & NumVec4Extensions<"uint"> & IntOrVecExtensions<"uvec4">
610
+ : TNodeType extends "bvec4" ? NumOrBoolVec4Extensions<"bool"> & BoolOrVecExtensions<"bvec4">
612
611
  : TNodeType extends "color" ? ColorExtensions
613
612
  : TNodeType extends "mat2" ? Mat2Extensions & MatExtensions<"mat2">
614
613
  : TNodeType extends "mat3" ? Mat3Extensions & MatExtensions<"mat3">
@@ -2,143 +2,11 @@ import { BufferGeometry } from "../../core/BufferGeometry.js";
2
2
  import { Object3D } from "../../core/Object3D.js";
3
3
  import { Material } from "../../materials/Material.js";
4
4
  import Renderer from "../../renderers/common/Renderer.js";
5
- import { Texture } from "../../textures/Texture.js";
6
- import LightsNode from "../lighting/LightsNode.js";
7
- import { NodeShaderStage } from "./constants.js";
8
- import Node from "./Node.js";
9
- import NodeAttribute from "./NodeAttribute.js";
10
- import NodeCache from "./NodeCache.js";
11
- import NodeParser from "./NodeParser.js";
12
- import NodeUniform from "./NodeUniform.js";
13
- import NodeVar from "./NodeVar.js";
14
- import NodeVarying from "./NodeVarying.js";
15
- import StackNode from "./StackNode.js";
16
-
17
- export type BuildStageOption = "construct" | "analyze" | "generate";
18
-
19
- export interface FlowData {
20
- code: string;
21
- }
22
-
23
- export interface NodeData {
24
- vertex: { [key: string]: unknown };
25
- fragment: { [key: string]: unknown };
26
- compute: { [key: string]: unknown };
27
- }
28
-
29
- export interface NodeBuilderContext {
30
- [key: string]: unknown;
31
- }
32
5
 
33
6
  export default abstract class NodeBuilder {
34
7
  object: Object3D;
35
8
  material: Material;
36
9
  geometry: BufferGeometry;
37
10
  renderer: Renderer;
38
- parser: NodeParser;
39
-
40
- nodes: Node[];
41
- updateNodes: Node[];
42
- hashNodes: { [hash: string]: Node };
43
-
44
- lightsNode: LightsNode;
45
- fogNode: Node;
46
-
47
- vertexShader: string;
48
- fragmentShader: string;
49
- computeShader: string;
50
-
51
- cache: NodeCache;
52
- globalCache: NodeCache;
53
-
54
- /**
55
- * @TODO used to be missing. check the actual type later
56
- */
57
- flowsData: any;
58
-
59
- shaderStage: NodeShaderStage | null;
60
- buildStage: BuildStageOption | null;
61
- stack: StackNode;
62
-
63
- setHashNode(node: Node, hash: string): void;
64
- addNode(node: Node): void;
65
- get currentNode(): Node;
66
- isFilteredTexture(texture: Texture): boolean;
67
- getMethod(method: string): string;
68
- getNodeFromHash(hash: string): Node;
69
-
70
- addFlow(shaderStage: NodeShaderStage, node: Node): Node;
71
-
72
- setContext(context: NodeBuilderContext): void;
73
- getContext(): NodeBuilderContext;
74
- setCache(cache: NodeCache): void;
75
- getCache(): NodeCache;
76
- getCacheFromNode(node: Node, parent?: boolean): NodeCache;
77
- isAvailable(name: string): boolean;
78
-
79
- abstract getInstanceIndex(): string;
80
-
81
- abstract getDrawIndex(): string | null;
82
-
83
- abstract getFrontFacing(): string;
84
-
85
- abstract getFragCoord(): string;
86
-
87
- isFlipY(): boolean;
88
-
89
- // @TODO: rename to .generateConst()
90
- getConst(type: string, value?: unknown): Node;
91
- getType(type: string): string;
92
-
93
- generateMethod(method: string): string;
94
-
95
- getAttribute(name: string, type: string): NodeAttribute;
96
-
97
- getPropertyName(node: NodeVar | NodeUniform<unknown, unknown>, shaderStage: NodeShaderStage): string;
98
- isVector(type: string): boolean;
99
-
100
- isMatrix(type: string): boolean;
101
- isReference(type: string): boolean;
102
- getElementType(type: string): string | null;
103
- getComponentType(type: string): string | null;
104
- getVectorType(type: string): string;
105
- getTypeFromLength(length: number): string;
106
- getTypeLength(type: string): number;
107
- getVectorFromMatrix(type: string): string;
108
- getDataFromNode(node: Node, shaderStage?: NodeShaderStage): NodeData;
109
- getNodeProperties(node: Node, shaderStage?: NodeShaderStage): { [key: string]: unknown };
110
- getUniformFromNode(
111
- node: Node,
112
- type: string,
113
- shaderStage?: NodeShaderStage,
114
- name?: string | null,
115
- ): NodeUniform<unknown, string>;
116
- getVarFromNode(node: Node, type: string, shaderStage?: NodeShaderStage): NodeVar;
117
- getVaryFromNode(node: Node, type: string): NodeVarying;
118
- getCodeFromNode(node: Node, type: string, shaderStage?: NodeShaderStage): string;
119
- addFlowCode(code: string): void;
120
- getFlowData(node: Node, shaderStage: NodeShaderStage): FlowData;
121
- flowNode(node: Node): FlowData;
122
- flowChildNode(node: Node, output?: string | null): FlowData;
123
- flowNodeFromShaderStage(
124
- shaderStage: NodeShaderStage,
125
- node: Node,
126
- output?: string | null,
127
- propertyName?: string,
128
- ): FlowData;
129
- hasGeometryAttribute(name: string): boolean;
130
- abstract getAttributes(shaderStage: NodeShaderStage): string;
131
- abstract getVaryings(shaderStage: NodeShaderStage): string;
132
- getVars(shaderStage: NodeShaderStage): string;
133
- abstract getUniforms(stage: NodeShaderStage): string;
134
- getCodes(shaderStage: NodeShaderStage): string;
135
- getHash(): string;
136
- setShaderStage(shaderStage: NodeShaderStage): void;
137
- getShaderStage(): NodeShaderStage;
138
- setBuildStage(buildStage: BuildStageOption): void;
139
- getBuildStage(): BuildStageOption;
140
- abstract buildCode(): void;
141
- build(): this;
142
- format(snippet: string, fromType: string, toType: string): string;
143
- getSignature(): string;
11
+ context: unknown;
144
12
  }
@@ -0,0 +1,92 @@
1
+ import ContextNode from "./ContextNode.js";
2
+ import Node from "./Node.js";
3
+ import NodeBuilder from "./NodeBuilder.js";
4
+
5
+ /**
6
+ * A specialized context node designed to override specific target nodes within a
7
+ * node sub-graph or flow. This allows replacing specific inputs (e.g., normal
8
+ * and position vectors) dynamically during compilation for a specific flow node,
9
+ * without having to reconstruct or duplicate the source nodes.
10
+ *
11
+ * ```js
12
+ * // Method chaining example:
13
+ * node.overrideNode( positionLocal, () => positionLocal.add( vec3( 1, 0, 0 ) ) );
14
+ *
15
+ * // Context assignment example:
16
+ * material.contextNode = overrideNode( positionLocal, () => positionLocal.add( vec3( 1, 0, 0 ) ) );
17
+ * ```
18
+ *
19
+ * @augments ContextNode
20
+ */
21
+ declare class OverrideContextNode extends ContextNode<unknown> {
22
+ /**
23
+ * Constructs a new override context node.
24
+ *
25
+ * @param {Map<Node, Function>} overrideNodes - A map mapping target nodes to their respective override callback functions.
26
+ * @param {Node|null} [flowNode=null] - The node whose context should be modified.
27
+ */
28
+ constructor(overrideNodes: Map<Node, (nodeBuilder: NodeBuilder) => Node>, flowNode?: Node | null);
29
+ /**
30
+ * This flag can be used for type testing.
31
+ *
32
+ * @type {boolean}
33
+ * @readonly
34
+ * @default true
35
+ */
36
+ readonly isOverrideContextNode: boolean;
37
+ }
38
+
39
+ export default OverrideContextNode;
40
+
41
+ /**
42
+ * TSL function for creating an `OverrideContextNode` to override a single target node.
43
+ *
44
+ * ```js
45
+ * material.contextNode = overrideNode( positionLocal, ( builder ) => positionLocal.add( vec3( 1, 0, 0 ) ) );
46
+ * ```
47
+ *
48
+ * @tsl
49
+ * @function
50
+ * @param {Node} targetNode - The target node that should be overridden.
51
+ * @param {Function|Node|null} [callback=null] - A callback function returning the overriding node (which receives the builder as its argument), or the overriding node itself.
52
+ * @param {Node|null} [flowNode=null] - The node whose context should be modified.
53
+ * @return {OverrideContextNode} The created override context node.
54
+ */
55
+ export function overrideNode(
56
+ targetNode: Node,
57
+ callback?: ((nodeBuilder: NodeBuilder) => Node) | Node | null,
58
+ flowNode?: Node | null,
59
+ ): OverrideContextNode;
60
+
61
+ /**
62
+ * TSL function for creating an `OverrideContextNode` to override multiple target nodes.
63
+ *
64
+ * ```js
65
+ * material.contextNode = overrideNodes( [
66
+ * [ positionView, customPositionView ],
67
+ * [ positionViewDirection, ( builder ) => customPositionViewDirection ]
68
+ * ] );
69
+ * ```
70
+ *
71
+ * @tsl
72
+ * @function
73
+ * @param {Map<Node, (Function|Node)>|Array<Array<Node|Function|Node>>} overrides - The overrides mapping target nodes to callback functions or overriding nodes.
74
+ * @param {Node|null} [flowNode=null] - The node whose context should be modified.
75
+ * @return {OverrideContextNode} The created override context node.
76
+ */
77
+ export function overrideNodes(
78
+ overrides:
79
+ | Map<Node, ((nodeBuilder: NodeBuilder) => Node) | Node | null>
80
+ | Array<[Node, ((nodeBuilder: NodeBuilder) => Node) | Node | null]>,
81
+ flowNode?: Node | null,
82
+ ): OverrideContextNode;
83
+
84
+ declare module "./Node.js" {
85
+ interface NodeElements {
86
+ overrideNodes: (
87
+ overrides:
88
+ | Map<Node, ((nodeBuilder: NodeBuilder) => Node) | Node | null>
89
+ | Array<[Node, ((nodeBuilder: NodeBuilder) => Node) | Node | null]>,
90
+ ) => OverrideContextNode;
91
+ }
92
+ }
@@ -3,6 +3,7 @@ import Node from "./Node.js";
3
3
  interface PropertyNodeInterface {
4
4
  name: string | null;
5
5
  varying: boolean;
6
+ placeholderNode: Node;
6
7
 
7
8
  readonly isPropertyNode: true;
8
9
  }
@@ -12,6 +13,7 @@ declare const PropertyNode: {
12
13
  nodeType: TNodeType,
13
14
  name?: string | null,
14
15
  varying?: boolean,
16
+ placeholderNode?: Node | null,
15
17
  ): PropertyNode<TNodeType>;
16
18
  };
17
19
 
@@ -19,8 +21,16 @@ type PropertyNode<TNodeType> = Node<TNodeType> & PropertyNodeInterface;
19
21
 
20
22
  export default PropertyNode;
21
23
 
22
- export const property: <const TNodeType>(type: TNodeType, name?: string | null) => PropertyNode<TNodeType>;
23
- export const varyingProperty: <const TNodeType>(type: TNodeType, name?: string | null) => PropertyNode<TNodeType>;
24
+ export const property: <const TNodeType>(
25
+ type: TNodeType,
26
+ name?: string | null,
27
+ placeholderNode?: Node | null,
28
+ ) => PropertyNode<TNodeType>;
29
+ export const varyingProperty: <const TNodeType>(
30
+ type: TNodeType,
31
+ name?: string | null,
32
+ placeholderNode?: Node | null,
33
+ ) => PropertyNode<TNodeType>;
24
34
 
25
35
  export const diffuseColor: PropertyNode<"vec4">;
26
36
  export const diffuseContribution: PropertyNode<"vec3">;
@@ -52,3 +62,4 @@ export const thickness: PropertyNode<"float">;
52
62
  export const attenuationDistance: PropertyNode<"float">;
53
63
  export const attenuationColor: PropertyNode<"color">;
54
64
  export const dispersion: PropertyNode<"float">;
65
+ export const ambientOcclusion: PropertyNode<"float">;
@@ -13,8 +13,6 @@ export interface Struct {
13
13
  (): StructNode;
14
14
  (values: Node[]): StructNode;
15
15
  (...values: Node[]): StructNode;
16
- layout: StructTypeNode;
17
- isStruct: true;
18
16
  }
19
17
 
20
18
  export const struct: (membersLayout: MembersLayout, name?: string | null) => Struct;
@@ -43,12 +43,13 @@ declare class StructTypeNode extends Node {
43
43
  * @readonly
44
44
  * @default true
45
45
  */
46
- readonly isStructLayoutNode: boolean;
46
+ readonly isStructTypeNode: boolean;
47
47
  /**
48
- * Returns the length of the struct.
49
- * The length is calculated by summing the lengths of the struct's members.
48
+ * Returns the length of the struct in 4-byte elements (e.g. float or int components).
49
+ * The length is calculated by summing the lengths of the struct's members, accounting for memory alignment.
50
+ * To get the size in bytes, multiply the returned value by 4.
50
51
  *
51
- * @returns {number} The length of the struct.
52
+ * @returns {number} The length of the struct in 4-byte elements.
52
53
  */
53
54
  getLength(): number;
54
55
  }
@@ -71,9 +71,17 @@ declare class UniformNodeClass<TValue> extends InputNode<unknown, TValue> {
71
71
  * @return {string} The uniform hash.
72
72
  */
73
73
  getUniformHash(builder: NodeBuilder): string;
74
- onUpdate(callback: (frame: NodeFrame, self: this) => TValue | undefined, updateType: NodeUpdateType): this;
74
+ onUpdate(
75
+ callback: (this: this, frame: NodeFrame, self: this) => TValue | undefined,
76
+ updateType: NodeUpdateType,
77
+ ): this;
75
78
  getInputType(builder: NodeBuilder): string;
76
79
  generate(builder: NodeBuilder, output: string | null): string;
80
+
81
+ // In UniformNode, callbacks provided to onUpdate-related functions are called with `this` as the last parameter:
82
+ onFrameUpdate(callback: (this: this, frame: NodeFrame, self: this) => TValue | undefined): this;
83
+ onRenderUpdate(callback: (this: this, frame: NodeFrame, self: this) => TValue | undefined): this;
84
+ onObjectUpdate(callback: (this: this, frame: NodeFrame, self: this) => TValue | undefined): this;
77
85
  }
78
86
 
79
87
  declare const UniformNode: {
@@ -90,16 +98,45 @@ type UniformNode<TNodeType, TValue> = UniformNodeClass<TValue> & InputNode<TNode
90
98
 
91
99
  export default UniformNode;
92
100
 
101
+ interface UniformValue {
102
+ float: number;
103
+ int: number;
104
+ uint: number;
105
+ bool: boolean;
106
+ vec2: Vector2;
107
+ ivec2: Vector2;
108
+ uvec2: Vector2;
109
+ vec3: Vector3;
110
+ ivec3: Vector3;
111
+ uvec3: Vector3;
112
+ vec4: Vector4;
113
+ ivec4: Vector4;
114
+ uvec4: Vector4;
115
+ mat2: Matrix2;
116
+ mat3: Matrix3;
117
+ mat4: Matrix4;
118
+ color: Color;
119
+ }
120
+
93
121
  interface Uniform {
122
+ <const TNodeType extends keyof UniformValue>(type: TNodeType): UniformNode<TNodeType, UniformValue[TNodeType]>;
94
123
  (value: number, type?: "float"): UniformNode<"float", number>;
95
- (value: boolean): UniformNode<"bool", boolean>;
96
- (value: Vector2): UniformNode<"vec2", Vector2>;
97
- (value: Vector3): UniformNode<"vec3", Vector3>;
98
- (value: Vector4): UniformNode<"vec4", Vector4>;
99
- (value: Matrix2): UniformNode<"mat2", Matrix2>;
100
- (value: Matrix3): UniformNode<"mat3", Matrix3>;
101
- (value: Matrix4): UniformNode<"mat4", Matrix4>;
102
- (value: Color): UniformNode<"color", Color>;
124
+ (value: number, type: "int"): UniformNode<"int", number>;
125
+ (value: number, type: "uint"): UniformNode<"uint", number>;
126
+ (value: boolean, type?: "bool"): UniformNode<"bool", boolean>;
127
+ (value: Vector2, type?: "vec2"): UniformNode<"vec2", Vector2>;
128
+ (value: Vector2, type: "ivec2"): UniformNode<"ivec2", Vector2>;
129
+ (value: Vector2, type: "uvec2"): UniformNode<"uvec2", Vector2>;
130
+ (value: Vector3, type?: "vec3"): UniformNode<"vec3", Vector3>;
131
+ (value: Vector3, type: "ivec3"): UniformNode<"ivec3", Vector3>;
132
+ (value: Vector3, type: "uvec3"): UniformNode<"uvec3", Vector3>;
133
+ (value: Vector4, type?: "vec4"): UniformNode<"vec4", Vector4>;
134
+ (value: Vector4, type: "ivec4"): UniformNode<"ivec4", Vector4>;
135
+ (value: Vector4, type: "uvec4"): UniformNode<"uvec4", Vector4>;
136
+ (value: Matrix2, type?: "mat2"): UniformNode<"mat2", Matrix2>;
137
+ (value: Matrix3, type?: "mat3"): UniformNode<"mat3", Matrix3>;
138
+ (value: Matrix4, type?: "mat4"): UniformNode<"mat4", Matrix4>;
139
+ (value: Color, type?: "color"): UniformNode<"color", Color>;
103
140
  <TNodeType, TValue>(value: InputNode<TNodeType, TValue>): UniformNode<TNodeType, TValue>;
104
141
  <TNodeType, TValue>(value: VarNode<TNodeType, ConstNode<TNodeType, TValue>>): UniformNode<TNodeType, TValue>;
105
142
  }
@@ -113,3 +150,5 @@ interface Uniform {
113
150
  * @returns {UniformNode}
114
151
  */
115
152
  export declare const uniform: Uniform;
153
+
154
+ export {};