@types/three 0.171.0 → 0.172.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 (121) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/Addons.d.ts +0 -5
  3. three/examples/jsm/controls/ArcballControls.d.ts +1 -1
  4. three/examples/jsm/controls/OrbitControls.d.ts +5 -0
  5. three/examples/jsm/csm/CSMShadowNode.d.ts +2 -3
  6. three/examples/jsm/geometries/InstancedPointsGeometry.d.ts +13 -0
  7. three/examples/jsm/helpers/VertexNormalsHelper.d.ts +2 -0
  8. three/examples/jsm/lines/LineSegments2.d.ts +3 -1
  9. three/examples/jsm/modifiers/CurveModifier.d.ts +1 -1
  10. three/examples/jsm/modifiers/CurveModifierGPU.d.ts +1 -1
  11. three/examples/jsm/objects/InstancedPoints.d.ts +10 -0
  12. three/examples/jsm/postprocessing/OutlinePass.d.ts +1 -1
  13. three/examples/jsm/postprocessing/UnrealBloomPass.d.ts +1 -1
  14. three/examples/jsm/utils/ShadowMapViewer.d.ts +2 -2
  15. three/package.json +2 -2
  16. three/src/Three.Core.d.ts +2 -1
  17. three/src/Three.TSL.d.ts +9 -4
  18. three/src/Three.WebGPU.Nodes.d.ts +2 -2
  19. three/src/Three.WebGPU.d.ts +2 -2
  20. three/src/cameras/CubeCamera.d.ts +19 -2
  21. three/src/core/RenderTarget.d.ts +3 -5
  22. three/src/core/RenderTarget3D.d.ts +9 -0
  23. three/src/core/RenderTargetArray.d.ts +9 -0
  24. three/src/materials/Material.d.ts +3 -1
  25. three/src/materials/MeshDepthMaterial.d.ts +0 -5
  26. three/src/materials/MeshDistanceMaterial.d.ts +0 -5
  27. three/src/materials/nodes/Line2NodeMaterial.d.ts +1 -0
  28. three/src/materials/nodes/MeshSSSNodeMaterial.d.ts +6 -6
  29. three/src/materials/nodes/NodeMaterial.d.ts +3 -0
  30. three/src/materials/nodes/manager/NodeMaterialObserver.d.ts +56 -0
  31. three/src/nodes/Nodes.d.ts +1 -6
  32. three/src/nodes/TSL.d.ts +2 -3
  33. three/src/nodes/accessors/Arrays.d.ts +3 -2
  34. three/src/nodes/accessors/BufferAttributeNode.d.ts +117 -0
  35. three/src/nodes/accessors/BufferNode.d.ts +4 -4
  36. three/src/nodes/accessors/MaterialNode.d.ts +3 -3
  37. three/src/nodes/accessors/ModelNode.d.ts +10 -2
  38. three/src/nodes/accessors/ModelViewProjectionNode.d.ts +2 -6
  39. three/src/nodes/accessors/StorageBufferNode.d.ts +5 -1
  40. three/src/nodes/accessors/TextureNode.d.ts +5 -0
  41. three/src/nodes/accessors/UniformArrayNode.d.ts +3 -2
  42. three/src/nodes/core/Node.d.ts +237 -0
  43. three/src/nodes/core/NodeAttribute.d.ts +13 -0
  44. three/src/nodes/core/NodeBuilder.d.ts +1 -2
  45. three/src/nodes/core/NodeCache.d.ts +21 -0
  46. three/src/nodes/core/NodeParser.d.ts +11 -0
  47. three/src/nodes/core/NodeUniform.d.ts +28 -0
  48. three/src/nodes/core/NodeVar.d.ts +12 -0
  49. three/src/nodes/core/NodeVarying.d.ts +14 -0
  50. three/src/nodes/core/StructTypeNode.d.ts +19 -1
  51. three/src/nodes/core/UniformNode.d.ts +44 -0
  52. three/src/nodes/core/VaryingNode.d.ts +3 -0
  53. three/src/nodes/core/constants.d.ts +35 -0
  54. three/src/nodes/display/PassNode.d.ts +1 -1
  55. three/src/nodes/fog/Fog.d.ts +26 -0
  56. three/src/nodes/gpgpu/ComputeNode.d.ts +6 -1
  57. three/src/nodes/gpgpu/WorkgroupInfoNode.d.ts +2 -0
  58. three/src/nodes/lighting/ShadowBaseNode.d.ts +15 -0
  59. three/src/nodes/lighting/ShadowNode.d.ts +2 -1
  60. three/src/nodes/math/MathNode.d.ts +13 -4
  61. three/src/nodes/tsl/TSLCore.d.ts +48 -16
  62. three/src/nodes/utils/EquirectUVNode.d.ts +2 -2
  63. three/src/nodes/utils/LoopNode.d.ts +23 -2
  64. three/src/objects/ClippingGroup.d.ts +1 -1
  65. three/src/renderers/WebGLRenderer.d.ts +8 -8
  66. three/src/renderers/common/Animation.d.ts +30 -0
  67. three/src/renderers/common/Attributes.d.ts +31 -0
  68. three/src/renderers/common/Backend.d.ts +11 -0
  69. three/src/renderers/common/Background.d.ts +22 -0
  70. three/src/renderers/common/BindGroup.d.ts +15 -0
  71. three/src/renderers/common/Binding.d.ts +24 -0
  72. three/src/renderers/common/Bindings.d.ts +54 -0
  73. three/src/renderers/common/Buffer.d.ts +31 -0
  74. three/src/renderers/common/BufferUtils.d.ts +26 -0
  75. three/src/renderers/common/BundleGroup.d.ts +22 -0
  76. three/src/renderers/common/ChainMap.d.ts +31 -1
  77. three/src/renderers/common/ClippingContext.d.ts +45 -0
  78. three/src/renderers/common/Color4.d.ts +36 -0
  79. three/src/renderers/common/ComputePipeline.d.ts +12 -0
  80. three/src/renderers/common/CubeRenderTarget.d.ts +13 -0
  81. three/src/renderers/common/DataMap.d.ts +30 -0
  82. three/src/renderers/common/Geometries.d.ts +52 -0
  83. three/src/renderers/common/Info.d.ts +27 -0
  84. three/src/renderers/common/Pipeline.d.ts +11 -0
  85. three/src/renderers/common/Pipelines.d.ts +104 -0
  86. three/src/renderers/common/ProgrammableStage.d.ts +19 -1
  87. three/src/renderers/common/RenderBundle.d.ts +15 -4
  88. three/src/renderers/common/RenderBundles.d.ts +20 -2
  89. three/src/renderers/common/RenderContext.d.ts +22 -0
  90. three/src/renderers/common/RenderContexts.d.ts +42 -3
  91. three/src/renderers/common/RenderList.d.ts +85 -0
  92. three/src/renderers/common/RenderLists.d.ts +21 -0
  93. three/src/renderers/common/RenderObject.d.ts +152 -1
  94. three/src/renderers/common/RenderObjects.d.ts +53 -0
  95. three/src/renderers/common/RenderPipeline.d.ts +13 -0
  96. three/src/renderers/common/Renderer.d.ts +583 -6
  97. three/src/renderers/common/{PostProcessingUtils.d.ts → RendererUtils.d.ts} +16 -4
  98. three/src/renderers/common/StorageBufferAttribute.d.ts +1 -1
  99. three/src/renderers/common/Textures.d.ts +66 -0
  100. three/src/renderers/common/Uniform.d.ts +106 -0
  101. three/src/renderers/common/UniformBuffer.d.ts +12 -0
  102. three/src/renderers/common/UniformsGroup.d.ts +103 -0
  103. three/src/renderers/common/nodes/NodeBuilderState.d.ts +30 -0
  104. three/src/renderers/common/nodes/NodeLibrary.d.ts +71 -0
  105. three/src/renderers/common/nodes/NodeUniform.d.ts +154 -0
  106. three/src/renderers/common/nodes/NodeUniformsGroup.d.ts +14 -2
  107. three/src/renderers/common/nodes/Nodes.d.ts +185 -11
  108. three/src/renderers/webgpu/nodes/BasicNodeLibrary.d.ts +10 -0
  109. three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +11 -0
  110. three/src/textures/DataTexture.d.ts +2 -2
  111. three/src/textures/Texture.d.ts +3 -0
  112. three/examples/jsm/animation/MMDAnimationHelper.d.ts +0 -99
  113. three/examples/jsm/animation/MMDPhysics.d.ts +0 -128
  114. three/examples/jsm/exporters/MMDExporter.d.ts +0 -11
  115. three/examples/jsm/loaders/MMDLoader.d.ts +0 -60
  116. three/examples/jsm/shaders/MMDToonShader.d.ts +0 -15
  117. three/src/Three.Legacy.d.ts +0 -20
  118. three/src/nodes/core/UniformGroup.d.ts +0 -7
  119. three/src/nodes/fog/FogExp2Node.d.ts +0 -14
  120. three/src/nodes/fog/FogNode.d.ts +0 -20
  121. three/src/nodes/fog/FogRangeNode.d.ts +0 -19
