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.

test(stylize): cover the textured-mesh color path the forge actually sends

nirholasfdd2f2414036
diff --git a/workers/stylize/test_stylize.py b/workers/stylize/test_stylize.py
index 3546917d4..51f0cdf67 100644
--- a/workers/stylize/test_stylize.py
+++ b/workers/stylize/test_stylize.py
@@ -22,6 +22,7 @@ os.environ.setdefault("GCS_BUCKET", "test-bucket")
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import numpy as np # noqa: E402
+import PIL.Image # noqa: E402
import trimesh # noqa: E402
from pydantic import ValidationError # noqa: E402
@@ -159,6 +160,36 @@ check(
str(sampled[0]),
)
+# A textured mesh is the forge's common case, and until 2026-08-11 it was the
+# one that lost its colors: to_color() returns a ColorVisuals with no mesh
+# attached, so reading .face_colors on it raises and everything fell through to
+# the flat default.
+textured = trimesh.creation.box(extents=(1, 1, 1))
+texture = PIL.Image.new("RGB", (4, 4), (17, 200, 90))
+textured.visual = trimesh.visual.TextureVisuals(
+ uv=np.zeros((len(textured.vertices), 2)),
+ material=trimesh.visual.material.PBRMaterial(baseColorTexture=texture),
+)
+check("a textured mesh is read as a texture", textured.visual.kind == "texture")
+texture_sample = main._source_color_sampler(textured)(textured.triangles_center)
+check(
+ "a texture's colors survive instead of falling back",
+ texture_sample.shape == (len(textured.faces), 4)
+ and np.all(texture_sample[:, :3] == np.array([17, 200, 90], dtype=np.uint8)),
+ str(texture_sample[0]),
+)
+
+face_painted = trimesh.creation.box(extents=(1, 1, 1))
+face_painted.visual.face_colors = np.tile(
+ np.array([9, 130, 240, 255], dtype=np.uint8), (len(face_painted.faces), 1)
+)
+face_sample = main._source_color_sampler(face_painted)(face_painted.triangles_center)
+check(
+ "face colors survive",
+ np.all(face_sample[:, 2] == 240),
+ str(face_sample[0]),
+)
+
plain = trimesh.creation.box(extents=(1, 1, 1))
plain.visual = trimesh.visual.ColorVisuals(mesh=plain)
default_sample = main._source_color_sampler(plain)(plain.triangles_center)