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
feat: iso-game polish — ambient crowd, spin wheel, agent commerce
nirholas9f0afcda7540
diff --git a/pages/mocap-studio.html b/pages/mocap-studio.htmlindex 1ca3587fd..7865df3ce 100644--- a/pages/mocap-studio.html+++ b/pages/mocap-studio.html@@ -50,27 +50,6 @@button { font-family: inherit; cursor: pointer; }::selection { background: var(--accent); color: #fff; }- /* ── Site header ───────────────────────────────────── */- .site-header {- display: flex;- align-items: center;- gap: 0;- padding: 0 32px;- height: 56px;- position: sticky;- top: 0;- z-index: 100;- }- .site-header-brand h1 {- margin: 0;- font-size: inherit;- font-weight: inherit;- line-height: inherit;- }- @media (max-width: 640px) {- .site-header { padding: 0 20px; }- }-/* ── Page layout ───────────────────────────────────── */.page-wrap {flex: 1;diff --git a/src/game/agent-commerce.js b/src/game/agent-commerce.jsindex edbc28acf..826e19e8d 100644--- a/src/game/agent-commerce.js+++ b/src/game/agent-commerce.js@@ -32,16 +32,11 @@ const INTERACT_RANGE = 6.5; // how close the player must be to trigger a rouconst ROUND_COOLDOWN_MS = 9000; // min time between paid rounds (one real payment each)const BUBBLE_MS = 5200;-// The models NOVA pays to have inspected, rotated each round for variety. Each is-// a public https GLB (the validator only fetches public URLs) — three.ws's own-// avatars, so the exchange stays on-brand and never references any coin/token.-const MODELS = [- { name: 'default.glb', url: 'https://three.ws/avatars/default.glb' },- { name: 'cz.glb', url: 'https://three.ws/avatars/cz.glb' },-];--// The paid x402 tool NOVA buys from ORACLE — the platform's own glTF inspector.-const PAID_TOOL = 'inspect_model';+// What NOVA buys from ORACLE: the platform's own `tools/list` MCP call — the+// simplest, fastest paid tool (no args, no file fetch), so a round settles in a+// beat. The "intel" is ORACLE's live service catalog (its priced skills).+const PAID_TOOL = 'tools/list';+const PAID_LABEL = 'service catalog';// Stage labels for the HUD stepper, keyed to the SSE events /api/x402-pay emits.const STAGES = [@@ -52,42 +47,44 @@ const STAGES = [{ id: 'done', label: 'Confirmed' },];-// Scripted dialogue, matched to each stage. SELLER runs the inspector; BUYER pays.+// Scripted dialogue, matched to each stage. SELLER hosts the catalog; BUYER pays.const LINES = {seller: {- idle: '3D model intel — a real glTF inspection, settled on-chain in USDC.',+ idle: 'My service catalog — priced skills, paid per call in USDC, on-chain.',challenge: 'Payment challenge issued. Awaiting your signed transfer…',built: 'Transfer received. Forwarding to the facilitator…',- verified: 'Payment verified. Running the inspection…',- settled: 'Funds confirmed on-chain. Sending the report.',- done: (summary) => `Report: ${summary}`,+ verified: 'Payment verified. Pulling the catalog…',+ settled: 'Funds confirmed on-chain. Sending the list.',+ done: (summary) => `Catalog: ${summary}`,error: 'Payment failed — no charge made.',},buyer: {- idle: (name) => `I need a structural read on ${name}. Paying now.`,+ idle: 'I need your live rate card. Paying now.',challenge: 'Building and signing the Solana transfer…',built: 'Signed. Sending to the facilitator for verification.',verified: 'Verified on-chain. Waiting on settlement…',- settled: 'Settled. Collecting my report.',- done: (verts) => `Report received — ${verts}. Filing it.`,+ settled: 'Settled. Collecting the catalog.',+ done: (count) => `Got it — ${count}. Indexing your services.`,error: 'Transaction rolled back. Wallet unchanged.',},};-// Pull a one-line summary + a vertex count out of the inspector's text report,-// so the agents can speak it and the receipt can headline it.-function summarizeModelReport(intel) {- const text = intel?.result?.content?.[0]?.text || '';- const lines = text.split('\n').map((l) => l.trim()).filter(Boolean);- const modelLine = lines.find((l) => /^Model:/i.test(l)) || lines[0] || 'model inspected';- const vertLine = lines.find((l) => /Vertices:/i.test(l)) || '';- const verts = (vertLine.match(/Vertices:\s*([\d,]+)/i)?.[1] || '').trim();- const tris = (vertLine.match(/Triangles:\s*([\d,]+)/i)?.[1] || '').trim();- const stat = verts ? `${verts} verts${tris ? ` · ${tris} tris` : ''}` : '';+// Summarize ORACLE's catalog from a tools/list result: how many priced skills it+// offers and the cheapest price, so the agents can speak it and the receipt can+// headline it.+function summarizeCatalog(intel) {+ const tools = intel?.result?.tools || [];+ const n = tools.length;+ const prices = tools+ .map((t) => Number(t?.pricing?.amount_usdc))+ .filter((v) => Number.isFinite(v) && v > 0);+ const min = prices.length ? Math.min(...prices) : null;+ const fromStr = min != null ? `from $${min < 0.01 ? min.toFixed(4) : min.toFixed(2)}` : '';+ const count = n ? `${n} service${n === 1 ? '' : 's'}` : 'catalog ready';return {- headline: modelLine.replace(/^Model:\s*/i, ''),- verts: verts ? `${verts} verts` : 'report ready',- stat,+ headline: n ? `${count} on offer${fromStr ? ` · ${fromStr}` : ''}` : 'catalog delivered',+ count,+ stat: fromStr,isError: !!intel?.result?.isError,};}@@ -411,15 +408,14 @@ export class AgentCommerce {this.lastRoundAt = (typeof performance !== 'undefined' ? performance.now() : 0);this.prompt.classList.remove('ac-show');- const model = MODELS[this.topicIdx % MODELS.length];+ const topic = PAID_LABEL;this.topicIdx++;- const topic = model.name;this._renderPanel({ topic, stage: 'challenge', stageState: 'active' });this.panel.classList.add('ac-show');// Opening beats.- this.buyer.say(LINES.buyer.idle(topic));+ this.buyer.say(LINES.buyer.idle);this._gesture(this.buyer, 'av-call-me');await delay(650);this.seller.say(LINES.seller.idle);@@ -431,10 +427,10 @@ export class AgentCommerce {const res = await fetch('/api/x402-pay', {method: 'POST',headers: { 'content-type': 'application/json', accept: 'text/event-stream' },- // Pay for the platform's own glTF inspector. /api/x402-pay handles the- // Solana USDC payment, then dispatches the MCP tool call and returns- // its report alongside the settlement.- body: JSON.stringify({ tool: PAID_TOOL, args: { url: model.url } }),+ // Pay for the platform's own tools/list MCP call — the simplest paid+ // tool. /api/x402-pay handles the Solana USDC payment, then dispatches+ // the call and returns ORACLE's catalog alongside the settlement.+ body: JSON.stringify({ tool: PAID_TOOL, args: {} }),});if (!res.ok || !res.body) {const text = await res.text().catch(() => '');@@ -472,14 +468,14 @@ export class AgentCommerce {if (!intel || !settled) throw new Error('incomplete response from payment service');// The settlement is on-chain truth; payer/payee/amount live on the result's- // payment block. Surface the inspector's report as the bought "intel".+ // payment block. Surface ORACLE's catalog as the bought "intel".const payment = { ...(intel.payment || {}), ...settled };- const report = summarizeModelReport(intel);+ const report = summarizeCatalog(intel);// Success choreography.this._gesture(this.buyer, 'celebrate');await delay(300);- this.buyer.say(LINES.buyer.done(report.verts));+ this.buyer.say(LINES.buyer.done(report.count));await delay(700);this.seller.say(LINES.seller.done(report.headline));this._gesture(this.seller, 'av-cheering');@@ -526,7 +522,7 @@ export class AgentCommerce {}).join('');this.panel.innerHTML =`<div class="ac-ph">` +- `<span class="ac-pt">NOVA pays ORACLE to inspect <b>${escHtml(topic)}</b> · ${escHtml(amt)}</span>` ++ `<span class="ac-pt">NOVA pays ORACLE for its <b>${escHtml(topic)}</b> · ${escHtml(amt)}</span>` +`<span class="ac-total">${fmtUsd(this.sessionTotal)}</span>` +`</div><div class="ac-steps">${steps}</div>`;}diff --git a/src/game/ambient-crowd.js b/src/game/ambient-crowd.jsindex 0792c03c2..55ff1f8f9 100644--- a/src/game/ambient-crowd.js+++ b/src/game/ambient-crowd.js@@ -18,6 +18,7 @@ import { AnimationManager } from '../animation-manager.js';const AVATAR_DEFAULT = '/avatars/default.glb';const MANIFEST_URL = '/animations/manifest.json';+const GALLERY_URL = '/api/avatars/public?limit=24'; // public avatar gallery — one distinct model per wandererconst CLIP_IDLE = 'idle';const CLIP_WALK = 'av-walk-feminine';const WORLD_RADIUS = 54; // a touch inside the plaza edge@@ -30,6 +31,7 @@ const LINES = ['gm ☀️', 'wen moon', 'lfg 🚀', 'wagmi', 'probably nothing',const _gltf = new GLTFLoader();let _defs = null; // [idle, walk] animation defslet _emotes = null; // a handful of emote defs+let _avatars = null; // pool of public-gallery GLB URLs ([] once the fetch settles)async function loadManifest() {if (_defs) return;@@ -43,11 +45,27 @@ async function loadManifest() {_emotes = manifest.filter((d) => d.name !== CLIP_IDLE && d.name !== CLIP_WALK).slice(0, 6);}-// Load the default avatar into a rig + animation manager. Falls back to a simple-// stand-in so a wanderer is never invisible.-async function buildAvatar(rig, anim) {+// Pull a varied set of real avatars from the public gallery so the crowd reads as+// a living mix of community models rather than one repeated default. Settles to an+// empty array on failure — each wanderer then falls back to AVATAR_DEFAULT.+async function loadAvatarPool() {+ if (_avatars) return;+ let urls = [];try {- const gltf = await _gltf.loadAsync(AVATAR_DEFAULT);+ const r = await fetch(GALLERY_URL, { headers: { accept: 'application/json' } });+ if (r.ok) {+ const { avatars } = await r.json();+ urls = (avatars || []).map((a) => a.model_url || a.base_model_url).filter(Boolean);+ }+ } catch { /* default-avatar fallback below */ }+ _avatars = urls;+}++// Load a gallery avatar (or the default) into a rig + animation manager. Falls+// back to a simple stand-in so a wanderer is never invisible.+async function buildAvatar(rig, anim, url) {+ try {+ const gltf = await _gltf.loadAsync(url || AVATAR_DEFAULT);const model = gltf.scene;model.traverse((n) => { if (n.isMesh) { n.castShadow = true; n.receiveShadow = false; } });const box = new Box3().setFromObject(model);@@ -57,6 +75,9 @@ async function buildAvatar(rig, anim) {if (_defs?.length) { anim.setAnimationDefs(_defs); await anim.loadAll(); await anim.crossfadeTo(CLIP_IDLE, 0); }return Math.max(0.5, box.max.y - box.min.y);} catch {+ // A gallery model that fails to load shouldn't strand the wanderer on a+ // capsule — fall back to the bundled default once before the stand-in.+ if (url && url !== AVATAR_DEFAULT) return buildAvatar(rig, anim, AVATAR_DEFAULT);const body = new Mesh(new CapsuleGeometry(0.32, 0.7, 4, 10), new MeshStandardMaterial({ color: 0x9aa3ad }));body.position.y = 0.85; body.castShadow = true;const head = new Mesh(new SphereGeometry(0.28, 14, 10), new MeshStandardMaterial({ color: 0xc9cdd2 }));@@ -77,7 +98,7 @@ async function playEmote(anim, motion) {}class Wanderer {- constructor(scene, name) {+ constructor(scene, name, avatarUrl) {this.name = name;this.rig = new Group();this.anim = new AnimationManager();@@ -100,7 +121,7 @@ class Wanderer {this._sayIn = 5 + Math.random() * 16;this._emoteIn = 9 + Math.random() * 22;- buildAvatar(this.rig, this.anim).then((h) => { this.height = h; });+ buildAvatar(this.rig, this.anim, avatarUrl).then((h) => { this.height = h; });}_setMotion(m) {if (m === this.motion) return;@@ -162,6 +183,7 @@ class AmbientCrowd {this.list = [];this.active = false;this._names = [...NAMES];+ this._avatarBag = []; // shuffled gallery URLs, drained for distinct assignmentthis._onChat = (n, t) => { try { this.cc.ui?.addChat?.({ name: n, text: t, mine: false }); } catch { /* ui not ready */ } };}_takeName() {@@ -169,9 +191,17 @@ class AmbientCrowd {const i = (Math.random() * this._names.length) | 0;return this._names.splice(i, 1)[0];}+ // Hand out a distinct gallery avatar each time; refill (and reshuffle) only once+ // the bag empties, so we exhaust the pool before any model repeats.+ _takeAvatar() {+ if (!_avatars?.length) return AVATAR_DEFAULT;+ if (!this._avatarBag.length) this._avatarBag = [..._avatars];+ const i = (Math.random() * this._avatarBag.length) | 0;+ return this._avatarBag.splice(i, 1)[0];+ }sync(realCount) {const want = Math.max(0, AMBIENT_TARGET - (realCount | 0));- while (this.list.length < want) this.list.push(new Wanderer(this.cc.scene, this._takeName()));+ while (this.list.length < want) this.list.push(new Wanderer(this.cc.scene, this._takeName(), this._takeAvatar()));while (this.list.length > want) this.list.pop().dispose();// Reflect the livelier population in the HUD's online count.try { this.cc.ui?.setOnline?.((realCount | 0) + this.list.length + 1); } catch { /* ignore */ }@@ -198,10 +228,10 @@ class AmbientCrowd {}// ---- bootstrap: wait for the scene, then run an independent update loop -----function attach() {+async function attach() {const cc = window.__CC__;if (!cc || !cc.scene || !cc.camera) { setTimeout(attach, 300); return; }- loadManifest();+ await Promise.all([loadManifest(), loadAvatarPool()]);const crowd = new AmbientCrowd(cc);let last = performance.now();let realCount = -1;diff --git a/src/game/iso-game.css b/src/game/iso-game.cssindex 174a5012c..57d8ebe4f 100644--- a/src/game/iso-game.css+++ b/src/game/iso-game.css@@ -279,6 +279,20 @@ body.kg-loading-cursor {.kg-toast--market {border-color: rgba(110, 231, 176, 0.5);}+.kg-toast-link {+ color: var(--kg-text);+ pointer-events: auto;+ text-decoration: underline;+ text-underline-offset: 2px;+ text-decoration-color: rgba(110, 231, 176, 0.6);+ white-space: nowrap;+ transition: text-decoration-color 0.15s;+}+.kg-toast-link:hover,+.kg-toast-link:focus-visible {+ text-decoration-color: var(--kg-text);+ outline: none;+}/* Contextual action bar (cook at a Roast Pit, eat to heal). Buttons reveal onlywhen the action is actually possible; see _updateActions in iso-game.js. */diff --git a/src/game/iso-game.js b/src/game/iso-game.jsindex 8c08926c2..1b6b69238 100644--- a/src/game/iso-game.js+++ b/src/game/iso-game.js@@ -1550,6 +1550,7 @@ export class IsoGame {const latest = await conn.getLatestBlockhash('confirmed');await conn.confirmTransaction({ signature: sig, blockhash: latest.blockhash, lastValidBlockHeight: latest.lastValidBlockHeight }, 'confirmed');this.q?.setMarketBusy(id, 'Settling…');+ this._lastMarketSig = sig;this.net?.marketTokenSettle(qd.quote, sig);} catch (err) {const msg = String(err?.message || err);@@ -1566,6 +1567,9 @@ export class IsoGame {const id = s?.id || this._tokenBuy?.id;this._tokenBuy = null;if (id) this.q?.clearMarketBusy(id);+ const sig = this._lastMarketSig;+ this._lastMarketSig = null;+ if (sig) this._toast({ kind: 'market', text: 'Purchase settled on-chain.', href: `https://solscan.io/tx/${sig}`, hrefText: 'View on Solscan ↗' });}// Server rejected a token quote/settle (price feed down, expired quote, failed@@ -2471,14 +2475,26 @@ export class IsoGame {else if ((n?.kind === 'full' || n?.kind === 'tool') && this._cast) this._resolveCast(false);}- _toast({ kind, text }) {+ _toast({ kind, text, href, hrefText }) {if (!text) return;const el = document.createElement('div');el.className = 'kg-toast kg-toast--' + (kind || 'info');el.textContent = text;+ if (href) {+ el.appendChild(document.createTextNode(' '));+ const a = document.createElement('a');+ a.className = 'kg-toast-link';+ a.href = href;+ a.target = '_blank';+ a.rel = 'noopener';+ a.textContent = hrefText || 'view ↗';+ el.appendChild(a);+ }this.hud.toasts.appendChild(el);requestAnimationFrame(() => el.classList.add('kg-toast--in'));- setTimeout(() => { el.classList.remove('kg-toast--in'); setTimeout(() => el.remove(), 300); }, 2600);+ // A toast carrying a link lingers longer so it can actually be clicked.+ const ttl = href ? 7000 : 2600;+ setTimeout(() => { el.classList.remove('kg-toast--in'); setTimeout(() => el.remove(), 300); }, ttl);}// ---------------------------------------------------------------- cooking & fooddiff --git a/src/game/spin-wheel-ui.js b/src/game/spin-wheel-ui.jsindex 95dbe4de2..d26e3a451 100644--- a/src/game/spin-wheel-ui.js+++ b/src/game/spin-wheel-ui.js@@ -300,6 +300,7 @@ class SpinWheel {this.busy = false;this.phase = 'result';this._prep = null;+ const sig = this._sig;this._sig = null;const seg = this.segments?.[m.index];const label = m.label || seg?.label || 'a prize';@@ -307,7 +308,12 @@ class SpinWheel {if (m.overflow > 0) line += ` (${m.overflow} waiting in a bag at your feet — your pack was full)`;this.resultLine.textContent = line;this.resultLine.dataset.kind = seg ? kindOf(seg) : 'stone';- this._status(m.mode === 'paid' ? 'Paid spin settled on-chain.' : 'Free spin used.', 'ok');+ if (m.mode === 'paid' && sig) {+ const url = solanaTxExplorerUrl(NETWORK, sig);+ this._statusNode(el('span', {}, ['Paid spin settled on-chain — ', el('a', { href: url, target: '_blank', rel: 'noopener', text: 'view on Solscan ↗' })]), 'ok');+ } else {+ this._status(m.mode === 'paid' ? 'Paid spin settled on-chain.' : 'Free spin used.', 'ok');+ }if (m.mode === 'free') this._startCountdown();this._sync();}