Skip to content

Commit

Permalink
Update declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 committed Dec 15, 2024
1 parent 9e746e9 commit 9a74766
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
13 changes: 13 additions & 0 deletions types/three/src/nodes/core/NodeAttribute.d.ts
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions types/three/src/nodes/core/NodeVar.d.ts
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 14 additions & 0 deletions types/three/src/nodes/core/NodeVarying.d.ts
Original file line number Diff line number Diff line change
@@ -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;
35 changes: 35 additions & 0 deletions types/three/src/nodes/core/UniformNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TValue> extends InputNode<TValue> {
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;
Expand Down
26 changes: 26 additions & 0 deletions types/three/src/nodes/core/constants.d.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down

0 comments on commit 9a74766

Please sign in to comment.