@@ -4,6 +4,29 @@ import { InterleavedBuffer } from "../../core/InterleavedBuffer.js";
4
4
  import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribute.js";
5
5
  import InputNode from "../core/InputNode.js";
6
6
  import NodeBuilder from "../core/NodeBuilder.js";
7
+ /** @module BufferAttributeNode **/
8
+ /**
9
+ * In earlier `three.js` versions it was only possible to define attribute data
10
+ * on geometry level. With `BufferAttributeNode`, it is also possible to do this
11
+ * on the node level.
12
+ * ```js
13
+ * const geometry = new THREE.PlaneGeometry();
14
+ * const positionAttribute = geometry.getAttribute( 'position' );
15
+ *
16
+ * const colors = [];
17
+ * for ( let i = 0; i < position.count; i ++ ) {
18
+ * colors.push( 1, 0, 0 );
19
+ * }
20
+ *
21
+ * material.colorNode = bufferAttribute( new THREE.Float32BufferAttribute( colors, 3 ) );
22
+ * ```
23
+ * This new approach is especially interesting when geometry data are generated via
24
+ * compute shaders. The below line converts a storage buffer into an attribute node.
25
+ * ```js
26
+ * material.positionNode = positionBuffer.toAttribute();
27
+ * ```
28
+ * @augments InputNode
29
+ */
7
30
  declare class BufferAttributeNode extends InputNode<TypedArray | InterleavedBuffer | BufferAttribute> {
8
31
  static get type(): string;
9
32
  readonly isBufferNode: true;
@@ -13,39 +36,133 @@ declare class BufferAttributeNode extends InputNode<TypedArray | InterleavedBuff
13
36
  usage: Usage;
14
37
  instanced: boolean;
15
38
  attribute: BufferAttribute | InterleavedBufferAttribute | null;
39
+ /**
40
+ * Constructs a new buffer attribute node.
41
+ *
42
+ * @param {BufferAttribute|InterleavedBuffer|TypedArray} value - The attribute data.
43
+ * @param {String?} [bufferType=null] - The buffer type (e.g. `'vec3'`).
44
+ * @param {Number} [bufferStride=0] - The buffer stride.
45
+ * @param {Number} [bufferOffset=0] - The buffer offset.
46
+ */
16
47
  constructor(
17
48
  value: TypedArray | InterleavedBuffer | BufferAttribute,
18
49
  bufferType?: string | null,
19
50
  bufferStride?: number,
20
51
  bufferOffset?: number,
21
52
  );
53
+ /**
54
+ * This method is overwritten since the attribute data might be shared
55
+ * and thus the hash should be shared as well.
56
+ *
57
+ * @param {NodeBuilder} builder - The current node builder.
58
+ * @return {String} The hash.
59
+ */
22
60
  getHash(builder: NodeBuilder): string;
61
+ /**
62
+ * This method is overwritten since the node type is inferred from
63
+ * the buffer attribute.
64
+ *
65
+ * @param {NodeBuilder} builder - The current node builder.
66
+ * @return {String} The node type.
67
+ */
23
68
  getNodeType(builder: NodeBuilder): string | null;
69
+ /**
70
+ * Depending on which value was passed to the node, `setup()` behaves
71
+ * differently. If no instance of `BufferAttribute` was passed, the method
72
+ * creates an internal attribute and configures it respectively.
73
+ *
74
+ * @param {NodeBuilder} builder - The current node builder.
75
+ */
24
76
  setup(builder: NodeBuilder): void;
77
+ /**
78
+ * Generates the code snippet of the buffer attribute node.
79
+ *
80
+ * @param {NodeBuilder} builder - The current node builder.
81
+ * @return {String} The generated code snippet.
82
+ */
25
83
  generate(builder: NodeBuilder): string | null | undefined;
84
+ /**
85
+ * Overwrites the default implementation to return a fixed value `'bufferAttribute'`.
86
+ *
87
+ * @param {NodeBuilder} builder - The current node builder.
88
+ * @return {String} The input type.
89
+ */
26
90
  getInputType(): string;
91
+ /**
92
+ * Sets the `usage` property to the given value.
93
+ *
94
+ * @param {Number} value - The usage to set.
95
+ * @return {BufferAttributeNode} A reference to this node.
96
+ */
27
97
  setUsage(value: Usage): this;
98
+ /**
99
+ * Sets the `instanced` property to the given value.
100
+ *
101
+ * @param {Number} value - The value to set.
102
+ * @return {BufferAttributeNode} A reference to this node.
103
+ */
28
104
  setInstanced(value: boolean): this;
29
105
  }
