@types/three 0.176.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 (214) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/Addons.d.ts +0 -1
  3. three/examples/jsm/capabilities/WebGL.d.ts +0 -11
  4. three/examples/jsm/controls/TransformControls.d.ts +16 -1
  5. three/examples/jsm/helpers/TextureHelper.d.ts +2 -2
  6. three/examples/jsm/helpers/TextureHelperGPU.d.ts +2 -2
  7. three/examples/jsm/loaders/LDrawLoader.d.ts +8 -3
  8. three/examples/jsm/loaders/SVGLoader.d.ts +1 -1
  9. three/examples/jsm/math/Octree.d.ts +3 -0
  10. three/examples/jsm/physics/RapierPhysics.d.ts +1 -0
  11. three/examples/jsm/postprocessing/AfterimagePass.d.ts +13 -10
  12. three/examples/jsm/postprocessing/FXAAPass.d.ts +7 -0
  13. three/examples/jsm/transpiler/AST.d.ts +77 -26
  14. three/examples/jsm/transpiler/TSLEncoder.d.ts +9 -3
  15. three/examples/jsm/tsl/display/AnamorphicNode.d.ts +4 -4
  16. three/examples/jsm/tsl/display/BleachBypass.d.ts +2 -2
  17. three/examples/jsm/tsl/display/BloomNode.d.ts +2 -2
  18. three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts +20 -0
  19. three/examples/jsm/tsl/display/DenoiseNode.d.ts +4 -4
  20. three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts +6 -6
  21. three/examples/jsm/tsl/display/DotScreenNode.d.ts +2 -2
  22. three/examples/jsm/tsl/display/FXAANode.d.ts +3 -3
  23. three/examples/jsm/tsl/display/FilmNode.d.ts +4 -4
  24. three/examples/jsm/tsl/display/GTAONode.d.ts +3 -3
  25. three/examples/jsm/tsl/display/GaussianBlurNode.d.ts +5 -5
  26. three/examples/jsm/tsl/display/LensflareNode.d.ts +8 -8
  27. three/examples/jsm/tsl/display/Lut3DNode.d.ts +4 -4
  28. three/examples/jsm/tsl/display/MotionBlur.d.ts +4 -4
  29. three/examples/jsm/tsl/display/OutlineNode.d.ts +3 -3
  30. three/examples/jsm/tsl/display/RGBShiftNode.d.ts +3 -3
  31. three/examples/jsm/tsl/display/SMAANode.d.ts +3 -3
  32. three/examples/jsm/tsl/display/SSRNode.d.ts +5 -5
  33. three/examples/jsm/tsl/display/Sepia.d.ts +2 -2
  34. three/examples/jsm/tsl/display/SobelOperatorNode.d.ts +3 -3
  35. three/examples/jsm/tsl/display/TransitionNode.d.ts +4 -4
  36. three/examples/jsm/tsl/display/hashBlur.d.ts +10 -4
  37. three/examples/jsm/tsl/lighting/TiledLightsNode.d.ts +5 -5
  38. three/package.json +3 -3
  39. three/src/Three.Core.d.ts +0 -2
  40. three/src/Three.TSL.d.ts +11 -18
  41. three/src/Three.WebGPU.Nodes.d.ts +1 -0
  42. three/src/Three.WebGPU.d.ts +3 -0
  43. three/src/animation/tracks/NumberKeyframeTrack.d.ts +1 -1
  44. three/src/animation/tracks/QuaternionKeyframeTrack.d.ts +1 -1
  45. three/src/animation/tracks/StringKeyframeTrack.d.ts +1 -1
  46. three/src/animation/tracks/VectorKeyframeTrack.d.ts +1 -1
  47. three/src/constants.d.ts +13 -5
  48. three/src/core/BufferGeometry.d.ts +11 -2
  49. three/src/core/GLBufferAttribute.d.ts +18 -1
  50. three/src/core/RenderTarget.d.ts +3 -20
  51. three/src/extras/DataUtils.d.ts +4 -4
  52. three/src/geometries/CapsuleGeometry.d.ts +1 -0
  53. three/src/helpers/AxesHelper.d.ts +3 -1
  54. three/src/lights/SpotLightShadow.d.ts +2 -0
  55. three/src/lights/webgpu/ProjectorLight.d.ts +17 -0
  56. three/src/materials/LineBasicMaterial.d.ts +66 -34
  57. three/src/materials/LineDashedMaterial.d.ts +41 -21
  58. three/src/materials/Material.d.ts +408 -398
  59. three/src/materials/MeshBasicMaterial.d.ts +101 -62
  60. three/src/materials/MeshDepthMaterial.d.ts +71 -32
  61. three/src/materials/MeshDistanceMaterial.d.ts +65 -29
  62. three/src/materials/MeshLambertMaterial.d.ts +179 -103
  63. three/src/materials/MeshMatcapMaterial.d.ts +97 -55
  64. three/src/materials/MeshNormalMaterial.d.ts +76 -41
  65. three/src/materials/MeshPhongMaterial.d.ts +164 -100
  66. three/src/materials/MeshPhysicalMaterial.d.ts +164 -116
  67. three/src/materials/MeshStandardMaterial.d.ts +178 -91
  68. three/src/materials/MeshToonMaterial.d.ts +130 -81
  69. three/src/materials/PointsMaterial.d.ts +77 -30
  70. three/src/materials/RawShaderMaterial.d.ts +12 -7
  71. three/src/materials/ShaderMaterial.d.ts +186 -98
  72. three/src/materials/ShadowMaterial.d.ts +49 -23
  73. three/src/materials/SpriteMaterial.d.ts +62 -33
  74. three/src/materials/nodes/Line2NodeMaterial.d.ts +87 -40
  75. three/src/materials/nodes/LineBasicNodeMaterial.d.ts +35 -16
  76. three/src/materials/nodes/LineDashedNodeMaterial.d.ts +75 -20
  77. three/src/materials/nodes/MeshBasicNodeMaterial.d.ts +49 -30
  78. three/src/materials/nodes/MeshLambertNodeMaterial.d.ts +49 -42
  79. three/src/materials/nodes/MeshMatcapNodeMaterial.d.ts +38 -26
  80. three/src/materials/nodes/MeshNormalNodeMaterial.d.ts +36 -22
  81. three/src/materials/nodes/MeshPhongNodeMaterial.d.ts +68 -48
  82. three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts +240 -65
  83. three/src/materials/nodes/MeshSSSNodeMaterial.d.ts +99 -3
  84. three/src/materials/nodes/MeshStandardNodeMaterial.d.ts +83 -47
  85. three/src/materials/nodes/MeshToonNodeMaterial.d.ts +42 -36
  86. three/src/materials/nodes/NodeMaterial.d.ts +418 -55
  87. three/src/materials/nodes/NodeMaterials.d.ts +3 -2
  88. three/src/materials/nodes/PointsNodeMaterial.d.ts +31 -7
  89. three/src/materials/nodes/ShadowNodeMaterial.d.ts +38 -11
  90. three/src/materials/nodes/SpriteNodeMaterial.d.ts +68 -18
  91. three/src/materials/nodes/VolumeNodeMaterial.d.ts +50 -14
  92. three/src/materials/nodes/manager/NodeMaterialObserver.d.ts +4 -0
  93. three/src/math/Box3.d.ts +8 -0
  94. three/src/math/Color.d.ts +1 -1
  95. three/src/math/ColorManagement.d.ts +12 -2
  96. three/src/math/Sphere.d.ts +8 -0
  97. three/src/math/Triangle.d.ts +3 -3
  98. three/src/nodes/Nodes.d.ts +2 -3
  99. three/src/nodes/TSL.d.ts +4 -3
  100. three/src/nodes/accessors/AccessorsUtils.d.ts +3 -3
  101. three/src/nodes/accessors/Bitangent.d.ts +0 -2
  102. three/src/nodes/accessors/CubeTextureNode.d.ts +16 -5
  103. three/src/nodes/accessors/Normal.d.ts +19 -5
  104. three/src/nodes/accessors/ReferenceBaseNode.d.ts +1 -1
  105. three/src/nodes/accessors/StorageBufferNode.d.ts +3 -2
  106. three/src/nodes/accessors/StorageTextureNode.d.ts +5 -5
  107. three/src/nodes/accessors/Tangent.d.ts +0 -2
  108. three/src/nodes/accessors/TangentUtils.d.ts +22 -0
  109. three/src/nodes/accessors/Texture3DNode.d.ts +5 -4
  110. three/src/nodes/accessors/TextureBicubic.d.ts +4 -2
  111. three/src/nodes/accessors/TextureNode.d.ts +24 -19
  112. three/src/nodes/accessors/TextureSizeNode.d.ts +3 -3
  113. three/src/nodes/accessors/UniformArrayNode.d.ts +2 -7
  114. three/src/nodes/code/FunctionCallNode.d.ts +3 -1
  115. three/src/nodes/code/FunctionNode.d.ts +2 -2
  116. three/src/nodes/code/ScriptableNode.d.ts +2 -2
  117. three/src/nodes/core/AssignNode.d.ts +7 -3
  118. three/src/nodes/core/AttributeNode.d.ts +1 -1
  119. three/src/nodes/core/BypassNode.d.ts +2 -2
  120. three/src/nodes/core/CacheNode.d.ts +1 -0
  121. three/src/nodes/core/ContextNode.d.ts +3 -3
  122. three/src/nodes/core/Node.d.ts +5 -4
  123. three/src/nodes/core/NodeUtils.d.ts +4 -0
  124. three/src/nodes/core/StackNode.d.ts +3 -13
  125. three/src/nodes/core/SubBuildNode.d.ts +15 -0
  126. three/src/nodes/core/VarNode.d.ts +4 -4
  127. three/src/nodes/core/VaryingNode.d.ts +3 -3
  128. three/src/nodes/display/BlendModes.d.ts +14 -10
  129. three/src/nodes/display/BumpMapNode.d.ts +4 -3
  130. three/src/nodes/display/ColorAdjustment.d.ts +17 -17
  131. three/src/nodes/display/ColorSpaceFunctions.d.ts +3 -3
  132. three/src/nodes/display/ColorSpaceNode.d.ts +6 -16
  133. three/src/nodes/display/FrontFacingNode.d.ts +1 -0
  134. three/src/nodes/display/PosterizeNode.d.ts +3 -3
  135. three/src/nodes/display/RenderOutputNode.d.ts +2 -2
  136. three/src/nodes/display/ScreenNode.d.ts +0 -10
  137. three/src/nodes/display/ToneMappingFunctions.d.ts +7 -7
  138. three/src/nodes/display/ToneMappingNode.d.ts +6 -6
  139. three/src/nodes/display/ViewportDepthTextureNode.d.ts +3 -3
  140. three/src/nodes/fog/Fog.d.ts +10 -10
  141. three/src/nodes/functions/BSDF/Schlick_to_F0.d.ts +4 -4
  142. three/src/nodes/functions/material/getAlphaHashThreshold.d.ts +2 -2
  143. three/src/nodes/functions/material/getParallaxCorrectNormal.d.ts +4 -4
  144. three/src/nodes/geometry/RangeNode.d.ts +9 -2
  145. three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +20 -20
  146. three/src/nodes/gpgpu/ComputeNode.d.ts +2 -2
  147. three/src/nodes/lighting/PointShadowNode.d.ts +11 -11
  148. three/src/nodes/lighting/ProjectorLightNode.d.ts +5 -0
  149. three/src/nodes/lighting/ShadowFilterNode.d.ts +11 -11
  150. three/src/nodes/lighting/SpotLightNode.d.ts +15 -1
  151. three/src/nodes/materialx/MaterialXNodes.d.ts +59 -59
  152. three/src/nodes/materialx/lib/mx_hsv.d.ts +3 -3
  153. three/src/nodes/materialx/lib/mx_noise.d.ts +206 -206
  154. three/src/nodes/materialx/lib/mx_transform_color.d.ts +2 -2
  155. three/src/nodes/math/ConditionalNode.d.ts +4 -19
  156. three/src/nodes/math/Hash.d.ts +2 -2
  157. three/src/nodes/math/MathNode.d.ts +21 -17
  158. three/src/nodes/math/OperatorNode.d.ts +41 -52
  159. three/src/nodes/math/TriNoise3D.d.ts +6 -6
  160. three/src/nodes/pmrem/PMREMNode.d.ts +3 -3
  161. three/src/nodes/pmrem/PMREMUtils.d.ts +20 -20
  162. three/src/nodes/procedural/Checker.d.ts +2 -2
  163. three/src/nodes/shapes/Shapes.d.ts +2 -2
  164. three/src/nodes/tsl/TSLBase.d.ts +1 -0
  165. three/src/nodes/tsl/TSLCore.d.ts +186 -81
  166. three/src/nodes/utils/CubeMapNode.d.ts +2 -2
  167. three/src/nodes/utils/DebugNode.d.ts +2 -2
  168. three/src/nodes/utils/Discard.d.ts +2 -2
  169. three/src/nodes/utils/EquirectUV.d.ts +4 -0
  170. three/src/nodes/utils/LoopNode.d.ts +2 -7
  171. three/src/nodes/utils/MatcapUV.d.ts +4 -0
  172. three/src/nodes/utils/Oscillators.d.ts +5 -5
  173. three/src/nodes/utils/Packing.d.ts +3 -3
  174. three/src/nodes/utils/PostProcessingUtils.d.ts +9 -9
  175. three/src/nodes/utils/RTTNode.d.ts +3 -3
  176. three/src/nodes/utils/ReflectorNode.d.ts +1 -0
  177. three/src/nodes/utils/RemapNode.d.ts +9 -9
  178. three/src/nodes/utils/RotateNode.d.ts +3 -3
  179. three/src/nodes/utils/SampleNode.d.ts +16 -0
  180. three/src/nodes/utils/SpriteSheetUVNode.d.ts +4 -4
  181. three/src/nodes/utils/SpriteUtils.d.ts +2 -2
  182. three/src/nodes/utils/StorageArrayElementNode.d.ts +4 -3
  183. three/src/nodes/utils/TriplanarTextures.d.ts +20 -0
  184. three/src/nodes/utils/UVUtils.d.ts +8 -7
  185. three/src/nodes/utils/ViewportUtils.d.ts +2 -2
  186. three/src/objects/LOD.d.ts +1 -1
  187. three/src/objects/Mesh.d.ts +8 -0
  188. three/src/objects/Sprite.d.ts +8 -0
  189. three/src/renderers/WebGLRenderer.d.ts +3 -3
  190. three/src/renderers/common/Backend.d.ts +3 -3
  191. three/src/renderers/common/RenderObject.d.ts +10 -2
  192. three/src/renderers/common/Renderer.d.ts +10 -5
  193. three/src/renderers/common/Storage3DTexture.d.ts +40 -0
  194. three/src/renderers/common/StorageArrayTexture.d.ts +29 -0
  195. three/src/renderers/common/Textures.d.ts +2 -2
  196. three/src/renderers/common/XRManager.d.ts +45 -0
  197. three/src/renderers/common/XRRenderTarget.d.ts +3 -2
  198. three/src/renderers/common/nodes/NodeLibrary.d.ts +4 -9
  199. three/src/renderers/common/nodes/NodeSampledTexture.d.ts +1 -1
  200. three/src/renderers/common/nodes/Nodes.d.ts +1 -1
  201. three/src/renderers/webgpu/WebGPURenderer.d.ts +3 -0
  202. three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +65 -0
  203. three/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +1 -0
  204. three/src/renderers/webgpu/utils/WebGPUConstants.d.ts +10 -1
  205. three/src/textures/DepthTexture.d.ts +4 -2
  206. three/src/textures/Source.d.ts +20 -16
  207. three/src/textures/Texture.d.ts +69 -2
  208. three/examples/jsm/effects/PeppersGhostEffect.d.ts +0 -10
  209. three/src/core/RenderTargetArray.d.ts +0 -9
  210. three/src/nodes/utils/EquirectUVNode.d.ts +0 -8
  211. three/src/nodes/utils/MatcapUVNode.d.ts +0 -8
  212. three/src/nodes/utils/TriplanarTexturesNode.d.ts +0 -36
  213. three/src/renderers/common/nodes/StandardNodeLibrary.d.ts +0 -5
  214. three/src/textures/DepthArrayTexture.d.ts +0 -14
