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
Document $THREE token split/treasury env; feed, IRL and viewer updates
nirholasce3ee57f6399
diff --git a/.env.example b/.env.exampleindex 92fe12ce2..ae664540c 100644--- a/.env.example+++ b/.env.example@@ -675,6 +675,36 @@ QSTASH_TOKEN=QSTASH_CURRENT_SIGNING_KEY=QSTASH_NEXT_SIGNING_KEY=+# ── $THREE token split, quote & treasury wiring ──────────────────────────────+# The $THREE mint and the wallets every priced split routes to. Read by+# api/token/[action].js (quote/settle) and api/cron/rewards-distribute.js.+#+# THREE_TREASURY_WALLET, THREE_REWARDS_WALLET and THREE_QUOTE_SECRET are REQUIRED+# in production: token/config.js + token/quote.js fail closed when they are unset+# (the source of the live `POST /api/token/quote → 503 THREE_TREASURY_WALLET is+# required in production` log entries) rather than silently routing treasury funds+# to a placeholder or signing quotes with the dev key. Set all three in prod.++# Platform $THREE mint. Defaults to the canonical mint; override only for a+# devnet/test mint. There is no other coin — never point this at a different one.+THREE_TOKEN_MINT=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump+# pump.fun mints are 6-decimal. Override only for a non-pump mint.+THREE_TOKEN_DECIMALS=6+# Treasury wallet — receives the treasury share of every split. REQUIRED in prod.+THREE_TREASURY_WALLET=+# Holder-rewards (reflections) wallet — receives the `rewards` share of every+# split; the rewards cron drains it back to holders pro-rata. REQUIRED in prod.+THREE_REWARDS_WALLET=+# Burn address. Defaults to the Solana incinerator (unspendable — tokens sent+# there leave circulation permanently). Override only with another null address.+THREE_BURN_ADDRESS=1nc1nerator11111111111111111111111111111111+# HMAC secret that signs payment quotes so a client cannot tamper with the quoted+# amount or split after the server prices it. REQUIRED in prod. NEVER log this.+THREE_QUOTE_SECRET=+# Validity window (seconds) for an issued quote. Short enough that a quoted price+# can't be exploited after the market moves; long enough to sign + send one tx.+THREE_QUOTE_TTL_S=90+# ── Payments / fees / treasury wiring ────────────────────────────────────────# Recipient wallets for /api/payments/* checkout sessions. Set per-chain EVM# overrides as PAYMENT_RECIPIENT_EVM_<chainId> (e.g. PAYMENT_RECIPIENT_EVM_8453)diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 876f78510..568b65abe 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Embedded avatars never show a blank frame** — A walking-avatar embed whose avatar can't load — a deleted or mistyped ID, a private avatar a public page can't read, or a dropped connection — now shows the default avatar walking with a short 'couldn't load that avatar — showing the default' note, instead of leaving an empty, all-dark frame on the host page. The embed always renders a body. The embed editor now flags an avatar ID it can't find with a clear 'not found' marker and tells you to pick a public or unlisted avatar, rather than silently keeping a dead ID. And owners can now load their own private avatar's 3D file when signed in, which previously failed even for the avatar's owner. (`/embed`) `[fix]`- **Fix the location-proof behind IRL 'agents near me'** — The step that proves you're physically where you say you are — so the 'agents near me' view only reveals pins around your real location, never somewhere you point at from afar — could fail and return an error on every attempt. That same failure meant the privacy check it powers wasn't being enforced. It now works reliably with or without a configured signing secret: locally and in preview it stays open so testing isn't blocked, and in production each nearby read is bound to a genuine, freshly-signed location fix that expires in a few minutes and can't be forged or replayed from a distance. Nothing changes in how you use IRL — your location is still read only to mint the short-lived proof, never stored or logged. (`/irl`) `[fix, security]`- **Fix: agent reputation scores now read correctly** — Two places that read an agent's ERC-8004 reputation were decoding it wrong. The on-chain registry returns the average rating already worked out (and signed, so it can go negative); both the paid reputation MCP tool and the trust check that guards autonomous agent-to-agent payments were dividing that value a second time — understating every score, and turning a negative reputation into a meaninglessly large positive one. The MCP tool was also listening for the wrong on-chain event, so it always reported zero past vouches even when an agent had many. Both now report the true average, handle negative reputations correctly, and surface real review history — so a 'pay only above this score' rule actually does what it says. `[fix]`+- **Fix: token art loads reliably and 3D embeds never blank out** — Hardened two things that could fail quietly on the platform. Token artwork is fetched through our own image proxy so it loads cross-origin without errors; a slow or dead image host could previously hang that proxy until it was killed, leaving art stuck loading — it now bounds every lookup and falls back to a clean on-brand placeholder fast, so art always resolves. And every embedded 3D view (agent stages, model viewers, profile avatars) now degrades to a tasteful 'not available on this device' state instead of throwing when a browser or GPU refuses a WebGL context — so a low-end or locked-down device sees a graceful fallback rather than a broken page. `[fix, infra]`- **Forge polish: engine picker, honest wording, keyboard tabs, full-length remix** — A round of Forge fixes. The engine picker now wraps all eight lanes — NVIDIA, Hunyuan3D, Fast, Meshy, Tripo, Rodin, Stability, Replicate — cleanly inside its selector instead of spilling past the panel edge, so every engine stays readable at a glance. The build estimate is honest to the tab you're on: on Describe it it reads 'renders a preview image, then builds 3D' (it never asked you for an image), on From photos 'builds from your reference photos', and a credit figure now only appears on metered lanes so a free build never reads 'Free · ~N credits'. The Describe it / From photos / From a sketch tabs are now fully keyboard-navigable with the arrow keys and announce correctly to screen readers. And opening a remix link keeps your whole prompt — long prompts are no longer clipped to 300 characters. (`/forge`) `[fix, improvement]`- **Free Forge on the IBM demo stays reliable while the GPU warms up** — The free, no-wallet 'forge a 3D model' widget on the IBM partnership page no longer shows a false 'briefly unreachable' error when the free GPU is cold. It used to fire up to six generation requests behind a single click, which spent the free lane's hourly limit about six times faster — a few tries could lock you out — and a slow cold start would surface as an error even though the model was still on its way. Now it makes one request per click (the server already falls back across NVIDIA, TRELLIS, and Hugging Face on its own), shows honest progress while a cold start warms up (which can take up to a minute), and, if the free lane is genuinely at its hourly limit, says exactly that and when to try again — pointing you to the instant paid Forge above. A model reliably comes back to orbit and download. (`/ibm/x402-demo`) `[fix, improvement]`- **Hide the controls in IRL for an unobstructed AR view** — On a phone, the IRL controls (the top bar, the bottom row of buttons, the room badges, the compass and on-screen hints) could cover so much of the screen that you couldn't see the camera view or move your avatar past them. There's now a one-tap hide button on the right edge: tap it and all of that chrome slides away, leaving just the live AR scene — the on-screen joystick and drag-to-look still work, so you can walk around and look about with nothing in the way. Tap the same button (it stays put and glows green) to bring everything back; on a keyboard, Esc restores it too. (`/irl`) `[feature, improvement]`diff --git a/api/agents/onchain/[action].js b/api/agents/onchain/[action].jsindex 0016e2817..27806ab1a 100644--- a/api/agents/onchain/[action].js+++ b/api/agents/onchain/[action].js@@ -218,6 +218,15 @@ function isRpcRateLimited(err) {return msg.includes('429') || /max usage reached|-32429|rate.?limit|too many requests|endpoints (failed|exhausted)/i.test(msg);}+// A node that returns a malformed/empty 200 (truncated body, proxy error page,+// wrong-cluster response) makes web3.js's superstruct decode throw a `StructError`+// out of getLatestBlockhash/getAccountInfo. That's a transient upstream fault, not+// a client error — surface it as a retryable 503 instead of an unhandled 500.+function isRpcMalformed(err) {+ const msg = err?.message || '';+ return /StructError|failed to get recent blockhash|failed to get info about account|Unexpected (token|end of JSON)|invalid json response/i.test(msg);+}+async function prepSolana({ cluster, metadataUri, walletAddress, name, attributes }) {const configuredRpc =cluster === 'devnet'@@ -271,6 +280,14 @@ async function prepSolana({ cluster, metadataUri, walletAddress, name, attributee.code = 'rpc_auth_failed';throw e;}+ if (isRpcMalformed(err)) {+ const e = new Error(+ 'Solana RPC returned a malformed response across every endpoint — the network ' ++ 'is likely congested. Wait a moment and retry; the mint transaction was not built.',+ );+ e.code = 'rpc_unavailable';+ throw e;+ }throw err;}@@ -360,6 +377,11 @@ async function handlePrep(req, res) {console.error('[agents/onchain] rpc auth failed', e?.message);return serverError(res, 503, 'rpc_unavailable', e);}+ if (e.code === 'rpc_unavailable') {+ res.setHeader('Retry-After', '10');+ console.error('[agents/onchain] rpc malformed response', e?.message);+ return serverError(res, 503, 'rpc_unavailable', e);+ }if (e.code === 'authority_unconfigured') {return error(res, 500, 'authority_unconfigured', e.message);}diff --git a/api/agents/solana/_handlers.js b/api/agents/solana/_handlers.jsindex 8fa366457..3972ef363 100644--- a/api/agents/solana/_handlers.js+++ b/api/agents/solana/_handlers.js@@ -967,7 +967,12 @@ export const handleEdit = wrap(async (req, res) => {let umi;try {- umi = createUmi(rpc).use(mplCore());+ // Failover Connection rather than the bare `rpc` URL: every on-chain read+ // (fetchAsset/fetchCollection) and write (sendAndConfirm → getLatestBlockhash)+ // below rotates across the endpoint chain, so a single node's malformed/empty+ // 200 body fails over to a healthy provider instead of throwing+ // `StructError: … but received:` and failing the whole edit.+ umi = createUmi(solanaConnection({ url: rpc, network })).use(mplCore());umi.use(signerIdentity(collectionAuthoritySigner(umi)));} catch (e) {console.error('[agents/solana] authority/umi init failed', e?.message);@@ -1237,7 +1242,10 @@ export const handleRegistrationCard = wrap(async (req, res) => {// ── Step 1: on-chain identity PDA ────────────────────────────────────────let pdaUri = null;try {- const umi = createUmi(rpcUrl).use(mplCore()).use(mplAgentIdentity());+ // Failover Connection so the best-effort on-chain PDA read rotates across the+ // endpoint chain rather than silently failing (→ DB fallback) every time the+ // single configured node returns a malformed/empty body.+ const umi = createUmi(solanaConnection({ url: rpcUrl, network })).use(mplCore()).use(mplAgentIdentity());const assetPk = umiPublicKey(asset);const [pdaAddr] = findAgentIdentityV1Pda(umi, { asset: assetPk });const acct = await umi.rpc.getAccount(pdaAddr).catch(() => null);diff --git a/api/cron/[name].js b/api/cron/[name].jsindex 22e7afb16..863d36ac7 100644--- a/api/cron/[name].js+++ b/api/cron/[name].js@@ -456,12 +456,21 @@ const PUBLIC_RPCS = {],421614: ['https://sepolia-rollup.arbitrum.io/rpc',- 'https://arbitrum-sepolia.publicnode.com',+ // PublicNode serves testnets at the `<chain>-rpc` subdomain (cf. the working+ // base-/ethereum-sepolia entries above). The bare `arbitrum-sepolia.publicnode.com`+ // host has no RPC service and answered every request with a hard 403 — fixed+ // to the canonical `-rpc` form so failover lands on a live node.+ 'https://arbitrum-sepolia-rpc.publicnode.com',+ // Tenderly's keyless public gateway — an independent provider so a single+ // node's outage/throttle doesn't blank the rotation.+ 'https://arbitrum-sepolia.gateway.tenderly.co','https://rpc.ankr.com/arbitrum_sepolia',],11155420: ['https://sepolia.optimism.io',- 'https://optimism-sepolia.publicnode.com',+ // Same PublicNode testnet `-rpc` correction as Arbitrum Sepolia above.+ 'https://optimism-sepolia-rpc.publicnode.com',+ 'https://optimism-sepolia.gateway.tenderly.co','https://rpc.ankr.com/optimism_sepolia',],};diff --git a/api/users/me/feed.js b/api/users/me/feed.jsindex eff2cdd1b..7925aede8 100644--- a/api/users/me/feed.js+++ b/api/users/me/feed.js@@ -32,9 +32,12 @@ export default wrap(async (req, res) => {const limit = Math.min(50, Math.max(1, parseInt(req.query.limit, 10) || 30));const perKind = limit; // pull `limit` of each kind, then merge + trim to `limit`+ // Follow graph lives in user_follows. A deploy that lands before the+ // user_follows migration must degrade to an empty feed rather than 500 every+ // home feed (migrate-then-deploy; mirrors api/users/[username].js).const [{ following_count }] = await sql`select count(*)::int as following_count from user_follows where follower_id = ${viewer.id}- `;+ `.catch(() => [{ following_count: 0 }]);if (following_count === 0) {return json(res, 200, { items: [], following_count: 0 });diff --git a/data/changelog.json b/data/changelog.jsonindex 70f61c009..9b8491a11 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,12 @@{"$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-22",+ "title": "Fix: token art loads reliably and 3D embeds never blank out",+ "summary": "Hardened two things that could fail quietly on the platform. Token artwork is fetched through our own image proxy so it loads cross-origin without errors; a slow or dead image host could previously hang that proxy until it was killed, leaving art stuck loading — it now bounds every lookup and falls back to a clean on-brand placeholder fast, so art always resolves. And every embedded 3D view (agent stages, model viewers, profile avatars) now degrades to a tasteful 'not available on this device' state instead of throwing when a browser or GPU refuses a WebGL context — so a low-end or locked-down device sees a graceful fallback rather than a broken page.",+ "tags": ["fix", "infra"]+ },{"date": "2026-06-22","title": "New: an Agent Bouncer that vets any agent before you pay it",diff --git a/pages/irl.html b/pages/irl.htmlindex 1d7dbe2fa..eb7e3a993 100644--- a/pages/irl.html+++ b/pages/irl.html@@ -289,6 +289,37 @@pointer-events: none;}+ /* First-run reveal coachmark — floats above the cleared view, fades on cue. */+ .irl-immersive-hint {+ position: fixed;+ left: 50%;+ bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);+ transform: translate(-50%, 8px);+ z-index: 12;+ padding: 9px 16px;+ border-radius: 999px;+ background: rgba(0,0,0,0.62);+ border: 1px solid rgba(255,255,255,0.16);+ backdrop-filter: blur(10px);+ -webkit-backdrop-filter: blur(10px);+ color: var(--text);+ font-size: 13px;+ font-weight: 500;+ white-space: nowrap;+ pointer-events: none;+ opacity: 0;+ transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.22,1,0.36,1);+ }+ .irl-immersive-hint.is-visible { opacity: 1; transform: translate(-50%, 0); }++ /* Respect reduced-motion: collapse instantly, no slide. */+ @media (prefers-reduced-motion: reduce) {+ .irl-topbar, .irl-bottom, .irl-immersive-hint { transition: opacity 0.18s ease; }+ body.irl-immersive .irl-topbar,+ body.irl-immersive .irl-bottom { transform: none; }+ .irl-immersive-hint.is-visible { transform: translate(-50%, 0); }+ }+/* ── Joystick ────────────────────────────────────────────── */#irl-joystick {position: fixed;@@ -1945,6 +1976,10 @@<svg class="irl-eye-show" width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z"/><circle cx="12" cy="12" r="3"/></svg></button>+<!-- One-time coachmark shown the first time the chrome auto-hides, so the+ reveal gesture is discoverable. Decorative + non-interactive. -->+<div id="irl-immersive-hint" class="irl-immersive-hint" aria-hidden="true"></div>+<!-- Proximity-arrival cue (task 03): a transient "look around" banner when a newagent enters your ~40 m bubble. aria-live polite so a screen reader announcesthe arrival without stealing focus. Filled + shown by src/irl.js. -->@@ -1994,6 +2029,8 @@<span class="irl-key"><kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> move</span><span class="irl-key"><kbd>Shift</kbd> run</span><span class="irl-key">drag to orbit</span>+ <span class="irl-key"><kbd>H</kbd> hide UI</span>+ <span class="irl-key"><kbd>F</kbd> fullscreen</span></div><!-- Bottom panel -->diff --git a/public/changelog.json b/public/changelog.jsonindex bce4d0088..347550b89 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-22T23:21:05.966Z",+ "generated_at": "2026-06-22T23:42:13.630Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -117,6 +117,17 @@"fix"]},+ {+ "date": "2026-06-22",+ "type": "update",+ "title": "Fix: token art loads reliably and 3D embeds never blank out",+ "summary": "Hardened two things that could fail quietly on the platform. Token artwork is fetched through our own image proxy so it loads cross-origin without errors; a slow or dead image host could previously hang that proxy until it was killed, leaving art stuck loading — it now bounds every lookup and falls back to a clean on-brand placeholder fast, so art always resolves. And every embedded 3D view (agent stages, model viewers, profile avatars) now degrades to a tasteful 'not available on this device' state instead of throwing when a browser or GPU refuses a WebGL context — so a low-end or locked-down device sees a graceful fallback rather than a broken page.",+ "link": null,+ "tags": [+ "fix",+ "infra"+ ]+ },{"date": "2026-06-22","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 3a87effb1..9d8431201 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -94,6 +94,14 @@<category>fix</category><description>Two places that read an agent's ERC-8004 reputation were decoding it wrong. The on-chain registry returns the average rating already worked out (and signed, so it can go negative); both the paid reputation MCP tool and the trust check that guards autonomous agent-to-agent payments were dividing that value a second time — understating every score, and turning a negative reputation into a meaninglessly large positive one. The MCP tool was also listening for the wrong on-chain event, so it always reported zero past vouches even when an agent had many. Both now report the true average, handle negative reputations correctly, and surface real review history — so a 'pay only above this score' rule actually does what it says.</description></item>+ <item>+ <title>Fix: token art loads reliably and 3D embeds never blank out</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-06-22:Fix: token art loads reliably and 3D embeds never blank out</guid>+ <pubDate>Mon, 22 Jun 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>Hardened two things that could fail quietly on the platform. Token artwork is fetched through our own image proxy so it loads cross-origin without errors; a slow or dead image host could previously hang that proxy until it was killed, leaving art stuck loading — it now bounds every lookup and falls back to a clean on-brand placeholder fast, so art always resolves. And every embedded 3D view (agent stages, model viewers, profile avatars) now degrades to a tasteful 'not available on this device' state instead of throwing when a browser or GPU refuses a WebGL context — so a low-end or locked-down device sees a graceful fallback rather than a broken page.</description>+ </item><item><title>Forge polish: engine picker, honest wording, keyboard tabs, full-length remix</title><link>https://three.ws/forge</link>diff --git a/public/error-reporter.js b/public/error-reporter.jsindex 6505270e2..e0391ac0e 100644--- a/public/error-reporter.js+++ b/public/error-reporter.js@@ -120,16 +120,12 @@if (!raw || typeof raw !== 'object') return null;if (raw.type === 'unhandledrejection') {const reason = raw.reason;- const isError = reason instanceof Error;+ const described = describeReason(reason);return {type: 'unhandledrejection',- name: isError ? reason.name : undefined,- message: isError- ? reason.message- : typeof reason === 'string'- ? reason- : safeStringify(reason),- stack: isError ? reason.stack : undefined,+ name: described.name,+ message: described.message,+ stack: described.stack,};}if (raw.type === 'error') {@@ -169,12 +165,49 @@function safeStringify(value) {try {- return JSON.stringify(value) ?? String(value);+ const json = JSON.stringify(value);+ // A real Error (or any object whose useful fields are non-enumerable)+ // serializes to "{}" — a content-free report that tells us nothing. Fall+ // back to the value's own string form so we capture at least the class.+ if (json == null || json === '{}' || json === 'null') return String(value);+ return json;} catch {return String(value);}}+ // Extract a useful { name, message, stack } from a rejection reason of ANY+ // shape. A promise can reject with a real Error, an Error thrown across a+ // module/realm boundary (whose `instanceof Error` is false but which still+ // carries `message`/`stack`), a plain object, a DOMException, or a primitive.+ // The old code only special-cased `instanceof Error` and JSON-stringified the+ // rest — so a cross-realm Error or a bare `{}` produced `message: "{}"`, a+ // report with no diagnostic value. Dig out the message before stringifying.+ function describeReason(reason) {+ if (reason instanceof Error) {+ return { name: reason.name, message: reason.message, stack: reason.stack };+ }+ if (typeof reason === 'string') {+ return { name: undefined, message: reason, stack: undefined };+ }+ if (reason && typeof reason === 'object') {+ // Duck-typed / cross-realm errors and common wrapper shapes.+ const message =+ (typeof reason.message === 'string' && reason.message) ||+ (typeof reason.reason === 'string' && reason.reason) ||+ (reason.error && typeof reason.error.message === 'string' && reason.error.message) ||+ safeStringify(reason);+ const name =+ (typeof reason.name === 'string' && reason.name) ||+ (reason.constructor && reason.constructor.name) ||+ undefined;+ const stack = typeof reason.stack === 'string' ? reason.stack : undefined;+ return { name, message, stack };+ }+ // Primitive (number, boolean, null, undefined, symbol, bigint).+ return { name: undefined, message: String(reason), stack: undefined };+ }+function shouldIgnore(report) {if (!report.message && !report.source) return true;if (report.source && IGNORED_SOURCES.test(report.source)) return true;@@ -379,12 +412,12 @@// Manual reporting hook for app code: window.reportClientError(err, { ...context })win.reportClientError = (err, context) => {try {- const isError = err instanceof Error;+ const described = describeReason(err);enqueue({type: 'manual',- name: isError ? err.name : undefined,- message: isError ? err.message : typeof err === 'string' ? err : safeStringify(err),- stack: isError ? err.stack : undefined,+ name: described.name,+ message: described.message,+ stack: described.stack,source: context && typeof context === 'object' ? safeStringify(context) : undefined,});} catch {diff --git a/public/features.json b/public/features.jsonindex f2e91bfef..1c3280bbd 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-22T23:21:05.954Z",+ "generated_at": "2026-06-22T23:42:13.602Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/components/ModelViewerElement.js b/src/components/ModelViewerElement.jsindex 12b950257..c6e4d042f 100644--- a/src/components/ModelViewerElement.js+++ b/src/components/ModelViewerElement.js@@ -19,6 +19,7 @@ function injectStylesOnce() {mv-viewer .mv-viewer__stage { position: absolute; inset: 0; }mv-viewer .mv-viewer__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .3s ease; cursor: pointer; }mv-viewer .mv-viewer__poster[data-hidden] { opacity: 0; pointer-events: none; }+ mv-viewer .mv-viewer__webgl-unavailable { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; text-align: center; color: rgba(255,255,255,.55); font: 500 0.8125rem/1.4 'Inter','Segoe UI',system-ui,sans-serif; letter-spacing: .02em; }`;document.head.appendChild(style);}@@ -78,7 +79,18 @@ export class ModelViewerElement extends HTMLElement {// everything else flows through state and methods after construction.};- this._viewer = new Viewer(this._stageEl, options);+ // A device/browser that can't grant a WebGL context (GPU blocklist, context+ // budget exhausted, headless) makes the Viewer constructor throw "Error+ // creating WebGL context". connectedCallback runs synchronously, so an+ // unguarded throw escapes as an uncaught error. Degrade to the poster (if+ // the embedder supplied one) or a designed message instead of crashing.+ try {+ this._viewer = new Viewer(this._stageEl, options);+ } catch (err) {+ this._viewer = null;+ this._showWebglUnavailable();+ return;+ }this._viewer.state.environment = envName;// Initial attribute sync (before first load, invalidate for the env + lighting updates).@@ -115,6 +127,20 @@ export class ModelViewerElement extends HTMLElement {}}+ // Designed fallback when the device can't give us a WebGL context. A supplied+ // poster already renders the model's still, so we keep it and just stop; with+ // no poster we show a small, on-brand message so the embed is never a blank box.+ _showWebglUnavailable() {+ if (this._posterEl) return; // poster is already visible — that's the fallback+ if (!this._stageEl) return;+ const note = document.createElement('div');+ note.className = 'mv-viewer__webgl-unavailable';+ note.setAttribute('role', 'img');+ note.setAttribute('aria-label', "3D view unavailable — this browser or device couldn't start WebGL");+ note.textContent = '3D view unavailable on this device';+ this._stageEl.appendChild(note);+ }+disconnectedCallback() {if (!this._viewer) return;if (this._onControlsChange && this._viewer.controls) {diff --git a/src/irl.js b/src/irl.jsindex f2ac10852..6fb04baaa 100644--- a/src/irl.js+++ b/src/irl.js@@ -717,6 +717,10 @@ canvas.addEventListener('pointerup', e => {// reliability on a phone. Front agent wins a cluster tie (see helper).if (!pin) pin = _nearestLabelWithinSlop(e.clientX, e.clientY);if (pin) openPinSheet(pin);+ // A clean tap on empty space hits no agent — the canonical immersive+ // gesture: toggle the chrome so you can clear the view (or bring it back)+ // without hunting for the eye button.+ else toggleImmersive();}});@@ -4445,27 +4449,145 @@ syncGhostToggle();document.getElementById('irl-cue-mute')?.addEventListener('click', () => setCueMuted(!_cueMuted));syncCueMuteButton();-// Immersive toggle — collapse every chrome layer (topbar, bottom panel, radar,-// room badge, aim HUD, hints) so the live AR view is unobstructed. The joystick-// and drag-to-orbit stay live underneath, so you can still look around and move-// the avatar; the toggle itself is the one control left, to bring it all back.-const immersiveBtn = document.getElementById('irl-immersive-toggle');+// ── Immersive mode ────────────────────────────────────────────────────────+// Collapse every chrome layer (topbar, bottom panel, radar, room badge, aim+// HUD, hints) so the live AR view is unobstructed. The joystick and+// drag-to-orbit stay live underneath, so you can still look around and move the+// avatar while hidden. Two ways in/out, tuned per device:+// • Touch — chrome auto-hides after idle (once the camera is live); tap empty+// space (or the eye button) to bring it back. Joystick/drag never reveal it,+// so you can move freely with nothing in the way.+// • Desktop — a focus/cinematic mode: controls behave like a video player+// (move the mouse to reveal, idle to hide), with H to toggle, F for+// fullscreen, Esc to restore.+const immersiveBtn = document.getElementById('irl-immersive-toggle');+const immersiveHint = document.getElementById('irl-immersive-hint');+const FINE_POINTER = typeof matchMedia === 'function'+ && matchMedia('(hover: hover) and (pointer: fine)').matches;+const IMMERSIVE_IDLE_MS = FINE_POINTER ? 4500 : 5000;+let _idleTimer = 0;+let _hintShown = false;+let _engaged = false; // never auto-hide until the user has actually interacted++const chromeHidden = () => document.body.classList.contains('irl-immersive');+function setImmersive(on) {document.body.classList.toggle('irl-immersive', on);- if (!immersiveBtn) return;- immersiveBtn.setAttribute('aria-pressed', String(on));- const label = on ? 'Show controls' : 'Hide controls';- immersiveBtn.setAttribute('aria-label', label);- immersiveBtn.title = label;-}-immersiveBtn?.addEventListener('click', () => {- setImmersive(!document.body.classList.contains('irl-immersive'));-});-// Esc restores the chrome on desktop, matching the convention for immersive views.+ if (immersiveBtn) {+ immersiveBtn.setAttribute('aria-pressed', String(on));+ const label = on ? 'Show controls' : 'Hide controls';+ const hotkey = FINE_POINTER ? ' (H)' : '';+ immersiveBtn.setAttribute('aria-label', label);+ immersiveBtn.title = label + hotkey;+ }+}++// Auto-hide is appropriate only when there's a live scene to enjoy and nothing+// modal is competing for the screen: on touch that means the camera is on; on+// desktop the 3D walk view always qualifies. A focused input or open sheet+// (movementKeysCaptured) always blocks it, and so does an active room-placement.+function _canAutoHide() {+ if (!_engaged || chromeHidden() || movementKeysCaptured()) return false;+ const aimHud = document.getElementById('irl-aim-hud');+ if (aimHud && aimHud.classList.contains('is-open')) return false;+ if (!FINE_POINTER && !document.body.classList.contains('is-ar')) return false;+ return true;+}+function _armIdle() {+ clearTimeout(_idleTimer);+ if (!_canAutoHide()) return;+ _idleTimer = setTimeout(() => {+ if (!_canAutoHide()) return;+ setImmersive(true);+ _flashImmersiveHint();+ }, IMMERSIVE_IDLE_MS);+}++// One-time coachmark the first time the chrome disappears, so the reveal gesture+// is discoverable. The eye button stays on screen regardless, so this only ever+// shows once per device.+function _flashImmersiveHint() {+ if (!immersiveHint || _hintShown) return;+ try { if (localStorage.getItem('irl_immersive_hinted')) { _hintShown = true; return; } } catch {}+ _hintShown = true;+ try { localStorage.setItem('irl_immersive_hinted', '1'); } catch {}+ immersiveHint.textContent = FINE_POINTER+ ? 'Move the mouse or press H to show controls'+ : 'Tap anywhere to show controls';+ immersiveHint.classList.add('is-visible');+ clearTimeout(_flashImmersiveHint._t);+ _flashImmersiveHint._t = setTimeout(() => immersiveHint.classList.remove('is-visible'), 2800);+}++// Deliberate toggle (eye button, H key, tap on empty scene). Showing re-arms the+// idle timer; hiding cancels it and is sticky until the user asks for chrome again.+function toggleImmersive() {+ if (chromeHidden()) {+ setImmersive(false);+ immersiveHint?.classList.remove('is-visible');+ _armIdle();+ } else {+ setImmersive(true);+ clearTimeout(_idleTimer);+ _flashImmersiveHint();+ }+}+// Reveal without toggling (desktop pointer motion / any explicit "show"): restore+// chrome if hidden, then re-arm so it fades again after the next idle stretch.+function revealChrome() {+ if (chromeHidden()) { setImmersive(false); immersiveHint?.classList.remove('is-visible'); }+ _armIdle();+}++immersiveBtn?.addEventListener('click', toggleImmersive);+window.addEventListener('keydown', (e) => {- if (e.key === 'Escape' && document.body.classList.contains('irl-immersive')) setImmersive(false);+ if (movementKeysCaptured() && e.key !== 'Escape') return;+ if (e.key === 'Escape') {+ if (chromeHidden()) { setImmersive(false); _armIdle(); }+ return;+ }+ if (e.key === 'h' || e.key === 'H') { toggleImmersive(); }+ else if (e.key === 'f' || e.key === 'F') { toggleFullscreen(); }+ else { _engaged = true; _armIdle(); } // any other walk key resets the idle countdown});+// Real fullscreen (desktop focus mode). iOS Safari has no element Fullscreen API,+// so this no-ops there — the optional-chaining guards make that graceful.+function toggleFullscreen() {+ const fsEl = document.fullscreenElement || document.webkitFullscreenElement;+ if (fsEl) {+ (document.exitFullscreen || document.webkitExitFullscreen)?.call(document);+ } else {+ const el = document.documentElement;+ (el.requestFullscreen || el.webkitRequestFullscreen)?.call(el);+ }+}++// Activity wiring. Touch: world interaction only re-arms the hide timer (it must+// NOT reveal, so the user can move/look with the chrome gone). Desktop: pointer+// motion reveals like a video player. Joystick + canvas taps are the world.+const _noteWorldActivity = () => { _engaged = true; _armIdle(); };+if (FINE_POINTER) {+ let _moveThrottle = 0;+ window.addEventListener('pointermove', (e) => {+ if (e.pointerType === 'touch') return;+ const now = e.timeStamp || 0;+ if (now - _moveThrottle < 200) return;+ _moveThrottle = now;+ if (movementKeysCaptured()) return;+ _engaged = true;+ revealChrome();+ }, { passive: true });+}+canvas.addEventListener('pointerdown', _noteWorldActivity, { passive: true });+joystickEl?.addEventListener('pointerdown', _noteWorldActivity, { passive: true });+// Once the camera goes live, start the idle countdown (the body gains .is-ar in+// enableAR); a class-watch keeps this independent of that code path's internals.+new MutationObserver(() => {+ if (document.body.classList.contains('is-ar')) { _engaged = true; _armIdle(); }+}).observe(document.body, { attributes: true, attributeFilter: ['class'] });+// L3 — Location & privacy center: honest disclosure + discovery precision +// presence opt-in + a jump into pin management, all in one designed surface.document.getElementById('irl-privacy-btn')?.addEventListener('click', () => {diff --git a/src/stage-element.js b/src/stage-element.jsindex 69c6c9949..9fb03271a 100644--- a/src/stage-element.js+++ b/src/stage-element.js@@ -90,7 +90,19 @@ class AgentStageElement extends HTMLElement {_initViewer() {if (this._initialized) return;- this._viewer = new Viewer(this._canvasBox, { kiosk: true });+ // A device/browser that can't grant a WebGL context (GPU blocklist, context+ // budget exhausted, headless) makes the Viewer constructor throw "Error+ // creating WebGL context". connectedCallback runs this synchronously, so an+ // unguarded throw escapes as an uncaught error and blanks the host page.+ // Degrade instead: leave _viewer null (registerAgent/unregisterAgent already+ // null-check it) so child agents simply don't render rather than crash.+ try {+ this._viewer = new Viewer(this._canvasBox, { kiosk: true });+ } catch (err) {+ this._viewer = null;+ this._initialized = true;+ return;+ }// Default framing for a human-scale stage.this._viewer.defaultCamera.position.set(0, 1.55, 3.4);this._viewer.defaultCamera.lookAt(0, 1.2, 0);