@types/three 0.143.0 → 0.143.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. three/README.md +1 -1
  2. three/examples/jsm/nodes/Nodes.d.ts +215 -0
  3. three/examples/jsm/nodes/accessors/BufferNode.d.ts +11 -0
  4. three/examples/jsm/nodes/accessors/CameraNode.d.ts +12 -0
  5. three/examples/jsm/nodes/accessors/CubeTextureNode.d.ts +11 -0
  6. three/examples/jsm/nodes/accessors/InstanceNode.d.ts +9 -0
  7. three/examples/jsm/nodes/accessors/MaterialNode.d.ts +23 -0
  8. three/examples/jsm/nodes/accessors/MaterialReferenceNode.d.ts +6 -0
  9. three/examples/jsm/nodes/accessors/ModelNode.d.ts +9 -0
  10. three/examples/jsm/nodes/accessors/ModelViewProjectionNode.d.ts +6 -0
  11. three/examples/jsm/nodes/accessors/NormalNode.d.ts +17 -0
  12. three/examples/jsm/nodes/accessors/Object3DNode.d.ts +22 -0
  13. three/examples/jsm/nodes/accessors/PointUVNode.d.ts +7 -0
  14. three/examples/jsm/nodes/accessors/PositionNode.d.ts +19 -0
  15. three/examples/jsm/nodes/accessors/ReferenceNode.d.ts +13 -0
  16. three/examples/jsm/nodes/accessors/ReflectVectorNode.d.ts +8 -0
  17. three/examples/jsm/nodes/accessors/SkinningNode.d.ts +13 -0
  18. three/examples/jsm/nodes/accessors/StorageBufferNode.d.ts +6 -0
  19. three/examples/jsm/nodes/accessors/TextureNode.d.ts +12 -0
  20. three/examples/jsm/nodes/accessors/UVNode.d.ts +8 -0
  21. three/examples/jsm/nodes/accessors/UserDataNode.d.ts +7 -0
  22. three/examples/jsm/nodes/core/ArrayUniformNode.d.ts +8 -0
  23. three/examples/jsm/nodes/core/AttributeNode.d.ts +9 -0
  24. three/examples/jsm/nodes/core/BypassNode.d.ts +9 -0
  25. three/examples/jsm/nodes/core/CodeNode.d.ts +16 -0
  26. three/examples/jsm/nodes/core/ConstNode.d.ts +10 -0
  27. three/examples/jsm/nodes/core/ContextNode.d.ts +10 -0
  28. three/examples/jsm/nodes/core/ExpressionNode.d.ts +7 -0
  29. three/examples/jsm/nodes/core/FunctionCallNode.d.ts +13 -0
  30. three/examples/jsm/nodes/core/FunctionNode.d.ts +15 -0
  31. three/examples/jsm/nodes/core/InputNode.d.ts +12 -0
  32. three/examples/jsm/nodes/core/InstanceIndexNode.d.ts +6 -0
  33. three/examples/jsm/nodes/core/Node.d.ts +30 -0
  34. three/examples/jsm/nodes/core/NodeAttribute.d.ts +6 -0
  35. three/examples/jsm/nodes/core/NodeBuilder.d.ts +134 -0
  36. three/examples/jsm/nodes/core/NodeCode.d.ts +4 -0
  37. three/examples/jsm/nodes/core/NodeFrame.d.ts +19 -0
  38. three/examples/jsm/nodes/core/NodeFunction.d.ts +13 -0
  39. three/examples/jsm/nodes/core/NodeFunctionInput.d.ts +7 -0
  40. three/examples/jsm/nodes/core/NodeKeywords.d.ts +14 -0
  41. three/examples/jsm/nodes/core/NodeParser.d.ts +5 -0
  42. three/examples/jsm/nodes/core/NodeUniform.d.ts +13 -0
  43. three/examples/jsm/nodes/core/NodeUtils.d.ts +6 -0
  44. three/examples/jsm/nodes/core/NodeVar.d.ts +6 -0
  45. three/examples/jsm/nodes/core/NodeVary.d.ts +6 -0
  46. three/examples/jsm/nodes/core/PropertyNode.d.ts +6 -0
  47. three/examples/jsm/nodes/core/TempNode.d.ts +8 -0
  48. three/examples/jsm/nodes/core/UniformNode.d.ts +10 -0
  49. three/examples/jsm/nodes/core/VarNode.d.ts +16 -0
  50. three/examples/jsm/nodes/core/VaryNode.d.ts +8 -0
  51. three/examples/jsm/nodes/core/constants.d.ts +77 -0
  52. three/examples/jsm/nodes/display/ColorAdjustmentNode.d.ts +20 -0
  53. three/examples/jsm/nodes/display/ColorSpaceNode.d.ts +15 -0
  54. three/examples/jsm/nodes/display/FrontFacingNode.d.ts +6 -0
  55. three/examples/jsm/nodes/display/NormalMapNode.d.ts +12 -0
  56. three/examples/jsm/nodes/display/ToneMappingNode.d.ts +14 -0
  57. three/examples/jsm/nodes/fog/FogNode.d.ts +10 -0
  58. three/examples/jsm/nodes/fog/FogRangeNode.d.ts +10 -0
  59. three/examples/jsm/nodes/functions/BSDF/BRDF_GGX.d.ts +6 -0
  60. three/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.d.ts +6 -0
  61. three/examples/jsm/nodes/functions/BSDF/DFGApprox.d.ts +10 -0
  62. three/examples/jsm/nodes/functions/BSDF/D_GGX.d.ts +9 -0
  63. three/examples/jsm/nodes/functions/BSDF/F_Schlick.d.ts +6 -0
  64. three/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.d.ts +6 -0
  65. three/examples/jsm/nodes/functions/PhysicalLightingModel.d.ts +11 -0
  66. three/examples/jsm/nodes/functions/light/getDistanceAttenuation.d.ts +5 -0
  67. three/examples/jsm/nodes/functions/material/getGeometryRoughness.d.ts +5 -0
  68. three/examples/jsm/nodes/functions/material/getRoughness.d.ts +6 -0
  69. three/examples/jsm/nodes/geometry/RangeNode.d.ts +12 -0
  70. three/examples/jsm/nodes/gpgpu/ComputeNode.d.ts +11 -0
  71. three/examples/jsm/nodes/lighting/AONode.d.ts +8 -0
  72. three/examples/jsm/nodes/lighting/AnalyticLightNode.d.ts +10 -0
  73. three/examples/jsm/nodes/lighting/EnvironmentNode.d.ts +8 -0
  74. three/examples/jsm/nodes/lighting/HemisphereLightNode.d.ts +13 -0
  75. three/examples/jsm/nodes/lighting/LightingContextNode.d.ts +15 -0
  76. three/examples/jsm/nodes/lighting/LightingNode.d.ts +5 -0
  77. three/examples/jsm/nodes/lighting/LightsNode.d.ts +19 -0
  78. three/examples/jsm/nodes/lighting/PunctualLightNode.d.ts +12 -0
  79. three/examples/jsm/nodes/loaders/NodeLoader.d.ts +21 -0
  80. three/examples/jsm/nodes/loaders/NodeMaterialLoader.d.ts +8 -0
  81. three/examples/jsm/nodes/loaders/NodeObjectLoader.d.ts +11 -0
  82. three/examples/jsm/nodes/materials/LineBasicNodeMaterial.d.ts +16 -0
  83. three/examples/jsm/nodes/materials/Materials.d.ts +15 -0
  84. three/examples/jsm/nodes/materials/MeshBasicNodeMaterial.d.ts +19 -0
  85. three/examples/jsm/nodes/materials/MeshStandardNodeMaterial.d.ts +27 -0
  86. three/examples/jsm/nodes/materials/NodeMaterial.d.ts +22 -0
  87. three/examples/jsm/nodes/materials/PointsNodeMaterial.d.ts +15 -0
  88. three/examples/jsm/nodes/materials/SpriteNodeMaterial.d.ts +23 -0
  89. three/examples/jsm/nodes/math/CondNode.d.ts +9 -0
  90. three/examples/jsm/nodes/math/MathNode.d.ts +116 -0
  91. three/examples/jsm/nodes/math/OperatorNode.d.ts +31 -0
  92. three/examples/jsm/nodes/procedural/CheckerNode.d.ts +6 -0
  93. three/examples/jsm/nodes/shadernode/ShaderNode.d.ts +155 -0
  94. three/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.d.ts +267 -0
  95. three/examples/jsm/nodes/shadernode/ShaderNodeElements.d.ts +128 -0
  96. three/examples/jsm/nodes/utils/ArrayElementNode.d.ts +9 -0
  97. three/examples/jsm/nodes/utils/ConvertNode.d.ts +8 -0
  98. three/examples/jsm/nodes/utils/JoinNode.d.ts +10 -0
  99. three/examples/jsm/nodes/utils/MatcapUVNode.d.ts +5 -0
  100. three/examples/jsm/nodes/utils/MaxMipLevelNode.d.ts +7 -0
  101. three/examples/jsm/nodes/utils/OscNode.d.ts +19 -0
  102. three/examples/jsm/nodes/utils/RotateUVNode.d.ts +10 -0
  103. three/examples/jsm/nodes/utils/SplitNode.d.ts +16 -0
  104. three/examples/jsm/nodes/utils/SpriteSheetUVNode.d.ts +9 -0
  105. three/examples/jsm/nodes/utils/TimerNode.d.ts +14 -0
  106. three/examples/jsm/renderers/webgl/nodes/SlotNode.d.ts +5 -0
  107. three/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.d.ts +56 -0
  108. three/examples/jsm/renderers/webgl/nodes/WebGLNodes.d.ts +3 -0
  109. three/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.d.ts +13 -0
  110. three/index.d.ts +1 -1
  111. three/package.json +2 -2
