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.

feat: cache circuit breaker, walk-embed enhancements, and changelog updates

nirholasf23a6e1957d3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4498d0564..522171af5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **API endpoints answer HEAD checks instantly and shrug off cache hiccups** — Two reliability fixes for anything that talks to the three.ws API. Lightweight HEAD requests — the kind uptime monitors, link previews, and agent crawlers send to check an endpoint — used to hang on agent routes until the request timed out; they now return immediately, the same as a GET but without the body. And when our cache store has a rough moment, the platform now trips a fast circuit-breaker and serves from local memory instantly instead of making every request wait on a slow cache write. Live feeds and agent pages stay snappy through a cache blip. `[fix, infra]`
- **Default avatars render again everywhere** — Avatars stopped appearing across the site — the homepage hero, guest avatars, and any embed that falls back to the default character all showed an empty frame. The default avatar was being loaded from an asset host that had gone offline. It now loads from three.ws itself, so default avatars render again on every page and in every embed. `[fix]`
+- **Living Worlds video generator is back online** — The Cosmos text-to-world lane — describe a scene and get a short cinematic video that plays as a living backdrop behind your avatar — had stopped generating: NVIDIA moved the hosted Cosmos model to a new address, so every request came back as an error. We've pointed the lane at the new endpoint and it generates worlds again. (`/cosmos`) `[fix]`
- **Mission Control's live launch feed never goes dark** — The terminal's Live feed streams brand-new pump.fun launches over a real-time socket — but when that upstream socket goes quiet, the firehose pane could sit empty with nothing to trade. The feed now has a live safety net: it also reads pump.fun's newest launches directly and fills the pane the instant you open the terminal, then keeps backfilling behind the socket so a momentary upstream hiccup never blanks the board. Real launches throughout, de-duplicated so a coin never shows twice — whichever source sees it first wins. (`/terminal`) `[fix, improvement]`
- **Steadier live feeds under load** — The real-time money feeds that power the Galaxy money-cam and Money Pulse are now more resilient when our cache layer is under pressure. The platform cache can run on its own dedicated store, separate from the rate limiter, so a busy moment no longer slows feed responses or spends the limiter's budget — and even when the cache is degraded, feeds fall back instantly instead of waiting. You'll see the live maps stay smooth during traffic spikes. `[infra, improvement]`
- **The trader leaderboard is never empty: live top Solana traders until agents take over** — The leaderboard ranks three.ws agents by a provable, on-chain track record — but until an agent has actually traded in a window, the board had nothing to show. Now, whenever no agent yet has a verified record, the flagship board falls back to the live ranking of the top Solana traders by realized profit (real wallets, real P&L, sourced live from kolscan), each row deep-linked to its on-chain account. The moment an agent earns a record it takes precedence again. Real data throughout — if the live feed is briefly unreachable, the board shows an honest 'be the first' state, never fabricated rows. (`/leaderboard`) `[feature, improvement]`
diff --git a/api/_lib/cache.js b/api/_lib/cache.js
index 0e6c8efb0..a19ddb40a 100644
--- a/api/_lib/cache.js
+++ b/api/_lib/cache.js
@@ -158,6 +158,32 @@ function circuitRecordFailure() {
}
}
+// Throttled warning for the memory-fallback paths. When Upstash is sustainedly
+// degraded in a way the circuit breaker does NOT trip — the production case is a
+// slow SET path interleaved with fast, healthy GETs: each request's successful
+// GET resets the consecutive-failure counter before the SET timeout can push it
+// to the threshold, so the breaker stays (correctly) closed to keep serving cache
+// hits, yet every SET still logs — the per-request "redis SET failed" line floods
+// the logs (hundreds per export window for one hot endpoint). The breaker should
+// not open here (GETs are healthy and worth keeping), so the fix is at the log:
+// collapse repeats of the same category to one line per WARN_THROTTLE_MS, with a
+// suppressed-count digest so a sustained outage stays visible without the flood.
+const WARN_THROTTLE_MS = 30_000;
+const warnState = new Map(); // category -> { lastAt, suppressed }
+
+function warnThrottled(category, message) {
+ const now = Date.now();
+ const st = warnState.get(category) || { lastAt: 0, suppressed: 0 };
+ if (now - st.lastAt < WARN_THROTTLE_MS) {
+ st.suppressed++;
+ warnState.set(category, st);
+ return;
+ }
+ const tail = st.suppressed > 0 ? ` (+${st.suppressed} more in last ${Math.round((now - st.lastAt) / 1000)}s)` : '';
+ console.warn(message + tail);
+ warnState.set(category, { lastAt: now, suppressed: 0 });
+}
+
async function redisCmd(args) {
const target = cacheTarget();
if (!target) throw new Error('cache redis not configured');
@@ -197,7 +223,7 @@ export async function cacheGet(key) {
memoPut(key, value);
return value;
} catch (err) {
- if (!err?.circuitOpen) console.warn('[cache] redis GET failed, using memory fallback:', err?.message);
+ if (!err?.circuitOpen) warnThrottled('GET', `[cache] redis GET failed, using memory fallback: ${err?.message}`);
return memGet(key);
} finally {
inflightGets.delete(key);
@@ -214,7 +240,7 @@ export async function cacheSet(key, value, ttlSeconds = 60) {
await redisCmd(['SET', key, payload, 'EX', String(ttlSeconds)]);
memoPut(key, value); // keep the memo coherent with what we just wrote
} catch (err) {
- if (!err?.circuitOpen) console.warn('[cache] redis SET failed, using memory fallback:', err?.message);
+ if (!err?.circuitOpen) warnThrottled('SET', `[cache] redis SET failed, using memory fallback: ${err?.message}`);
readMemo.delete(key);
memSet(key, value, ttlSeconds);
}
@@ -256,7 +282,7 @@ export async function acquireLock(key, ttlSeconds) {
const res = await redisCmd(['SET', key, '1', 'NX', 'EX', String(ttlSeconds)]);
return res === 'OK';
} catch (err) {
- if (!err?.circuitOpen) console.warn('[cache] acquireLock failed, proceeding without lock:', err?.message);
+ if (!err?.circuitOpen) warnThrottled('acquireLock', `[cache] acquireLock failed, proceeding without lock: ${err?.message}`);
return true;
}
}
diff --git a/api/_lib/env.js b/api/_lib/env.js
index fab70c17f..1d1497cb2 100644
--- a/api/_lib/env.js
+++ b/api/_lib/env.js
@@ -344,8 +344,8 @@ export const env = {
// Optional override for the hosted NVIDIA Cosmos world-model invoke URL used by
// the Cosmos text→world video lane (api/_providers/nvidia-cosmos.js, api/cosmos.js).
- // Defaults to the published genai gateway path for cosmos-predict
- // (https://ai.api.nvidia.com/v1/genai/nvidia/cosmos-predict1-7b); set this only
+ // Defaults to the published cosmos gateway path for cosmos-predict
+ // (https://ai.api.nvidia.com/v1/cosmos/nvidia/cosmos-predict1-7b); set this only
// to pin a different Cosmos model/version or a self-hosted NIM without a code
// deploy. Confirm the live contract for an account with
// `node scripts/verify-nvidia-cosmos.mjs`. Auth reuses NVIDIA_API_KEY.
diff --git a/api/_providers/nvidia-cosmos.js b/api/_providers/nvidia-cosmos.js
index 9e5687a72..3abf849d6 100644
--- a/api/_providers/nvidia-cosmos.js
+++ b/api/_providers/nvidia-cosmos.js
@@ -41,8 +41,8 @@
// the other providers. On an unrecognized shape the warn logs the
// top-level keys so the next schema drift is visible without guessing.
//
-// The default INVOKE_URL follows NVIDIA's published genai gateway path for
-// cosmos-predict and is overridable (without a redeploy) via
+// The default INVOKE_URL follows NVIDIA's published cosmos gateway path
+// (/v1/cosmos/nvidia/cosmos-predict1-7b) and is overridable (without a redeploy) via
// NVIDIA_COSMOS_INVOKE_URL — confirm the live contract for an account with
// `node scripts/verify-nvidia-cosmos.mjs`.
//
@@ -55,7 +55,7 @@ import { env } from '../_lib/env.js';
// Published genai gateway path for the hosted cosmos-predict world model. The
// `command` input's leading token (text2world) selects the modality, so one
// endpoint serves the whole predict line.
-const DEFAULT_COSMOS_INVOKE_URL = 'https://ai.api.nvidia.com/v1/genai/nvidia/cosmos-predict1-7b';
+const DEFAULT_COSMOS_INVOKE_URL = 'https://ai.api.nvidia.com/v1/cosmos/nvidia/cosmos-predict1-7b';
const NVCF_STATUS_URL = 'https://api.nvcf.nvidia.com/v2/nvcf/pexec/status';
// Cosmos predict renders a fixed ~5 s 1280×704 @ 24fps clip; the prompt is the
diff --git a/data/changelog.json b/data/changelog.json
index 1829e695d..ab3a060e4 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,13 @@
{
"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-26",
+ "title": "Living Worlds video generator is back online",
+ "summary": "The Cosmos text-to-world lane — describe a scene and get a short cinematic video that plays as a living backdrop behind your avatar — had stopped generating: NVIDIA moved the hosted Cosmos model to a new address, so every request came back as an error. We've pointed the lane at the new endpoint and it generates worlds again.",
+ "tags": ["fix"],
+ "link": "/cosmos"
+ },
{
"date": "2026-06-26",
"title": "API endpoints answer HEAD checks instantly and shrug off cache hiccups",
diff --git a/pages/walk-embed.html b/pages/walk-embed.html
index 0a36215ab..5fb3d2372 100644
--- a/pages/walk-embed.html
+++ b/pages/walk-embed.html
@@ -108,15 +108,184 @@
}
#walk-status.is-error { color: #f87171; border-color: rgba(248, 113, 113, 0.5); }
#walk-status.is-hidden { opacity: 0; }
+
+ /* ── Loading poster ───────────────────────────────────────────────
+ A silhouette + shimmer shown until the avatar's first frame, so a
+ host page never sees a blank transparent hole while the GLB loads.
+ Fades out (and is removed) on walk:ready. */
+ #walk-poster {
+ position: fixed;
+ inset: 0;
+ z-index: 4;
+ display: flex;
+ align-items: flex-end;
+ justify-content: center;
+ pointer-events: none;
+ transition: opacity 0.45s ease;
+ }
+ #walk-poster.is-hidden { opacity: 0; }
+ #walk-poster svg {
+ width: 38%;
+ max-width: 180px;
+ height: auto;
+ margin-bottom: 8%;
+ opacity: 0.5;
+ }
+ #walk-poster .poster-shimmer {
+ fill: rgba(255, 255, 255, 0.16);
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ #walk-poster svg { animation: poster-bob 2.4s ease-in-out infinite; }
+ #walk-poster .poster-shimmer { animation: poster-pulse 1.6s ease-in-out infinite; }
+ }
+ @keyframes poster-bob {
+ 0%, 100% { transform: translateY(0); }
+ 50% { transform: translateY(-5px); }
+ }
+ @keyframes poster-pulse {
+ 0%, 100% { opacity: 0.35; }
+ 50% { opacity: 0.85; }
+ }
+
+ /* ── Control hint ─────────────────────────────────────────────────
+ One-time affordance so visitors discover the avatar is interactive.
+ Dismissed on first input or after a timeout (see walk-embed.js). */
+ #walk-hint {
+ position: fixed;
+ z-index: 6;
+ left: 50%;
+ top: 14px;
+ transform: translate(-50%, -6px);
+ max-width: calc(100% - 28px);
+ display: flex;
+ align-items: center;
+ gap: 7px;
+ background: rgba(17, 17, 17, 0.74);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: 999px;
+ padding: 7px 14px;
+ font-size: 11.5px;
+ line-height: 1.3;
+ color: #e4e4e7;
+ white-space: nowrap;
+ backdrop-filter: blur(10px);
+ -webkit-backdrop-filter: blur(10px);
+ pointer-events: none;
+ opacity: 0;
+ transition: opacity 0.35s ease, transform 0.35s ease;
+ }
+ #walk-hint.is-visible { opacity: 1; transform: translate(-50%, 0); }
+ #walk-hint svg { flex: 0 0 auto; opacity: 0.8; }
+
+ /* ── Gesture buttons (opt-in via ?gestures=true) ──────────────────── */
+ #walk-gestures {
+ position: fixed;
+ z-index: 6;
+ right: 14px;
+ bottom: calc(58px + env(safe-area-inset-bottom, 0));
+ display: none;
+ flex-direction: column;
+ gap: 8px;
+ }
+ #walk-stage[data-gestures="true"] #walk-gestures { display: flex; }
+ .walk-gesture-btn {
+ width: 44px;
+ height: 44px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 20px;
+ border-radius: 50%;
+ border: 1px solid rgba(255, 255, 255, 0.14);
+ background: rgba(17, 17, 17, 0.66);
+ color: #fafafa;
+ cursor: pointer;
+ padding: 0;
+ backdrop-filter: blur(10px);
+ -webkit-backdrop-filter: blur(10px);
+ transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
+ pointer-events: auto;
+ }
+ .walk-gesture-btn:hover { background: rgba(40, 40, 40, 0.82); border-color: rgba(255, 255, 255, 0.28); }
+ .walk-gesture-btn:active { transform: scale(0.92); }
+ .walk-gesture-btn:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
+
+ /* ── Attribution badge ────────────────────────────────────────────
+ The embed is the distribution channel — every dropped avatar links
+ home. Subtle by default; hidden entirely with ?badge=false. */
+ #walk-badge {
+ position: fixed;
+ z-index: 7;
+ right: 10px;
+ bottom: calc(10px + env(safe-area-inset-bottom, 0));
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ padding: 4px 9px 4px 7px;
+ font-size: 10.5px;
+ font-weight: 600;
+ letter-spacing: 0.01em;
+ color: #d4d4d8;
+ text-decoration: none;
+ background: rgba(10, 10, 10, 0.5);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: 999px;
+ backdrop-filter: blur(8px);
+ -webkit-backdrop-filter: blur(8px);
+ opacity: 0.62;
+ transition: opacity 0.18s ease, background 0.18s ease;
+ }
+ #walk-badge:hover { opacity: 1; background: rgba(20, 20, 24, 0.78); }
+ #walk-badge:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; opacity: 1; }
+ #walk-badge .badge-dot {
+ width: 13px;
+ height: 13px;
+ flex: 0 0 auto;
+ border-radius: 4px;
+ background: linear-gradient(135deg, #6366f1, #8b5cf6);
+ }
</style>
</head>
<body>
<div id="walk-stage" data-controls="joystick">
- <canvas id="walk-canvas"></canvas>
+ <canvas
+ id="walk-canvas"
+ role="img"
+ aria-label="Interactive 3D walking avatar. Use the joystick or W A S D keys to move, drag to look around, and tap the ground to walk there."
+ tabindex="0"
+ ></canvas>
+
+ <!-- Loading poster: silhouette shown until the first avatar frame. -->
+ <div id="walk-poster" aria-hidden="true">
+ <svg viewBox="0 0 64 96" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <circle class="poster-shimmer" cx="32" cy="16" r="11" />
+ <rect class="poster-shimmer" x="18" y="31" width="28" height="42" rx="13" />
+ <rect class="poster-shimmer" x="22" y="68" width="8" height="26" rx="4" />
+ <rect class="poster-shimmer" x="34" y="68" width="8" height="26" rx="4" />
+ </svg>
+ </div>
<div id="walk-joystick" aria-label="Movement joystick"></div>
+ <!-- One-time discovery hint; text is set by the runtime per control mode. -->
+ <div id="walk-hint" role="status" aria-live="polite">
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 11l3 3 8-8"/><path d="M21 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h7"/></svg>
+ <span id="walk-hint-text"></span>
+ </div>
+
+ <!-- Optional end-user gesture controls (?gestures=true). -->
+ <div id="walk-gestures" aria-label="Avatar gestures">
+ <button type="button" class="walk-gesture-btn" data-gesture="wave" title="Wave" aria-label="Make the avatar wave">👋</button>
+ <button type="button" class="walk-gesture-btn" data-gesture="jump" title="Jump" aria-label="Make the avatar jump">⤴️</button>
+ </div>
+
<div id="walk-status">loading avatar…</div>
+
+ <!-- Attribution / made-with badge. Removed when ?badge=false. -->
+ <a id="walk-badge" href="https://three.ws/embed?ref=walk-embed" target="_blank" rel="noopener" title="Make your own — three.ws">
+ <span class="badge-dot" aria-hidden="true"></span>
+ <span>three.ws</span>
+ </a>
</div>
<!--
diff --git a/public/changelog.json b/public/changelog.json
index a0993ad5b..b000a5814 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-26T00:16:41.927Z",
+ "generated_at": "2026-06-26T03:49:16.783Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -27,6 +27,16 @@
"fix"
]
},
+ {
+ "date": "2026-06-26",
+ "type": "update",
+ "title": "Living Worlds video generator is back online",
+ "summary": "The Cosmos text-to-world lane — describe a scene and get a short cinematic video that plays as a living backdrop behind your avatar — had stopped generating: NVIDIA moved the hosted Cosmos model to a new address, so every request came back as an error. We've pointed the lane at the new endpoint and it generates worlds again.",
+ "link": "/cosmos",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-26",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 1f615f9b5..db7cd1532 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -22,6 +22,14 @@
<category>fix</category>
<description>Avatars stopped appearing across the site — the homepage hero, guest avatars, and any embed that falls back to the default character all showed an empty frame. The default avatar was being loaded from an asset host that had gone offline. It now loads from three.ws itself, so default avatars render again on every page and in every embed.</description>
</item>
+ <item>
+ <title>Living Worlds video generator is back online</title>
+ <link>https://three.ws/cosmos</link>
+ <guid isPermaLink="false">2026-06-26:Living Worlds video generator is back online</guid>
+ <pubDate>Fri, 26 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The Cosmos text-to-world lane — describe a scene and get a short cinematic video that plays as a living backdrop behind your avatar — had stopped generating: NVIDIA moved the hosted Cosmos model to a new address, so every request came back as an error. We've pointed the lane at the new endpoint and it generates worlds again.</description>
+ </item>
<item>
<title>Mission Control's live launch feed never goes dark</title>
<link>https://three.ws/terminal</link>
diff --git a/public/features.json b/public/features.json
index 600ae4a0a..1f9c4c84b 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-26T00:16:41.905Z",
+ "generated_at": "2026-06-26T03:49:16.761Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index a488ad85d..755e54062 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -56,25 +56,6 @@
.sm-brand img { width: 24px; height: 24px; border-radius: 5px; }
.sm-brand:hover { text-decoration: none; }
</style>
-
- <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
- <meta property="og:type" content="website">
- <meta property="og:site_name" content="three.ws">
- <meta property="og:locale" content="en_US">
- <meta property="og:title" content="Sitemap · three.ws">
- <meta property="og:description" content="Human-readable index of every page on three.ws.">
- <meta property="og:url" content="https://three.ws/sitemap">
- <meta property="og:image" content="https://three.ws/api/page-og?s=main&amp;t=Sitemap&amp;d=Human-readable+index+of+every+page+on+three.ws.&amp;p=%2Fsitemap">
- <meta property="og:image:width" content="1200">
- <meta property="og:image:height" content="630">
- <meta property="og:image:type" content="image/png">
- <meta property="og:image:alt" content="Sitemap — three.ws">
- <meta name="twitter:card" content="summary_large_image">
- <meta name="twitter:site" content="@trythreews">
- <meta name="twitter:title" content="Sitemap · three.ws">
- <meta name="twitter:description" content="Human-readable index of every page on three.ws.">
- <meta name="twitter:image" content="https://three.ws/api/page-og?s=main&amp;t=Sitemap&amp;d=Human-readable+index+of+every+page+on+three.ws.&amp;p=%2Fsitemap">
- <script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"WebPage","name":"Sitemap","description":"Human-readable index of every page on three.ws.","url":"https://three.ws/sitemap","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"},"primaryImageOfPage":"https://three.ws/api/page-og?s=main&t=Sitemap&d=Human-readable+index+of+every+page+on+three.ws.&p=%2Fsitemap"}]}</script>
</head>
<body>
<header class="sm-topbar">
diff --git a/scripts/verify-nvidia-cosmos.mjs b/scripts/verify-nvidia-cosmos.mjs
index 904fabba4..187bb7410 100644
--- a/scripts/verify-nvidia-cosmos.mjs
+++ b/scripts/verify-nvidia-cosmos.mjs
@@ -30,7 +30,7 @@ if (!KEY) {
}
const INVOKE_URL =
- process.env.NVIDIA_COSMOS_INVOKE_URL || 'https://ai.api.nvidia.com/v1/genai/nvidia/cosmos-predict1-7b';
+ process.env.NVIDIA_COSMOS_INVOKE_URL || 'https://ai.api.nvidia.com/v1/cosmos/nvidia/cosmos-predict1-7b';
const STATUS_URL = 'https://api.nvcf.nvidia.com/v2/nvcf/pexec/status';
const args = process.argv.slice(2);
diff --git a/src/walk-embed.js b/src/walk-embed.js
index bc845cf92..929194029 100644
--- a/src/walk-embed.js
+++ b/src/walk-embed.js
@@ -26,9 +26,12 @@ import {
MeshStandardMaterial,
PCFShadowMap,
PerspectiveCamera,
+ Plane,
PMREMGenerator,
+ Raycaster,
Scene,
ShadowMaterial,
+ Vector2,
Vector3,
WebGLRenderer,
} from 'three';
@@ -62,6 +65,22 @@ const SPEED_PARAM = (() => {
if (!Number.isFinite(n)) return 1.0;
return Math.min(3, Math.max(0.3, n));
})();
+// Attribution badge ships by default — the embed is the distribution channel, so
+// every dropped avatar links home. `?badge=false` removes it (paid/whitelabel).
+const SHOW_BADGE = params.get('badge') !== 'false' && params.get('badge') !== '0';
+// Opt-in floating wave/jump buttons so a plain iframe visitor can trigger the
+// gestures the postMessage contract already exposes to hosts.
+const SHOW_GESTURE_UI = params.get('gestures') === 'true' || params.get('gestures') === '1';
+// Tap/click the ground to send the avatar there — on by default for interactive
+// control modes, off for non-interactive (controls=none) embeds and ?click=false.
+const CLICK_TO_MOVE = params.get('click') !== 'false' && CONTROLS !== 'none';
+// Honor the viewer's OS "reduce motion" setting: skip the autoplay circle-walk
+// (the avatar settles to idle) so an embed never animates against their wishes.
+const PREFERS_REDUCED_MOTION =
+ typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
+// Idle cursor-glance only on hover-capable (desktop) pointers — on touch there's
+// no persistent cursor to glance toward and it would jitter.
+const HAS_HOVER = typeof matchMedia === 'function' && matchMedia('(hover: hover) and (pointer: fine)').matches;
// Live-tracked state surfaced to the host via the typed contract. `currentAvatarId`
// is the public identifier hosts gave us (?avatar=<id|url>, else the ?agent=<id>
@@ -204,8 +223,16 @@ const stage = document.getElementById('walk-stage');
const canvas = document.getElementById('walk-canvas');
const joystickEl = document.getElementById('walk-joystick');
const statusEl = document.getElementById('walk-status');
+const posterEl = document.getElementById('walk-poster');
+const hintEl = document.getElementById('walk-hint');
+const hintTextEl = document.getElementById('walk-hint-text');
+const gesturesEl = document.getElementById('walk-gestures');
+const badgeEl = document.getElementById('walk-badge');
stage.dataset.controls = CONTROLS;
+stage.dataset.gestures = String(SHOW_GESTURE_UI);
+if (!SHOW_BADGE && badgeEl) badgeEl.remove();
+if (!SHOW_GESTURE_UI && gesturesEl) gesturesEl.remove();
// Apply background. Default is transparent so the host page shows through.
// `?bg=#101820` paints a solid color; `?bg=transparent` is explicit no-op.
@@ -225,6 +252,39 @@ function setStatus(text, { error = false, sticky = false } = {}) {
}
}
+// ── Loading poster ──────────────────────────────────────────────────────────
+// Fades the silhouette out once the first avatar frame is ready, then removes it
+// so it never intercepts pointer events or stays in the a11y tree.
+function hidePoster() {
+ if (!posterEl) return;
+ posterEl.classList.add('is-hidden');
+ setTimeout(() => posterEl.remove(), 500);
+}
+
+// ── Control hint ────────────────────────────────────────────────────────────
+// A one-time discovery affordance: most visitors never realize an embedded
+// avatar is interactive. We show a per-control-mode hint after load and dismiss
+// it on the first real input (or after a timeout) so it never nags.
+let hintDismissed = CONTROLS === 'none'; // non-interactive embeds get no hint
+function maybeShowHint() {
+ if (hintDismissed || !hintEl || !hintTextEl) return;
+ const move = CONTROLS === 'joystick' ? 'Joystick or WASD to move' : 'WASD / arrows to move';
+ const tap = CLICK_TO_MOVE ? ' · tap the ground to walk there' : '';
+ hintTextEl.textContent = `${move} · drag to look${tap}`;
+ hintEl.classList.add('is-visible');
+ clearTimeout(maybeShowHint._t);
+ maybeShowHint._t = setTimeout(dismissHint, 6000);
+}
+function dismissHint() {
+ if (hintDismissed) return;
+ hintDismissed = true;
+ clearTimeout(maybeShowHint._t);
+ if (hintEl) {
+ hintEl.classList.remove('is-visible');
+ setTimeout(() => hintEl.remove(), 400);
+ }
+}
+
// ── Outbound event bus → installEmbedBridge (src/walk-embed-events.js) ──────
// The runtime never touches postMessage itself. It fires typed lifecycle events
// on this tiny in-process bus; the embed bridge (installed from
@@ -403,6 +463,11 @@ const input = {
// Seek target from `walk:goto` — drive toward a world (x,z) then stop within
// GOTO_ARRIVE_EPSILON. Cleared by any live input or a new command.
seek: { active: false, x: 0, z: 0, run: false },
+ // Idle cursor-glance: the avatar gently turns its body toward the pointer when
+ // standing still, so a hovered embed feels like it noticed you. `targetYaw` is
+ // the desired heading (radians) derived from the cursor's horizontal position;
+ // `active` is true only while the pointer is over the canvas on a hover device.
+ glance: { active: false, targetYaw: 0 },
_speedMultiplier: SPEED_PARAM,
};
@@ -428,6 +493,7 @@ if (CONTROLS === 'keyboard' || CONTROLS === 'joystick') {
case 'ShiftLeft': case 'ShiftRight': input.keys.run = true; break;
default: return;
}
+ dismissHint();
});
window.addEventListener('keyup', (e) => {
switch (e.code) {
@@ -458,6 +524,7 @@ if (CONTROLS === 'joystick') {
input.joy.x = data.vector.x;
input.joy.y = data.vector.y;
input.joy.active = Math.hypot(data.vector.x, data.vector.y) > 0.05;
+ if (input.joy.active) dismissHint();
}
});
joystick.on('end', () => {
@@ -557,7 +624,7 @@ async function loadAvatar() {
await animationManager.crossfadeTo(CLIP_IDLE, 0.0);
currentMotion = 'idle';
- if (AUTOPLAY) {
+ if (AUTOPLAY && !PREFERS_REDUCED_MOTION) {
input.autoplay.active = true;
input.autoplay.t = 0;
}
@@ -567,6 +634,8 @@ async function loadAvatar() {
} else {
setStatus('walk it');
}
+ hidePoster();
+ maybeShowHint();
isReady = true;
emit(OUTBOUND.READY, { avatarId: currentAvatarId, env: currentEnv, fallback: usedFallback });
}