@@ -1,56 +1,103 @@
1
- import { Color, ColorRepresentation } from "../math/Color.js";
1
+ import { Color } from "../math/Color.js";
2
2
  import { Texture } from "../textures/Texture.js";
3
- import { Material, MaterialParameters } from "./Material.js";
4
-
5
- export interface PointsMaterialParameters extends MaterialParameters {
6
- color?: ColorRepresentation | undefined;
7
- map?: Texture | null | undefined;
8
- alphaMap?: Texture | null | undefined;
9
- size?: number | undefined;
10
- sizeAttenuation?: boolean | undefined;
11
- fog?: boolean | undefined;
12
- }
13
-
14
- export class PointsMaterial extends Material {
15
- constructor(parameters?: PointsMaterialParameters);
16
-
17
- /**
18
- * Read-only flag to check if a given object is of type {@link PointsMaterial}.
19
- * @remarks This is a _constant_ value
20
- * @defaultValue `true`
21
- */
22
- readonly isPointsMaterial: true;
3
+ import { MapColorPropertiesToColorRepresentations, Material, MaterialProperties } from "./Material.js";
23
4
 
5
+ export interface PointsMaterialProperties extends MaterialProperties {
24
6
  /**
25
- * @default new THREE.Color( 0xffffff )
7
+ * Color of the material.
8
+ *
9
+ * @default (1,1,1)
26
10
  */
27
11
  color: Color;
28
-
29
12
  /**
13
+ * The color map. May optionally include an alpha channel, typically combined
14
+ * with {@link Material#transparent} or {@link Material#alphaTest}. The texture map
15
+ * color is modulated by the diffuse `color`.
16
+ *
30
17
  * @default null
31
18
  */
32
19
  map: Texture | null;
33
-
34
20
  /**
21
+ * The alpha map is a grayscale texture that controls the opacity across the
22
+ * surface (black: fully transparent; white: fully opaque).
23
+ *
24
+ * Only the color of the texture is used, ignoring the alpha channel if one
25
+ * exists. For RGB and RGBA textures, the renderer will use the green channel
26
+ * when sampling this texture due to the extra bit of precision provided for
27
+ * green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and
28
+ * luminance/alpha textures will also still work as expected.
29
+ *
35
30
  * @default null
36
31
  */
37
32
  alphaMap: Texture | null;
38
-
39
33
  /**
34
+ * Defines the size of the points in pixels.
35
+ *
36
+ * Might be capped if the value exceeds hardware dependent parameters like [gl.ALIASED_POINT_SIZE_RANGE]{@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getParamete}.
37
+ *
40
38
  * @default 1
41
39
  */
42
40
  size: number;
43
-
44
41
  /**
42
+ * Specifies whether size of individual points is attenuated by the camera depth (perspective camera only).
43
+ *
45
44
  * @default true
46
45
  */
47
46
  sizeAttenuation: boolean;
48
-
49
47
  /**
50
- * Whether the material is affected by fog. Default is true.
51
- * @default fog
48
+ * Whether the material is affected by fog or not.
49
+ *
50
+ * @default true
52
51
  */
53
52
  fog: boolean;
53
+ }
54
54
 
55
- setValues(parameters: PointsMaterialParameters): void;
55
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
56
+ export interface PointsMaterialParameters
57
+ extends Partial<MapColorPropertiesToColorRepresentations<PointsMaterialProperties>>
58
+ {}
59
+
60
+ /**
61
+ * A material for rendering point primitives.
62
+ *
63
+ * Materials define the appearance of renderable 3D objects.
64
+ *
65
+ * ```js
66
+ * const vertices = [];
67
+ *
68
+ * for ( let i = 0; i < 10000; i ++ ) {
69
+ * const x = THREE.MathUtils.randFloatSpread( 2000 );
70
+ * const y = THREE.MathUtils.randFloatSpread( 2000 );
71
+ * const z = THREE.MathUtils.randFloatSpread( 2000 );
72
+ *
73
+ * vertices.push( x, y, z );
74
+ * }
75
+ *
76
+ * const geometry = new THREE.BufferGeometry();
77
+ * geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
78
+ * const material = new THREE.PointsMaterial( { color: 0x888888 } );
79
+ * const points = new THREE.Points( geometry, material );
80
+ * scene.add( points );
81
+ * ```
82
+ */
83
+ export class PointsMaterial extends Material {
84
+ /**
85
+ * Constructs a new points material.
86
+ *
87
+ * @param {Object} [parameters] - An object with one or more properties
88
+ * defining the material's appearance. Any property of the material
89
+ * (including any property from inherited materials) can be passed
90
+ * in here. Color values can be passed any type of value accepted
91
+ * by {@link Color#set}.
92
+ */
93
+ constructor(parameters?: PointsMaterialParameters);
94
+ /**
95
+ * This flag can be used for type testing.
96
+ *
97
+ * @default true
98
+ */
99
+ readonly isPointsMaterial: boolean;
56
100
  }
101
+
102
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
103
+ export interface PointsMaterial extends PointsMaterialProperties {}
@@ -1,12 +1,17 @@
1
- import { ShaderMaterial, ShaderMaterialParameters } from "./ShaderMaterial.js";
1
+ import { ShaderMaterial } from "./ShaderMaterial.js";
2
2
 
3
+ /**
4
+ * This class works just like {@link ShaderMaterial}, except that definitions
5
+ * of built-in uniforms and attributes are not automatically prepended to the
6
+ * GLSL shader code.
7
+ *
8
+ * `RawShaderMaterial` can only be used with {@link WebGLRenderer}.
9
+ */
3
10
  export class RawShaderMaterial extends ShaderMaterial {
4
- constructor(parameters?: ShaderMaterialParameters);
5
-
6
11
  /**
7
- * Read-only flag to check if a given object is of type {@link RawShaderMaterial}.
8
- * @remarks This is a _constant_ value
9
- * @defaultValue `true`
12
+ * This flag can be used for type testing.
13
+ *
14
+ * @default true
10
15
  */
11
- readonly isRawShaderMaterial: true;
16
+ readonly isRawShaderMaterial: boolean;
12
17
  }
@@ -1,162 +1,250 @@
1
1
  import { GLSLVersion } from "../constants.js";
2
2
  import { JSONMeta } from "../core/Object3D.js";
3
3
  import { UniformsGroup } from "../core/UniformsGroup.js";
4
- import { Matrix3, Matrix3Tuple } from "../math/Matrix3.js";
5
- import { Matrix4, Matrix4Tuple } from "../math/Matrix4.js";
4
+ import { Matrix3Tuple } from "../math/Matrix3.js";
5
+ import { Matrix4Tuple } from "../math/Matrix4.js";
6
6
  import { Vector2Tuple } from "../math/Vector2.js";
7
7
  import { Vector3Tuple } from "../math/Vector3.js";
8
8
  import { Vector4Tuple } from "../math/Vector4.js";
9
9
  import { IUniform } from "../renderers/shaders/UniformsLib.js";
10
- import { Material, MaterialJSON, MaterialParameters } from "./Material.js";
11
-
12
- export interface ShaderMaterialParameters extends MaterialParameters {
13
- uniforms?: { [uniform: string]: IUniform } | undefined;
14
- uniformsGroups?: UniformsGroup[] | undefined;
15
- vertexShader?: string | undefined;
16
- fragmentShader?: string | undefined;
17
- linewidth?: number | undefined;
18
- wireframe?: boolean | undefined;
19
- wireframeLinewidth?: number | undefined;
20
- lights?: boolean | undefined;
21
- clipping?: boolean | undefined;
22
- fog?: boolean | undefined;
23
- extensions?:
24
- | {
25
- clipCullDistance?: boolean | undefined;
26
- multiDraw?: boolean | undefined;
27
- }
28
- | undefined;
29
- glslVersion?: GLSLVersion | undefined;
30
- }
31
-
32
- export type ShaderMaterialUniformJSON = {
33
- type: "t";
34
- value: string;
35
- } | {
36
- type: "c";
37
- value: number;
38
- } | {
39
- type: "v2";
40
- value: Vector2Tuple;
41
- } | {
42
- type: "v3";
43
- value: Vector3Tuple;
44
- } | {
45
- type: "v4";
46
- value: Vector4Tuple;
47
- } | {
48
- type: "m3";
49
- value: Matrix3Tuple;
50
- } | {
51
- type: "m4";
52
- value: Matrix4Tuple;
53
- } | {
54
- value: unknown;
55
- };
56
-
57
- export interface ShaderMaterialJSON extends MaterialJSON {
58
- glslVersion: number | null;
59
- uniforms: Record<string, ShaderMaterialUniformJSON>;
60
-
61
- defines?: Record<string, unknown>;
62
-
63
- vertexShader: string;
64
- fragmentShader: string;
65
-
66
- lights: boolean;
67
- clipping: boolean;
68
-
69
- extensions?: Record<string, boolean>;
70
- }
71
-
72
- export class ShaderMaterial extends Material {
73
- constructor(parameters?: ShaderMaterialParameters);
74
-
75
- /**
76
- * Read-only flag to check if a given object is of type {@link ShaderMaterial}.
77
- * @remarks This is a _constant_ value
78
- * @defaultValue `true`
79
- */
80
- readonly isShaderMaterial: true;
10
+ import { MapColorPropertiesToColorRepresentations, Material, MaterialJSON, MaterialProperties } from "./Material.js";
81
11
 
12
+ export interface ShaderMaterialProperties extends MaterialProperties {
82
13
  /**
83
- * @default {}
14
+ * Defines custom constants using `#define` directives within the GLSL code
15
+ * for both the vertex shader and the fragment shader; each key/value pair
16
+ * yields another directive.
17
+ * ```js
18
+ * defines: {
19
+ * FOO: 15,
20
+ * BAR: true
21
+ * }
22
+ * ```
23
+ * Yields the lines:
24
+ * ```
25
+ * #define FOO 15
26
+ * #define BAR true
27
+ * ```
84
28
  */
85
29
  defines: { [key: string]: any };
86
-
87
30
  /**
88
- * @default {}
31
+ * An object of the form:
32
+ * ```js
33
+ * {
34
+ * "uniform1": { value: 1.0 },
35
+ * "uniform2": { value: 2 }
36
+ * }
37
+ * ```
38
+ * specifying the uniforms to be passed to the shader code; keys are uniform
39
+ * names, values are definitions of the form
40
+ * ```
41
+ * {
42
+ * value: 1.0
43
+ * }
44
+ * ```
45
+ * where `value` is the value of the uniform. Names must match the name of
46
+ * the uniform, as defined in the GLSL code. Note that uniforms are refreshed
47
+ * on every frame, so updating the value of the uniform will immediately
48
+ * update the value available to the GLSL code.
89
49
  */
90
50
  uniforms: { [uniform: string]: IUniform };
91
-
92
- uniformsGroups: UniformsGroup[];
93
-
51
+ /**
52
+ * An array holding uniforms groups for configuring UBOs.
53
+ */
54
+ uniformsGroups: Array<UniformsGroup>;
55
+ /**
56
+ * Vertex shader GLSL code. This is the actual code for the shader.
57
+ */
94
58
  vertexShader: string;
95
-
59
+ /**
60
+ * Fragment shader GLSL code. This is the actual code for the shader.
61
+ */
96
62
  fragmentShader: string;
97
-
98
63
  /**
64
+ * Controls line thickness or lines.
65
+ *
66
+ * WebGL and WebGPU ignore this setting and always render line primitives with a
67
+ * width of one pixel.
68
+ *
99
69
  * @default 1
100
70
  */
101
71
  linewidth: number;
102
-
103
72
  /**
73
+ * Renders the geometry as a wireframe.
74
+ *
104
75
  * @default false
105
76
  */
106
77
  wireframe: boolean;
107
-
108
78
  /**
79
+ * Controls the thickness of the wireframe.
80
+ *
81
+ * WebGL and WebGPU ignore this property and always render
82
+ * 1 pixel wide lines.
83
+ *
109
84
  * @default 1
110
85
  */
111
86
  wireframeLinewidth: number;
112
-
113
87
  /**
88
+ * Define whether the material color is affected by global fog settings; `true`
89
+ * to pass fog uniforms to the shader.
90
+ *
114
91
  * @default false
115
92
  */
116
93
  fog: boolean;
117
-
118
94
  /**
95
+ * Defines whether this material uses lighting; `true` to pass uniform data
96
+ * related to lighting to this shader.
97
+ *
119
98
  * @default false
120
99
  */
121
100
  lights: boolean;
122
-
123
101
  /**
102
+ * Defines whether this material supports clipping; `true` to let the renderer
103
+ * pass the clippingPlanes uniform.
104
+ *
124
105
  * @default false
125
106
  */
126
107
  clipping: boolean;
127
-
128
108
  /**
129
- * @default {
130
- * clipCullDistance: false,
131
- * multiDraw: false
132
- * }
109
+ * This object allows to enable certain WebGL 2 extensions.
110
+ *
111
+ * - clipCullDistance: set to `true` to use vertex shader clipping
112
+ * - multiDraw: set to `true` to use vertex shader multi_draw / enable gl_DrawID
133
113
  */
134
114
  extensions: {
135
115
  clipCullDistance: boolean;
136
116
  multiDraw: boolean;
137
117
  };
138
-
139
118
  /**
140
- * @default { 'color': [ 1, 1, 1 ], 'uv': [ 0, 0 ], 'uv1': [ 0, 0 ] }
119
+ * When the rendered geometry doesn't include these attributes but the
120
+ * material does, these default values will be passed to the shaders. This
121
+ * avoids errors when buffer data is missing.
122
+ *
123
+ * - color: [ 1, 1, 1 ]
124
+ * - uv: [ 0, 0 ]
125
+ * - uv1: [ 0, 0 ]
141
126
  */
142
- defaultAttributeValues: any;
143
-
127
+ defaultAttributeValues: {
128
+ color: [number, number, number];
129
+ uv: [number, number];
130
+ uv1: [number, number];
131
+ };
144
132
  /**
133
+ * If set, this calls [gl.bindAttribLocation]{@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bindAttribLocation}
134
+ * to bind a generic vertex index to an attribute variable.
135
+ *
145
136
  * @default undefined
146
137
  */
147
138
  index0AttributeName: string | undefined;
148
-
149
139
  /**
140
+ * Can be used to force a uniform update while changing uniforms in
141
+ * {@link Object3D#onBeforeRender}.
142
+ *
150
143
  * @default false
151
144
  */
152
145
  uniformsNeedUpdate: boolean;
153
-
154
146
  /**
147
+ * Defines the GLSL version of custom shader code.
148
+ *
155
149
  * @default null
156
150
  */
157
151
  glslVersion: GLSLVersion | null;
152
+ }
158
153
 
159
- setValues(parameters: ShaderMaterialParameters): void;
154
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
155
+ export interface ShaderMaterialParameters
156
+ extends Partial<MapColorPropertiesToColorRepresentations<ShaderMaterialProperties>>
157
+ {}
160
158
 
159
+ export type ShaderMaterialUniformJSON = {
160
+ type: "t";
161
+ value: string;
162
+ } | {
163
+ type: "c";
164
+ value: number;
165
+ } | {
166
+ type: "v2";
167
+ value: Vector2Tuple;
168
+ } | {
169
+ type: "v3";
170
+ value: Vector3Tuple;
171
+ } | {
172
+ type: "v4";
173
+ value: Vector4Tuple;
174
+ } | {
175
+ type: "m3";
176
+ value: Matrix3Tuple;
177
+ } | {
178
+ type: "m4";
179
+ value: Matrix4Tuple;
180
+ } | {
181
+ value: unknown;
182
+ };
183
+
184
+ export interface ShaderMaterialJSON extends MaterialJSON {
185
+ glslVersion: number | null;
186
+ uniforms: Record<string, ShaderMaterialUniformJSON>;
187
+
188
+ defines?: Record<string, unknown>;
189
+
190
+ vertexShader: string;
191
+ fragmentShader: string;
192
+
193
+ lights: boolean;
194
+ clipping: boolean;
195
+
196
+ extensions?: Record<string, boolean>;
197
+ }
198
+
199
+ /**
200
+ * A material rendered with custom shaders. A shader is a small program written in GLSL.
201
+ * that runs on the GPU. You may want to use a custom shader if you need to implement an
202
+ * effect not included with any of the built-in materials.
203
+ *
204
+ * There are the following notes to bear in mind when using a `ShaderMaterial`:
205
+ *
206
+ * - `ShaderMaterial` can only be used with {@link WebGLRenderer}.
207
+ * - Built in attributes and uniforms are passed to the shaders along with your code. If
208
+ * you don't want that, use {@link RawShaderMaterial} instead.
209
+ * - You can use the directive `#pragma unroll_loop_start` and `#pragma unroll_loop_end`
210
+ * in order to unroll a `for` loop in GLSL by the shader preprocessor. The directive has
211
+ * to be placed right above the loop. The loop formatting has to correspond to a defined standard.
212
+ * - The loop has to be [normalized]{@link https://en.wikipedia.org/wiki/Normalized_loop}.
213
+ * - The loop variable has to be *i*.
214
+ * - The value `UNROLLED_LOOP_INDEX` will be replaced with the explicitly
215
+ * value of *i* for the given iteration and can be used in preprocessor
216
+ * statements.
217
+ *
218
+ * ```js
219
+ * const material = new THREE.ShaderMaterial( {
220
+ * uniforms: {
221
+ * time: { value: 1.0 },
222
+ * resolution: { value: new THREE.Vector2() }
223
+ * },
224
+ * vertexShader: document.getElementById( 'vertexShader' ).textContent,
225
+ * fragmentShader: document.getElementById( 'fragmentShader' ).textContent
226
+ * } );
227
+ * ```
228
+ */
229
+ export class ShaderMaterial extends Material {
230
+ /**
231
+ * Constructs a new shader material.
232
+ *
233
+ * @param {Object} [parameters] - An object with one or more properties
234
+ * defining the material's appearance. Any property of the material
235
+ * (including any property from inherited materials) can be passed
236
+ * in here. Color values can be passed any type of value accepted
237
+ * by {@link Color#set}.
238
+ */
239
+ constructor(parameters?: ShaderMaterialParameters);
240
+ /**
241
+ * This flag can be used for type testing.
242
+ *
243
+ * @default true
244
+ */
245
+ readonly isShaderMaterial: boolean;
161
246
  toJSON(meta?: JSONMeta): ShaderMaterialJSON;
162
247
  }
248
+
249
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
250
+ export interface ShaderMaterial extends ShaderMaterialProperties {}
@@ -1,34 +1,60 @@
1
- import { Color, ColorRepresentation } from "../math/Color.js";
2
- import { Material, MaterialParameters } from "./Material.js";
3
-
4
- export interface ShadowMaterialParameters extends MaterialParameters {
5
- color?: ColorRepresentation | undefined;
6
- fog?: boolean | undefined;
7
- }
8
-
9
- export class ShadowMaterial extends Material {
10
- constructor(parameters?: ShadowMaterialParameters);
1
+ import { Color } from "../math/Color.js";
2
+ import { MapColorPropertiesToColorRepresentations, Material, MaterialProperties } from "./Material.js";
11
3
 
4
+ export interface ShadowMaterialProperties extends MaterialProperties {
12
5
  /**
13
- * Read-only flag to check if a given object is of type {@link ShadowMaterial}.
14
- * @remarks This is a _constant_ value
15
- * @defaultValue `true`
16
- */
17
- readonly isShadowMaterial: true;
18
-
19
- /**
20
- * @default new THREE.Color( 0x000000 )
6
+ * Color of the material.
7
+ *
8
+ * @default (0,0,0)
21
9
  */
22
10
  color: Color;
23
-
24
11
  /**
12
+ * Whether the material is affected by fog or not.
13
+ *
25
14
  * @default true
26
15
  */
27
- transparent: boolean;
16
+ fog: boolean;
17
+ }
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
20
+ export interface ShadowMaterialParameters
21
+ extends Partial<MapColorPropertiesToColorRepresentations<ShadowMaterialProperties>>
22
+ {}
28
23
 
24
+ /**
25
+ * This material can receive shadows, but otherwise is completely transparent.
26
+ *
27
+ * ```js
28
+ * const geometry = new THREE.PlaneGeometry( 2000, 2000 );
29
+ * geometry.rotateX( - Math.PI / 2 );
30
+ *
31
+ * const material = new THREE.ShadowMaterial();
32
+ * material.opacity = 0.2;
33
+ *
34
+ * const plane = new THREE.Mesh( geometry, material );
35
+ * plane.position.y = -200;
36
+ * plane.receiveShadow = true;
37
+ * scene.add( plane );
38
+ * ```
39
+ */
40
+ export class ShadowMaterial extends Material {
29
41
  /**
30
- * Whether the material is affected by fog. Default is true.
31
- * @default fog
42
+ * Constructs a new shadow material.
43
+ *
44
+ * @param {Object} [parameters] - An object with one or more properties
45
+ * defining the material's appearance. Any property of the material
46
+ * (including any property from inherited materials) can be passed
47
+ * in here. Color values can be passed any type of value accepted
48
+ * by {@link Color#set}.
32
49
  */
33
- fog: boolean;
50
+ constructor(parameters?: ShadowMaterialParameters);
51
+ /**
52
+ * This flag can be used for type testing.
53
+ *
54
+ * @default true
55
+ */
56
+ readonly isShadowMaterial: boolean;
34
57
  }
58
+
59
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
60
+ export interface ShadowMaterial extends ShadowMaterialProperties {}