From 9a74766d3193266b3d93171a0a9bc315b90e1fc2 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sun, 15 Dec 2024 15:21:28 -0500 Subject: [PATCH] Update declarations --- types/three/src/nodes/core/NodeAttribute.d.ts | 13 +++++++ types/three/src/nodes/core/NodeVar.d.ts | 12 +++++++ types/three/src/nodes/core/NodeVarying.d.ts | 14 ++++++++ types/three/src/nodes/core/UniformNode.d.ts | 35 +++++++++++++++++++ types/three/src/nodes/core/constants.d.ts | 26 ++++++++++++++ 5 files changed, 100 insertions(+) diff --git a/types/three/src/nodes/core/NodeAttribute.d.ts b/types/three/src/nodes/core/NodeAttribute.d.ts index cc3d12d08..e2accc1c1 100644 --- a/types/three/src/nodes/core/NodeAttribute.d.ts +++ b/types/three/src/nodes/core/NodeAttribute.d.ts @@ -1,9 +1,22 @@ import Node from "./Node.js"; +/** + * {@link NodeBuilder} is going to create instances of this class during the build process + * of nodes. They represent the final shader attributes that are going to be generated + * by the builder. Arrays of node attributes is maintained in {@link NodeBuilder#attributes} + * and {@link NodeBuilder#bufferAttributes} for this purpose. + */ declare class NodeAttribute { readonly isNodeAttribute: true; name: string; type: string | null; node: Node | null; + /** + * Constructs a new node attribute. + * + * @param {String} name - The name of the attribute. + * @param {String} type - The type of the attribute. + * @param {Node?} node - An optinal reference to the node. + */ constructor(name: string, type: string | null, node?: Node | null); } export default NodeAttribute; diff --git a/types/three/src/nodes/core/NodeVar.d.ts b/types/three/src/nodes/core/NodeVar.d.ts index 02ac1754a..af2164bcf 100644 --- a/types/three/src/nodes/core/NodeVar.d.ts +++ b/types/three/src/nodes/core/NodeVar.d.ts @@ -1,7 +1,19 @@ +/** + * {@link NodeBuilder} is going to create instances of this class during the build process + * of nodes. They represent the final shader variables that are going to be generated + * by the builder. A dictionary of node variables is maintained in {@link NodeBuilder#vars} for + * this purpose. + */ declare class NodeVar { readonly isNodeVar: true; name: string; type: string | null; + /** + * Constructs a new node variable. + * + * @param {String} name - The name of the variable. + * @param {String} type - The type of the variable. + */ constructor(name: string, type: string | null); } export default NodeVar; diff --git a/types/three/src/nodes/core/NodeVarying.d.ts b/types/three/src/nodes/core/NodeVarying.d.ts index 71e9aa40b..b488549d5 100644 --- a/types/three/src/nodes/core/NodeVarying.d.ts +++ b/types/three/src/nodes/core/NodeVarying.d.ts @@ -1,7 +1,21 @@ import NodeVar from "./NodeVar.js"; +/** + * {@link NodeBuilder} is going to create instances of this class during the build process + * of nodes. They represent the final shader varyings that are going to be generated + * by the builder. An array of node varyings is maintained in {@link NodeBuilder#varyings} for + * this purpose. + * + * @augments NodeVar + */ declare class NodeVarying extends NodeVar { needsInterpolation: boolean; readonly isNodeVarying: true; + /** + * Constructs a new node varying. + * + * @param {String} name - The name of the varying. + * @param {String} type - The type of the varying. + */ constructor(name: string, type: string | null); } export default NodeVarying; diff --git a/types/three/src/nodes/core/UniformNode.d.ts b/types/three/src/nodes/core/UniformNode.d.ts index a92f816b6..fd2dd74af 100644 --- a/types/three/src/nodes/core/UniformNode.d.ts +++ b/types/three/src/nodes/core/UniformNode.d.ts @@ -4,15 +4,50 @@ import Node from "./Node.js"; import NodeBuilder from "./NodeBuilder.js"; import NodeFrame from "./NodeFrame.js"; import UniformGroupNode from "./UniformGroupNode.js"; +/** + * Class for representing a uniform. + * + * @augments InputNode + */ declare class UniformNode extends InputNode { static get type(): string; readonly isUniformNode: true; name: string; groupNode: UniformGroupNode; + /** + * Constructs a new uniform node. + * + * @param {Any} value - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture). + * @param {String?} nodeType - The node type. If no explicit type is defined, the node tries to derive the type from its value. + */ constructor(value: TValue, nodeType?: string | null); + /** + * Sets the {@link UniformNode#name} property. + * + * @param {String} name - The name of the uniform. + * @return {UniformNode} A reference to this node. + */ label(name: string): this; + /** + * Sets the {@link UniformNode#groupNode} property. + * + * @param {UniformGroupNode} group - The uniform group. + * @return {UniformNode} A reference to this node. + */ setGroup(group: UniformGroupNode): this; + /** + * Returns the {@link UniformNode#groupNode}. + * + * @return {UniformGroupNode} The uniform group. + */ getGroup(): UniformGroupNode; + /** + * By default, this method returns the result of {@link Node#getHash} but derived + * classes might overwrite this method with a different implementation. + * + * @param {NodeBuilder} builder - The current node builder. + * @return {String} The uniform hash. + */ getUniformHash(builder: NodeBuilder): string; onUpdate(callback: (frame: NodeFrame, self: this) => TValue | undefined, updateType: NodeUpdateType): this; generate(builder: NodeBuilder, output: string | null): string; diff --git a/types/three/src/nodes/core/constants.d.ts b/types/three/src/nodes/core/constants.d.ts index 2151a69fc..72c280b6f 100644 --- a/types/three/src/nodes/core/constants.d.ts +++ b/types/three/src/nodes/core/constants.d.ts @@ -1,3 +1,9 @@ +/** + * Possible shader stages. + * + * @property {string} VERTEX The vertex shader stage. + * @property {string} FRAGMENT The fragment shader stage. + */ export declare const NodeShaderStage: { readonly VERTEX: "vertex"; readonly FRAGMENT: "fragment"; @@ -16,6 +22,19 @@ export declare const NodeUpdateType: { readonly RENDER: "render"; readonly OBJECT: "object"; }; +/** + * Data types of a node. + * + * @property {string} BOOLEAN Boolean type. + * @property {string} INTEGER Integer type. + * @property {string} FLOAT Float type. + * @property {string} VECTOR2 Two-dimensional vector type. + * @property {string} VECTOR3 Three-dimensional vector type. + * @property {string} VECTOR4 Four-dimensional vector type. + * @property {string} MATRIX2 2x2 matrix type. + * @property {string} MATRIX3 3x3 matrix type. + * @property {string} MATRIX4 4x4 matrix type. + */ export declare const NodeType: { readonly BOOLEAN: "bool"; readonly INTEGER: "int"; @@ -27,6 +46,13 @@ export declare const NodeType: { readonly MATRIX3: "mat3"; readonly MATRIX4: "mat4"; }; +/** + * Access types of a node. These are relevant for compute and storage usage. + * + * @property {string} READ_ONLY Read-only access + * @property {string} WRITE_ONLY Write-only access. + * @property {string} READ_WRITE Read and write access. + */ export declare const NodeAccess: { readonly READ_ONLY: "readOnly"; readonly WRITE_ONLY: "writeOnly";