Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

Wire face-geometry morph into the reconstruction worker + es locale

nirholas75ed27ff0b6a
diff --git a/public/locales/es.json b/public/locales/es.json
index 9855063c2..6cf6577cd 100644
--- a/public/locales/es.json
+++ b/public/locales/es.json
@@ -3780,9 +3780,9 @@
"show_more": "Show more",
"live": "live",
"hero_try": "Try",
- "forge_it": "",
- "hero_forge_placeholder": "",
- "hero_forge_note": "",
+ "forge_it": "Forge it",
+ "hero_forge_placeholder": "describe anything: a brass compass, weathered…",
+ "hero_forge_note": "Free, no sign-up, a real textured model in about a minute. <a href=\"/forge\">Open the full Forge →</a>",
"feed_empty_top": "",
"feed_empty_fresh": ""
},
diff --git a/tests/api/forge-gallery-community.test.js b/tests/api/forge-gallery-community.test.js
index 886272265..63c3e7dad 100644
--- a/tests/api/forge-gallery-community.test.js
+++ b/tests/api/forge-gallery-community.test.js
@@ -15,11 +15,13 @@ import { describe, it, expect, beforeEach, vi } from 'vitest';
const storeEnabledMock = vi.fn(() => true);
const listCreationsMock = vi.fn(async () => []);
const listShowcaseMock = vi.fn(async () => []);
+const countShowcaseMock = vi.fn(async () => 0);
const hashClientMock = vi.fn(() => 'hashed-client');
vi.mock('../../api/_lib/forge-store.js', () => ({
forgeStoreEnabled: (...a) => storeEnabledMock(...a),
listCreations: (...a) => listCreationsMock(...a),
listShowcase: (...a) => listShowcaseMock(...a),
+ countShowcase: (...a) => countShowcaseMock(...a),
hashClient: (...a) => hashClientMock(...a),
}));
@@ -63,9 +65,11 @@ beforeEach(() => {
storeEnabledMock.mockReturnValue(true);
listCreationsMock.mockResolvedValue([]);
listShowcaseMock.mockResolvedValue([]);
+ countShowcaseMock.mockResolvedValue(0);
hashClientMock.mockClear();
listCreationsMock.mockClear();
listShowcaseMock.mockClear();
+ countShowcaseMock.mockClear();
});
describe('GET /api/forge-gallery?scope=community', () => {
@@ -74,13 +78,15 @@ describe('GET /api/forge-gallery?scope=community', () => {
{ id: 'c1', prompt: 'a glazed ceramic teapot', glb_url: 'https://cdn/x.glb', preview_image_url: 'https://cdn/x.png', vote_count: 0, voted: false },
];
listShowcaseMock.mockResolvedValue(rows);
+ countShowcaseMock.mockResolvedValue(137); // full community count — social proof
const res = mkRes();
// Deliberately no x-forge-client header — community (fresh) must not need one.
await handler(mkReq('/api/forge-gallery?scope=community&limit=12'), res);
expect(res.statusCode).toBe(200);
- expect(parsed(res)).toEqual({ enabled: true, creations: rows, sort: 'fresh', window: 'all' });
+ // `total` carries the full community model count independent of the page.
+ expect(parsed(res)).toEqual({ enabled: true, creations: rows, total: 137, sort: 'fresh', window: 'all' });
// Anonymous read → no voter key resolved, default fresh/all ordering.
expect(listShowcaseMock).toHaveBeenCalledWith({ limit: 12, sort: 'fresh', window: 'all', voterKey: null });
expect(listCreationsMock).not.toHaveBeenCalled();
@@ -90,12 +96,13 @@ describe('GET /api/forge-gallery?scope=community', () => {
it('serves the Forge-Off board on sort=top&window=week', async () => {
const rows = [{ id: 'c2', prompt: 'a low-poly red fox', glb_url: 'https://cdn/f.glb', vote_count: 5, voted: false }];
listShowcaseMock.mockResolvedValue(rows);
+ countShowcaseMock.mockResolvedValue(42);
const res = mkRes();
await handler(mkReq('/api/forge-gallery?scope=community&sort=top&window=week&limit=24'), res);
expect(res.statusCode).toBe(200);
- expect(parsed(res)).toEqual({ enabled: true, creations: rows, sort: 'top', window: 'week' });
+ expect(parsed(res)).toEqual({ enabled: true, creations: rows, total: 42, sort: 'top', window: 'week' });
expect(listShowcaseMock).toHaveBeenCalledWith({ limit: 24, sort: 'top', window: 'week', voterKey: null });
});
diff --git a/workers/avatar-reconstruction/README.md b/workers/avatar-reconstruction/README.md
index b221e18dc..8ea84ecb3 100644
--- a/workers/avatar-reconstruction/README.md
+++ b/workers/avatar-reconstruction/README.md
@@ -1,6 +1,42 @@
# Avatar Reconstruction Service
-FastAPI service running InstantMesh on a Cloud Run GPU instance (NVIDIA L4). Accepts 1–6 face photos, synthesizes 6 multi-view renders via Zero123++, reconstructs a textured GLB mesh via InstantMesh, and stores the result in Cloud Storage.
+FastAPI service on a Cloud Run GPU instance (NVIDIA L4) that turns 1–6 selfie
+photos into a rigged, animation-ready GLB avatar and stores it in Cloud Storage.
+Same external contract the three.ws backend (`api/_providers/gcp.js`) already
+speaks — `POST /reconstruct` → `GET /jobs/:id`.
+
+## Pipeline
+
+The avatar is built on a fixed-topology Wolf3D/RPM template head+body that ships
+pre-rigged with a humanoid skeleton and **52 ARKit blendshapes + 15 visemes**
+(the same architecture Avaturn uses: fit a person onto a rigged template, don't
+generate an arbitrary mesh). Two phases, both commercial-clean:
+
+1. **Face texture transfer** (`face_pipeline.py`) — MediaPipe FaceLandmarker →
+ TPS-warp the selfie into the template's skin UV → composite over the face
+ oval → sample and tint skin / hair / eye colour.
+2. **Face geometry morph** (`face_geometry.py`, Phase 2) — recover the person's
+ actual 3D face shape (width, jaw, nose projection, brow, cheekbones) from the
+ same 468 MediaPipe landmarks and reshape the template head to match, so the
+ avatar reads as *that person* instead of their texture on a generic head.
+ Umeyama-aligns the landmarks to MediaPipe's neutral canonical face, carries
+ the identity residual onto the head's corresponding vertices (precomputed
+ nearest-vertex map), and diffuses it with a normalised-Gaussian RBF that fades
+ to zero off the face. Vertex count/order are preserved, so `glb_ops.set_head_geometry`
+ writes it back **without disturbing skinning or any blendshape**.
+
+`precompute_uv.py` builds `face_uv_map.json` at image-build time: the canonical
+face model, the landmark→head-vertex correspondence, and the skin UV mapping.
+
+Toggle Phase 2 with `GEOMETRY_MORPH` (default `1`; set `0` for texture-only). If
+the map lacks geometry fields or the morph raises, the job degrades cleanly to
+texture-only — the shape refinement never fails a reconstruction.
+
+Everything above is Apache-2.0 / MIT-clean (MediaPipe, numpy, scipy) — no
+non-commercial 3DMM (FLAME/BFM/SMPL) is used. See
+[`docs/avatar-reconstruction.md`](../../docs/avatar-reconstruction.md) for the
+fidelity roadmap (FaceLift dense geometry + Imagen texture inpaint, then an
+Anny/MakeHuman CC0 body to drop the RPM-template dependency).
## Prerequisites
@@ -84,7 +120,7 @@ Poll for status.
### GET /health
-Returns `{ "ok": true, "device": "cuda", "model_loaded": true }`.
+Returns `{ "ok": true, "pipeline": "face_texture_transfer_v2", "model_loaded": true, "geometry_morph": true }`.
## Local development (CPU only, no GPU)
diff --git a/workers/avatar-reconstruction/main.py b/workers/avatar-reconstruction/main.py
index 0186e0803..b52a69767 100644
--- a/workers/avatar-reconstruction/main.py
+++ b/workers/avatar-reconstruction/main.py
@@ -175,9 +175,11 @@ async def get_job(job_id: str, authorization: str = Header(...)) -> dict:
@app.get("/health")
async def health() -> dict:
uv_ready = (face_pipeline.HERE / "face_uv_map.json").exists()
+ geometry_ready = face_pipeline.GEOMETRY_MORPH_ENABLED and face_pipeline._get_face_map() is not None
return {
"ok": True,
- "pipeline": "face_texture_transfer_v1",
+ "pipeline": "face_texture_transfer_v2" if geometry_ready else "face_texture_transfer_v1",
"model_loaded": uv_ready,
"uv_map_ready": uv_ready,
+ "geometry_morph": bool(geometry_ready),
}