@types/three 0.159.0 → 0.160.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 (129) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/loaders/KTX2Loader.d.ts +2 -8
  3. three/examples/jsm/loaders/MaterialXLoader.d.ts +6 -0
  4. three/examples/jsm/misc/Timer.d.ts +80 -0
  5. three/examples/jsm/nodes/Nodes.d.ts +238 -60
  6. three/examples/jsm/nodes/accessors/BitangentNode.d.ts +9 -0
  7. three/examples/jsm/nodes/accessors/BufferNode.d.ts +4 -1
  8. three/examples/jsm/nodes/accessors/CameraNode.d.ts +7 -0
  9. three/examples/jsm/nodes/accessors/CubeTextureNode.d.ts +9 -2
  10. three/examples/jsm/nodes/accessors/InstanceNode.d.ts +3 -0
  11. three/examples/jsm/nodes/accessors/MaterialNode.d.ts +12 -0
  12. three/examples/jsm/nodes/accessors/MaterialReferenceNode.d.ts +7 -0
  13. three/examples/jsm/nodes/accessors/ModelNode.d.ts +7 -1
  14. three/examples/jsm/nodes/accessors/ModelViewProjectionNode.d.ts +3 -0
  15. three/examples/jsm/nodes/accessors/NormalNode.d.ts +8 -0
  16. three/examples/jsm/nodes/accessors/PointUVNode.d.ts +3 -0
  17. three/examples/jsm/nodes/accessors/PositionNode.d.ts +8 -0
  18. three/examples/jsm/nodes/accessors/ReferenceNode.d.ts +4 -1
  19. three/examples/jsm/nodes/accessors/ReflectVectorNode.d.ts +3 -0
  20. three/examples/jsm/nodes/accessors/SkinningNode.d.ts +3 -0
  21. three/examples/jsm/nodes/accessors/StorageBufferNode.d.ts +8 -1
  22. three/examples/jsm/nodes/accessors/TangentNode.d.ts +9 -0
  23. three/examples/jsm/nodes/accessors/TextureNode.d.ts +10 -2
  24. three/examples/jsm/nodes/accessors/UVNode.d.ts +3 -0
  25. three/examples/jsm/nodes/accessors/UserDataNode.d.ts +7 -0
  26. three/examples/jsm/nodes/code/CodeNode.d.ts +4 -0
  27. three/examples/jsm/nodes/code/ExpressionNode.d.ts +3 -0
  28. three/examples/jsm/nodes/code/FunctionCallNode.d.ts +7 -1
  29. three/examples/jsm/nodes/code/FunctionNode.d.ts +17 -0
  30. three/examples/jsm/nodes/core/ArrayUniformNode.d.ts +1 -1
  31. three/examples/jsm/nodes/core/AttributeNode.d.ts +3 -0
  32. three/examples/jsm/nodes/core/BypassNode.d.ts +3 -0
  33. three/examples/jsm/nodes/core/CacheNode.d.ts +3 -0
  34. three/examples/jsm/nodes/core/ConstNode.d.ts +3 -3
  35. three/examples/jsm/nodes/core/ContextNode.d.ts +3 -0
  36. three/examples/jsm/nodes/core/InputNode.d.ts +4 -4
  37. three/examples/jsm/nodes/core/NodeBuilder.d.ts +6 -3
  38. three/examples/jsm/nodes/core/NodeUniform.d.ts +12 -8
  39. three/examples/jsm/nodes/core/NodeUtils.d.ts +6 -3
  40. three/examples/jsm/nodes/core/PropertyNode.d.ts +9 -0
  41. three/examples/jsm/nodes/core/UniformNode.d.ts +12 -4
  42. three/examples/jsm/nodes/core/VarNode.d.ts +4 -0
  43. three/examples/jsm/nodes/core/VaryingNode.d.ts +3 -0
  44. three/examples/jsm/nodes/core/constants.d.ts +9 -5
  45. three/examples/jsm/nodes/display/BlendModeNode.d.ts +7 -2
  46. three/examples/jsm/nodes/display/ColorAdjustmentNode.d.ts +18 -1
  47. three/examples/jsm/nodes/display/ColorSpaceNode.d.ts +4 -0
  48. three/examples/jsm/nodes/display/FrontFacingNode.d.ts +4 -0
  49. three/examples/jsm/nodes/display/NormalMapNode.d.ts +7 -1
  50. three/examples/jsm/nodes/display/PosterizeNode.d.ts +6 -0
  51. three/examples/jsm/nodes/display/ToneMappingNode.d.ts +8 -1
  52. three/examples/jsm/nodes/display/ViewportNode.d.ts +8 -0
  53. three/examples/jsm/nodes/fog/FogExp2Node.d.ts +3 -0
  54. three/examples/jsm/nodes/fog/FogNode.d.ts +3 -0
  55. three/examples/jsm/nodes/fog/FogRangeNode.d.ts +3 -0
  56. three/examples/jsm/nodes/functions/BSDF/BRDF_GGX.d.ts +1 -1
  57. three/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.d.ts +1 -1
  58. three/examples/jsm/nodes/functions/BSDF/DFGApprox.d.ts +1 -1
  59. three/examples/jsm/nodes/functions/BSDF/D_GGX.d.ts +1 -1
  60. three/examples/jsm/nodes/functions/BSDF/F_Schlick.d.ts +1 -1
  61. three/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.d.ts +1 -1
  62. three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts +1 -1
  63. three/examples/jsm/nodes/functions/material/getGeometryRoughness.d.ts +1 -1
  64. three/examples/jsm/nodes/functions/material/getRoughness.d.ts +1 -1
  65. three/examples/jsm/nodes/geometry/RangeNode.d.ts +3 -0
  66. three/examples/jsm/nodes/gpgpu/ComputeNode.d.ts +7 -0
  67. three/examples/jsm/nodes/lighting/LightingContextNode.d.ts +6 -1
  68. three/examples/jsm/nodes/lighting/LightsNode.d.ts +3 -0
  69. three/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.d.ts +18 -5
  70. three/examples/jsm/nodes/materials/MeshStandardNodeMaterial.d.ts +0 -3
  71. three/examples/jsm/nodes/materials/NodeMaterial.d.ts +25 -2
  72. three/examples/jsm/nodes/materialx/MaterialXNodes.d.ts +43 -34
  73. three/examples/jsm/nodes/materialx/lib/mx_hsv.d.ts +5 -3
  74. three/examples/jsm/nodes/materialx/lib/mx_noise.d.ts +7 -5
  75. three/examples/jsm/nodes/math/CondNode.d.ts +7 -0
  76. three/examples/jsm/nodes/math/MathNode.d.ts +134 -1
  77. three/examples/jsm/nodes/math/OperatorNode.d.ts +51 -0
  78. three/examples/jsm/nodes/procedural/CheckerNode.d.ts +3 -0
  79. three/examples/jsm/nodes/shadernode/ShaderNode.d.ts +75 -33
  80. three/examples/jsm/nodes/utils/EquirectUVNode.d.ts +4 -2
  81. three/examples/jsm/nodes/utils/MatcapUVNode.d.ts +3 -0
  82. three/examples/jsm/nodes/utils/MaxMipLevelNode.d.ts +6 -3
  83. three/examples/jsm/nodes/utils/OscNode.d.ts +6 -0
  84. three/examples/jsm/nodes/utils/RemapNode.d.ts +4 -0
  85. three/examples/jsm/nodes/utils/RotateUVNode.d.ts +3 -0
  86. three/examples/jsm/nodes/utils/SpecularMIPLevelNode.d.ts +5 -1
  87. three/examples/jsm/nodes/utils/SpriteSheetUVNode.d.ts +7 -0
  88. three/examples/jsm/nodes/utils/TimerNode.d.ts +7 -1
  89. three/examples/jsm/nodes/utils/TriplanarTexturesNode.d.ts +22 -7
  90. three/examples/jsm/objects/QuadMesh.d.ts +13 -0
  91. three/examples/jsm/postprocessing/{HBAOPass.d.ts → GTAOPass.d.ts} +22 -10
  92. three/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.d.ts +3 -0
  93. three/examples/jsm/shaders/{HBAOShader.d.ts → GTAOShader.d.ts} +23 -8
  94. three/examples/jsm/shaders/PoissonDenoiseShader.d.ts +1 -1
  95. three/package.json +2 -2
  96. three/src/Three.d.ts +1 -0
  97. three/src/constants.d.ts +3 -1
  98. three/src/core/UniformsGroup.d.ts +3 -3
  99. three/src/lights/PointLight.d.ts +7 -0
  100. three/src/loaders/MaterialLoader.d.ts +6 -3
  101. three/src/materials/LineBasicMaterial.d.ts +7 -0
  102. three/src/materials/LineDashedMaterial.d.ts +7 -1
  103. three/src/materials/Material.d.ts +14 -14
  104. three/src/materials/MeshBasicMaterial.d.ts +7 -0
  105. three/src/materials/MeshDepthMaterial.d.ts +6 -0
  106. three/src/materials/MeshDistanceMaterial.d.ts +7 -0
  107. three/src/materials/MeshLambertMaterial.d.ts +7 -0
  108. three/src/materials/MeshMatcapMaterial.d.ts +7 -0
  109. three/src/materials/MeshNormalMaterial.d.ts +7 -0
  110. three/src/materials/MeshPhongMaterial.d.ts +7 -0
  111. three/src/materials/MeshPhysicalMaterial.d.ts +6 -1
  112. three/src/materials/MeshStandardMaterial.d.ts +7 -2
  113. three/src/materials/MeshToonMaterial.d.ts +7 -0
  114. three/src/materials/PointsMaterial.d.ts +7 -0
  115. three/src/materials/RawShaderMaterial.d.ts +9 -0
  116. three/src/materials/ShaderMaterial.d.ts +9 -3
  117. three/src/materials/ShadowMaterial.d.ts +7 -0
  118. three/src/materials/SpriteMaterial.d.ts +7 -2
  119. three/src/math/Matrix4.d.ts +30 -30
  120. three/src/math/Sphere.d.ts +5 -0
  121. three/src/math/Triangle.d.ts +8 -8
  122. three/src/objects/SkinnedMesh.d.ts +1 -2
  123. three/src/renderers/shaders/ShaderLib.d.ts +18 -18
  124. three/src/renderers/shaders/UniformsUtils.d.ts +3 -2
  125. three/src/renderers/webgl/WebGLLights.d.ts +39 -37
  126. three/src/renderers/webgl/WebGLPrograms.d.ts +224 -9
  127. three/src/textures/CompressedCubeTexture.d.ts +13 -0
  128. three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +0 -310
  129. three/examples/jsm/nodes/shadernode/ShaderNodeElements.d.ts +0 -166
