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: add IBM showcase live variant and update x402 server

nirholas4687df0faaa0
diff --git a/packages/x402-server/src/index.js b/packages/x402-server/src/index.js
index 283f7d5e6..0c40574b3 100644
--- a/packages/x402-server/src/index.js
+++ b/packages/x402-server/src/index.js
@@ -47,6 +47,15 @@ const CANONICAL_USDC = {
base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
};
+// $THREE — the three.ws platform token, the second main x402 settlement asset
+// alongside USDC. Solana-only (it's an SPL mint). `asset: 'three'` resolves to
+// it; `acceptThree: true` advertises it next to USDC on the Solana lane, exactly
+// as api/_lib/x402-spec.js does server-side. 6 decimals.
+const CANONICAL_THREE = {
+ solana: 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump',
+};
+const THREE_DECIMALS = 6;
+
// Maps the ergonomic lane name → CAIP-2 network id. Solana leads when both are
// present, matching paymentRequirements()'s Solana-first ordering.
const LANE_NETWORK = {
@@ -162,7 +171,7 @@ export function paid(opts, handler) {
// order. Each entry carries scheme/network/amount/asset/payTo/maxTimeoutSeconds
// + the per-lane `extra` block (Solana needs a feePayer; Base pins the EIP-712
// domain name "USD Coin"). Grounded in paymentRequirements().
-function buildAccepts({ price, asset, payTo, network, feePayer, maxTimeoutSeconds, resourceUrl }) {
+function buildAccepts({ price, asset, payTo, network, feePayer, maxTimeoutSeconds, resourceUrl, acceptThree, threeAmount }) {
if (price === undefined || price === null || String(price) === '') {
throw new ThreeWsError('buildChallenge() needs a `price` in atomic units.', { code: 'invalid_input' });
}
@@ -189,6 +198,16 @@ function buildAccepts({ price, asset, payTo, network, feePayer, maxTimeoutSecond
}
out.push(buildAccept({ lane, amount, asset, payTo: to, feePayer, maxTimeoutSeconds, resourceUrl }));
}
+ // $THREE alongside USDC on Solana — the platform's second main asset. Pushed
+ // AFTER the USDC entry so first-accept clients keep settling USDC; a wallet
+ // that renders a token chooser surfaces both. Mirrors paymentRequirements().
+ if (acceptThree && lanes.includes('solana') && payTo.solana) {
+ const threeAmt = threeAmount === undefined || threeAmount === null || String(threeAmount) === '' ? amount : String(threeAmount);
+ if (!/^\d+$/.test(threeAmt)) {
+ throw new ThreeWsError(`threeAmount must be a whole atomic amount string, got "${threeAmt}".`, { code: 'invalid_input' });
+ }
+ out.push(buildAccept({ lane: 'solana', amount: threeAmt, asset: 'three', payTo: payTo.solana, feePayer, maxTimeoutSeconds, resourceUrl }));
+ }
if (!out.length) {
throw new ThreeWsError('No payable lanes — set payTo for solana and/or base.', { code: 'invalid_input' });
}
@@ -213,7 +232,12 @@ function buildAccept({ lane, amount, asset, payTo, feePayer, maxTimeoutSeconds,
if (!feePayer) {
throw new ThreeWsError('Solana accepts need a `feePayer` (the facilitator sponsor account) — set X402_FEE_PAYER_SOLANA.', { code: 'missing_fee_payer' });
}
- accept.extra = { name: 'USDC', decimals: 6, feePayer };
+ // `extra` names the settlement token — $THREE when this is a THREE accept,
+ // USDC otherwise — so a wallet labels the choice correctly.
+ const isThree = asset === 'three' || assetAddress === CANONICAL_THREE.solana;
+ accept.extra = isThree
+ ? { name: 'THREE', decimals: THREE_DECIMALS, feePayer }
+ : { name: 'USDC', decimals: 6, feePayer };
} else {
// `name` MUST match the on-chain EIP-712 domain. Base USDC's domain name
// is "USD Coin" (not "USDC") — using "USDC" recomputes the wrong domain
@@ -224,6 +248,14 @@ function buildAccept({ lane, amount, asset, payTo, feePayer, maxTimeoutSeconds,
}
function resolveAsset(asset, lane) {
+ if (asset === 'three') {
+ // $THREE is an SPL mint — Solana only. Advertising it on an EVM lane is a
+ // misconfiguration, not a silent USDC fallback.
+ if (lane !== 'solana') {
+ throw new ThreeWsError(`$THREE settlement is Solana-only — lane "${lane}" can't advertise THREE.`, { code: 'invalid_input' });
+ }
+ return CANONICAL_THREE.solana;
+ }
if (!asset || asset === 'usdc') return CANONICAL_USDC[lane === 'base-sepolia' ? 'base' : lane];
if (typeof asset === 'string') return asset;
if (typeof asset === 'object') {
@@ -243,6 +275,8 @@ function buildChallengeEnvelope({
feeBps,
feeTo,
feePayer,
+ acceptThree,
+ threeAmount,
accepts,
maxTimeoutSeconds,
resourceUrl,
@@ -256,7 +290,7 @@ function buildChallengeEnvelope({
} = {}) {
const list = Array.isArray(accepts) && accepts.length
? accepts
- : buildAccepts({ price, asset, payTo, network, feePayer, maxTimeoutSeconds, resourceUrl });
+ : buildAccepts({ price, asset, payTo, network, feePayer, maxTimeoutSeconds, resourceUrl, acceptThree, threeAmount });
const resource = { url: resourceUrl ?? null, mimeType };
if (typeof description === 'string' && description.length) resource.description = description;
diff --git a/pages/ibm/hello.live.html b/pages/ibm/hello.live.html
new file mode 100644
index 000000000..0fbdde09d
--- /dev/null
+++ b/pages/ibm/hello.live.html
@@ -0,0 +1,2708 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <style>/* three.ws hidden-guard — make the `hidden` attribute authoritative; see scripts/lib/hidden-guard.mjs */[hidden]{display:none!important}</style>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<meta name="color-scheme" content="light dark">
+<title>IBM and three.ws partnership</title>
+<meta name="description" content="IBM and three.ws work together to unite payments, data, 3D and AI — pairing IBM Granite on watsonx.ai with three.ws's on-chain micropayments and 3D agent engine. Explore live demos that run against real production systems.">
+<meta property="og:title" content="IBM and three.ws partnership">
+<meta property="og:description" content="IBM and three.ws unite payments, data, 3D and AI — IBM Granite on watsonx.ai with three.ws on-chain micropayments and 3D agents. Live demos, nothing mocked.">
+<meta property="og:type" content="website">
+<style>
+/* ─── Self-hosted IBM Plex (latin subset) — no third-party font CDN, so a
+ strict `font-src 'self'` CSP on the host page won't break typography.
+ Files travel with this page under ./fonts/. ─────────────────────────────── */
+@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:300;font-display:swap;src:url('./fonts/IBMPlexSans-300.woff2') format('woff2')}
+@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:400;font-display:swap;src:url('./fonts/IBMPlexSans-400.woff2') format('woff2')}
+@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:500;font-display:swap;src:url('./fonts/IBMPlexSans-500.woff2') format('woff2')}
+@font-face{font-family:'IBM Plex Sans';font-style:normal;font-weight:600;font-display:swap;src:url('./fonts/IBMPlexSans-600.woff2') format('woff2')}
+@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:400;font-display:swap;src:url('./fonts/IBMPlexMono-400.woff2') format('woff2')}
+@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:500;font-display:swap;src:url('./fonts/IBMPlexMono-500.woff2') format('woff2')}
+
+*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+
+:root{
+ /* Carbon G10 (light) — defaults. Every surface token is themed so the dark
+ override below is a single, deliberate switch. */
+ --ibm-blue:#0f62fe; /* accent: text, borders, focus rings */
+ --ibm-blue-fill:#0f62fe; /* fills that carry white text (button, skip link) */
+ --ibm-blue-fill-hover:#0353e9;
+ --ibm-blue-hover:#0353e9;
+ --ibm-link:#0f62fe; /* AA on white (4.6:1) */
+ --ibm-ink:#161616;
+ --ibm-muted:#525252; /* AA on white (7.4:1) */
+ --ibm-subtle:#595959; /* AA on white (7:1) — was #6f6f6f (3.9:1, failed) */
+ --ibm-border:#e0e0e0;
+ --ibm-divider:#c6c6c6;
+ --ibm-surface:#ffffff; /* card / panel fill */
+ --ibm-field:#f4f4f4;
+ --ibm-field-focus:#ffffff;
+ --ibm-green:#0e7a32; /* darkened for AA on light fills */
+ --ibm-green-ink:#0e7a32; /* green text on light pill fills */
+ --ibm-green-fill:#defbe6;
+ --ibm-red:#da1e28;
+ --ibm-red-ink:#a2191f; /* red text on light fills (AA) */
+ --ibm-red-fill:#fff1f1;
+ --ibm-red-edge:#ffb3b8;
+ --ibm-amber:#8a6100; /* AA on white */
+ --ibm-amber-fill:#fcf4d6;
+ --ibm-skel-a:#e8e8e8;
+ --ibm-skel-b:#f4f4f4;
+ --font-sans:'IBM Plex Sans',system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
+ --font-mono:'IBM Plex Mono',ui-monospace,'SF Mono',Menlo,Consolas,monospace;
+ --ease:cubic-bezier(.2,.7,.3,1);
+}
+
+/* Carbon G100 (dark) — looks deliberate when embedded in a dark IBM context.
+ Background stays transparent so the page rides the host surface in both schemes. */
+@media (prefers-color-scheme: dark){
+ :root{
+ --ibm-blue:#78a9ff; /* accent on dark — AA as text on G100 (7.2:1) */
+ --ibm-blue-fill:#0f62fe; /* white text stays AA (4.84:1); recognizably IBM blue */
+ --ibm-blue-fill-hover:#1f6fff;
+ --ibm-blue-hover:#a6c8ff;
+ --ibm-link:#78a9ff; /* AA on #161616 (7.2:1) */
+ --ibm-ink:#f4f4f4;
+ --ibm-muted:#c6c6c6; /* AA on #161616 (12:1) */
+ --ibm-subtle:#a8a8a8; /* AA on #161616 (7.4:1) */
+ --ibm-border:#393939;
+ --ibm-divider:#525252;
+ --ibm-surface:#262626; /* card / panel fill on dark */
+ --ibm-field:#393939;
+ --ibm-field-focus:#4c4c4c;
+ --ibm-green:#42be65; /* used as accent edge/dot on dark */
+ --ibm-green-ink:#42be65; /* AA on dark green fill */
+ --ibm-green-fill:#0b2818;
+ --ibm-red:#fa4d56;
+ --ibm-red-ink:#ff8389; /* AA on dark red fill */
+ --ibm-red-fill:#2a1416;
+ --ibm-red-edge:#7f1d1d;
+ --ibm-amber:#f1c21b; /* AA on dark */
+ --ibm-amber-fill:#2a1d10;
+ --ibm-skel-a:#333333;
+ --ibm-skel-b:#3f3f3f;
+ }
+}
+
+html,body{background:transparent;font-family:var(--font-sans);color:var(--ibm-ink);font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
+a{color:var(--ibm-link);text-decoration:none}
+a:hover{text-decoration:underline}
+.mono{font-family:var(--font-mono)}
+
+/* Visible focus everywhere — never rely on the UA default the reset removes. */
+:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
+a:focus-visible{outline-offset:3px}
+
+.skip-link{position:absolute;left:-9999px;top:0;background:var(--ibm-blue-fill);color:#fff;padding:10px 16px;z-index:50;font-weight:600;font-size:14px}
+.skip-link:focus{left:8px;top:8px;text-decoration:none}
+
+/* Visually hidden but available to assistive tech. */
+.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
+
+.inner{max-width:880px;margin:0 auto;padding:0 16px}
+.section{padding:40px 0;border-bottom:1px solid var(--ibm-border)}
+.section:last-child{border-bottom:none}
+
+/* ── Global error banner (resilience safety net) ── */
+.err-banner{position:fixed;left:0;right:0;top:0;z-index:60;background:var(--ibm-red-fill);border-bottom:1px solid var(--ibm-red-edge);color:var(--ibm-red-ink);font-size:13px;padding:10px 16px;display:none;align-items:center;gap:12px;justify-content:center}
+.err-banner.show{display:flex}
+.err-banner button{background:none;border:1px solid var(--ibm-red-edge);color:var(--ibm-red-ink);font-family:inherit;font-size:12px;font-weight:600;padding:4px 10px;cursor:pointer;border-radius:2px}
+.err-banner button:hover{background:rgba(218,30,40,.12)}
+
+/* ── Hero ── */
+.hero{padding:56px 0 36px}
+.hero h1{font-size:clamp(30px,5vw,46px);font-weight:300;line-height:1.1;margin-bottom:18px;max-width:680px}
+.hero h1 strong{font-weight:600}
+.hero-sub{font-size:18px;color:var(--ibm-muted);max-width:620px;font-weight:300;line-height:1.6}
+.hero-eyebrow{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-blue);font-weight:500;margin-bottom:14px}
+.hero-cta{display:flex;flex-wrap:wrap;align-items:center;gap:16px 28px;margin-top:30px}
+.btn-tertiary{display:inline-flex;align-items:center;gap:10px;color:var(--ibm-link);font-size:15px;font-weight:500;background:none;border:none;padding:0;cursor:pointer;transition:gap .12s,color .12s}
+.btn-tertiary:hover{text-decoration:none;color:var(--ibm-blue-hover);gap:14px}
+.btn-tertiary:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:3px}
+.hero-note{font-size:14px;color:var(--ibm-subtle);max-width:660px;font-weight:300;line-height:1.65;margin-top:30px}
+
+/* ── How-it-works ── */
+.steps{display:grid;grid-template-columns:repeat(3,1fr);gap:1px;background:var(--ibm-border);border:1px solid var(--ibm-border);list-style:none;margin-top:24px}
+.step{background:var(--ibm-surface);padding:24px 22px}
+.step-n{font-family:var(--font-mono);font-size:12px;color:var(--ibm-blue);font-weight:500;margin-bottom:10px}
+.step h3{font-size:15px;font-weight:600;margin-bottom:6px}
+.step p{font-size:13px;color:var(--ibm-muted);font-weight:300;line-height:1.55}
+.step code{font-family:var(--font-mono);font-size:12px;background:var(--ibm-field);padding:1px 5px;color:var(--ibm-ink);word-break:break-word}
+
+/* ── Section heads ── */
+.section-tag{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-blue);margin-bottom:8px;font-weight:500}
+.section h2{font-size:clamp(22px,4vw,32px);font-weight:300}
+.section h2 strong{font-weight:600}
+.section-lead{font-size:15px;color:var(--ibm-muted);max-width:620px;margin-top:10px;font-weight:300;line-height:1.6}
+
+/* ── Demo card ── */
+.demo{border:1px solid var(--ibm-divider);margin-top:28px;background:var(--ibm-surface)}
+.demo-head{padding:22px 24px 18px;border-bottom:1px solid var(--ibm-border);display:flex;flex-wrap:wrap;gap:16px;align-items:flex-end;justify-content:space-between}
+.demo-title{font-size:20px;font-weight:600}
+.demo-title span{color:var(--ibm-blue)}
+.demo-desc{font-size:13px;color:var(--ibm-muted);font-weight:300;max-width:460px;margin-top:4px;line-height:1.55}
+.price-tag{text-align:right;flex:0 0 auto}
+.price-tag .amt{font-size:30px;font-weight:300;line-height:1;font-variant-numeric:tabular-nums}
+.price-tag .amt strong{font-weight:600;color:var(--ibm-blue)}
+.price-tag .amt.flash{animation:priceflash .42s var(--ease) 1}
+@keyframes priceflash{0%{transform:scale(1)}40%{transform:scale(1.06);opacity:.7}100%{transform:scale(1);opacity:1}}
+.price-tag .net{font-size:12px;color:var(--ibm-muted);margin-top:6px}
+
+.demo-body{padding:22px 24px}
+
+/* 402 preview */
+.preview{border:1px solid var(--ibm-border);background:var(--ibm-field);padding:14px 16px;margin-bottom:22px;font-family:var(--font-mono);font-size:12px}
+.preview-label{font-family:var(--font-sans);font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--ibm-subtle);margin-bottom:10px;display:flex;align-items:center;gap:8px}
+.preview-label .dot{width:7px;height:7px;border-radius:50%;background:var(--ibm-subtle);flex:0 0 auto}
+.preview-label.ok .dot{background:var(--ibm-green)}
+.preview-label.ok.fresh .dot{animation:dotpulse 1.2s var(--ease) 1}
+.preview-label.err .dot{background:var(--ibm-red)}
+@keyframes dotpulse{0%{box-shadow:0 0 0 0 rgba(14,122,50,.5)}100%{box-shadow:0 0 0 9px rgba(14,122,50,0)}}
+.preview-row{display:flex;gap:12px;padding:3px 0;flex-wrap:wrap}
+.preview-row .k{color:var(--ibm-subtle);min-width:84px}
+.preview-row .v{color:var(--ibm-ink);word-break:break-all}
+.badge{display:inline-block;font-family:var(--font-sans);font-size:11px;font-weight:500;padding:1px 8px;border:1px solid var(--ibm-divider);margin-right:6px;border-radius:2px}
+.pv-retry{margin-top:10px;background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink);font-family:var(--font-sans);font-size:12px;font-weight:500;padding:6px 12px;cursor:pointer}
+.pv-retry:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+/* skeleton */
+.sk{display:inline-block;height:11px;border-radius:2px;background:linear-gradient(90deg,var(--ibm-skel-a) 25%,var(--ibm-skel-b) 37%,var(--ibm-skel-a) 63%);background-size:400% 100%;animation:sk 1.4s ease infinite}
+@keyframes sk{0%{background-position:100% 0}100%{background-position:0 0}}
+
+/* input row */
+.field-row{display:flex;gap:0;flex-wrap:wrap;align-items:flex-end;margin-bottom:10px}
+.field-wrap{flex:1 1 240px;min-width:0}
+.field-wrap label{display:block;font-size:12px;color:var(--ibm-muted);margin-bottom:6px;font-weight:500}
+.field{width:100%;height:48px;padding:0 14px;border:none;border-bottom:1px solid var(--ibm-divider);background:var(--ibm-field);font-family:var(--font-mono);font-size:15px;color:var(--ibm-ink);letter-spacing:.04em;outline:none;transition:border-color .12s,background .12s}
+.field:focus{border-bottom:2px solid var(--ibm-blue);background:var(--ibm-field-focus)}
+.field[aria-invalid="true"]{border-bottom:2px solid var(--ibm-red)}
+.field-hint{font-size:11px;color:var(--ibm-subtle);margin-top:6px}
+.field-hint.err{color:var(--ibm-red)}
+
+.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;background:var(--ibm-blue-fill);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:15px;font-weight:500;letter-spacing:.01em;padding:0 24px;height:48px;min-width:200px;transition:background .12s,transform .04s,box-shadow .12s}
+.btn:hover:not(:disabled){background:var(--ibm-blue-fill-hover)}
+.btn:active:not(:disabled){transform:translateY(1px)}
+.btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px;box-shadow:0 0 0 4px rgba(15,98,254,.25)}
+.btn:disabled{background:var(--ibm-divider);color:var(--ibm-subtle);cursor:not-allowed}
+.btn .arrow{font-size:17px;line-height:1}
+.btn .spin{width:15px;height:15px;border:2px solid rgba(255,255,255,.45);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;display:none}
+.btn.loading .spin{display:inline-block}
+.btn.loading .arrow{display:none}
+@media(min-width:560px){.btn{margin-left:1px}}
+
+.wallet-hint{font-size:11px;color:var(--ibm-subtle);margin-bottom:18px;line-height:1.5;transition:color .12s}
+.wallet-hint b{color:var(--ibm-ink);font-weight:600}
+.wallet-hint.offline{color:var(--ibm-amber);font-weight:500}
+.wallet-hint.detected{color:var(--ibm-green)}
+.wallet-hint.detected b{color:var(--ibm-green)}
+
+/* result panel */
+.result{border:1px solid var(--ibm-border);min-height:96px;padding:18px 20px;background:var(--ibm-surface);transition:border-color .15s}
+.result.is-empty{display:flex;align-items:center;justify-content:center;color:var(--ibm-subtle);font-size:13px;text-align:center;font-weight:300;border-style:dashed}
+.result.is-loading{border-color:var(--ibm-blue)}
+.result.is-error{border-color:var(--ibm-red)}
+.result.is-done{border-color:var(--ibm-green);animation:reveal .28s var(--ease)}
+@keyframes reveal{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
+
+.r-status{display:flex;align-items:center;gap:10px;font-size:13px;font-weight:500}
+.r-status .spin{width:14px;height:14px;border:2px solid var(--ibm-divider);border-top-color:var(--ibm-blue);border-radius:50%;animation:spin .8s linear infinite;flex:0 0 auto}
+@keyframes spin{to{transform:rotate(360deg)}}
+.r-status.err{color:var(--ibm-red)}
+.r-status.ok{color:var(--ibm-green)}
+.r-check{display:inline-flex;width:18px;height:18px;border-radius:50%;background:var(--ibm-green);color:#161616;align-items:center;justify-content:center;font-size:11px;font-weight:700;flex:0 0 auto;animation:pop .3s var(--ease)}
+@keyframes pop{0%{transform:scale(0)}60%{transform:scale(1.15)}100%{transform:scale(1)}}
+
+.r-headline{font-size:18px;font-weight:300;margin:12px 0 4px}
+.r-headline strong{font-weight:600}
+.r-reco{font-size:14px;color:var(--ibm-ink);margin-bottom:14px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
+.pill{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;padding:2px 9px;border-radius:2px}
+.pill.ok{background:var(--ibm-green-fill);color:var(--ibm-green-ink)}
+.pill.warn{background:var(--ibm-amber-fill);color:var(--ibm-amber)}
+.pill.bad{background:var(--ibm-red-fill);color:var(--ibm-red-ink)}
+
+.matches{border-top:1px solid var(--ibm-border);margin-top:6px;padding-top:12px}
+.matches h4{font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--ibm-subtle);margin-bottom:8px;font-weight:600}
+.match{display:flex;justify-content:space-between;gap:12px;padding:5px 0;font-size:13px;border-bottom:1px solid var(--ibm-field)}
+.match:last-child{border-bottom:none}
+.match .m-name{color:var(--ibm-ink);min-width:0;word-break:break-word}
+.match .m-name b{font-weight:600}
+.match .m-sim{font-family:var(--font-mono);color:var(--ibm-muted);font-size:12px;flex:0 0 auto}
+
+.receipt{margin-top:14px;padding-top:12px;border-top:1px solid var(--ibm-border);display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px 20px}
+.receipt-pair{min-width:0}
+.receipt .rk{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--ibm-subtle);margin-bottom:2px}
+.receipt .rv{font-family:var(--font-mono);font-size:12px;color:var(--ibm-ink);word-break:break-all}
+.receipt .rv a{color:var(--ibm-link)}
+
+.raw{margin-top:14px}
+.raw summary{cursor:pointer;font-size:12px;color:var(--ibm-muted);font-weight:500;user-select:none}
+.raw summary:hover{color:var(--ibm-blue)}
+.raw pre{margin-top:10px;background:#161616;color:#e0e0e0;padding:14px 16px;overflow:auto;max-height:300px;font-family:var(--font-mono);font-size:12px;line-height:1.5}
+
+.retry{margin-top:14px;background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink);padding:9px 16px;font-family:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:border-color .12s,color .12s}
+.retry:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+/* Actionable, plain-language guidance under an error (top up / reconnect). */
+.r-tip{font-size:13px;color:var(--ibm-muted);margin:8px 0 0;line-height:1.5;font-weight:300}
+.r-status.err span:last-child{word-break:break-word;min-width:0}
+
+.note{display:flex;gap:14px;margin-top:22px;padding:16px 18px;border:1px solid var(--ibm-border);background:var(--ibm-field)}
+.note svg{flex:0 0 auto;width:20px;height:20px;color:var(--ibm-blue);margin-top:1px}
+.note p{font-size:13px;color:var(--ibm-muted);line-height:1.6;font-weight:300}
+.note p b{color:var(--ibm-ink);font-weight:600}
+.note-aside{display:block;margin-top:8px;padding-top:8px;border-top:1px solid var(--ibm-border);color:var(--ibm-subtle);font-size:12px}
+
+/* ── Forge demo (Demo 03): tier selector, model viewer, result actions ── */
+.tier-row{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:18px}
+.tier{flex:1 1 150px;min-width:0;text-align:left;background:var(--ibm-field);border:1px solid var(--ibm-divider);border-bottom:2px solid var(--ibm-divider);padding:12px 14px;cursor:pointer;font-family:var(--font-sans);color:var(--ibm-ink);transition:border-color .12s,background .12s,transform .04s;border-radius:2px}
+.tier:hover{border-color:var(--ibm-blue);background:var(--ibm-field-focus)}
+.tier:active{transform:translateY(1px)}
+.tier:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
+.tier[aria-checked="true"]{border-color:var(--ibm-blue);border-bottom-color:var(--ibm-blue);background:var(--ibm-field-focus)}
+.tier .t-name{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
+.tier .t-tier{font-size:14px;font-weight:600;text-transform:capitalize}
+.tier .t-price{font-family:var(--font-mono);font-size:13px;color:var(--ibm-blue);font-variant-numeric:tabular-nums}
+.tier .t-blurb{font-size:11px;color:var(--ibm-muted);margin-top:4px;line-height:1.45;font-weight:300}
+.tier .t-eta{font-size:11px;color:var(--ibm-subtle);margin-top:6px;font-family:var(--font-mono)}
+
+.mv-wrap{margin:12px 0 6px;border:1px solid var(--ibm-border);background:var(--ibm-field);position:relative;border-radius:2px;overflow:hidden}
+.mv-wrap model-viewer{display:block;width:100%;height:min(56vh,440px);background:radial-gradient(circle at 50% 30%,#1c2530,#0c1116 70%)}
+.mv-wrap .mv-progress{position:absolute;left:0;bottom:0;height:2px;background:var(--ibm-blue);width:0;transition:width .2s linear}
+
+.r-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px}
+.r-btn{display:inline-flex;align-items:center;gap:7px;background:var(--ibm-blue-fill);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:500;padding:10px 16px;border-radius:2px;text-decoration:none;transition:background .12s,transform .04s}
+.r-btn:hover{background:var(--ibm-blue-fill-hover)}
+.r-btn:active{transform:translateY(1px)}
+.r-btn.ghost{background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink)}
+.r-btn.ghost:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+.r-btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
+
+.forge-foot{font-size:13px;color:var(--ibm-muted);margin-top:18px;font-weight:300}
+.forge-foot a{font-weight:500}
+/* Free text→3D widget — the no-wallet companion to the paid Forge */
+.g3d{margin-top:32px;border:1px solid var(--ibm-border);background:var(--ibm-field);padding:24px}
+.g3d-tag{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-blue);font-weight:500;margin-bottom:8px}
+.g3d h4{font-size:20px;font-weight:300;margin:0 0 8px;color:var(--ibm-ink);max-width:none}
+.g3d h4 strong{font-weight:600}
+.g3d-sub{font-size:14px;color:var(--ibm-muted);line-height:1.6;margin:0 0 20px;max-width:640px}
+.g3d-field{display:flex;gap:1px;flex-wrap:wrap;background:var(--ibm-border)}
+.g3d-input{flex:1 1 280px;min-width:0;font-family:var(--font-sans);font-size:15px;color:var(--ibm-ink);background:var(--ibm-page);border:none;padding:0 16px;height:48px;outline:none}
+.g3d-input:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:-2px}
+.g3d-btn{display:inline-flex;align-items:center;gap:10px;background:var(--ibm-blue);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:15px;font-weight:500;padding:0 24px;height:48px;transition:background .12s,transform .04s}
+.g3d-btn:hover:not(:disabled){background:var(--ibm-blue-hover)}
+.g3d-btn:active:not(:disabled){transform:translateY(1px)}
+.g3d-btn:disabled{opacity:.7;cursor:not-allowed}
+.g3d-btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
+.g3d-spin{width:15px;height:15px;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;display:none}
+.g3d-btn.loading .g3d-spin{display:inline-block}
+.g3d-suggest{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
+.g3d-suggest button{font-family:inherit;font-size:13px;color:var(--ibm-muted);background:transparent;border:1px solid var(--ibm-border);padding:6px 12px;cursor:pointer;transition:border-color .12s,color .12s}
+.g3d-suggest button:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+.g3d-result{margin-top:20px;border:1px solid var(--ibm-border);background:var(--ibm-page)}
+.g3d-result.is-empty{padding:28px 20px;text-align:center;font-size:14px;color:var(--ibm-subtle)}
+.g3d-load{padding:28px 20px}
+.g3d-bar{display:block;height:3px;background:var(--ibm-border);overflow:hidden;margin-bottom:16px}
+.g3d-bar span{display:block;height:100%;width:40%;background:var(--ibm-blue);animation:g3dslide 1.3s ease-in-out infinite}
+@keyframes g3dslide{0%{transform:translateX(-110%)}100%{transform:translateX(360%)}}
+.g3d-loadmsg{font-size:14px;color:var(--ibm-muted);text-align:center}
+.g3d-err{padding:24px 20px;text-align:center}
+.g3d-err p{font-size:14px;color:var(--ibm-muted);margin:0 auto 16px;max-width:440px;line-height:1.6}
+.g3d-retry{font-family:inherit;font-size:14px;font-weight:500;color:#fff;background:var(--ibm-blue);border:none;padding:10px 20px;cursor:pointer;transition:background .12s}
+.g3d-retry:hover{background:var(--ibm-blue-hover)}
+.g3d-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:14px 16px;border-top:1px solid var(--ibm-border)}
+.g3d-act{display:inline-flex;align-items:center;font-family:inherit;font-size:14px;font-weight:500;text-decoration:none;padding:9px 16px;border:1px solid var(--ibm-blue);color:var(--ibm-blue);cursor:pointer;transition:background .12s}
+.g3d-act:hover{background:rgba(15,98,254,.08);text-decoration:none}
+.g3d-act.primary{background:var(--ibm-blue);color:#fff;border-color:var(--ibm-blue)}
+.g3d-act.primary:hover{background:var(--ibm-blue-hover)}
+.g3d-engine{font-size:12px;color:var(--ibm-subtle);margin-left:auto}
+@media(max-width:560px){.g3d-btn{width:100%}.g3d-engine{margin-left:0;width:100%}}
+
+@media(pointer:coarse){.tier,.r-btn{min-height:44px}}
+
+/* embed snippet */
+.embed-block{background:#161616;color:#e0e0e0;border:1px solid #393939;padding:18px 20px;overflow:auto;margin-top:24px;font-family:var(--font-mono);font-size:13px;line-height:1.6;white-space:pre}
+.embed-block .c-tag{color:#82cfff}
+.embed-block .c-attr{color:#a6c8ff}
+.embed-block .c-str{color:#a7f0ba}
+.embed-block .c-com{color:#a8a8a8}
+.copy-row{display:flex;justify-content:flex-end;margin-top:10px}
+.copy-btn{background:none;border:1px solid var(--ibm-divider);color:var(--ibm-muted);font-family:inherit;font-size:12px;font-weight:500;padding:7px 14px;cursor:pointer;transition:border-color .12s,color .12s}
+.copy-btn:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+
+/* footer */
+.footer{padding:40px 0;color:var(--ibm-subtle);font-size:12px}
+.footer-nav{display:flex;flex-wrap:wrap;gap:20px;margin-bottom:18px}
+.footer-nav a{color:var(--ibm-muted);font-weight:500;font-size:13px}
+.footer-nav a:hover{color:var(--ibm-blue)}
+.footer-legal{padding-top:16px;border-top:1px solid var(--ibm-border);line-height:1.6}
+
+/* Tablet: keep the 3-up strip but let it breathe; stack the field row earlier. */
+@media(max-width:768px){
+ .section{padding:32px 0}
+ .hero{padding:44px 0 30px}
+}
+
+@media(max-width:640px){
+ .steps{grid-template-columns:1fr}
+ .demo-head{flex-direction:column;align-items:flex-start;gap:8px}
+ .price-tag{text-align:left}
+ .field-row{gap:14px}
+ .btn{width:100%;min-width:0}
+ .demo-head,.demo-body{padding-left:18px;padding-right:18px}
+}
+
+/* Small phones (≤360px, incl. 320px). Tighten gutters, keep mono strings contained,
+ and never let a long address/hash force a wide layout viewport (the documented iOS
+ overflow gotcha). overflow-wrap:anywhere is the belt-and-braces over word-break. */
+@media(max-width:360px){
+ .inner{padding:0 12px}
+ .demo-head,.demo-body{padding-left:14px;padding-right:14px}
+ .hero h1{font-size:clamp(26px,8vw,34px)}
+ .price-tag .amt{font-size:26px}
+ .preview-row{gap:6px}
+ .preview-row .k{min-width:72px}
+}
+.preview-row .v,.receipt .rv,.match .m-name,.footer-legal{overflow-wrap:anywhere}
+
+/* Touch devices: every interactive control clears the 44×44 px minimum. The
+ coarse-pointer query keeps desktop sizing compact while guaranteeing mobile taps. */
+@media(pointer:coarse){
+ .pv-retry,.retry,.copy-btn,.err-banner button{min-height:44px;padding-top:10px;padding-bottom:10px}
+ .footer-nav a{display:inline-flex;align-items:center;min-height:44px}
+ .raw summary{min-height:44px;display:flex;align-items:center}
+}
+
+/* ── Demo nav strip (hero) ── */
+.demo-nav{display:flex;flex-wrap:wrap;gap:8px;margin-top:26px}
+.demo-nav a{font-size:13px;font-weight:500;color:var(--ibm-ink);border:1px solid var(--ibm-border);padding:8px 14px;border-radius:2px;transition:border-color .12s,color .12s,background .12s}
+.demo-nav a:hover{border-color:var(--ibm-blue);color:var(--ibm-blue);background:var(--ibm-field);text-decoration:none}
+.demo-nav a .n{font-family:var(--font-mono);color:var(--ibm-blue);margin-right:8px;font-size:11px}
+
+/* ── Full-size live demo embed (Forge / Play / IRL) ── */
+/* Each runs at full content width and most of the viewport height — these are
+ real production apps, presented full-size, lazy-loaded as they scroll in. */
+.live-embed{border:1px solid var(--ibm-divider);background:var(--ibm-surface);margin-top:28px}
+.live-embed .embed-bar{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:9px 16px;border-bottom:1px solid var(--ibm-border);font-size:12px;color:var(--ibm-subtle);font-weight:500}
+.live-embed .bar-url{display:inline-flex;align-items:center;gap:8px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-mono)}
+.live-embed .bar-url .dot{width:7px;height:7px;border-radius:50%;background:var(--ibm-amber);flex:0 0 auto;transition:background .2s}
+.live-embed.loaded .bar-url .dot{background:var(--ibm-green)}
+.live-embed.failed .bar-url .dot{background:var(--ibm-red)}
+.live-embed .bar-actions{display:flex;gap:8px;flex:0 0 auto}
+.live-embed .bar-actions button,.live-embed .bar-actions a{background:none;border:1px solid var(--ibm-divider);color:var(--ibm-ink);font-family:inherit;font-size:12px;font-weight:500;padding:6px 11px;cursor:pointer;border-radius:2px;display:inline-flex;align-items:center;gap:5px;text-decoration:none}
+.live-embed .bar-actions button:hover,.live-embed .bar-actions a:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+.embed-frame{position:relative;background:var(--ibm-field);height:min(78vh,820px)}
+.embed-frame iframe{display:block;width:100%;height:100%;border:0;background:var(--ibm-field)}
+/* Play runs the dark `noir` world (?biome=noir) — paint its frame, loading and
+ error states on the same #1c2530→#0c1116 stage the 3D viewers use, so the embed
+ reads as part of that surface in both themes and never flashes a light box. */
+.play-embed .embed-frame,.play-embed .embed-frame iframe,.play-embed .embed-state{background:radial-gradient(circle at 50% 30%,#1c2530,#0c1116 70%)}
+.play-embed .embed-state{color:#aebccd}
+.play-embed .embed-state .es-hint{color:#8a9bb0}
+.play-embed .embed-state .spin{border-color:rgba(255,255,255,.22);border-top-color:#78a9ff}
+/* True full-screen via the Fullscreen API — the app fills the whole display. */
+.live-embed:fullscreen{display:flex;flex-direction:column;background:var(--ibm-surface)}
+.live-embed:fullscreen .embed-frame{flex:1;height:auto}
+.live-embed:-webkit-full-screen{background:var(--ibm-surface)}
+.embed-state{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center;padding:24px;color:var(--ibm-subtle);font-size:14px;background:var(--ibm-field)}
+.embed-state .spin{width:18px;height:18px;border:2px solid var(--ibm-divider);border-top-color:var(--ibm-blue);border-radius:50%;animation:spin .8s linear infinite}
+.embed-state .es-hint{font-size:12px;color:var(--ibm-subtle);max-width:44ch;font-weight:300;line-height:1.55}
+.embed-err{display:none}
+.live-embed.loaded .embed-load{display:none}
+.live-embed.failed .embed-load{display:none}
+.live-embed.failed .embed-err{display:flex}
+.embed-err a{font-weight:600}
+@media(pointer:coarse){.demo-nav a,.live-embed .bar-actions button,.live-embed .bar-actions a{min-height:44px}}
+
+@media(prefers-reduced-motion:reduce){
+ *,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
+}
+</style>
+
+ <link rel="canonical" href="https://three.ws/ibm/x402-demo">
+ <meta property="og:site_name" content="three.ws">
+ <meta property="og:url" content="https://three.ws/ibm/x402-demo">
+ <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=x402+Live+Demo+%28IBM+%C3%97+three.ws%29&amp;d=A+self-contained+x402+micropayment+demo%3A+pay+%240.001+USDC+from+your+own+wallet+%E2%80%94+MetaMask+on+Base+or+Phantom+on+Solana+%E2%80%94+to+call+a+real+three.ws+data+API.+Watch+&amp;p=%2Fibm%2Fx402-demo">
+ <meta property="og:image:width" content="1200">
+ <meta property="og:image:height" content="630">
+ <meta name="twitter:card" content="summary_large_image">
+ <meta name="twitter:title" content="x402 Live Demo (IBM × three.ws) · three.ws">
+ <meta name="twitter:description" content="A self-contained x402 micropayment demo: pay $0.001 USDC from your own wallet — MetaMask on Base or Phantom on Solana — to call a real three.ws data API. Watch the live HTTP 402 challenge, sign a gasless authorization, and see the on-chain settlement receipt. No backend, no account; built as the public face of the IBM × three.ws partnership.">
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=x402+Live+Demo+%28IBM+%C3%97+three.ws%29&amp;d=A+self-contained+x402+micropayment+demo%3A+pay+%240.001+USDC+from+your+own+wallet+%E2%80%94+MetaMask+on+Base+or+Phantom+on+Solana+%E2%80%94+to+call+a+real+three.ws+data+API.+Watch+&amp;p=%2Fibm%2Fx402-demo">
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"x402 Live Demo (IBM × three.ws)","description":"A self-contained x402 micropayment demo: pay $0.001 USDC from your own wallet — MetaMask on Base or Phantom on Solana — to call a real three.ws data API. Watch the live HTTP 402 challenge, sign a gasless authorization, and see the on-chain settlement receipt. No backend, no account; built as the public face of the IBM × three.ws partnership.","url":"https://three.ws/ibm/x402-demo","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <!-- model-viewer renders the GLB returned by the paid Forge demo (Demo 01).
+ Self-hosted (travels with this file under ./vendor/) so the page needs no
+ third-party script CDN — a strict `script-src 'self'` host won't block it.
+ The forged GLBs are uncompressed glTF with embedded textures, so model-viewer
+ loads no external Draco/KTX2 decoder; its only fetch is the GLB from three.ws.
+ It is loaded lazily (see ensureModelViewer below) only after a model is forged,
+ so the 955 KB bundle never costs a page view that doesn't use it, and its bundled
+ Three.js doesn't co-exist with the agent's at idle. -->
+
+ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
+ <meta property="og:locale" content="en_US">
+ <meta property="og:image:alt" content="x402 Live Demo (IBM × three.ws) — three.ws">
+ <meta name="twitter:site" content="@trythreews">
+</head>
+<body>
+
+<a href="#forge" class="skip-link">Skip to the demos</a>
+
+<div class="err-banner" id="errBanner" role="alert">
+ <span id="errBannerText">Something went wrong.</span>
+ <button type="button" id="errBannerClose">Dismiss</button>
+</div>
+
+<!-- ══ IBM MASTHEAD + BREADCRUMB ══
+ The IBM.com global-navigation design language: a thin top bar with the IBM
+ wordmark, primary product links (to real ibm.com destinations), and the
+ search / account / app-grid icons, followed by a content breadcrumb. The
+ masthead logo is the neutral IBM Plex wordmark, NOT the registered 8-bar
+ mark — a defensible placeholder; confirm the exact lockup with IBM brand
+ before public launch (see HOSTING.md, "Note on branding"). -->
+<style id="ibm-shell-styles">
+.ibm-mast{position:sticky;top:0;z-index:40;background:var(--ibm-surface);border-bottom:1px solid var(--ibm-border)}
+.ibm-mast .mast-inner{display:flex;align-items:center;height:48px;padding:0 16px;gap:0}
+.ibm-mast .mast-logo{display:inline-flex;align-items:center;height:100%;padding:0 16px 0 0;font-weight:700;font-size:18px;letter-spacing:-.01em;color:var(--ibm-ink);line-height:1}
+.ibm-mast .mast-logo:hover{text-decoration:none;color:var(--ibm-blue)}
+.ibm-mast .mast-logo:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:-2px}
+.ibm-mast .mast-nav{display:flex;align-items:stretch;height:100%;flex:1 1 auto;min-width:0}
+.ibm-mast .mast-nav a{display:inline-flex;align-items:center;height:100%;padding:0 16px;font-size:14px;font-weight:400;color:var(--ibm-ink);border-bottom:2px solid transparent;transition:background .12s,border-color .12s,color .12s}
+.ibm-mast .mast-nav a:hover{background:var(--ibm-field);text-decoration:none;border-bottom-color:var(--ibm-blue)}
+.ibm-mast .mast-nav a:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:-2px}
+.ibm-mast .mast-actions{display:flex;align-items:stretch;height:100%;margin-left:auto;flex:0 0 auto}
+.ibm-mast .mast-actions a{display:inline-flex;align-items:center;justify-content:center;width:48px;height:100%;color:var(--ibm-ink);transition:background .12s,color .12s}
+.ibm-mast .mast-actions a:hover{background:var(--ibm-field);color:var(--ibm-blue)}
+.ibm-mast .mast-actions a:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:-2px}
+.ibm-mast .mast-actions svg{width:20px;height:20px;display:block}
+.breadcrumb{border-bottom:1px solid var(--ibm-border)}
+.breadcrumb ol{display:flex;flex-wrap:wrap;align-items:center;gap:8px;list-style:none;margin:0 auto;max-width:880px;padding:14px 16px;font-size:14px}
+.breadcrumb li{display:inline-flex;align-items:center;gap:8px;color:var(--ibm-subtle)}
+.breadcrumb li+li::before{content:"/";color:var(--ibm-divider);font-size:14px}
+.breadcrumb a{color:var(--ibm-link)}
+.breadcrumb a:hover{text-decoration:underline}
+.breadcrumb [aria-current="page"]{color:var(--ibm-subtle)}
+@media(max-width:671px){
+ .ibm-mast .mast-nav{display:none}
+ .breadcrumb ol{padding:12px}
+}
+</style>
+<nav class="ibm-mast" aria-label="IBM">
+ <div class="mast-inner">
+ <a class="mast-logo" href="https://www.ibm.com" target="_blank" rel="noopener" aria-label="IBM home">IBM</a>
+ <div class="mast-nav">
+ <a href="https://www.ibm.com/products/software" target="_blank" rel="noopener">Software</a>
+ <a href="https://www.ibm.com/infrastructure" target="_blank" rel="noopener">Infrastructure</a>
+ <a href="https://www.ibm.com/consulting" target="_blank" rel="noopener">Consulting</a>
+ <a href="https://www.ibm.com/support" target="_blank" rel="noopener">Support</a>
+ <a href="https://www.ibm.com/think" target="_blank" rel="noopener">Think</a>
+ </div>
+ <div class="mast-actions">
+ <a href="https://www.ibm.com/search" target="_blank" rel="noopener" aria-label="Search ibm.com">
+ <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="14" cy="14" r="9"/><path d="M21 21l6 6" stroke-linecap="round"/></svg>
+ </a>
+ <a href="https://www.ibm.com/profile" target="_blank" rel="noopener" aria-label="IBM account">
+ <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="16" cy="11" r="5"/><path d="M6 27c0-5 4.5-8 10-8s10 3 10 8" stroke-linecap="round"/></svg>
+ </a>
+ <a href="https://www.ibm.com" target="_blank" rel="noopener" aria-label="IBM products and tools">
+ <svg viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"><rect x="4" y="4" width="7" height="7"/><rect x="13" y="4" width="7" height="7"/><rect x="22" y="4" width="7" height="7"/><rect x="4" y="13" width="7" height="7"/><rect x="13" y="13" width="7" height="7"/><rect x="22" y="13" width="7" height="7"/><rect x="4" y="22" width="7" height="7"/><rect x="13" y="22" width="7" height="7"/><rect x="22" y="22" width="7" height="7"/></svg>
+ </a>
+ </div>
+ </div>
+</nav>
+<nav class="breadcrumb" aria-label="Breadcrumb">
+ <ol>
+ <li><a href="https://www.ibm.com" target="_blank" rel="noopener">Home</a></li>
+ <li><a href="https://www.ibm.com/partnerplus" target="_blank" rel="noopener">Strategic Partnerships</a></li>
+ <li><span aria-current="page">three.ws</span></li>
+ </ol>
+</nav>
+
+<!-- ══ HERO ══ -->
+<header class="hero">
+ <div class="inner">
+ <p class="hero-eyebrow">Strategic partnership</p>
+ <h1>IBM and <strong>three.ws</strong> partnership</h1>
+ <p class="hero-sub">IBM® and three.ws work together to unite payments, data, 3D and AI — pairing IBM Granite on watsonx.ai with three.ws's on-chain micropayments and 3D agent engine, so developers and brands can deliver trusted, personalized agent experiences at scale.</p>
+ <div class="hero-cta">
+ <a class="btn" href="#forge">Explore the live demos <span class="arrow" aria-hidden="true">→</span></a>
+ <a class="btn-tertiary" href="https://three.ws/docs/ibm" target="_blank" rel="noopener">Explore IBM and three.ws technology collaborations <span aria-hidden="true">→</span></a>
+ </div>
+ <p class="hero-note">Every demo below runs against real, production three.ws systems: pay a few cents to turn text into a 3D model, forge a rigged avatar from a sentence, pose it by hand, fly a 3D galaxy of agents mapped by <span class="mono">IBM Granite</span>, enter a shared world, or place an agent in augmented reality. The paid Forge settles real USDC — or <span class="mono">$THREE</span> — from your own wallet; the rest are free, no wallet needed. Nothing is mocked.</p>
+ <nav class="demo-nav" aria-label="The demos on this page">
+ <a href="#webinar" class="nav-live"><span class="live-dot" aria-hidden="true"></span>Watch live</a>
+ <a href="#forge"><span class="n">01</span>Forge</a>
+ <a href="#demo"><span class="n">02</span>Avatars</a>
+ <a href="#pose"><span class="n">03</span>Pose</a>
+ <a href="#galaxy"><span class="n">04</span>Galaxy</a>
+ <a href="#play"><span class="n">05</span>Play</a>
+ <a href="#irl"><span class="n">06</span>IRL</a>
+ </nav>
+ </div>
+</header>
+
+<main>
+<!-- ══ WEBINAR · live stage (countdown → synced premiere / live OBS) ══ -->
+<style id="wb-styles">
+.webinar{padding:34px 0 40px;border-bottom:1px solid var(--ibm-border)}
+.wb-head{margin-bottom:18px}
+.wb-stage{position:relative;aspect-ratio:16/9;width:100%;background:
+ radial-gradient(120% 120% at 80% -10%,rgba(15,98,254,.28),transparent 55%),
+ radial-gradient(90% 90% at 0% 110%,rgba(120,169,255,.16),transparent 55%),#0b0b0d;
+ border:1px solid var(--ibm-divider);overflow:hidden;border-radius:2px}
+.wb-fill{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:20px;color:#fff}
+.wb-fill[hidden]{display:none}
+.wb-kicker{font-family:var(--font-mono);font-size:12px;letter-spacing:.12em;text-transform:uppercase;color:#a6c8ff;margin-bottom:6px}
+.wb-stage-title{font-size:clamp(18px,3.4vw,28px);font-weight:300;line-height:1.15;max-width:560px;margin:0 0 22px;color:#fff}
+.wb-stage-title strong{font-weight:600}
+.wb-countdown{display:flex;align-items:flex-start;gap:clamp(8px,2.4vw,22px);font-variant-numeric:tabular-nums}
+.wb-cell{display:flex;flex-direction:column;align-items:center;min-width:54px}
+.wb-num{font-size:clamp(34px,7.2vw,66px);font-weight:200;line-height:1;color:#fff}
+.wb-lbl{font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:rgba(255,255,255,.62);margin-top:8px}
+.wb-colon{font-size:clamp(28px,6vw,54px);font-weight:200;color:rgba(255,255,255,.35);line-height:1;padding-top:2px}
+.wb-soon{margin-top:20px;font-size:13px;color:rgba(255,255,255,.7);max-width:440px;line-height:1.55}
+.wb-spinner{width:34px;height:34px;border:3px solid rgba(255,255,255,.25);border-top-color:#78a9ff;border-radius:50%;animation:wbspin .9s linear infinite;margin-bottom:14px}
+@keyframes wbspin{to{transform:rotate(360deg)}}
+.wb-retry{margin-top:18px;background:rgba(255,255,255,.12);color:#fff;border:1px solid rgba(255,255,255,.4);cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:600;padding:9px 16px;border-radius:2px;transition:background .12s}
+.wb-retry[hidden]{display:none}
+.wb-retry:hover{background:rgba(255,255,255,.22)}
+.wb-retry:focus-visible{outline:2px solid #fff;outline-offset:2px}
+.wb-player{position:absolute;inset:0;background:#000}
+.wb-player[hidden]{display:none}
+.wb-player>video,.wb-player>iframe{width:100%;height:100%;display:block;border:0;background:#000;object-fit:contain}
+.wb-badge{position:absolute;top:12px;left:12px;z-index:3;display:inline-flex;align-items:center;gap:7px;background:rgba(218,30,40,.95);color:#fff;font-family:var(--font-sans);font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;padding:5px 10px;border-radius:2px}
+.wb-badge[hidden]{display:none}
+.wb-badge .d{width:7px;height:7px;border-radius:50%;background:#fff;animation:wbpulse 1.4s var(--ease) infinite}
+@keyframes wbpulse{0%,100%{opacity:1}50%{opacity:.25}}
+.wb-unmute{position:absolute;bottom:14px;right:14px;z-index:3;display:inline-flex;align-items:center;gap:8px;background:rgba(255,255,255,.94);color:#161616;border:none;cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:600;padding:9px 14px;border-radius:2px;box-shadow:0 4px 16px rgba(0,0,0,.4)}
+.wb-unmute[hidden]{display:none}
+.wb-unmute:hover{background:#fff}
+.wb-unmute:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
+.wb-meta{display:flex;flex-wrap:wrap;align-items:center;gap:14px;justify-content:space-between;margin-top:16px}
+.wb-when{font-size:14px;color:var(--ibm-muted);font-weight:300}
+.wb-when b{color:var(--ibm-ink);font-weight:500}
+.wb-actions{display:flex;flex-wrap:wrap;gap:10px}
+.wb-cal{display:inline-flex;align-items:center;gap:8px;background:transparent;color:var(--ibm-link);border:1px solid var(--ibm-divider);cursor:pointer;font-family:var(--font-sans);font-size:13px;font-weight:500;padding:8px 14px;border-radius:2px;text-decoration:none;transition:border-color .12s,background .12s}
+.wb-cal:hover{border-color:var(--ibm-blue);background:var(--ibm-field)}
+.wb-cal:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px}
+.wb-cal svg{width:15px;height:15px;flex:0 0 auto}
+.demo-nav a.nav-live .live-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--ibm-red);margin-right:7px;vertical-align:middle;animation:wbpulse 1.4s var(--ease) infinite}
+.wb-gate{gap:0}
+.wb-gate[hidden]{display:none}
+.wb-lock{width:34px;height:34px;color:#78a9ff;margin-bottom:16px}
+.wb-gate-row{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:6px;width:100%;max-width:420px}
+.wb-gate-input{flex:1 1 220px;min-width:0;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.38);color:#fff;font-family:var(--font-sans);font-size:15px;padding:0 14px;height:46px;border-radius:2px}
+.wb-gate-input::placeholder{color:rgba(255,255,255,.55)}
+.wb-gate-input:focus-visible{outline:2px solid #78a9ff;outline-offset:1px;background:rgba(255,255,255,.14)}
+.wb-gate-btn{flex:0 0 auto;background:var(--ibm-blue-fill);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:15px;font-weight:500;padding:0 22px;height:46px;border-radius:2px;transition:background .12s}
+.wb-gate-btn:hover{background:var(--ibm-blue-fill-hover)}
+.wb-gate-btn:focus-visible{outline:2px solid #fff;outline-offset:2px}
+.wb-gate-err{margin-top:14px;font-size:13px;color:#ffb3b8}
+.wb-gate-err[hidden]{display:none}
+</style>
+<section class="section webinar" id="webinar" aria-labelledby="wb-h">
+ <div class="inner">
+ <div class="wb-head">
+ <div class="section-tag">Live · IBM community webinar</div>
+ <h2 id="wb-h">Watch the <strong>live walkthrough</strong></h2>
+ <p class="section-lead">A guided tour of x402 micropayments and 3D AI agents — with every demo on this page running in real time. Can't make it live? The recording stays right here afterward.</p>
+ </div>
+
+ <div class="wb-stage" id="wbStage" role="region" aria-label="Webinar player">
+ <span class="wb-badge" id="wbBadge" hidden><span class="d" aria-hidden="true"></span>Live now</span>
+
+ <!-- PRE-EVENT · countdown -->
+ <div class="wb-fill wb-pre" id="wbPre">
+ <div class="wb-kicker" id="wbKicker">Starts in</div>
+ <h3 class="wb-stage-title" id="wbStageTitle">three.ws × <strong>IBM</strong> — agentic commerce, live</h3>
+ <div class="wb-countdown" id="wbCountdown" role="timer" aria-live="off" aria-label="Time until the webinar begins">
+ <div class="wb-cell"><span class="wb-num" id="wbD">00</span><span class="wb-lbl">Days</span></div>
+ <span class="wb-colon" aria-hidden="true">:</span>
+ <div class="wb-cell"><span class="wb-num" id="wbH">00</span><span class="wb-lbl">Hours</span></div>
+ <span class="wb-colon" aria-hidden="true">:</span>
+ <div class="wb-cell"><span class="wb-num" id="wbM">00</span><span class="wb-lbl">Minutes</span></div>
+ <span class="wb-colon" aria-hidden="true">:</span>
+ <div class="wb-cell"><span class="wb-num" id="wbS">00</span><span class="wb-lbl">Seconds</span></div>
+ </div>
+ <p class="wb-soon" id="wbSoon">Add it to your calendar so you don't miss it.</p>
+ </div>
+
+ <!-- LIVE · stream not yet attached, or a designed error state (graceful) -->
+ <div class="wb-fill wb-holding" id="wbHolding" hidden>
+ <div class="wb-spinner" id="wbSpinner" aria-hidden="true"></div>
+ <h3 class="wb-stage-title" id="wbHoldTitle">We're about to begin</h3>
+ <p class="wb-soon" id="wbHoldMsg">The stream will appear here the moment it starts.</p>
+ <button class="wb-retry" id="wbRetry" type="button" hidden>Reload the player</button>
+ </div>
+
+ <!-- POST-EVENT · password-gated replay -->
+ <form class="wb-fill wb-gate" id="wbGate" hidden>
+ <svg class="wb-lock" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><rect x="4" y="11" width="16" height="9" rx="1.5"/><path d="M8 11V8a4 4 0 018 0v3"/></svg>
+ <h3 class="wb-stage-title">This session has ended</h3>
+ <p class="wb-soon" id="wbGateMsg">The replay is private. Enter the access password to watch the recording.</p>
+ <div class="wb-gate-row">
+ <input class="wb-gate-input" id="wbGateInput" type="password" autocomplete="off" autocapitalize="off" spellcheck="false" aria-label="Replay access password" placeholder="Access password">
+ <button class="wb-gate-btn" id="wbGateBtn" type="submit">Unlock</button>
+ </div>
+ <p class="wb-gate-err" id="wbGateErr" role="alert" hidden>That password didn't match. Try again.</p>
+ </form>
+
+ <!-- LIVE / REPLAY · player mounts here -->
+ <div class="wb-player" id="wbPlayer" hidden></div>
+ <button class="wb-unmute" id="wbUnmute" type="button" hidden>
+ <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 00-2.5-4v8a4.5 4.5 0 002.5-4z"/></svg>
+ Tap to unmute
+ </button>
+ </div>
+
+ <div class="wb-meta">
+ <div class="wb-when" id="wbWhen">Loading the schedule…</div>
+ <div class="wb-actions">
+ <a class="wb-cal" id="wbGcal" href="#" target="_blank" rel="noopener">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/></svg>
+ Google Calendar
+ </a>
+ <button class="wb-cal" id="wbIcs" type="button">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"/></svg>
+ Add to calendar (.ics)
+ </button>
+ </div>
+ </div>
+ </div>
+</section>
+<script>
+/* Webinar stage — countdown → wall-clock-synced premiere or live OBS feed.
+ Self-contained, no platform API dependency, so it runs verbatim on live.ibm.com.
+
+ ─────────────────────────────────────────────────────────────────────────────
+ TO GO LIVE: edit the WEBINAR config below. Today only `startTime` matters —
+ the stage shows a countdown to it. When the recording or stream is ready,
+ paste ONE source (vodHls / mp4 / liveHls / youTubeId) and the stage becomes
+ the player automatically. Recommended host: Cloudflare Stream (one product
+ does both the uploaded recording's HLS and an OBS RTMP/SRT live ingest);
+ a plain MP4 on R2 is the zero-setup fallback for a pre-recorded talk.
+ ───────────────────────────────────────────────────────────────────────────── */
+(function () {
+ const WEBINAR = {
+ // ⚠️ SET THE REAL START TIME — ISO 8601 with timezone offset (Z = UTC).
+ // Set to 6:00 PM Pacific on Jun 24, 2026. June is daylight time (PDT =
+ // UTC−7), so the −07:00 offset below is the correct "6pm Pacific" — it
+ // equals 2026-06-25T01:00:00Z. If you literally mean PST (UTC−8), change
+ // the offset to −08:00; if the talk is a different calendar day, change
+ // the date.
+ startTime: '2026-06-24T18:00:00-07:00',
+ durationMin: 60, // SET to the recorded video's length → when the stage flips to "replay"
+ title: 'three.ws × IBM — agentic commerce, live',
+ details: 'A live walkthrough of x402 micropayments and 3D AI agents on three.ws. Demos run in real time at https://three.ws/ibm/x402-demo',
+ location: 'https://three.ws/ibm/x402-demo',
+
+ // ── Video source — leave ALL blank for countdown-only. Fill exactly ONE
+ // when ready. Resolution priority: liveHls → vodHls → mp4 → youTubeId.
+ liveHls: '', // OBS → ingest → HLS (.m3u8) live feed
+ vodHls: '', // Cloudflare Stream / Mux HLS (.m3u8) of the recording (synced premiere)
+ mp4: '', // ⭐ PRE-RECORDED TALK: paste a web-optimized MP4 URL here (synced premiere).
+ // Self-host on a three.ws-served origin so the host CSP's media-src
+ // can allow it without a third-party CDN; a plain MP4 needs no hls.js.
+ youTubeId: '', // YouTube video / live id → iframe (its own premiere/live)
+ // 'premiere' = a finished recording played wall-clock-synced so it behaves
+ // like a live broadcast (the plan for Jun 24). Switch to 'live' ONLY for a
+ // real OBS/RTMP feed via liveHls.
+ mode: 'premiere', // 'auto' | 'premiere' | 'live'
+
+ // ── After the event ENDS — what the stage becomes once the countdown is over
+ // and the slot has passed. Leave blank for the default "Thanks for joining"
+ // card. Set endLoop to a muted MP4 (e.g. a highlight reel / ambient loop) and
+ // it plays full-stage, looping forever, the instant the countdown expires.
+ // A real recording (vodHls/mp4 above) always wins over this — those become a
+ // proper replay; endLoop is the no-recording fallback so the stage never dies.
+ endLoop: '', // looped, muted highlight reel shown after the event ends (MP4)
+
+ // ── REPLAY POLICY — what the recording does once the live window has passed.
+ // 'password' — the replay is private, gated behind replayPasswordSha256.
+ // With no hash set it stays fully locked (the "ended" card),
+ // so the talk is never freely replayable.
+ // 'off' — no replay at all; the stage shows the "session ended" card.
+ // 'open' — the recording becomes a normal, seekable replay (legacy).
+ replay: 'off',
+ // SHA-256 hex of the replay password — NOT the password itself, so it can't
+ // be read from page source. Generate it once:
+ // echo -n 'your-password' | shasum -a 256
+ // (browser) crypto.subtle.digest('SHA-256', new TextEncoder().encode('your-password'))
+ // .then(b => console.log([...new Uint8Array(b)].map(x=>x.toString(16).padStart(2,'0')).join('')))
+ // Leave blank to keep the replay locked until you set it. NOTE: a client-side
+ // gate keeps casual viewers out, but once unlocked the MP4 URL is visible in
+ // the network panel — for hard protection, serve the video from signed/
+ // expiring URLs (e.g. Cloudflare Stream signed playback).
+ replayPasswordSha256: '',
+ };
+
+ const startMs = Date.parse(WEBINAR.startTime);
+ if (!Number.isFinite(startMs)) { console.warn('[webinar] invalid startTime'); return; }
+ const endMs = startMs + WEBINAR.durationMin * 60_000;
+
+ const $ = (id) => document.getElementById(id);
+ const stage = $('wbStage'), pre = $('wbPre'), holding = $('wbHolding'),
+ player = $('wbPlayer'), badge = $('wbBadge'), unmute = $('wbUnmute'),
+ gate = $('wbGate'), gateInput = $('wbGateInput'), gateErr = $('wbGateErr');
+
+ // Replay gate: a 64-hex SHA-256 of the access password. The plaintext password
+ // is never in the page — we hash what the viewer types and compare.
+ const REPLAY_HASH = String(WEBINAR.replayPasswordSha256 || '').trim().toLowerCase();
+ const replayHashSet = /^[0-9a-f]{64}$/.test(REPLAY_HASH);
+ async function sha256Hex(str) {
+ const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(str));
+ return Array.from(new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, '0')).join('');
+ }
+
+ const hasSource = !!(WEBINAR.liveHls || WEBINAR.vodHls || WEBINAR.mp4 || WEBINAR.youTubeId);
+ const isLiveSource = WEBINAR.mode === 'live' || (WEBINAR.mode === 'auto' && !!WEBINAR.liveHls && !WEBINAR.vodHls && !WEBINAR.mp4);
+
+ // QA preview: ?wb=live | premiere | ended | countdown forces a phase, so the
+ // player and the live path can be verified before the event without waiting on
+ // the clock. Harmless in production — only takes effect when the param is set.
+ const qaParam = (new URLSearchParams(location.search).get('wb') || '').toLowerCase();
+ const QA_PHASE = { live: 'live', premiere: 'live', preview: 'live', ended: 'ended', countdown: 'pre' }[qaParam] || null;
+ $('wbRetry').addEventListener('click', () => location.reload());
+
+ // ── Schedule label + calendar links ──────────────────────────────────────
+ const startDate = new Date(startMs);
+ const whenStr = startDate.toLocaleString(undefined, {
+ weekday: 'long', month: 'long', day: 'numeric',
+ hour: 'numeric', minute: '2-digit', timeZoneName: 'short',
+ });
+ $('wbWhen').innerHTML = '<b>' + whenStr + '</b> · ' + WEBINAR.durationMin + ' min';
+
+ const icsStamp = (ms) => new Date(ms).toISOString().replace(/[-:]/g, '').replace(/\.\d{3}/, '');
+ const gcal = new URL('https://calendar.google.com/calendar/render');
+ gcal.searchParams.set('action', 'TEMPLATE');
+ gcal.searchParams.set('text', WEBINAR.title);
+ gcal.searchParams.set('dates', icsStamp(startMs) + '/' + icsStamp(endMs));
+ gcal.searchParams.set('details', WEBINAR.details);
+ gcal.searchParams.set('location', WEBINAR.location);
+ $('wbGcal').href = gcal.toString();
+
+ $('wbIcs').addEventListener('click', () => {
+ const ics = [
+ 'BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:-//three.ws//webinar//EN',
+ 'BEGIN:VEVENT', 'UID:' + icsStamp(startMs) + '@three.ws',
+ 'DTSTAMP:' + icsStamp(Date.now()), 'DTSTART:' + icsStamp(startMs), 'DTEND:' + icsStamp(endMs),
+ 'SUMMARY:' + WEBINAR.title,
+ 'DESCRIPTION:' + WEBINAR.details.replace(/,/g, '\\,'),
+ 'LOCATION:' + WEBINAR.location, 'END:VEVENT', 'END:VCALENDAR',
+ ].join('\r\n');
+ const url = URL.createObjectURL(new Blob([ics], { type: 'text/calendar' }));
+ const a = document.createElement('a');
+ a.href = url; a.download = 'three-ws-ibm-webinar.ics';
+ document.body.appendChild(a); a.click(); a.remove();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+ });
+
+ // ── Countdown ─────────────────────────────────────────────────────────────
+ const pad = (n) => String(n).padStart(2, '0');
+ let phase = '';
+ function render() {
+ const now = Date.now();
+ let next = now < startMs ? 'pre' : (now < endMs ? 'live' : 'ended');
+ if (QA_PHASE) next = QA_PHASE;
+ if (now < startMs) {
+ let s = Math.floor((startMs - now) / 1000);
+ const d = Math.floor(s / 86400); s -= d * 86400;
+ const h = Math.floor(s / 3600); s -= h * 3600;
+ const m = Math.floor(s / 60); s -= m * 60;
+ $('wbD').textContent = pad(d); $('wbH').textContent = pad(h);
+ $('wbM').textContent = pad(m); $('wbS').textContent = pad(s);
+ }
+ if (next !== phase) { phase = next; applyPhase(); }
+ }
+
+ function applyPhase() {
+ if (phase === 'pre') return; // countdown already visible
+ pre.hidden = true;
+ if (phase === 'ended') { enterEnded(); clearInterval(timer); return; }
+ // Live window:
+ if (!hasSource) { holding.hidden = false; return; } // awaiting source
+ mountPlayer();
+ clearInterval(timer);
+ }
+
+ // Static "session ended" card — no video. Used when there's no recording, when
+ // replay is 'off', or when a password gate has no hash set yet (stays locked).
+ function endedCard(msg) {
+ pre.hidden = true; player.hidden = true; player.innerHTML = '';
+ badge.hidden = true; unmute.hidden = true; if (gate) gate.hidden = true;
+ holding.hidden = false;
+ $('wbSpinner').style.display = 'none';
+ $('wbHoldTitle').textContent = 'This session has ended';
+ $('wbHoldMsg').textContent = msg || 'Thanks for joining.';
+ $('wbRetry').hidden = true;
+ }
+
+ function showGate() {
+ pre.hidden = true; holding.hidden = true; player.hidden = true; player.innerHTML = '';
+ badge.hidden = true; unmute.hidden = true;
+ gate.hidden = false;
+ setTimeout(() => { try { gateInput.focus(); } catch (_) {} }, 0);
+ }
+
+ // The recording is private once the live window closes. Route per REPLAY POLICY:
+ // 'open' → seekable replay; 'off' or password-without-hash → locked card;
+ // 'password' (+hash) → gate, unless this tab already unlocked it.
+ function enterEnded() {
+ if (!hasSource) {
+ if (WEBINAR.endLoop) { mountLoop(); return; }
+ endedCard('Thanks for joining. The recording will be posted shortly.');
+ return;
+ }
+ if (WEBINAR.replay === 'open') { mountPlayer(); return; }
+ if (WEBINAR.replay === 'password' && replayHashSet) {
+ let unlocked = false;
+ try { unlocked = sessionStorage.getItem('wbReplayOk') === '1'; } catch (_) {}
+ if (unlocked) { mountPlayer(); return; }
+ showGate();
+ return;
+ }
+ endedCard(WEBINAR.replay === 'off'
+ ? 'Thanks for joining. The live session has ended.'
+ : 'Thanks for joining. This recording is private.');
+ }
+
+ if (gate) gate.addEventListener('submit', async (e) => {
+ e.preventDefault();
+ const val = gateInput.value || '';
+ if (!val) { gateInput.focus(); return; }
+ let ok = false;
+ try { ok = (await sha256Hex(val)) === REPLAY_HASH; } catch (_) { ok = false; }
+ if (ok) {
+ try { sessionStorage.setItem('wbReplayOk', '1'); } catch (_) {}
+ gate.hidden = true;
+ mountPlayer();
+ } else {
+ gateErr.hidden = false;
+ gateInput.value = ''; gateInput.focus();
+ }
+ });
+
+ // ── Player ──────────────────────────────────────────────────────────────
+ function loadHls() {
+ return new Promise((res, rej) => {
+ if (window.Hls) return res(window.Hls);
+ const s = document.createElement('script');
+ s.src = 'https://cdn.jsdelivr.net/npm/[email protected]/dist/hls.min.js';
+ s.onload = () => res(window.Hls); s.onerror = () => rej(new Error('hls.js load failed'));
+ document.head.appendChild(s);
+ });
+ }
+
+ // Designed, actionable error state — reuse the holding card with a retry.
+ function showError(msg) {
+ if (player) { player.hidden = true; player.innerHTML = ''; }
+ badge.hidden = true; unmute.hidden = true;
+ holding.hidden = false;
+ $('wbSpinner').style.display = 'none';
+ $('wbHoldTitle').textContent = 'Playback hit a snag';
+ $('wbHoldMsg').textContent = msg || 'The stream is temporarily unavailable.';
+ $('wbRetry').hidden = false;
+ }
+
+ // Post-event ambient loop: a muted, controls-free MP4 that covers the stage and
+ // repeats forever once the event is over. If it can't load, fall back to the
+ // calm "thanks" card so the stage is never a black void.
+ function mountLoop() {
+ pre.hidden = true; holding.hidden = true; badge.hidden = true; unmute.hidden = true;
+ player.hidden = false; player.innerHTML = '';
+ const v = document.createElement('video');
+ v.src = WEBINAR.endLoop;
+ v.loop = true; v.muted = true; v.autoplay = true; v.playsInline = true;
+ v.setAttribute('controlslist', 'nodownload');
+ v.addEventListener('error', () => {
+ player.hidden = true; player.innerHTML = '';
+ holding.hidden = false;
+ $('wbSpinner').style.display = 'none';
+ $('wbHoldTitle').textContent = 'Thanks for joining';
+ $('wbHoldMsg').textContent = 'The recording will be posted here shortly.';
+ });
+ player.appendChild(v);
+ v.play().catch(() => {});
+ }
+
+ async function mountPlayer() {
+ holding.hidden = true; player.hidden = false;
+ // A synced premiere should read as "Live now" during its window — that's the
+ // whole point — so the badge shows for a true live feed AND a premiere, and
+ // only hides once we're past the slot (replay).
+ badge.hidden = phase !== 'live';
+
+ if (WEBINAR.youTubeId) {
+ const offset = Math.max(0, Math.floor((Date.now() - startMs) / 1000));
+ const p = new URLSearchParams({ autoplay: '1', mute: '1', modestbranding: '1', rel: '0', playsinline: '1' });
+ if (!isLiveSource && phase === 'live') p.set('start', String(offset));
+ const f = document.createElement('iframe');
+ f.src = 'https://www.youtube-nocookie.com/embed/' + WEBINAR.youTubeId + '?' + p.toString();
+ f.allow = 'autoplay; encrypted-media; picture-in-picture; fullscreen';
+ f.allowFullscreen = true; f.title = WEBINAR.title;
+ player.appendChild(f);
+ return;
+ }
+
+ const video = document.createElement('video');
+ // During a premiere's live window, hide the native controls entirely: a seek
+ // bar would expose the fixed duration and give away that it's a recording. No
+ // scrubber + the "Live now" badge + can't-skip-ahead reads as a real stream.
+ // Full controls return for the replay once the window has passed (and when the
+ // video ends on its own).
+ const livePremiere = !isLiveSource && phase === 'live';
+ video.playsInline = true; video.controls = !livePremiere; video.muted = true;
+ video.setAttribute('controlslist', 'nodownload noplaybackrate');
+ player.appendChild(video);
+
+ const src = WEBINAR.liveHls || WEBINAR.vodHls || WEBINAR.mp4;
+ const isHls = /\.m3u8(\?|$)/i.test(src);
+ let usingHls = false;
+ try {
+ if (isHls && !video.canPlayType('application/vnd.apple.mpegurl')) {
+ const Hls = await loadHls();
+ if (Hls.isSupported()) {
+ usingHls = true;
+ const hls = new Hls({ lowLatencyMode: isLiveSource });
+ // Fatal-error recovery: retry network/media a few times, then surface a
+ // clean error rather than leaving a black frame.
+ let recover = 0;
+ hls.on(Hls.Events.ERROR, (_evt, data) => {
+ if (!data || !data.fatal) return;
+ if (data.type === Hls.ErrorTypes.NETWORK_ERROR && recover < 3) { recover++; hls.startLoad(); }
+ else if (data.type === Hls.ErrorTypes.MEDIA_ERROR && recover < 3) { recover++; hls.recoverMediaError(); }
+ else { hls.destroy(); showError('The stream is temporarily unavailable — it may not have started yet.'); }
+ });
+ hls.loadSource(src); hls.attachMedia(video);
+ } else { video.src = src; }
+ } else {
+ video.src = src; // native HLS (Safari) or MP4
+ }
+ } catch (e) { showError('We couldn’t start the player. Reload to try again.'); return; }
+
+ // Native media error (MP4 / Safari HLS). The hls.js path reports through its
+ // own ERROR event above, so skip this listener when hls.js owns the element.
+ video.addEventListener('error', () => { if (!usingHls) showError('We couldn’t load the video — it may not be available yet.'); });
+
+ // Premiere sync: a finished recording behaves like a broadcast — join at the
+ // point the talk is actually at, and (during the live window) can't skip ahead.
+ const isPremiere = !isLiveSource;
+ video.addEventListener('loadedmetadata', () => {
+ if (isPremiere && phase === 'live') {
+ const offset = (Date.now() - startMs) / 1000;
+ if (offset > 0 && offset < (video.duration || Infinity)) video.currentTime = offset;
+ }
+ }, { once: true });
+ if (isPremiere && phase === 'live') {
+ video.addEventListener('seeking', () => {
+ const edge = (Date.now() - startMs) / 1000 + 1.5;
+ if (video.currentTime > edge) video.currentTime = Math.max(0, edge - 1.5);
+ });
+ }
+
+ video.play().then(() => {
+ if (video.muted) unmute.hidden = false; // autoplay needs muted; offer one-tap unmute
+ }).catch(() => { unmute.hidden = false; });
+
+ unmute.addEventListener('click', () => {
+ video.muted = false; unmute.hidden = true; video.play().catch(() => {});
+ });
+
+ // When the recording finishes, honor the replay policy. An open replay (or a
+ // viewer who already unlocked it this session) gets full scrub controls; an
+ // otherwise-private recording is taken off screen and re-gated so it isn't
+ // left freely playable once the live moment has passed.
+ video.addEventListener('ended', () => {
+ let unlocked = false;
+ try { unlocked = sessionStorage.getItem('wbReplayOk') === '1'; } catch (_) {}
+ if (WEBINAR.replay === 'open' || unlocked) { video.controls = true; badge.hidden = true; return; }
+ player.hidden = true; player.innerHTML = '';
+ if (WEBINAR.replay === 'password' && replayHashSet) showGate();
+ else endedCard(WEBINAR.replay === 'off'
+ ? 'Thanks for joining. The live session has ended.'
+ : 'Thanks for joining. This recording is private.');
+ });
+ }
+
+ // Assign the interval BEFORE the first render() so an at/after-start load that
+ // clears it on the opening tick doesn't hit `timer` in its temporal dead zone.
+ let timer = setInterval(render, 1000);
+ render();
+})();
+</script>
+
+<!-- ══ DEMO 01 · FORGE (paid x402 prompt→3D) ══ -->
+<section class="section" id="forge" aria-labelledby="forge-h">
+ <div class="inner">
+ <div class="section-tag">Demo 01 · Creation</div>
+ <h2 id="forge-h">Forge a <strong>3D model</strong> from a sentence</h2>
+ <p class="section-lead">This pays the same x402 rail as the demo below — one micropayment, in USDC or <span class="mono">$THREE</span> on Solana, runs a real text→3D pipeline (Microsoft TRELLIS on NVIDIA NIM) and hands back a textured GLB you can orbit and download. The price below is read live from the server's own 402 response; pick your token in the wallet.</p>
+
+ <div class="demo">
+ <div class="demo-head">
+ <div>
+ <h3 class="demo-title">three<span>.ws</span> Forge</h3>
+ <div class="demo-desc">Describe one object; pay; get back a textured, downloadable 3D model. Runs Microsoft TRELLIS on NVIDIA NIM (native text→mesh) — the same engine that builds the bodies our agents wear.</div>
+ </div>
+ <div class="price-tag">
+ <div class="amt" id="fgPriceAmt" aria-hidden="true">$<strong>0.05</strong></div>
+ <div class="net" aria-hidden="true">USDC or $THREE · per model</div>
+ <span class="sr-only" id="fgPriceSr">Price: five cents per generation, payable in USDC or $THREE on Solana.</span>
+ </div>
+ </div>
+
+ <div class="demo-body">
+ <!-- live 402 preview -->
+ <div class="preview" id="fgPreview" role="region" aria-label="Live HTTP 402 payment challenge" aria-live="polite" aria-busy="true">
+ <div class="preview-label" id="fgPvLabel"><span class="dot" aria-hidden="true"></span><span id="fgPvLabelText">Reading the server's 402 challenge…</span></div>
+ <div id="fgPvRows">
+ <div class="preview-row"><span class="sk" style="width:38%"></span></div>
+ <div class="preview-row"><span class="sk" style="width:54%"></span></div>
+ <div class="preview-row"><span class="sk" style="width:46%"></span></div>
+ </div>
+ </div>
+
+ <!-- quality tier -->
+ <div class="tier-row" id="fgTiers" role="radiogroup" aria-label="Generation quality tier">
+ <button class="tier" type="button" role="radio" aria-checked="true" tabindex="0" data-tier="draft">
+ <span class="t-name"><span class="t-tier">Draft</span><span class="t-price" data-price>$0.05</span></span>
+ <span class="t-blurb">Fast preview geometry. Best to try the flow.</span>
+ <span class="t-eta" data-eta>~40s</span>
+ </button>
+ <button class="tier" type="button" role="radio" aria-checked="false" tabindex="-1" data-tier="standard">
+ <span class="t-name"><span class="t-tier">Standard</span><span class="t-price" data-price>$0.15</span></span>
+ <span class="t-blurb">Balanced detail. The default for most assets.</span>
+ <span class="t-eta" data-eta>~60s</span>
+ </button>
+ <button class="tier" type="button" role="radio" aria-checked="false" tabindex="-1" data-tier="high">
+ <span class="t-name"><span class="t-tier">High</span><span class="t-price" data-price>$0.50</span></span>
+ <span class="t-blurb">Maximum geometry + PBR textures. Slower.</span>
+ <span class="t-eta" data-eta>~130s</span>
+ </button>
+ </div>
+
+ <!-- input -->
+ <div class="field-row">
+ <div class="field-wrap">
+ <label for="fgPrompt">Describe the object</label>
+ <input id="fgPrompt" class="field" value="a brass steampunk owl, full body" maxlength="1000" autocomplete="off" spellcheck="true" inputmode="text" aria-describedby="fgPromptHint">
+ <div class="field-hint" id="fgPromptHint">One subject works best — describe it in a sentence.</div>
+ </div>
+ <button id="fgBtn" class="btn" type="button"><span class="spin" aria-hidden="true"></span><span class="label">Pay $0.05 &amp; forge</span> <span class="arrow" aria-hidden="true">→</span></button>
+ </div>
+ <div class="wallet-hint" id="fgWalletHint">On a phone? Open this page inside your <b>Phantom</b> wallet's in-app browser to pay.</div>
+
+ <!-- result. Not a live region (its success state holds a raw-JSON block);
+ concise spoken updates go to #fgAnnouncer instead. -->
+ <div id="fgResult" class="result is-empty">
+ Forge a model to see it appear here — orbit it, then download the GLB.
+ </div>
+ <p id="fgAnnouncer" class="sr-only" role="status" aria-live="polite"></p>
+
+ <!-- requirements -->
+ <div class="note">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>
+ <p>You'll need the <b>Phantom</b> wallet on <b>Solana</b> — holding the model's price in <b>USDC</b>, or the equivalent in <b>$THREE</b>, on Solana mainnet. This spends <b>real funds</b> — the price shown above — from your own wallet; the wallet lets you pick USDC or <b>$THREE</b>. The payment itself is a gasless signature: the network fee is sponsored by the x402 facilitator, so it isn't added to your cost. Generation runs once the payment verifies and takes roughly a minute. No wallet? Forge one <b>free</b> below — no wallet, no key, no payment.</p>
+ </div>
+ </div>
+ </div>
+
+ <!-- Free, no-wallet companion to the paid Forge above. Same text→3D
+ pipeline (Microsoft TRELLIS on NVIDIA NIM), on the house — no wallet,
+ no key, no payment. POSTs the free /api/forge lane and polls it. -->
+ <div class="g3d">
+ <div class="g3d-tag">Live · Free · No wallet</div>
+ <h4 id="g3d-h">Or forge one <strong>free</strong> — no wallet needed</h4>
+ <p class="g3d-sub">The same pipeline, on the house. No wallet, no API key, no payment — it runs Microsoft TRELLIS on NVIDIA NIM with automatic fallback across generation lanes, so a textured GLB always comes back to orbit and download.</p>
+ <div class="g3d-field">
+ <label for="g3dPrompt" class="sr-only">Describe an object to generate for free</label>
+ <input id="g3dPrompt" class="g3d-input" value="a brass steampunk owl, full body" maxlength="600" autocomplete="off" spellcheck="true" inputmode="text" aria-describedby="g3d-h">
+ <button id="g3dBtn" class="g3d-btn" type="button"><span class="g3d-spin" aria-hidden="true"></span><span class="g3d-label">Generate free</span> <span aria-hidden="true">→</span></button>
+ </div>
+ <div class="g3d-suggest" id="g3dSuggest" aria-label="Example prompts">
+ <button type="button" data-p="a low-poly red fox, sitting">low-poly fox</button>
+ <button type="button" data-p="a glossy ceramic teapot with gold trim">ceramic teapot</button>
+ <button type="button" data-p="a futuristic delivery drone">delivery drone</button>
+ <button type="button" data-p="a worn leather hiking boot">hiking boot</button>
+ </div>
+ <div id="g3dResult" class="g3d-result is-empty">
+ Describe an object and generate — your model appears here to orbit and download.
+ </div>
+ <p id="g3dStatus" class="sr-only" role="status" aria-live="polite"></p>
+ </div>
+
+ <p class="forge-foot">Want image→3D, auto-rigging, AR preview and the full gallery? <a href="https://three.ws/forge" target="_blank" rel="noopener">Open the full Forge tool ↗</a></p>
+ </div>
+</section>
+
+<!-- ══ HOW IT WORKS ══ -->
+<section class="section" aria-labelledby="how-h">
+ <div class="inner">
+ <div class="section-tag">The protocol in three moves</div>
+ <h2 id="how-h">How <strong>x402</strong> works</h2>
+ <ol class="steps">
+ <li class="step">
+ <div class="step-n">01 · REQUEST</div>
+ <h3>You ask normally</h3>
+ <p>A plain <code>GET</code> to a paid endpoint — no payment attached yet.</p>
+ </li>
+ <li class="step">
+ <div class="step-n">02 · 402 CHALLENGE</div>
+ <h3>Server quotes a price</h3>
+ <p>It replies <code>402</code> with exactly what it wants: amount, asset, network, and the address to pay.</p>
+ </li>
+ <li class="step">
+ <div class="step-n">03 · PAY &amp; RETRY</div>
+ <h3>Wallet signs, call settles</h3>
+ <p>You sign a gasless USDC authorization, resend with an <code>X-PAYMENT</code> header, and the call settles on-chain — your data comes back.</p>
+ </li>
+ </ol>
+ </div>
+</section>
+
+<!-- ══ LIVE DEMO ══ -->
+<!-- ══ DEMO 02 · AVATARS (free text→mesh→auto-rig→animated) ══ -->
+<style id="av-styles">
+.av-forge{margin-top:28px;border:1px solid var(--ibm-divider);background:var(--ibm-surface)}
+.av-head{padding:22px 24px 18px;border-bottom:1px solid var(--ibm-border)}
+.av-head h3{font-size:20px;font-weight:600}
+.av-head h3 span{color:var(--ibm-blue)}
+.av-head p{font-size:13px;color:var(--ibm-muted);font-weight:300;max-width:540px;margin-top:4px;line-height:1.55}
+.av-body{padding:22px 24px}
+.av-field{display:flex;gap:1px;flex-wrap:wrap;background:var(--ibm-border)}
+.av-input{flex:1 1 280px;min-width:0;font-family:var(--font-sans);font-size:15px;color:var(--ibm-ink);background:var(--ibm-surface);border:none;padding:0 16px;height:48px;outline:none}
+.av-input:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:-2px}
+.av-btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;background:var(--ibm-blue-fill);color:#fff;border:none;cursor:pointer;font-family:var(--font-sans);font-size:15px;font-weight:500;padding:0 24px;height:48px;transition:background .12s,transform .04s}
+.av-btn:hover:not(:disabled){background:var(--ibm-blue-fill-hover)}
+.av-btn:active:not(:disabled){transform:translateY(1px)}
+.av-btn:disabled{opacity:.7;cursor:not-allowed}
+.av-btn:focus-visible{outline:2px solid var(--ibm-blue);outline-offset:2px;box-shadow:0 0 0 4px rgba(15,98,254,.25)}
+.av-spin{width:15px;height:15px;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite;display:none}
+.av-btn.loading .av-spin{display:inline-block}
+.av-suggest{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
+.av-suggest button{font-family:inherit;font-size:13px;color:var(--ibm-muted);background:transparent;border:1px solid var(--ibm-border);padding:6px 12px;cursor:pointer;transition:border-color .12s,color .12s}
+.av-suggest button:hover{border-color:var(--ibm-blue);color:var(--ibm-blue)}
+/* pipeline step indicator — mesh → rig → animate */
+.av-steps{display:flex;flex-wrap:wrap;gap:8px;margin:20px 0 0;list-style:none;padding:0;counter-reset:av}
+.av-steps li{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--ibm-subtle);font-weight:500;border:1px solid var(--ibm-border);padding:6px 12px;border-radius:2px;transition:color .2s,border-color .2s}
+.av-steps li .dot{width:7px;height:7px;border-radius:50%;background:var(--ibm-divider);flex:0 0 auto;transition:background .2s}
+.av-steps li.active{color:var(--ibm-blue);border-color:var(--ibm-blue)}
+.av-steps li.active .dot{background:var(--ibm-blue);animation:dotpulse 1.2s var(--ease) infinite}
+.av-steps li.done{color:var(--ibm-green-ink);border-color:var(--ibm-green)}
+.av-steps li.done .dot{background:var(--ibm-green)}
+.av-result{margin-top:20px;border:1px solid var(--ibm-border);background:var(--ibm-field)}
+.av-result.is-empty{padding:44px 20px;text-align:center;font-size:14px;color:var(--ibm-subtle);border-style:dashed}
+.av-stage{position:relative;min-height:460px;background:radial-gradient(circle at 50% 30%,#1c2530,#0c1116 70%)}
+.av-stage agent-3d,.av-stage model-viewer{display:block;width:100%;height:460px}
+.av-load{padding:44px 20px}
+.av-bar{display:block;height:3px;background:var(--ibm-border);overflow:hidden;margin-bottom:16px}
+.av-bar span{display:block;height:100%;width:40%;background:var(--ibm-blue);animation:g3dslide 1.3s ease-in-out infinite}
+.av-loadmsg{font-size:14px;color:var(--ibm-muted);text-align:center}
+.av-err{padding:28px 20px;text-align:center}
+.av-err p{font-size:14px;color:var(--ibm-muted);margin:0 auto 16px;max-width:460px;line-height:1.6}
+.av-retry{font-family:inherit;font-size:14px;font-weight:500;color:#fff;background:var(--ibm-blue-fill);border:none;padding:10px 20px;cursor:pointer;transition:background .12s}
+.av-retry:hover{background:var(--ibm-blue-fill-hover)}
+.av-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:14px 16px;border-top:1px solid var(--ibm-border);background:var(--ibm-surface)}
+.av-act{display:inline-flex;align-items:center;font-family:inherit;font-size:14px;font-weight:500;text-decoration:none;padding:9px 16px;border:1px solid var(--ibm-blue);color:var(--ibm-blue);cursor:pointer;transition:background .12s}
+.av-act:hover{background:rgba(15,98,254,.08);text-decoration:none}
+.av-act.primary{background:var(--ibm-blue-fill);color:#fff;border-color:var(--ibm-blue-fill)}
+.av-act.primary:hover{background:var(--ibm-blue-fill-hover)}
+.av-engine{font-size:12px;color:var(--ibm-subtle);margin-left:auto}
+@media(max-width:560px){.av-btn{width:100%}.av-engine{margin-left:0;width:100%}}
+@media(pointer:coarse){.av-act,.av-retry,.av-suggest button{min-height:44px}}
+</style>
+<section class="section" id="demo" aria-labelledby="demo-h">
+ <div class="inner">
+ <div class="section-tag">Demo 02 · Avatars</div>
+ <h2 id="demo-h">Forge a <strong>living avatar</strong> from a sentence</h2>
+ <p class="section-lead">Describe a character; three.ws generates the textured mesh, auto-rigs a skeleton, and drops it straight into the avatar engine — where it stands, breathes, and waves. Free, no wallet. The same universal rig that lets <em>any</em> humanoid wear our animation library, running live in your browser.</p>
+
+ <div class="av-forge">
+ <div class="av-head">
+ <h3 class="demo-title">three<span>.ws</span> Avatar Forge</h3>
+ <p>Text → textured mesh (Microsoft TRELLIS on NVIDIA NIM) → auto-rigged skeleton → animated avatar. No payment, no API key — a generation lane kept free for everyone.</p>
+ </div>
+ <div class="av-body">
+ <div class="av-field">
+ <label for="avPrompt" class="sr-only">Describe a character to generate</label>
+ <input id="avPrompt" class="av-input" value="a brass steampunk knight, full body" maxlength="600" autocomplete="off" spellcheck="true" inputmode="text">
+ <button id="avBtn" class="av-btn" type="button"><span class="av-spin" aria-hidden="true"></span><span class="av-label">Forge avatar</span> <span aria-hidden="true">→</span></button>
+ </div>
+ <div class="av-suggest" id="avSuggest" aria-label="Example characters">
+ <button type="button" data-p="a brass steampunk knight, full body">Steampunk knight</button>
+ <button type="button" data-p="a friendly cartoon astronaut, full body">Cartoon astronaut</button>
+ <button type="button" data-p="a wise wizard in a flowing blue robe, full body">Blue wizard</button>
+ <button type="button" data-p="a sleek cyberpunk ninja, full body">Cyberpunk ninja</button>
+ </div>
+
+ <ol class="av-steps" id="avSteps" aria-hidden="true">
+ <li data-step="mesh"><span class="dot" aria-hidden="true"></span>Generate mesh</li>
+ <li data-step="rig"><span class="dot" aria-hidden="true"></span>Auto-rig skeleton</li>
+ <li data-step="animate"><span class="dot" aria-hidden="true"></span>Animate</li>
+ </ol>
+
+ <div id="avResult" class="av-result is-empty">Forge a character to watch it come to life here.</div>
+ <p id="avStatus" class="sr-only" role="status" aria-live="polite"></p>
+
+ <div class="note">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>
+ <p>Every avatar here is generated and rigged on demand — <b>no template library, no canned characters</b>. The rig maps to three.ws's canonical skeleton, so the same idle, walk and emote clips play on whatever you describe. Want image→3D, your own GLB upload, or AR preview? <a href="https://three.ws/forge" target="_blank" rel="noopener">Open the full Forge tool ↗</a> <span class="note-aside">The free lane has an hourly cap so it stays free for everyone; if it's busy it tells you exactly when to retry. Generation runs on NVIDIA NIM and auto-falls back across lanes, so a model always comes back.</span></p>
+ </div>
+ </div>
+ </div>
+ </div>
+</section>
+
+<!-- ══ DEMO 03 · POSE (live MannequinRig — the lite Pose Studio slice) ══ -->
+<section class="section" id="pose" aria-labelledby="pose-h">
+ <div class="inner">
+ <div class="section-tag">Demo 03 · Motion</div>
+ <h2 id="pose-h">Pose a figure <strong>by hand</strong></h2>
+ <p class="section-lead">Every avatar three.ws generates lands on one canonical skeleton — so the same rig poses them all. Orbit the mannequin, grab a limb to move it (inverse kinematics on hands and feet), nudge a joint with the sliders, or tap a preset to morph the whole pose. It's the exact rig behind the full <a href="https://three.ws/pose" target="_blank" rel="noopener">Pose Studio</a>, running live on the page.</p>
+ <div class="live-embed" data-src="https://three.ws/pose-mini" data-allow="fullscreen" data-label="Pose Studio (lite) — three.ws">
+ <div class="embed-bar">
+ <span class="bar-url"><span class="dot" aria-hidden="true"></span>three.ws/pose</span>
+ <span class="bar-actions">
+ <button type="button" data-fs>⤢ Full screen</button>
+ <a href="https://three.ws/pose" target="_blank" rel="noopener">Open the studio ↗</a>
+ </span>
+ </div>
+ <div class="embed-frame">
+ <div class="embed-load embed-state"><span class="spin" aria-hidden="true"></span><span>Loading the live rig…</span></div>
+ <div class="embed-err embed-state">The poser couldn't load inline here. <span class="es-hint"><a href="https://three.ws/pose" target="_blank" rel="noopener">Open it in a new tab ↗</a></span></div>
+ </div>
+ </div>
+ </div>
+</section>
+
+<!-- ══ DEMO 04 · AGENT GALAXY (live IBM Granite semantic 3D map) ══ -->
+<section class="section" id="galaxy" aria-labelledby="galaxy-h">
+ <div class="inner">
+ <div class="section-tag">Demo 04 · Intelligence</div>
+ <h2 id="galaxy-h">Every agent, <strong>mapped by meaning</strong></h2>
+ <p class="section-lead">Fly through a 3D constellation of every AI agent on three.ws — each one placed in space by what it <em>means</em>, not by name or date. Coordinates come from <strong>IBM Granite</strong> embeddings on watsonx.ai, so agents that do similar things sit in the same neighbourhood; Granite names each constellation. Search by meaning and watch the matching stars light up. It runs full-size, right on the page.</p>
+ <div class="live-embed" data-src="https://three.ws/galaxy" data-allow="fullscreen; xr-spatial-tracking" data-label="Agent Galaxy — three.ws × IBM Granite">
+ <div class="embed-bar">
+ <span class="bar-url"><span class="dot" aria-hidden="true"></span>three.ws/galaxy</span>
+ <span class="bar-actions">
+ <button type="button" data-fs>⤢ Full screen</button>
+ <a href="https://three.ws/galaxy" target="_blank" rel="noopener">New tab ↗</a>
+ </span>
+ </div>
+ <div class="embed-frame">
+ <div class="embed-load embed-state"><span class="spin" aria-hidden="true"></span><span>Mapping the galaxy with IBM Granite…</span></div>
+ <div class="embed-err embed-state">The galaxy couldn't load inline here. <span class="es-hint"><a href="https://three.ws/galaxy" target="_blank" rel="noopener">Open it in a new tab ↗</a></span></div>
+ </div>
+ </div>
+ </div>
+</section>
+
+<!-- ══ DEMO 05 · PLAY ══ -->
+<section class="section" id="play" aria-labelledby="play-h">
+ <div class="inner">
+ <div class="section-tag">Demo 05 · Worlds</div>
+ <h2 id="play-h">Play — drop an agent into a <strong>live world</strong></h2>
+ <p class="section-lead">Every coin on three.ws is a 3D space agents and visitors share in real time — walk in, pick an avatar, and move around a world that reacts to live on-chain activity. Pick a name and a body below to enter; it runs full-size, right on the page.</p>
+ <div class="live-embed play-embed" data-src="https://three.ws/play?biome=noir" data-allow="fullscreen; gamepad; autoplay; xr-spatial-tracking; microphone" data-label="Play — three.ws">
+ <div class="embed-bar">
+ <span class="bar-url"><span class="dot" aria-hidden="true"></span>three.ws/play</span>
+ <span class="bar-actions">
+ <button type="button" data-fs>⤢ Full screen</button>
+ <a href="https://three.ws/play" target="_blank" rel="noopener">New tab ↗</a>
+ </span>
+ </div>
+ <div class="embed-frame">
+ <div class="embed-load embed-state"><span class="spin" aria-hidden="true"></span><span>Loading the live world…</span></div>
+ <div class="embed-err embed-state">Play couldn't load inline here. <span class="es-hint"><a href="https://three.ws/play" target="_blank" rel="noopener">Open it in a new tab ↗</a></span></div>
+ </div>
+ </div>
+ </div>
+</section>
+
+<!-- ══ DEMO 06 · IRL ══ -->
+<section class="section" id="irl" aria-labelledby="irl-h">
+ <div class="inner">
+ <div class="section-tag">Demo 06 · Reality</div>
+ <h2 id="irl-h">IRL — put an agent in the <strong>real world</strong></h2>
+ <p class="section-lead">Anchor a 3D agent to physical space and see it through your camera, with real-world pins you place around you — you stay in control of every permission. AR is a phone experience, so it's best opened on a mobile device; the live surface is below, and the camera prompt only fires when you choose to enable it.</p>
+ <div class="live-embed" data-src="https://three.ws/irl" data-allow="camera; gyroscope; accelerometer; magnetometer; xr-spatial-tracking; fullscreen" data-label="IRL — three.ws">
+ <div class="embed-bar">
+ <span class="bar-url"><span class="dot" aria-hidden="true"></span>three.ws/irl</span>
+ <span class="bar-actions">
+ <button type="button" data-fs>⤢ Full screen</button>
+ <a href="https://three.ws/irl" target="_blank" rel="noopener">Open on your phone ↗</a>
+ </span>
+ </div>
+ <div class="embed-frame">
+ <div class="embed-load embed-state"><span class="spin" aria-hidden="true"></span><span>Loading IRL…</span></div>
+ <div class="embed-err embed-state">IRL couldn't load inline here — augmented reality works best opened directly on a phone. <span class="es-hint"><a href="https://three.ws/irl" target="_blank" rel="noopener">Open it on your device ↗</a></span></div>
+ </div>
+ </div>
+ </div>
+</section>
+
+<!-- ══ EMBED ══ -->
+<style id="three-x402-styles">
+.x402-live{margin-top:28px;border:1px solid var(--ibm-border);background:var(--ibm-surface)}
+.x402-live .xl-head{padding:16px 18px;border-bottom:1px solid var(--ibm-border)}
+.x402-live .xl-kicker{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--ibm-blue);font-weight:500;margin-bottom:6px}
+.x402-live .xl-title{font-size:18px;font-weight:600}
+.x402-live .xl-body{padding:18px}
+.x402-live .xl-row{display:flex;flex-wrap:wrap;align-items:center;gap:16px 24px;margin-top:16px}
+.x402-live .xl-note{font-size:12.5px;color:var(--ibm-subtle);margin-top:14px;line-height:1.55}
+.ti-result{margin-top:18px}
+.ti-empty{font-size:14px;color:var(--ibm-subtle);line-height:1.6;margin:0}
+.ti-topline{display:flex;align-items:center;gap:12px;margin-bottom:14px}
+.ti-sym{font-size:20px;font-weight:600}
+.ti-signal{display:inline-flex;align-items:center;gap:7px;padding:5px 12px;font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;border-radius:2px}
+.ti-signal::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
+.ti-signal.bullish{background:var(--ibm-green-fill);color:var(--ibm-green-ink)}
+.ti-signal.bearish{background:var(--ibm-red-fill);color:var(--ibm-red-ink)}
+.ti-signal.neutral{background:var(--ibm-amber-fill);color:var(--ibm-amber)}
+.ti-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(118px,1fr));gap:1px;background:var(--ibm-border);border:1px solid var(--ibm-border)}
+.ti-cell{background:var(--ibm-surface);padding:12px 14px}
+.ti-cell .k{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ibm-subtle);margin-bottom:5px}
+.ti-cell .v{font-size:16px;font-weight:600;font-family:var(--font-mono)}
+.ti-cell .v.ti-up{color:var(--ibm-green-ink)}
+.ti-cell .v.ti-down{color:var(--ibm-red-ink)}
+.ti-headline{font-size:15px;font-weight:600;margin:16px 0 6px}
+.ti-rationale{font-size:14px;color:var(--ibm-muted);line-height:1.55;margin:0}
+.ti-meta{font-size:12px;color:var(--ibm-subtle);margin-top:12px;font-family:var(--font-mono)}
+</style>
+<section class="section" aria-labelledby="embed-h">
+ <div class="inner">
+ <div class="section-tag">For developers</div>
+ <h2 id="embed-h">Add a paywall in <strong>eight lines</strong></h2>
+ <p class="section-lead">The paid Forge demo above is powered by one drop-in script. Any element with a <span class="mono">data-x402-endpoint</span> opens the wallet flow on click — no framework, no build step, no SDK.</p>
+ <div class="embed-block" id="embedCode"><span class="c-com">&lt;!-- one script tag, served from three.ws --&gt;</span>
+<span class="c-tag">&lt;script</span> <span class="c-attr">type</span>=<span class="c-str">"module"</span> <span class="c-attr">src</span>=<span class="c-str">"https://three.ws/x402.js"</span><span class="c-tag">&gt;&lt;/script&gt;</span>
+
+<span class="c-com">&lt;!-- any element with data-x402-endpoint becomes payable --&gt;</span>
+<span class="c-tag">&lt;button</span>
+ <span class="c-attr">data-x402-endpoint</span>=<span class="c-str">"https://three.ws/api/x402/three-intel"</span>
+ <span class="c-attr">data-x402-merchant</span>=<span class="c-str">"three.ws"</span>
+ <span class="c-attr">data-x402-action</span>=<span class="c-str">"$THREE intel"</span><span class="c-tag">&gt;</span>
+ Pay $0.01 &amp; get $THREE intel
+<span class="c-tag">&lt;/button&gt;</span></div>
+ <div class="copy-row"><button class="copy-btn" id="copyBtn" type="button">Copy snippet</button></div>
+
+ <!-- The snippet above, wired live. x402.js (loaded near </body>) binds any
+ [data-x402-endpoint]; this is the same $THREE Town Oracle the in-world
+ kiosk on /play buys from, settled in real USDC or $THREE over x402. -->
+ <div class="x402-live" id="threeOracle">
+ <div class="xl-head">
+ <div class="xl-kicker">Live · runs right here</div>
+ <div class="xl-title">The <span class="mono">$THREE</span> Town Oracle</div>
+ </div>
+ <div class="xl-body">
+ <p class="section-lead" style="margin-top:0">That exact button, wired to the real endpoint. Pay <strong>$0.01 USDC</strong> from your own wallet and get live <span class="mono">$THREE</span> market intel — price, 24-hour move, market cap, liquidity, volume, and a bullish / bearish / neutral signal — from the same oracle the paid kiosk in the <span class="mono">$THREE</span> town on <a href="https://three.ws/play" target="_blank" rel="noopener">/play</a> sells from.</p>
+ <div class="xl-row">
+ <button class="btn" id="threeOracleBtn" type="button"
+ data-x402-endpoint="https://three.ws/api/x402/three-intel"
+ data-x402-merchant="three.ws"
+ data-x402-action="$THREE market intel">
+ <span class="label">Pay $0.01 &amp; fetch live $THREE intel</span> <span class="arrow" aria-hidden="true">→</span>
+ </button>
+ <a class="btn-tertiary" href="https://pump.fun/FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump" target="_blank" rel="noopener">View <span class="mono">$THREE</span> on pump.fun <span aria-hidden="true">→</span></a>
+ </div>
+ <div class="ti-result" id="threeOracleResult" aria-live="polite">
+ <p class="ti-empty">You'll get back price, 24-hour change, market cap, liquidity, 24-hour volume, and a signal with a short rationale — live from DexScreener. Settles in USDC or <span class="mono">$THREE</span> on Solana (USDC on Base); the network fee is sponsored by the facilitator.</p>
+ </div>
+ <p class="xl-note">Spends $0.01 of real funds from your wallet — pay in USDC, or in <span class="mono">$THREE</span> on Solana. The only coin three.ws issues is <span class="mono">$THREE</span> &middot; <span class="mono">FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump</span>.</p>
+ </div>
+ </div>
+ </div>
+</section>
+</main>
+
+<!-- ══ FOOTER ══ -->
+<footer class="footer">
+ <div class="inner">
+ <nav class="footer-nav" aria-label="Footer">
+ <a href="https://three.ws" target="_blank" rel="noopener">Platform</a>
+ <a href="https://three.ws/docs/x402" target="_blank" rel="noopener">x402 Protocol</a>
+ <a href="https://three.ws/docs/ibm" target="_blank" rel="noopener">IBM × three.ws</a>
+ <a href="https://three.ws/bazaar" target="_blank" rel="noopener">Endpoint Bazaar</a>
+ <a href="https://three.ws/forge" target="_blank" rel="noopener">Forge</a>
+ <a href="https://three.ws/pose" target="_blank" rel="noopener">Pose</a>
+ <a href="https://three.ws/play" target="_blank" rel="noopener">Play</a>
+ <a href="https://three.ws/irl" target="_blank" rel="noopener">IRL</a>
+ <a href="https://three.ws/changelog" target="_blank" rel="noopener">Changelog</a>
+ </nav>
+ <div class="footer-legal">
+ Live x402 demo · three.ws, an IBM Business Partner. Payments settle in USDC on Base or Solana mainnet — or in $THREE on Solana — via the x402 protocol. The only coin this platform issues is $THREE (FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump).
+ </div>
+ </div>
+</footer>
+
+<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry) -->
+<script type="module" src="https://three.ws/x402.js"></script>
+<!-- <agent-3d> web component — the whole 3D agent framework in one tag. Lazy-boots when scrolled into view. -->
+<script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script>
+
+<script>
+(function () {
+ 'use strict';
+
+ var $ = function (id) { return document.getElementById(id); };
+
+ // ── global resilience net ────────────────────────────────────────────────
+ // Last-ditch catch for an unexpected throw or rejected promise, so a visitor
+ // sees a calm, dismissible notice instead of a half-rendered panel. It is
+ // deliberately conservative: this page also loads a lazy-booting 3D agent,
+ // <model-viewer>, and cross-origin embeds, all of which own their own failure
+ // UI. Their noise (and opaque cross-origin "Script error." with no detail, or
+ // aborted fetches) must never raise an alarming banner on an IBM property.
+ // Shows once; the close button re-arms it.
+ var bannerShown = false;
+ function showBanner(msg) {
+ var b = $('errBanner'); if (!b || bannerShown) return;
+ bannerShown = true;
+ $('errBannerText').textContent = msg || 'Something went wrong. Reload the page if it persists.';
+ b.classList.add('show');
+ }
+ // Noise, or failures owned by a third-party module that renders its own state.
+ var BENIGN_ERR = /ResizeObserver|^Script error\.?$|model-viewer|agent-3d|esm\.sh|WebGL|webgl|\.glb\b|Loading chunk|importing a module|dynamically imported|AbortError|The operation was aborted|NetworkError when attempting/i;
+ function isBenignReason(reason) {
+ if (reason == null) return true; // no detail → not actionable
+ if (reason.name === 'AbortError' || reason.code === 'cancelled') return true;
+ var text = reason.message ? reason.message : String(reason);
+ return BENIGN_ERR.test(text);
+ }
+ window.addEventListener('error', function (e) {
+ // No message → opaque cross-origin error (carries nothing actionable); skip.
+ if (!e || !e.message || BENIGN_ERR.test(e.message)) return;
+ showBanner('A script error occurred. The demo may be degraded — reload to recover.');
+ });
+ window.addEventListener('unhandledrejection', function (e) {
+ if (isBenignReason(e && e.reason)) return;
+ showBanner('A background request failed. Check your connection, then retry below.');
+ });
+ $('errBannerClose').addEventListener('click', function () {
+ $('errBanner').classList.remove('show'); bannerShown = false;
+ });
+
+ // ── full-size demo embeds (Galaxy / Play / IRL) ────────────────────────────
+ // Each presents a real, framable production surface at full size. The iframe
+ // is created only as the section nears the viewport (IntersectionObserver),
+ // so three heavy apps never load at once on first paint. A load timeout falls
+ // back to an "open in a new tab" path; the Full-screen button uses the real
+ // Fullscreen API.
+ function loadEmbed(embed) {
+ if (embed.dataset.loaded === '1') return;
+ embed.dataset.loaded = '1';
+ var frame = embed.querySelector('.embed-frame');
+ var iframe = document.createElement('iframe');
+ iframe.title = embed.getAttribute('data-label') || 'three.ws demo';
+ iframe.loading = 'lazy';
+ // `data-allow` already carries `fullscreen`, which is the modern Permissions-Policy
+ // way to grant it; adding the legacy `allowfullscreen` attribute too just makes the
+ // browser warn that `allow` takes precedence, so we rely on `allow` alone.
+ iframe.setAttribute('allow', embed.getAttribute('data-allow') || '');
+ iframe.setAttribute('referrerpolicy', 'no-referrer-when-downgrade');
+ var timer = setTimeout(function () {
+ if (!embed.classList.contains('loaded')) embed.classList.add('failed');
+ }, 15000);
+ iframe.addEventListener('load', function () {
+ clearTimeout(timer);
+ embed.classList.add('loaded');
+ });
+ iframe.src = embed.getAttribute('data-src');
+ frame.appendChild(iframe);
+ }
+ function wireLiveEmbeds() {
+ var embeds = document.querySelectorAll('.live-embed');
+ Array.prototype.forEach.call(embeds, function (embed) {
+ var fsBtn = embed.querySelector('[data-fs]');
+ if (fsBtn) fsBtn.addEventListener('click', function () {
+ var req = embed.requestFullscreen || embed.webkitRequestFullscreen;
+ if (req) { try { req.call(embed); } catch (_) {} }
+ else { window.open(embed.getAttribute('data-src'), '_blank', 'noopener'); }
+ });
+ });
+ if ('IntersectionObserver' in window) {
+ var io = new IntersectionObserver(function (entries) {
+ entries.forEach(function (e) {
+ if (e.isIntersecting) { loadEmbed(e.target); io.unobserve(e.target); }
+ });
+ }, { rootMargin: '400px 0px' });
+ Array.prototype.forEach.call(embeds, function (embed) { io.observe(embed); });
+ } else {
+ Array.prototype.forEach.call(embeds, loadEmbed);
+ }
+ }
+
+ $('copyBtn').addEventListener('click', function () {
+ var snippet =
+ '<script type="module" src="https://three.ws/x402.js"><\/script>\n\n' +
+ '<button\n' +
+ ' data-x402-endpoint="https://three.ws/api/x402/three-intel"\n' +
+ ' data-x402-merchant="three.ws"\n' +
+ ' data-x402-action="$THREE intel">\n' +
+ ' Pay $0.01 & get $THREE intel\n' +
+ '</button>';
+ var done = function (label) { var b = $('copyBtn'); b.textContent = label; setTimeout(function () { b.textContent = 'Copy snippet'; }, 1600); };
+ if (navigator.clipboard && navigator.clipboard.writeText) {
+ navigator.clipboard.writeText(snippet).then(function () { done('Copied ✓'); }, function () { done('Copy failed — select manually'); });
+ } else {
+ done('Select the code above to copy');
+ }
+ });
+
+ // ── Live $THREE Town Oracle ($0.01 USDC over x402) ─────────────────────────
+ // x402.js binds [data-x402-endpoint] and fires `x402:result` on the button
+ // with detail { ok, result, payment, response } once payment settles. We
+ // format the live oracle response into the on-page intel card.
+ (function () {
+ var btn = $('threeOracleBtn');
+ var out = $('threeOracleResult');
+ if (!btn || !out) return;
+ var esc = function (s) { var d = document.createElement('div'); d.textContent = String(s == null ? '' : s); return d.innerHTML; };
+ var num = function (n) { return typeof n === 'number' && isFinite(n); };
+ var fmtPrice = function (n) { if (!num(n)) return '—'; return n >= 1 ? '$' + n.toLocaleString(undefined, { maximumFractionDigits: 4 }) : '$' + Number(n).toPrecision(4); };
+ var fmtCompact = function (n) { if (!num(n)) return '—'; try { return '$' + new Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 2 }).format(n); } catch (_) { return '$' + Math.round(n).toLocaleString(); } };
+ var fmtPct = function (n) { if (!num(n)) return '—'; return (n >= 0 ? '+' : '') + n.toFixed(2) + '%'; };
+ function render(r) {
+ if (!r || typeof r !== 'object') { out.innerHTML = '<p class="ti-empty">The call settled but returned no data. Try again.</p>'; return; }
+ var sig = String(r.signal || 'neutral').toLowerCase();
+ if (['bullish', 'bearish', 'neutral'].indexOf(sig) < 0) sig = 'neutral';
+ var chgCls = num(r.change_24h) ? (r.change_24h >= 0 ? 'ti-up' : 'ti-down') : '';
+ var mintShort = r.mint ? (String(r.mint).slice(0, 4) + '…' + String(r.mint).slice(-4)) : '';
+ out.innerHTML =
+ '<div class="ti-topline"><span class="ti-sym mono">$' + esc(r.symbol || 'THREE') + '</span>' +
+ '<span class="ti-signal ' + sig + '">' + esc(sig) + '</span></div>' +
+ '<div class="ti-grid">' +
+ '<div class="ti-cell"><div class="k">Price</div><div class="v">' + fmtPrice(r.price_usd) + '</div></div>' +
+ '<div class="ti-cell"><div class="k">24h</div><div class="v ' + chgCls + '">' + fmtPct(r.change_24h) + '</div></div>' +
+ '<div class="ti-cell"><div class="k">Market cap</div><div class="v">' + fmtCompact(r.market_cap_usd) + '</div></div>' +
+ '<div class="ti-cell"><div class="k">Liquidity</div><div class="v">' + fmtCompact(r.liquidity_usd) + '</div></div>' +
+ '<div class="ti-cell"><div class="k">24h volume</div><div class="v">' + fmtCompact(r.volume_24h_usd) + '</div></div>' +
+ '</div>' +
+ (r.headline ? '<p class="ti-headline">' + esc(r.headline) + '</p>' : '') +
+ (r.rationale ? '<p class="ti-rationale">' + esc(r.rationale) + '</p>' : '') +
+ '<p class="ti-meta">' + (mintShort ? 'mint ' + esc(mintShort) + ' · ' : '') + (num(r.confidence) ? 'confidence ' + Math.round(r.confidence * 100) + '% · ' : '') + 'live via x402</p>';
+ }
+ btn.addEventListener('x402:result', function (e) {
+ var d = e.detail || {};
+ var r = d.result;
+ if (typeof r === 'string') { try { r = JSON.parse(r); } catch (_) {} }
+ render(r);
+ try { out.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } catch (_) {}
+ });
+ btn.addEventListener('x402:error', function (e) {
+ var msg = (e.detail && e.detail.error) ? String(e.detail.error) : 'The payment was cancelled or failed.';
+ out.innerHTML = '<p class="ti-empty">' + esc(msg) + ' Nothing was charged unless a receipt appeared — you can try again.</p>';
+ });
+ })();
+
+ wireLiveEmbeds();
+})();
+</script>
+
+<!-- Demo 01 · Forge — paid x402 prompt→3D. Pays POST /api/x402/forge, then polls
+ the free GET /api/forge?job=<id> for the finished GLB and orbits it inline. -->
+<script type="module">
+(function () {
+ 'use strict';
+
+ var FORGE_ENDPOINT = 'https://three.ws/api/x402/forge';
+ var POLL_ENDPOINT = 'https://three.ws/api/forge';
+ // Per-tier atomic USDC prices (6 decimals) — refreshed live from the 402
+ // challenge, but seeded so the UI is correct before the first fetch resolves.
+ var TIER_ATOMIC = { draft: 50000, standard: 150000, high: 500000 };
+ var TIER_ETA = { draft: 40, standard: 60, high: 130 };
+
+ var $ = function (id) { return document.getElementById(id); };
+ if (!$('fgBtn')) return; // section not present — nothing to wire
+
+ var selectedTier = 'draft';
+ var inFlight = false;
+ var pollTimer = null;
+ var genTimer = null;
+ // Networks the live 402 challenge is quoting, for specific error guidance.
+ var quotedNetworks = '';
+
+ // model-viewer is heavy (~955 KB, bundles its own Three.js) and only needed once
+ // a model has actually been forged. Load it lazily, self-hosted from ./vendor/, so
+ // a page view that never forges pays nothing for it and its Three.js never co-exists
+ // with the agent's at idle. Injected <model-viewer> elements upgrade automatically
+ // once the module defines the custom element; a blocked/failed load never wedges the
+ // result UI (the GLB download link still works).
+ var _mvLoading = null;
+ function ensureModelViewer() {
+ if (_mvLoading) return _mvLoading;
+ _mvLoading = new Promise(function (resolve) {
+ if (window.customElements && customElements.get('model-viewer')) { resolve(); return; }
+ var s = document.createElement('script');
+ s.type = 'module';
+ // Absolute, not './vendor/…': this page is built to be embedded. On any host
+ // where the relative path doesn't resolve (a preview tool, a partner site,
+ // file://) the element would never upgrade and sit as a blank box — exactly
+ // why the free generator looked broken while <agent-3d> (loaded from an
+ // absolute URL) worked. The canonical copy on three.ws is served with
+ // `Access-Control-Allow-Origin: *`, so it loads cross-origin anywhere.
+ s.src = 'https://three.ws/ibm/vendor/model-viewer.min.js';
+ s.addEventListener('error', resolve);
+ document.head.appendChild(s);
+ if (window.customElements) customElements.whenDefined('model-viewer').then(resolve, resolve);
+ else resolve();
+ });
+ return _mvLoading;
+ }
+
+ function escapeHtml(s) {
+ return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
+ return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
+ });
+ }
+ // Route the forged GLB through three.ws's first-party /cdn proxy (CORS `*`) so
+ // model-viewer can fetch it from any origin this page is embedded on — the raw
+ // r2.dev bucket domain only allow-lists specific hosts, which would leave a
+ // cross-origin embed staring at an empty viewer. See the free-forge widget below.
+ function cdnGlb(u) {
+ try {
+ var url = new URL(u, location.href);
+ if (/(^|\.)r2\.dev$/i.test(url.hostname)) return 'https://three.ws/cdn' + url.pathname + url.search;
+ return u;
+ } catch (_) { return u; }
+ }
+ function prefersReducedMotion() {
+ return !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
+ }
+ function flashPrice(el) {
+ if (!el || prefersReducedMotion()) return;
+ el.classList.remove('flash'); void el.offsetWidth; el.classList.add('flash');
+ el.addEventListener('animationend', function once() { el.classList.remove('flash'); el.removeEventListener('animationend', once); });
+ }
+ function shortAddr(a) {
+ if (!a) return '—'; a = String(a);
+ return a.length > 16 ? a.slice(0, 6) + '…' + a.slice(-4) : a;
+ }
+ function networkLabel(net) {
+ if (!net) return '—';
+ if (net.indexOf('solana') === 0) return 'Solana';
+ if (net === 'eip155:8453') return 'Base';
+ if (net.indexOf('eip155:') === 0) return 'EVM ' + net.split(':')[1];
+ return net;
+ }
+ function explorerUrl(net, tx) {
+ if (!tx || !net) return null;
+ if (net.indexOf('solana') === 0) return 'https://solscan.io/tx/' + tx;
+ if (net === 'eip155:8453') return 'https://basescan.org/tx/' + tx;
+ return null;
+ }
+ function fmtUsd(atomics, decimals) {
+ var n = Number(atomics) / Math.pow(10, decimals || 6);
+ if (!isFinite(n)) return '$0';
+ if (n < 0.01) return '$' + n.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
+ return '$' + n.toFixed(2);
+ }
+ function priceLabel(tier) { return fmtUsd(TIER_ATOMIC[tier] || 50000, 6); }
+ function announce(msg) {
+ var a = $('fgAnnouncer'); if (!a) return;
+ a.textContent = '';
+ window.requestAnimationFrame(function () { a.textContent = msg || ''; });
+ }
+
+ function sanitizePrompt(raw) { return String(raw || '').replace(/\s+/g, ' ').trim().slice(0, 1000); }
+ function setPromptError(msg) {
+ var f = $('fgPrompt'), h = $('fgPromptHint');
+ if (msg) { f.setAttribute('aria-invalid', 'true'); h.className = 'field-hint err'; h.textContent = msg; }
+ else { f.removeAttribute('aria-invalid'); h.className = 'field-hint'; h.textContent = 'One subject works best — describe it in a sentence.'; }
+ }
+ function setBusy(b, label) {
+ inFlight = b;
+ var btn = $('fgBtn');
+ btn.disabled = b || !navigator.onLine;
+ btn.classList.toggle('loading', b);
+ btn.querySelector('.label').textContent = b ? (label || 'Working…') : ('Pay ' + priceLabel(selectedTier) + ' & forge');
+ }
+
+ // ── price tag + button reflect the selected tier ─────────────────────────
+ function syncTierUi() {
+ var amt = $('fgPriceAmt');
+ var html = escapeHtml(priceLabel(selectedTier)).replace(/^\$/, '$<strong>') + '</strong>';
+ if (amt.innerHTML !== html) { amt.innerHTML = html; flashPrice(amt); }
+ var sr = $('fgPriceSr'); if (sr) sr.textContent = 'Price: ' + priceLabel(selectedTier) + ' USDC per generation.';
+ if (!inFlight) $('fgBtn').querySelector('.label').textContent = 'Pay ' + priceLabel(selectedTier) + ' & forge';
+ }
+
+ // ── tier prices from the public catalog (authoritative) ──────────────────
+ function loadCatalog() {
+ fetch(FORGE_ENDPOINT, { method: 'GET' })
+ .then(function (r) { return r.ok ? r.json() : null; })
+ .then(function (d) {
+ var list = d && d.pricing_usdc;
+ if (!Array.isArray(list)) return;
+ list.forEach(function (t) {
+ var atomic = Math.round(Number(t.price_usdc) * 1e6);
+ if (t.tier && isFinite(atomic) && atomic > 0) TIER_ATOMIC[t.tier] = atomic;
+ });
+ document.querySelectorAll('#fgTiers .tier').forEach(function (btn) {
+ var tier = btn.getAttribute('data-tier');
+ var el = btn.querySelector('[data-price]');
+ if (el && TIER_ATOMIC[tier]) el.textContent = fmtUsd(TIER_ATOMIC[tier], 6);
+ });
+ syncTierUi();
+ })
+ .catch(function () {});
+ }
+
+ // ── live 402 challenge preview for the selected tier ─────────────────────
+ function loadChallengePreview() {
+ var preview = $('fgPreview');
+ if (preview) preview.setAttribute('aria-busy', 'true');
+ var prompt = sanitizePrompt($('fgPrompt').value) || 'a brass steampunk owl, full body';
+ fetch(FORGE_ENDPOINT, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ prompt: prompt, tier: selectedTier, aspect_ratio: '1:1' })
+ })
+ .then(function (res) {
+ if (res.status !== 402 && res.status !== 401) throw new Error('expected 402, got ' + res.status);
+ return res.json().catch(function () { return null; });
+ })
+ .then(function (body) {
+ var accepts = (body && body.accepts) || [];
+ if (!accepts.length) throw new Error('no payment terms in challenge');
+ // Solana-only checkout — quote just the Solana terms in the live preview
+ // so it matches the wallet flow. Fall back to all terms if the server
+ // ever omits Solana, so the preview never renders empty.
+ var solanaOnly = accepts.filter(function (a) { return a && typeof a.network === 'string' && a.network.indexOf('solana') === 0; });
+ renderChallengePreview(solanaOnly.length ? solanaOnly : accepts);
+ })
+ .catch(function (err) {
+ var label = $('fgPvLabel'); label.className = 'preview-label err';
+ $('fgPvLabelText').textContent = navigator.onLine
+ ? "Couldn't read the live price just now — the forge button still works."
+ : "You're offline — the live price will load when you reconnect.";
+ var detail = escapeHtml(String((err && err.message) || 'request failed')).slice(0, 120);
+ $('fgPvRows').innerHTML =
+ '<div class="preview-row"><span class="v" style="color:var(--ibm-subtle)">' + detail + '</span></div>' +
+ '<button class="pv-retry" type="button" id="fgPvRetry">Retry</button>';
+ var r = $('fgPvRetry'); if (r) r.addEventListener('click', loadChallengePreview);
+ })
+ .then(function () { if (preview) preview.setAttribute('aria-busy', 'false'); });
+ }
+
+ function renderChallengePreview(accepts) {
+ var byNet = {};
+ accepts.forEach(function (a) { if (a && a.network && !byNet[a.network]) byNet[a.network] = a; });
+ var nets = Object.keys(byNet).map(function (k) { return byNet[k]; });
+ var first = nets[0];
+ var decimals = (first.extra && first.extra.decimals) || 6;
+ quotedNetworks = nets.map(function (a) { return networkLabel(a.network); }).join(' or ');
+
+ var atomic = Number(first.amount);
+ if (isFinite(atomic) && atomic > 0) { TIER_ATOMIC[selectedTier] = atomic; syncTierUi(); }
+
+ var label = $('fgPvLabel'); label.className = 'preview-label ok fresh';
+ $('fgPvLabelText').innerHTML = '<span class="mono">HTTP 402 Payment Required</span> — the server is quoting these terms right now';
+
+ var rows = '';
+ rows += '<div class="preview-row"><span class="k">price</span><span class="v">' + escapeHtml(fmtUsd(first.amount, decimals)) + ' USDC · ' + escapeHtml(selectedTier) + '</span></div>';
+ var badges = nets.map(function (a) { return '<span class="badge">' + escapeHtml(networkLabel(a.network)) + '</span>'; }).join('');
+ rows += '<div class="preview-row"><span class="k">networks</span><span class="v">' + badges + '</span></div>';
+ nets.forEach(function (a) {
+ rows += '<div class="preview-row"><span class="k">pay&nbsp;to</span><span class="v">' + escapeHtml(shortAddr(a.payTo)) + ' <span style="color:var(--ibm-subtle)">(' + escapeHtml(networkLabel(a.network)) + ')</span></span></div>';
+ });
+ rows += '<div class="preview-row"><span class="k">returns</span><span class="v">a job token → poll for the finished GLB</span></div>';
+ $('fgPvRows').innerHTML = rows;
+ }
+
+ // ── result states ─────────────────────────────────────────────────────────
+ function setResultEmpty() {
+ var el = $('fgResult'); el.className = 'result is-empty';
+ el.innerHTML = 'Forge a model to see it appear here — orbit it, then download the GLB.';
+ announce('');
+ }
+ function setResultLoading(msg) {
+ var el = $('fgResult'); el.className = 'result is-loading';
+ el.innerHTML = '<div class="r-status"><span class="spin" aria-hidden="true"></span><span>' + escapeHtml(msg) + '</span></div>';
+ announce(msg);
+ }
+ function payGuidance(msg) {
+ var m = String(msg || '').toLowerCase();
+ if (/insufficient|not enough|exceeds balance|transfer amount exceeds|enough usdc|enough funds|low balance/.test(m)) {
+ return 'Top up USDC on ' + (quotedNetworks || 'your wallet network') + ', then try again.';
+ }
+ if (/offline|failed to fetch|networkerror|connection|timeout|timed out|could not reach|lost contact/.test(m)) {
+ return 'Check your connection, then try again.';
+ }
+ return '';
+ }
+ function setResultError(msg) {
+ var text = msg || 'Something went wrong.';
+ var tip = payGuidance(text);
+ var el = $('fgResult'); el.className = 'result is-error';
+ el.innerHTML = '<div class="r-status err"><span aria-hidden="true">✕</span> <span>' + escapeHtml(text) + '</span></div>' +
+ (tip ? '<p class="r-tip">' + escapeHtml(tip) + '</p>' : '') +
+ '<button class="retry" type="button" id="fgRetry">Try again</button>';
+ var rb = $('fgRetry'); if (rb) rb.addEventListener('click', runForge);
+ announce('Error: ' + text + (tip ? ' ' + tip : ''));
+ }
+ // The paid generation has settled but is taking longer than this inline demo can
+ // wait. Rather than leave the visitor stranded, hand them the job in the full Forge
+ // tool (the same backend, with a durable job view) so they can collect the result.
+ function setResultStillWorking(msg, jobId) {
+ var text = msg || 'Still working — your payment settled.';
+ var forgeUrl = 'https://three.ws/forge' + (jobId ? '?job=' + encodeURIComponent(jobId) : '');
+ var el = $('fgResult'); el.className = 'result is-error';
+ el.innerHTML =
+ '<div class="r-status err"><span aria-hidden="true">⏳</span> <span>' + escapeHtml(text) + '</span></div>' +
+ '<p class="r-tip">Your payment went through and the model is still generating. Open it in the full Forge tool to watch it finish and download the GLB — your job is waiting there.</p>' +
+ '<div class="r-actions">' +
+ '<a class="r-btn" href="' + escapeHtml(forgeUrl) + '" target="_blank" rel="noopener">Continue in Forge ↗</a>' +
+ '<button class="r-btn ghost" type="button" id="fgRetry">Try again</button>' +
+ '</div>';
+ var rb = $('fgRetry'); if (rb) rb.addEventListener('click', runForge);
+ announce(text + ' Continue in the full Forge tool to collect your model.');
+ }
+ function setResultGenerating(payment, etaSec, startTs) {
+ ensureModelViewer(); // warm the viewer during the generation wait so the result paints instantly
+ var el = $('fgResult'); el.className = 'result is-loading';
+ el.innerHTML =
+ '<div class="r-status"><span class="spin" aria-hidden="true"></span><span id="fgGenText">Payment settled — forging your model…</span></div>' +
+ '<div class="mv-wrap"><div style="height:min(56vh,440px);display:flex;align-items:center;justify-content:center;color:var(--ibm-subtle);font-size:13px">Generating geometry…</div><div class="mv-progress" id="fgProg"></div></div>';
+ announce('Payment settled. Forging your 3D model — about ' + etaSec + ' seconds.');
+ clearInterval(genTimer);
+ genTimer = setInterval(function () {
+ var elapsed = Math.round((Date.now() - startTs) / 1000);
+ var prog = Math.min(0.95, elapsed / (etaSec * 1.4));
+ var bar = $('fgProg'); if (bar) bar.style.width = (prog * 100).toFixed(1) + '%';
+ var t = $('fgGenText'); if (t) t.textContent = 'Payment settled — forging your model… ' + elapsed + 's';
+ }, 1000);
+ }
+ function mvAvailable() {
+ return !!(window.customElements && customElements.get('model-viewer'));
+ }
+ function setResultDone(glbUrl, payment, meta) {
+ clearInterval(genTimer);
+ var el = $('fgResult'); el.className = 'result is-done';
+ var explorer = explorerUrl(payment.network, payment.transaction);
+ glbUrl = cdnGlb(glbUrl);
+ var safeGlb = escapeHtml(glbUrl);
+
+ var html = '';
+ html += '<div class="r-status ok"><span class="r-check" aria-hidden="true">✓</span><span>Payment settled — model forged</span></div>';
+ // The viewer is optional polish. If model-viewer never loaded (blocked script,
+ // failed CDN-free fetch, unsupported engine) we don't render a dead <model-viewer>
+ // that sits empty forever — we show the GLB as a downloadable file with a note.
+ // ensureModelViewer() resolves whether or not the element upgrades, so by the time
+ // its promise settles we can make an honest decision and re-render in place.
+ ensureModelViewer().then(function () {
+ // Element upgraded (or will upgrade in place) → leave the live viewer alone.
+ if (mvAvailable()) return;
+ // The module never defined the custom element. Swap the inert <model-viewer>
+ // for an explicit download fallback so the user always gets their model.
+ var mv = el.querySelector('.mv-wrap');
+ if (mv) {
+ mv.innerHTML =
+ '<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:28px 18px;text-align:center;color:var(--ibm-subtle);font-size:13px;font-weight:300">' +
+ '<span>The 3D viewer couldn’t load here — your model is ready as a downloadable file.</span>' +
+ '<a class="r-btn" href="' + safeGlb + '" download target="_blank" rel="noopener">Download GLB</a>' +
+ '</div>';
+ announce('The 3D viewer could not load, but your model is ready to download.');
+ }
+ });
+ html += '<div class="mv-wrap"><model-viewer src="' + safeGlb + '" alt="The 3D model you just forged" camera-controls auto-rotate rotation-per-second="18deg" interaction-prompt="none" shadow-intensity="0.7" shadow-softness="0.8" environment-image="neutral" exposure="1" camera-orbit="0deg 80deg auto" loading="eager"></model-viewer></div>';
+ html += '<div class="r-actions">' +
+ '<a class="r-btn" href="' + safeGlb + '" download target="_blank" rel="noopener">Download GLB</a>' +
+ '<a class="r-btn ghost" href="https://three.ws/forge" target="_blank" rel="noopener">Rig &amp; refine in Forge ↗</a>' +
+ '</div>';
+
+ html += '<dl class="receipt">';
+ html += '<div class="receipt-pair"><dt class="rk">Tier</dt><dd class="rv">' + escapeHtml((meta && meta.tier) || selectedTier) + '</dd></div>';
+ html += '<div class="receipt-pair"><dt class="rk">Network</dt><dd class="rv">' + escapeHtml(networkLabel(payment.network)) + '</dd></div>';
+ html += '<div class="receipt-pair"><dt class="rk">Payer</dt><dd class="rv">' + escapeHtml(shortAddr(payment.payer)) + '</dd></div>';
+ html += '<div class="receipt-pair"><dt class="rk">Transaction</dt><dd class="rv">' +
+ (payment.transaction
+ ? (explorer ? '<a href="' + explorer + '" target="_blank" rel="noopener">' + escapeHtml(shortAddr(payment.transaction)) + ' <span aria-hidden="true">↗</span></a>' : escapeHtml(shortAddr(payment.transaction)))
+ : '—') + '</dd></div>';
+ html += '</dl>';
+
+ html += '<details class="raw"><summary>View raw response &amp; settlement</summary><pre>' +
+ escapeHtml(JSON.stringify({ glb_url: glbUrl, job: meta, payment: payment }, null, 2)).slice(0, 6000) + '</pre></details>';
+
+ el.innerHTML = html;
+ // If model-viewer upgraded but can't fetch the GLB (CORS/404), swap the inert
+ // viewer for the same honest download fallback rather than leaving it blank.
+ var mvLive = el.querySelector('model-viewer');
+ if (mvLive) mvLive.addEventListener('error', function () {
+ var mv = el.querySelector('.mv-wrap');
+ if (!mv) return;
+ mv.innerHTML =
+ '<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:28px 18px;text-align:center;color:var(--ibm-subtle);font-size:13px;font-weight:300">' +
+ '<span>The 3D viewer couldn’t load the model here — it’s ready as a downloadable file.</span>' +
+ '<a class="r-btn" href="' + safeGlb + '" download target="_blank" rel="noopener">Download GLB</a>' +
+ '</div>';
+ announce('The 3D viewer could not load the model, but it is ready to download.');
+ }, { once: true });
+ announce('Your 3D model is ready. Orbit it above or download the GLB.');
+ }
+
+ // ── poll the free status endpoint until the GLB is ready ─────────────────
+ function pollForge(jobId, payment, etaSec) {
+ var startTs = Date.now();
+ var tries = 0;
+ var maxTries = 150; // ~6.5 min at 2.6s
+ setResultGenerating(payment, etaSec, startTs);
+ (function tick() {
+ fetch(POLL_ENDPOINT + '?job=' + encodeURIComponent(jobId), { method: 'GET' })
+ .then(function (r) { return r.json().catch(function () { return null; }); })
+ .then(function (d) {
+ if (!d) throw new Error('empty');
+ if (d.status === 'done' && d.glb_url) { setResultDone(d.glb_url, payment, d); return; }
+ if (d.status === 'failed') { clearInterval(genTimer); setResultError(d.error || 'Generation failed. Your payment settled — try the full Forge tool.'); return; }
+ tries++;
+ if (tries >= maxTries) { clearInterval(genTimer); setResultStillWorking('Still working after several minutes — your payment settled.', jobId); return; }
+ pollTimer = setTimeout(tick, 2600);
+ })
+ .catch(function () {
+ tries++;
+ if (tries >= maxTries) { clearInterval(genTimer); setResultStillWorking('Lost contact while generating — your payment settled.', jobId); return; }
+ pollTimer = setTimeout(tick, 2600);
+ });
+ })();
+ }
+
+ // ── pay → generate ───────────────────────────────────────────────────────
+ function runForge() {
+ if (inFlight) return;
+ if (!navigator.onLine) { setResultError('You appear to be offline. Reconnect and try again.'); return; }
+
+ var prompt = sanitizePrompt($('fgPrompt').value);
+ if (prompt.length < 3) { setPromptError('Describe an object — at least a few characters.'); $('fgPrompt').focus(); return; }
+ setPromptError(null);
+ $('fgPrompt').value = prompt;
+
+ if (!window.X402 || typeof window.X402.pay !== 'function') {
+ setResultError('Payment widget is still loading — give it a second and try again.');
+ return;
+ }
+
+ var tier = selectedTier;
+ var trigger = document.activeElement;
+ setBusy(true, 'Waiting for wallet…');
+ setResultLoading('Waiting for your wallet… approve the ' + priceLabel(tier) + ' USDC payment to start the generation.');
+
+ window.X402.pay({
+ endpoint: FORGE_ENDPOINT,
+ method: 'POST',
+ body: { prompt: prompt, tier: tier, aspect_ratio: '1:1' },
+ merchant: 'three.ws',
+ action: 'Forge: ' + prompt.slice(0, 48),
+ networks: ['solana'],
+ caps: { maxPerCall: (TIER_ATOMIC[tier] || 500000) }
+ }).then(function (out) {
+ if (!out || !out.ok) { setResultError('The payment did not complete. Please try again.'); return; }
+ var job = out.result || {};
+ var payment = out.payment || {};
+ // The paid route may finish synchronously on some backends.
+ if (job.status === 'done' && job.glb_url) { setResultDone(job.glb_url, payment, job); return; }
+ var jobId = job.job_id;
+ if (!jobId) { setResultError('Payment settled, but no job token came back. Try the full Forge tool.'); return; }
+ var eta = Number(job.eta_seconds) || TIER_ETA[tier] || 60;
+ pollForge(jobId, payment, eta);
+ }).catch(function (err) {
+ if (err && err.code === 'cancelled') { setResultEmpty(); return; }
+ setResultError((err && err.message) || 'Payment failed. Please try again.');
+ }).then(function () {
+ setBusy(false);
+ var t = (trigger && trigger.focus && document.body.contains(trigger)) ? trigger : $('fgBtn');
+ try { t.focus(); } catch (_) { try { $('fgBtn').focus(); } catch (_2) {} }
+ });
+ }
+
+ // ── tier selection (WAI-ARIA radiogroup) ─────────────────────────────────────
+ // Selection drives a roving tabindex: only the checked radio is in the tab
+ // order, so Tab lands on the group once and Arrow/Home/End move within it —
+ // the operable behaviour the role="radiogroup"/role="radio" markup promises.
+ function tierButtons() {
+ return Array.prototype.slice.call(document.querySelectorAll('#fgTiers .tier'));
+ }
+ function selectTier(tier, focusIt) {
+ if (!TIER_ATOMIC[tier]) return;
+ var changed = tier !== selectedTier;
+ selectedTier = tier;
+ tierButtons().forEach(function (btn) {
+ var on = btn.getAttribute('data-tier') === tier;
+ btn.setAttribute('aria-checked', on ? 'true' : 'false');
+ btn.tabIndex = on ? 0 : -1;
+ if (on && focusIt) { try { btn.focus(); } catch (_) {} }
+ });
+ if (changed) { syncTierUi(); loadChallengePreview(); }
+ }
+
+ // ── wiring ──────────────────────────────────────────────────────────────────
+ (function wireTierKeys() {
+ var btns = tierButtons();
+ btns.forEach(function (btn, i) {
+ btn.addEventListener('click', function () { selectTier(btn.getAttribute('data-tier')); });
+ btn.addEventListener('keydown', function (e) {
+ var key = e.key, next = -1;
+ if (key === 'ArrowRight' || key === 'ArrowDown') next = (i + 1) % btns.length;
+ else if (key === 'ArrowLeft' || key === 'ArrowUp') next = (i - 1 + btns.length) % btns.length;
+ else if (key === 'Home') next = 0;
+ else if (key === 'End') next = btns.length - 1;
+ else return;
+ e.preventDefault();
+ selectTier(btns[next].getAttribute('data-tier'), true);
+ });
+ });
+ })();
+ $('fgBtn').addEventListener('click', runForge);
+ $('fgPrompt').addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); runForge(); } });
+ var pvTimer;
+ $('fgPrompt').addEventListener('input', function () {
+ setPromptError(null);
+ clearTimeout(pvTimer);
+ pvTimer = setTimeout(loadChallengePreview, 600);
+ });
+ window.addEventListener('online', function () { setBusy(inFlight); loadChallengePreview(); });
+ window.addEventListener('offline', function () { setBusy(inFlight); });
+
+ syncTierUi();
+ loadCatalog();
+ loadChallengePreview();
+})();
+</script>
+
+<!-- Free, no-wallet text→3D companion to the paid Forge. POSTs the free
+ /api/forge NVIDIA NIM (Microsoft TRELLIS) lane, walks a fallback ladder, and
+ polls GET /api/forge?job=<id>. No wallet, no key, no payment. -->
+<script type="module">
+(function () {
+ 'use strict';
+
+ var API = 'https://three.ws/api/forge';
+ var $ = function (id) { return document.getElementById(id); };
+ var btn = $('g3dBtn');
+ if (!btn) return; // panel not present — nothing to wire
+
+ var input = $('g3dPrompt');
+ var result = $('g3dResult');
+ var statusEl = $('g3dStatus');
+ var suggest = $('g3dSuggest');
+
+ var inFlight = false;
+ var runSeq = 0;
+ var loadTimer = null;
+
+ var CID = (function () {
+ var fresh = function () { return 'c-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); };
+ try {
+ var KEY = 'forge:cid';
+ var v = localStorage.getItem(KEY);
+ if (!v) { v = (window.crypto && crypto.randomUUID) ? crypto.randomUUID() : fresh(); localStorage.setItem(KEY, v); }
+ return v;
+ } catch (e) { return fresh(); }
+ })();
+ var HEADERS = { 'x-forge-client': CID };
+
+ // Load model-viewer, resilient to a transient script failure, and resolve to
+ // whether the element is genuinely defined so the caller never mounts an inert
+ // tag. Absolute, not './vendor/…': this page is built to be embedded. On any
+ // host where a relative path doesn't resolve (a preview tool, a partner site,
+ // file://) the element would never upgrade and would sit as a blank box — which
+ // is exactly why the free generator looked broken while <agent-3d> (loaded from
+ // an absolute URL) worked. The canonical copy on three.ws is self-contained and
+ // served with `Access-Control-Allow-Origin: *`, so it upgrades from any origin.
+ var MV_SRC = 'https://three.ws/ibm/vendor/model-viewer.min.js';
+ var _mv = null;
+ function ensureModelViewer() {
+ if (_mv) return _mv;
+ _mv = new Promise(function (resolve) {
+ function defined() { return !!(window.customElements && customElements.get('model-viewer')); }
+ if (defined()) { resolve(true); return; }
+ if (!window.customElements) { resolve(false); return; }
+ var settled = false;
+ function done(v) { if (settled) return; settled = true; resolve(v); }
+ customElements.whenDefined('model-viewer').then(function () { done(true); });
+ function inject(attempt) {
+ var s = document.createElement('script');
+ s.type = 'module';
+ s.src = attempt > 1 ? (MV_SRC + '?r=' + attempt) : MV_SRC;
+ s.addEventListener('error', function () {
+ if (attempt < 3) setTimeout(function () { inject(attempt + 1); }, 600 * attempt);
+ else done(defined());
+ });
+ document.head.appendChild(s);
+ }
+ inject(1);
+ setTimeout(function () { done(defined()); }, 15000); // never hang — report real state
+ });
+ return _mv;
+ }
+
+ function esc(s) {
+ return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
+ return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
+ });
+ }
+ function sleep(ms) { return new Promise(function (r) { setTimeout(r, ms); }); }
+
+ // Forge outputs are served from the bucket's public r2.dev domain, whose CORS
+ // only allow-lists specific hosts (three.ws, the IBM properties). Embedded on
+ // any other origin — a page builder, file://, a sandboxed iframe (Origin:
+ // null), a partner site — model-viewer's cross-origin GLB fetch is CORS-blocked
+ // and the viewer paints nothing but its background. three.ws's first-party /cdn
+ // proxy streams the same object with `Access-Control-Allow-Origin: *`, so route
+ // every GLB through it and the model loads no matter where this page runs.
+ function cdnGlb(u) {
+ try {
+ var url = new URL(u, location.href);
+ if (/(^|\.)r2\.dev$/i.test(url.hostname)) return 'https://three.ws/cdn' + url.pathname + url.search;
+ return u;
+ } catch (_) { return u; }
+ }
+
+ // Attempt plan. /api/forge already runs its OWN internal fallback ladder
+ // (NVIDIA NIM → TRELLIS → Hugging Face → Replicate) inside a single request and
+ // always hands back a job that polls to a finished GLB — so the client must NOT
+ // re-walk backends. The old 3-rung × 2-pass ladder fired up to six POSTs per
+ // click, which (a) spent the free lane's hourly budget ~6× faster — a few clicks
+ // self-inflicted a 429 — and (b) turned a slow NVCF cold-start into a multi-minute
+ // cascade that surfaced as a hard error even though the backend was fine. We make
+ // one primary request and, only on a HARD failure (network / 5xx / timeout — never
+ // a rate-limit), retry once nudging the reliable reconstruct lane. A 429 is its own
+ // "busy" state (see setBusy), not a wasted retry.
+ var ATTEMPTS = [
+ { tier: 'draft' }, // server picks the fast NVIDIA lane (warm ≈ 15s; cold ≈ up to a minute, then it degrades internally)
+ { tier: 'draft', backend: 'trellis' } // hard-failure retry only: force the reliable reconstruct lane
+ ];
+
+ // POST a generation. A cold NVCF lane can hold the request ~a minute before the
+ // server degrades, so the abort budget is generous; a genuinely hung/cut socket
+ // still aborts and is retried rather than spinning forever. 429 and other non-2xx
+ // become typed errors the caller can branch on (busy vs hard failure).
+ async function startJob(body) {
+ var ctrl = new AbortController();
+ var to = setTimeout(function () { ctrl.abort(); }, 95000);
+ var res;
+ try {
+ res = await fetch(API, {
+ method: 'POST',
+ headers: Object.assign({ 'content-type': 'application/json' }, HEADERS),
+ body: JSON.stringify(body),
+ signal: ctrl.signal
+ });
+ } finally { clearTimeout(to); }
+ var data = await res.json().catch(function () { return {}; });
+ if (res.status === 429) {
+ var ra = Number(data.retry_after) || Number(res.headers.get('retry-after')) || 20;
+ throw Object.assign(new Error(data.message || 'The free lane is busy.'), { code: 429, retryAfter: ra });
+ }
+ if (!res.ok) throw Object.assign(new Error(data.message || data.error || ('HTTP ' + res.status)), { code: res.status });
+ return data;
+ }
+
+ async function pollJob(jobId, seq) {
+ var deadline = Date.now() + 240000;
+ while (seq === runSeq && Date.now() < deadline) {
+ await sleep(2500);
+ if (seq !== runSeq) return null;
+ var data = {};
+ try {
+ var ctrl = new AbortController();
+ var to = setTimeout(function () { ctrl.abort(); }, 20000);
+ var res;
+ try { res = await fetch(API + '?job=' + encodeURIComponent(jobId), { headers: HEADERS, signal: ctrl.signal }); }
+ finally { clearTimeout(to); }
+ data = await res.json().catch(function () { return {}; });
+ } catch (_) { data = {}; } // a transient poll blip is not fatal — keep polling
+ if (data.status === 'done' && data.glb_url) return data;
+ if (data.status === 'failed') throw new Error(data.error || 'generation failed');
+ }
+ if (seq !== runSeq) return null;
+ throw new Error('timed out');
+ }
+
+ async function generate(prompt, seq) {
+ var lastErr = null;
+ for (var i = 0; i < ATTEMPTS.length; i++) {
+ if (seq !== runSeq) return null;
+ try {
+ var job = await startJob(Object.assign({ prompt: prompt, aspect_ratio: '1:1', path: 'image' }, ATTEMPTS[i]));
+ if (job.status === 'done' && job.glb_url) return job; // synchronous (NVIDIA warm)
+ if (job.job_id) {
+ var done = await pollJob(job.job_id, seq);
+ if (done) return done;
+ if (seq !== runSeq) return null;
+ }
+ lastErr = new Error('no model returned');
+ } catch (e) {
+ if (e && e.code === 429) throw e; // rate-limited — surface "busy", don't burn another attempt
+ lastErr = e;
+ if (seq !== runSeq) return null;
+ await sleep(1800); // brief backoff before the reliable-lane retry
+ }
+ }
+ throw lastErr || new Error('generation unavailable');
+ }
+
+ function setLoading() {
+ var msgs = [
+ 'Reading your prompt…',
+ 'Warming up the free GPU — a cold start can take up to a minute…',
+ 'Generating geometry on NVIDIA NIM…',
+ 'Texturing the mesh…',
+ 'Finalizing the GLB…'
+ ];
+ var i = 0;
+ result.className = 'g3d-result is-loading';
+ result.innerHTML =
+ '<div class="g3d-load"><span class="g3d-bar"><span></span></span>' +
+ '<span class="g3d-loadmsg" id="g3dLoadMsg">' + esc(msgs[0]) + '</span></div>';
+ statusEl.textContent = 'Generating your 3D model.';
+ clearInterval(loadTimer);
+ loadTimer = setInterval(function () {
+ i = (i + 1) % msgs.length;
+ var el = $('g3dLoadMsg');
+ if (el) el.textContent = msgs[i];
+ }, 4000);
+ }
+
+ function setError() {
+ clearInterval(loadTimer);
+ result.className = 'g3d-result is-error';
+ result.innerHTML =
+ '<div class="g3d-err"><p>The free generator is briefly unreachable. It auto-retries across NVIDIA NIM and TRELLIS — give it another try.</p>' +
+ '<button type="button" class="g3d-retry" id="g3dRetry">Try again</button></div>';
+ var rb = $('g3dRetry');
+ if (rb) rb.addEventListener('click', run);
+ statusEl.textContent = 'Generation failed. Press try again.';
+ }
+
+ // Distinct from a hard failure: the free lane has an hourly cap so it stays free
+ // for everyone. Tell the visitor exactly when to retry and point at the instant
+ // paid lane above, instead of the misleading "unreachable" copy.
+ function setBusy(retryAfter) {
+ clearInterval(loadTimer);
+ var secs = Math.max(5, Math.round(Number(retryAfter) || 20));
+ result.className = 'g3d-result is-error';
+ result.innerHTML =
+ '<div class="g3d-err"><p>The free lane is busy — it has an hourly limit so it stays free for everyone. Try again in about ' + secs + ' seconds, or use the paid Forge above for an instant generation.</p>' +
+ '<button type="button" class="g3d-retry" id="g3dRetry">Try again</button></div>';
+ var rb = $('g3dRetry');
+ if (rb) rb.addEventListener('click', run);
+ statusEl.textContent = 'The free lane is busy. Try again in about ' + secs + ' seconds.';
+ }
+
+ function engineLabel(backend) {
+ if (backend === 'nvidia') return 'Microsoft TRELLIS · NVIDIA NIM';
+ if (backend === 'trellis') return 'Microsoft TRELLIS';
+ if (backend === 'huggingface') return 'TRELLIS · Hugging Face';
+ return 'three.ws Forge';
+ }
+
+ function viewerMarkup(glb) {
+ return '<div class="mv-wrap"><model-viewer src="' + esc(glb) + '" alt="3D model generated from your prompt" ' +
+ 'camera-controls auto-rotate rotation-per-second="18deg" interaction-prompt="none" ' +
+ 'shadow-intensity="0.7" shadow-softness="0.8" environment-image="neutral" exposure="1" ' +
+ 'camera-orbit="0deg 80deg auto" loading="eager"></model-viewer></div>';
+ }
+
+ async function renderModel(job, prompt) {
+ clearInterval(loadTimer);
+ var ready = await ensureModelViewer();
+ var glb = cdnGlb(job.glb_url);
+ var scene = 'https://three.ws/scene?model=' + encodeURIComponent(glb) +
+ '&name=' + encodeURIComponent(prompt.slice(0, 80));
+ var actions =
+ '<div class="g3d-actions">' +
+ '<a class="g3d-act primary" href="' + esc(glb) + '" download>Download GLB</a>' +
+ '<a class="g3d-act" href="' + esc(scene) + '" target="_blank" rel="noopener">Open in 3D scene ↗</a>' +
+ '<span class="g3d-engine">Generated free · ' + esc(engineLabel(job.backend)) + '</span>' +
+ '</div>';
+ result.className = 'g3d-result is-done';
+ result.innerHTML = viewerMarkup(glb) + actions;
+ statusEl.textContent = 'Your 3D model is ready. Orbit it, or download the GLB.';
+
+ // Make the orbit view a certainty, not a hope. Confirm the GLB actually paints
+ // (model-viewer's 'load'); if it errors or never paints, remount the viewer
+ // once — that clears a one-off decode/WebGL-context blip — before falling back
+ // to the designed retry. The visitor either orbits their model or gets a clear
+ // way to recover; never a silent black box.
+ if (!ready) { setError(); return; }
+ var attempted = 0;
+ function mountViewer() {
+ attempted++;
+ var wrap = result.querySelector('.mv-wrap');
+ var mv = wrap && wrap.querySelector('model-viewer');
+ if (!mv) { setError(); return; }
+ var settled = false;
+ var watchdog = setTimeout(function () {
+ // 'load' should fire within seconds of a reachable GLB; if neither load nor
+ // error arrives, treat it as a stall and remount/recover.
+ if (settled) return;
+ if (mv.loaded) { settled = true; return; } // painted, event just missed
+ onProblem();
+ }, 12000);
+ function onProblem() {
+ if (settled) return; settled = true; clearTimeout(watchdog);
+ if (attempted < 2) { result.innerHTML = viewerMarkup(glb) + actions; mountViewer(); }
+ else setError();
+ }
+ mv.addEventListener('load', function () { settled = true; clearTimeout(watchdog); }, { once: true });
+ mv.addEventListener('error', onProblem, { once: true });
+ }
+ mountViewer();
+ }
+
+ async function run() {
+ var prompt = (input.value || '').trim();
+ if (!prompt) { try { input.focus(); } catch (_) {} return; }
+ var seq = ++runSeq;
+ inFlight = true;
+ btn.classList.add('loading');
+ btn.disabled = true;
+ setLoading();
+ try {
+ var job = await generate(prompt, seq);
+ if (seq !== runSeq) return;
+ if (!job || !job.glb_url) throw new Error('no model');
+ await renderModel(job, prompt);
+ } catch (e) {
+ if (seq !== runSeq) return;
+ if (e && e.code === 429) setBusy(e.retryAfter);
+ else setError();
+ } finally {
+ if (seq === runSeq) {
+ inFlight = false;
+ btn.classList.remove('loading');
+ btn.disabled = false;
+ }
+ }
+ }
+
+ btn.addEventListener('click', function () { if (!inFlight) run(); });
+ input.addEventListener('keydown', function (e) {
+ if (e.key === 'Enter') { e.preventDefault(); if (!inFlight) run(); }
+ });
+ if (suggest) {
+ suggest.addEventListener('click', function (e) {
+ var b = e.target.closest('button[data-p]');
+ if (!b) return;
+ input.value = b.getAttribute('data-p');
+ if (!inFlight) run();
+ });
+ }
+})();
+</script>
+
+<!-- Demo 02 · Avatar Forge — free text → textured mesh → auto-rigged → animated.
+ Two-stage /api/forge pipeline: POST (reconstruct) → POST ?action=rig, then the
+ rigged GLB is mounted into <agent-3d> so the universal retarget animates it. If
+ that web component can't boot (no WebGL / script blocked) it falls back to an
+ orbiting <model-viewer> so the visitor always sees their avatar. No wallet, no
+ key. Drives the guide agent (Demo 03) via window 'avatar:*' events. -->
+<script type="module">
+(function () {
+ 'use strict';
+ var API = 'https://three.ws/api/forge';
+ var $ = function (id) { return document.getElementById(id); };
+ var btn = $('avBtn');
+ if (!btn) return; // panel not present — nothing to wire
+
+ var input = $('avPrompt');
+ var result = $('avResult');
+ var statusEl = $('avStatus');
+ var suggest = $('avSuggest');
+ var steps = $('avSteps');
+
+ var inFlight = false;
+ var runSeq = 0;
+ var loadTimer = null;
+ var bootTimer = null;
+
+ // Shared free-lane client id (same key the object forge uses) so the hourly
+ // budget is accounted per visitor, not per widget.
+ var CID = (function () {
+ var fresh = function () { return 'c-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); };
+ try {
+ var KEY = 'forge:cid';
+ var v = localStorage.getItem(KEY);
+ if (!v) { v = (window.crypto && crypto.randomUUID) ? crypto.randomUUID() : fresh(); localStorage.setItem(KEY, v); }
+ return v;
+ } catch (e) { return fresh(); }
+ })();
+ var HEADERS = { 'x-forge-client': CID };
+
+ function esc(s) {
+ return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
+ return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
+ });
+ }
+ function sleep(ms) { return new Promise(function (r) { setTimeout(r, ms); }); }
+ function emit(name) { try { window.dispatchEvent(new Event(name)); } catch (_) {} }
+
+ // Route the rigged GLB through three.ws's first-party /cdn proxy (CORS `*`) so
+ // both <agent-3d> and the <model-viewer> fallback can fetch it from whatever
+ // origin this page is embedded on. The raw r2.dev bucket domain only allow-lists
+ // specific hosts, so a cross-origin embed would otherwise get an empty stage.
+ function cdnGlb(u) {
+ try {
+ var url = new URL(u, location.href);
+ if (/(^|\.)r2\.dev$/i.test(url.hostname)) return 'https://three.ws/cdn' + url.pathname + url.search;
+ return u;
+ } catch (_) { return u; }
+ }
+
+ // ── pipeline step indicator (mesh → rig → animate) ──────────────────────────
+ var STEP_ORDER = ['mesh', 'rig', 'animate'];
+ function setStep(active) {
+ if (!steps) return;
+ steps.setAttribute('aria-hidden', 'false');
+ var ai = STEP_ORDER.indexOf(active);
+ Array.prototype.forEach.call(steps.querySelectorAll('li'), function (li) {
+ var i = STEP_ORDER.indexOf(li.getAttribute('data-step'));
+ li.classList.toggle('active', i === ai);
+ li.classList.toggle('done', ai >= 0 && i < ai);
+ });
+ }
+ function clearSteps() {
+ if (!steps) return;
+ steps.setAttribute('aria-hidden', 'true');
+ Array.prototype.forEach.call(steps.querySelectorAll('li'), function (li) { li.classList.remove('active', 'done'); });
+ }
+
+ // ── /api/forge job helpers — same contract as the free object forge ─────────
+ // A POST returns either a synchronous { glb_url } (warm lane) or a { job_id }
+ // we poll. ?action=rig surfaces the rigged GLB through the identical envelope.
+ async function startJob(body, action) {
+ var ctrl = new AbortController();
+ var to = setTimeout(function () { ctrl.abort(); }, 95000);
+ var res;
+ try {
+ res = await fetch(API + (action ? '?action=' + action : ''), {
+ method: 'POST',
+ headers: Object.assign({ 'content-type': 'application/json' }, HEADERS),
+ body: JSON.stringify(body),
+ signal: ctrl.signal
+ });
+ } finally { clearTimeout(to); }
+ var data = await res.json().catch(function () { return {}; });
+ if (res.status === 429) {
+ var ra = Number(data.retry_after) || Number(res.headers.get('retry-after')) || 20;
+ throw Object.assign(new Error(data.message || 'The free lane is busy.'), { code: 429, retryAfter: ra });
+ }
+ if (!res.ok) throw Object.assign(new Error(data.message || data.error || ('HTTP ' + res.status)), { code: res.status });
+ return data;
+ }
+ async function pollJob(jobId, seq) {
+ var deadline = Date.now() + 240000;
+ while (seq === runSeq && Date.now() < deadline) {
+ await sleep(2500);
+ if (seq !== runSeq) return null;
+ var data = {};
+ try {
+ var ctrl = new AbortController();
+ var to = setTimeout(function () { ctrl.abort(); }, 20000);
+ var res;
+ try { res = await fetch(API + '?job=' + encodeURIComponent(jobId), { headers: HEADERS, signal: ctrl.signal }); }
+ finally { clearTimeout(to); }
+ data = await res.json().catch(function () { return {}; });
+ } catch (_) { data = {}; } // a transient poll blip is not fatal — keep polling
+ if (data.status === 'done' && data.glb_url) return data;
+ if (data.status === 'failed') throw new Error(data.error || 'generation failed');
+ }
+ if (seq !== runSeq) return null;
+ throw new Error('timed out');
+ }
+ async function jobToGlb(body, action, seq) {
+ var job = await startJob(body, action);
+ if (job && job.glb_url) return job; // synchronous result
+ if (job && job.job_id) {
+ var done = await pollJob(job.job_id, seq);
+ if (done) return done;
+ if (seq !== runSeq) return null;
+ }
+ throw new Error('no model returned');
+ }
+
+ // Stage 1 — text → textured mesh. One primary request, then a single
+ // hard-failure retry forcing the reliable reconstruct lane (never on a 429),
+ // mirroring the object forge so we don't burn the shared hourly budget.
+ async function generateMesh(prompt, seq) {
+ var hint = prompt + ', full body, standing, humanoid character';
+ var attempts = [{ tier: 'draft' }, { tier: 'draft', backend: 'trellis' }];
+ var lastErr = null;
+ for (var i = 0; i < attempts.length; i++) {
+ if (seq !== runSeq) return null;
+ try {
+ var job = await jobToGlb(Object.assign({ prompt: hint, aspect_ratio: '1:1', path: 'image' }, attempts[i]), null, seq);
+ if (job && job.glb_url) return job;
+ lastErr = new Error('no mesh');
+ } catch (e) {
+ if (e && e.code === 429) throw e; // rate-limited — surface "busy", don't burn the retry
+ lastErr = e;
+ if (seq !== runSeq) return null;
+ await sleep(1800);
+ }
+ }
+ throw lastErr || new Error('generation unavailable');
+ }
+ // Stage 2 — auto-rig the mesh into an animation-ready skeleton.
+ function rigMesh(glbUrl, seq) { return jobToGlb({ glb_url: glbUrl }, 'rig', seq); }
+
+ // ── states ──────────────────────────────────────────────────────────────────
+ function setLoading(stage) {
+ var copy = stage === 'rig'
+ ? ['Mesh ready — building the skeleton…', 'Mapping bones to the canonical rig…', 'Binding skin weights…', 'Retargeting the animation library…']
+ : ['Reading your prompt…', 'Warming the free GPU — a cold start can take up to a minute…', 'Generating geometry on NVIDIA NIM…', 'Texturing the mesh…'];
+ result.className = 'av-result is-loading';
+ result.innerHTML = '<div class="av-load"><span class="av-bar"><span></span></span><span class="av-loadmsg" id="avLoadMsg">' + esc(copy[0]) + '</span></div>';
+ statusEl.textContent = stage === 'rig' ? 'Rigging your avatar.' : 'Generating your avatar.';
+ clearInterval(loadTimer);
+ var i = 0;
+ loadTimer = setInterval(function () { i = (i + 1) % copy.length; var el = $('avLoadMsg'); if (el) el.textContent = copy[i]; }, 4000);
+ }
+ function setError() {
+ clearInterval(loadTimer); clearSteps(); emit('avatar:error');
+ result.className = 'av-result is-error';
+ result.innerHTML =
+ '<div class="av-err"><p>The free generator is briefly unreachable. It auto-retries across NVIDIA NIM and TRELLIS — give it another try.</p>' +
+ '<button type="button" class="av-retry" id="avRetry">Try again</button></div>';
+ var rb = $('avRetry'); if (rb) rb.addEventListener('click', run);
+ statusEl.textContent = 'Generation failed. Press try again.';
+ }
+ // The free lane has an hourly cap so it stays free for everyone — tell the
+ // visitor exactly when to retry rather than the misleading "unreachable" copy.
+ function setBusy(retryAfter) {
+ clearInterval(loadTimer); clearSteps(); emit('avatar:error');
+ var secs = Math.max(5, Math.round(Number(retryAfter) || 20));
+ result.className = 'av-result is-error';
+ result.innerHTML =
+ '<div class="av-err"><p>The free lane is busy — it has an hourly limit so it stays free for everyone. Try again in about ' + secs + ' seconds, or open the full Forge for an instant generation.</p>' +
+ '<button type="button" class="av-retry" id="avRetry">Try again</button></div>';
+ var rb = $('avRetry'); if (rb) rb.addEventListener('click', run);
+ statusEl.textContent = 'The free lane is busy. Try again in about ' + secs + ' seconds.';
+ }
+
+ // ── result rendering ──────────────────────────────────────────────────────
+ var _mv = null;
+ function ensureModelViewer() {
+ if (_mv) return _mv;
+ _mv = new Promise(function (resolve) {
+ if (window.customElements && customElements.get('model-viewer')) { resolve(); return; }
+ var s = document.createElement('script');
+ s.type = 'module';
+ // Absolute, not './vendor/…': this page is built to be embedded. On any host
+ // where the relative path doesn't resolve (a preview tool, a partner site,
+ // file://) the element would never upgrade and sit as a blank box — exactly
+ // why the free generator looked broken while <agent-3d> (loaded from an
+ // absolute URL) worked. The canonical copy on three.ws is served with
+ // `Access-Control-Allow-Origin: *`, so it loads cross-origin anywhere.
+ s.src = 'https://three.ws/ibm/vendor/model-viewer.min.js';
+ s.addEventListener('error', resolve);
+ document.head.appendChild(s);
+ if (window.customElements) customElements.whenDefined('model-viewer').then(resolve, resolve);
+ else resolve();
+ });
+ return _mv;
+ }
+ function actionsHtml(glb, prompt, live) {
+ var scene = 'https://three.ws/scene?model=' + encodeURIComponent(glb) + '&name=' + encodeURIComponent(prompt.slice(0, 80));
+ return '<div class="av-actions">' +
+ '<a class="av-act primary" href="' + esc(glb) + '" download>Download rigged GLB</a>' +
+ '<a class="av-act" href="' + esc(scene) + '" target="_blank" rel="noopener">Open in 3D scene ↗</a>' +
+ '<span class="av-engine">Rigged free · ' + (live ? 'live avatar engine' : 'orbit preview') + '</span></div>';
+ }
+ async function renderFallback(glb, prompt) {
+ clearInterval(loadTimer); clearSteps();
+ await ensureModelViewer();
+ result.className = 'av-result is-done';
+ result.innerHTML =
+ '<div class="av-stage"><model-viewer src="' + esc(glb) + '" alt="Rigged 3D avatar generated from your prompt" ' +
+ 'camera-controls auto-rotate rotation-per-second="18deg" interaction-prompt="none" ' +
+ 'shadow-intensity="0.8" shadow-softness="0.8" environment-image="neutral" exposure="1" ' +
+ 'camera-orbit="0deg 85deg auto" loading="eager"></model-viewer></div>' + actionsHtml(glb, prompt, false);
+ var mv = result.querySelector('model-viewer');
+ if (mv) mv.addEventListener('error', function () { setError(); }, { once: true });
+ statusEl.textContent = 'Your rigged avatar is ready. Orbit it, or download the GLB.';
+ emit('avatar:done');
+ }
+ function renderAvatar(glb, prompt) {
+ clearInterval(loadTimer);
+ setStep('animate');
+ result.className = 'av-result is-done';
+ result.innerHTML = '<div class="av-stage" id="avStageBox"></div>' + actionsHtml(glb, prompt, true);
+ var box = $('avStageBox');
+ var el = document.createElement('agent-3d');
+ el.setAttribute('body', glb);
+ el.setAttribute('background', 'transparent');
+ el.setAttribute('width', '100%');
+ el.setAttribute('height', '460px');
+ var settled = false;
+ el.addEventListener('agent:ready', function () {
+ if (settled) return; settled = true;
+ clearTimeout(bootTimer); clearSteps();
+ try { if (el.playEmote) el.playEmote('wave'); } catch (_) {}
+ statusEl.textContent = 'Your avatar is live — it stands, breathes, and waves. Download it, or open it in a scene.';
+ emit('avatar:done');
+ });
+ el.addEventListener('error', function () {
+ if (settled) return; settled = true;
+ clearTimeout(bootTimer); renderFallback(glb, prompt);
+ });
+ box.appendChild(el);
+ // If the component never upgrades/boots, show the orbit fallback so the
+ // visitor still gets their avatar; if it upgraded but is slow to signal
+ // ready, accept it as live rather than tearing down a working render.
+ bootTimer = setTimeout(function () {
+ if (settled) return;
+ var upgraded = window.customElements && customElements.get('agent-3d');
+ if (!upgraded) { settled = true; renderFallback(glb, prompt); }
+ else { settled = true; clearSteps(); statusEl.textContent = 'Your avatar is live. Download it, or open it in a scene.'; emit('avatar:done'); }
+ }, 14000);
+ }
+
+ async function run() {
+ var prompt = (input.value || '').trim();
+ if (!prompt) { try { input.focus(); } catch (_) {} return; }
+ var seq = ++runSeq;
+ inFlight = true;
+ btn.classList.add('loading'); btn.disabled = true;
+ emit('avatar:generating');
+ setStep('mesh'); setLoading('mesh');
+ try {
+ var mesh = await generateMesh(prompt, seq);
+ if (seq !== runSeq) return;
+ if (!mesh || !mesh.glb_url) throw new Error('no mesh');
+
+ // Stage 2 is best-effort: a rig hiccup still yields a viewable textured mesh.
+ var glb = mesh.glb_url;
+ setStep('rig'); setLoading('rig');
+ try {
+ var rigged = await rigMesh(mesh.glb_url, seq);
+ if (seq !== runSeq) return;
+ if (rigged && rigged.glb_url) glb = rigged.glb_url;
+ } catch (rigErr) {
+ if (rigErr && rigErr.code === 429) throw rigErr; // free lane busy — surface it
+ if (seq !== runSeq) return;
+ // otherwise fall through with the unrigged mesh
+ }
+ renderAvatar(cdnGlb(glb), prompt);
+ } catch (e) {
+ if (seq !== runSeq) return;
+ if (e && e.code === 429) setBusy(e.retryAfter);
+ else setError();
+ } finally {
+ if (seq === runSeq) { inFlight = false; btn.classList.remove('loading'); btn.disabled = false; }
+ }
+ }
+
+ btn.addEventListener('click', function () { if (!inFlight) run(); });
+ input.addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); if (!inFlight) run(); } });
+ if (suggest) {
+ suggest.addEventListener('click', function (e) {
+ var b = e.target.closest('button[data-p]');
+ if (!b) return;
+ input.value = b.getAttribute('data-p');
+ if (!inFlight) run();
+ });
+ }
+})();
+</script>
+</body>
+</html>