From 5decd5ff309bd1cb715b360198be56bb494badc9 Mon Sep 17 00:00:00 2001 From: 0b5vr <0b5vr@0b5vr.com> Date: Thu, 5 Sep 2024 16:10:24 +0900 Subject: [PATCH] fix: Fix type error of MToonNodeMaterial The return type should be matched to the super class (NodeMaterial) --- .../src/nodes/MToonNodeMaterial.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/three-vrm-materials-mtoon/src/nodes/MToonNodeMaterial.ts b/packages/three-vrm-materials-mtoon/src/nodes/MToonNodeMaterial.ts index eefceba7a..cbdd8c1fe 100644 --- a/packages/three-vrm-materials-mtoon/src/nodes/MToonNodeMaterial.ts +++ b/packages/three-vrm-materials-mtoon/src/nodes/MToonNodeMaterial.ts @@ -252,7 +252,7 @@ export class MToonNodeMaterial extends THREE.NodeMaterial { parametricRim.assign(this._setupParametricRimNode()); } - public setupNormal(builder: THREE.NodeBuilder): THREE.ShaderNodeObject | null | undefined { + public setupNormal(builder: THREE.NodeBuilder): THREE.ShaderNodeObject { // we must apply uv scroll to the normalMap // this.normalNode will be used in super.setupNormal() so we temporarily replace it const tempNormalNode = this.normalNode; @@ -276,7 +276,7 @@ export class MToonNodeMaterial extends THREE.NodeMaterial { // See: https://github.com/mrdoob/three.js/pull/29137 const threeRevision = parseInt(THREE.REVISION, 10); if (threeRevision >= 168) { - const ret = this.normalNode as THREE.ShaderNodeObject | null; + const ret = this.normalNode as THREE.ShaderNodeObject; // revert the normalNode this.normalNode = tempNormalNode; @@ -289,6 +289,10 @@ export class MToonNodeMaterial extends THREE.NodeMaterial { // revert the normalNode this.normalNode = tempNormalNode; + + // type workaround: pretend to return a valid value + // r167 doesn't use the return value anyway + return undefined as any; } }