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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(garment-forge): headwear placement is contain-fit
nirholas3578a48ab50f
diff --git a/workers/garment-forge/garment_glb.py b/workers/garment-forge/garment_glb.pyindex 317bfef68..9cb19c44b 100644--- a/workers/garment-forge/garment_glb.py+++ b/workers/garment-forge/garment_glb.py@@ -97,7 +97,12 @@ SLOT_BOXES = {"bottom": {"center": (0.0, 0.50, 0.02), "size": (0.50, 0.90, 0.35), "fit": 1},"footwear": {"center": (0.0, 0.09, 0.07), "size": (0.60, 0.18, 0.30), "fit": 2},"hair": {"center": (0.0, 1.58, 0.03), "size": (0.30, 0.25, 0.30), "fit": 0},- "headwear": {"center": (0.0, 1.60, 0.03), "size": (0.30, 0.22, 0.30), "fit": 0},+ # Headwear is CONTAIN-fit (bounded on every axis): generated caps carry+ # deep brims, so scaling by width alone let a 2:1 depth:width cap jut some+ # 30 cm past the face (walk-gait audit 2026-07-26: cap p95 21-23 cm vs the+ # 15 cm slot ceiling). Containing the whole mesh in the box sizes the dome+ # to the skull and the brim comes along at cap proportions.+ "headwear": {"center": (0.0, 1.60, 0.03), "size": (0.30, 0.22, 0.30), "fit": "contain"},"glasses": {"center": (0.0, 1.547, 0.11), "size": (0.18, 0.08, 0.12), "fit": 0},"accessory": {"center": (0.0, 1.20, 0.05), "size": (0.35, 0.35, 0.25), "fit": 0},}@@ -159,9 +164,16 @@ def garment_placement(meshes: list[trimesh.Trimesh], slot: str, yaw_deg: float =lo, hi = _bounds(rotated)extent = hi - lofit = box["fit"]- if extent[fit] <= 1e-9:- raise ValueError(f"degenerate garment mesh (zero extent on fit axis {fit})")- scale = box["size"][fit] / extent[fit]+ if fit == "contain":+ # Uniform scale bounded by EVERY axis: the largest scale at which the+ # whole mesh still fits inside the slot box, whatever its aspect.+ if np.any(extent <= 1e-9):+ raise ValueError("degenerate garment mesh (zero extent on a contain axis)")+ scale = float(np.min(np.asarray(box["size"], dtype=np.float64) / extent))+ else:+ if extent[fit] <= 1e-9:+ raise ValueError(f"degenerate garment mesh (zero extent on fit axis {fit})")+ scale = box["size"][fit] / extent[fit]center = (lo + hi) / 2.0target = np.array(box["center"], dtype=np.float64)diff --git a/workers/garment-forge/test_garment_glb.py b/workers/garment-forge/test_garment_glb.pyindex 7623cf7fe..4ba22c942 100644--- a/workers/garment-forge/test_garment_glb.py+++ b/workers/garment-forge/test_garment_glb.py@@ -245,6 +245,20 @@ single = trimesh.creation.box(extents=(0.1, 0.1, 0.3))check("single component is not snapped",snap_pair_to_feet([single.copy()])[0].centroid[0] == single.centroid[0])+# Headwear is contain-fit: a cap with a deep brim (depth 2x width) must be+# bounded by the box on EVERY axis, so depth becomes the limiting dimension+# and the width scales down with it instead of blowing the brim past the face.+cap = trimesh.creation.box(extents=(1.0, 0.9, 2.0))+head_place = garment_placement([cap], "headwear")+placed_cap = cap.copy()+placed_cap.apply_transform(head_place)+head_box = SLOT_BOXES["headwear"]+cap_ext = placed_cap.bounds[1] - placed_cap.bounds[0]+check("headwear contained on depth", abs(cap_ext[2] - head_box["size"][2]) < 1e-6,+ f"depth={cap_ext[2]}")+check("headwear width shrinks with depth", cap_ext[0] <= head_box["size"][0] + 1e-9,+ f"width={cap_ext[0]}")+# ── composition ─────────────────────────────────────────────────────────────composite = compose_scene(box_glb, plain_body_glb(), "top")