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.

fix(thumbnails): aim the GLB thumbnail camera from the model's shape so flat and long objects stop rendering as slivers

nirholasc98749dccece
diff --git a/scripts/glb-thumbnail-harness.html b/scripts/glb-thumbnail-harness.html
index 6cf0917d7..2febe15c0 100644
--- a/scripts/glb-thumbnail-harness.html
+++ b/scripts/glb-thumbnail-harness.html
@@ -28,6 +28,17 @@
<script type="module">
const mv = document.getElementById('mv');
+ // theta: swing round so the longer horizontal side faces the camera instead
+ // of pointing at it. phi: look down on something flat, across at something
+ // tall. "auto" radius still fits the whole bounding sphere.
+ function orbitFor({ x, y, z }) {
+ const footprint = Math.max(x, z) || 1;
+ const flat = y < 0.35 * footprint;
+ const phi = flat ? 42 : y > 1.6 * footprint ? 80 : 68;
+ const theta = z > 1.4 * x ? 62 : 28;
+ return `${theta}deg ${phi}deg auto`;
+ }
+
// Load a GLB by (same-origin) URL, wait for it to render, frame it, and
// return a PNG data URL. Called by the playwright driver via evaluate().
window.__renderGlb = async (url) => {
@@ -39,11 +50,20 @@
clearTimeout(to);
mv.removeEventListener('error', onError);
try {
+ // Choose the camera from the model's own shape. One fixed, nearly
+ // side-on view works for a chair and fails for anything flat or
+ // long: a wrench or a sword lying on the ground was shot edge-on
+ // and came out as a sliver a few pixels wide.
+ mv.cameraOrbit = orbitFor(mv.getDimensions());
+ mv.jumpCameraToGoal();
// Let a couple of frames settle so lighting/framing is stable.
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
mv.dismissPoster?.();
await new Promise((r) => setTimeout(r, 250));
- const blob = await mv.toBlob({ mimeType: 'image/png', idealAspect: true });
+ // Always the full square frame. Cropping to the model's "ideal
+ // aspect" is what turned a thin object into a 73px-wide poster,
+ // and every card in a gallery wants the same shape anyway.
+ const blob = await mv.toBlob({ mimeType: 'image/png', idealAspect: false });
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = () => reject(new Error('blob read failed'));