Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nodes storage types #931

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/three/examples/jsm/nodes/accessors/BufferNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { NodeTypeOption } from "../core/constants.js";
import UniformNode from "../core/UniformNode.js";
import { NodeOrType, ShaderNodeObject } from "../shadernode/ShaderNode.js";

export default class BufferNode extends UniformNode<ArrayLike<number> | null> {
export default class BufferNode extends UniformNode<unknown> {
isBufferNode: true;

bufferType: string;
bufferCount: number;

constructor(value: ArrayLike<number> | null, bufferType: NodeTypeOption, bufferCount?: number);
constructor(value: unknown, bufferType: NodeTypeOption, bufferCount?: number);
}

export const buffer: (
value: ArrayLike<number> | null,
value: unknown,
nodeOrType: NodeOrType,
count: number,
) => ShaderNodeObject<BufferNode>;
12 changes: 9 additions & 3 deletions types/three/examples/jsm/nodes/accessors/StorageBufferNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import StorageBufferAttribute from "../../renderers/common/StorageBufferAttribute.js";
import StorageInstancedBufferAttribute from "../../renderers/common/StorageInstancedBufferAttribute.js";
import { NodeTypeOption } from "../core/constants.js";
import { NodeOrType, NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js";
import StorageArrayElementNode from "../utils/StoargeArrayElementNode.js";
Expand All @@ -7,20 +9,24 @@ export default class StorageBufferNode extends BufferNode {
readonly isStorageBufferNode: true;
bufferObject: boolean;

constructor(value: ArrayLike<number>, bufferType: NodeTypeOption, bufferCount?: number);
constructor(
value: StorageBufferAttribute | StorageInstancedBufferAttribute,
bufferType: NodeTypeOption,
bufferCount?: number,
);

element(indexNode: NodeRepresentation): ShaderNodeObject<StorageArrayElementNode>;

setBufferObject(value: boolean): this;
}

export const storage: (
value: ArrayLike<number>,
value: StorageBufferAttribute | StorageInstancedBufferAttribute,
nodeOrType: NodeOrType,
count: number,
) => ShaderNodeObject<StorageBufferNode>;
export const storageObject: (
value: ArrayLike<number>,
value: StorageBufferAttribute | StorageInstancedBufferAttribute,
nodeOrType: NodeOrType,
count: number,
) => ShaderNodeObject<StorageBufferNode>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BufferAttribute, TypedArray } from "three";

export default class StorageBufferAttribute extends BufferAttribute {
readonly isStorageBufferAttribute: true;

constructor(array: TypedArray, itemSize: number);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { InstancedBufferAttribute, TypedArray } from "three";

export default class StorageInstancedBufferAttribute extends InstancedBufferAttribute {
readonly isStorageInstancedBufferAttribute: true;

constructor(array: TypedArray | number, itemSize: number);
}
2 changes: 0 additions & 2 deletions types/three/test/integration/nodes-webgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { HemisphereLight, Object3D, PointLight, WebGLRenderer } from "three";
import StorageBufferNode from "three/addons/nodes/accessors/StorageBufferNode.js";
import * as NodeUtils from "three/addons/nodes/core/NodeUtils.js";
import * as Nodes from "three/addons/nodes/Nodes.js";
import SlotNode from "three/addons/renderers/webgl/nodes/SlotNode.js";
Expand All @@ -12,7 +11,6 @@ import { nodeFrame } from "three/addons/renderers/webgl/nodes/WebGLNodes.js";

nodeFrame.update();
new WebGLNodeBuilder(new Object3D(), new WebGLRenderer(), { uniforms: [], vertexShader: [], fragmentShader: [] });
new StorageBufferNode([], "float");
new SlotNode({
node: new Nodes.ConstNode(1),
nodeType: "float",
Expand Down
Loading