From 75f4798ac19a6131282e2596bbef13d3703fd737 Mon Sep 17 00:00:00 2001 From: 0b5vr <0b5vr@0b5vr.com> Date: Thu, 15 Feb 2024 19:09:23 +0900 Subject: [PATCH 1/2] fix: Fix type definition of VRM Animation - Humanoid is optional - Properties of HumanoidHumanBones are optional - Some bones are required but that would be handled in the implementation side - I also fixed the `VRMC_vrm` one See: https://github.com/vrm-c/vrm-specification/blob/2d40293a5aa21f1a5011d7a53074056bd31cbad3/specification/VRMC_vrm_animation-1.0/schema/VRMC_vrm_animation.schema.json See: https://github.com/vrm-c/vrm-specification/blob/2d40293a5aa21f1a5011d7a53074056bd31cbad3/specification/VRMC_vrm_animation-1.0/schema/VRMC_vrm_animation.humanoid.humanBones.schema.json --- packages/types-vrmc-vrm-1.0/src/HumanoidHumanBones.ts | 2 +- packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBones.ts | 2 +- packages/types-vrmc-vrm-animation-1.0/src/VRMCVRMAnimation.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/types-vrmc-vrm-1.0/src/HumanoidHumanBones.ts b/packages/types-vrmc-vrm-1.0/src/HumanoidHumanBones.ts index 540b1bf8e..eacccfc13 100644 --- a/packages/types-vrmc-vrm-1.0/src/HumanoidHumanBones.ts +++ b/packages/types-vrmc-vrm-1.0/src/HumanoidHumanBones.ts @@ -5,5 +5,5 @@ import type { HumanoidHumanBoneName } from './HumanoidHumanBoneName'; * Represents a set of humanBones of a humanoid. */ export type HumanoidHumanBones = { - [key in HumanoidHumanBoneName]: HumanoidHumanBone; + [key in HumanoidHumanBoneName]?: HumanoidHumanBone; }; diff --git a/packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBones.ts b/packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBones.ts index c6ffdc0bc..00f67baaa 100644 --- a/packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBones.ts +++ b/packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBones.ts @@ -5,5 +5,5 @@ import type { HumanoidHumanBoneName } from '@pixiv/types-vrmc-vrm-1.0'; * An object which maps humanoid bones to nodes. */ export type HumanoidHumanBones = { - [key in HumanoidHumanBoneName]: HumanoidHumanBone; + [key in HumanoidHumanBoneName]?: HumanoidHumanBone; }; diff --git a/packages/types-vrmc-vrm-animation-1.0/src/VRMCVRMAnimation.ts b/packages/types-vrmc-vrm-animation-1.0/src/VRMCVRMAnimation.ts index 7f9f6fa9e..0cef4fc38 100644 --- a/packages/types-vrmc-vrm-animation-1.0/src/VRMCVRMAnimation.ts +++ b/packages/types-vrmc-vrm-animation-1.0/src/VRMCVRMAnimation.ts @@ -14,7 +14,7 @@ export interface VRMCVRMAnimation { /** * An object which describes about humanoid bones. */ - humanoid: Humanoid; + humanoid?: Humanoid; /** * An object which maps expressions to nodes. From 7cfbffd8d6260aad73b32d0bf358652654c9090c Mon Sep 17 00:00:00 2001 From: 0b5vr <0b5vr@0b5vr.com> Date: Mon, 26 Feb 2024 18:11:49 +0900 Subject: [PATCH 2/2] fix: Fix an error of VRMAnimationLoaderPlugin it attempts to use humanoid even when it doesn't exist --- packages/three-vrm-animation/src/VRMAnimationLoaderPlugin.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/three-vrm-animation/src/VRMAnimationLoaderPlugin.ts b/packages/three-vrm-animation/src/VRMAnimationLoaderPlugin.ts index c498fa7e0..b1236b818 100644 --- a/packages/three-vrm-animation/src/VRMAnimationLoaderPlugin.ts +++ b/packages/three-vrm-animation/src/VRMAnimationLoaderPlugin.ts @@ -144,6 +144,10 @@ export class VRMAnimationLoaderPlugin implements GLTFLoaderPlugin { const worldMatrixMap: VRMAnimationLoaderPluginWorldMatrixMap = new Map(); + if (defExtension.humanoid == null) { + return worldMatrixMap; + } + for (const [boneName, humanBone] of Object.entries(defExtension.humanoid.humanBones)) { const node = humanBone?.node; if (node != null) {