Skip to content

Commit

Permalink
fix: Patch the ShaderNodeObject circular reference issue on `@types/t…
Browse files Browse the repository at this point in the history
  • Loading branch information
0b5vr committed Apr 8, 2024
1 parent 0b61ba1 commit 98dee38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ export class MToonAnimatedUVNode extends Nodes.TempNode {
let uvAnimationMask: Nodes.NodeRepresentation = 1.0;

if (this.hasMaskTexture) {
// @ts-expect-error The `Type of property 'cache' circularly references itself ...` error (TS2615)
uvAnimationMask = Nodes.vec4(refUVAnimationMaskTexture).context({ getUV: () => Nodes.uv() }).r;
}

// @ts-expect-error The `Type of property 'cache' circularly references itself ...` error (TS2615)
let uv: Nodes.ShaderNodeObject<Nodes.Swizzable> = Nodes.uv();

// scroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class MToonLightingModel extends Nodes.LightingModel {
const dotNL = Nodes.transformedNormalView.dot(lightDirection).clamp(-1.0, 1.0);

// toon diffuse
// @ts-expect-error The `Type of property 'cache' circularly references itself ...` error (TS2615)
const shading = getShading({
dotNL,
});
Expand Down
13 changes: 12 additions & 1 deletion patches/@types+three+0.162.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ index ef17737..0c16fe3 100644
+export const materialNormal: ShaderNodeObject<MaterialNode>;
export const materialRotation: ShaderNodeObject<MaterialNode>;
diff --git a/node_modules/@types/three/examples/jsm/nodes/shadernode/ShaderNode.d.ts b/node_modules/@types/three/examples/jsm/nodes/shadernode/ShaderNode.d.ts
index 812d23f..b7aee2e 100644
index 812d23f..e250a7a 100644
--- a/node_modules/@types/three/examples/jsm/nodes/shadernode/ShaderNode.d.ts
+++ b/node_modules/@types/three/examples/jsm/nodes/shadernode/ShaderNode.d.ts
@@ -40,6 +40,13 @@ export interface NodeElements {
Expand All @@ -38,3 +38,14 @@ index 812d23f..b7aee2e 100644
}

export function addNodeElement(name: string, nodeElement: unknown): void;
@@ -53,8 +60,8 @@ export type Swizzable<T extends Node = Node> =
export type ShaderNodeObject<T extends Node> =
& T
& {
- [Key in keyof NodeElements]: NodeElements[Key] extends (node: T, ...args: infer Args) => infer R
- ? (...args: Args) => R
+ [Key in keyof NodeElements]: T extends { [K in Key]: infer M } ? M
+ : NodeElements[Key] extends (node: T, ...args: infer Args) => infer R ? (...args: Args) => R
: never;
}
& Swizzable<T>;

0 comments on commit 98dee38

Please sign in to comment.