30
106
  export default BufferAttributeNode;
107
+ /**
108
+ * TSL function for creating a buffer attribute node.
109
+ *
110
+ * @function
111
+ * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
112
+ * @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
113
+ * @param {Number} [stride=0] - The buffer stride.
114
+ * @param {Number} [offset=0] - The buffer offset.
115
+ * @returns {BufferAttributeNode}
116
+ */
31
117
  export declare const bufferAttribute: (
32
118
  array: TypedArray | InterleavedBuffer | BufferAttribute,
33
119
  type?: string | null,
34
120
  stride?: number,
35
121
  offset?: number,
36
122
  ) => import("../tsl/TSLCore.js").ShaderNodeObject<BufferAttributeNode>;
123
+ /**
124
+ * TSL function for creating a buffer attribute node but with dynamic draw usage.
125
+ * Use this function if attribute data are updated per frame.
126
+ *
127
+ * @function
128
+ * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
129
+ * @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
130
+ * @param {Number} [stride=0] - The buffer stride.
131
+ * @param {Number} [offset=0] - The buffer offset.
132
+ * @returns {BufferAttributeNode}
133
+ */
37
134
  export declare const dynamicBufferAttribute: (
38
135
  array: TypedArray | InterleavedBuffer | BufferAttribute,
39
136
  type?: string | null,
40
137
  stride?: number,
41
138
  offset?: number,
42
139
  ) => import("../tsl/TSLCore.js").ShaderNodeObject<BufferAttributeNode>;
