[PR #8656] [MERGED] feat(avatars): rigged GLB and FBX models for 3D Avatars #8728

Closed
opened 2026-11-07 17:39:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8656
Author: @SpicyMarinara
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/avatar-glb-fbx-8620


📝 Commits (2)

  • 2da21e9 feat(avatars): rigged GLB and FBX models for 3D Avatars, auto-mapped onto the humanoid rig (#8620)
  • 26846e2 fix(avatars): removing a GLB or FBX model clears an earlier import refusal (#8620)

📊 Changes

28 files changed (+2410 additions, -81 deletions)

View changed files

📝 docs/agents/avatars.md (+14 -4)
📝 docs/agents/built-in-agents.md (+2 -1)
➕ e2e/avatar-glb-fbx.e2e.ts (+268 -0)
📝 packages/client/src/components/chat/AvatarLayoutSettings.tsx (+2 -1)
📝 packages/client/src/features/avatars/contract.ts (+2 -0)
➕ packages/client/src/features/avatars/renderers/glb-fbx/GlbFbxSetupPanel.tsx (+146 -0)
➕ packages/client/src/features/avatars/renderers/glb-fbx/glb-fbx-renderer.ts (+213 -0)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts (+96 -30)
📝 packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx (+1 -0)
📝 packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx (+2 -1)
📝 packages/client/src/features/avatars/stage/AvatarStage.tsx (+2 -1)
📝 packages/client/src/localization/locales/en.json (+16 -0)
📝 packages/server/src/db/file-backed-store.ts (+3 -1)
📝 packages/server/src/routes/avatar-models.routes.ts (+9 -2)
➕ packages/server/src/services/avatars/formats/glb-fbx.ts (+316 -0)
📝 packages/server/src/services/avatars/formats/registry.ts (+3 -0)
📝 packages/server/src/services/avatars/formats/vrm.ts (+62 -32)
📝 packages/server/src/services/avatars/storage.ts (+1 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/schemas/avatars.schema.ts (+15 -0)

...and 8 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8620

Why this change

  • The 3D Avatars agent only accepted VRM and MMD models. Most rigged characters people already have come as a plain .glb or .fbx: Mixamo, Ready Player Me, VRoid FBX exports, Unity and Unreal exports. These were refused as "a plain 3D model, not a VRM". The maintainer chose this scope for #8620: GLB and FBX, with common rig naming auto-mapped onto the existing humanoid layer, morph-target faces when present, and a clear message for rigs that can't be mapped. No Xnalara, bone editor, pose editor or rendering presets.

What changed

  • New avatar kind glb-fbx.
  • Bone matching (shared avatar-humanoid-bones.ts).
    • matchAvatarHumanoidBones maps common rig names onto the humanoid bones: mixamorig:Hips, mixamorigHips, Armature|hips, J_Bip_C_Hips, upper_arm.L, Bip01 L UpperArm, upperarm_l, Character1_LeftArm, CC_Base_L_Upperarm, lShldrBend, ValveBiped.Bip01_Head1.
    • It skips helper, twist, finger and end bones.
    • It refuses a rig missing hips, spine, head or an upper or lower arm, and the message names the missing bones.
    • pairedAvatarMorphNames gives left/right blend shapes one name, so eyeBlinkLeft and eyeBlinkRight blink together.
  • Importer (formats/glb-fbx.ts).
    • GLB reuses the VRM importer's checks for GLB JSON, compression, external files and the scene.
    • FBX reads object names from binary or ASCII FBX 7.0 and newer. Both scans are bounded, so a hostile file can't block the server.
    • Faces and mouth shapes bind to blend shapes: VRM names, Oculus visemes (viseme_aa), VRoid Fcl_*, ARKit (eyeBlink) and looser fallbacks.
    • Refused in plain words: a VRM saved as .glb, an unmappable rig, an FBX older than 7.0, and a mislabelled file. It warns when an FBX's textures aren't embedded.
  • Renderer.
    • vrm-renderer.ts now takes a model source instead of being VRM-only.
    • The new glb-fbx-renderer.ts loads the file with GLTFLoader or FBXLoader and builds three-vrm's humanoid and expressions from the stored bones. The existing idle and emotion poses, blinking and lip-sync therefore apply unchanged.
    • It straightens A-pose arms, turns a model that faces away, scales centimetre rigs and centres the model.
    • FBXLoader lands in vendor-three. The renderer is a 3.4 kB lazy chunk.
  • Setup panel. GlbFbxSetupPanel shows "GLB model: N of 22 body bones matched." plus the face and mouth bindings. An import refusal stays on the page as an alert, and removing the model clears it.
  • Upload, serving and kinds. Imports and file serving work like VRM and MMD. The route checks the content type of glb-fbx/ files from their first bytes. isAvatar3dKind() replaces three kind === "vrm" || kind === "mmd" checks. 16 new English keys in en.json.
  • Storage format 9 → 10 (storage-format.json and STORAGE_VERSION). Without it, a format-9 build would reject the new kind and could overwrite that owner's avatar.json. This follows the MMD (8) and format-9 precedents. Please check that no other open branch bumps the format too.
  • Docs. docs/agents/avatars.md gets a new "GLB and FBX avatars" section, and the setup steps, intro and "What to avoid when exporting" are updated. docs/agents/built-in-agents.md is updated too.
  • Tests.
    • New scripts/regressions/avatar-glb-fbx.regression.ts covers bone matching across naming schemes, unmappable rigs, blend shape pairing, both importers and their refusals, hostile FBX inputs, the import route, and loading and posing in Node.
    • New e2e/avatar-glb-fbx.e2e.ts imports a generated GLB on a real server and checks that the preview draws in the model's colours, moves and talks, and that a rig with unmatched bones is refused inline.
    • avatar-stage-logic, avatar-mmd-client and avatar-models now know the new kind.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What the agent ran locally:

  • After rebasing on staging, node ./scripts/pnpm-runner.mjs check, localization:check and check:e2e-types all pass.
  • All 25 avatar regressions pass, and so do the 9 launcher regressions (including the format guard: storage-format.json equals STORAGE_VERSION 10) and message-sharding.
  • The e2e specs avatar-glb-fbx and avatar-vrm, plus the other avatar specs, pass 8/8 on desktop Chromium. The VRM spec covers the renderer refactor.
  • An independent review agent bounded both FBX scans, which a hostile file could use to block the event loop, and fixed a stale docs bullet. Local CodeRabbit raised the refusal that stayed after removal, which is fixed.

To verify by hand:

  • Manually verify that a real Mixamo FBX (downloaded with skin, in T-pose) imports in Agents → 3D Avatars → GLB or FBX model, and that the preview shows its textures, breathes, blinks and lowers its arms. No real skinned FBX has been rendered in a browser yet: the FBX fixture is a skeleton without a mesh.
  • Manually verify a Ready Player Me (or other ARKit/Oculus) GLB: the mouth should move with Talk, and both eyes should blink together.
  • Manually verify a VRoid-exported FBX or GLB: faces and mouth should bind automatically and the model should face the camera.
  • Manually verify that an A-pose model rests with its arms at its sides.
  • Manually verify that an unrigged or oddly named model shows the inline refusal naming the missing bones, and that removing a model clears it.
  • Manually verify a GLB/FBX avatar in a Roleplay chat and a Game chat with the 3D Avatars agent on: framing (portrait, half-body, full body), lip sync while streaming and with TTS, and faces from the reply.
  • Manually verify the setup panel and preview at phone width.

Known limits (outside the chosen scope):

  • Embedded TGA/DDS textures in an FBX load as placeholders.
  • A model's own embedded animations and .vrma idles aren't used.
  • A Rigify DEF-only rig is refused, with the missing-bones message.
  • Sketchfab _NN spine suffixes leave chest and upper chest unmatched (less upper-body motion).
  • A model facing sideways is caught only in the browser.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/agents/avatars.md and docs/agents/built-in-agents.md changed. A [docs-i18n] follow-up issue is opened for the translated packs. The Marinara-Agents 3d-avatars package needs no code change, but its description still says "Uses VRM model files", so that copy is updated in a separate Agents PR.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8656 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/avatar-glb-fbx-8620` --- ### 📝 Commits (2) - [`2da21e9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2da21e9d34013f5b4e4594dc5d08f39d7926e652) feat(avatars): rigged GLB and FBX models for 3D Avatars, auto-mapped onto the humanoid rig (#8620) - [`26846e2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26846e2d3dd0c2e3057a58612ca7f94dc6d3b5f1) fix(avatars): removing a GLB or FBX model clears an earlier import refusal (#8620) ### 📊 Changes **28 files changed** (+2410 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+14 -4) 📝 `docs/agents/built-in-agents.md` (+2 -1) ➕ `e2e/avatar-glb-fbx.e2e.ts` (+268 -0) 📝 `packages/client/src/components/chat/AvatarLayoutSettings.tsx` (+2 -1) 📝 `packages/client/src/features/avatars/contract.ts` (+2 -0) ➕ `packages/client/src/features/avatars/renderers/glb-fbx/GlbFbxSetupPanel.tsx` (+146 -0) ➕ `packages/client/src/features/avatars/renderers/glb-fbx/glb-fbx-renderer.ts` (+213 -0) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts` (+96 -30) 📝 `packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx` (+1 -0) 📝 `packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx` (+2 -1) 📝 `packages/client/src/features/avatars/stage/AvatarStage.tsx` (+2 -1) 📝 `packages/client/src/localization/locales/en.json` (+16 -0) 📝 `packages/server/src/db/file-backed-store.ts` (+3 -1) 📝 `packages/server/src/routes/avatar-models.routes.ts` (+9 -2) ➕ `packages/server/src/services/avatars/formats/glb-fbx.ts` (+316 -0) 📝 `packages/server/src/services/avatars/formats/registry.ts` (+3 -0) 📝 `packages/server/src/services/avatars/formats/vrm.ts` (+62 -32) 📝 `packages/server/src/services/avatars/storage.ts` (+1 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/schemas/avatars.schema.ts` (+15 -0) _...and 8 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #8620 ## Why this change - The 3D Avatars agent only accepted VRM and MMD models. Most rigged characters people already have come as a plain `.glb` or `.fbx`: Mixamo, Ready Player Me, VRoid FBX exports, Unity and Unreal exports. These were refused as "a plain 3D model, not a VRM". The maintainer chose this scope for #8620: GLB and FBX, with common rig naming auto-mapped onto the existing humanoid layer, morph-target faces when present, and a clear message for rigs that can't be mapped. No Xnalara, bone editor, pose editor or rendering presets. ## What changed - **New avatar kind `glb-fbx`.** - **Bone matching (shared `avatar-humanoid-bones.ts`).** - `matchAvatarHumanoidBones` maps common rig names onto the humanoid bones: `mixamorig:Hips`, `mixamorigHips`, `Armature|hips`, `J_Bip_C_Hips`, `upper_arm.L`, `Bip01 L UpperArm`, `upperarm_l`, `Character1_LeftArm`, `CC_Base_L_Upperarm`, `lShldrBend`, `ValveBiped.Bip01_Head1`. - It skips helper, twist, finger and end bones. - It refuses a rig missing hips, spine, head or an upper or lower arm, and the message names the missing bones. - `pairedAvatarMorphNames` gives left/right blend shapes one name, so `eyeBlinkLeft` and `eyeBlinkRight` blink together. - **Importer (`formats/glb-fbx.ts`).** - GLB reuses the VRM importer's checks for GLB JSON, compression, external files and the scene. - FBX reads object names from binary or ASCII FBX 7.0 and newer. Both scans are bounded, so a hostile file can't block the server. - Faces and mouth shapes bind to blend shapes: VRM names, Oculus visemes (`viseme_aa`), VRoid `Fcl_*`, ARKit (`eyeBlink`) and looser fallbacks. - Refused in plain words: a VRM saved as `.glb`, an unmappable rig, an FBX older than 7.0, and a mislabelled file. It warns when an FBX's textures aren't embedded. - **Renderer.** - `vrm-renderer.ts` now takes a model source instead of being VRM-only. - The new `glb-fbx-renderer.ts` loads the file with GLTFLoader or FBXLoader and builds three-vrm's humanoid and expressions from the stored bones. The existing idle and emotion poses, blinking and lip-sync therefore apply unchanged. - It straightens A-pose arms, turns a model that faces away, scales centimetre rigs and centres the model. - FBXLoader lands in `vendor-three`. The renderer is a 3.4 kB lazy chunk. - **Setup panel.** `GlbFbxSetupPanel` shows "GLB model: N of 22 body bones matched." plus the face and mouth bindings. An import refusal stays on the page as an alert, and removing the model clears it. - **Upload, serving and kinds.** Imports and file serving work like VRM and MMD. The route checks the content type of `glb-fbx/` files from their first bytes. `isAvatar3dKind()` replaces three `kind === "vrm" || kind === "mmd"` checks. 16 new English keys in `en.json`. - **Storage format 9 → 10** (`storage-format.json` and `STORAGE_VERSION`). Without it, a format-9 build would reject the new kind and could overwrite that owner's `avatar.json`. This follows the MMD (8) and format-9 precedents. **Please check that no other open branch bumps the format too.** - **Docs.** `docs/agents/avatars.md` gets a new "GLB and FBX avatars" section, and the setup steps, intro and "What to avoid when exporting" are updated. `docs/agents/built-in-agents.md` is updated too. - **Tests.** - New `scripts/regressions/avatar-glb-fbx.regression.ts` covers bone matching across naming schemes, unmappable rigs, blend shape pairing, both importers and their refusals, hostile FBX inputs, the import route, and loading and posing in Node. - New `e2e/avatar-glb-fbx.e2e.ts` imports a generated GLB on a real server and checks that the preview draws in the model's colours, moves and talks, and that a rig with unmatched bones is refused inline. - `avatar-stage-logic`, `avatar-mmd-client` and `avatar-models` now know the new kind. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What the agent ran locally: - After rebasing on staging, `node ./scripts/pnpm-runner.mjs check`, `localization:check` and `check:e2e-types` all pass. - All 25 `avatar` regressions pass, and so do the 9 `launcher` regressions (including the format guard: `storage-format.json` equals `STORAGE_VERSION` 10) and `message-sharding`. - The e2e specs `avatar-glb-fbx` and `avatar-vrm`, plus the other avatar specs, pass 8/8 on desktop Chromium. The VRM spec covers the renderer refactor. - An independent review agent bounded both FBX scans, which a hostile file could use to block the event loop, and fixed a stale docs bullet. Local CodeRabbit raised the refusal that stayed after removal, which is fixed. To verify by hand: - Manually verify that a real Mixamo FBX (downloaded with skin, in T-pose) imports in Agents → 3D Avatars → GLB or FBX model, and that the preview shows its textures, breathes, blinks and lowers its arms. No real skinned FBX has been rendered in a browser yet: the FBX fixture is a skeleton without a mesh. - Manually verify a Ready Player Me (or other ARKit/Oculus) GLB: the mouth should move with Talk, and both eyes should blink together. - Manually verify a VRoid-exported FBX or GLB: faces and mouth should bind automatically and the model should face the camera. - Manually verify that an A-pose model rests with its arms at its sides. - Manually verify that an unrigged or oddly named model shows the inline refusal naming the missing bones, and that removing a model clears it. - Manually verify a GLB/FBX avatar in a Roleplay chat and a Game chat with the 3D Avatars agent on: framing (portrait, half-body, full body), lip sync while streaming and with TTS, and faces from the reply. - Manually verify the setup panel and preview at phone width. **Known limits (outside the chosen scope):** - Embedded TGA/DDS textures in an FBX load as placeholders. - A model's own embedded animations and `.vrma` idles aren't used. - A Rigify DEF-only rig is refused, with the missing-bones message. - Sketchfab `_NN` spine suffixes leave chest and upper chest unmatched (less upper-body motion). - A model facing sideways is caught only in the browser. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/agents/avatars.md` and `docs/agents/built-in-agents.md` changed. A `[docs-i18n]` follow-up issue is opened for the translated packs. The Marinara-Agents `3d-avatars` package needs no code change, but its description still says "Uses VRM model files", so that copy is updated in a separate Agents PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:17 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8728
No description provided.