[PR #7557] [MERGED] feat(avatars): VRM renderer, importer and setup for 3D Avatars #7796

Closed
opened 2026-10-24 04:07:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: feat/avatars-3d


📝 Commits (7)

  • 7e3dc98 feat(avatars): VRM renderer, importer and setup for the 3D Avatars agent
  • 0ffc3f3 fix(avatars): linear VRM expression scan, 16px pickers on touch, aspect-safe size cap
  • e235044 fix(avatars): keep VRM lip sync on faces that hold the mouth, and refuse files the loader cannot open
  • f45154d fix(avatars): show a VRM model's rules on sexual, violent and other sensitive use
  • 96428b0 fix(avatars): keep the VRM import-warning icon on the steady accent
  • 98ff4e8 Merge branch 'staging' into avatar lane
  • 4e0a264 Merge remote-tracking branch 'origin/staging' into HEAD

📊 Changes

9 files changed (+2684 additions, -25 deletions)

View changed files

📝 docs/agents/avatars.md (+19 -1)
📝 packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx (+403 -5)
➕ packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts (+278 -0)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts (+391 -10)
📝 packages/client/src/localization/locales/en.json (+71 -0)
📝 packages/server/src/services/avatars/formats/vrm.ts (+583 -9)
📝 packages/shared/src/schemas/avatars.schema.ts (+32 -0)
📝 packages/shared/src/types/avatars.ts (+36 -0)
➕ scripts/regressions/avatar-vrm.regression.ts (+871 -0)

📄 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

Refs #7537 (lane: 3D, VRM renderer and importer).

Depends on https://github.com/Pasta-Devs/Marinara-Engine/pull/7539 (opened ready, base staging, "feat(avatars): shared contract for the 2D and 3D avatar agents", Refs #7537). All 4 GitHub CodeRabbit threads on 15af58f10 got replies and are resolved. Two were fixed in df538660f: Windows device names in stored paths, and the code comments now point at the developer notes. Two were answered: the docs-i18n issue is #7540, and the 1.73 bump stays, with a publish-order rule added to the developer notes. CI on df538660f was still running at hand-off, so mergeStateStatus was BLOCKED; on 15af58f10 every check had passed except complete-node-regressions, which was still pending. Not merged; no checkboxes ticked. (its commits show in this diff until it merges)

Update: #7539 has since merged into staging (13d796e1e), so this diff now shows only the 3D lane's commits.

Why this change

  • The 3D Avatars agent needs to show a character's or persona's VRM model in chats, with a face that follows the reply and a mouth that moves while it talks. This PR fills the 3D lane of the contract: the VRM importer, the lazy-loaded VRM renderer and the VRM part of the agent's setup page.
  • Imported model files are untrusted, so the server checks them before anything is stored, and refuses the files the browser could not load (or should not load) with a sentence the user can act on, instead of a broken avatar later.
  • On its own this PR changes nothing users can see yet: the setup page and the chat stage that mount these pieces belong to the base lane (#7556), and the contract stubs stay inert until then.

What changed

  • Contract change (additive, called out on purpose): VrmAvatarData gains two optional fields, meta (VrmModelMeta) and expressionNames (every expression the model has). VrmModelMeta holds the title, authors, version, avatar permission, commercial use, modification, the VRM 0.x licence name and an http(s) licence link, plus these optional fields: the author's own terms link (termsUrl), creditNotation, and yes/no rules for sharing the file, sexual content, very violent content, political or religious use, and hateful or antisocial use. The strict schema accepts all of them and bounds them (256-character text, 64-character terms, 16 authors, 256 names of up to 128 characters, links only http/https). Setup needs them to show the author's terms and to offer the model's own expressions without downloading the model. Files: packages/shared/src/types/avatars.ts, packages/shared/src/schemas/avatars.schema.ts. Existing avatar.json files without them stay valid. These contract files are frozen now that #7539 has merged, so this change is called out here and on the epic. It only adds fields that this lane's own VrmAvatarData.meta uses.
  • VRM importer (packages/server/src/services/avatars/formats/vrm.ts): reads only the GLB header and the JSON chunk. The header length must equal the real byte length and every chunk must fit, so a dishonest file is refused. No file-size limit is added below the global upload cap. The JSON chunk alone is read only up to 16 MiB; see "Review follow-up" below. It mirrors what @pixiv/three-vrm 3.5.5 and three 0.186.1 load:
    • VRM 1.0 (VRMC_vrm listed as used, spec 1.0/1.0-beta) and VRM 0.x (VRM extension), with the 15 humanoid bones three-vrm requires (missing ones are named in the refusal). Every listed bone, optional ones included, must be an object that points to a node in the file, because three-vrm loads each one.
    • Expression names exactly as three-vrm registers them: VRM 1.0 known presets plus customs that are not preset names; VRM 0.x preset groups under their VRM 1.0 names (joy → happy, a → aa …), duplicates dropped. At most 256 are listed (a preset past that point still binds), and the scan stays linear however many entries a file holds.
    • Bindings for the six emotions, five visemes and blink: the model's preset first (preset, confidence 1), then a custom name that clearly means the slot (VRoid/UniVRM/VRChat/Japanese names such as Surprised, Smile, vrc.v_aa, まばたき; name-match, 0.9), then emotion word stems via mapSpriteExpressionToAvatarEmotion (name-match, lower confidence), else missing. Users can change every slot in setup.
    • Meta kept as bounded plain text; links only when they are http(s).
    • Plain refusals for:
      • Draco, even when optional, since three throws without a decoder.
      • Required meshopt (EXT_ or KHR_meshopt_compression) or KTX2 textures.
      • Buffers or images that point outside the file.
      • A missing default scene.
      • Plain glTF/GLB models without VRM data.
      • Unsupported VRM versions and missing meta.
      • Broken skeletons and damaged JSON.
    • A .vrma (VRMC_vrm_animation with hips and at least one animation) attaches to the owner's existing VRM as vrm/idle.vrma; importing a new vrm/model.vrm keeps the idle animation.
  • VRM renderer (packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts, vrm-motion.ts): loaded only through loadAvatarRenderer("vrm"), so three, three-vrm and three-vrm-animation stay in their lazy vendor-three* chunks.
    • One shared WebGLRenderer for every VRM avatar on screen: each avatar draws into a corner of the shared canvas and copies it into its stage canvas in the same task. The context is released (forceContextLoss) when the last VRM avatar goes.
    • Loads VRM 0.x and 1.0 from the stored file through api.raw; the loader only lets the file's own embedded data load. A VRM 1.0 file with a non-standard or missing licence URL still loads (its terms show in setup).
    • Procedural idle (breathing, slow sway, head tilt while thinking, lean while listening, small nods while talking), arms at the sides (mirrored for VRM 0.x), auto blink when the model has a blink expression (or the frame's blink), gaze toward the viewer or the frame's lookAt, eased emotion weights and fast-eased visemes (an unknown or missing mouth shape falls back to aa). Eased weights land exactly on their target.
    • Lip sync on VRM 1.0 faces that hold the mouth (overrideMouth blend/block): such a face switches to blend and stays at 0.4 while the avatar speaks, so the mouth keeps 60% of its movement; the face returns to full strength when it stops.
    • Hair and clothes (spring bones) start from the posed model, so they do not whip when the avatar appears.
    • Framing follows the canvas shape smoothly: the head stays near the top, a wide spot shows the head and shoulders, and a narrower one shows more of the body, down to the whole figure. There is no threshold to flip across.
    • Optional .vrma idle with body tracks only, so the director keeps the face and the gaze.
    • Device-pixel-ratio cap (2) and a 2048-pixel-per-side cap that scales both sides alike, so a tall avatar keeps its shape; no loop or timer of its own (the stage drives update()); paused avatars draw nothing; reduced motion keeps the face and mouth but drops idle motion and the idle animation.
    • Mount is abort-safe and cleans up after itself on failure; dispose() stops the mixer and runs VRMUtils.deepDispose; a lost WebGL context keeps the last frame on screen and three redraws everything once it is restored.
  • VRM setup panel (renderers/vrm/VrmSetupPanel.tsx):
    • Import or replace a .vrm. The server's refusal shows as a toast.
    • The author's terms in plain words: who may use the model, commercial use, changes, sharing, credit, and sexual, very violent, political or religious, and hateful use, whenever the file states them. Links go to the licence and to the author's own terms.
    • A picker for every face, mouth shape and blink. Each shows whether it was set by the model, guessed from its name, chosen by the user or not found.
    • The optional idle animation (add, replace, remove). The idle picker only takes .vrma files, so a .vrm picked there cannot replace the model.
    • Remove model asks first.
    • Theme colours only. Two columns of pickers on phones and desktops, 44 px touch targets, and 16 px picker text on touch screens so iOS does not zoom on every tap.
  • Copy: avatars.vrm.* keys in the English catalog only.
  • Docs: the "3D avatars: VRM models" section of docs/agents/avatars.md (translation follow-up is #7540).
  • Regression: scripts/regressions/avatar-vrm.regression.ts uses synthetic GLBs built in the test; no VRM file is committed. It also loads every file the importer accepts in the stage's own loader. That is three's GLTFLoader with three-vrm, configured as the renderer does, running in Node with api.raw served from memory. It drives three-vrm's real expression manager to prove that the mouth moves on faces that hold it.

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

Commands run by the agent (results as observed, boxes left for the human):

  • pnpm check: passed on 96428b054 (exit 0). Its only lint output is an existing warning in HomeProfessorMariChat.tsx.
  • pnpm localization:check: passed (13,377 canonical keys, no static JSX copy found).
  • node scripts/run-regressions.mjs --filter avatar: 6/6 passed, including avatar-vrm and the contract's avatar-contract.
  • --filter agent-activation (2/2), --filter spatial-context (1/1), --filter open-issues (1/1): passed.
  • Mutation checks on the new regression, each reverted afterwards: the regression fails with the old licence-URL handling ("The license url "undefined" is not accepted") and fails without the weight settling.
  • Earlier, on 0ffc3f36c and unchanged by this follow-up:
    • Lazy chunks: only the vrm-renderer chunk imports vendor-three (394.6 kB), vendor-three-core (232.8 kB) and vendor-three-vrm (156.4 kB). index.html loads none of them, and VrmSetupPanel loads no three code.
    • Importer on real VRM Public License samples and three-vrm's example models, kept local.
    • Renderer in headless Chromium, WebKit and Firefox.
    • Setup panel at 900 px and 390 px, dark and light.

Review follow-up (reviewer findings on 0ffc3f36c)

Fixed in e23504487:

  • Lip sync froze on VRM 1.0 faces with overrideMouth (major). three-vrm multiplies the mouth by 1 minus the face's weight (blend), or by 0 at any weight (block). Such faces now switch to blend and stay at 0.4 while the avatar speaks. With three-vrm 3.5.5's own expression manager, aa at a full happy face went from 0.001 to 0.600, for blend and block alike. Found while fixing it: eased weights never reached 0, so a faded block face kept blinks blocked for about two minutes. They now land on their target, and blinks are back in the same check (applied 0 → 1).

  • Spring bones whipped at every mount. vrm.springBoneManager?.reset() now runs after the rest pose (and after the idle animation's first pose). Local proof with three-vrm's VRMSpringBoneJoint on a lowered arm: the sleeve's angle went from 131° on frame 1 (settling after about 12 frames) to 0° in every frame.

  • Accepted files the loader then refused. These are now refused at import:

    • a bone entry that is not an object, or that points past the nodes, optional bones included;
    • required KHR_meshopt_compression;
    • a missing default scene, found by the new loader check.

    A VRM 1.0 licence URL that is missing or not text now loads. three-vrm compares it as it is, so the renderer accepts the file's own value. The regression proves both directions with the real loader.

  • Framing flipped between bust and full body within the stage's own shapes (aspect 0.49 to 0.75). The framing is now continuous: the largest step in the visible bottom edge per 0.01 of aspect went from 1.007 m (at 0.66) to 0.048 m.

  • Oversized JSON chunk could exhaust the server's memory. The JSON chunk is refused above 16 MiB before it is decoded. Real VRM JSON is about 0.1 to 2 MiB, and the binary chunk and the file stay unlimited. Measured locally with a 1 GiB heap, hostile 16 MiB JSON parses in about 5 s at 380 MiB heap. The reviewer saw 64 MiB crash a 1 GiB heap.

  • VRM 1.0 terms left out the author's terms link, credit and sharing rules. They are now stored and shown (VRM 0.x otherPermissionUrl too).

  • The idle picker could replace the model. It now only takes .vrma files.

Local CodeRabbit review (CLI, Pasta-Devs org, --committed --base-commit df538660f, the merge base with staging):

  • Pass on e23504487: 2 findings.
    • Fixed in f45154d4e: the terms left out the content rules (VRM 1.0 sexual, violent, political or religious, and antisocial or hate use; VRM 0.x sexual and violent use). They are now stored and shown.
    • Not changed: "implement the avatar storage lane before enabling VRM imports". On this branch avatarModelsRoutes is an empty plugin, so no import reaches extract. Storage (services/avatars/storage.ts) belongs to the base lane, #7556, by the epic's ownership map.
  • Re-review on f45154d4e (once, after the substantive fixes): 1 finding, fixed in 96428b054. The import-warning Info icon used --primary, which Accent Pulse animates. It now uses the steady --marinara-app-accent-static.

GitHub CodeRabbit on 96428b054 opened 2 threads. Both were answered and resolved without code changes:

  • docs-i18n: the follow-up issue is #7540, which covers all three paths.
  • readAvatarConfig is still a stub here: storage belongs to the base lane, #7556, and the import route is an empty plugin on this branch.

Manual verification notes

Needs the base lane (setup page and chat stage) on the same build. Then, for each of desktop Chrome, Firefox and Safari, Android Chrome, the Android app WebView and iOS Safari:

  • Manually verify importing a VRM 1.0 model and a VRM 0.x model (for example from VRoid Studio) on a character's 3D Avatars page. Check that the title, version, authors and the author's terms show, including the credit, sharing and content rows and the "Read the author's terms" link when the file has them. Every face and mouth shape should be filled in or marked "Not found in the model".
  • Manually verify changing a face's expression and choosing "None" saves and survives a reload.
  • Manually verify importing a .vrma, then replacing the model: the idle animation stays; removing the animation brings back the built-in breathing and sway; Remove model asks first and deletes both.
  • Manually verify that choosing a .vrm in the idle-animation picker shows "Only .vrma animation files can be added here." and leaves the model as it was. On Android, the picker may list every file.
  • Manually verify a Draco-compressed model, a plain .glb and a non-VRM file are refused with a readable sentence.
  • Manually verify in a Roleplay chat with 3D Avatars on that the model shows without its hair or sleeves whipping, looks at you, blinks, changes face with the reply and moves its mouth while text streams. With a VRM 1.0 model whose happy face holds the mouth (for example VRM1_Constraint_Twist_Sample.vrm), the mouth must still move while it speaks happily.
  • Manually verify the framing while resizing the window and when a second character joins on a phone. The head stays near the top, and a narrower spot shows more of the body without a sudden jump.
  • Manually verify that two VRM avatars on a phone and four on desktop stay smooth, that switching tabs pauses them, and that with reduced motion on they stop swaying but still change face.
  • Manually verify that the avatar reappears after the GPU resets (for example by switching apps on a phone for a while, or chrome://gpuclean).

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: docs/agents/avatars.md, section "3D avatars: VRM models". The translation follow-up is the existing #7540. No CHANGELOG edit, no version bump.

UI evidence (if applicable)

Screenshots were taken with the temporary harness (sample models under the VRM Public License and three-vrm's example model) and are not attached, because the base lane's setup page and stage are not on this branch yet; please capture them during the manual checks above.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Import VRM 0.x and 1.0 avatars, configure facial-expression and mouth-shape mappings, and optionally add or remove idle animations.
    • View model details, usage terms, and import warnings; replace or remove models with confirmation.
    • Avatars support animated expressions, lip-sync, blinking, and subtle idle movement, with reduced-motion preferences respected.
    • Unsupported, incomplete, or compressed models are rejected with import feedback.

🔄 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/7557 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/avatars-3d` --- ### 📝 Commits (7) - [`7e3dc98`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7e3dc981c35da39eae473192bd9bb6dee29ab45c) feat(avatars): VRM renderer, importer and setup for the 3D Avatars agent - [`0ffc3f3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0ffc3f36c72865a60c0389b4e77c3daccc38391e) fix(avatars): linear VRM expression scan, 16px pickers on touch, aspect-safe size cap - [`e235044`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e23504487cc432521108d0df6adb4bf033afc5c6) fix(avatars): keep VRM lip sync on faces that hold the mouth, and refuse files the loader cannot open - [`f45154d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f45154d4e5b1c31d3ab1006495735fb0d7ae4ff8) fix(avatars): show a VRM model's rules on sexual, violent and other sensitive use - [`96428b0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/96428b054180ee0d8a65dea76689d3dceb6ce4e9) fix(avatars): keep the VRM import-warning icon on the steady accent - [`98ff4e8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/98ff4e848b23bdf1d58b288e810f3243a485e7c5) Merge branch 'staging' into avatar lane - [`4e0a264`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4e0a2646eaf112c8942f9d4e9e344f2c8f709a91) Merge remote-tracking branch 'origin/staging' into HEAD ### 📊 Changes **9 files changed** (+2684 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+19 -1) 📝 `packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx` (+403 -5) ➕ `packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts` (+278 -0) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts` (+391 -10) 📝 `packages/client/src/localization/locales/en.json` (+71 -0) 📝 `packages/server/src/services/avatars/formats/vrm.ts` (+583 -9) 📝 `packages/shared/src/schemas/avatars.schema.ts` (+32 -0) 📝 `packages/shared/src/types/avatars.ts` (+36 -0) ➕ `scripts/regressions/avatar-vrm.regression.ts` (+871 -0) </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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Refs #7537 (lane: 3D, VRM renderer and importer). Depends on https://github.com/Pasta-Devs/Marinara-Engine/pull/7539 (opened ready, base staging, "feat(avatars): shared contract for the 2D and 3D avatar agents", Refs #7537). All 4 GitHub CodeRabbit threads on 15af58f10 got replies and are resolved. Two were fixed in df538660f: Windows device names in stored paths, and the code comments now point at the developer notes. Two were answered: the docs-i18n issue is #7540, and the 1.73 bump stays, with a publish-order rule added to the developer notes. CI on df538660f was still running at hand-off, so mergeStateStatus was BLOCKED; on 15af58f10 every check had passed except complete-node-regressions, which was still pending. Not merged; no checkboxes ticked. (its commits show in this diff until it merges) Update: #7539 has since merged into `staging` (13d796e1e), so this diff now shows only the 3D lane's commits. ## Why this change - The **3D Avatars** agent needs to show a character's or persona's VRM model in chats, with a face that follows the reply and a mouth that moves while it talks. This PR fills the 3D lane of the contract: the VRM importer, the lazy-loaded VRM renderer and the VRM part of the agent's setup page. - Imported model files are untrusted, so the server checks them before anything is stored, and refuses the files the browser could not load (or should not load) with a sentence the user can act on, instead of a broken avatar later. - On its own this PR changes nothing users can see yet: the setup page and the chat stage that mount these pieces belong to the base lane (#7556), and the contract stubs stay inert until then. ## What changed - **Contract change (additive, called out on purpose):** `VrmAvatarData` gains two optional fields, `meta` (`VrmModelMeta`) and `expressionNames` (every expression the model has). `VrmModelMeta` holds the title, authors, version, avatar permission, commercial use, modification, the VRM 0.x licence name and an http(s) licence link, plus these optional fields: the author's own terms link (`termsUrl`), `creditNotation`, and yes/no rules for sharing the file, sexual content, very violent content, political or religious use, and hateful or antisocial use. The strict schema accepts all of them and bounds them (256-character text, 64-character terms, 16 authors, 256 names of up to 128 characters, links only `http`/`https`). Setup needs them to show the author's terms and to offer the model's own expressions without downloading the model. Files: `packages/shared/src/types/avatars.ts`, `packages/shared/src/schemas/avatars.schema.ts`. Existing `avatar.json` files without them stay valid. These contract files are frozen now that #7539 has merged, so this change is called out here and on the epic. It only adds fields that this lane's own `VrmAvatarData.meta` uses. - **VRM importer** (`packages/server/src/services/avatars/formats/vrm.ts`): reads only the GLB header and the JSON chunk. The header length must equal the real byte length and every chunk must fit, so a dishonest file is refused. No file-size limit is added below the global upload cap. The JSON chunk alone is read only up to 16 MiB; see "Review follow-up" below. It mirrors what `@pixiv/three-vrm` 3.5.5 and three 0.186.1 load: - VRM 1.0 (`VRMC_vrm` listed as used, spec `1.0`/`1.0-beta`) and VRM 0.x (`VRM` extension), with the 15 humanoid bones three-vrm requires (missing ones are named in the refusal). Every listed bone, optional ones included, must be an object that points to a node in the file, because three-vrm loads each one. - Expression names exactly as three-vrm registers them: VRM 1.0 known presets plus customs that are not preset names; VRM 0.x preset groups under their VRM 1.0 names (`joy` → `happy`, `a` → `aa` …), duplicates dropped. At most 256 are listed (a preset past that point still binds), and the scan stays linear however many entries a file holds. - Bindings for the six emotions, five visemes and blink: the model's preset first (`preset`, confidence 1), then a custom name that clearly means the slot (VRoid/UniVRM/VRChat/Japanese names such as `Surprised`, `Smile`, `vrc.v_aa`, `まばたき`; `name-match`, 0.9), then emotion word stems via `mapSpriteExpressionToAvatarEmotion` (`name-match`, lower confidence), else `missing`. Users can change every slot in setup. - Meta kept as bounded plain text; links only when they are http(s). - Plain refusals for: - Draco, even when optional, since three throws without a decoder. - Required meshopt (`EXT_` or `KHR_meshopt_compression`) or KTX2 textures. - Buffers or images that point outside the file. - A missing default scene. - Plain glTF/GLB models without VRM data. - Unsupported VRM versions and missing meta. - Broken skeletons and damaged JSON. - A `.vrma` (`VRMC_vrm_animation` with hips and at least one animation) attaches to the owner's existing VRM as `vrm/idle.vrma`; importing a new `vrm/model.vrm` keeps the idle animation. - **VRM renderer** (`packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts`, `vrm-motion.ts`): loaded only through `loadAvatarRenderer("vrm")`, so three, three-vrm and three-vrm-animation stay in their lazy `vendor-three*` chunks. - One shared `WebGLRenderer` for every VRM avatar on screen: each avatar draws into a corner of the shared canvas and copies it into its stage canvas in the same task. The context is released (`forceContextLoss`) when the last VRM avatar goes. - Loads VRM 0.x and 1.0 from the stored file through `api.raw`; the loader only lets the file's own embedded data load. A VRM 1.0 file with a non-standard or missing licence URL still loads (its terms show in setup). - Procedural idle (breathing, slow sway, head tilt while thinking, lean while listening, small nods while talking), arms at the sides (mirrored for VRM 0.x), auto blink when the model has a blink expression (or the frame's `blink`), gaze toward the viewer or the frame's `lookAt`, eased emotion weights and fast-eased visemes (an unknown or missing mouth shape falls back to `aa`). Eased weights land exactly on their target. - Lip sync on VRM 1.0 faces that hold the mouth (`overrideMouth` `blend`/`block`): such a face switches to `blend` and stays at 0.4 while the avatar speaks, so the mouth keeps 60% of its movement; the face returns to full strength when it stops. - Hair and clothes (spring bones) start from the posed model, so they do not whip when the avatar appears. - Framing follows the canvas shape smoothly: the head stays near the top, a wide spot shows the head and shoulders, and a narrower one shows more of the body, down to the whole figure. There is no threshold to flip across. - Optional `.vrma` idle with body tracks only, so the director keeps the face and the gaze. - Device-pixel-ratio cap (2) and a 2048-pixel-per-side cap that scales both sides alike, so a tall avatar keeps its shape; no loop or timer of its own (the stage drives `update()`); paused avatars draw nothing; reduced motion keeps the face and mouth but drops idle motion and the idle animation. - Mount is abort-safe and cleans up after itself on failure; `dispose()` stops the mixer and runs `VRMUtils.deepDispose`; a lost WebGL context keeps the last frame on screen and three redraws everything once it is restored. - **VRM setup panel** (`renderers/vrm/VrmSetupPanel.tsx`): - Import or replace a `.vrm`. The server's refusal shows as a toast. - The author's terms in plain words: who may use the model, commercial use, changes, sharing, credit, and sexual, very violent, political or religious, and hateful use, whenever the file states them. Links go to the licence and to the author's own terms. - A picker for every face, mouth shape and blink. Each shows whether it was set by the model, guessed from its name, chosen by the user or not found. - The optional idle animation (add, replace, remove). The idle picker only takes `.vrma` files, so a `.vrm` picked there cannot replace the model. - Remove model asks first. - Theme colours only. Two columns of pickers on phones and desktops, 44 px touch targets, and 16 px picker text on touch screens so iOS does not zoom on every tap. - **Copy:** `avatars.vrm.*` keys in the English catalog only. - **Docs:** the "3D avatars: VRM models" section of `docs/agents/avatars.md` (translation follow-up is #7540). - **Regression:** `scripts/regressions/avatar-vrm.regression.ts` uses synthetic GLBs built in the test; no VRM file is committed. It also loads every file the importer accepts in the stage's own loader. That is three's GLTFLoader with three-vrm, configured as the renderer does, running in Node with `api.raw` served from memory. It drives three-vrm's real expression manager to prove that the mouth moves on faces that hold it. ## 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` Commands run by the agent (results as observed, boxes left for the human): - `pnpm check`: passed on `96428b054` (exit 0). Its only lint output is an existing warning in `HomeProfessorMariChat.tsx`. - `pnpm localization:check`: passed (13,377 canonical keys, no static JSX copy found). - `node scripts/run-regressions.mjs --filter avatar`: 6/6 passed, including `avatar-vrm` and the contract's `avatar-contract`. - `--filter agent-activation` (2/2), `--filter spatial-context` (1/1), `--filter open-issues` (1/1): passed. - Mutation checks on the new regression, each reverted afterwards: the regression fails with the old licence-URL handling ("The license url "undefined" is not accepted") and fails without the weight settling. - Earlier, on `0ffc3f36c` and unchanged by this follow-up: - Lazy chunks: only the `vrm-renderer` chunk imports `vendor-three` (394.6 kB), `vendor-three-core` (232.8 kB) and `vendor-three-vrm` (156.4 kB). `index.html` loads none of them, and `VrmSetupPanel` loads no three code. - Importer on real VRM Public License samples and three-vrm's example models, kept local. - Renderer in headless Chromium, WebKit and Firefox. - Setup panel at 900 px and 390 px, dark and light. ### Review follow-up (reviewer findings on `0ffc3f36c`) Fixed in `e23504487`: - **Lip sync froze on VRM 1.0 faces with `overrideMouth`** (major). three-vrm multiplies the mouth by 1 minus the face's weight (`blend`), or by 0 at any weight (`block`). Such faces now switch to `blend` and stay at 0.4 while the avatar speaks. With three-vrm 3.5.5's own expression manager, `aa` at a full happy face went from 0.001 to 0.600, for `blend` and `block` alike. Found while fixing it: eased weights never reached 0, so a faded `block` face kept blinks blocked for about two minutes. They now land on their target, and blinks are back in the same check (applied 0 → 1). - **Spring bones whipped at every mount.** `vrm.springBoneManager?.reset()` now runs after the rest pose (and after the idle animation's first pose). Local proof with three-vrm's `VRMSpringBoneJoint` on a lowered arm: the sleeve's angle went from 131° on frame 1 (settling after about 12 frames) to 0° in every frame. - **Accepted files the loader then refused.** These are now refused at import: - a bone entry that is not an object, or that points past the nodes, optional bones included; - required `KHR_meshopt_compression`; - a missing default scene, found by the new loader check. A VRM 1.0 licence URL that is missing or not text now loads. three-vrm compares it as it is, so the renderer accepts the file's own value. The regression proves both directions with the real loader. - **Framing flipped between bust and full body** within the stage's own shapes (aspect 0.49 to 0.75). The framing is now continuous: the largest step in the visible bottom edge per 0.01 of aspect went from 1.007 m (at 0.66) to 0.048 m. - **Oversized JSON chunk could exhaust the server's memory.** The JSON chunk is refused above 16 MiB before it is decoded. Real VRM JSON is about 0.1 to 2 MiB, and the binary chunk and the file stay unlimited. Measured locally with a 1 GiB heap, hostile 16 MiB JSON parses in about 5 s at 380 MiB heap. The reviewer saw 64 MiB crash a 1 GiB heap. - **VRM 1.0 terms left out the author's terms link, credit and sharing rules.** They are now stored and shown (VRM 0.x `otherPermissionUrl` too). - **The idle picker could replace the model.** It now only takes `.vrma` files. Local CodeRabbit review (CLI, Pasta-Devs org, `--committed --base-commit df538660f`, the merge base with `staging`): - Pass on `e23504487`: 2 findings. - Fixed in `f45154d4e`: the terms left out the content rules (VRM 1.0 sexual, violent, political or religious, and antisocial or hate use; VRM 0.x sexual and violent use). They are now stored and shown. - Not changed: "implement the avatar storage lane before enabling VRM imports". On this branch `avatarModelsRoutes` is an empty plugin, so no import reaches `extract`. Storage (`services/avatars/storage.ts`) belongs to the base lane, #7556, by the epic's ownership map. - Re-review on `f45154d4e` (once, after the substantive fixes): 1 finding, fixed in `96428b054`. The import-warning `Info` icon used `--primary`, which Accent Pulse animates. It now uses the steady `--marinara-app-accent-static`. GitHub CodeRabbit on `96428b054` opened 2 threads. Both were answered and resolved without code changes: - docs-i18n: the follow-up issue is #7540, which covers all three paths. - `readAvatarConfig` is still a stub here: storage belongs to the base lane, #7556, and the import route is an empty plugin on this branch. ### Manual verification notes Needs the base lane (setup page and chat stage) on the same build. Then, for each of desktop Chrome, Firefox and Safari, Android Chrome, the Android app WebView and iOS Safari: - Manually verify importing a VRM 1.0 model and a VRM 0.x model (for example from VRoid Studio) on a character's 3D Avatars page. Check that the title, version, authors and the author's terms show, including the credit, sharing and content rows and the "Read the author's terms" link when the file has them. Every face and mouth shape should be filled in or marked "Not found in the model". - Manually verify changing a face's expression and choosing "None" saves and survives a reload. - Manually verify importing a `.vrma`, then replacing the model: the idle animation stays; removing the animation brings back the built-in breathing and sway; Remove model asks first and deletes both. - Manually verify that choosing a `.vrm` in the idle-animation picker shows "Only .vrma animation files can be added here." and leaves the model as it was. On Android, the picker may list every file. - Manually verify a Draco-compressed model, a plain `.glb` and a non-VRM file are refused with a readable sentence. - Manually verify in a Roleplay chat with 3D Avatars on that the model shows without its hair or sleeves whipping, looks at you, blinks, changes face with the reply and moves its mouth while text streams. With a VRM 1.0 model whose happy face holds the mouth (for example `VRM1_Constraint_Twist_Sample.vrm`), the mouth must still move while it speaks happily. - Manually verify the framing while resizing the window and when a second character joins on a phone. The head stays near the top, and a narrower spot shows more of the body without a sudden jump. - Manually verify that two VRM avatars on a phone and four on desktop stay smooth, that switching tabs pauses them, and that with reduced motion on they stop swaying but still change face. - Manually verify that the avatar reappears after the GPU resets (for example by switching apps on a phone for a while, or `chrome://gpuclean`). ## 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: `docs/agents/avatars.md`, section "3D avatars: VRM models". The translation follow-up is the existing #7540. No CHANGELOG edit, no version bump. ## UI evidence (if applicable) Screenshots were taken with the temporary harness (sample models under the VRM Public License and three-vrm's example model) and are not attached, because the base lane's setup page and stage are not on this branch yet; please capture them during the manual checks above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Import VRM 0.x and 1.0 avatars, configure facial-expression and mouth-shape mappings, and optionally add or remove idle animations. * View model details, usage terms, and import warnings; replace or remove models with confirmation. * Avatars support animated expressions, lip-sync, blinking, and subtle idle movement, with reduced-motion preferences respected. * Unsupported, incomplete, or compressed models are rejected with import feedback. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:07:35 +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#7796
No description provided.