@types/three 0.177.0 → 0.178.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 (178) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/capabilities/WebGL.d.ts +0 -11
  3. three/examples/jsm/controls/TransformControls.d.ts +16 -1
  4. three/examples/jsm/helpers/TextureHelper.d.ts +2 -2
  5. three/examples/jsm/helpers/TextureHelperGPU.d.ts +2 -2
  6. three/examples/jsm/loaders/SVGLoader.d.ts +1 -1
  7. three/examples/jsm/physics/RapierPhysics.d.ts +1 -0
  8. three/examples/jsm/transpiler/AST.d.ts +77 -26
  9. three/examples/jsm/transpiler/TSLEncoder.d.ts +9 -3
  10. three/examples/jsm/tsl/display/AnamorphicNode.d.ts +4 -4
  11. three/examples/jsm/tsl/display/BleachBypass.d.ts +2 -2
  12. three/examples/jsm/tsl/display/BloomNode.d.ts +2 -2
  13. three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts +20 -0
  14. three/examples/jsm/tsl/display/DenoiseNode.d.ts +4 -4
  15. three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts +6 -6
  16. three/examples/jsm/tsl/display/DotScreenNode.d.ts +2 -2
  17. three/examples/jsm/tsl/display/FXAANode.d.ts +3 -3
  18. three/examples/jsm/tsl/display/FilmNode.d.ts +4 -4
  19. three/examples/jsm/tsl/display/GTAONode.d.ts +3 -3
  20. three/examples/jsm/tsl/display/GaussianBlurNode.d.ts +5 -5
  21. three/examples/jsm/tsl/display/LensflareNode.d.ts +8 -8
  22. three/examples/jsm/tsl/display/Lut3DNode.d.ts +4 -4
  23. three/examples/jsm/tsl/display/MotionBlur.d.ts +4 -4
  24. three/examples/jsm/tsl/display/OutlineNode.d.ts +3 -3
  25. three/examples/jsm/tsl/display/RGBShiftNode.d.ts +3 -3
  26. three/examples/jsm/tsl/display/SMAANode.d.ts +3 -3
  27. three/examples/jsm/tsl/display/SSRNode.d.ts +5 -5
  28. three/examples/jsm/tsl/display/Sepia.d.ts +2 -2
  29. three/examples/jsm/tsl/display/SobelOperatorNode.d.ts +3 -3
  30. three/examples/jsm/tsl/display/TransitionNode.d.ts +4 -4
  31. three/examples/jsm/tsl/display/hashBlur.d.ts +5 -5
  32. three/examples/jsm/tsl/lighting/TiledLightsNode.d.ts +5 -5
  33. three/package.json +2 -2
  34. three/src/Three.TSL.d.ts +9 -16
  35. three/src/Three.WebGPU.d.ts +2 -0
  36. three/src/constants.d.ts +13 -5
  37. three/src/core/BufferGeometry.d.ts +6 -1
  38. three/src/core/GLBufferAttribute.d.ts +18 -1
  39. three/src/helpers/AxesHelper.d.ts +3 -1
  40. three/src/materials/LineBasicMaterial.d.ts +66 -34
  41. three/src/materials/LineDashedMaterial.d.ts +41 -21
  42. three/src/materials/Material.d.ts +408 -398
  43. three/src/materials/MeshBasicMaterial.d.ts +101 -62
  44. three/src/materials/MeshDepthMaterial.d.ts +71 -32
  45. three/src/materials/MeshDistanceMaterial.d.ts +65 -29
  46. three/src/materials/MeshLambertMaterial.d.ts +179 -103
  47. three/src/materials/MeshMatcapMaterial.d.ts +97 -55
  48. three/src/materials/MeshNormalMaterial.d.ts +76 -41
  49. three/src/materials/MeshPhongMaterial.d.ts +164 -100
  50. three/src/materials/MeshPhysicalMaterial.d.ts +164 -116
  51. three/src/materials/MeshStandardMaterial.d.ts +178 -91
  52. three/src/materials/MeshToonMaterial.d.ts +130 -81
  53. three/src/materials/PointsMaterial.d.ts +77 -30
  54. three/src/materials/RawShaderMaterial.d.ts +12 -7
  55. three/src/materials/ShaderMaterial.d.ts +186 -98
  56. three/src/materials/ShadowMaterial.d.ts +49 -23
  57. three/src/materials/SpriteMaterial.d.ts +62 -33
  58. three/src/materials/nodes/Line2NodeMaterial.d.ts +87 -40
  59. three/src/materials/nodes/LineBasicNodeMaterial.d.ts +35 -16
  60. three/src/materials/nodes/LineDashedNodeMaterial.d.ts +75 -20
  61. three/src/materials/nodes/MeshBasicNodeMaterial.d.ts +49 -30
  62. three/src/materials/nodes/MeshLambertNodeMaterial.d.ts +49 -42
  63. three/src/materials/nodes/MeshMatcapNodeMaterial.d.ts +38 -26
  64. three/src/materials/nodes/MeshNormalNodeMaterial.d.ts +36 -22
  65. three/src/materials/nodes/MeshPhongNodeMaterial.d.ts +68 -48
  66. three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts +240 -65
  67. three/src/materials/nodes/MeshSSSNodeMaterial.d.ts +99 -3
  68. three/src/materials/nodes/MeshStandardNodeMaterial.d.ts +83 -47
  69. three/src/materials/nodes/MeshToonNodeMaterial.d.ts +42 -36
  70. three/src/materials/nodes/NodeMaterial.d.ts +417 -56
  71. three/src/materials/nodes/NodeMaterials.d.ts +3 -2
  72. three/src/materials/nodes/PointsNodeMaterial.d.ts +31 -7
  73. three/src/materials/nodes/ShadowNodeMaterial.d.ts +38 -11
  74. three/src/materials/nodes/SpriteNodeMaterial.d.ts +68 -20
  75. three/src/materials/nodes/VolumeNodeMaterial.d.ts +50 -14
  76. three/src/math/Color.d.ts +1 -1
  77. three/src/nodes/Nodes.d.ts +1 -3
  78. three/src/nodes/TSL.d.ts +4 -3
  79. three/src/nodes/accessors/AccessorsUtils.d.ts +3 -3
  80. three/src/nodes/accessors/Bitangent.d.ts +0 -2
  81. three/src/nodes/accessors/CubeTextureNode.d.ts +7 -7
  82. three/src/nodes/accessors/Normal.d.ts +19 -5
  83. three/src/nodes/accessors/ReferenceBaseNode.d.ts +1 -1
  84. three/src/nodes/accessors/StorageBufferNode.d.ts +3 -2
  85. three/src/nodes/accessors/StorageTextureNode.d.ts +5 -5
  86. three/src/nodes/accessors/Tangent.d.ts +0 -2
  87. three/src/nodes/accessors/TangentUtils.d.ts +22 -0
  88. three/src/nodes/accessors/Texture3DNode.d.ts +5 -4
  89. three/src/nodes/accessors/TextureBicubic.d.ts +4 -2
  90. three/src/nodes/accessors/TextureNode.d.ts +16 -16
  91. three/src/nodes/accessors/TextureSizeNode.d.ts +3 -3
  92. three/src/nodes/accessors/UniformArrayNode.d.ts +2 -7
  93. three/src/nodes/code/FunctionCallNode.d.ts +3 -1
  94. three/src/nodes/code/FunctionNode.d.ts +2 -2
  95. three/src/nodes/code/ScriptableNode.d.ts +2 -2
  96. three/src/nodes/core/AssignNode.d.ts +2 -2
  97. three/src/nodes/core/AttributeNode.d.ts +1 -1
  98. three/src/nodes/core/BypassNode.d.ts +2 -2
  99. three/src/nodes/core/CacheNode.d.ts +0 -2
  100. three/src/nodes/core/ContextNode.d.ts +3 -3
  101. three/src/nodes/core/StackNode.d.ts +3 -13
  102. three/src/nodes/core/SubBuildNode.d.ts +15 -0
  103. three/src/nodes/core/VarNode.d.ts +4 -4
  104. three/src/nodes/core/VaryingNode.d.ts +3 -3
  105. three/src/nodes/display/BlendModes.d.ts +12 -12
  106. three/src/nodes/display/BumpMapNode.d.ts +4 -3
  107. three/src/nodes/display/ColorAdjustment.d.ts +17 -17
  108. three/src/nodes/display/ColorSpaceFunctions.d.ts +3 -3
  109. three/src/nodes/display/ColorSpaceNode.d.ts +4 -4
  110. three/src/nodes/display/FrontFacingNode.d.ts +1 -0
  111. three/src/nodes/display/PosterizeNode.d.ts +3 -3
  112. three/src/nodes/display/RenderOutputNode.d.ts +2 -2
  113. three/src/nodes/display/ScreenNode.d.ts +0 -10
  114. three/src/nodes/display/ToneMappingFunctions.d.ts +7 -7
  115. three/src/nodes/display/ToneMappingNode.d.ts +6 -6
  116. three/src/nodes/display/ViewportDepthTextureNode.d.ts +3 -3
  117. three/src/nodes/fog/Fog.d.ts +10 -10
  118. three/src/nodes/functions/BSDF/Schlick_to_F0.d.ts +4 -4
  119. three/src/nodes/functions/material/getAlphaHashThreshold.d.ts +2 -2
  120. three/src/nodes/functions/material/getParallaxCorrectNormal.d.ts +4 -4
  121. three/src/nodes/geometry/RangeNode.d.ts +9 -2
  122. three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +20 -20
  123. three/src/nodes/gpgpu/ComputeNode.d.ts +2 -2
  124. three/src/nodes/lighting/PointShadowNode.d.ts +11 -11
  125. three/src/nodes/lighting/ShadowFilterNode.d.ts +11 -11
  126. three/src/nodes/materialx/MaterialXNodes.d.ts +59 -59
  127. three/src/nodes/materialx/lib/mx_hsv.d.ts +3 -3
  128. three/src/nodes/materialx/lib/mx_noise.d.ts +206 -206
  129. three/src/nodes/materialx/lib/mx_transform_color.d.ts +2 -2
  130. three/src/nodes/math/ConditionalNode.d.ts +4 -19
  131. three/src/nodes/math/Hash.d.ts +2 -2
  132. three/src/nodes/math/MathNode.d.ts +21 -17
  133. three/src/nodes/math/OperatorNode.d.ts +41 -52
  134. three/src/nodes/math/TriNoise3D.d.ts +6 -6
  135. three/src/nodes/pmrem/PMREMNode.d.ts +3 -3
  136. three/src/nodes/pmrem/PMREMUtils.d.ts +20 -20
  137. three/src/nodes/procedural/Checker.d.ts +2 -2
  138. three/src/nodes/shapes/Shapes.d.ts +2 -2
  139. three/src/nodes/tsl/TSLBase.d.ts +1 -0
  140. three/src/nodes/tsl/TSLCore.d.ts +176 -76
  141. three/src/nodes/utils/CubeMapNode.d.ts +2 -2
  142. three/src/nodes/utils/DebugNode.d.ts +2 -2
  143. three/src/nodes/utils/Discard.d.ts +2 -2
  144. three/src/nodes/utils/EquirectUV.d.ts +4 -0
  145. three/src/nodes/utils/LoopNode.d.ts +2 -7
  146. three/src/nodes/utils/MatcapUV.d.ts +4 -0
  147. three/src/nodes/utils/Oscillators.d.ts +5 -5
  148. three/src/nodes/utils/Packing.d.ts +3 -3
  149. three/src/nodes/utils/PostProcessingUtils.d.ts +9 -9
  150. three/src/nodes/utils/RTTNode.d.ts +3 -3
  151. three/src/nodes/utils/RemapNode.d.ts +9 -9
  152. three/src/nodes/utils/RotateNode.d.ts +3 -3
  153. three/src/nodes/utils/SampleNode.d.ts +16 -0
  154. three/src/nodes/utils/SpriteSheetUVNode.d.ts +4 -4
  155. three/src/nodes/utils/SpriteUtils.d.ts +2 -2
  156. three/src/nodes/utils/StorageArrayElementNode.d.ts +4 -3
  157. three/src/nodes/utils/TriplanarTextures.d.ts +20 -0
  158. three/src/nodes/utils/UVUtils.d.ts +8 -7
  159. three/src/nodes/utils/ViewportUtils.d.ts +2 -2
  160. three/src/objects/LOD.d.ts +1 -1
  161. three/src/renderers/WebGLRenderer.d.ts +1 -1
  162. three/src/renderers/common/Backend.d.ts +3 -3
  163. three/src/renderers/common/RenderObject.d.ts +10 -2
  164. three/src/renderers/common/Renderer.d.ts +5 -5
  165. three/src/renderers/common/Storage3DTexture.d.ts +40 -0
  166. three/src/renderers/common/StorageArrayTexture.d.ts +29 -0
  167. three/src/renderers/common/Textures.d.ts +2 -2
  168. three/src/renderers/common/XRRenderTarget.d.ts +3 -2
  169. three/src/renderers/common/nodes/NodeLibrary.d.ts +4 -9
  170. three/src/renderers/common/nodes/NodeSampledTexture.d.ts +1 -1
  171. three/src/renderers/common/nodes/Nodes.d.ts +1 -1
  172. three/src/renderers/webgpu/WebGPURenderer.d.ts +3 -0
  173. three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +65 -0
  174. three/src/renderers/webgpu/utils/WebGPUConstants.d.ts +9 -0
  175. three/src/nodes/utils/EquirectUVNode.d.ts +0 -8
  176. three/src/nodes/utils/MatcapUVNode.d.ts +0 -8
  177. three/src/nodes/utils/TriplanarTexturesNode.d.ts +0 -36
  178. three/src/renderers/common/nodes/StandardNodeLibrary.d.ts +0 -5