140
+ /**
141
+ * TSL function for creating a buffer attribute node but with enabled instancing
142
+ *
143
+ * @function
144
+ * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
145
+ * @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
146
+ * @param {Number} [stride=0] - The buffer stride.
147
+ * @param {Number} [offset=0] - The buffer offset.
148
+ * @returns {BufferAttributeNode}
149
+ */
43
150
  export declare const instancedBufferAttribute: (
44
151
  array: TypedArray | InterleavedBuffer | BufferAttribute,
45
152
  type?: string | null,
46
153
  stride?: number,
47
154
  offset?: number,
48
155
  ) => import("../tsl/TSLCore.js").ShaderNodeObject<BufferAttributeNode>;
156
+ /**
157
+ * TSL function for creating a buffer attribute node but with dynamic draw usage and enabled instancing
158
+ *
159
+ * @function
160
+ * @param {BufferAttribute|InterleavedBuffer|TypedArray} array - The attribute data.
161
+ * @param {String?} [type=null] - The buffer type (e.g. `'vec3'`).
162
+ * @param {Number} [stride=0] - The buffer stride.
163
+ * @param {Number} [offset=0] - The buffer offset.
164
+ * @returns {BufferAttributeNode}
165
+ */
49
166
  export declare const instancedDynamicBufferAttribute: (
50
167
  array: TypedArray | InterleavedBuffer | BufferAttribute,
51
168
  type?: string | null,
@@ -1,17 +1,17 @@
1
1
  import UniformNode from "../core/UniformNode.js";
2
2
  import { NodeOrType, ShaderNodeObject } from "../tsl/TSLCore.js";
3
3
 
4
- export default class BufferNode extends UniformNode<unknown> {
4
+ export default class BufferNode<TValue> extends UniformNode<TValue> {
5
5
  isBufferNode: true;
6
6
 
7
7
  bufferType: string;
8
8
  bufferCount: number;
9
9
 
10
- constructor(value: unknown, bufferType: string, bufferCount?: number);
10
+ constructor(value: TValue, bufferType: string, bufferCount?: number);
11
11
  }
12
12
 
13
- export const buffer: (
13
+ export const buffer: <TValue>(
14
14
  value: unknown,
15
15
  nodeOrType: NodeOrType,
16
16
  count: number,
17
- ) => ShaderNodeObject<BufferNode>;
17
+ ) => ShaderNodeObject<BufferNode<TValue>>;
@@ -40,7 +40,7 @@ export type MaterialNodeScope =
40
40
  | typeof MaterialNode.POINT_WIDTH
41
41
  | typeof MaterialNode.DISPERSION
42
42
  | typeof MaterialNode.LIGHT_MAP
43
- | typeof MaterialNode.AO_MAP
43
+ | typeof MaterialNode.AO
44
44
  | typeof MaterialNode.REFRACTION_RATIO;
45
45
 
46
46
  export default class MaterialNode extends Node {
@@ -80,7 +80,7 @@ export default class MaterialNode extends Node {
80
80
  static POINT_WIDTH: "pointWidth";
81
81
  static DISPERSION: "dispersion";
82
82
  static LIGHT_MAP: "light";
83
- static AO_MAP: "ao";
83
+ static AO: "ao";
84
84
  static REFRACTION_RATIO: "refractionRatio";
85
85
 
86
86
  scope: MaterialNodeScope;
@@ -125,5 +125,5 @@ export const materialLineDashOffset: ShaderNodeObject<MaterialNode>;
125
125
  export const materialPointWidth: ShaderNodeObject<MaterialNode>;
126
126
  export const materialDispersion: ShaderNodeObject<MaterialNode>;
127
127
  export const materialLightMap: ShaderNodeObject<MaterialNode>;
128
- export const materialAOMap: ShaderNodeObject<MaterialNode>;
128
+ export const materialAO: ShaderNodeObject<MaterialNode>;
129
129
  export const materialAnisotropyVector: ShaderNodeObject<UniformNode<Vector2>>;
@@ -18,7 +18,15 @@ export const modelScale: ShaderNodeObject<ModelNode>;
18
18
  export const modelViewPosition: ShaderNodeObject<ModelNode>;
19
19
  export const modelNormalMatrix: ShaderNodeObject<Node>;
20
20
  export const modelWorldMatrixInverse: ShaderNodeObject<UniformNode<Matrix4>>;
21
+
21
22
  export const modelViewMatrix: ShaderNodeObject<ModelNode>;
22
23
 
23
- export const highPrecisionModelViewMatrix: ShaderNodeObject<Node>;
24
- export const highPrecisionModelNormalViewMatrix: ShaderNodeObject<Node>;
24
+ // GPU Precision
25
+
26
+ export const mediumpModelViewMatrix: ShaderNodeObject<Node>;
27
+
28
+ // CPU Precision
29
+
30
+ export const highpModelViewMatrix: ShaderNodeObject<Node>;
31
+
32
+ export const highpModelNormalViewMatrix: ShaderNodeObject<Node>;
@@ -1,8 +1,4 @@
1
1
  import Node from "../core/Node.js";
2
- import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
2
+ import { ShaderNodeObject } from "../tsl/TSLCore.js";
3
3
 
4
- export default class ModelViewProjectionNode extends Node {
5
- constructor(positionNode?: Node);
6
- }
7
-
8
- export const modelViewProjection: (position?: NodeRepresentation) => ShaderNodeObject<ModelViewProjectionNode>;
4
+ export const modelViewProjection: ShaderNodeObject<Node>;
@@ -5,7 +5,7 @@ import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
5
5
  import StorageArrayElementNode from "../utils/StorageArrayElementNode.js";
6
6
  import BufferNode from "./BufferNode.js";
7
7
 
8
- export default class StorageBufferNode extends BufferNode {
8
+ export default class StorageBufferNode extends BufferNode<StorageBufferAttribute | StorageInstancedBufferAttribute> {
9
9
  readonly isStorageBufferNode: true;
10
10
 
11
11
  access: NodeAccess;
@@ -29,6 +29,10 @@ export default class StorageBufferNode extends BufferNode {
29
29
  setAccess(value: NodeAccess): this;
30
30
 
31
31
  toReadOnly(): this;
32
+
33
+ setAtmoic(value: boolean): this;
34
+
35
+ toAtomic(): this;
32
36
  }
33
37
 
34
38
  export const storage: (
@@ -31,8 +31,13 @@ export default class TextureNode extends UniformNode<Texture> {
31
31
 
32
32
  getSampler(): boolean;
33
33
 
34
+ /**
35
+ * @deprecated
36
+ */
34
37
  uv(uvNode: NodeRepresentation): ShaderNodeObject<Node>;
35
38
 
39
+ sample(uvNode: NodeRepresentation): ShaderNodeObject<Node>;
40
+
36
41
  blur(amountNode: NodeRepresentation): ShaderNodeObject<Node>;
37
42
 
38
43
  level(levelNode: NodeRepresentation): ShaderNodeObject<Node>;
@@ -7,15 +7,16 @@ declare class UniformArrayElementNode extends ArrayElementNode {
7
7
  constructor(arrayBuffer: Node, indexNode: Node);
8
8
  }
9
9
 
10
- declare class UniformArrayNode extends BufferNode {
10
+ declare class UniformArrayNode extends BufferNode<unknown[]> {
11
11
  array: unknown[];
12
12
  elementType: string | null;
13
+ paddedType: string;
13
14
 
14
15
  readonly isArrayBufferNode: true;
15
16
 
16
17
  constructor(value: unknown[], elementType?: string | null);
17
18
 
18
- getElementLength(): number;
19
+ getPaddedType(): string;
19
20
 
20
21
  element(indexNode: NodeRepresentation): ShaderNodeObject<UniformArrayElementNode>;
21
22
  }
@@ -57,6 +57,11 @@ interface NodeJSONOutputData {
57
57
  images?: unknown[];
58
58
  nodes?: NodeJSONOutputData[];
59
59
  }
60
+ /**
61
+ * Base class for all nodes.
62
+ *
63
+ * @augments EventDispatcher
64
+ */
60
65
  declare class Node extends EventDispatcher<{
61
66
  dispose: {};
62
67
  }> {
@@ -73,39 +78,271 @@ declare class Node extends EventDispatcher<{
73
78
  readonly isNode: true;
74
79
  readonly id: number;
75
80
  self?: this;
81
+ /**
82
+ * Constructs a new node.
83
+ *
84
+ * @param {String?} nodeType - The node type.
85
+ */
76
86
  constructor(nodeType?: string | null);
87
+ /**
88
+ * Set this property to `true` when the node should be regenerated.
89
+ *
90
+ * @type {Boolean}
91
+ * @default false
92
+ * @param {boolean} value
93
+ */
77
94
  set needsUpdate(value: boolean);
95
+ /**
96
+ * The type of the class. The value is usually the constructor name.
97
+ *
98
+ * @type {String}
99
+ * @readonly
100
+ */
78
101
  get type(): string | undefined;
102
+ /**
103
+ * Convenient method for defining {@link Node#update}.
104
+ *
105
+ * @param {Function} callback - The update method.
106
+ * @param {String} updateType - The update type.
107
+ * @return {Node} A reference to this node.
108
+ */
79
109
  onUpdate(callback: (this: this, frame: NodeFrame) => unknown, updateType: NodeUpdateType): this;
110
+ /**
111
+ * Convenient method for defining {@link Node#update}. Similar to {@link Node#onUpdate}, but
112
+ * this method automatically sets the update type to `FRAME`.
113
+ *
114
+ * @param {Function} callback - The update method.
115
+ * @return {Node} A reference to this node.
116
+ */
80
117
  onFrameUpdate(callback: (this: this, frame: NodeFrame) => void): this;
118
+ /**
119
+ * Convenient method for defining {@link Node#update}. Similar to {@link Node#onUpdate}, but
120
+ * this method automatically sets the update type to `RENDER`.
121
+ *
122
+ * @param {Function} callback - The update method.
123
+ * @return {Node} A reference to this node.
124
+ */
81
125
  onRenderUpdate(callback: (this: this, frame: NodeFrame) => void): this;
126
+ /**
127
+ * Convenient method for defining {@link Node#update}. Similar to {@link Node#onUpdate}, but
128
+ * this method automatically sets the update type to `OBJECT`.
129
+ *
130
+ * @param {Function} callback - The update method.
131
+ * @return {Node} A reference to this node.
132
+ */
82
133
  onObjectUpdate(callback: (this: this, frame: NodeFrame) => void): this;
134
+ /**
135
+ * Convenient method for defining {@link Node#updateReference}.
136
+ *
137
+ * @param {Function} callback - The update method.
138
+ * @return {Node} A reference to this node.
139
+ */
83
140
  onReference(callback: (this: this, frame: NodeBuilder | NodeFrame) => unknown): this;
141
+ /**
142
+ * The `this` reference might point to a Proxy so this method can be used
143
+ * to get the reference to the actual node instance.
144
+ *
145
+ * @return {Node} A reference to the node.
146
+ */
84
147
  getSelf(): this;
148
+ /**
149
+ * Nodes might refer to other objects like materials. This method allows to dynamically update the reference
150
+ * to such objects based on a given state (e.g. the current node frame or builder).
151
+ *
152
+ * @param {Any} state - This method can be invocated in different contexts so `state` can refer to any object type.
153
+ * @return {Any} The updated reference.
154
+ */
85
155
  updateReference(state: NodeBuilder | NodeFrame): unknown;
156
+ /**
157
+ * By default this method returns the value of the {@link Node#global} flag. This method
158
+ * can be overwritten in derived classes if an analytical way is required to determine the
159
+ * global status.
160
+ *
161
+ * @param {NodeBuilder} builder - The current node builder.
162
+ * @return {Boolean} Whether this node is global or not.
163
+ */
86
164
  isGlobal(builder: NodeBuilder): boolean;
165
+ /**
166
+ * Generator function that can be used to iterate over the child nodes.
167
+ *
168
+ * @generator
169
+ * @yields {Node} A child node.
170
+ */
87
171
  getChildren(): Generator<Node, void, unknown>;
172
+ /**
173
+ * Calling this method dispatches the `dispose` event. This event can be used
174
+ * to register event listeners for clean up tasks.
175
+ */
88
176
  dispose(): void;
177
+ /**
178
+ * Callback for {@link Node#traverse}.
179
+ *
180
+ * @callback traverseCallback
181
+ * @param {Node} node - The current node.
182
+ */
183
+ /**
184
+ * Can be used to traverse through the node's hierarchy.
185
+ *
186
+ * @param {traverseCallback} callback - A callback that is executed per node.
187
+ */
89
188
  traverse(callback: (node: Node) => void): void;
189
+ /**
190
+ * Returns the cache key for this node.
191
+ *
192
+ * @param {Boolean} [force=false] - When set to `true`, a recomputation of the cache key is forced.
193
+ * @return {Number} The cache key of the node.
194
+ */
90
195
  getCacheKey(force?: boolean): number;
196
+ /**
197
+ * Generate a custom cache key for this node.
198
+ *
199
+ * @return {Number} The cache key of the node.
200
+ */
201
+ customCacheKey(): number;
202
+ /**
203
+ * Returns the references to this node which is by default `this`.
204
+ *
205
+ * @return {Node} A reference to this node.
206
+ */
91
207
  getScope(): this;
208
+ /**
209
+ * Returns the hash of the node which is used to identify the node. By default it's
210
+ * the {@link Node#uuid} however derived node classes might have to overwrite this method
211
+ * depending on their implementation.
212
+ *
213
+ * @param {NodeBuilder} builder - The current node builder.
214
+ * @return {String} The hash.
215
+ */
92
216
  getHash(builder: NodeBuilder): string;
217
+ /**
218
+ * Returns the update type of {@link Node#update}.
219
+ *
220
+ * @return {NodeUpdateType} The update type.
221
+ */
93
222
  getUpdateType(): NodeUpdateType;
223
+ /**
224
+ * Returns the update type of {@link Node#updateBefore}.
225
+ *
226
+ * @return {NodeUpdateType} The update type.
227
+ */
94
228
  getUpdateBeforeType(): NodeUpdateType;
229
+ /**
230
+ * Returns the update type of {@link Node#updateAfter}.
231
+ *
232
+ * @return {NodeUpdateType} The update type.
233
+ */
95
234
  getUpdateAfterType(): NodeUpdateType;
235
+ /**
236
+ * Certain types are composed of multiple elements. For example a `vec3`
237
+ * is composed of three `float` values. This method returns the type of
238
+ * these elements.
239
+ *
240
+ * @param {NodeBuilder} builder - The current node builder.
241
+ * @return {String} The type of the node.
242
+ */
96
243
  getElementType(builder: NodeBuilder): "bool" | "int" | "float" | "vec2" | "vec3" | "vec4" | "uint" | null;
244
+ /**
245
+ * Returns the node's type.
246
+ *
247
+ * @param {NodeBuilder} builder - The current node builder.
248
+ * @return {String} The type of the node.
249
+ */
97
250
  getNodeType(builder: NodeBuilder): string | null;
251
+ /**
252
+ * This method is used during the build process of a node and ensures
253
+ * equal nodes are not built multiple times but just once. For example if
254
+ * `attribute( 'uv' )` is used multiple times by the user, the build
255
+ * process makes sure to process just the first node.
256
+ *
257
+ * @param {NodeBuilder} builder - The current node builder.
258
+ * @return {Node} The shared node if possible. Otherwise `this` is returned.
259
+ */
98
260
  getShared(builder: NodeBuilder): Node;
261
+ /**
262
+ * Represents the setup stage which is the first step of the build process, see {@link Node#build} method.
263
+ * This method is often overwritten in derived modules to prepare the node which is used as the output/result.
264
+ * The output node must be returned in the `return` statement.
265
+ *
266
+ * @param {NodeBuilder} builder - The current node builder.
267
+ * @return {Node?} The output node.
268
+ */
99
269
  setup(builder: NodeBuilder): unknown;
270
+ /**
271
+ * Represents the analyze stage which is the second step of the build process, see {@link Node#build} method.
272
+ * This stage analyzes the node hierarchy and ensures descendent nodes are built.
273
+ *
274
+ * @param {NodeBuilder} builder - The current node builder.
275
+ */
100
276
  analyze(builder: NodeBuilder): void;
277
+ /**
278
+ * Represents the generate stage which is the third step of the build process, see {@link Node#build} method.
279
+ * This state builds the output node and returns the resulting shader string.
280
+ *
281
+ * @param {NodeBuilder} builder - The current node builder.
282
+ * @param {String?} output - Can be used to define the output type.
283
+ * @return {String?} The generated shader string.
284
+ */
101
285
  generate(builder: NodeBuilder, output?: string | null): string | null | undefined;
286
+ /**
287
+ * The method can be implemented to update the node's internal state before it is used to render an object.
288
+ * The {@link Node#updateBeforeType} property defines how often the update is executed.
289
+ *
290
+ * @abstract
291
+ * @param {NodeFrame} frame - A reference to the current node frame.
292
+ * @return {Boolean?} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching).
293
+ */
102
294
  updateBefore(frame: NodeFrame): void;
295
+ /**
296
+ * The method can be implemented to update the node's internal state after it was used to render an object.
297
+ * The {@link Node#updateAfterType} property defines how often the update is executed.
298
+ *
299
+ * @abstract
300
+ * @param {NodeFrame} frame - A reference to the current node frame.
301
+ * @return {Boolean?} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching).
302
+ */
103
303
  updateAfter(frame: NodeFrame): void;
304
+ /**
305
+ * The method can be implemented to update the node's internal state when it is used to render an object.
306
+ * The {@link Node#updateType} property defines how often the update is executed.
307
+ *
308
+ * @abstract
309
+ * @param {NodeFrame} frame - A reference to the current node frame.
310
+ * @return {Boolean?} An optional bool that indicates whether the implementation actually performed an update or not (e.g. due to caching).
311
+ */
104
312
  update(frame: NodeFrame): void;
313
+ /**
314
+ * This method performs the build of a node. The behavior of this method as well as its return value depend
315
+ * on the current build stage (setup, analyze or generate).
316
+ *
317
+ * @param {NodeBuilder} builder - The current node builder.
318
+ * @param {String?} output - Can be used to define the output type.
319
+ * @return {String?} When this method is executed in the setup or analyze stage, `null` is returned. In the generate stage, the generated shader string.
320
+ */
105
321
  build(builder: NodeBuilder, output?: string | null): string | null;
322
+ /**
323
+ * Returns the child nodes as a JSON object.
324
+ *
325
+ * @return {Object} The serialized child objects as JSON.
326
+ */
106
327
  getSerializeChildren(): Generator<import("./NodeUtils.js").NodeChild, void, unknown>;
328
+ /**
329
+ * Serializes the node to JSON.
330
+ *
331
+ * @param {Object} json - The output JSON object.
332
+ */
107
333
  serialize(json: NodeJSONIntermediateOutputData): void;
334
+ /**
335
+ * Deserializes the node from the given JSON.
336
+ *
337
+ * @param {Object} json - The JSON object.
338
+ */
108
339
  deserialize(json: NodeJSONInputData): void;
340
+ /**
341
+ * Serializes the node into the three.js JSON Object/Scene format.
342
+ *
343
+ * @param {Object?} meta - An optional JSON object that already holds serialized data from other scene objects.
344
+ * @return {Object} The serialized node.
345
+ */
109
346
  toJSON(meta?: NodeJSONMeta | string): NodeJSONOutputData;
110
347
  }
111
348
  export default Node;
@@ -1,9 +1,22 @@
1
1
  import Node from "./Node.js";
2
+ /**
3
+ * {@link NodeBuilder} is going to create instances of this class during the build process
4
+ * of nodes. They represent the final shader attributes that are going to be generated
5
+ * by the builder. Arrays of node attributes is maintained in {@link NodeBuilder#attributes}
6
+ * and {@link NodeBuilder#bufferAttributes} for this purpose.
7
+ */
2
8
  declare class NodeAttribute {
3
9
  readonly isNodeAttribute: true;
4
10
  name: string;
5
11
  type: string | null;
6
12
  node: Node | null;
13
+ /**
14
+ * Constructs a new node attribute.
15
+ *
16
+ * @param {String} name - The name of the attribute.
17
+ * @param {String} type - The type of the attribute.
18
+ * @param {Node?} node - An optional reference to the node.
19
+ */
7
20
  constructor(name: string, type: string | null, node?: Node | null);
8
21
  }
9
22
  export default NodeAttribute;
@@ -3,7 +3,6 @@ import { Object3D } from "../../core/Object3D.js";
3
3
  import { Material } from "../../materials/Material.js";
4
4
  import Renderer from "../../renderers/common/Renderer.js";
5
5
  import { Texture } from "../../textures/Texture.js";
6
- import FogNode from "../fog/FogNode.js";
7
6
  import LightsNode from "../lighting/LightsNode.js";
8
7
  import { NodeShaderStage } from "./constants.js";
9
8
  import Node from "./Node.js";
@@ -41,7 +40,7 @@ export default abstract class NodeBuilder {
41
40
  hashNodes: { [hash: string]: Node };
42
41
 
43
42
  lightsNode: LightsNode;
44
- fogNode: FogNode;
43
+ fogNode: Node;
45
44
 
46
45
  vertexShader: string;
47
46
  fragmentShader: string;
@@ -39,13 +39,34 @@ interface NodeData {
39
39
  interface BufferAttributeData {
40
40
  node: BufferAttributeNode;
41
41
  }
42
+ /**
43
+ * This utility class is used in {@link NodeBuilder} as an internal
44
+ * cache data structure for node data.
45
+ */
42
46
  declare class NodeCache {
43
47
  id: number;
44
48
  nodesData: WeakMap<Node | TypedArray | InterleavedBuffer | BufferAttribute, NodeData | BufferAttributeData>;
45
49
  parent: NodeCache | null;
50
+ /**
51
+ * Constructs a new node cache.
52
+ *
53
+ * @param {NodeCache?} parent - A reference to a parent cache.
54
+ */
46
55
  constructor(parent?: NodeCache | null);
56
+ /**
57
+ * Returns the data for the given node.
58
+ *
59
+ * @param {Node} node - The node.
60
+ * @return {Object?} The data for the node.
61
+ */
47
62
  getData(node: Node): NodeData | undefined;
48
63
  getData(node: TypedArray | InterleavedBuffer | BufferAttribute): BufferAttributeData | undefined;
64
+ /**
65
+ * Sets the data for a given node.
66
+ *
67
+ * @param {Node} node - The node.
68
+ * @param {Object} data - The data that should be cached.
69
+ */
49
70
  setData(node: Node, data: NodeData): void;
50
71
  setData(node: TypedArray | InterleavedBuffer | BufferAttribute, data: BufferAttributeData): void;
51
72
  }
@@ -1,5 +1,16 @@
1
1
  import NodeFunction from "./NodeFunction.js";
2
+ /**
3
+ * Base class for node parsers. A derived parser must be implemented
4
+ * for each supported native shader language.
5
+ */
2
6
  declare abstract class NodeParser {
7
+ /**
8
+ * The method parses the given native code an returns a node function.
9
+ *
10
+ * @abstract
11
+ * @param {String} source - The native shader code.
12
+ * @return {NodeFunction} A node function.
13
+ */
3
14
  abstract parseFunction(source: string): NodeFunction;
4
15
  }
5
16
  export default NodeParser;