mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7557] [MERGED] feat(avatars): VRM renderer, importer and setup for 3D Avatars #7796
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7796
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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)
7e3dc98feat(avatars): VRM renderer, importer and setup for the 3D Avatars agent0ffc3f3fix(avatars): linear VRM expression scan, 16px pickers on touch, aspect-safe size cape235044fix(avatars): keep VRM lip sync on faces that hold the mouth, and refuse files the loader cannot openf45154dfix(avatars): show a VRM model's rules on sexual, violent and other sensitive use96428b0fix(avatars): keep the VRM import-warning icon on the steady accent98ff4e8Merge branch 'staging' into avatar lane4e0a264Merge 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
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
15af58f10got replies and are resolved. Two were fixed indf538660f: 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 ondf538660fwas still running at hand-off, so mergeStateStatus was BLOCKED; on15af58f10every 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
What changed
VrmAvatarDatagains two optional fields,meta(VrmModelMeta) andexpressionNames(every expression the model has).VrmModelMetaholds 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 onlyhttp/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. Existingavatar.jsonfiles 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 ownVrmAvatarData.metauses.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-vrm3.5.5 and three 0.186.1 load:VRMC_vrmlisted as used, spec1.0/1.0-beta) and VRM 0.x (VRMextension), 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.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.preset, confidence 1), then a custom name that clearly means the slot (VRoid/UniVRM/VRChat/Japanese names such asSurprised,Smile,vrc.v_aa,まばたき;name-match, 0.9), then emotion word stems viamapSpriteExpressionToAvatarEmotion(name-match, lower confidence), elsemissing. Users can change every slot in setup.EXT_orKHR_meshopt_compression) or KTX2 textures..vrma(VRMC_vrm_animationwith hips and at least one animation) attaches to the owner's existing VRM asvrm/idle.vrma; importing a newvrm/model.vrmkeeps the idle animation.packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts,vrm-motion.ts): loaded only throughloadAvatarRenderer("vrm"), so three, three-vrm and three-vrm-animation stay in their lazyvendor-three*chunks.WebGLRendererfor 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.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).blink), gaze toward the viewer or the frame'slookAt, eased emotion weights and fast-eased visemes (an unknown or missing mouth shape falls back toaa). Eased weights land exactly on their target.overrideMouthblend/block): such a face switches toblendand 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..vrmaidle with body tracks only, so the director keeps the face and the gaze.update()); paused avatars draw nothing; reduced motion keeps the face and mouth but drops idle motion and the idle animation.dispose()stops the mixer and runsVRMUtils.deepDispose; a lost WebGL context keeps the last frame on screen and three redraws everything once it is restored.renderers/vrm/VrmSetupPanel.tsx):.vrm. The server's refusal shows as a toast..vrmafiles, so a.vrmpicked there cannot replace the model.avatars.vrm.*keys in the English catalog only.docs/agents/avatars.md(translation follow-up is #7540).scripts/regressions/avatar-vrm.regression.tsuses 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 withapi.rawserved from memory. It drives three-vrm's real expression manager to prove that the mouth moves on faces that hold it.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent (results as observed, boxes left for the human):
pnpm check: passed on96428b054(exit 0). Its only lint output is an existing warning inHomeProfessorMariChat.tsx.pnpm localization:check: passed (13,377 canonical keys, no static JSX copy found).node scripts/run-regressions.mjs --filter avatar: 6/6 passed, includingavatar-vrmand the contract'savatar-contract.--filter agent-activation(2/2),--filter spatial-context(1/1),--filter open-issues(1/1): passed.0ffc3f36cand unchanged by this follow-up:vrm-rendererchunk importsvendor-three(394.6 kB),vendor-three-core(232.8 kB) andvendor-three-vrm(156.4 kB).index.htmlloads none of them, andVrmSetupPanelloads no three code.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 toblendand stay at 0.4 while the avatar speaks. With three-vrm 3.5.5's own expression manager,aaat a full happy face went from 0.001 to 0.600, forblendandblockalike. Found while fixing it: eased weights never reached 0, so a fadedblockface 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'sVRMSpringBoneJointon 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:
KHR_meshopt_compression;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
otherPermissionUrltoo).The idle picker could replace the model. It now only takes
.vrmafiles.Local CodeRabbit review (CLI, Pasta-Devs org,
--committed --base-commit df538660f, the merge base withstaging):e23504487: 2 findings.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.avatarModelsRoutesis an empty plugin, so no import reachesextract. Storage (services/avatars/storage.ts) belongs to the base lane, #7556, by the epic's ownership map.f45154d4e(once, after the substantive fixes): 1 finding, fixed in96428b054. The import-warningInfoicon used--primary, which Accent Pulse animates. It now uses the steady--marinara-app-accent-static.GitHub CodeRabbit on
96428b054opened 2 threads. Both were answered and resolved without code changes:readAvatarConfigis 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:
.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..vrmin 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..glband a non-VRM file are refused with a readable sentence.VRM1_Constraint_Twist_Sample.vrm), the mouth must still move while it speaks happily.chrome://gpuclean).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.