@types/three 0.177.0 → 0.178.1

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 +171 -111
  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
@@ -7,7 +7,6 @@ import {
7
7
  Combine,
8
8
  DepthModes,
9
9
  NormalMapTypes,
10
- PixelFormat,
11
10
  Side,
12
11
  StencilFunc,
13
12
  StencilOp,
@@ -16,62 +15,351 @@ import { BufferGeometry } from "../core/BufferGeometry.js";
16
15
  import { EventDispatcher } from "../core/EventDispatcher.js";
17
16
  import { JSONMeta, Object3D } from "../core/Object3D.js";
18
17
  import { Color, ColorRepresentation } from "../math/Color.js";
18
+ import { EulerTuple } from "../math/Euler.js";
19
19
  import { Plane } from "../math/Plane.js";
20
+ import { Vector2Tuple } from "../math/Vector2.js";
20
21
  import { Group } from "../objects/Group.js";
21
22
  import { WebGLProgramParametersWithUniforms } from "../renderers/webgl/WebGLPrograms.js";
22
23
  import { WebGLRenderer } from "../renderers/WebGLRenderer.js";
23
24
  import { Scene } from "../scenes/Scene.js";
24
- import { EulerTuple, SourceJSON, TextureJSON, Vector2Tuple } from "../Three.js";
25
-
26
- export interface MaterialParameters {
27
- alphaHash?: boolean | undefined;
28
- alphaTest?: number | undefined;
29
- alphaToCoverage?: boolean | undefined;
30
- blendAlpha?: number | undefined;
31
- blendColor?: ColorRepresentation | undefined;
32
- blendDst?: BlendingDstFactor | undefined;
33
- blendDstAlpha?: number | undefined;
34
- blendEquation?: BlendingEquation | undefined;
35
- blendEquationAlpha?: number | undefined;
36
- blending?: Blending | undefined;
37
- blendSrc?: BlendingSrcFactor | BlendingDstFactor | undefined;
38
- blendSrcAlpha?: number | undefined;
39
- clipIntersection?: boolean | undefined;
40
- clippingPlanes?: Plane[] | undefined;
41
- clipShadows?: boolean | undefined;
42
- colorWrite?: boolean | undefined;
43
- defines?: any;
44
- depthFunc?: DepthModes | undefined;
45
- depthTest?: boolean | undefined;
46
- depthWrite?: boolean | undefined;
47
- name?: string | undefined;
48
- opacity?: number | undefined;
49
- polygonOffset?: boolean | undefined;
50
- polygonOffsetFactor?: number | undefined;
51
- polygonOffsetUnits?: number | undefined;
52
- precision?: "highp" | "mediump" | "lowp" | null | undefined;
53
- premultipliedAlpha?: boolean | undefined;
54
- forceSinglePass?: boolean | undefined;
55
- allowOverride?: boolean | undefined;
56
- dithering?: boolean | undefined;
57
- side?: Side | undefined;
58
- shadowSide?: Side | undefined;
59
- toneMapped?: boolean | undefined;
60
- transparent?: boolean | undefined;
61
- vertexColors?: boolean | undefined;
62
- visible?: boolean | undefined;
63
- format?: PixelFormat | undefined;
64
- stencilWrite?: boolean | undefined;
65
- stencilFunc?: StencilFunc | undefined;
66
- stencilRef?: number | undefined;
67
- stencilWriteMask?: number | undefined;
68
- stencilFuncMask?: number | undefined;
69
- stencilFail?: StencilOp | undefined;
70
- stencilZFail?: StencilOp | undefined;
71
- stencilZPass?: StencilOp | undefined;
72
- userData?: Record<string, any> | undefined;
25
+ import { SourceJSON } from "../textures/Source.js";
26
+ import { TextureJSON } from "../textures/Texture.js";
27
+
28
+ export interface MaterialProperties {
29
+ /**
30
+ * The name of the material.
31
+ */
32
+ name: string;
33
+ /**
34
+ * Defines the blending type of the material.
35
+ *
36
+ * It must be set to `CustomBlending` if custom blending properties like
37
+ * {@link Material#blendSrc}, {@link Material#blendDst} or {@link Material#blendEquation}
38
+ * should have any effect.
39
+ *
40
+ * @default NormalBlending
41
+ */
42
+ blending: Blending;
43
+ /**
44
+ * Defines which side of faces will be rendered - front, back or both.
45
+ *
46
+ * @default FrontSide
47
+ */
48
+ side: Side;
49
+ /**
50
+ * If set to `true`, vertex colors should be used.
51
+ *
52
+ * The engine supports RGB and RGBA vertex colors depending on whether a three (RGB) or
53
+ * four (RGBA) component color buffer attribute is used.
54
+ *
55
+ * @default false
56
+ */
57
+ vertexColors: boolean;
58
+ /**
59
+ * Defines how transparent the material is.
60
+ * A value of `0.0` indicates fully transparent, `1.0` is fully opaque.
61
+ *
62
+ * If the {@link Material#transparent} is not set to `true`,
63
+ * the material will remain fully opaque and this value will only affect its color.
64
+ *
65
+ * @default 1
66
+ */
67
+ opacity: number;
68
+ /**
69
+ * Defines whether this material is transparent. This has an effect on
70
+ * rendering as transparent objects need special treatment and are rendered
71
+ * after non-transparent objects.
72
+ *
73
+ * When set to true, the extent to which the material is transparent is
74
+ * controlled by {@link Material#opacity}.
75
+ *
76
+ * @default false
77
+ */
78
+ transparent: boolean;
79
+ /**
80
+ * Enables alpha hashed transparency, an alternative to {@link Material#transparent} or
81
+ * {@link Material#alphaTest}. The material will not be rendered if opacity is lower than
82
+ * a random threshold. Randomization introduces some grain or noise, but approximates alpha
83
+ * blending without the associated problems of sorting. Using TAA can reduce the resulting noise.
84
+ *
85
+ * @default false
86
+ */
87
+ alphaHash: boolean;
88
+ /**
89
+ * Defines the blending source factor.
90
+ *
91
+ * @default SrcAlphaFactor
92
+ */
93
+ blendSrc: BlendingSrcFactor;
94
+ /**
95
+ * Defines the blending destination factor.
96
+ *
97
+ * @default OneMinusSrcAlphaFactor
98
+ */
99
+ blendDst: BlendingDstFactor;
100
+ /**
101
+ * Defines the blending equation.
102
+ *
103
+ * @default AddEquation
104
+ */
105
+ blendEquation: BlendingEquation;
106
+ /**
107
+ * Defines the blending source alpha factor.
108
+ *
109
+ * @default null
110
+ */
111
+ blendSrcAlpha: BlendingSrcFactor | null;
112
+ /**
113
+ * Defines the blending destination alpha factor.
114
+ *
115
+ * @default null
116
+ */
117
+ blendDstAlpha: BlendingDstFactor | null;
118
+ /**
119
+ * Defines the blending equation of the alpha channel.
120
+ *
121
+ * @default null
122
+ */
123
+ blendEquationAlpha: BlendingEquation | null;
124
+ /**
125
+ * Represents the RGB values of the constant blend color.
126
+ *
127
+ * This property has only an effect when using custom blending with `ConstantColor` or `OneMinusConstantColor`.
128
+ *
129
+ * @default (0,0,0)
130
+ */
131
+ blendColor: Color;
132
+ /**
133
+ * Represents the alpha value of the constant blend color.
134
+ *
135
+ * This property has only an effect when using custom blending with `ConstantAlpha` or `OneMinusConstantAlpha`.
136
+ *
137
+ * @default 0
138
+ */
139
+ blendAlpha: number;
140
+ /**
141
+ * Defines the depth function.
142
+ *
143
+ * @default LessEqualDepth
144
+ */
145
+ depthFunc: DepthModes;
146
+ /**
147
+ * Whether to have depth test enabled when rendering this material.
148
+ * When the depth test is disabled, the depth write will also be implicitly disabled.
149
+ *
150
+ * @default true
151
+ */
152
+ depthTest: boolean;
153
+ /**
154
+ * Whether rendering this material has any effect on the depth buffer.
155
+ *
156
+ * When drawing 2D overlays it can be useful to disable the depth writing in
157
+ * order to layer several things together without creating z-index artifacts.
158
+ *
159
+ * @default true
160
+ */
161
+ depthWrite: boolean;
162
+ /**
163
+ * The bit mask to use when writing to the stencil buffer.
164
+ *
165
+ * @default 0xff
166
+ */
167
+ stencilWriteMask: number;
168
+ /**
169
+ * The stencil comparison function to use.
170
+ *
171
+ * @default AlwaysStencilFunc
172
+ */
173
+ stencilFunc: StencilFunc;
174
+ /**
175
+ * The value to use when performing stencil comparisons or stencil operations.
176
+ *
177
+ * @default 0
178
+ */
179
+ stencilRef: number;
180
+ /**
181
+ * The bit mask to use when comparing against the stencil buffer.
182
+ *
183
+ * @default 0xff
184
+ */
185
+ stencilFuncMask: number;
186
+ /**
187
+ * Which stencil operation to perform when the comparison function returns `false`.
188
+ *
189
+ * @default KeepStencilOp
190
+ */
191
+ stencilFail: StencilOp;
192
+ /**
193
+ * Which stencil operation to perform when the comparison function returns
194
+ * `true` but the depth test fails.
195
+ *
196
+ * @default KeepStencilOp
197
+ */
198
+ stencilZFail: StencilOp;
199
+ /**
200
+ * Which stencil operation to perform when the comparison function returns
201
+ * `true` and the depth test passes.
202
+ *
203
+ * @default KeepStencilOp
204
+ */
205
+ stencilZPass: StencilOp;
206
+ /**
207
+ * Whether stencil operations are performed against the stencil buffer. In
208
+ * order to perform writes or comparisons against the stencil buffer this
209
+ * value must be `true`.
210
+ *
211
+ * @default false
212
+ */
213
+ stencilWrite: boolean;
214
+ /**
215
+ * User-defined clipping planes specified as THREE.Plane objects in world
216
+ * space. These planes apply to the objects this material is attached to.
217
+ * Points in space whose signed distance to the plane is negative are clipped
218
+ * (not rendered). This requires {@link WebGLRenderer#localClippingEnabled} to
219
+ * be `true`.
220
+ *
221
+ * @default null
222
+ */
223
+ clippingPlanes: Array<Plane> | null;
224
+ /**
225
+ * Changes the behavior of clipping planes so that only their intersection is
226
+ * clipped, rather than their union.
227
+ *
228
+ * @default false
229
+ */
230
+ clipIntersection: boolean;
231
+ /**
232
+ * Defines whether to clip shadows according to the clipping planes specified
233
+ * on this material.
234
+ *
235
+ * @default false
236
+ */
237
+ clipShadows: boolean;
238
+ /**
239
+ * Defines which side of faces cast shadows. If `null`, the side casting shadows
240
+ * is determined as follows:
241
+ *
242
+ * - When {@link Material#side} is set to `FrontSide`, the back side cast shadows.
243
+ * - When {@link Material#side} is set to `BackSide`, the front side cast shadows.
244
+ * - When {@link Material#side} is set to `DoubleSide`, both sides cast shadows.
245
+ *
246
+ * @default null
247
+ */
248
+ shadowSide: Side | null;
249
+ /**
250
+ * Whether to render the material's color.
251
+ *
252
+ * This can be used in conjunction with {@link Object3D#renderOder} to create invisible
253
+ * objects that occlude other objects.
254
+ *
255
+ * @default true
256
+ */
257
+ colorWrite: boolean;
258
+ /**
259
+ * Override the renderer's default precision for this material.
260
+ *
261
+ * @default null
262
+ */
263
+ precision: ("highp" | "mediump" | "lowp") | null;
264
+ /**
265
+ * Whether to use polygon offset or not. When enabled, each fragment's depth value will
266
+ * be offset after it is interpolated from the depth values of the appropriate vertices.
267
+ * The offset is added before the depth test is performed and before the value is written
268
+ * into the depth buffer.
269
+ *
270
+ * Can be useful for rendering hidden-line images, for applying decals to surfaces, and for
271
+ * rendering solids with highlighted edges.
272
+ *
273
+ * @default false
274
+ */
275
+ polygonOffset: boolean;
276
+ /**
277
+ * Specifies a scale factor that is used to create a variable depth offset for each polygon.
278
+ *
279
+ * @default 0
280
+ */
281
+ polygonOffsetFactor: number;
282
+ /**
283
+ * Is multiplied by an implementation-specific value to create a constant depth offset.
284
+ *
285
+ * @default 0
286
+ */
287
+ polygonOffsetUnits: number;
288
+ /**
289
+ * Whether to apply dithering to the color to remove the appearance of banding.
290
+ *
291
+ * @default false
292
+ */
293
+ dithering: boolean;
294
+ /**
295
+ * Whether alpha to coverage should be enabled or not. Can only be used with MSAA-enabled contexts
296
+ * (meaning when the renderer was created with *antialias* parameter set to `true`). Enabling this
297
+ * will smooth aliasing on clip plane edges and alphaTest-clipped edges.
298
+ *
299
+ * @default false
300
+ */
301
+ alphaToCoverage: boolean;
302
+ /**
303
+ * Whether to premultiply the alpha (transparency) value.
304
+ *
305
+ * @default false
306
+ */
307
+ premultipliedAlpha: boolean;
308
+ /**
309
+ * Whether double-sided, transparent objects should be rendered with a single pass or not.
310
+ *
311
+ * The engine renders double-sided, transparent objects with two draw calls (back faces first,
312
+ * then front faces) to mitigate transparency artifacts. There are scenarios however where this
313
+ * approach produces no quality gains but still doubles draw calls e.g. when rendering flat
314
+ * vegetation like grass sprites. In these cases, set the `forceSinglePass` flag to `true` to
315
+ * disable the two pass rendering to avoid performance issues.
316
+ *
317
+ * @default false
318
+ */
319
+ forceSinglePass: boolean;
320
+ /**
321
+ * Whether it's possible to override the material with {@link Scene#overrideMaterial} or not.
322
+ *
323
+ * @default true
324
+ */
325
+ allowOverride: boolean;
326
+ /**
327
+ * Defines whether 3D objects using this material are visible.
328
+ *
329
+ * @default true
330
+ */
331
+ visible: boolean;
332
+ /**
333
+ * Defines whether this material is tone mapped according to the renderer's tone mapping setting.
334
+ *
335
+ * It is ignored when rendering to a render target or using post processing or when using
336
+ * `WebGPURenderer`. In all these cases, all materials are honored by tone mapping.
337
+ *
338
+ * @default true
339
+ */
340
+ toneMapped: boolean;
341
+ /**
342
+ * An object that can be used to store custom data about the Material. It
343
+ * should not hold references to functions as these will not be cloned.
344
+ */
345
+ userData: Record<string, any>;
346
+ set alphaTest(value: number);
347
+ /**
348
+ * Sets the alpha value to be used when running an alpha test. The material
349
+ * will not be rendered if the opacity is lower than this value.
350
+ *
351
+ * @default 0
352
+ */
353
+ get alphaTest(): number;
73
354
  }
74
355
 
356
+ export type MapColorPropertiesToColorRepresentations<T> = {
357
+ [P in keyof T]: T[P] extends Color ? ColorRepresentation : T[P];
358
+ };
359
+
360
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
361
+ export interface MaterialParameters extends Partial<MapColorPropertiesToColorRepresentations<MaterialProperties>> {}
362
+
75
363
  export interface MaterialJSON {
76
364
  metadata: { version: number; type: string; generator: string };
77
365
 
@@ -232,337 +520,45 @@ export interface MaterialJSON {
232
520
  }
233
521
 
234
522
  /**
235
- * Materials describe the appearance of objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer.
523
+ * Abstract base class for materials.
524
+ *
525
+ * Materials define the appearance of renderable 3D objects.
526
+ *
527
+ * @abstract
236
528
  */
237
529
  export class Material extends EventDispatcher<{ dispose: {} }> {
238
- constructor();
239
-
240
- /**
241
- * Read-only flag to check if a given object is of type {@link Material}.
242
- * @remarks This is a _constant_ value
243
- * @defaultValue `true`
244
- */
245
- readonly isMaterial: true;
246
-
247
- /**
248
- * Value is the string 'Material'. This shouldn't be changed, and can be used to find all objects of this type in a
249
- * scene.
250
- */
251
- type: string;
252
-
253
- /**
254
- * Enables alpha hashed transparency, an alternative to {@link .transparent} or {@link .alphaTest}. The material
255
- * will not be rendered if opacity is lower than a random threshold. Randomization introduces some grain or noise,
256
- * but approximates alpha blending without the associated problems of sorting. Using TAARenderPass can reduce the
257
- * resulting noise.
258
- */
259
- alphaHash: boolean;
260
-
261
- /**
262
- * Enables alpha to coverage. Can only be used with MSAA-enabled rendering contexts (meaning when the renderer was
263
- * created with *antialias* parameter set to `true`). Enabling this will smooth aliasing on clip plane edges and
264
- * alphaTest-clipped edges.
265
- * @default false
266
- */
267
- alphaToCoverage: boolean;
268
-
269
- /**
270
- * Represents the alpha value of the constant blend color. This property has only an effect when using custom
271
- * blending with {@link ConstantAlphaFactor} or {@link OneMinusConstantAlphaFactor}.
272
- * @default 0
273
- */
274
- blendAlpha: number;
275
-
276
- /**
277
- * Represent the RGB values of the constant blend color. This property has only an effect when using custom
278
- * blending with {@link ConstantColorFactor} or {@link OneMinusConstantColorFactor}.
279
- * @default 0x000000
280
- */
281
- blendColor: Color;
282
-
283
- /**
284
- * Blending destination. It's one of the blending mode constants defined in Three.js. Default is {@link OneMinusSrcAlphaFactor}.
285
- * @default THREE.OneMinusSrcAlphaFactor
286
- */
287
- blendDst: BlendingDstFactor;
288
-
289
- /**
290
- * The transparency of the .blendDst. Default is null.
291
- * @default null
292
- */
293
- blendDstAlpha: number | null;
294
-
295
- /**
296
- * Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is {@link AddEquation}.
297
- * @default THREE.AddEquation
298
- */
299
- blendEquation: BlendingEquation;
300
-
301
- /**
302
- * The transparency of the .blendEquation. Default is null.
303
- * @default null
304
- */
305
- blendEquationAlpha: number | null;
306
-
307
- /**
308
- * Which blending to use when displaying objects with this material. Default is {@link NormalBlending}.
309
- * @default THREE.NormalBlending
310
- */
311
- blending: Blending;
312
-
313
- /**
314
- * Blending source. It's one of the blending mode constants defined in Three.js. Default is {@link SrcAlphaFactor}.
315
- * @default THREE.SrcAlphaFactor
316
- */
317
- blendSrc: BlendingSrcFactor | BlendingDstFactor;
318
-
319
- /**
320
- * The transparency of the .blendSrc. Default is null.
321
- * @default null
322
- */
323
- blendSrcAlpha: number | null;
324
-
325
- /**
326
- * Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union. Default is false.
327
- * @default false
328
- */
329
- clipIntersection: boolean;
330
-
331
- /**
332
- * User-defined clipping planes specified as THREE.Plane objects in world space.
333
- * These planes apply to the objects this material is attached to.
334
- * Points in space whose signed distance to the plane is negative are clipped (not rendered).
335
- * See the WebGL / clipping /intersection example. Default is null.
336
- * @default null
337
- */
338
- clippingPlanes: Plane[] | null;
339
-
340
- /**
341
- * Defines whether to clip shadows according to the clipping planes specified on this material. Default is false.
342
- * @default false
343
- */
344
- clipShadows: boolean;
345
-
346
530
  /**
347
- * Whether to render the material's color. This can be used in conjunction with a mesh's .renderOrder property to create invisible objects that occlude other objects. Default is true.
348
- * @default true
349
- */
350
- colorWrite: boolean;
351
-
352
- /**
353
- * Custom defines to be injected into the shader. These are passed in form of an object literal, with key/value pairs. { MY_CUSTOM_DEFINE: '' , PI2: Math.PI * 2 }.
354
- * The pairs are defined in both vertex and fragment shaders. Default is undefined.
355
- * @default undefined
356
- */
357
- defines: undefined | { [key: string]: any };
358
-
359
- /**
360
- * Which depth function to use. Default is {@link LessEqualDepth}. See the depth mode constants for all possible values.
361
- * @default THREE.LessEqualDepth
362
- */
363
- depthFunc: DepthModes;
364
-
365
- /**
366
- * Whether to have depth test enabled when rendering this material. When the depth test is disabled, the depth write
367
- * will also be implicitly disabled.
368
- * @default true
369
- */
370
- depthTest: boolean;
371
-
372
- /**
373
- * Whether rendering this material has any effect on the depth buffer. Default is true.
374
- * When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts.
375
- * @default true
376
- */
377
- depthWrite: boolean;
378
-
379
- /**
380
- * Unique number of this material instance.
381
- */
382
- id: number;
383
-
384
- /**
385
- * Whether rendering this material has any effect on the stencil buffer. Default is *false*.
386
- * @default false
387
- */
388
- stencilWrite: boolean;
389
-
390
- /**
391
- * The stencil comparison function to use. Default is {@link AlwaysStencilFunc}. See stencil operation constants for all possible values.
392
- * @default THREE.AlwaysStencilFunc
393
- */
394
- stencilFunc: StencilFunc;
395
-
396
- /**
397
- * The value to use when performing stencil comparisons or stencil operations. Default is *0*.
398
- * @default 0
399
- */
400
- stencilRef: number;
401
-
402
- /**
403
- * The bit mask to use when writing to the stencil buffer. Default is *0xFF*.
404
- * @default 0xff
405
- */
406
- stencilWriteMask: number;
407
-
408
- /**
409
- * The bit mask to use when comparing against the stencil buffer. Default is *0xFF*.
410
- * @default 0xff
411
- */
412
- stencilFuncMask: number;
413
-
414
- /**
415
- * Which stencil operation to perform when the comparison function returns false. Default is {@link KeepStencilOp}. See the stencil operation constants for all possible values.
416
- * @default THREE.KeepStencilOp
417
- */
418
- stencilFail: StencilOp;
419
-
420
- /**
421
- * Which stencil operation to perform when the comparison function returns true but the depth test fails.
422
- * Default is {@link KeepStencilOp}.
423
- * See the stencil operation constants for all possible values.
424
- * @default THREE.KeepStencilOp
425
- */
426
- stencilZFail: StencilOp;
427
-
428
- /**
429
- * Which stencil operation to perform when the comparison function returns true and the depth test passes.
430
- * Default is {@link KeepStencilOp}.
431
- * See the stencil operation constants for all possible values.
432
- * @default THREE.KeepStencilOp
433
- */
434
- stencilZPass: StencilOp;
435
-
436
- /**
437
- * Material name. Default is an empty string.
438
- * @default ''
439
- */
440
- name: string;
441
-
442
- /**
443
- * Opacity. Default is 1.
444
- * @default 1
445
- */
446
- opacity: number;
447
-
448
- /**
449
- * Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature.
450
- * @default false
451
- */
452
- polygonOffset: boolean;
453
-
454
- /**
455
- * Sets the polygon offset factor. Default is 0.
456
- * @default 0
457
- */
458
- polygonOffsetFactor: number;
459
-
460
- /**
461
- * Sets the polygon offset units. Default is 0.
462
- * @default 0
463
- */
464
- polygonOffsetUnits: number;
465
-
466
- /**
467
- * Override the renderer's default precision for this material. Can be "highp", "mediump" or "lowp". Defaults is null.
468
- * @default null
469
- */
470
- precision: "highp" | "mediump" | "lowp" | null;
471
-
472
- /**
473
- * Whether to premultiply the alpha (transparency) value. See WebGL / Materials / Transparency for an example of the difference. Default is false.
474
- * @default false
475
- */
476
- premultipliedAlpha: boolean;
477
-
478
- /**
479
- * @default false
480
- */
481
- forceSinglePass: boolean;
482
-
483
- allowOverride: boolean;
484
-
485
- /**
486
- * Whether to apply dithering to the color to remove the appearance of banding. Default is false.
487
- * @default false
488
- */
489
- dithering: boolean;
490
-
491
- /**
492
- * Defines which of the face sides will be rendered - front, back or both.
493
- * Default is {@link THREE.FrontSide}. Other options are {@link THREE.BackSide} and {@link THREE.DoubleSide}.
531
+ * This flag can be used for type testing.
494
532
  *
495
- * @default {@link THREE.FrontSide}
496
- */
497
- side: Side;
498
-
499
- /**
500
- * Defines which of the face sides will cast shadows. Default is *null*.
501
- * If *null*, the value is opposite that of side, above.
502
- * @default null
503
- */
504
- shadowSide: Side | null;
505
-
506
- /**
507
- * Defines whether this material is tone mapped according to the renderer's
508
- * {@link WebGLRenderer.toneMapping toneMapping} setting. It is ignored when rendering to a render target or using
509
- * post processing.
510
- * @default true
511
- */
512
- toneMapped: boolean;
513
-
514
- /**
515
- * Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects.
516
- * When set to true, the extent to which the material is transparent is controlled by setting it's .opacity property.
517
- * @default false
518
- */
519
- transparent: boolean;
520
-
521
- /**
522
- * UUID of this material instance. This gets automatically assigned, so this shouldn't be edited.
523
- */
524
- uuid: string;
525
-
526
- /**
527
- * Defines whether vertex coloring is used. Default is false.
528
- * @default false
529
- */
530
- vertexColors: boolean;
531
-
532
- /**
533
- * Defines whether this material is visible. Default is true.
534
533
  * @default true
535
534
  */
536
- visible: boolean;
537
-
538
- /**
539
- * An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned.
540
- * @default {}
541
- */
542
- userData: Record<string, any>;
543
-
535
+ readonly isMaterial: boolean;
544
536
  /**
545
- * This starts at 0 and counts how many times .needsUpdate is set to true.
546
- * @default 0
537
+ * The UUID of the material.
547
538
  */
548
- version: number;
549
-
539
+ readonly uuid: string;
550
540
  /**
551
- * Gets the alpha value to be used when running an alpha test. Default is 0.
552
- * @default 0
541
+ * The type property is used for detecting the object type
542
+ * in context of serialization/deserialization.
553
543
  */
554
- get alphaTest(): number;
555
-
544
+ readonly type: string;
556
545
  /**
557
- * Sets the alpha value to be used when running an alpha test. Default is 0.
546
+ * This starts at `0` and counts how many times {@link Material#needsUpdate} is set to `true`.
547
+ *
558
548
  * @default 0
559
549
  */
560
- set alphaTest(value: number);
561
-
550
+ readonly version: number;
562
551
  /**
563
552
  * An optional callback that is executed immediately before the material is used to render a 3D object.
564
- * Unlike properties, the callback is not supported by {@link .clone()}, {@link .copy()} and {@link .toJSON()}.
565
- * This callback is only supported in `WebGLRenderer` (not `WebGPURenderer`).
553
+ *
554
+ * This method can only be used when rendering with {@link WebGLRenderer}.
555
+ *
556
+ * @param {WebGLRenderer} renderer - The renderer.
557
+ * @param {Scene} scene - The scene.
558
+ * @param {Camera} camera - The camera that is used to render the scene.
559
+ * @param {BufferGeometry} geometry - The 3D object's geometry.
560
+ * @param {Object3D} object - The 3D object.
561
+ * @param {Object} group - The geometry group data.
566
562
  */
567
563
  onBeforeRender(
568
564
  renderer: WebGLRenderer,
@@ -572,60 +568,74 @@ export class Material extends EventDispatcher<{ dispose: {} }> {
572
568
  object: Object3D,
573
569
  group: Group,
574
570
  ): void;
575
-
576
571
  /**
577
- * An optional callback that is executed immediately before the shader program is compiled.
578
- * This function is called with the shader source code as a parameter.
579
- * Useful for the modification of built-in materials, but the recommended approach moving forward is to use
580
- * `WebGPURenderer` with the new Node Material system and
581
- * [TSL]{@link https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language}.
582
- * Unlike properties, the callback is not supported by {@link .clone()}, {@link .copy()} and {@link .toJSON()}.
583
- * This callback is only supported in `WebGLRenderer` (not `WebGPURenderer`).
584
- * @param parameters WebGL program parameters
585
- * @param renderer WebGLRenderer context that is initializing the material
572
+ * An optional callback that is executed immediately before the shader
573
+ * program is compiled. This function is called with the shader source code
574
+ * as a parameter. Useful for the modification of built-in materials.
575
+ *
576
+ * This method can only be used when rendering with {@link WebGLRenderer}. The
577
+ * recommended approach when customizing materials is to use `WebGPURenderer` with the new
578
+ * Node Material system and [TSL]{@link https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language}.
579
+ *
580
+ * @param {{vertexShader:string,fragmentShader:string,uniforms:Object}} shaderobject - The object holds the uniforms and the vertex and fragment shader source.
581
+ * @param {WebGLRenderer} renderer - A reference to the renderer.
586
582
  */
587
583
  onBeforeCompile(parameters: WebGLProgramParametersWithUniforms, renderer: WebGLRenderer): void;
588
-
589
584
  /**
590
- * In case onBeforeCompile is used, this callback can be used to identify values of settings used in onBeforeCompile, so three.js can reuse a cached shader or recompile the shader as needed.
585
+ * In case {@link Material#onBeforeCompile} is used, this callback can be used to identify
586
+ * values of settings used in `onBeforeCompile()`, so three.js can reuse a cached
587
+ * shader or recompile the shader for this material as needed.
588
+ *
589
+ * This method can only be used when rendering with {@link WebGLRenderer}.
590
+ *
591
+ * @return {string} The custom program cache key.
591
592
  */
592
593
  customProgramCacheKey(): string;
593
-
594
594
  /**
595
- * Sets the properties based on the values.
596
- * @param values A container with parameters.
595
+ * This method can be used to set default values from parameter objects.
596
+ * It is a generic implementation so it can be used with different types
597
+ * of materials.
598
+ *
599
+ * @param {Object} [values] - The material values to set.
597
600
  */
598
- setValues(values: MaterialParameters): void;
599
-
601
+ setValues(values?: MaterialParameters): void;
600
602
  /**
601
- * Convert the material to three.js JSON format.
602
- * @param meta Object containing metadata such as textures or images for the material.
603
+ * Serializes the material into JSON.
604
+ *
605
+ * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
606
+ * @return {Object} A JSON object representing the serialized material.
607
+ * @see {@link ObjectLoader#parse}
603
608
  */
604
609
  toJSON(meta?: JSONMeta): MaterialJSON;
605
-
606
610
  /**
607
- * Return a new material with the same parameters as this material.
611
+ * Returns a new material with copied values from this instance.
612
+ *
613
+ * @return {Material} A clone of this instance.
608
614
  */
609
615
  clone(): this;
610
-
611
616
  /**
612
- * Copy the parameters from the passed material into this material.
613
- * @param material
617
+ * Copies the values of the given material to this instance.
618
+ *
619
+ * @param {Material} source - The material to copy.
620
+ * @return {Material} A reference to this instance.
614
621
  */
615
- copy(material: Material): this;
616
-
622
+ copy(source: Material): this;
617
623
  /**
618
- * Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer
619
- * used in your app.
624
+ * Frees the GPU-related resources allocated by this instance. Call this
625
+ * method whenever this instance is no longer used in your app.
620
626
  *
621
- * Material textures must be disposed of by the dispose() method of {@link Texture}.
627
+ * @fires Material#dispose
622
628
  */
623
629
  dispose(): void;
624
-
625
630
  /**
626
- * Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL.
627
- * This property is automatically set to true when instancing a new material.
631
+ * Setting this property to `true` indicates the engine the material
632
+ * needs to be recompiled.
633
+ *
628
634
  * @default false
635
+ * @param {boolean} value
629
636
  */
630
637
  set needsUpdate(value: boolean);
631
638
  }
639
+
640
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
641
+ export interface Material extends MaterialProperties {}