Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / library / avatar / src / main / rust / AGENTS.md

AGENTS.md1.9 KiBRenderedCodeRaw
1# AGENTS.md — games/hub/src/main/rust/ (`yuu_avatar`)
2
3> Scoped supplement. Hub-local 3D avatar engine: glTF upper-body base mesh,
4> skeletal skinning, preset poses, Vulkan-first + GLES fallback renderer.
5
6## Overview
7**Purpose:** Real-time 3D Yuu avatars for hero surfaces (editor preview,
8profile/dashboard headers). Traits arrive as `YuuFaceConfig` JSON, poses as
9preset ids; the engine maps both onto bone matrices every frame.
10**Key features:** 13-joint upper-body rig, 5 preset poses, procedural fallback
11mesh when no glb is bundled, turntable preview camera with idle sway.
12**Architecture:** `avatar.rs` (skeleton/traits/poses/FK) → `engine.rs`
13(lifecycle/camera) → `renderer.rs` (Vulkan/GLES dispatch) → `vulkan/` + `gles/`
14backends; `mesh.rs` (procedural fallback + glTF loader); `lib.rs` (JNI).
15**Entry points:** `lib.rs` JNI fns → `engine::set_config/tick_and_render`.
16
17## Skeleton (UBO order — do not reorder)
18`root → spine → chest → neck → head`, plus per side
19`clavicle → upperArm → forearm → hand` (`avatar.rs: Joint`, `ALL_JOINTS`).
20`MAX_BONES = 32` in the shader UBO; joints beyond index 12 are identity.
21
22## Trait mapping (coarse, v1)
23`skinTone`→material, `bodyHeight/Weight`→bone scale, `faceShape`→head scale,
24style fields→attachment/texture variants (later phase);
25`mole/wrinkle/blush` explicitly skipped in v1.
26
27## Gotchas
28- Vulkan `new()` currently reports unavailable until the swapchain bring-up
29 lands; GLES path is complete. Kotlin `isAvailable` fallback keeps 2D.
30- `gltf` parses the first mesh primitive with JOINTS_0/WEIGHTS_0; node names
31 must match `joint_name()` or they remap to root.
32- Workspace lints deny `unwrap_used`/`panic`/`expect_used` — fall back, never
33 crash (missing glb → procedural mesh).
34- Shaders: `*.vert`/`*.frag` (Vulkan, Y-flip) + `*_gles.*` twins (no flip);
35 `build.rs` compiles via NDK glslc with minimal-SPV fallback.