@@ -1,4 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export type PositionNodeScope =
4
5
  | typeof PositionNode.GEOMETRY
@@ -19,3 +20,10 @@ export default class PositionNode extends Node {
19
20
 
20
21
  constructor(scope?: PositionNodeScope);
21
22
  }
23
+
24
+ export const positionGeometry: ShaderNodeObject<PositionNode>;
25
+ export const positionLocal: ShaderNodeObject<PositionNode>;
26
+ export const positionWorld: ShaderNodeObject<PositionNode>;
27
+ export const positionWorldDirection: ShaderNodeObject<PositionNode>;
28
+ export const positionView: ShaderNodeObject<PositionNode>;
29
+ export const positionViewDirection: ShaderNodeObject<PositionNode>;
@@ -1,5 +1,6 @@
1
1
  import Node from '../core/Node.js';
2
- import { NodeTypeOption } from '../Nodes.js';
2
+ import { NodeTypeOption } from '../core/constants.js';
3
+ import { NodeOrType, ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class ReferenceNode<T> extends Node {
5
6
  object: T;
@@ -11,3 +12,5 @@ export default class ReferenceNode<T> extends Node {
11
12
 
12
13
  setNodeType(uniformType: NodeTypeOption): void;
13
14
  }
15
+
16
+ export const reference: <T>(name: string, nodeOrType: NodeOrType, object: T) => ShaderNodeObject<ReferenceNode<T>>;
@@ -1,4 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export default class ReflectVectorNode extends Node {
4
5
  constructor();
@@ -6,3 +7,5 @@ export default class ReflectVectorNode extends Node {
6
7
  getHash(): 'reflectVector';
7
8
  setup(): Node;
8
9
  }
10
+
11
+ export const reflectVector: ShaderNodeObject<ReflectVectorNode>;
@@ -1,5 +1,6 @@
1
1
  import { SkinnedMesh } from '../../../../src/Three.js';
2
2
  import Node from '../core/Node.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class SkinningNode extends Node {
5
6
  skinIndexNode: Node;
@@ -11,3 +12,5 @@ export default class SkinningNode extends Node {
11
12
 
12
13
  constructor(skinnedMesh: SkinnedMesh);
13
14
  }
15
+
16
+ export function skinning(skinnedMesh: SkinnedMesh): ShaderNodeObject<SkinningNode>;
@@ -1,6 +1,13 @@
1
- import { NodeTypeOption } from '../Nodes.js';
2
1
  import BufferNode from './BufferNode.js';
2
+ import { NodeTypeOption } from '../core/constants.js';
3
+ import { NodeOrType, ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class StorageBufferNode extends BufferNode {
5
6
  constructor(value: ArrayLike<number>, bufferType: NodeTypeOption, bufferCount?: number);
6
7
  }
8
+
9
+ export const storage: (
10
+ value: ArrayLike<number>,
11
+ nodeOrType: NodeOrType,
12
+ count: number,
13
+ ) => ShaderNodeObject<StorageBufferNode>;
@@ -1,4 +1,6 @@
1
1
  import Node from '../core/Node.js';
2
+ import MathNode from '../math/MathNode.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
4
 
3
5
  export type TangentNodeScope =
4
6
  | typeof TangentNode.LOCAL
@@ -16,3 +18,10 @@ export default class TangentNode extends Node {
16
18
 
17
19
  constructor(scope?: TangentNodeScope);
18
20
  }
21
+
22
+ export const tangentGeometry: ShaderNodeObject<TangentNode>;
23
+ export const tangentLocal: ShaderNodeObject<TangentNode>;
24
+ export const tangentView: ShaderNodeObject<TangentNode>;
25
+ export const tangentWorld: ShaderNodeObject<TangentNode>;
26
+ export const transformedTangentView: ShaderNodeObject<MathNode>;
27
+ export const transformedTangentWorld: ShaderNodeObject<MathNode>;
@@ -1,8 +1,9 @@
1
1
  import { Texture } from '../../../../src/Three.js';
2
2
  import UniformNode from '../core/UniformNode.js';
3
- import { Node } from '../Nodes.js';
3
+ import Node from '../core/Node.js';
4
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
5
 
5
- export default class TextureNode extends UniformNode {
6
+ export default class TextureNode extends UniformNode<Texture> {
6
7
  isTextureNode: true;
7
8
 
8
9
  uvNode: Node | null;
@@ -12,3 +13,10 @@ export default class TextureNode extends UniformNode {
12
13
 
13
14
  getDefaultUV(): Node;
14
15
  }
16
+
17
+ export const texture: (
18
+ value: Texture,
19
+ uvNode?: NodeRepresentation,
20
+ levelNode?: NodeRepresentation,
21
+ ) => ShaderNodeObject<TextureNode>;
22
+ export const sampler: (aTexture: Texture | TextureNode) => ShaderNodeObject<Node>;
@@ -1,4 +1,5 @@
1
1
  import AttributeNode from '../core/AttributeNode.js';
2
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export default class UVNode extends AttributeNode {
4
5
  isUVNode: true;
@@ -6,3 +7,5 @@ export default class UVNode extends AttributeNode {
6
7
 
7
8
  constructor(index?: number);
8
9
  }
10
+
11
+ export const uv: (index?: number) => ShaderNodeObject<UVNode>;
@@ -1,7 +1,14 @@
1
1
  import { NodeTypeOption, NodeUserData } from '../core/constants.js';
2
2
  import ReferenceNode from './ReferenceNode.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class UserDataNode extends ReferenceNode<NodeUserData> {
5
6
  userData: NodeUserData | null;
6
7
  constructor(property: string, inputType: NodeTypeOption, userData?: NodeUserData | null);
7
8
  }
9
+
10
+ export const userData: (
11
+ name: string,
12
+ inputType: NodeTypeOption,
13
+ userData?: NodeUserData,
14
+ ) => ShaderNodeObject<UserDataNode>;
@@ -1,5 +1,7 @@
1
1
  import Node from '../core/Node.js';
2
2
  import NodeBuilder from '../core/NodeBuilder.js';
3
+ import { NodeTypeOption } from '../core/constants.js';
4
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
5
 
4
6
  export interface CodeNodeInclude {
5
7
  build(builder: NodeBuilder): void;
@@ -13,3 +15,5 @@ export default class CodeNode extends Node {
13
15
  setIncludes(includes: CodeNodeInclude[]): this;
14
16
  getIncludes(builder: NodeBuilder): CodeNodeInclude[];
15
17
  }
18
+
19
+ export const code: (code: string, nodeType?: NodeTypeOption) => ShaderNodeObject<CodeNode>;
@@ -1,7 +1,10 @@
1
1
  import { NodeTypeOption } from '../core/constants.js';
2
2
  import TempNode from '../core/TempNode.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class ExpressionNode extends TempNode {
5
6
  snipped: string; /* sic */
6
7
  constructor(snipped?: string, nodeType?: NodeTypeOption);
7
8
  }
9
+
10
+ export const expression: (snipped?: string, nodeType?: NodeTypeOption) => ShaderNodeObject<ExpressionNode>;
@@ -1,6 +1,7 @@
1
- import FunctionNode from './FunctionNode.js';
1
+ import FunctionNode, { FunctionNodeArguments } from './FunctionNode.js';
2
2
  import TempNode from '../core/TempNode.js';
3
3
  import Node from '../core/Node.js';
4
+ import { ProxiedObject, ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
5
 
5
6
  export default class FunctionCallNode<P extends Node[] | { [name: string]: Node }> extends TempNode {
6
7
  functionNode: FunctionNode<P>;
@@ -11,3 +12,8 @@ export default class FunctionCallNode<P extends Node[] | { [name: string]: Node
11
12
  setParameters(parameters: P): this;
12
13
  getParameters(): P;
13
14
  }
15
+
16
+ export const call: <P extends FunctionNodeArguments>(
17
+ functionNode?: FunctionNode<P>,
18
+ parameters?: ProxiedObject<P>,
19
+ ) => ShaderNodeObject<FunctionCallNode<P>>;
@@ -4,6 +4,7 @@ import NodeBuilder from '../core/NodeBuilder.js';
4
4
  import NodeFunction from '../core/NodeFunction.js';
5
5
  import NodeFunctionInput from '../core/NodeFunctionInput.js';
6
6
  import Node from '../core/Node.js';
7
+ import { ProxiedObject, ProxiedTuple, ShaderNodeObject } from '../shadernode/ShaderNode.js';
7
8
 
8
9
  export type FunctionNodeArguments = Node[] | { [name: string]: Node };
9
10
 
@@ -15,3 +16,19 @@ export default class FunctionNode<P extends Node[] | { [name: string]: Node }> e
15
16
  getNodeFunction(builder: NodeBuilder): NodeFunction;
16
17
  call(parameters: P): FunctionCallNode<P>;
17
18
  }
19
+
20
+ export type Fn<P extends FunctionNodeArguments> = P extends readonly [...unknown[]]
21
+ ? ProxiedTuple<P>
22
+ : readonly [ProxiedObject<P>];
23
+
24
+ export const func: <P extends FunctionNodeArguments>(
25
+ code: string,
26
+ includes?: CodeNodeInclude[],
27
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
28
+ ) => { call: (...params: Fn<P>) => ShaderNodeObject<Node> };
29
+
30
+ export const fn: <P extends FunctionNodeArguments>(
31
+ code: string,
32
+ includes?: CodeNodeInclude[],
33
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
34
+ ) => (...params: Fn<P>) => ShaderNodeObject<Node>;
@@ -1,7 +1,7 @@
1
1
  import UniformNode from './UniformNode.js';
2
2
  import Node from './Node.js';
3
3
 
4
- export default class ArrayUniformNode extends UniformNode {
4
+ export default class ArrayUniformNode extends UniformNode<undefined> {
5
5
  isArrayUniformNode: true;
6
6
  nodes: Node[];
7
7
  constructor(nodes?: Node[]);
@@ -1,9 +1,12 @@
1
1
  import { NodeTypeOption } from './constants.js';
2
2
  import Node from './Node.js';
3
3
  import NodeBuilder from './NodeBuilder.js';
4
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
5
 
5
6
  export default class AttributeNode extends Node {
6
7
  constructor(attributeName: string, nodeType?: NodeTypeOption | null);
7
8
  setAttributeName(attributeName: string): this;
8
9
  getAttributeName(builder: NodeBuilder): string;
9
10
  }
11
+
12
+ export const attribute: (name: string, nodeType: NodeTypeOption) => ShaderNodeObject<Node>;
@@ -1,4 +1,5 @@
1
1
  import Node from './Node.js';
2
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export default class BypassNode extends Node {
4
5
  isBypassNode: true;
@@ -7,3 +8,5 @@ export default class BypassNode extends Node {
7
8
 
8
9
  constructor(returnNode: Node, callNode: Node);
9
10
  }
11
+
12
+ export const bypass: (returnNode: NodeRepresentation, callNode: NodeRepresentation) => ShaderNodeObject<BypassNode>;
@@ -1,5 +1,6 @@
1
1
  import Node from './Node.js';
2
2
  import NodeCache from './NodeCache.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class CacheNode extends Node {
5
6
  isCacheNode: true;
@@ -8,3 +9,5 @@ export default class CacheNode extends Node {
8
9
 
9
10
  constructor(node: Node, cache?: NodeCache);
10
11
  }
12
+
13
+ export const cache: (node: Node, cache?: NodeCache) => ShaderNodeObject<CacheNode>;
@@ -1,10 +1,10 @@
1
- import { NodeTypeOption, NodeValueOption } from './constants.js';
1
+ import { NodeTypeOption } from './constants.js';
2
2
  import InputNode from './InputNode.js';
3
3
  import NodeBuilder from './NodeBuilder.js';
4
4
 
5
- export default class ConstNode extends InputNode {
5
+ export default class ConstNode<Value> extends InputNode<Value> {
6
6
  isConstNode: true;
7
- constructor(value: NodeValueOption, nodeType?: NodeTypeOption | null);
7
+ constructor(value: Value, nodeType?: NodeTypeOption | null);
8
8
 
9
9
  generateConst(builder: NodeBuilder): string;
10
10
  }
@@ -1,5 +1,6 @@
1
1
  import Node from './Node.js';
2
2
  import { NodeBuilderContext } from './NodeBuilder.js';
3
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class ContextNode extends Node {
5
6
  isContextNode: true;
@@ -8,3 +9,5 @@ export default class ContextNode extends Node {
8
9
 
9
10
  constructor(node: Node, context: NodeBuilderContext);
10
11
  }
12
+
13
+ export const context: (node: NodeRepresentation, context: NodeBuilderContext) => ShaderNodeObject<ContextNode>;
@@ -1,15 +1,15 @@
1
- import { NodeTypeOption, NodeValueOption } from './constants.js';
1
+ import { NodeTypeOption } from './constants.js';
2
2
  import Node from './Node.js';
3
3
  import NodeBuilder from './NodeBuilder.js';
4
4
 
5
5
  export type Precision = 'low' | 'medium' | 'high';
6
6
 
7
- export default abstract class InputNode extends Node {
7
+ export default abstract class InputNode<Value> extends Node {
8
8
  isInputNode: true;
9
- value: NodeValueOption;
9
+ value: Value;
10
10
  precision: Precision | null;
11
11
 
12
- constructor(value: NodeValueOption, nodeType?: NodeTypeOption | null);
12
+ constructor(value: Value, nodeType?: NodeTypeOption | null);
13
13
 
14
14
  getInputType(builder: NodeBuilder): string | null;
15
15
  setPrecision(precision: Precision): this;
@@ -3,14 +3,12 @@ import {
3
3
  Material,
4
4
  Object3D,
5
5
  Renderer,
6
- Scene,
7
6
  Texture,
8
7
  TextureEncoding,
9
8
  WebGLRenderTarget,
10
9
  } from '../../../../src/Three.js';
11
10
  import FogNode from '../fog/FogNode.js';
12
11
  import LightsNode from '../lighting/LightsNode.js';
13
- import { nodeObject } from '../Nodes.js';
14
12
  import { AnyObject, NodeShaderStageOption, NodeTypeOption } from './constants.js';
15
13
  import Node from './Node.js';
16
14
  import NodeAttribute from './NodeAttribute.js';
@@ -106,7 +104,12 @@ export default abstract class NodeBuilder {
106
104
  getVectorFromMatrix(type: NodeTypeOption): NodeTypeOption;
107
105
  getDataFromNode(node: Node, shaderStage?: NodeShaderStageOption): NodeData;
108
106
  getNodeProperties(node: Node, shaderStage?: NodeShaderStageOption): AnyObject;
109
- getUniformFromNode(node: Node, type: NodeTypeOption, shaderStage?: NodeShaderStageOption): NodeUniform;
107
+ getUniformFromNode(
108
+ node: Node,
109
+ type: NodeTypeOption,
110
+ shaderStage?: NodeShaderStageOption,
111
+ name?: string | null,
112
+ ): NodeUniform<string>;
110
113
  getVarFromNode(node: Node, type: NodeTypeOption, shaderStage?: NodeShaderStageOption): NodeVar;
111
114
  getVaryFromNode(node: Node, type: NodeTypeOption): NodeVarying;
112
115
  getCodeFromNode(node: Node, type: NodeTypeOption, shaderStage?: NodeShaderStageOption): string;
@@ -1,13 +1,17 @@
1
- import { NodeValueOption } from './constants.js';
2
- import InputNode from './InputNode.js';
1
+ import UniformNode from './UniformNode.js';
2
+
3
+ export default class NodeUniform<Value> {
4
+ readonly isNodeUniform: true;
3
5
 
4
- export default class NodeUniform {
5
- isNodeUniform: true;
6
6
  name: string;
7
7
  type: string;
8
- node: InputNode;
9
- needsUpdate: boolean;
10
- value: NodeValueOption;
8
+ node: UniformNode<Value>;
9
+ needsUpdate: boolean | undefined;
10
+
11
+ constructor(name: string, type: string, node: UniformNode<Value>, needsUpdate?: boolean);
12
+
13
+ get(): Value;
14
+ set value(val: Value);
11
15
 
12
- constructor(name: string, type: string, node: InputNode, needsUpdate?: boolean);
16
+ get id(): number;
13
17
  }
@@ -1,4 +1,4 @@
1
- import { NodeValueOption } from './constants.js';
1
+ import { Color, Vector2, Vector3, Vector4, Matrix3, Matrix4 } from '../../../../src/Three.js';
2
2
  import Node from './Node.js';
3
3
 
4
4
  export interface NodeChild {
@@ -9,5 +9,8 @@ export interface NodeChild {
9
9
 
10
10
  export function getCacheKey(object: Node): string;
11
11
  export function getNodeChildren(object: Node): Generator<NodeChild, void>;
12
- export function getValueType(value: NodeValueOption): string | null;
13
- export function getValueFromType(type: string, ...params: number[]): NodeValueOption | null;
12
+ export function getValueType(value: unknown): string | null;
13
+ export function getValueFromType(
14
+ type: string,
15
+ ...params: number[]
16
+ ): Color | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4 | boolean | number | string | ArrayBufferLike | null;
@@ -1,6 +1,15 @@
1
1
  import { NodeTypeOption } from './constants.js';
2
2
  import Node from './Node.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class PropertyNode extends Node {
5
6
  constructor(name?: string, nodeType?: NodeTypeOption);
6
7
  }
8
+
9
+ export const property: (name: string, nodeOrType: Node | NodeTypeOption) => ShaderNodeObject<Node>;
10
+
11
+ export const diffuseColor: ShaderNodeObject<PropertyNode>;
12
+ export const roughness: ShaderNodeObject<PropertyNode>;
13
+ export const metalness: ShaderNodeObject<PropertyNode>;
14
+ export const specularColor: ShaderNodeObject<PropertyNode>;
15
+ export const shininess: ShaderNodeObject<PropertyNode>;
@@ -1,10 +1,18 @@
1
- import { NodeTypeOption, NodeValueOption } from './constants.js';
1
+ import { NodeTypeOption } from './constants.js';
2
2
  import InputNode from './InputNode.js';
3
3
  import NodeBuilder from './NodeBuilder.js';
4
+ import Node from './Node.js';
5
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
6
 
5
- export default class UniformNode extends InputNode {
6
- isUniformNode: true;
7
+ export default class UniformNode<Value> extends InputNode<Value> {
8
+ readonly isUniformNode: true;
9
+
10
+ constructor(value: Value, nodeType?: NodeTypeOption | null);
7
11
 
8
- constructor(value: NodeValueOption, nodeType?: NodeTypeOption | null);
9
12
  getUniformHash(builder: NodeBuilder): string;
10
13
  }
14
+
15
+ export const uniform: <Value>(
16
+ arg1: InputNode<Value> | Value,
17
+ arg2?: Node | string,
18
+ ) => ShaderNodeObject<UniformNode<Value>>;
@@ -1,5 +1,6 @@
1
1
  import { OperatorNodeOp } from '../math/OperatorNode.js';
2
2
  import Node from './Node.js';
3
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class VarNode extends Node {
5
6
  node: Node;
@@ -14,3 +15,6 @@ export default class VarNode extends Node {
14
15
  mul(...params: Node[]): this;
15
16
  div(...params: Node[]): this;
16
17
  }
18
+
19
+ export const label: (node: NodeRepresentation, name?: string) => ShaderNodeObject<VarNode>;
20
+ export const temp: (node: NodeRepresentation, name?: string) => ShaderNodeObject<VarNode>;
@@ -1,4 +1,5 @@
1
1
  import Node from './Node.js';
2
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export default class VaryingNode extends Node {
4
5
  node: Node;
@@ -6,3 +7,5 @@ export default class VaryingNode extends Node {
6
7
 
7
8
  constructor(node: Node, name?: string | null);
8
9
  }
10
+
11
+ export const varying: (node: NodeRepresentation, name?: string) => ShaderNodeObject<VaryingNode>;
@@ -1,5 +1,3 @@
1
- import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from '../../../../src/Three.js';
2
-
3
1
  // disable automatic export, we have some private declarations
4
2
  export const NodeShaderStage: {
5
3
  VERTEX: 'vertex';
@@ -13,7 +11,6 @@ export const NodeUpdateType: {
13
11
  OBJECT: 'object';
14
12
  };
15
13
 
16
- export type NodeValueOption = Color | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4 | boolean | number;
17
14
  export type NodeUpdateTypeOption = 'none' | 'frame' | 'object';
18
15
  export type NodeShaderStageOption = 'vertex' | 'fragment' | 'compute';
19
16
  export type NodeTypeOption =
@@ -50,8 +47,15 @@ export type NodeTypeOption =
50
47
  | 'umat4'
51
48
  | 'bmat4';
52
49
 
53
- // can be defined with string template type in Typescript 4.1
54
- export type SwizzleOption = string;
50
+ export type SwizzleCharacter = 'x' | 'y' | 'z' | 'w' | 'r' | 'g' | 'b' | 'a' | 's' | 't' | 'p' | 'q';
51
+
52
+ export type SwizzleOption = Exclude<
53
+ | `${SwizzleCharacter}`
54
+ | `${SwizzleCharacter}${SwizzleCharacter}`
55
+ | `${SwizzleCharacter}${SwizzleCharacter}${SwizzleCharacter}`
56
+ | `${SwizzleCharacter}${SwizzleCharacter}${SwizzleCharacter}${SwizzleCharacter}`,
57
+ 'abs' | 'sqrt'
58
+ >;
55
59
 
56
60
  /** Should be the same type as Object3D.userData */
57
61
  export type NodeUserData = Record<string, any>;
@@ -1,6 +1,6 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { ShaderNode } from '../shadernode/ShaderNodeBaseElements.js';
3
- import { Node } from '../Nodes.js';
2
+ import Node from '../core/Node.js';
3
+ import { NodeRepresentation, ShaderNode, ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
4
 
5
5
  export const BurnNode: ShaderNode<{ base: Node; blendNode: Node }>;
6
6
 
@@ -30,3 +30,8 @@ export default class BlendModeNode extends TempNode {
30
30
 
31
31
  setup(): Node;
32
32
  }
33
+
34
+ export const burn: (baseNode: NodeRepresentation, blendNode?: NodeRepresentation) => ShaderNodeObject<BlendModeNode>;
35
+ export const dodge: (baseNode: NodeRepresentation, blendNode?: NodeRepresentation) => ShaderNodeObject<BlendModeNode>;
36
+ export const overlay: (baseNode: NodeRepresentation, blendNode?: NodeRepresentation) => ShaderNodeObject<BlendModeNode>;
37
+ export const screen: (baseNode: NodeRepresentation, blendNode?: NodeRepresentation) => ShaderNodeObject<BlendModeNode>;
@@ -1,5 +1,6 @@
1
1
  import TempNode from '../core/TempNode.js';
2
- import { Node } from '../Nodes.js';
2
+ import MathNode from '../math/MathNode.js';
3
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export type ColorAdjustmentMethod =
5
6
  | typeof ColorAdjustmentNode.SATURATION
@@ -18,3 +19,19 @@ export default class ColorAdjustmentNode extends TempNode {
18
19
 
19
20
  constructor(method: ColorAdjustmentMethod, colorNode: Node, adjustmentNode?: Node);
20
21
  }
22
+
23
+ export const saturation: (
24
+ colorNode: NodeRepresentation,
25
+ adjustmentNode?: NodeRepresentation,
26
+ ) => ShaderNodeObject<ColorAdjustmentNode>;
27
+ export const vibrance: (
28
+ colorNode: NodeRepresentation,
29
+ adjustmentNode?: NodeRepresentation,
30
+ ) => ShaderNodeObject<ColorAdjustmentNode>;
31
+ export const hue: (
32
+ colorNode: NodeRepresentation,
33
+ adjustmentNode?: NodeRepresentation,
34
+ ) => ShaderNodeObject<ColorAdjustmentNode>;
35
+
36
+ export const lumaCoeffs: ShaderNodeObject<MathNode>;
37
+ export const luminance: (a: NodeRepresentation, b: NodeRepresentation) => ShaderNodeObject<MathNode>;
@@ -1,5 +1,7 @@
1
+ import { TextureEncoding } from '../../../../src/Three.js';
1
2
  import TempNode from '../core/TempNode.js';
2
3
  import Node from '../core/Node.js';
4
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
5
 
4
6
  export type ColorSpaceNodeMethod =
5
7
  | typeof ColorSpaceNode.LINEAR_TO_LINEAR
@@ -16,3 +18,5 @@ export default class ColorSpaceNode extends TempNode {
16
18
 
17
19
  constructor(method: ColorSpaceNodeMethod | null, node: Node);
18
20
  }
21
+
22
+ export const colorSpace: (node: NodeRepresentation, encoding: TextureEncoding) => ShaderNodeObject<ColorSpaceNode>;
@@ -1,6 +1,10 @@
1
1
  import Node from '../core/Node.js';
2
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export default class FrontFacingNode extends Node {
4
5
  isFrontFacingNode: true;
5
6
  constructor();
6
7
  }
8
+
9
+ export const frontFacing: ShaderNodeObject<FrontFacingNode>;
10
+ export const faceDirection: ShaderNodeObject<Node>;
@@ -1,6 +1,8 @@
1
- import TempNode from '../core/TempNode.js';
2
1
  import { NormalMapTypes } from '../../../../src/Three.js';
2
+ import TempNode from '../core/TempNode.js';
3
3
  import Node from '../core/Node.js';
4
+ import MathNode from '../math/MathNode.js';
5
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
6
 
5
7
  export default class NormalMapNode extends TempNode {
6
8
  node: Node;
@@ -10,3 +12,7 @@ export default class NormalMapNode extends TempNode {
10
12
 
11
13
  constructor(node: Node, scaleNode?: Node | null);
12
14
  }
15
+
16
+ export const normalMap: (node: Node, scaleNode?: Node) => ShaderNodeObject<NormalMapNode>;
17
+
18
+ export const TBNViewMatrix: ShaderNodeObject<MathNode>;
@@ -1,4 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export default class PosterizeNode extends Node {
4
5
  sourceNode: Node;
@@ -6,3 +7,8 @@ export default class PosterizeNode extends Node {
6
7
 
7
8
  constructor(sourceNode: Node, stepsNode: Node);
8
9
  }
10
+
11
+ export const posterize: (
12
+ sourceNode: NodeRepresentation,
13
+ stepsNode: NodeRepresentation,
14
+ ) => ShaderNodeObject<PosterizeNode>;
@@ -1,6 +1,7 @@
1
+ import { ToneMapping } from '../../../../src/Three.js';
1
2
  import TempNode from '../core/TempNode.js';
2
3
  import Node from '../core/Node.js';
3
- import { ToneMapping } from '../../../../src/Three.js';
4
+ import { NodeRepresentation, ShaderNodeObject } from '../shadernode/ShaderNode.js';
4
5
 
5
6
  // exposure only
6
7
  export const LinearToneMappingNode: Node;
@@ -12,3 +13,9 @@ export default class ToneMappingNode extends TempNode {
12
13
 
13
14
  constructor(toneMapping: ToneMapping, exposureNode?: Node, colorNode?: Node | null);
14
15
  }
16
+
17
+ export const toneMapping: (
18
+ mapping: ToneMapping,
19
+ exposure: NodeRepresentation,
20
+ color?: NodeRepresentation,
21
+ ) => ShaderNodeObject<ToneMappingNode>;
@@ -1,4 +1,5 @@
1
1
  import Node from '../core/Node.js';
2
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
2
3
 
3
4
  export type ViewportNodeScope =
4
5
  | typeof ViewportNode.COORDINATE
@@ -21,3 +22,10 @@ export default class ViewportNode extends Node {
21
22
 
22
23
  constructor(scope: ViewportNodeScope);
23
24
  }
25
+
26
+ export const viewportCoordinate: ShaderNodeObject<ViewportNode>;
27
+ export const viewportResolution: ShaderNodeObject<ViewportNode>;
28
+ export const viewportTopLeft: ShaderNodeObject<ViewportNode>;
29
+ export const viewportBottomLeft: ShaderNodeObject<ViewportNode>;
30
+ export const viewportTopRight: ShaderNodeObject<ViewportNode>;
31
+ export const viewportBottomRight: ShaderNodeObject<ViewportNode>;
@@ -1,5 +1,6 @@
1
1
  import Node from '../core/Node.js';
2
2
  import FogNode from './FogNode.js';
3
+ import { ShaderNodeObject } from '../shadernode/ShaderNode.js';
3
4
 
4
5
  export default class FogExp2Node extends FogNode {
5
6
  isFogExp2Node: true;
@@ -7,3 +8,5 @@ export default class FogExp2Node extends FogNode {
7
8
 
8
9
  constructor(colorNode: Node, densityNode: Node);
9
10
  }
11
+
12
+ export const densityFog: (colorNode: Node, densityNode: Node) => ShaderNodeObject<FogExp2Node>;