@@ -5,104 +5,465 @@ import Node from "../../nodes/core/Node.js";
5
5
  import NodeBuilder from "../../nodes/core/NodeBuilder.js";
6
6
  import LightsNode from "../../nodes/lighting/LightsNode.js";
7
7
  import { ShaderNodeObject } from "../../nodes/tsl/TSLCore.js";
8
- import { Material, MaterialParameters } from "../Material.js";
9
-
10
- export interface NodeMaterialParameters extends MaterialParameters {
11
- normals?: boolean | undefined;
12
-
13
- colorSpaced?: boolean | undefined;
14
-
15
- lightsNode?: LightsNode | null | undefined;
16
- envNode?: Node | null | undefined;
17
- aoNode?: Node | null | undefined;
18
-
19
- colorNode?: Node | null | undefined;
20
- normalNode?: Node | null | undefined;
21
- opacityNode?: Node | null | undefined;
22
- backdropNode?: Node | null | undefined;
23
- backdropAlphaNode?: Node | null | undefined;
24
- alphaTestNode?: Node | null | undefined;
25
- maskNode?: Node | null | undefined;
26
-
27
- positionNode?: Node | null | undefined;
28
- geometryNode?: Node | null | undefined;
29
-
30
- depthNode?: Node | null | undefined;
31
- receivedShadowPositionNode?: Node | null | undefined;
32
- castShadowPositionNode?: Node | null | undefined;
33
-
34
- outputNode?: Node | null | undefined;
35
-
36
- fragmentNode?: Node | null | undefined;
37
- vertexNode?: Node | null | undefined;
38
- }
39
-
40
- declare class NodeMaterial extends Material {
41
- static get type(): string;
42
-
43
- readonly isNodeMaterial: true;
8
+ import { MapColorPropertiesToColorRepresentations, Material, MaterialParameters } from "../Material.js";
9
+ import NodeMaterialObserver from "./manager/NodeMaterialObserver.js";
44
10
 
11
+ export interface NodeMaterialNodeProperties {
12
+ /**
13
+ * Whether this material is affected by fog or not.
14
+ *
15
+ * @default true
16
+ */
45
17
  fog: boolean;
18
+ /**
19
+ * Whether this material is affected by lights or not.
20
+ *
21
+ * @default false
22
+ */
46
23
  lights: boolean;
24
+ /**
25
+ * Whether this material uses hardware clipping or not.
26
+ * This property is managed by the engine and should not be
27
+ * modified by apps.
28
+ *
29
+ * @default false
30
+ */
47
31
  hardwareClipping: boolean;
48
-
32
+ /**
33
+ * Node materials which set their `lights` property to `true`
34
+ * are affected by all lights of the scene. Sometimes selective
35
+ * lighting is wanted which means only _some_ lights in the scene
36
+ * affect a material. This can be achieved by creating an instance
37
+ * of {@link LightsNode} with a list of selective
38
+ * lights and assign the node to this property.
39
+ *
40
+ * ```js
41
+ * const customLightsNode = lights( [ light1, light2 ] );
42
+ * material.lightsNode = customLightsNode;
43
+ * ```
44
+ *
45
+ * @default null
46
+ */
49
47
  lightsNode: LightsNode | null;
48
+ /**
49
+ * The environment of node materials can be defined by an environment
50
+ * map assigned to the `envMap` property or by `Scene.environment`
51
+ * if the node material is a PBR material. This node property allows to overwrite
52
+ * the default behavior and define the environment with a custom node.
53
+ *
54
+ * ```js
55
+ * material.envNode = pmremTexture( renderTarget.texture );
56
+ * ```
57
+ *
58
+ * @default null
59
+ */
50
60
  envNode: Node | null;
61
+ /**
62
+ * The lighting of node materials might be influenced by ambient occlusion.
63
+ * The default AO is inferred from an ambient occlusion map assigned to `aoMap`
64
+ * and the respective `aoMapIntensity`. This node property allows to overwrite
65
+ * the default and define the ambient occlusion with a custom node instead.
66
+ *
67
+ * If you don't want to overwrite the diffuse color but modify the existing
68
+ * values instead, use {@link materialAO}.
69
+ *
70
+ * @default null
71
+ */
51
72
  aoNode: Node | null;
52
-
73
+ /**
74
+ * The diffuse color of node materials is by default inferred from the
75
+ * `color` and `map` properties. This node property allows to overwrite the default
76
+ * and define the diffuse color with a node instead.
77
+ *
78
+ * ```js
79
+ * material.colorNode = color( 0xff0000 ); // define red color
80
+ * ```
81
+ *
82
+ * If you don't want to overwrite the diffuse color but modify the existing
83
+ * values instead, use {@link materialColor}.
84
+ *
85
+ * ```js
86
+ * material.colorNode = materialColor.mul( color( 0xff0000 ) ); // give diffuse colors a red tint
87
+ * ```
88
+ *
89
+ * @default null
90
+ */
53
91
  colorNode: Node | null;
92
+ /**
93
+ * The normals of node materials are by default inferred from the `normalMap`/`normalScale`
94
+ * or `bumpMap`/`bumpScale` properties. This node property allows to overwrite the default
95
+ * and define the normals with a node instead.
96
+ *
97
+ * If you don't want to overwrite the normals but modify the existing values instead,
98
+ * use {@link materialNormal}.
99
+ *
100
+ * @default null
101
+ */
54
102
  normalNode: Node | null;
103
+ /**
104
+ * The opacity of node materials is by default inferred from the `opacity`
105
+ * and `alphaMap` properties. This node property allows to overwrite the default
106
+ * and define the opacity with a node instead.
107
+ *
108
+ * If you don't want to overwrite the normals but modify the existing
109
+ * value instead, use {@link materialOpacity}.
110
+ *
111
+ * @default null
112
+ */
55
113
  opacityNode: Node | null;
114
+ /**
115
+ * This node can be used to implement a variety of filter-like effects. The idea is
116
+ * to store the current rendering into a texture e.g. via `viewportSharedTexture()`, use it
117
+ * to create an arbitrary effect and then assign the node composition to this property.
118
+ * Everything behind the object using this material will now be affected by a filter.
119
+ *
120
+ * ```js
121
+ * const material = new NodeMaterial()
122
+ * material.transparent = true;
123
+ *
124
+ * // everything behind the object will be monochromatic
125
+ * material.backdropNode = saturation( viewportSharedTexture().rgb, 0 );
126
+ * ```
127
+ *
128
+ * Backdrop computations are part of the lighting so only lit materials can use this property.
129
+ *
130
+ * @default null
131
+ */
56
132
  backdropNode: Node | null;
133
+ /**
134
+ * This node allows to modulate the influence of `backdropNode` to the outgoing light.
135
+ *
136
+ * @default null
137
+ */
57
138
  backdropAlphaNode: Node | null;
139
+ /**
140
+ * The alpha test of node materials is by default inferred from the `alphaTest`
141
+ * property. This node property allows to overwrite the default and define the
142
+ * alpha test with a node instead.
143
+ *
144
+ * If you don't want to overwrite the alpha test but modify the existing
145
+ * value instead, use {@link materialAlphaTest}.
146
+ *
147
+ * @default null
148
+ */
58
149
  alphaTestNode: Node | null;
150
+ /**
151
+ * Discards the fragment if the mask value is `false`.
152
+ *
153
+ * @default null
154
+ */
59
155
  maskNode: Node | null;
60
-
156
+ /**
157
+ * The local vertex positions are computed based on multiple factors like the
158
+ * attribute data, morphing or skinning. This node property allows to overwrite
159
+ * the default and define local vertex positions with nodes instead.
160
+ *
161
+ * If you don't want to overwrite the vertex positions but modify the existing
162
+ * values instead, use {@link positionLocal}.
163
+ *
164
+ * ```js
165
+ * material.positionNode = positionLocal.add( displace );
166
+ * ```
167
+ *
168
+ * @default null
169
+ */
61
170
  positionNode: Node | null;
62
- geometryNode: Node | null;
63
-
171
+ /**
172
+ * This node property is intended for logic which modifies geometry data once or per animation step.
173
+ * Apps usually place such logic randomly in initialization routines or in the animation loop.
174
+ * `geometryNode` is intended as a dedicated API so there is an intended spot where geometry modifications
175
+ * can be implemented.
176
+ *
177
+ * The idea is to assign a `Fn` definition that holds the geometry modification logic. A typical example
178
+ * would be a GPU based particle system that provides a node material for usage on app level. The particle
179
+ * simulation would be implemented as compute shaders and managed inside a `Fn` function. This function is
180
+ * eventually assigned to `geometryNode`.
181
+ *
182
+ * @default null
183
+ */
184
+ geometryNode: (() => Node) | null;
185
+ /**
186
+ * Allows to overwrite depth values in the fragment shader.
187
+ *
188
+ * @default null
189
+ */
64
190
  depthNode: Node | null;
191
+ /**
192
+ * Allows to overwrite the position used for shadow map rendering which
193
+ * is by default {@link positionWorld}, the vertex position
194
+ * in world space.
195
+ *
196
+ * @default null
197
+ */
65
198
  receivedShadowPositionNode: Node | null;
199
+ /**
200
+ * Allows to overwrite the geometry position used for shadow map projection which
201
+ * is by default {@link positionLocal}, the vertex position in local space.
202
+ *
203
+ * @default null
204
+ */
66
205
  castShadowPositionNode: Node | null;
206
+ /**
207
+ * This node can be used to influence how an object using this node material
208
+ * receive shadows.
209
+ *
210
+ * ```js
211
+ * const totalShadows = float( 1 ).toVar();
212
+ * material.receivedShadowNode = Fn( ( [ shadow ] ) => {
213
+ * totalShadows.mulAssign( shadow );
214
+ * //return float( 1 ); // bypass received shadows
215
+ * return shadow.mix( color( 0xff0000 ), 1 ); // modify shadow color
216
+ * } );
217
+ *
218
+ * @default null
219
+ */
67
220
  receivedShadowNode: (() => Node) | null;
221
+ /**
222
+ * This node can be used to influence how an object using this node material
223
+ * casts shadows. To apply a color to shadows, you can simply do:
224
+ *
225
+ * ```js
226
+ * material.castShadowNode = vec4( 1, 0, 0, 1 );
227
+ * ```
228
+ *
229
+ * Which can be nice to fake colored shadows of semi-transparent objects. It
230
+ * is also common to use the property with `Fn` function so checks are performed
231
+ * per fragment.
232
+ *
233
+ * ```js
234
+ * materialCustomShadow.castShadowNode = Fn( () => {
235
+ * hash( vertexIndex ).greaterThan( 0.5 ).discard();
236
+ * return materialColor;
237
+ * } )();
238
+ * ```
239
+ *
240
+ * @default null
241
+ */
68
242
  castShadowNode: Node | null;
69
-
243
+ /**
244
+ * This node can be used to define the final output of the material.
245
+ *
246
+ * TODO: Explain the differences to `fragmentNode`.
247
+ *
248
+ * @default null
249
+ */
70
250
  outputNode: Node | null;
251
+ /**
252
+ * MRT configuration is done on renderer or pass level. This node allows to
253
+ * overwrite what values are written into MRT targets on material level. This
254
+ * can be useful for implementing selective FX features that should only affect
255
+ * specific objects.
256
+ *
257
+ * @default null
258
+ */
71
259
  mrtNode: MRTNode | null;
72
-
260
+ /**
261
+ * This node property can be used if you need complete freedom in implementing
262
+ * the fragment shader. Assigning a node will replace the built-in material
263
+ * logic used in the fragment stage.
264
+ *
265
+ * @default null
266
+ */
73
267
  fragmentNode: Node | null;
74
- vertexNode: Node | null;
75
-
76
268
  /**
77
- * @deprecated ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'
269
+ * This node property can be used if you need complete freedom in implementing
270
+ * the vertex shader. Assigning a node will replace the built-in material logic
271
+ * used in the vertex stage.
272
+ *
273
+ * @default null
78
274
  */
79
- get shadowPositionNode(): Node | null;
80
- set shadowPositionNode(value: Node | null);
275
+ vertexNode: Node | null;
276
+ }
81
277
 
82
- constructor();
278
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
279
+ export interface NodeMaterialParameters
280
+ extends Partial<MapColorPropertiesToColorRepresentations<NodeMaterialNodeProperties>>, MaterialParameters
281
+ {}
83
282
 
283
+ /**
284
+ * Base class for all node materials.
285
+ */
286
+ declare class NodeMaterial extends Material {
287
+ static get type(): string;
288
+ /**
289
+ * This flag can be used for type testing.
290
+ *
291
+ * @default true
292
+ */
293
+ readonly isNodeMaterial: boolean;
294
+ /**
295
+ * Builds this material with the given node builder.
296
+ *
297
+ * @param {NodeBuilder} builder - The current node builder.
298
+ */
84
299
  build(builder: NodeBuilder): void;
300
+ /**
301
+ * Setups a node material observer with the given builder.
302
+ *
303
+ * @param {NodeBuilder} builder - The current node builder.
304
+ * @return {NodeMaterialObserver} The node material observer.
305
+ */
306
+ setupObserver(builder: NodeBuilder): NodeMaterialObserver;
307
+ /**
308
+ * Setups the vertex and fragment stage of this node material.
309
+ *
310
+ * @param {NodeBuilder} builder - The current node builder.
311
+ */
85
312
  setup(builder: NodeBuilder): void;
86
- setupClipping(builder: NodeBuilder): ClippingNode | null;
313
+ /**
314
+ * Setups the clipping node.
315
+ *
316
+ * @param {NodeBuilder} builder - The current node builder.
317
+ * @return {ClippingNode} The clipping node.
318
+ */
319
+ setupClipping(builder: NodeBuilder): ClippingNode;
320
+ /**
321
+ * Setups the hardware clipping if available on the current device.
322
+ *
323
+ * @param {NodeBuilder} builder - The current node builder.
324
+ */
87
325
  setupHardwareClipping(builder: NodeBuilder): void;
326
+ /**
327
+ * Setups the depth of this material.
328
+ *
329
+ * @param {NodeBuilder} builder - The current node builder.
330
+ */
88
331
  setupDepth(builder: NodeBuilder): void;
89
- setupPositionView(): Node;
332
+ /**
333
+ * Setups the position node in view space. This method exists
334
+ * so derived node materials can modify the implementation e.g. sprite materials.
335
+ *
336
+ * @param {NodeBuilder} builder - The current node builder.
337
+ * @return {Node<vec3>} The position in view space.
338
+ */
339
+ setupPositionView(builder: NodeBuilder): Node;
340
+ /**
341
+ * Setups the position in clip space.
342
+ *
343
+ * @param {NodeBuilder} builder - The current node builder.
344
+ * @return {Node<vec4>} The position in view space.
345
+ */
90
346
  setupModelViewProjection(): Node;
347
+ /**
348
+ * Setups the logic for the vertex stage.
349
+ *
350
+ * @param {NodeBuilder} builder - The current node builder.
351
+ * @return {Node<vec4>} The position in clip space.
352
+ */
91
353
  setupVertex(builder: NodeBuilder): Node;
354
+ /**
355
+ * Setups the computation of the position in local space.
356
+ *
357
+ * @param {NodeBuilder} builder - The current node builder.
358
+ * @return {Node<vec3>} The position in local space.
359
+ */
92
360
  setupPosition(builder: NodeBuilder): Node;
361
+ /**
362
+ * Setups the computation of the material's diffuse color.
363
+ *
364
+ * @param {NodeBuilder} builder - The current node builder.
365
+ * @param {BufferGeometry} geometry - The geometry.
366
+ */
93
367
  setupDiffuseColor(builder: NodeBuilder): void;
368
+ /**
369
+ * Abstract interface method that can be implemented by derived materials
370
+ * to setup material-specific node variables.
371
+ *
372
+ * @abstract
373
+ * @param {NodeBuilder} builder - The current node builder.
374
+ */
94
375
  setupVariants(builder: NodeBuilder): void;
95
- setupNormal(builder: NodeBuilder): ShaderNodeObject<Node>;
376
+ /**
377
+ * Setups the outgoing light node variable
378
+ *
379
+ * @return {Node<vec3>} The outgoing light node.
380
+ */
381
+ setupOutgoingLight(): Node;
382
+ /**
383
+ * Setups the normal node from the material.
384
+ *
385
+ * @return {Node<vec3>} The normal node.
386
+ */
387
+ setupNormal(): ShaderNodeObject<Node>;
388
+ /**
389
+ * Setups the environment node from the material.
390
+ *
391
+ * @param {NodeBuilder} builder - The current node builder.
392
+ * @return {Node<vec4>} The environment node.
393
+ */
96
394
  setupEnvironment(builder: NodeBuilder): Node | null;
97
- setupLightMap(builder: NodeBuilder): Node | null;
395
+ /**
396
+ * Setups the light map node from the material.
397
+ *
398
+ * @param {NodeBuilder} builder - The current node builder.
399
+ * @return {Node<vec3>} The light map node.
400
+ */
401
+ setupLightMap(builder: NodeBuilder): Node;
402
+ /**
403
+ * Setups the lights node based on the scene, environment and material.
404
+ *
405
+ * @param {NodeBuilder} builder - The current node builder.
406
+ * @return {LightsNode} The lights node.
407
+ */
98
408
  setupLights(builder: NodeBuilder): LightsNode;
99
- setupOutgoingLight(): Node;
100
- setupLightingModel(builder: NodeBuilder): LightingModel;
409
+ /**
410
+ * This method should be implemented by most derived materials
411
+ * since it defines the material's lighting model.
412
+ *
413
+ * @abstract
414
+ * @param {NodeBuilder} builder - The current node builder.
415
+ * @return {LightingModel} The lighting model.
416
+ */
417
+ setupLightingModel(): LightingModel;
418
+ /**
419
+ * Setups the outgoing light node.
420
+ *
421
+ * @param {NodeBuilder} builder - The current node builder.
422
+ * @return {Node<vec3>} The outgoing light node.
423
+ */
101
424
  setupLighting(builder: NodeBuilder): Node;
425
+ /**
426
+ * Setup the fog.
427
+ *
428
+ * @param {NodeBuilder} builder - The current node builder.
429
+ * @param {Node<vec4>} outputNode - The existing output node.
430
+ * @return {Node<vec4>} The output node.
431
+ */
102
432
  setupFog(builder: NodeBuilder, outputNode: Node): Node;
433
+ /**
434
+ * Setups premultiplied alpha.
435
+ *
436
+ * @param {NodeBuilder} builder - The current node builder.
437
+ * @param {Node<vec4>} outputNode - The existing output node.
438
+ * @return {Node<vec4>} The output node.
439
+ */
440
+ setupPremultipliedAlpha(builder: NodeBuilder, outputNode: Node): Node;
441
+ /**
442
+ * Setups the output node.
443
+ *
444
+ * @param {NodeBuilder} builder - The current node builder.
445
+ * @param {Node<vec4>} outputNode - The existing output node.
446
+ * @return {Node<vec4>} The output node.
447
+ */
103
448
  setupOutput(builder: NodeBuilder, outputNode: Node): Node;
104
-
449
+ /**
450
+ * Most classic material types have a node pendant e.g. for `MeshBasicMaterial`
451
+ * there is `MeshBasicNodeMaterial`. This utility method is intended for
452
+ * defining all material properties of the classic type in the node type.
453
+ *
454
+ * @param {Material} material - The material to copy properties with their values to this node material.
455
+ */
105
456
  setDefaultValues(material: Material): void;
457
+ /**
458
+ * Copies the properties of the given node material to this instance.
459
+ *
460
+ * @param {NodeMaterial} source - The material to copy.
461
+ * @return {NodeMaterial} A reference to this node material.
462
+ */
463
+ copy(source: NodeMaterial): this;
106
464
  }
107
465
 
466
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
467
+ interface NodeMaterial extends NodeMaterialNodeProperties {}
468
+
108
469
  export default NodeMaterial;
@@ -1,17 +1,18 @@
1
1
  export { default as Line2NodeMaterial, Line2NodeMaterialParameters } from "./Line2NodeMaterial.js";
2
2
  export { default as LineBasicNodeMaterial, LineBasicNodeMaterialParameters } from "./LineBasicNodeMaterial.js";
3
3
  export { default as LineDashedNodeMaterial, LineDashedNodeMaterialParameters } from "./LineDashedNodeMaterial.js";
4
+ export { default as NodeMaterialObserver } from "./manager/NodeMaterialObserver.js";
4
5
  export { default as MeshBasicNodeMaterial, MeshBasicNodeMaterialParameters } from "./MeshBasicNodeMaterial.js";
5
6
  export { default as MeshLambertNodeMaterial, MeshLambertNodeMaterialParameters } from "./MeshLambertNodeMaterial.js";
6
7
  export { default as MeshMatcapNodeMaterial, MeshMatcapNodeMaterialParameters } from "./MeshMatcapNodeMaterial.js";
7
8
  export { default as MeshNormalNodeMaterial, MeshNormalNodeMaterialParameters } from "./MeshNormalNodeMaterial.js";
8
9
  export { default as MeshPhongNodeMaterial, MeshPhongNodeMaterialParameters } from "./MeshPhongNodeMaterial.js";
9
10
  export { default as MeshPhysicalNodeMaterial, MeshPhysicalNodeMaterialParameters } from "./MeshPhysicalNodeMaterial.js";
10
- export { default as MeshSSSNodeMaterial } from "./MeshSSSNodeMaterial.js";
11
+ export { default as MeshSSSNodeMaterial, MeshSSSNodeMaterialParameters } from "./MeshSSSNodeMaterial.js";
11
12
  export { default as MeshStandardNodeMaterial, MeshStandardNodeMaterialParameters } from "./MeshStandardNodeMaterial.js";
12
13
  export { default as MeshToonNodeMaterial, MeshToonNodeMaterialParameters } from "./MeshToonNodeMaterial.js";
13
14
  export { default as NodeMaterial, NodeMaterialParameters } from "./NodeMaterial.js";
14
15
  export { default as PointsNodeMaterial, PointsNodeMaterialParameters } from "./PointsNodeMaterial.js";
15
16
  export { default as ShadowNodeMaterial, ShadowNodeMaterialParameters } from "./ShadowNodeMaterial.js";
16
17
  export { default as SpriteNodeMaterial, SpriteNodeMaterialParameters } from "./SpriteNodeMaterial.js";
17
- export { default as VolumeNodeMaterial } from "./VolumeNodeMaterial.js";
18
+ export { default as VolumeNodeMaterial, VolumeNodeMaterialParameters } from "./VolumeNodeMaterial.js";
@@ -1,14 +1,38 @@
1
1
  import Node from "../../nodes/core/Node.js";
2
- import SpriteNodeMaterial, { SpriteNodeMaterialParameters } from "./SpriteNodeMaterial.js";
2
+ import { MapColorPropertiesToColorRepresentations } from "../Material.js";
3
+ import { PointsMaterialParameters, PointsMaterialProperties } from "../PointsMaterial.js";
4
+ import SpriteNodeMaterial, { SpriteNodeMaterialNodeProperties } from "./SpriteNodeMaterial.js";
3
5
 
4
- export interface PointsNodeMaterialParameters extends SpriteNodeMaterialParameters {
5
- sizeNode?: Node | null | undefined;
6
+ export interface PointsNodeMaterialNodeProperties extends SpriteNodeMaterialNodeProperties {
7
+ /**
8
+ * This node property provides an additional way to set the point size.
9
+ *
10
+ * @default null
11
+ */
12
+ sizeNode: Node;
6
13
  }
7
14
 
8
- export default class PointsNodeMaterial extends SpriteNodeMaterial {
9
- sizeNode: Node | null;
10
-
11
- readonly isPointsNodeMaterial: true;
15
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
16
+ export interface PointsNodeMaterialParameters
17
+ extends
18
+ Partial<MapColorPropertiesToColorRepresentations<PointsNodeMaterialNodeProperties>>,
19
+ PointsMaterialParameters
20
+ {}
12
21
 
22
+ /**
23
+ * Node material version of {@link PointsMaterial}.
24
+ */
25
+ declare class PointsNodeMaterial extends SpriteNodeMaterial {
13
26
  constructor(parameters?: PointsNodeMaterialParameters);
27
+ /**
28
+ * This flag can be used for type testing.
29
+ *
30
+ * @default true
31
+ */
32
+ readonly isPointsNodeMaterial: boolean;
14
33
  }
34
+
35
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
36
+ interface PointsNodeMaterial extends PointsNodeMaterialNodeProperties, PointsMaterialProperties {}
37
+
38
+ export default PointsNodeMaterial;
@@ -1,17 +1,44 @@
1
- import { Color } from "../../math/Color.js";
2
- import { ShadowMaterialParameters } from "../ShadowMaterial.js";
3
- import NodeMaterial, { NodeMaterialParameters } from "./NodeMaterial.js";
1
+ import ShadowMaskModel from "../../nodes/functions/ShadowMaskModel.js";
2
+ import { MapColorPropertiesToColorRepresentations } from "../Material.js";
3
+ import { ShadowMaterialParameters, ShadowMaterialProperties } from "../ShadowMaterial.js";
4
+ import NodeMaterial, { NodeMaterialNodeProperties } from "./NodeMaterial.js";
4
5
 
5
- export interface ShadowNodeMaterialParameters extends NodeMaterialParameters, ShadowMaterialParameters {
6
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
7
+ export interface ShadowNodeMaterialNodeProperties extends NodeMaterialNodeProperties {
6
8
  }
7
9
 
8
- export default class ShadowNodeMaterial extends NodeMaterial {
9
- readonly isShadowNodeMaterial: true;
10
-
11
- // Properties from ShadowMaterial
12
- readonly isShadowMaterial: true;
13
- color: Color;
14
- fog: boolean;
10
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
11
+ export interface ShadowNodeMaterialParameters
12
+ extends
13
+ Partial<MapColorPropertiesToColorRepresentations<ShadowNodeMaterialNodeProperties>>,
14
+ ShadowMaterialParameters
15
+ {}
15
16
 
17
+ /**
18
+ * Node material version of {@link ShadowMaterial}.
19
+ */
20
+ declare class ShadowNodeMaterial extends NodeMaterial {
21
+ /**
22
+ * Constructs a new shadow node material.
23
+ *
24
+ * @param {Object} [parameters] - The configuration parameter.
25
+ */
16
26
  constructor(parameters?: ShadowNodeMaterialParameters);
27
+ /**
28
+ * This flag can be used for type testing.
29
+ *
30
+ * @default true
31
+ */
32
+ readonly isShadowNodeMaterial: boolean;
33
+ /**
34
+ * Setups the lighting model.
35
+ *
36
+ * @return {ShadowMaskModel} The lighting model.
37
+ */
38
+ setupLightingModel(): ShadowMaskModel;
17
39
  }
40
+
41
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
42
+ interface ShadowNodeMaterial extends ShadowNodeMaterialNodeProperties, ShadowMaterialProperties {}
43
+
44
+ export default ShadowNodeMaterial;