@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.
- three/README.md +1 -1
- three/examples/jsm/capabilities/WebGL.d.ts +0 -11
- three/examples/jsm/controls/TransformControls.d.ts +16 -1
- three/examples/jsm/helpers/TextureHelper.d.ts +2 -2
- three/examples/jsm/helpers/TextureHelperGPU.d.ts +2 -2
- three/examples/jsm/loaders/SVGLoader.d.ts +1 -1
- three/examples/jsm/physics/RapierPhysics.d.ts +1 -0
- three/examples/jsm/transpiler/AST.d.ts +77 -26
- three/examples/jsm/transpiler/TSLEncoder.d.ts +9 -3
- three/examples/jsm/tsl/display/AnamorphicNode.d.ts +4 -4
- three/examples/jsm/tsl/display/BleachBypass.d.ts +2 -2
- three/examples/jsm/tsl/display/BloomNode.d.ts +2 -2
- three/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts +20 -0
- three/examples/jsm/tsl/display/DenoiseNode.d.ts +4 -4
- three/examples/jsm/tsl/display/DepthOfFieldNode.d.ts +6 -6
- three/examples/jsm/tsl/display/DotScreenNode.d.ts +2 -2
- three/examples/jsm/tsl/display/FXAANode.d.ts +3 -3
- three/examples/jsm/tsl/display/FilmNode.d.ts +4 -4
- three/examples/jsm/tsl/display/GTAONode.d.ts +3 -3
- three/examples/jsm/tsl/display/GaussianBlurNode.d.ts +5 -5
- three/examples/jsm/tsl/display/LensflareNode.d.ts +8 -8
- three/examples/jsm/tsl/display/Lut3DNode.d.ts +4 -4
- three/examples/jsm/tsl/display/MotionBlur.d.ts +4 -4
- three/examples/jsm/tsl/display/OutlineNode.d.ts +3 -3
- three/examples/jsm/tsl/display/RGBShiftNode.d.ts +3 -3
- three/examples/jsm/tsl/display/SMAANode.d.ts +3 -3
- three/examples/jsm/tsl/display/SSRNode.d.ts +5 -5
- three/examples/jsm/tsl/display/Sepia.d.ts +2 -2
- three/examples/jsm/tsl/display/SobelOperatorNode.d.ts +3 -3
- three/examples/jsm/tsl/display/TransitionNode.d.ts +4 -4
- three/examples/jsm/tsl/display/hashBlur.d.ts +5 -5
- three/examples/jsm/tsl/lighting/TiledLightsNode.d.ts +5 -5
- three/package.json +2 -2
- three/src/Three.TSL.d.ts +9 -16
- three/src/Three.WebGPU.d.ts +2 -0
- three/src/constants.d.ts +13 -5
- three/src/core/BufferGeometry.d.ts +6 -1
- three/src/core/GLBufferAttribute.d.ts +18 -1
- three/src/helpers/AxesHelper.d.ts +3 -1
- three/src/materials/LineBasicMaterial.d.ts +66 -34
- three/src/materials/LineDashedMaterial.d.ts +41 -21
- three/src/materials/Material.d.ts +408 -398
- three/src/materials/MeshBasicMaterial.d.ts +101 -62
- three/src/materials/MeshDepthMaterial.d.ts +71 -32
- three/src/materials/MeshDistanceMaterial.d.ts +65 -29
- three/src/materials/MeshLambertMaterial.d.ts +179 -103
- three/src/materials/MeshMatcapMaterial.d.ts +97 -55
- three/src/materials/MeshNormalMaterial.d.ts +76 -41
- three/src/materials/MeshPhongMaterial.d.ts +164 -100
- three/src/materials/MeshPhysicalMaterial.d.ts +171 -111
- three/src/materials/MeshStandardMaterial.d.ts +178 -91
- three/src/materials/MeshToonMaterial.d.ts +130 -81
- three/src/materials/PointsMaterial.d.ts +77 -30
- three/src/materials/RawShaderMaterial.d.ts +12 -7
- three/src/materials/ShaderMaterial.d.ts +186 -98
- three/src/materials/ShadowMaterial.d.ts +49 -23
- three/src/materials/SpriteMaterial.d.ts +62 -33
- three/src/materials/nodes/Line2NodeMaterial.d.ts +87 -40
- three/src/materials/nodes/LineBasicNodeMaterial.d.ts +35 -16
- three/src/materials/nodes/LineDashedNodeMaterial.d.ts +75 -20
- three/src/materials/nodes/MeshBasicNodeMaterial.d.ts +49 -30
- three/src/materials/nodes/MeshLambertNodeMaterial.d.ts +49 -42
- three/src/materials/nodes/MeshMatcapNodeMaterial.d.ts +38 -26
- three/src/materials/nodes/MeshNormalNodeMaterial.d.ts +36 -22
- three/src/materials/nodes/MeshPhongNodeMaterial.d.ts +68 -48
- three/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts +240 -65
- three/src/materials/nodes/MeshSSSNodeMaterial.d.ts +99 -3
- three/src/materials/nodes/MeshStandardNodeMaterial.d.ts +83 -47
- three/src/materials/nodes/MeshToonNodeMaterial.d.ts +42 -36
- three/src/materials/nodes/NodeMaterial.d.ts +417 -56
- three/src/materials/nodes/NodeMaterials.d.ts +3 -2
- three/src/materials/nodes/PointsNodeMaterial.d.ts +31 -7
- three/src/materials/nodes/ShadowNodeMaterial.d.ts +38 -11
- three/src/materials/nodes/SpriteNodeMaterial.d.ts +68 -20
- three/src/materials/nodes/VolumeNodeMaterial.d.ts +50 -14
- three/src/math/Color.d.ts +1 -1
- three/src/nodes/Nodes.d.ts +1 -3
- three/src/nodes/TSL.d.ts +4 -3
- three/src/nodes/accessors/AccessorsUtils.d.ts +3 -3
- three/src/nodes/accessors/Bitangent.d.ts +0 -2
- three/src/nodes/accessors/CubeTextureNode.d.ts +7 -7
- three/src/nodes/accessors/Normal.d.ts +19 -5
- three/src/nodes/accessors/ReferenceBaseNode.d.ts +1 -1
- three/src/nodes/accessors/StorageBufferNode.d.ts +3 -2
- three/src/nodes/accessors/StorageTextureNode.d.ts +5 -5
- three/src/nodes/accessors/Tangent.d.ts +0 -2
- three/src/nodes/accessors/TangentUtils.d.ts +22 -0
- three/src/nodes/accessors/Texture3DNode.d.ts +5 -4
- three/src/nodes/accessors/TextureBicubic.d.ts +4 -2
- three/src/nodes/accessors/TextureNode.d.ts +16 -16
- three/src/nodes/accessors/TextureSizeNode.d.ts +3 -3
- three/src/nodes/accessors/UniformArrayNode.d.ts +2 -7
- three/src/nodes/code/FunctionCallNode.d.ts +3 -1
- three/src/nodes/code/FunctionNode.d.ts +2 -2
- three/src/nodes/code/ScriptableNode.d.ts +2 -2
- three/src/nodes/core/AssignNode.d.ts +2 -2
- three/src/nodes/core/AttributeNode.d.ts +1 -1
- three/src/nodes/core/BypassNode.d.ts +2 -2
- three/src/nodes/core/CacheNode.d.ts +0 -2
- three/src/nodes/core/ContextNode.d.ts +3 -3
- three/src/nodes/core/StackNode.d.ts +3 -13
- three/src/nodes/core/SubBuildNode.d.ts +15 -0
- three/src/nodes/core/VarNode.d.ts +4 -4
- three/src/nodes/core/VaryingNode.d.ts +3 -3
- three/src/nodes/display/BlendModes.d.ts +12 -12
- three/src/nodes/display/BumpMapNode.d.ts +4 -3
- three/src/nodes/display/ColorAdjustment.d.ts +17 -17
- three/src/nodes/display/ColorSpaceFunctions.d.ts +3 -3
- three/src/nodes/display/ColorSpaceNode.d.ts +4 -4
- three/src/nodes/display/FrontFacingNode.d.ts +1 -0
- three/src/nodes/display/PosterizeNode.d.ts +3 -3
- three/src/nodes/display/RenderOutputNode.d.ts +2 -2
- three/src/nodes/display/ScreenNode.d.ts +0 -10
- three/src/nodes/display/ToneMappingFunctions.d.ts +7 -7
- three/src/nodes/display/ToneMappingNode.d.ts +6 -6
- three/src/nodes/display/ViewportDepthTextureNode.d.ts +3 -3
- three/src/nodes/fog/Fog.d.ts +10 -10
- three/src/nodes/functions/BSDF/Schlick_to_F0.d.ts +4 -4
- three/src/nodes/functions/material/getAlphaHashThreshold.d.ts +2 -2
- three/src/nodes/functions/material/getParallaxCorrectNormal.d.ts +4 -4
- three/src/nodes/geometry/RangeNode.d.ts +9 -2
- three/src/nodes/gpgpu/AtomicFunctionNode.d.ts +20 -20
- three/src/nodes/gpgpu/ComputeNode.d.ts +2 -2
- three/src/nodes/lighting/PointShadowNode.d.ts +11 -11
- three/src/nodes/lighting/ShadowFilterNode.d.ts +11 -11
- three/src/nodes/materialx/MaterialXNodes.d.ts +59 -59
- three/src/nodes/materialx/lib/mx_hsv.d.ts +3 -3
- three/src/nodes/materialx/lib/mx_noise.d.ts +206 -206
- three/src/nodes/materialx/lib/mx_transform_color.d.ts +2 -2
- three/src/nodes/math/ConditionalNode.d.ts +4 -19
- three/src/nodes/math/Hash.d.ts +2 -2
- three/src/nodes/math/MathNode.d.ts +21 -17
- three/src/nodes/math/OperatorNode.d.ts +41 -52
- three/src/nodes/math/TriNoise3D.d.ts +6 -6
- three/src/nodes/pmrem/PMREMNode.d.ts +3 -3
- three/src/nodes/pmrem/PMREMUtils.d.ts +20 -20
- three/src/nodes/procedural/Checker.d.ts +2 -2
- three/src/nodes/shapes/Shapes.d.ts +2 -2
- three/src/nodes/tsl/TSLBase.d.ts +1 -0
- three/src/nodes/tsl/TSLCore.d.ts +176 -76
- three/src/nodes/utils/CubeMapNode.d.ts +2 -2
- three/src/nodes/utils/DebugNode.d.ts +2 -2
- three/src/nodes/utils/Discard.d.ts +2 -2
- three/src/nodes/utils/EquirectUV.d.ts +4 -0
- three/src/nodes/utils/LoopNode.d.ts +2 -7
- three/src/nodes/utils/MatcapUV.d.ts +4 -0
- three/src/nodes/utils/Oscillators.d.ts +5 -5
- three/src/nodes/utils/Packing.d.ts +3 -3
- three/src/nodes/utils/PostProcessingUtils.d.ts +9 -9
- three/src/nodes/utils/RTTNode.d.ts +3 -3
- three/src/nodes/utils/RemapNode.d.ts +9 -9
- three/src/nodes/utils/RotateNode.d.ts +3 -3
- three/src/nodes/utils/SampleNode.d.ts +16 -0
- three/src/nodes/utils/SpriteSheetUVNode.d.ts +4 -4
- three/src/nodes/utils/SpriteUtils.d.ts +2 -2
- three/src/nodes/utils/StorageArrayElementNode.d.ts +4 -3
- three/src/nodes/utils/TriplanarTextures.d.ts +20 -0
- three/src/nodes/utils/UVUtils.d.ts +8 -7
- three/src/nodes/utils/ViewportUtils.d.ts +2 -2
- three/src/objects/LOD.d.ts +1 -1
- three/src/renderers/WebGLRenderer.d.ts +1 -1
- three/src/renderers/common/Backend.d.ts +3 -3
- three/src/renderers/common/RenderObject.d.ts +10 -2
- three/src/renderers/common/Renderer.d.ts +5 -5
- three/src/renderers/common/Storage3DTexture.d.ts +40 -0
- three/src/renderers/common/StorageArrayTexture.d.ts +29 -0
- three/src/renderers/common/Textures.d.ts +2 -2
- three/src/renderers/common/XRRenderTarget.d.ts +3 -2
- three/src/renderers/common/nodes/NodeLibrary.d.ts +4 -9
- three/src/renderers/common/nodes/NodeSampledTexture.d.ts +1 -1
- three/src/renderers/common/nodes/Nodes.d.ts +1 -1
- three/src/renderers/webgpu/WebGPURenderer.d.ts +3 -0
- three/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +65 -0
- three/src/renderers/webgpu/utils/WebGPUConstants.d.ts +9 -0
- three/src/nodes/utils/EquirectUVNode.d.ts +0 -8
- three/src/nodes/utils/MatcapUVNode.d.ts +0 -8
- three/src/nodes/utils/TriplanarTexturesNode.d.ts +0 -36
- three/src/renderers/common/nodes/StandardNodeLibrary.d.ts +0 -5
|
@@ -1,56 +1,103 @@
|
|
|
1
|
-
import { Color
|
|
1
|
+
import { Color } from "../math/Color.js";
|
|
2
2
|
import { Texture } from "../textures/Texture.js";
|
|
3
|
-
import { Material,
|
|
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
|
-
*
|
|
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
|
|
51
|
-
*
|
|
48
|
+
* Whether the material is affected by fog or not.
|
|
49
|
+
*
|
|
50
|
+
* @default true
|
|
52
51
|
*/
|
|
53
52
|
fog: boolean;
|
|
53
|
+
}
|
|
54
54
|
|
|
55
|
-
|
|
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
|
|
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
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
12
|
+
* This flag can be used for type testing.
|
|
13
|
+
*
|
|
14
|
+
* @default true
|
|
10
15
|
*/
|
|
11
|
-
readonly isRawShaderMaterial:
|
|
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 {
|
|
5
|
-
import {
|
|
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,
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
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
|
-
*
|
|
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:
|
|
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
|
-
|
|
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
|
|
2
|
-
import { Material,
|
|
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
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
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
|
-
|
|
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
|
-
*
|
|
31
|
-
*
|
|
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
|
-
|
|
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 {}
|