@@ -0,0 +1,5 @@
1
+ import Node from '../core/Node';
2
+
3
+ export default abstract class LightingNode extends Node {
4
+ constructor();
5
+ }
@@ -0,0 +1,19 @@
1
+ import { Light } from '../../../../src/Three';
2
+ import Node from '../core/Node';
3
+ import LightingNode from './LightingNode';
4
+
5
+ export default class LightsNode extends Node {
6
+ lightNodes: LightingNode[];
7
+
8
+ constructor(lightNodes?: LightingNode[]);
9
+
10
+ get hasLight(): boolean;
11
+ getLightNodeByHash(hash: string): LightingNode | null;
12
+
13
+ fromLights(lights: Light[]): this;
14
+
15
+ static setReference<T extends Light>(
16
+ lightClass: { new (): T },
17
+ lightNodeClass: { new (light: T): LightingNode },
18
+ ): void;
19
+ }
@@ -0,0 +1,12 @@
1
+ import AnalyticLightNode from './AnalyticLightNode';
2
+ import Node from '../core/Node';
3
+ import { PointLight, SpotLight } from '../../../../src/Three';
4
+
5
+ export type PunctualLight = PointLight | SpotLight;
6
+
7
+ export default class PunctualLightNode extends AnalyticLightNode<PunctualLight> {
8
+ cutoffDistanceNode: Node;
9
+ decayExponentNode: Node;
10
+
11
+ constructor(light?: PunctualLight | null);
12
+ }
@@ -0,0 +1,21 @@
1
+ import { Loader, LoadingManager, Texture } from '../../../../src/Three';
2
+ import { Node, AnyJson } from '../Nodes';
3
+
4
+ export interface NodeLoaderResult {
5
+ [hash: string]: Node;
6
+ }
7
+
8
+ export default class NodeLoader extends Loader {
9
+ constructor(manager?: LoadingManager);
10
+
11
+ load(
12
+ url: string,
13
+ onLoad: (gltf: NodeLoaderResult) => void,
14
+ onProgress?: (event: ProgressEvent) => void,
15
+ onError?: (event: ErrorEvent) => void,
16
+ ): void;
17
+
18
+ parseNodes(json: AnyJson): NodeLoaderResult;
19
+ parse(json: AnyJson): Node;
20
+ setTextures(textures: { [key: string]: Texture }): this;
21
+ }
@@ -0,0 +1,8 @@
1
+ import { MaterialLoader } from '../../../../src/Three';
2
+ import { NodeLoaderResult } from './NodeLoader';
3
+
4
+ export default class NodeMaterialLoader extends MaterialLoader {
5
+ nodes: NodeLoaderResult;
6
+
7
+ setNodes(value: NodeLoaderResult): this;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { NodeLoaderResult } from './NodeLoader';
2
+ import { Material, ObjectLoader, Texture } from '../../../../src/Three';
3
+ import { AnyJson } from '../core/constants';
4
+
5
+ export default class NodeObjectLoader extends ObjectLoader {
6
+ parseNodes(json: AnyJson, textures: { [key: string]: Texture }): NodeLoaderResult;
7
+
8
+ // tslint:disable-next-line:comment-format
9
+ //@ts-expect-error
10
+ parseMaterials(json: AnyJson, textures: { [key: string]: Texture }): { [key: string]: Material };
11
+ }
@@ -0,0 +1,16 @@
1
+ import NodeMaterial from './NodeMaterial';
2
+ import { ShaderMaterialParameters } from '../../../../src/Three';
3
+ import { Node } from '../Nodes';
4
+
5
+ export default class LineBasicNodeMaterial extends NodeMaterial {
6
+ isLineBasicNodeMaterial: true;
7
+
8
+ colorNode: Node | null;
9
+ opacityNode: Node | null;
10
+ alphaTestNode: Node | null;
11
+ lightNode: Node | null;
12
+ positionNode: Node | null;
13
+
14
+ constructor(parameters?: ShaderMaterialParameters);
15
+ copy(source: LineBasicNodeMaterial): this;
16
+ }
@@ -0,0 +1,15 @@
1
+ import NodeMaterial from '../materials/NodeMaterial';
2
+ import LineBasicNodeMaterial from '../materials/LineBasicNodeMaterial';
3
+ import MeshBasicNodeMaterial from '../materials/MeshBasicNodeMaterial';
4
+ import MeshStandardNodeMaterial from '../materials/MeshStandardNodeMaterial';
5
+ import PointsNodeMaterial from '../materials/PointsNodeMaterial';
6
+ import SpriteNodeMaterial from '../materials/SpriteNodeMaterial';
7
+
8
+ export {
9
+ NodeMaterial,
10
+ LineBasicNodeMaterial,
11
+ MeshBasicNodeMaterial,
12
+ MeshStandardNodeMaterial,
13
+ PointsNodeMaterial,
14
+ SpriteNodeMaterial,
15
+ };
@@ -0,0 +1,19 @@
1
+ import NodeMaterial from './NodeMaterial';
2
+ import Node from '../core/Node';
3
+ import { ShaderMaterialParameters } from '../../../../src/Three';
4
+
5
+ export default class MeshBasicNodeMaterial extends NodeMaterial {
6
+ isMeshBasicNodeMaterial: true;
7
+ lights: true;
8
+
9
+ colorNode: Node | null;
10
+ opacityNode: Node | null;
11
+
12
+ alphaTestNode: Node | null;
13
+ lightNode: Node | null;
14
+
15
+ positionNode: Node | null;
16
+
17
+ constructor(paramters?: ShaderMaterialParameters);
18
+ copy(source: MeshBasicNodeMaterial): this;
19
+ }
@@ -0,0 +1,27 @@
1
+ import { ShaderMaterialParameters } from '../../../../src/Three';
2
+ import Node from '../core/Node';
3
+ import NodeMaterial from './NodeMaterial';
4
+
5
+ export default class MeshStandardNodeMaterial extends NodeMaterial {
6
+ isMeshStandardNodeMaterial: true;
7
+
8
+ colorNode: Node | null;
9
+ opacityNode: Node | null;
10
+ alphaTestNode: Node | null;
11
+ normalNode: Node | null;
12
+ emissiveNode: Node | null;
13
+
14
+ metalnessNode: Node | null;
15
+ roughnessNode: Node | null;
16
+
17
+ clearcoatNode: Node | null;
18
+ clearcoatRoughnessNode: Node | null;
19
+
20
+ envNode: Node | null;
21
+
22
+ lightsNode: Node | null;
23
+ positionNode: Node | null;
24
+
25
+ constructor(paramters?: ShaderMaterialParameters);
26
+ copy(source: MeshStandardNodeMaterial): this;
27
+ }
@@ -0,0 +1,22 @@
1
+ import { Material, ShaderMaterial } from '../../../../src/Three';
2
+ import NodeBuilder from '../core/NodeBuilder';
3
+ import Node from '../core/Node';
4
+ import { LightingModelNode } from '../lighting/LightingContextNode';
5
+
6
+ export default class NodeMaterial extends ShaderMaterial {
7
+ isNodeMaterial: true;
8
+ lights: true;
9
+ type: string;
10
+ constructor();
11
+
12
+ build(builder: NodeBuilder): void;
13
+ customProgramCacheKey(): string;
14
+ generatePosition(builder: NodeBuilder): void;
15
+ generateDiffuseColor(builder: NodeBuilder): void;
16
+ generateLight(
17
+ builder: NodeBuilder,
18
+ lights: { diffuseColorNode: Node; lightingModelNode: LightingModelNode; lightsNode?: Node },
19
+ ): void;
20
+ generateOutput(builder: NodeBuilder, lights: { diffuseColorNode: Node; outgoingLightNode: Node }): void;
21
+ static fromMaterial(m: Material): NodeMaterial;
22
+ }
@@ -0,0 +1,15 @@
1
+ import NodeMaterial from './NodeMaterial';
2
+ import { ShaderMaterialParameters } from '../../../../src/Three';
3
+ import { Node } from '../Nodes';
4
+
5
+ export default class PointsNodeMaterial extends NodeMaterial {
6
+ isPointsNodeMateria: true;
7
+ colorNode: Node | null;
8
+ opacityNode: Node | null;
9
+ alphaTestNode: Node | null;
10
+ lightNode: Node | null;
11
+ sizeNode: Node | null;
12
+ positionNode: Node | null;
13
+ constructor(parameters?: ShaderMaterialParameters);
14
+ copy(source: PointsNodeMaterial): this;
15
+ }
@@ -0,0 +1,23 @@
1
+ import NodeMaterial from './NodeMaterial';
2
+ import { ShaderMaterialParameters } from '../../../../src/Three';
3
+ import { NodeBuilder } from '../Nodes';
4
+ import Node from '../core/Node';
5
+
6
+ export default class SpriteNodeMaterial extends NodeMaterial {
7
+ isSpriteNodeMaterial: true;
8
+
9
+ colorNode: Node | null;
10
+ opacityNode: Node | null;
11
+
12
+ alphaTestNode: Node | null;
13
+
14
+ lightNode: Node | null;
15
+
16
+ positionNode: Node | null;
17
+ rotationNode: Node | null;
18
+ scaleNode: Node | null;
19
+
20
+ constructor(parameters?: ShaderMaterialParameters);
21
+ generatePosition(builder: NodeBuilder): void;
22
+ copy(source: SpriteNodeMaterial): this;
23
+ }
@@ -0,0 +1,9 @@
1
+ import Node from '../core/Node';
2
+
3
+ export default class CondNode extends Node {
4
+ condNode: Node;
5
+ ifNode: Node;
6
+ elseNode: Node;
7
+
8
+ constructor(condNode: Node, ifNode: Node, elseNode: Node);
9
+ }
@@ -0,0 +1,116 @@
1
+ import Node from '../core/Node';
2
+ import TempNode from '../core/TempNode';
3
+
4
+ export type MathNodeMethod1 =
5
+ | typeof MathNode.RADIANS
6
+ | typeof MathNode.DEGREES
7
+ | typeof MathNode.EXP
8
+ | typeof MathNode.EXP2
9
+ | typeof MathNode.LOG
10
+ | typeof MathNode.LOG2
11
+ | typeof MathNode.SQRT
12
+ | typeof MathNode.INVERSE_SQRT
13
+ | typeof MathNode.FLOOR
14
+ | typeof MathNode.CEIL
15
+ | typeof MathNode.NORMALIZE
16
+ | typeof MathNode.FRACT
17
+ | typeof MathNode.SIN
18
+ | typeof MathNode.COS
19
+ | typeof MathNode.TAN
20
+ | typeof MathNode.ASIN
21
+ | typeof MathNode.ACOS
22
+ | typeof MathNode.ATAN
23
+ | typeof MathNode.ABS
24
+ | typeof MathNode.SIGN
25
+ | typeof MathNode.LENGTH
26
+ | typeof MathNode.NEGATE
27
+ | typeof MathNode.INVERT
28
+ | typeof MathNode.DFDX
29
+ | typeof MathNode.DFDY
30
+ | typeof MathNode.SATURATE
31
+ | typeof MathNode.ROUND;
32
+
33
+ export type MathNodeMethod2 =
34
+ | typeof MathNode.ATAN2
35
+ | typeof MathNode.MIN
36
+ | typeof MathNode.MAX
37
+ | typeof MathNode.MOD
38
+ | typeof MathNode.STEP
39
+ | typeof MathNode.REFLECT
40
+ | typeof MathNode.DISTANCE
41
+ | typeof MathNode.DOT
42
+ | typeof MathNode.CROSS
43
+ | typeof MathNode.POW
44
+ | typeof MathNode.TRANSFORM_DIRECTION;
45
+
46
+ export type MathNodeMethod3 =
47
+ | typeof MathNode.MIX
48
+ | typeof MathNode.CLAMP
49
+ | typeof MathNode.REFRACT
50
+ | typeof MathNode.SMOOTHSTEP
51
+ | typeof MathNode.FACEFORWARD;
52
+
53
+ export type MathNodeMethod = MathNodeMethod1 | MathNodeMethod2 | MathNodeMethod3;
54
+
55
+ export default class MathNode extends TempNode {
56
+ // 1 input
57
+
58
+ static RADIANS: 'radians';
59
+ static DEGREES: 'degrees';
60
+ static EXP: 'exp';
61
+ static EXP2: 'exp2';
62
+ static LOG: 'log';
63
+ static LOG2: 'log2';
64
+ static SQRT: 'sqrt';
65
+ static INVERSE_SQRT: 'inversesqrt';
66
+ static FLOOR: 'floor';
67
+ static CEIL: 'ceil';
68
+ static NORMALIZE: 'normalize';
69
+ static FRACT: 'fract';
70
+ static SIN: 'sin';
71
+ static COS: 'cos';
72
+ static TAN: 'tan';
73
+ static ASIN: 'asin';
74
+ static ACOS: 'acos';
75
+ static ATAN: 'atan';
76
+ static ABS: 'abs';
77
+ static SIGN: 'sign';
78
+ static LENGTH: 'length';
79
+ static NEGATE: 'negate';
80
+ static INVERT: 'invert';
81
+ static DFDX: 'dFdx';
82
+ static DFDY: 'dFdy';
83
+ static SATURATE: 'saturate';
84
+ static ROUND: 'round';
85
+
86
+ // 2 inputs
87
+
88
+ static ATAN2: 'atan2';
89
+ static MIN: 'min';
90
+ static MAX: 'max';
91
+ static MOD: 'mod';
92
+ static STEP: 'step';
93
+ static REFLECT: 'reflect';
94
+ static DISTANCE: 'distance';
95
+ static DOT: 'dot';
96
+ static CROSS: 'cross';
97
+ static POW: 'pow';
98
+ static TRANSFORM_DIRECTION: 'transformDirection';
99
+
100
+ // 3 inputs
101
+
102
+ static MIX: 'mix';
103
+ static CLAMP: 'clamp';
104
+ static REFRACT: 'refract';
105
+ static SMOOTHSTEP: 'smoothstep';
106
+ static FACEFORWARD: 'faceforward';
107
+
108
+ method: MathNodeMethod;
109
+ aNode: Node;
110
+ bNode: Node | null;
111
+ cNode: Node | null;
112
+
113
+ constructor(method: MathNodeMethod1, aNode: Node);
114
+ constructor(method: MathNodeMethod2, aNode: Node, bNode: Node);
115
+ constructor(method: MathNodeMethod3, aNode: Node, bNode: Node, cNode: Node);
116
+ }
@@ -0,0 +1,31 @@
1
+ import TempNode from '../core/TempNode';
2
+ import Node from '../core/Node';
3
+
4
+ export type OperatorNodeOp =
5
+ | '='
6
+ | '%'
7
+ | '&'
8
+ | '|'
9
+ | '^'
10
+ | '>>'
11
+ | '<<'
12
+ | '=='
13
+ | '&&'
14
+ | '||'
15
+ | '^^'
16
+ | '<'
17
+ | '>'
18
+ | '<='
19
+ | '>='
20
+ | '+'
21
+ | '-'
22
+ | '*'
23
+ | '/';
24
+
25
+ export default class OperatorNode extends TempNode {
26
+ aNode: Node;
27
+ bNode: Node;
28
+ op: OperatorNodeOp;
29
+
30
+ constructor(op: OperatorNodeOp, ...params: [Node, Node, ...Node[]]);
31
+ }
@@ -0,0 +1,6 @@
1
+ import Node from '../core/Node';
2
+
3
+ export default class CheckerNode extends Node {
4
+ uvNode: Node;
5
+ constructor(uvNode?: Node);
6
+ }
@@ -0,0 +1,155 @@
1
+ import { ConstNode, Node, NodeBuilder, NodeTypeOption, SwizzleOption } from '../Nodes';
2
+ // lot of private typescript magic here
3
+ export {};
4
+ export type Swizzable<T extends Node = Node> = T &
5
+ {
6
+ [key in SwizzleOption | number]: Swizzable;
7
+ };
8
+
9
+ /** anything that can be passed to {@link nodeObject} and returns a proxy */
10
+ export type NodeRepresentation = number | boolean | Node | Swizzable;
11
+
12
+ /** anything that can be passed to {@link nodeObject} */
13
+ export type NodeObjectOption = NodeRepresentation | string;
14
+
15
+ // same logic as in ShaderNodeObject
16
+ export type NodeObject<T> = T extends Node ? Swizzable<T> : T extends number | boolean ? Swizzable<ConstNode> : T;
17
+
18
+ type MakeObjectOption<T> = T extends Node ? NodeRepresentation : T;
19
+ // https://github.com/microsoft/TypeScript/issues/42435#issuecomment-765557874
20
+ type MakeObjectOptions<T extends readonly [...unknown[]]> = [...{ [index in keyof T]: MakeObjectOption<T[index]> }];
21
+ type RemoveTail<T extends readonly [...unknown[]]> = T extends [unknown, ...infer X] ? X : [];
22
+ type RemoveHeadAndTail<T extends readonly [...unknown[]]> = T extends [unknown, ...infer X, unknown] ? X : [];
23
+
24
+ /**
25
+ * Temporary type to save signatures of 4 constructors. Each element may be tuple or undefined.
26
+ *
27
+ * We use an object instead of tuple or union as it makes stuff easier, especially in Typescript 4.0.
28
+ */
29
+ interface Construtors<
30
+ A extends undefined | [...unknown[]],
31
+ B extends undefined | [...unknown[]],
32
+ C extends undefined | [...unknown[]],
33
+ D extends undefined | [...unknown[]],
34
+ > {
35
+ a: A;
36
+ b: B;
37
+ c: C;
38
+ d: D;
39
+ }
40
+
41
+ /**
42
+ * Returns all constructors
43
+ *
44
+ * <https://github.com/microsoft/TypeScript/issues/37079>
45
+ * <https://stackoverflow.com/a/52761156/1623826>
46
+ */
47
+ type OverloadedConstructorsOf<T> = T extends {
48
+ new (...args: infer A1): unknown;
49
+ new (...args: infer A2): unknown;
50
+ new (...args: infer A3): unknown;
51
+ new (...args: infer A4): unknown;
52
+ }
53
+ ? Construtors<A1, A2, A3, A4>
54
+ : T extends {
55
+ new (...args: infer A1): unknown;
56
+ new (...args: infer A2): unknown;
57
+ new (...args: infer A3): unknown;
58
+ }
59
+ ? Construtors<A1, A2, A3, undefined>
60
+ : T extends {
61
+ new (...args: infer A1): unknown;
62
+ new (...args: infer A2): unknown;
63
+ }
64
+ ? Construtors<A1, A2, undefined, undefined>
65
+ : T extends new (...args: infer A) => unknown
66
+ ? Construtors<A, undefined, undefined, undefined>
67
+ : Construtors<undefined, undefined, undefined, undefined>;
68
+
69
+ type AnyConstructors = Construtors<any, any, any, any>;
70
+
71
+ /**
72
+ * Returns all constructors where the first paramter is assignable to given "scope"
73
+ */
74
+ // tslint:disable-next-line:interface-over-type-literal
75
+ type FilterConstructorsByScope<T extends AnyConstructors, S> = {
76
+ a: S extends T['a'][0] ? T['a'] : undefined;
77
+ b: S extends T['b'][0] ? T['b'] : undefined;
78
+ c: S extends T['c'][0] ? T['c'] : undefined;
79
+ d: S extends T['d'][0] ? T['d'] : undefined;
80
+ };
81
+ /**
82
+ * "flattens" the tuple into an union type
83
+ */
84
+ type ConstructorUnion<T extends AnyConstructors> =
85
+ | (T['a'] extends undefined ? never : T['a'])
86
+ | (T['b'] extends undefined ? never : T['b'])
87
+ | (T['c'] extends undefined ? never : T['c'])
88
+ | (T['d'] extends undefined ? never : T['d']);
89
+
90
+ /**
91
+ * Extract list of possible scopes - union of the first paramter
92
+ * of all constructors, should it be string
93
+ */
94
+ type ExtractScopes<T extends AnyConstructors> =
95
+ | (T['a'][0] extends string ? T['a'][0] : never)
96
+ | (T['b'][0] extends string ? T['b'][0] : never)
97
+ | (T['c'][0] extends string ? T['c'][0] : never)
98
+ | (T['d'][0] extends string ? T['d'][0] : never);
99
+
100
+ type GetConstructorsByScope<T, S> = ConstructorUnion<FilterConstructorsByScope<OverloadedConstructorsOf<T>, S>>;
101
+ type GetConstructors<T> = ConstructorUnion<OverloadedConstructorsOf<T>>;
102
+ type GetPossibleScopes<T> = ExtractScopes<OverloadedConstructorsOf<T>>;
103
+
104
+ export type ConvertType = (...params: unknown[]) => Swizzable;
105
+
106
+ export const ConvertType: {
107
+ new (type: NodeTypeOption, cacheMap?: Map<unknown, ConstNode>): ConvertType;
108
+ };
109
+
110
+ type NodeArray<T extends NodeObjectOption[]> = { [index in keyof T]: NodeObject<T[index]> };
111
+ type NodeObjects<T> = { [key in keyof T]: T[key] extends NodeObjectOption ? NodeObject<T[key]> : T[key] };
112
+ type ConstructedNode<T> = T extends new (...args: any[]) => infer R ? (R extends Node ? R : never) : never;
113
+
114
+ export type NodeOrType = Node | NodeTypeOption;
115
+
116
+ export function getConstNodeType(value: NodeOrType): NodeTypeOption | null;
117
+ export function nodeObject<T extends NodeObjectOption>(obj: T): NodeObject<T>;
118
+ export function nodeObjects<T>(obj: T): NodeObjects<T>;
119
+
120
+ export function nodeArray<T extends NodeObjectOption[]>(obj: readonly [...T]): NodeArray<T>;
121
+
122
+ export function nodeProxy<T>(
123
+ nodeClass: T,
124
+ ): (...params: MakeObjectOptions<GetConstructors<T>>) => Swizzable<ConstructedNode<T>>;
125
+
126
+ export function nodeProxy<T, S extends GetPossibleScopes<T>>(
127
+ nodeClass: T,
128
+ scope: S,
129
+ ): (...params: MakeObjectOptions<RemoveTail<GetConstructorsByScope<T, S>>>) => Swizzable<ConstructedNode<T>>;
130
+
131
+ export function nodeProxy<T, S extends GetPossibleScopes<T>>(
132
+ nodeClass: T,
133
+ scope: S,
134
+ factor: NodeObjectOption,
135
+ ): (...params: MakeObjectOptions<RemoveHeadAndTail<GetConstructorsByScope<T, S>>>) => Swizzable<ConstructedNode<T>>;
136
+
137
+ export function nodeImmutable<T>(
138
+ nodeClass: T,
139
+ ...params: MakeObjectOptions<GetConstructors<T>>
140
+ ): Swizzable<ConstructedNode<T>>;
141
+
142
+ export class ShaderNode<T = {}, R extends Node = Node> {
143
+ constructor(jsFunc: (inputs: NodeObjects<T>, builder: NodeBuilder) => NodeRepresentation);
144
+ call: (
145
+ inputs: { [key in keyof T]: T[key] extends NodeRepresentation ? Swizzable | Node : T[key] },
146
+ builder?: NodeBuilder,
147
+ ) => Swizzable<R>;
148
+ }
149
+
150
+ export const cacheMaps: {
151
+ bool: Map<boolean, ConstNode>;
152
+ uint: Map<number, ConstNode>;
153
+ int: Map<number, ConstNode>;
154
+ float: Map<number, ConstNode>;
155
+ };