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.

Polish arena play scene; ignore root-level scratch artifacts

nirholasd0cda1285d73
diff --git a/.gitignore b/.gitignore
index ccf1d046d..b6c039e71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -240,3 +240,8 @@ scripts/.corr-*
/im-in-love-wit-a-stripper-fast.mp3
/alleyway.glb
/tour.glb
+
+# Root-level scratch/debug artifacts (one-off agent probe scripts + screenshots).
+# Anchored to root so legitimate underscore-prefixed files elsewhere are unaffected.
+/_*.mjs
+/_*.png
diff --git a/src/play/arena-world.js b/src/play/arena-world.js
index 96dd75f80..3854c0024 100644
--- a/src/play/arena-world.js
+++ b/src/play/arena-world.js
@@ -246,9 +246,18 @@ export class ArenaWorld {
return p;
}
- async _makeAvatar(glbUrl, { fallback = '/avatars/default.glb' } = {}) {
+ _loadTemplateTimed(url, ms) {
+ return Promise.race([
+ this._loadTemplate(url),
+ new Promise((_, rej) => setTimeout(() => rej(new Error('glb timeout: ' + url)), ms)),
+ ]);
+ }
+
+ // Load a GLB, falling back to a light known-good rig if the chosen one fails
+ // or stalls — so a crowd never ends up with a missing body.
+ async _makeAvatar(glbUrl, { fallback = '/avatars/mannequin.glb', timeout = 20000 } = {}) {
let gltf;
- try { gltf = await this._loadTemplate(glbUrl); }
+ try { gltf = await this._loadTemplateTimed(glbUrl, timeout); }
catch { gltf = await this._loadTemplate(fallback); }
// Clone so multiple agents can share one downloaded GLB.
const model = cloneSkeleton(gltf.scene);
diff --git a/src/play/arena.js b/src/play/arena.js
index bfdbf4cd2..ee39a36dd 100644
--- a/src/play/arena.js
+++ b/src/play/arena.js
@@ -90,26 +90,7 @@ async function loadAndPlace() {
if (!_placed && board.length) {
_placed = true;
- const positions = arenaPositions(board.length);
- // Spawn sequentially-ish but don't block the loop; stagger for a nice fill.
- board.forEach((row, i) => {
- const av = ROSTER[hash(row.agent_id) % ROSTER.length];
- const pos = positions[i];
- setTimeout(() => {
- world.spawnAgent({
- id: row.agent_id,
- name: row.agent_name || 'Agent',
- glbUrl: av.url,
- position: [pos.x, pos.z],
- facingY: pos.facing,
- leader: i === 0,
- pnlText: fmtSol(row.realized_pnl_sol),
- pnlUp: (row.realized_pnl_sol ?? 0) >= 0,
- thumbnail: row.image || '',
- rank: row.rank,
- }).then((agent) => createLabel(agent)).catch((err) => console.warn('[arena] spawn agent', err));
- }, i * 120);
- });
+ spawnAgentsProgressively(board);
}
// Seed the tape with recent closed trades (oldest first so prepend keeps order).
@@ -135,6 +116,41 @@ async function loadBoardOnly() {
} catch { /* keep last good */ }
}
+// Spawn agents with bounded concurrency. Avatar GLBs are 1–3 MB and share a
+// Draco/KTX2 worker pool — firing all of them at once thrashes the pool and
+// stalls loads. Two workers pull from a queue so avatars pop in steadily and
+// every one resolves. Repeats are instant (the world template-caches by URL).
+const SPAWN_CONCURRENCY = 2;
+async function spawnAgentsProgressively(board) {
+ const positions = arenaPositions(board.length);
+ const queue = board.map((row, i) => ({ row, i, pos: positions[i] }));
+ const worker = async () => {
+ let job;
+ while ((job = queue.shift())) {
+ const { row, i, pos } = job;
+ const av = ROSTER[hash(row.agent_id) % ROSTER.length];
+ try {
+ const agent = await world.spawnAgent({
+ id: row.agent_id,
+ name: row.agent_name || 'Agent',
+ glbUrl: av.url,
+ position: [pos.x, pos.z],
+ facingY: pos.facing,
+ leader: i === 0,
+ pnlText: fmtSol(row.realized_pnl_sol),
+ pnlUp: (row.realized_pnl_sol ?? 0) >= 0,
+ thumbnail: row.image || '',
+ rank: row.rank,
+ });
+ createLabel(agent);
+ } catch (err) {
+ console.warn('[arena] spawn agent', err);
+ }
+ }
+ };
+ await Promise.all(Array.from({ length: SPAWN_CONCURRENCY }, worker));
+}
+
// Arrange agents on a forward-facing arc; #1 elevated at the back-centre.
function arenaPositions(n) {
const out = [];