Skip to content

Commit

Permalink
Nodes: Introduce static type (#1234)
Browse files Browse the repository at this point in the history
* Nodes: Introduce static type

* Update three.js

* Add src

* Update patch and delete src

* Update declarations
  • Loading branch information
Methuselah96 committed Sep 22, 2024
1 parent 67eb185 commit 8335485
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 159 deletions.
287 changes: 144 additions & 143 deletions src-testing/changes.patch

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 166 files
2 changes: 2 additions & 0 deletions types/three/src/loaders/MaterialLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ export class MaterialLoader extends Loader<Material> {

setTextures(textures: { [key: string]: Texture }): this;

createMaterialFromType(type: string): Material;

static createMaterialFromType(type: string): Material;
}
5 changes: 5 additions & 0 deletions types/three/src/loaders/nodes/NodeLoader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ export interface NodeLoaderResult {
}

export default class NodeLoader extends Loader<NodeLoaderResult> {
textures: { [key: string]: Texture };
nodes: { [type: string]: Node };

constructor(manager?: LoadingManager);

parseNodes(json: unknown): NodeLoaderResult;
parse(json: unknown): Node;
setTextures(textures: { [key: string]: Texture }): this;
setNodes(value: { [type: string]: Node }): this;
createNodeFromType(type: string): Node;
}
3 changes: 3 additions & 0 deletions types/three/src/loaders/nodes/NodeMaterialLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import NodeMaterial from "../../materials/nodes/NodeMaterial.js";
import { MaterialLoader } from "../MaterialLoader.js";
import { NodeLoaderResult } from "./NodeLoader.js";

export default class NodeMaterialLoader extends MaterialLoader {
nodes: NodeLoaderResult;
nodeMaterials: { [type: string]: NodeMaterial };

setNodes(value: NodeLoaderResult): this;
setNodeMaterials(value: { [type: string]: NodeMaterial }): this;
}
12 changes: 12 additions & 0 deletions types/three/src/loaders/nodes/NodeObjectLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { Material } from "../../materials/Material.js";
import NodeMaterial from "../../materials/nodes/NodeMaterial.js";
import { Node } from "../../nodes/Nodes.js";
import { Texture } from "../../textures/Texture.js";
import { LoadingManager } from "../LoadingManager.js";
import { ObjectLoader } from "../ObjectLoader.js";
import { NodeLoaderResult } from "./NodeLoader.js";

export default class NodeObjectLoader extends ObjectLoader {
nodes: { [type: string]: Node };
nodeMaterials: { [type: string]: NodeMaterial };

constructor(manager?: LoadingManager);

setNodes(value: { [type: string]: Node }): this;

setNodeMaterials(value: { [type: string]: NodeMaterial }): this;

parseNodes(json: unknown, textures: { [key: string]: Texture }): NodeLoaderResult;

parseMaterials(json: unknown, textures: { [key: string]: Texture }): { [key: string]: Material };
Expand Down
6 changes: 2 additions & 4 deletions types/three/src/materials/nodes/NodeMaterial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface NodeMaterialParameters extends MaterialParameters {
}

declare class NodeMaterial extends Material {
static get type(): string;

readonly isNodeMaterial: true;

fog: boolean;
Expand Down Expand Up @@ -85,7 +87,3 @@ declare class NodeMaterial extends Material {
}

export default NodeMaterial;

export function registerNodeMaterial(type: string, nodeMaterialClass: { new(): NodeMaterial }): string;

export function createNodeMaterialFromType(type: string): NodeMaterial;
2 changes: 1 addition & 1 deletion types/three/src/nodes/Nodes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export {
LightingModelReflectedLight,
} from "./core/LightingModel.js";
export { default as MRTNode } from "./core/MRTNode.js";
export { default as Node, NodeJSONInputData, NodeJSONIntermediateOutputData, registerNode } from "./core/Node.js";
export { default as Node, NodeJSONInputData, NodeJSONIntermediateOutputData } from "./core/Node.js";
export { default as NodeAttribute } from "./core/NodeAttribute.js";
export {
BuildStageOption,
Expand Down
1 change: 1 addition & 0 deletions types/three/src/nodes/accessors/BufferAttributeNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { InterleavedBufferAttribute } from "../../core/InterleavedBufferAttribut
import InputNode from "../core/InputNode.js";
import NodeBuilder from "../core/NodeBuilder.js";
declare class BufferAttributeNode extends InputNode<TypedArray | InterleavedBuffer | BufferAttribute> {
static get type(): string;
readonly isBufferNode: true;
bufferType: string | null;
bufferStride: number;
Expand Down
11 changes: 1 addition & 10 deletions types/three/src/nodes/core/Node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface NodeJSONOutputData {
declare class Node extends EventDispatcher<{
dispose: {};
}> {
static get type(): string;
nodeType: string | null;
updateType: NodeUpdateType;
updateBeforeType: NodeUpdateType;
Expand Down Expand Up @@ -108,13 +109,3 @@ declare class Node extends EventDispatcher<{
toJSON(meta?: NodeJSONMeta | string): NodeJSONOutputData;
}
export default Node;
export declare function registerNode(type: string, nodeClass: {
new(...args: any[]): Node;
}): string | undefined;
export declare function createNodeFromType(type: string): Node | undefined;
/**
* @deprecated Function addNodeClass() is deprecated. Use registerNodeClass() instead.
*/
export declare function addNodeClass(type: string, nodeClass: {
new(...args: any[]): Node;
}): void;
1 change: 1 addition & 0 deletions types/three/src/nodes/core/StructTypeNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Node from "./Node.js";
declare class StructTypeNode extends Node {
static get type(): string;
types: string[];
readonly isStructTypeNode: true;
constructor(types: string[]);
Expand Down
1 change: 1 addition & 0 deletions types/three/src/nodes/core/UniformNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NodeBuilder from "./NodeBuilder.js";
import NodeFrame from "./NodeFrame.js";
import UniformGroupNode from "./UniformGroupNode.js";
declare class UniformNode<TValue> extends InputNode<TValue> {
static get type(): string;
readonly isUniformNode: true;
name: string;
groupNode: UniformGroupNode;
Expand Down

0 comments on commit 8335485

Please sign in to comment.