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

hotfix vrm0 data not being where we expect it #10236

Merged
merged 4 commits into from
May 24, 2024
Merged
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
21 changes: 11 additions & 10 deletions packages/engine/src/avatar/functions/avatarFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,30 @@ declare module '@pixiv/three-vrm/types/VRM' {
export const autoconvertMixamoAvatar = (model: GLTF | VRM) => {
const scene = model.scene ?? model // FBX assets do not have 'scene' property
if (!scene) return null!

//vrm1's vrm object is in the userData property
let foundModel = model
//sometimes, for some exporters, the vrm object is stored in the userData
if (model.userData?.vrm instanceof VRM) {
return model.userData.vrm
if (model.userData.vrmMeta.metaVersion > 0) return model.userData.vrm
foundModel = model.userData.vrm
}

//vrm0 is an instance of the vrm object
if (model instanceof VRM) {
const bones = model.humanoid.rawHumanBones
model.humanoid.normalizedHumanBonesRoot.removeFromParent()
if (foundModel instanceof VRM) {
const bones = foundModel.humanoid.rawHumanBones
foundModel.humanoid.normalizedHumanBonesRoot.removeFromParent()
bones.hips.node.rotateY(Math.PI)
const humanoid = new VRMHumanoid(bones)
const vrm = new VRM({
...model,
...foundModel,
humanoid,
scene: model.scene,
meta: { name: model.scene.children[0].name } as VRM1Meta
scene: foundModel.scene,
meta: { name: foundModel.scene.children[0].name } as VRM1Meta
})
if (!vrm.userData) vrm.userData = {}
return vrm
}

return avatarBoneMatching(model)
return avatarBoneMatching(foundModel)
}

export const isAvaturn = (url: string) => {
Expand Down
Loading