[PR #8481] [MERGED] feat(avatars): support PMX models and VMD motions #8628

Closed
opened 2026-11-07 16:46:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8481
Author: @SpicyMarinara
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/8473-mmd-pmx-avatars


📝 Commits (10+)

  • e6196bb test(avatars): reproduce missing PMX and VMD imports
  • 4398681 feat(avatars): import and animate MMD PMX avatars
  • 34c86b7 fix(avatars): bound MMD setup and keep its clock on demand
  • b033145 fix(avatars): protect MMD data from incompatible downgrades
  • 1ef9d02 test(avatars): exercise PMX and VRM production chunks
  • 116fcda test(avatars): isolate production MMD fixtures from service workers
  • 2edf709 fix(storage): refuse unidentified shard downgrades before writes
  • ddcb3d3 Merge remote-tracking branch 'origin/staging' into feat/8473-mmd-pmx-avatars
  • 8b3ba7d test(avatars): change themes through canonical UI controls
  • d11599d fix(avatars): repair MMD blinking, shared draws and Finder ZIPs

📊 Changes

37 files changed (+3414 additions, -167 deletions)

View changed files

📝 docs/TROUBLESHOOTING.md (+3 -1)
📝 docs/UPGRADING.md (+4 -2)
📝 docs/agents/avatars.md (+14 -2)
➕ e2e/avatar-mmd.e2e.ts (+621 -0)
📝 e2e/avatar-vrm.e2e.ts (+1 -1)
📝 e2e/server-csp-fixture.ts (+11 -2)
📝 packages/client/package.json (+2 -0)
📝 packages/client/src/components/chat/AvatarLayoutSettings.tsx (+1 -1)
📝 packages/client/src/features/avatars/contract.ts (+2 -0)
➕ packages/client/src/features/avatars/renderers/mmd/MmdSetupPanel.tsx (+143 -0)
➕ packages/client/src/features/avatars/renderers/mmd/mmd-renderer.ts (+468 -0)
📝 packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx (+10 -126)
📝 packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx (+1 -0)
📝 packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx (+1 -1)
➕ packages/client/src/features/avatars/setup/ModelSetupControls.tsx (+133 -0)
📝 packages/client/src/features/avatars/stage/AvatarStage.tsx (+1 -1)
📝 packages/client/src/localization/locales/en.json (+22 -0)
📝 packages/client/vite.config.ts (+21 -4)
📝 packages/server/package.json (+1 -0)
📝 packages/server/src/db/file-backed-store.ts (+3 -1)

...and 17 more files

📄 Description

Linked issue

Closes #8473

Why this change

3D Avatars previously accepted VRM only. MMD users need to import a PMX model with local textures, map its expressions, and optionally play a compatible VMD motion without an AI service.

What changed

  • Advances storage format 7 to 8 because released format-7 hosts reject the additive MMD avatar configuration. An upgraded data folder cannot be reopened on format-7 or older builds. To roll back, restore a full pre-upgrade backup; editing format metadata or unsharding does not convert MMD settings.
  • Adds bounded PMX/ZIP and VMD import, contained authenticated assets, character/persona setup, expression mappings and a lazy Three renderer using the existing director, framing, pause, reduced-motion and disposal paths. Native morphs remain intact; configured valid bindings outside the offered-name catalog remain usable.
  • Repairs the hosted-review defects: blink closure is rebuilt from the current eased weight; Finder-style AppleDouble metadata is skipped only after path, symlink and duplicate validation. A separately reproduced shared-viewport mismatch now copies the modern renderer's top-origin pixels, so a smaller avatar cannot inherit stale rows from a larger one.
  • Keeps the classic VRM path working. The pinned Three MMD renderer owns its stage clock; its guarded private on-demand adapter has an explicit upstream-API ceiling rather than assuming general private-API stability.
  • Refuses unidentified-format shard conversion before writes. Known formats 1–7 retain conversion; an already-unsharded legacy folder returns a truthful unchanged no-op without claiming old-host readability.
  • Adds the English avatar guide and backup-only downgrade guidance. Translations are tracked in #8483 / #8487.

PMX 2.0 and compatible 2.1 files using 2.0 records are supported. QDEF, flip/impulse morphs, new 2.1 joint types and soft bodies are rejected. Physics, PMD, VPD and camera/light animation are outside this implementation. WebGL2 is required. Setup offers at most 256 morph names; texture tables allow 256 references of up to 512 characters. Import bytes, decoded textures, morph allocations and IK work are bounded.

Validation

Repair head: d11599dc76b94aca71bd1e2772917e63de1ebbd9, including staging 1403a981. Local repair gates are complete; final-head hosted checks and Dottore re-examination remain merge gates.

  • Fresh repair checks: full pnpm check and pnpm version:check pass on the frozen repair. Both MMD regression files, avatar contract/stage/VRM/models/file-deletion, message-sharding and launcher-format suites pass (nine files). The full check ran on the frozen source and began before the commit; its client configured the previous build stamp. A subsequent supported pnpm build:client at committed d11599dc passed. Actual served client/API stamps and both renderer HTTP hashes were then verified before the final replay. No app version bump.
  • Compiled production: the matched repaired build passes 21/21, zero skips: seven each in desktop Chromium (25.0s), mobile Chromium (38.4s) and mobile WebKit (34.4s). Each group includes five MMD cases, the existing VRM case and production startup/reload. The default ZIP fixture now includes Finder-style PMX/texture/VMD metadata, so it exercises real HTTP/UI import as well as the focused importer controls.
  • Existing shell smoke: seven existing desktop cases passed unchanged on the earlier matched Lite API/Vite source harness; this is separate from the fresh compiled 21-case replay.
  • Owner/theme coverage: the final compiled matrix includes all 12 character/persona × light/dark setup rows across the three browser contexts. The earlier source-harness setup replay also passed 3/3. They retain import/mapping/motion/reload/pixel/44px assertions. Themes use the actual Settings control, with normal mobile agent re-entry. Final e2e types, formatting and whitespace checks passed.
  • Downgrade repair: the actual unshard path reproduced mutation with both missing and malformed manifests while schema-valid MMD data remained. The repaired complete launcher suite and controlled probes pass with every path/file byte unchanged on refusal. A real legacy no-op CLI exits 0 without an old-host readability claim.
  • Review: the initial review found one valid metadata-bound issue and three trivial suggestions, which were addressed. The later nine-file review emitted three findings: two duplicate major comments described the same unknown-manifest gap, and one minor identified dropped persona-light coverage. Both causes were repaired; the three-file repair review completed with zero findings. The final one-file theme-fixture review also completed with zero findings. Hosted Dottore then found two medium defects on 8b3ba7de (blink latching and Finder metadata); both were reproduced and repaired. Its viewport open question also reproduced with a fixed-frame before/after pixel mask. The substantive five-file repair review completed with zero findings; final-head hosted re-examination is pending.
  • New repair controls: blink supplied/automatic cycles reopen, disabling blink reopens, and a shared emotion target retains its eased weight. The viewport probe has an exact same-size control and exact dominant-color masks: the old crop differs at 15,968 pixels; the corrected crop differs at zero, with only seven antialias channel roundings below the tested color tolerance. The new source-browser case passes all three contexts. Finder sidecars remain unread/uncounted; unsafe/duplicate/symlink metadata, two real models/motions and sidecars-only ZIPs are still rejected.
  • Preserved the original PWA-interception, mounted-store theme-write, unnamed-control selector, mobile navigation and ENOSPC fixture/startup failures. The initial repaired compiled replay exposed a client/API build-stamp mismatch: the correct infinite update notice intercepted the phone Appearance tab. The matched client-only rebuild then required restarting the compiled API to register its new hashed assets; an inadvertently started pre-restart attempt and its missing-module trace are preserved. No runtime or fixture patch was made for these harness failures. No assertions, rows or timeouts were weakened; zero skips. The final compiled replay retained failure traces and disabled video; the earlier bounded source replay disabled both trace/video. No live or paid provider calls or third-party character assets were used.

Final repair receipts: /tmp/engine-8481-dottore-repairs-final-proof.json, /tmp/engine-8481-matched-compiled-build-proof.json, /tmp/engine-8481-dottore-repairs-coderabbit.log; compiled logs/results use /tmp/engine-8481-matched-final-{desktop,mobile-chromium,mobile-webkit}. Final phone persona-light and desktop persona-dark screenshots were visually inspected. Earlier local/storage/row proofs remain historical in /tmp/engine-8473-{final-local-proof,post-review-local-proof,staging-integration-invariant}.json. Raw failure recordings remain preserved, including verified lossless archives with per-file hashes.

  • Manually verify licensed native PMX models and VMD motions for both owner types.
  • Manually check physical-device performance, framing, touch controls, pause and reduced motion.
  • Manually compare artistic fidelity against native MMD; synthetic geometry is not native-model calibration.
  • Manually verify full pre-upgrade backup restoration.
  • Review the user guide and translated documentation follow-up.

🔄 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/8481 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/8473-mmd-pmx-avatars` --- ### 📝 Commits (10+) - [`e6196bb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e6196bb9d5968425958dbcb1cb7d8488297d2a9e) test(avatars): reproduce missing PMX and VMD imports - [`4398681`](https://github.com/Pasta-Devs/Marinara-Engine/commit/43986816149a63216bc6483f04ad5060c2a8cd68) feat(avatars): import and animate MMD PMX avatars - [`34c86b7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/34c86b79da3f3fefd607f299ffc2c78d58d605fb) fix(avatars): bound MMD setup and keep its clock on demand - [`b033145`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b0331450d98bf2483a1763efd039407b4deddad8) fix(avatars): protect MMD data from incompatible downgrades - [`1ef9d02`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ef9d024b433ce063dabfeeb2a38fb4430c2f7c6) test(avatars): exercise PMX and VRM production chunks - [`116fcda`](https://github.com/Pasta-Devs/Marinara-Engine/commit/116fcda0d62e46ca49ea1ecebe905da044daa012) test(avatars): isolate production MMD fixtures from service workers - [`2edf709`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2edf70953f83314c0dcdadf5f008c1848dcf03b6) fix(storage): refuse unidentified shard downgrades before writes - [`ddcb3d3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ddcb3d38b0dadaae61ba66cf61a08a636462b0c1) Merge remote-tracking branch 'origin/staging' into feat/8473-mmd-pmx-avatars - [`8b3ba7d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8b3ba7de10a531b0d3ccc166e74891b590034ffb) test(avatars): change themes through canonical UI controls - [`d11599d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d11599dc76b94aca71bd1e2772917e63de1ebbd9) fix(avatars): repair MMD blinking, shared draws and Finder ZIPs ### 📊 Changes **37 files changed** (+3414 additions, -167 deletions) <details> <summary>View changed files</summary> 📝 `docs/TROUBLESHOOTING.md` (+3 -1) 📝 `docs/UPGRADING.md` (+4 -2) 📝 `docs/agents/avatars.md` (+14 -2) ➕ `e2e/avatar-mmd.e2e.ts` (+621 -0) 📝 `e2e/avatar-vrm.e2e.ts` (+1 -1) 📝 `e2e/server-csp-fixture.ts` (+11 -2) 📝 `packages/client/package.json` (+2 -0) 📝 `packages/client/src/components/chat/AvatarLayoutSettings.tsx` (+1 -1) 📝 `packages/client/src/features/avatars/contract.ts` (+2 -0) ➕ `packages/client/src/features/avatars/renderers/mmd/MmdSetupPanel.tsx` (+143 -0) ➕ `packages/client/src/features/avatars/renderers/mmd/mmd-renderer.ts` (+468 -0) 📝 `packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx` (+10 -126) 📝 `packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx` (+1 -0) 📝 `packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx` (+1 -1) ➕ `packages/client/src/features/avatars/setup/ModelSetupControls.tsx` (+133 -0) 📝 `packages/client/src/features/avatars/stage/AvatarStage.tsx` (+1 -1) 📝 `packages/client/src/localization/locales/en.json` (+22 -0) 📝 `packages/client/vite.config.ts` (+21 -4) 📝 `packages/server/package.json` (+1 -0) 📝 `packages/server/src/db/file-backed-store.ts` (+3 -1) _...and 17 more files_ </details> ### 📄 Description ## Linked issue Closes #8473 ## Why this change 3D Avatars previously accepted VRM only. MMD users need to import a PMX model with local textures, map its expressions, and optionally play a compatible VMD motion without an AI service. ## What changed - Advances storage format 7 to 8 because released format-7 hosts reject the additive MMD avatar configuration. An upgraded data folder cannot be reopened on format-7 or older builds. To roll back, restore a full pre-upgrade backup; editing format metadata or unsharding does not convert MMD settings. - Adds bounded PMX/ZIP and VMD import, contained authenticated assets, character/persona setup, expression mappings and a lazy Three renderer using the existing director, framing, pause, reduced-motion and disposal paths. Native morphs remain intact; configured valid bindings outside the offered-name catalog remain usable. - Repairs the hosted-review defects: blink closure is rebuilt from the current eased weight; Finder-style AppleDouble metadata is skipped only after path, symlink and duplicate validation. A separately reproduced shared-viewport mismatch now copies the modern renderer's top-origin pixels, so a smaller avatar cannot inherit stale rows from a larger one. - Keeps the classic VRM path working. The pinned Three MMD renderer owns its stage clock; its guarded private on-demand adapter has an explicit upstream-API ceiling rather than assuming general private-API stability. - Refuses unidentified-format shard conversion before writes. Known formats 1–7 retain conversion; an already-unsharded legacy folder returns a truthful unchanged no-op without claiming old-host readability. - Adds the English avatar guide and backup-only downgrade guidance. Translations are tracked in #8483 / #8487. PMX 2.0 and compatible 2.1 files using 2.0 records are supported. QDEF, flip/impulse morphs, new 2.1 joint types and soft bodies are rejected. Physics, PMD, VPD and camera/light animation are outside this implementation. WebGL2 is required. Setup offers at most 256 morph names; texture tables allow 256 references of up to 512 characters. Import bytes, decoded textures, morph allocations and IK work are bounded. ## Validation Repair head: `d11599dc76b94aca71bd1e2772917e63de1ebbd9`, including staging `1403a981`. Local repair gates are complete; final-head hosted checks and Dottore re-examination remain merge gates. - **Fresh repair checks:** full `pnpm check` and `pnpm version:check` pass on the frozen repair. Both MMD regression files, avatar contract/stage/VRM/models/file-deletion, message-sharding and launcher-format suites pass (nine files). The full check ran on the frozen source and began before the commit; its client configured the previous build stamp. A subsequent supported `pnpm build:client` at committed `d11599dc` passed. Actual served client/API stamps and both renderer HTTP hashes were then verified before the final replay. No app version bump. - **Compiled production:** the matched repaired build passes **21/21**, zero skips: seven each in desktop Chromium (25.0s), mobile Chromium (38.4s) and mobile WebKit (34.4s). Each group includes five MMD cases, the existing VRM case and production startup/reload. The default ZIP fixture now includes Finder-style PMX/texture/VMD metadata, so it exercises real HTTP/UI import as well as the focused importer controls. - **Existing shell smoke:** seven existing desktop cases passed unchanged on the earlier matched Lite API/Vite source harness; this is separate from the fresh compiled 21-case replay. - **Owner/theme coverage:** the final compiled matrix includes all 12 character/persona × light/dark setup rows across the three browser contexts. The earlier source-harness setup replay also passed 3/3. They retain import/mapping/motion/reload/pixel/44px assertions. Themes use the actual Settings control, with normal mobile agent re-entry. Final e2e types, formatting and whitespace checks passed. - **Downgrade repair:** the actual unshard path reproduced mutation with both missing and malformed manifests while schema-valid MMD data remained. The repaired complete launcher suite and controlled probes pass with every path/file byte unchanged on refusal. A real legacy no-op CLI exits 0 without an old-host readability claim. - **Review:** the initial review found one valid metadata-bound issue and three trivial suggestions, which were addressed. The later nine-file review emitted three findings: two duplicate major comments described the same unknown-manifest gap, and one minor identified dropped persona-light coverage. Both causes were repaired; the three-file repair review completed with zero findings. The final one-file theme-fixture review also completed with zero findings. Hosted Dottore then found two medium defects on `8b3ba7de` (blink latching and Finder metadata); both were reproduced and repaired. Its viewport open question also reproduced with a fixed-frame before/after pixel mask. The substantive five-file repair review completed with zero findings; final-head hosted re-examination is pending. - **New repair controls:** blink supplied/automatic cycles reopen, disabling blink reopens, and a shared emotion target retains its eased weight. The viewport probe has an exact same-size control and exact dominant-color masks: the old crop differs at 15,968 pixels; the corrected crop differs at zero, with only seven antialias channel roundings below the tested color tolerance. The new source-browser case passes all three contexts. Finder sidecars remain unread/uncounted; unsafe/duplicate/symlink metadata, two real models/motions and sidecars-only ZIPs are still rejected. - Preserved the original PWA-interception, mounted-store theme-write, unnamed-control selector, mobile navigation and ENOSPC fixture/startup failures. The initial repaired compiled replay exposed a client/API build-stamp mismatch: the correct infinite update notice intercepted the phone Appearance tab. The matched client-only rebuild then required restarting the compiled API to register its new hashed assets; an inadvertently started pre-restart attempt and its missing-module trace are preserved. No runtime or fixture patch was made for these harness failures. No assertions, rows or timeouts were weakened; zero skips. The final compiled replay retained failure traces and disabled video; the earlier bounded source replay disabled both trace/video. No live or paid provider calls or third-party character assets were used. Final repair receipts: `/tmp/engine-8481-dottore-repairs-final-proof.json`, `/tmp/engine-8481-matched-compiled-build-proof.json`, `/tmp/engine-8481-dottore-repairs-coderabbit.log`; compiled logs/results use `/tmp/engine-8481-matched-final-{desktop,mobile-chromium,mobile-webkit}`. Final phone persona-light and desktop persona-dark screenshots were visually inspected. Earlier local/storage/row proofs remain historical in `/tmp/engine-8473-{final-local-proof,post-review-local-proof,staging-integration-invariant}.json`. Raw failure recordings remain preserved, including verified lossless archives with per-file hashes. - [ ] Manually verify licensed native PMX models and VMD motions for both owner types. - [ ] Manually check physical-device performance, framing, touch controls, pause and reduced motion. - [ ] Manually compare artistic fidelity against native MMD; synthetic geometry is not native-model calibration. - [ ] Manually verify full pre-upgrade backup restoration. - [ ] Review the user guide and translated documentation follow-up. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:46:04 +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#8628
No description provided.