[PR #7820] [MERGED] fix(avatars): keep colours and idle motion on generated 3D avatars #7947

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

📋 Pull Request Information

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

Base: staging ← Head: fix/avatar-3d-colors-motion


📝 Commits (1)

  • aec99f6 fix(avatars): keep colours and idle motion on generated 3D avatars

📊 Changes

7 files changed (+532 additions, -43 deletions)

View changed files

📝 e2e/avatar-2d.e2e.ts (+1 -31)
➕ e2e/avatar-vrm.e2e.ts (+147 -0)
➕ e2e/server-csp-fixture.ts (+32 -0)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts (+28 -9)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts (+13 -2)
📝 scripts/regressions/avatar-vrm.regression.ts (+126 -1)
➕ scripts/regressions/fixtures/avatar-3d-fixtures.ts (+185 -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

No issue: @SpicyMarinara reported this directly while testing the staging Docker build (3D Avatars page, a model made with Tripo).

Why this change

A model made with Tripo showed its colours in the preview picture, but drew plain white once it loaded, and it barely moved.

  • No colours. The model file is fine: it has its colour, normal and roughness pictures. The browser refused to load them. GLTFLoader reads a model's embedded pictures with fetch(blob:…), and the server's Content-Security-Policy (connect-src has no blob:) blocks those requests. three then quietly drops each texture, so the model renders white. This never showed in pnpm dev, because Vite sends no CSP. It affects every VRM with textures in Docker and production, VRoid models included.
  • Hardly moves. The idle sway and the talking nod were tuned as a quiet extra for models that also blink and move their mouth. A Tripo model has no face shapes, jaw or eye bones, so the body is the only thing that can move, and it moved only 1–2°.

Models that are already saved get both fixes the next time they load. Nobody needs to make them again.

What changed

  • vrm-renderer.ts: the loader loads a model's pictures as images (img-src already allows blob: and data:), using three's own TextureLoader fallback. The CSP stays as it is, as it did for the mesh avatar fix in 5d1ec08a8. On an M4 the first frame of the real model takes about 15 ms longer than with image bitmaps (81 ms against 65 ms). After that, frames cost the same.
  • vrm-motion.ts: a model with no mouth shape bound (bodyOnly) sways, breathes and turns 2.5 times as much, and nods and tilts its head with each phrase it speaks. A model with a face keeps exactly the pose it had (gain 1, no talk term), and reduced motion still holds every body still.
  • Tests:
    • scripts/regressions/fixtures/avatar-3d-fixtures.ts builds a Tripo-like model in code: a Mixamo skeleton under Root, facing +X, with one PBR material and normal, colour and ORM pictures in Tripo's order. It then runs the model through the real glb-to-vrm.
    • avatar-vrm.regression.ts checks the motion maths: a body-only model sways more and nods per phrase, and a model with a face nods exactly as before. It then loads the fixture while Node plays a browser whose connect-src refuses blob:, and checks that the colour map loads and that the Mixamo head visibly turns with no idle animation.
    • New e2e/avatar-vrm.e2e.ts draws the fixture with the real renderer under the server's own CSP. It checks that the pixels are the texture's colour and not white, that the body moves, and that the page reports no CSP violations.
    • serveWithServerCsp moved unchanged from avatar-2d.e2e.ts to e2e/server-csp-fixture.ts so both specs share it.

Not in this PR: the mouth. A Tripo model has no mouth to move: its rig is 23 body joints with no face shapes or jaw, so lip sync has nothing to drive. Here speech shows through head nods and tilts only. A moving mouth needs a new step, and that needs your decision first.

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:

  • pnpm check: passed.
  • node ./scripts/run-regressions.mjs --filter avatar: 18 of 18 passed.
  • Playwright on desktop-chromium: e2e/avatar-vrm.e2e.ts, avatar-2d, avatar-preview, avatar-setup, avatar-vrm-generation and avatar-generation, 26 of 26 passed.
  • Playwright on mobile-chromium and mobile-webkit: e2e/avatar-vrm.e2e.ts passed on both.
  • Against unchanged staging:
    • The new e2e fails: the average colour is 216,216,216 (white), and the page reports connect-src violations for blob:.
    • The new regression fails: the colour map is missing, and the body-only sway is no larger than a face model's.
  • The real Maukie model under the server's CSP, compared with staging:
    • Staging: three textures dropped, average colour 202,202,202.
    • This branch: coloured, average 56,41,40.
    • Pixels changed between 2 s and 4 s of idle: 13,657 on staging, 20,588 here.
  • A synthetic MToon (VRoid-style) model under the CSP has the same average colour as on a page without a CSP (43,127,231), so its look matches pnpm dev.

Manual verification notes

  • On the Docker/production build, open 3D Avatars for a character with a Tripo model (one made before this change). Check that it shows its colours in the setup preview and in a Roleplay chat, without being made again.
  • With Idle motion on, check that the Tripo model visibly sways and breathes while idle, and nods and tilts its head while a reply streams and while TTS plays.
  • Import a VRoid model (MToon, with face expressions) on 3D Avatars. Check that it shows its colours, and that its idle sway, blinking, lip sync and faces look the same as before.
  • With Reduce ambient effects or the OS reduce-motion setting on, check that both models hold still.
  • Check the browser console while a model loads: there should be no "Couldn't load texture" errors and no connect-src violations.

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 already says that a Tripo model's body moves and its face doesn't, which stays true.

UI evidence (if applicable)

The agent rendered the real model locally under the server's CSP. Staging draws it white; this branch draws it in full colour (black waistcoat, red shirt, brown hair), and the idle difference map shows the head and shoulders moving about 50% more. The screenshots are kept with the agent's run.

Summary by CodeRabbit

  • Bug Fixes
    • Body-only VRM avatars now retain their colour and texture maps under restrictive security settings.
    • Avatars without mouth shapes can visibly breathe, sway, and nod in response to speech.
    • Reduced-motion settings continue to keep the avatar pose still.
  • Tests
    • Added coverage for VRM rendering, animation, texture loading, and content security policy behavior.

🔄 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/7820 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/avatar-3d-colors-motion` --- ### 📝 Commits (1) - [`aec99f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aec99f644da47c5fb9e411996a94dfef97b8db4f) fix(avatars): keep colours and idle motion on generated 3D avatars ### 📊 Changes **7 files changed** (+532 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `e2e/avatar-2d.e2e.ts` (+1 -31) ➕ `e2e/avatar-vrm.e2e.ts` (+147 -0) ➕ `e2e/server-csp-fixture.ts` (+32 -0) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts` (+28 -9) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts` (+13 -2) 📝 `scripts/regressions/avatar-vrm.regression.ts` (+126 -1) ➕ `scripts/regressions/fixtures/avatar-3d-fixtures.ts` (+185 -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 No issue: @SpicyMarinara reported this directly while testing the staging Docker build (3D Avatars page, a model made with Tripo). ## Why this change A model made with Tripo showed its colours in the preview picture, but drew plain white once it loaded, and it barely moved. - **No colours.** The model file is fine: it has its colour, normal and roughness pictures. The browser refused to load them. GLTFLoader reads a model's embedded pictures with `fetch(blob:…)`, and the server's Content-Security-Policy (`connect-src` has no `blob:`) blocks those requests. three then quietly drops each texture, so the model renders white. This never showed in `pnpm dev`, because Vite sends no CSP. It affects every VRM with textures in Docker and production, VRoid models included. - **Hardly moves.** The idle sway and the talking nod were tuned as a quiet extra for models that also blink and move their mouth. A Tripo model has no face shapes, jaw or eye bones, so the body is the only thing that can move, and it moved only 1–2°. Models that are already saved get both fixes the next time they load. Nobody needs to make them again. ## What changed - `vrm-renderer.ts`: the loader loads a model's pictures as images (`img-src` already allows `blob:` and `data:`), using three's own `TextureLoader` fallback. The CSP stays as it is, as it did for the mesh avatar fix in 5d1ec08a8. On an M4 the first frame of the real model takes about 15 ms longer than with image bitmaps (81 ms against 65 ms). After that, frames cost the same. - `vrm-motion.ts`: a model with no mouth shape bound (`bodyOnly`) sways, breathes and turns 2.5 times as much, and nods and tilts its head with each phrase it speaks. A model with a face keeps exactly the pose it had (gain 1, no talk term), and reduced motion still holds every body still. - Tests: - `scripts/regressions/fixtures/avatar-3d-fixtures.ts` builds a Tripo-like model in code: a Mixamo skeleton under `Root`, facing +X, with one PBR material and normal, colour and ORM pictures in Tripo's order. It then runs the model through the real `glb-to-vrm`. - `avatar-vrm.regression.ts` checks the motion maths: a body-only model sways more and nods per phrase, and a model with a face nods exactly as before. It then loads the fixture while Node plays a browser whose `connect-src` refuses `blob:`, and checks that the colour map loads and that the Mixamo head visibly turns with no idle animation. - New `e2e/avatar-vrm.e2e.ts` draws the fixture with the real renderer under the server's own CSP. It checks that the pixels are the texture's colour and not white, that the body moves, and that the page reports no CSP violations. - `serveWithServerCsp` moved unchanged from `avatar-2d.e2e.ts` to `e2e/server-csp-fixture.ts` so both specs share it. Not in this PR: **the mouth.** A Tripo model has no mouth to move: its rig is 23 body joints with no face shapes or jaw, so lip sync has nothing to drive. Here speech shows through head nods and tilts only. A moving mouth needs a new step, and that needs your decision first. ## 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: - `pnpm check`: passed. - `node ./scripts/run-regressions.mjs --filter avatar`: 18 of 18 passed. - Playwright on desktop-chromium: `e2e/avatar-vrm.e2e.ts`, `avatar-2d`, `avatar-preview`, `avatar-setup`, `avatar-vrm-generation` and `avatar-generation`, 26 of 26 passed. - Playwright on mobile-chromium and mobile-webkit: `e2e/avatar-vrm.e2e.ts` passed on both. - Against unchanged staging: - The new e2e fails: the average colour is 216,216,216 (white), and the page reports `connect-src` violations for `blob:`. - The new regression fails: the colour map is missing, and the body-only sway is no larger than a face model's. - The real Maukie model under the server's CSP, compared with staging: - Staging: three textures dropped, average colour 202,202,202. - This branch: coloured, average 56,41,40. - Pixels changed between 2 s and 4 s of idle: 13,657 on staging, 20,588 here. - A synthetic MToon (VRoid-style) model under the CSP has the same average colour as on a page without a CSP (43,127,231), so its look matches `pnpm dev`. ### Manual verification notes - [ ] On the Docker/production build, open **3D Avatars** for a character with a Tripo model (one made before this change). Check that it shows its colours in the setup preview and in a Roleplay chat, without being made again. - [ ] With **Idle motion** on, check that the Tripo model visibly sways and breathes while idle, and nods and tilts its head while a reply streams and while TTS plays. - [ ] Import a VRoid model (MToon, with face expressions) on **3D Avatars**. Check that it shows its colours, and that its idle sway, blinking, lip sync and faces look the same as before. - [ ] With **Reduce ambient effects** or the OS reduce-motion setting on, check that both models hold still. - [ ] Check the browser console while a model loads: there should be no "Couldn't load texture" errors and no `connect-src` violations. ## 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` already says that a Tripo model's body moves and its face doesn't, which stays true. ## UI evidence (if applicable) The agent rendered the real model locally under the server's CSP. Staging draws it white; this branch draws it in full colour (black waistcoat, red shirt, brown hair), and the idle difference map shows the head and shoulders moving about 50% more. The screenshots are kept with the agent's run. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Body-only VRM avatars now retain their colour and texture maps under restrictive security settings. * Avatars without mouth shapes can visibly breathe, sway, and nod in response to speech. * Reduced-motion settings continue to keep the avatar pose still. * **Tests** * Added coverage for VRM rendering, animation, texture loading, and content security policy behavior. <!-- 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:09: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#7947
No description provided.