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: demo route shuffle, voice/blog additions, Resend email wiring

nirholas9822bb202b43
diff --git a/README.md b/README.md
index ddea94cfd..2a9c1da70 100644
--- a/README.md
+++ b/README.md
@@ -357,6 +357,14 @@ three.ws is available on major cloud marketplaces and open to infrastructure par
| **Alibaba Cloud** | Live: [product listing →](https://marketplace.alibabacloud.com/products/56724001/sgcmfw00036800.html) · [storefront →](https://marketplace.alibabacloud.com/store/3247293.html) |
| **Google Cloud** | three.ws runs on WebGL, Vercel edge, and EVM — a natural fit for GCP's AI infrastructure, Vertex AI, and global CDN. Open to co-listing, credits, and joint GTM. |
+## Ecosystem Directories
+
+three.ws is indexed in chain-ecosystem dApp directories so the community can discover, vet, and rank it.
+
+| Directory | Status |
+|---|---|
+| **BNB Chain · Dappbay** | Live: [dappbay.bnbchain.org/detail/three →](https://dappbay.bnbchain.org/detail/three) — categories: AI Agent Launchpad · AI Data · AI Infra |
+
---
## Screenshots
diff --git a/api/_lib/avatars.js b/api/_lib/avatars.js
index bfd17b15b..7fbf78933 100644
--- a/api/_lib/avatars.js
+++ b/api/_lib/avatars.js
@@ -26,9 +26,12 @@ export async function listAvatars({
conds.push(`a.created_at < $${params.length}`);
}
params.push(limit + 1);
+ // usdz_key / halfbody_key are intentionally NOT selected here yet — the
+ // 20260515 migration adds them but is rolled out separately. The decorate()
+ // helper falls back to null if the columns are missing from the row, so
+ // listAvatars stays safe on prod before the migration runs.
const rows = await sql(
`select a.id, a.owner_id, a.slug, a.name, a.description, a.storage_key, a.thumbnail_key,
- a.usdz_key, a.halfbody_key,
a.appearance, a.appearance_hash, a.baked_storage_key, a.baked_at,
a.size_bytes, a.content_type, a.source, a.visibility, a.tags, a.version,
a.created_at, a.updated_at, a.parent_avatar_id,
@@ -150,6 +153,13 @@ export async function updateAvatar({ id, userId, patch }) {
// Coalesce-style update keeps the statement static and safe against dynamic composition.
// `appearance` uses the explicit `hasAppearance` flag because null is a valid value
// (means "clear the dress-up state"); coalesce would let null fall through unchanged.
+ //
+ // NOTE on usdz_key / halfbody_key: the 20260515 migration adds those columns
+ // but ships separately. Referencing them in this static UPDATE would crash
+ // every avatar edit on prod before the migration runs. Until the migration
+ // is rolled out, those PATCH fields are silently dropped here; the demo
+ // pages under /demos/ write them via a separate code path that no-ops on
+ // "column does not exist".
const [row] = await sql`
update avatars set
name = coalesce(${patch.name ?? null}, name),
@@ -157,8 +167,6 @@ export async function updateAvatar({ id, userId, patch }) {
visibility = coalesce(${patch.visibility ?? null}, visibility),
tags = coalesce(${patch.tags ?? null}::text[], tags),
thumbnail_key = coalesce(${patch.thumbnail_key ?? null}, thumbnail_key),
- usdz_key = coalesce(${patch.usdz_key ?? null}, usdz_key),
- halfbody_key = coalesce(${patch.halfbody_key ?? null}, halfbody_key),
appearance = case when ${hasAppearance}::bool
then ${patch.appearance ? JSON.stringify(patch.appearance) : null}::jsonb
else appearance end,
@@ -211,9 +219,11 @@ export async function searchPublicAvatars({ q, tag, limit = 24, cursor, withTota
conds.push(`created_at < $${params.length}`);
}
params.push(limit + 1);
+ // usdz_key / halfbody_key are intentionally NOT selected here yet — see the
+ // matching comment in listAvatars(). decorate() returns null for both when
+ // the columns are absent from the row.
const rows = await sql(
`select id, owner_id, slug, name, description, storage_key, thumbnail_key,
- usdz_key, halfbody_key,
appearance, appearance_hash, baked_storage_key, baked_at,
size_bytes,
content_type, source, visibility, tags, view_count, created_at
diff --git a/api/cron/[name].js b/api/cron/[name].js
index 6c00748e3..957bea54b 100644
--- a/api/cron/[name].js
+++ b/api/cron/[name].js
@@ -2947,6 +2947,13 @@ async function handleRunCoinCycle(req, res) {
return error(res, 401, 'unauthorized', 'cron secret required');
}
+ // Demo gate: cron is wired in vercel.json but stays a no-op until the
+ // operator opts in by setting COIN_DEMO_ENABLED=true in env. Until then
+ // neither Vercel cron nor a manual call can touch any coin_launches row.
+ if (process.env.COIN_DEMO_ENABLED !== 'true') {
+ return json(res, 200, { ok: true, disabled: true, hint: 'set COIN_DEMO_ENABLED=true to enable' });
+ }
+
const coinLib = await import('../_lib/coin/index.js');
const coins = await coinLib.listActiveCoins();
@@ -3043,6 +3050,12 @@ async function handleRunCoinPayouts(req, res) {
return error(res, 401, 'unauthorized', 'cron secret required');
}
+ // Demo gate — see handleRunCoinCycle. Until COIN_DEMO_ENABLED=true is set,
+ // the payout drainer cannot fire even if rows are pending.
+ if (process.env.COIN_DEMO_ENABLED !== 'true') {
+ return json(res, 200, { ok: true, disabled: true, hint: 'set COIN_DEMO_ENABLED=true to enable' });
+ }
+
const coinLib = await import('../_lib/coin/index.js');
const coins = await coinLib.listActiveCoins();
diff --git a/api/coin/[action].js b/api/demo/coin/[action].js
similarity index 93%
rename from api/coin/[action].js
rename to api/demo/coin/[action].js
index 58a8a5050..ea6f1f60c 100644
--- a/api/coin/[action].js
+++ b/api/demo/coin/[action].js
@@ -1,23 +1,24 @@
-// Public read-only API for the lottery + reflection coin.
+// three.ws demo coin API — public read-only.
//
-// Routes (via vercel.json rewrites):
-// GET /api/coin/state?mint=XXX
-// GET /api/coin/holder?mint=XXX&wallet=YYY
-// GET /api/coin/history?mint=XXX&limit=20
-// GET /api/coin/events?mint=XXX&limit=50&kind=<event_kind>
-// GET /api/coin/winners?mint=XXX&limit=20
-// GET /api/coin/holders?mint=XXX&limit=50
+// Routes (via vercel.json rewrites, all under the /demo/* namespace until
+// graduation to a production path):
+// GET /api/demo/coin/state?mint=XXX
+// GET /api/demo/coin/holder?mint=XXX&wallet=YYY
+// GET /api/demo/coin/history?mint=XXX&limit=20
+// GET /api/demo/coin/events?mint=XXX&limit=50&kind=<event_kind>
+// GET /api/demo/coin/winners?mint=XXX&limit=20
+// GET /api/demo/coin/holders?mint=XXX&limit=50
//
// Caller may omit `mint` when exactly one active coin exists — the API picks
-// it automatically so the public dashboard can run on /coin without any
-// query parameter for the common single-launch case.
+// it automatically so /demo/coin works without any query parameter for the
+// common single-launch case.
//
// All `*_lamports` values are returned as strings to preserve precision on
// the JSON wire (Number can't safely represent values > 2^53).
-import { sql } from '../_lib/db.js';
-import { cors, error, json, method, wrap } from '../_lib/http.js';
-import { listActiveCoins, loadCoinByMint } from '../_lib/coin/index.js';
+import { sql } from '../../_lib/db.js';
+import { cors, error, json, method, wrap } from '../../_lib/http.js';
+import { listActiveCoins, loadCoinByMint } from '../../_lib/coin/index.js';
function bigStr(v) {
if (v === null || v === undefined) return null;
diff --git a/blog/index.html b/blog/index.html
new file mode 100644
index 000000000..a52e309a3
--- /dev/null
+++ b/blog/index.html
@@ -0,0 +1,98 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width,initial-scale=1" />
+<title>Blog · three.ws</title>
+<meta name="description" content="Announcements and long-form writing from three.ws — the platform for 3D AI agents on-chain." />
+<link rel="canonical" href="https://three.ws/blog" />
+<link rel="alternate" type="application/rss+xml" title="three.ws announcements" href="/rss/announcements.xml" />
+
+<meta property="og:type" content="website" />
+<meta property="og:site_name" content="three.ws" />
+<meta property="og:title" content="Blog · three.ws" />
+<meta property="og:description" content="Announcements and long-form writing from three.ws — the platform for 3D AI agents on-chain." />
+<meta property="og:url" content="https://three.ws/blog" />
+<meta property="og:image" content="https://three.ws/og-image.png" />
+
+<meta name="twitter:card" content="summary_large_image" />
+<meta name="twitter:title" content="Blog · three.ws" />
+<meta name="twitter:description" content="Announcements and long-form writing from three.ws." />
+
+<link rel="shortcut icon" href="/favicon.ico" />
+<link rel="stylesheet" href="/nav.css" />
+<link rel="stylesheet" href="/footer.css" />
+<style>
+ :root { color-scheme: dark; }
+ body { margin: 0; background: #060611; color: #e7e7f5; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
+ .bl-wrap { max-width: 880px; margin: 0 auto; padding: 96px 24px 64px; }
+ .bl-hero { margin-bottom: 56px; }
+ .bl-hero h1 { font-size: clamp(34px, 5vw, 56px); margin: 0 0 12px; letter-spacing: -0.02em; }
+ .bl-hero p { color: #b6b6cf; font-size: 17px; max-width: 64ch; margin: 0; line-height: 1.55; }
+ .bl-formats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
+ .bl-formats a { padding: 6px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; color: #d8d8ee; text-decoration: none; font-size: 13px; background: rgba(255,255,255,.02); transition: background .15s, border-color .15s; }
+ .bl-formats a:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.24); }
+ .bl-formats code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #9ad4ff; }
+ .bl-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 16px; }
+ .bl-item a { display: block; padding: 22px 24px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(255,255,255,.015); color: inherit; text-decoration: none; transition: background .15s, border-color .15s, transform .15s; }
+ .bl-item a:hover { background: rgba(120,140,255,.06); border-color: rgba(150,170,255,.30); transform: translateY(-1px); }
+ .bl-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: #7a85a8; font-size: 12px; margin-bottom: 8px; }
+ .bl-date { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
+ .bl-tag { padding: 2px 8px; border-radius: 999px; background: rgba(154,212,255,.08); color: #9ad4ff; font-size: 11px; font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
+ .bl-title { font-size: 22px; font-weight: 600; margin: 0 0 10px; letter-spacing: -0.01em; line-height: 1.25; color: #fff; }
+ .bl-summary { color: #b6b6cf; font-size: 15px; line-height: 1.55; margin: 0; }
+ .bl-empty { padding: 48px 24px; text-align: center; color: #7a85a8; border: 1px dashed rgba(255,255,255,.08); border-radius: 14px; }
+</style>
+</head>
+<body>
+ <div id="nav-container"></div>
+ <main class="bl-wrap">
+ <div class="bl-hero">
+ <h1>Blog</h1>
+ <p>Announcements, launches, and long-form writing from three.ws — the platform for 3D AI agents on-chain.</p>
+ <div class="bl-formats">
+ <a href="/rss/announcements.xml"><code>rss</code> · subscribe in any reader</a>
+ <a href="https://x.com/trythreews" target="_blank" rel="noopener">@trythreews on X</a>
+ <a href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener">GitHub</a>
+ </div>
+ </div>
+
+ <ul class="bl-list">
+ <li class="bl-item">
+ <a href="/blog/three-ws-on-bnb-chain-dappbay">
+ <div class="bl-meta">
+ <span class="bl-date">2026-05-17</span>
+ <span class="bl-tag">Listing</span>
+ <span class="bl-tag">BNB Chain</span>
+ </div>
+ <h2 class="bl-title">three.ws Listed on BNB Chain's Dappbay Directory</h2>
+ <p class="bl-summary">three.ws is now listed on Dappbay, BNB Chain's official dApp directory, under AI Agent Launchpad, AI Data, and AI Infra. The listing puts &lt;agent-3d&gt; in front of the BNB Chain ecosystem's discovery surface for AI dApps.</p>
+ </a>
+ </li>
+ <li class="bl-item">
+ <a href="/blog/three-ws-on-alibaba-cloud-marketplace">
+ <div class="bl-meta">
+ <span class="bl-date">2026-05-17</span>
+ <span class="bl-tag">Listing</span>
+ <span class="bl-tag">Alibaba Cloud</span>
+ <span class="bl-tag">x402</span>
+ </div>
+ <h2 class="bl-title">three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale</h2>
+ <p class="bl-summary">three.ws is now live on the Alibaba Cloud International Marketplace. The listing makes &lt;agent-3d&gt; — one HTML tag that deploys a Solana-minted, ERC-8004-walleted, x402-native 3D agent — available to every Alibaba Cloud customer worldwide.</p>
+ </a>
+ </li>
+ <li class="bl-item">
+ <a href="/blog/how-to-embed-3d-onchain-agents">
+ <div class="bl-meta">
+ <span class="bl-date">2026-05-15</span>
+ <span class="bl-tag">Guide</span>
+ </div>
+ <h2 class="bl-title">How to Embed 3D On-Chain Agents on Your Site</h2>
+ <p class="bl-summary">A short walkthrough for embedding a three.ws agent on any website using the &lt;agent-3d&gt; tag.</p>
+ </a>
+ </li>
+ </ul>
+ </main>
+ <script src="/nav.js"></script>
+</body>
+</html>
diff --git a/blog/three-ws-on-bnb-chain-dappbay.html b/blog/three-ws-on-bnb-chain-dappbay.html
new file mode 100644
index 000000000..c4367ec7a
--- /dev/null
+++ b/blog/three-ws-on-bnb-chain-dappbay.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>three.ws Listed on BNB Chain's Dappbay Directory</title>
+ <meta name="description" content="three.ws is now listed on Dappbay, BNB Chain's official dApp directory, under AI Agent Launchpad, AI Data, and AI Infra. The listing puts the &lt;agent-3d&gt; tag in front of the BNB Chain ecosystem's AI dApp discovery surface.">
+ <meta name="keywords" content="three.ws, Dappbay, BNB Chain, BSC, AI agent launchpad, x402, Solana, ERC-8004, 3D agents, on-chain agents, agent economy">
+ <link rel="canonical" href="https://three.ws/blog/three-ws-on-bnb-chain-dappbay.html">
+
+ <meta property="og:title" content="three.ws Listed on BNB Chain's Dappbay Directory">
+ <meta property="og:description" content="The one-tag deploy for Solana-minted, ERC-8004-walleted, x402-native 3D agents is now in BNB Chain's official dApp discovery layer.">
+ <meta property="og:url" content="https://three.ws/blog/three-ws-on-bnb-chain-dappbay.html">
+ <meta property="og:type" content="article">
+
+ <meta name="twitter:card" content="summary_large_image">
+ <meta name="twitter:title" content="three.ws Listed on BNB Chain's Dappbay Directory">
+ <meta name="twitter:description" content="The one-tag deploy for Solana-minted, ERC-8004-walleted, x402-native 3D agents is now in BNB Chain's official dApp discovery layer.">
+
+ <link rel="stylesheet" href="/style.css">
+</head>
+<body>
+ <header>
+ <h1>three.ws Listed on BNB Chain's Dappbay Directory</h1>
+ <p><time datetime="2026-05-17">May 17, 2026</time> &middot; three.ws</p>
+ </header>
+ <main>
+ <article>
+ <p><strong>three.ws is now listed on <a href="https://dappbay.bnbchain.org/detail/three" rel="noopener">Dappbay</a>, BNB Chain's official dApp directory.</strong> The listing is live under the categories <em>AI Agent Launchpad</em>, <em>AI Data</em>, and <em>AI Infra</em>, with a current rank of <strong>AI #121</strong>.</p>
+
+ <ul>
+ <li>Dappbay listing: <a href="https://dappbay.bnbchain.org/detail/three" rel="noopener">dappbay.bnbchain.org/detail/three</a></li>
+ <li>Open source: <a href="https://github.com/nirholas/three.ws" rel="noopener">github.com/nirholas/three.ws</a></li>
+ <li>Project site: <a href="https://three.ws" rel="noopener">three.ws</a></li>
+ </ul>
+
+ <h2>What three.ws ships</h2>
+ <p>three.ws is the platform for 3D AI agents on-chain. Every <code>&lt;agent-3d&gt;</code> tag deploys an autonomous 3D character with:</p>
+ <ul>
+ <li><strong>A Solana NFT identity.</strong> Each agent is minted as a transferable on-chain asset.</li>
+ <li><strong>An ERC-8004 wallet.</strong> The emerging cross-chain agent-identity standard, baked in.</li>
+ <li><strong>A browser-native 3D body.</strong> Rendered in WebGL &mdash; no plugins, no native install.</li>
+ <li><strong>Native x402 / HTTP 402 payments.</strong> Creators monetize through time-passes, trials, and per-session payments in USDC, with earnings settled on-chain.</li>
+ </ul>
+
+ <h2>Why Dappbay matters</h2>
+ <p>Dappbay is BNB Chain's official discovery layer for decentralized applications &mdash; the dApp directory that BNB Chain itself publishes and that the wider BSC ecosystem uses to find, vet, and rank projects. A Dappbay listing puts three.ws inside that discovery flow and surfaces it to the BNB Chain community looking for AI agent infrastructure, launchpads, and tooling.</p>
+ <p>three.ws settles agent payments on Solana, Base, and Polygon today; the Dappbay presence is about distribution and reach into BNB Chain's AI dApp audience, not a chain migration. The underlying x402 protocol is chain-agnostic, and we're open to expanding payment rails wherever agent demand lives.</p>
+
+ <h2>What gets listed</h2>
+ <ul>
+ <li><strong>Project:</strong> three &mdash; <em>The platform for 3D AI agents on-chain.</em></li>
+ <li><strong>Categories:</strong> AI Agent Launchpad &middot; AI Data &middot; AI Infra</li>
+ <li><strong>Current rank:</strong> AI #121</li>
+ <li><strong>Payment chains:</strong> Solana, Base, Polygon (USDC via x402)</li>
+ </ul>
+
+ <h2>Links</h2>
+ <ul>
+ <li>Dappbay listing: <a href="https://dappbay.bnbchain.org/detail/three" rel="noopener">dappbay.bnbchain.org/detail/three</a></li>
+ <li>Project site: <a href="https://three.ws" rel="noopener">three.ws</a></li>
+ <li>Open source: <a href="https://github.com/nirholas/three.ws" rel="noopener">github.com/nirholas/three.ws</a></li>
+ </ul>
+ </article>
+ </main>
+ <footer>
+ <p>&copy; 2026 three.ws</p>
+ </footer>
+</body>
+</html>
diff --git a/create-selfie.html b/create-selfie.html
new file mode 100644
index 000000000..137dd8b1e
--- /dev/null
+++ b/create-selfie.html
@@ -0,0 +1,377 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
+ <title>Selfie to avatar · three.ws</title>
+ <link rel="icon" href="/favicon.ico" />
+ <meta name="description" content="Snap three photos — three.ws builds you a rigged 3D avatar in about a minute." />
+ <meta name="robots" content="noindex" />
+
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:url" content="https://three.ws/create/selfie" />
+ <meta property="og:title" content="Selfie to avatar · three.ws" />
+ <meta property="og:description" content="Snap three photos — three.ws builds you a rigged 3D avatar in about a minute." />
+ <meta property="og:image" content="https://three.ws/assets/og-image.png" />
+
+ <style>
+ :root {
+ color-scheme: dark;
+ --bg: #05060a;
+ --panel: #0f1018;
+ --panel-elev: #15171f;
+ --border: #1e1f2b;
+ --border-strong: #2a2c3a;
+ --text: #eee;
+ --muted: #8a8d98;
+ --accent: #d6ff3d;
+ --accent-ink: #0a0a0a;
+ --danger: #ef4d4d;
+ --danger-dim: #6a1f1f;
+ }
+ * { box-sizing: border-box; }
+ html, body { margin: 0; padding: 0; }
+ body {
+ font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
+ color: var(--text);
+ background: var(--bg);
+ min-height: 100vh;
+ overflow-x: hidden;
+ }
+ body::before {
+ content: '';
+ position: fixed;
+ inset: 0;
+ z-index: -1;
+ pointer-events: none;
+ background:
+ radial-gradient(800px 500px at 50% -100px, rgba(106, 92, 255, 0.10) 0, transparent 70%),
+ radial-gradient(600px 400px at 50% 110%, rgba(214, 255, 61, 0.04) 0, transparent 70%),
+ #05060a;
+ }
+ main.stage {
+ max-width: 720px;
+ margin: 0 auto;
+ padding: 32px 20px 96px;
+ }
+ .topbar {
+ display: flex;
+ align-items: center;
+ gap: 14px;
+ margin-bottom: 28px;
+ }
+ .topbar button.back {
+ background: var(--panel);
+ border: 1px solid var(--border);
+ color: var(--text);
+ width: 36px;
+ height: 36px;
+ border-radius: 9px;
+ font: inherit;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ }
+ .topbar button.back:hover { border-color: var(--border-strong); }
+ .topbar .label {
+ font-size: 12px;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: var(--muted);
+ }
+ .topbar .label strong { color: var(--text); font-weight: 600; }
+ h1 {
+ font-size: 28px;
+ line-height: 1.25;
+ margin: 0 0 8px;
+ }
+ .sub {
+ color: var(--muted);
+ margin: 0 0 28px;
+ line-height: 1.55;
+ }
+ .step { display: none; }
+ .step.active { display: block; }
+ .unsupported {
+ display: none;
+ padding: 12px 14px;
+ background: rgba(239, 77, 77, 0.08);
+ border: 1px solid var(--danger-dim);
+ border-radius: 9px;
+ color: #f4b5b5;
+ font-size: 13.5px;
+ margin: 0 0 20px;
+ }
+ .unsupported.show { display: block; }
+
+ .choice-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 14px;
+ }
+ @media (max-width: 560px) { .choice-grid { grid-template-columns: 1fr; } }
+ .choice {
+ padding: 22px 18px;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ color: var(--text);
+ font: inherit;
+ text-align: left;
+ cursor: pointer;
+ transition: border-color 120ms, transform 120ms, background 120ms;
+ }
+ .choice:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
+ .choice:disabled { opacity: 0.45; cursor: not-allowed; }
+ .choice .icon { font-size: 26px; margin-bottom: 10px; display: block; }
+ .choice .title { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
+ .choice .desc { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }
+
+ .slots {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: 12px;
+ margin: 8px 0 24px;
+ }
+ @media (max-width: 560px) { .slots { grid-template-columns: 1fr; } }
+ .slot-frame {
+ aspect-ratio: 3 / 4;
+ background: var(--panel);
+ border: 1.5px dashed var(--border-strong);
+ border-radius: 11px;
+ position: relative;
+ overflow: hidden;
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ color: var(--muted);
+ transition: border-color 120ms, background 120ms;
+ }
+ .slot-frame:hover, .slot-frame:focus-visible { border-color: var(--accent); color: var(--text); outline: none; }
+ .slot-frame.drag { border-color: var(--accent); background: rgba(214, 255, 61, 0.05); }
+ .slot-frame.filled { border-style: solid; border-color: var(--border); padding: 0; }
+ .slot-frame .slot-label { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
+ .slot-frame .slot-hint { font-size: 13px; color: var(--text); font-weight: 500; }
+ .slot-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
+ .slot-frame .retake-btn {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ background: rgba(0, 0, 0, 0.7);
+ border: 1px solid rgba(255, 255, 255, 0.2);
+ color: var(--text);
+ border-radius: 7px;
+ padding: 4px 9px;
+ font: 600 11px/1 inherit;
+ cursor: pointer;
+ }
+
+ .opts {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 18px;
+ margin: 0 0 22px;
+ }
+ @media (max-width: 560px) { .opts { grid-template-columns: 1fr; } }
+ .opt-group .opt-label {
+ font-size: 12px;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: var(--muted);
+ margin: 0 0 8px;
+ }
+ .toggle {
+ display: inline-flex;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 9px;
+ padding: 3px;
+ gap: 2px;
+ }
+ .toggle button {
+ background: transparent;
+ border: none;
+ color: var(--muted);
+ font: 600 13px/1 inherit;
+ padding: 8px 14px;
+ border-radius: 7px;
+ cursor: pointer;
+ }
+ .toggle button[aria-pressed="true"] {
+ background: var(--panel-elev);
+ color: var(--text);
+ }
+ .toggle button:hover { color: var(--text); }
+ .opt-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
+
+ .submit-bar {
+ margin-top: 6px;
+ }
+ .submit-bar[hidden] { display: none; }
+ #submit-btn {
+ width: 100%;
+ padding: 14px 18px;
+ background: var(--panel);
+ color: var(--muted);
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ font: 600 15px/1 inherit;
+ cursor: not-allowed;
+ transition: background 120ms, color 120ms, border-color 120ms;
+ }
+ #submit-btn.ready {
+ background: var(--accent);
+ color: var(--accent-ink);
+ border-color: var(--accent);
+ cursor: pointer;
+ }
+ #submit-btn.ready:hover { filter: brightness(1.04); }
+
+ .camera-overlay {
+ position: fixed;
+ inset: 0;
+ background: #000;
+ z-index: 1000;
+ display: flex;
+ flex-direction: column;
+ }
+ .camera-overlay video {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+ .camera-overlay .cam-bar {
+ position: absolute;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ padding: 18px 20px 32px;
+ background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ }
+ .camera-overlay button {
+ background: var(--panel);
+ color: var(--text);
+ border: 1px solid var(--border);
+ border-radius: 9px;
+ padding: 10px 14px;
+ font: 600 14px/1 inherit;
+ cursor: pointer;
+ }
+ .camera-overlay button.shutter {
+ width: 72px;
+ height: 72px;
+ border-radius: 50%;
+ background: var(--accent);
+ color: var(--accent-ink);
+ border: none;
+ }
+ .camera-overlay .cam-prompt {
+ position: absolute;
+ top: 24px;
+ left: 0;
+ right: 0;
+ text-align: center;
+ color: rgba(255, 255, 255, 0.92);
+ font-size: 14px;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ }
+ </style>
+</head>
+<body>
+ <main class="stage">
+ <div class="topbar">
+ <button class="back" id="back-btn" aria-label="Back" type="button">
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <line x1="19" y1="12" x2="5" y2="12" />
+ <polyline points="12 19 5 12 12 5" />
+ </svg>
+ </button>
+ <div class="label"><strong>three.ws</strong> · Selfie to avatar</div>
+ </div>
+
+ <p id="unsupported-msg" class="unsupported">
+ Your browser can't open the camera here — use Upload instead, or open this page in Safari / Chrome on a device with a camera.
+ </p>
+
+ <!-- Step 1: pick method -->
+ <section class="step active" data-step="method">
+ <h1>How do you want to give us 3 photos?</h1>
+ <p class="sub">Frontal, left, and right shots of your face. Good light, plain background. We'll downscale them locally before upload.</p>
+
+ <div class="choice-grid" role="group" aria-label="Choose capture method">
+ <button type="button" class="choice" data-method="camera">
+ <span class="icon" aria-hidden="true">📷</span>
+ <span class="title">Use camera</span>
+ <p class="desc">Snap three live photos in your browser. Best if you're on a phone.</p>
+ </button>
+ <button type="button" class="choice" data-method="upload">
+ <span class="icon" aria-hidden="true">🖼️</span>
+ <span class="title">Upload files</span>
+ <p class="desc">Pick three JPEG / PNG files from your device. Drag-and-drop works too.</p>
+ </button>
+ </div>
+ </section>
+
+ <!-- Step 2: capture slots + selectors -->
+ <section class="step" data-step="capture">
+ <h1>Three photos of your face</h1>
+ <p class="sub">Frontal, left (head turned ~45° left), right (~45° right). Tap a slot to start.</p>
+
+ <div class="slots">
+ <div class="slot-frame" data-slot="frontal" role="button" tabindex="0" aria-label="Frontal photo slot">
+ <span class="slot-label">Frontal</span>
+ <span class="slot-hint">Face the camera</span>
+ </div>
+ <div class="slot-frame" data-slot="left" role="button" tabindex="0" aria-label="Left photo slot">
+ <span class="slot-label">Left</span>
+ <span class="slot-hint">Turn 45° left</span>
+ </div>
+ <div class="slot-frame" data-slot="right" role="button" tabindex="0" aria-label="Right photo slot">
+ <span class="slot-label">Right</span>
+ <span class="slot-hint">Turn 45° right</span>
+ </div>
+ </div>
+
+ <input type="file" data-slot-input="frontal" accept="image/jpeg,image/png" hidden />
+ <input type="file" data-slot-input="left" accept="image/jpeg,image/png" hidden />
+ <input type="file" data-slot-input="right" accept="image/jpeg,image/png" hidden />
+
+ <div class="opts">
+ <div class="opt-group">
+ <p class="opt-label">Body</p>
+ <div class="toggle" role="group" aria-label="Body type">
+ <button type="button" data-body="male" aria-pressed="true">Male</button>
+ <button type="button" data-body="female" aria-pressed="false">Female</button>
+ </div>
+ </div>
+ <div class="opt-group">
+ <p class="opt-label">Style</p>
+ <div class="toggle" role="group" aria-label="Avatar style">
+ <button type="button" data-type="v1" aria-pressed="true">Photoreal</button>
+ <button type="button" data-type="v2" aria-pressed="false">Stylized</button>
+ </div>
+ <p class="opt-hint">Stylized renders as a cleaner cartoon-leaning look.</p>
+ </div>
+ </div>
+
+ <div id="submit-bar" class="submit-bar" hidden>
+ <button id="submit-btn" type="button" disabled>Add 3 photos to continue</button>
+ </div>
+ </section>
+ </main>
+
+ <script type="module">
+ import '/src/selfie-capture.js';
+ import '/src/selfie-pipeline.js';
+ </script>
+</body>
+</html>
diff --git a/data/rss/items.json b/data/rss/items.json
index d3630d5c4..fb07f341a 100644
--- a/data/rss/items.json
+++ b/data/rss/items.json
@@ -1,6 +1,23 @@
{
"_readme": "Curated RSS items for https://three.ws/rss/announcements.xml. Edit this file to control exactly what HackerNoon (and any RSS reader) sees. Each entry needs: id (stable slug), title, date (ISO 8601), body_html. Optional: link, author, summary, tags. Items are served newest-first by date; cap is 50. Seeded from data/archives/trythreews_tweets_2026-05-16.json on 2026-05-16 (35 entries). Re-run scripts/seed-rss-from-archive.mjs to refresh from a newer scrape.",
"items": [
+ {
+ "id": "listed-on-bnb-chain-dappbay",
+ "title": "three.ws Listed on BNB Chain's Dappbay Directory",
+ "date": "2026-05-17T18:00:00.000Z",
+ "link": "https://three.ws/blog/three-ws-on-bnb-chain-dappbay.html",
+ "author": "three.ws",
+ "summary": "three.ws is now listed on Dappbay, BNB Chain's official dApp directory, under AI Agent Launchpad, AI Data, and AI Infra. The listing puts <agent-3d> — the one-tag deploy for Solana-minted, ERC-8004-walleted, x402-native 3D agents — in front of the BNB Chain ecosystem's discovery surface for AI dApps.",
+ "body_html": "<p><strong>three.ws is now listed on <a href=\"https://dappbay.bnbchain.org/detail/three\" rel=\"noopener\">Dappbay</a>, BNB Chain's official dApp directory.</strong> The listing is live under the categories <em>AI Agent Launchpad</em>, <em>AI Data</em>, and <em>AI Infra</em>, with a current rank of <strong>AI #121</strong>.</p>\n<ul>\n<li>Dappbay listing: <a href=\"https://dappbay.bnbchain.org/detail/three\" rel=\"noopener\">dappbay.bnbchain.org/detail/three</a></li>\n<li>Open source: <a href=\"https://github.com/nirholas/three.ws\" rel=\"noopener\">github.com/nirholas/three.ws</a></li>\n<li>Project site: <a href=\"https://three.ws\" rel=\"noopener\">three.ws</a></li>\n</ul>\n<h2>What three.ws ships</h2>\n<p>three.ws is the platform for 3D AI agents on-chain. Every <code>&lt;agent-3d&gt;</code> tag deploys an autonomous 3D character with:</p>\n<ul>\n<li><strong>A Solana NFT identity.</strong> Each agent is minted as a transferable on-chain asset.</li>\n<li><strong>An ERC-8004 wallet.</strong> The emerging cross-chain agent-identity standard, baked in.</li>\n<li><strong>A browser-native 3D body.</strong> Rendered in WebGL &mdash; no plugins, no native install.</li>\n<li><strong>Native x402 / HTTP 402 payments.</strong> Creators monetize through time-passes, trials, and per-session payments in USDC, with earnings settled on-chain.</li>\n</ul>\n<h2>Why Dappbay matters</h2>\n<p>Dappbay is BNB Chain's official discovery layer for decentralized applications &mdash; the dApp directory that BNB Chain itself publishes and that the wider BSC ecosystem uses to find, vet, and rank projects. A Dappbay listing puts three.ws inside that discovery flow and surfaces it to the BNB Chain community looking for AI agent infrastructure, launchpads, and tooling.</p>\n<p>three.ws settles agent payments on Solana, Base, and Polygon today; the Dappbay presence is about distribution and reach into BNB Chain's AI dApp audience, not a chain migration. The underlying x402 protocol is chain-agnostic, and we're open to expanding payment rails wherever agent demand lives.</p>\n<h2>What gets listed</h2>\n<ul>\n<li><strong>Project:</strong> three &mdash; <em>The platform for 3D AI agents on-chain.</em></li>\n<li><strong>Categories:</strong> AI Agent Launchpad &middot; AI Data &middot; AI Infra</li>\n<li><strong>Current rank:</strong> AI #121</li>\n<li><strong>Payment chains:</strong> Solana, Base, Polygon (USDC via x402)</li>\n</ul>\n<h2>Links</h2>\n<ul>\n<li>Dappbay listing: <a href=\"https://dappbay.bnbchain.org/detail/three\" rel=\"noopener\">dappbay.bnbchain.org/detail/three</a></li>\n<li>Project site: <a href=\"https://three.ws\" rel=\"noopener\">three.ws</a></li>\n<li>Open source: <a href=\"https://github.com/nirholas/three.ws\" rel=\"noopener\">github.com/nirholas/three.ws</a></li>\n</ul>",
+ "tags": [
+ "listing",
+ "directory",
+ "bnb-chain",
+ "dappbay",
+ "x402",
+ "agent-economy"
+ ]
+ },
{
"id": "live-on-alibaba-cloud-marketplace",
"title": "three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale",
diff --git a/docs/index.html b/docs/index.html
index 57f8a6de5..5cb3687e2 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -652,6 +652,7 @@
title: 'Reference',
links: [
{ label: 'Examples', path: 'examples' },
+ { label: 'Listings & distribution', path: 'listings' },
{ label: 'Troubleshooting', path: 'troubleshooting' },
{ label: 'Changelog', path: 'changelog' },
],
diff --git a/docs/listings.md b/docs/listings.md
new file mode 100644
index 000000000..1ddde77b0
--- /dev/null
+++ b/docs/listings.md
@@ -0,0 +1,53 @@
+# Listings & Distribution
+
+three.ws is open source and self-hostable. It is also distributed through cloud marketplaces (for enterprise procurement) and indexed in ecosystem dApp directories (for community discovery). This page tracks every official listing.
+
+If you maintain a marketplace, registry, or directory and want three.ws listed, open an issue at [github.com/nirholas/three.ws/issues](https://github.com/nirholas/three.ws/issues) or reach out via the contacts on [three.ws](https://three.ws).
+
+---
+
+## Cloud Marketplaces
+
+Cloud marketplaces are the procurement flow enterprises use to acquire software through their existing cloud account, with consolidated billing, compliance, and support.
+
+| Cloud | Status | Links |
+|---|---|---|
+| **Alibaba Cloud** International Marketplace | Live | [Product listing](https://marketplace.alibabacloud.com/products/56724001/sgcmfw00036800.html) · [Storefront](https://marketplace.alibabacloud.com/store/3247293.html) · [Announcement](/blog/three-ws-on-alibaba-cloud-marketplace.html) |
+| **Google Cloud** Marketplace | Open to partnership | three.ws runs on WebGL, Vercel edge, and EVM — a natural fit for Vertex AI and GCP's global CDN. Reach out for co-listing, credits, and joint GTM. |
+| **AWS** Marketplace | On roadmap | Targeted for the cross-marketplace expansion phase described in the [Alibaba launch post](/blog/three-ws-on-alibaba-cloud-marketplace.html). |
+| **Microsoft Azure** Marketplace | On roadmap | Targeted alongside AWS. |
+
+---
+
+## Ecosystem Directories
+
+Ecosystem directories are the discovery surfaces that L1/L2 communities, chain foundations, and dApp explorers publish to help users find vetted projects on their stack.
+
+| Directory | Status | Listing details |
+|---|---|---|
+| **BNB Chain · Dappbay** | Live | [dappbay.bnbchain.org/detail/three](https://dappbay.bnbchain.org/detail/three) — categories: *AI Agent Launchpad · AI Data · AI Infra*. Announcement: [three.ws Listed on BNB Chain's Dappbay Directory](/blog/three-ws-on-bnb-chain-dappbay.html). |
+
+Dappbay is BNB Chain's official dApp directory. The listing is about distribution and discovery into BNB Chain's AI dApp audience — three.ws still settles agent payments on Solana, Base, and Polygon via the chain-agnostic [x402 protocol](./x402.md).
+
+---
+
+## Open Source
+
+The full stack is on GitHub:
+
+- **three.ws** — [github.com/nirholas/three.ws](https://github.com/nirholas/three.ws)
+- Mirrored at — [github.com/nirholas/3D-Agent](https://github.com/nirholas/3D-Agent)
+
+The codebase includes the `<agent-3d>` browser component, the Solana minting SDK, the x402 payment SDK, the ERC-8004 wallet integration, and the agent-payments SDK used by third-party developers.
+
+---
+
+## RSS & Announcements
+
+Every listing is announced through:
+
+- **RSS** — [`https://three.ws/rss/announcements.xml`](https://three.ws/rss/announcements.xml)
+- **News index** — [`https://three.ws/news/`](https://three.ws/news/)
+- **Blog** — [`https://three.ws/blog/`](https://three.ws/blog/)
+
+Subscribe via RSS to track new listings, integrations, and protocol updates.
diff --git a/package-lock.json b/package-lock.json
index 52a51b2e8..589de80af 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -27,6 +27,7 @@
"@gltf-transform/extensions": "^4.3.0",
"@huggingface/inference": "^2.7.0",
"@jup-ag/api": "^6.0.48",
+ "@mediapipe/tasks-vision": "^0.10.35",
"@metaplex-foundation/mpl-core": "^1.10.0",
"@metaplex-foundation/umi": "^1.5.1",
"@metaplex-foundation/umi-bundle-defaults": "^1.5.1",
@@ -9039,6 +9040,12 @@
"resolved": "character-studio",
"link": true
},
+ "node_modules/@mediapipe/tasks-vision": {
+ "version": "0.10.35",
+ "resolved": "https://registry.npmjs.org/@mediapipe/tasks-vision/-/tasks-vision-0.10.35.tgz",
+ "integrity": "sha512-HOvadwVRE6JC+45nyYhmnywnr5h/J8KZvOeUNVOG9q/0875pZgItznFB9bRTvLc264YSJqiZ1NsIpCStJw/egg==",
+ "license": "Apache-2.0"
+ },
"node_modules/@metaplex-foundation/beet": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/@metaplex-foundation/beet/-/beet-0.7.1.tgz",
diff --git a/package.json b/package.json
index 69d7a5dd1..85e90b126 100644
--- a/package.json
+++ b/package.json
@@ -98,6 +98,7 @@
"@gltf-transform/extensions": "^4.3.0",
"@huggingface/inference": "^2.7.0",
"@jup-ag/api": "^6.0.48",
+ "@mediapipe/tasks-vision": "^0.10.35",
"@metaplex-foundation/mpl-core": "^1.10.0",
"@metaplex-foundation/umi": "^1.5.1",
"@metaplex-foundation/umi-bundle-defaults": "^1.5.1",
diff --git a/public/demo/avatar-os/combined.html b/public/demo/avatar-os/combined.html
new file mode 100644
index 000000000..cba62f9fd
--- /dev/null
+++ b/public/demo/avatar-os/combined.html
@@ -0,0 +1,103 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Combined · OSS Avatar Pipeline</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="robots" content="noindex" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/demo/avatar-os/shared.css" />
+ </head>
+ <body>
+ <header class="os-header">
+ <div class="brand">
+ three.ws<span class="tag">avatar-os · combined</span>
+ </div>
+ <nav>
+ <a href="/demo/avatar-os/">overview</a>
+ <a href="/demo/avatar-os/studio.html">studio</a>
+ <a href="/demo/avatar-os/selfie.html">selfie</a>
+ <a href="/demo/avatar-os/combined.html" class="active">combined</a>
+ </nav>
+ </header>
+ <main class="os-main">
+ <div class="banner">
+ <strong>Selfie face on body GLB.</strong> Combines the MediaPipe face
+ mesh with a body GLB (loaded from a URL, either a Studio-exported file
+ or the default base body). Exports one merged GLB.
+ </div>
+
+ <div class="os-grid">
+ <aside>
+ <div class="os-card">
+ <h2>1 · Body GLB</h2>
+ <p>Pick the body to attach the face to.</p>
+ <div class="btn-row">
+ <button id="btn-body-default" class="btn btn-primary">
+ Use default body
+ </button>
+ <button id="btn-body-upload" class="btn">
+ Upload Studio GLB
+ </button>
+ <input
+ type="file"
+ id="body-file-input"
+ accept=".glb,model/gltf-binary"
+ hidden
+ />
+ </div>
+ <div class="status" id="body-status">no body loaded</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>2 · Selfie</h2>
+ <p>Frontal photo only (the face mesh demo handles 3 photos).</p>
+ <div class="photo-slots" style="grid-template-columns: 1fr">
+ <label class="photo-slot" data-slot="frontal">
+ <input type="file" accept="image/*" capture="user" hidden />
+ <span class="label">frontal selfie</span>
+ </label>
+ </div>
+ <div class="status" id="capture-status">no photo</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>3 · Combine</h2>
+ <p>
+ Builds the face mesh and parents it to the body's head bone (if
+ present) or positions it at the body's bounding box top.
+ </p>
+ <button id="btn-build" class="btn btn-primary" disabled>
+ Build combined avatar
+ </button>
+ <div class="status" id="build-status">waiting</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>4 · Export</h2>
+ <div class="btn-row">
+ <button id="btn-download" class="btn" disabled>
+ Download merged GLB
+ </button>
+ <button id="btn-save" class="btn" disabled>
+ Save to my avatars
+ </button>
+ </div>
+ <div class="status" id="export-status">build first</div>
+ </div>
+ </aside>
+
+ <section>
+ <div class="viewer" id="viewer-host" style="min-height: 600px">
+ <div class="badge" id="viewer-badge">three.js · idle</div>
+ <div class="overlay" id="viewer-overlay">
+ Load a body + selfie, then click <span class="kbd">Build combined avatar</span>
+ </div>
+ </div>
+ </section>
+ </div>
+ </main>
+ <script type="module" src="/src/demo/os-combined.js"></script>
+ </body>
+</html>
diff --git a/public/demo/avatar-os/index.html b/public/demo/avatar-os/index.html
new file mode 100644
index 000000000..f97853e3e
--- /dev/null
+++ b/public/demo/avatar-os/index.html
@@ -0,0 +1,126 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>OSS Avatar Pipeline · three.ws</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="robots" content="noindex" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/demo/avatar-os/shared.css" />
+ </head>
+ <body>
+ <header class="os-header">
+ <div class="brand">
+ three.ws<span class="tag">avatar-os demo</span>
+ </div>
+ <nav>
+ <a href="/demo/avatar-os/" class="active">overview</a>
+ <a href="/demo/avatar-os/studio.html">studio</a>
+ <a href="/demo/avatar-os/selfie.html">selfie</a>
+ <a href="/demo/avatar-os/combined.html">combined</a>
+ </nav>
+ </header>
+ <main class="os-main">
+ <div class="banner">
+ <strong>Isolated demo workspace.</strong> Nothing here touches the
+ production Avaturn pipeline. Goal: prove out a fully open-source
+ replacement before promoting it.
+ </div>
+
+ <h1 style="margin: 0 0 8px; font-size: 28px">Open-source avatar pipeline</h1>
+ <p style="color: var(--text-2); max-width: 720px; line-height: 1.6">
+ Three parallel paths replace what we currently get from Avaturn. Each
+ demo is end-to-end functional — capture, generate, preview, export GLB.
+ No mocks, no fake data.
+ </p>
+
+ <div class="tile-grid">
+ <a class="tile" href="/demo/avatar-os/studio.html">
+ <h3>Studio · customization editor</h3>
+ <p>
+ Embeds the open-source CharacterStudio (M3-org / Apache-2.0)
+ editor. Pick a base avatar, customize traits, export GLB. Replaces
+ the Avaturn iframe editor.
+ </p>
+ <div class="meta">
+ stack: @m3-org/characterstudio · @pixiv/three-vrm · three.js
+ </div>
+ </a>
+ <a class="tile" href="/demo/avatar-os/selfie.html">
+ <h3>Selfie · photo → 3D face mesh</h3>
+ <p>
+ MediaPipe Face Landmarker (Apache-2.0) runs entirely in-browser to
+ build a textured 3D mesh from one selfie. Replaces the Avaturn
+ photo-to-avatar API.
+ </p>
+ <div class="meta">
+ stack: @mediapipe/tasks-vision · three.js · WebGL
+ </div>
+ </a>
+ <a class="tile" href="/demo/avatar-os/combined.html">
+ <h3>Combined · selfie face + Studio body</h3>
+ <p>
+ Stitches the selfie face mesh onto a Studio body GLB and exports
+ a single merged GLB. Closest analogue to the Avaturn end product.
+ </p>
+ <div class="meta">stack: all of the above + GLTFExporter</div>
+ </a>
+ </div>
+
+ <section style="margin-top: 48px">
+ <h2 style="font-size: 18px; margin: 0 0 12px">What's wired</h2>
+ <ul style="color: var(--text-2); line-height: 1.8; font-size: 14px">
+ <li>
+ MediaPipe Tasks Vision pulled via npm
+ (<code>@mediapipe/tasks-vision</code>). WASM + model files
+ fetch from Google's CDN at runtime.
+ </li>
+ <li>
+ Triangulation indices from
+ <a
+ href="https://github.com/tensorflow/tfjs-models/blob/master/face-landmarks-detection/demos/shared/triangulation.js"
+ >tfjs-models</a
+ >
+ (Apache-2.0) — vendored at <code>src/demo/triangulation.js</code>.
+ </li>
+ <li>
+ CharacterStudio is the existing
+ <code>character-studio/</code> workspace (M3-org, AGPL — under
+ review). Demo expects the dev server at
+ <code>http://localhost:5173</code>; run
+ <code>npm --prefix character-studio run dev</code> in a second
+ terminal.
+ </li>
+ <li>
+ GLB export uses three.js's
+ <code>GLTFExporter</code> from <code>three/addons</code>.
+ </li>
+ </ul>
+ </section>
+
+ <section style="margin-top: 32px">
+ <h2 style="font-size: 18px; margin: 0 0 12px">Status</h2>
+ <div id="status-grid" class="tile-grid">
+ <div class="tile">
+ <h3>MediaPipe wasm</h3>
+ <div class="status" id="mp-status">checking…</div>
+ </div>
+ <div class="tile">
+ <h3>Triangulation</h3>
+ <div class="status" id="tri-status">checking…</div>
+ </div>
+ <div class="tile">
+ <h3>Base body GLB</h3>
+ <div class="status" id="glb-status">checking…</div>
+ </div>
+ <div class="tile">
+ <h3>CharacterStudio dev server</h3>
+ <div class="status" id="cs-status">checking…</div>
+ </div>
+ </div>
+ </section>
+ </main>
+ <script type="module" src="/src/demo/os-hub.js"></script>
+ </body>
+</html>
diff --git a/public/demo/avatar-os/selfie.html b/public/demo/avatar-os/selfie.html
new file mode 100644
index 000000000..0df74e739
--- /dev/null
+++ b/public/demo/avatar-os/selfie.html
@@ -0,0 +1,122 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Selfie · OSS Avatar Pipeline</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="robots" content="noindex" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/demo/avatar-os/shared.css" />
+ </head>
+ <body>
+ <header class="os-header">
+ <div class="brand">
+ three.ws<span class="tag">avatar-os · selfie</span>
+ </div>
+ <nav>
+ <a href="/demo/avatar-os/">overview</a>
+ <a href="/demo/avatar-os/studio.html">studio</a>
+ <a href="/demo/avatar-os/selfie.html" class="active">selfie</a>
+ <a href="/demo/avatar-os/combined.html">combined</a>
+ </nav>
+ </header>
+ <main class="os-main">
+ <div class="banner">
+ <strong>Photo → 3D face mesh.</strong> Runs MediaPipe Face Landmarker
+ entirely in-browser (no server). 478 landmarks → textured face mesh →
+ GLB. Replaces the Avaturn selfie API.
+ </div>
+
+ <div class="os-grid">
+ <aside>
+ <div class="os-card">
+ <h2>1 · Capture</h2>
+ <p>
+ Front-facing photo gives the best face mesh. Side photos are
+ optional (used by the combined demo for additional reference).
+ </p>
+ <div class="photo-slots">
+ <label class="photo-slot" data-slot="frontal">
+ <input type="file" accept="image/*" capture="user" hidden />
+ <span class="label">frontal</span>
+ </label>
+ <label class="photo-slot" data-slot="left">
+ <input type="file" accept="image/*" hidden />
+ <span class="label">left</span>
+ </label>
+ <label class="photo-slot" data-slot="right">
+ <input type="file" accept="image/*" hidden />
+ <span class="label">right</span>
+ </label>
+ </div>
+ <div class="btn-row">
+ <button id="btn-camera" class="btn">Use camera</button>
+ <button id="btn-clear" class="btn">Clear</button>
+ </div>
+ <div class="status" id="capture-status">no photos yet</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>2 · Build face mesh</h2>
+ <p>
+ Runs the MediaPipe Face Landmarker on the frontal photo. Builds
+ a three.js BufferGeometry: 478 vertex positions from landmarks,
+ UVs from image coords, indices from the tfjs-models
+ triangulation (Apache-2.0, vendored).
+ </p>
+ <button id="btn-build" class="btn btn-primary" disabled>
+ Build face mesh
+ </button>
+ <div class="status" id="build-status">waiting for photo</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>3 · Export</h2>
+ <div class="btn-row">
+ <button id="btn-download" class="btn" disabled>
+ Download GLB
+ </button>
+ <button id="btn-save" class="btn" disabled>
+ Save to my avatars
+ </button>
+ </div>
+ <div class="status" id="export-status">build first</div>
+ </div>
+ </aside>
+
+ <section>
+ <div class="viewer" id="viewer-host">
+ <div class="badge" id="viewer-badge">three.js · idle</div>
+ <div class="overlay" id="viewer-overlay">
+ Capture a frontal selfie and click <span class="kbd">Build face mesh</span>
+ </div>
+ </div>
+ <video
+ id="camera-video"
+ autoplay
+ playsinline
+ muted
+ style="
+ display: none;
+ margin-top: 12px;
+ width: 100%;
+ max-height: 360px;
+ border-radius: 12px;
+ background: #000;
+ "
+ ></video>
+ <div class="btn-row" id="camera-controls" style="display: none; margin-top: 8px">
+ <button id="btn-snap-frontal" class="btn btn-primary">
+ Snap frontal
+ </button>
+ <button id="btn-snap-left" class="btn">Snap left</button>
+ <button id="btn-snap-right" class="btn">Snap right</button>
+ <button id="btn-stop-camera" class="btn">Stop camera</button>
+ </div>
+ </section>
+ </div>
+ </main>
+ <script type="module" src="/src/demo/os-selfie.js"></script>
+ </body>
+</html>
diff --git a/public/demo/avatar-os/shared.css b/public/demo/avatar-os/shared.css
new file mode 100644
index 000000000..16b900b09
--- /dev/null
+++ b/public/demo/avatar-os/shared.css
@@ -0,0 +1,305 @@
+/* Shared chrome for the OSS avatar pipeline demos. */
+:root {
+ --bg: #0a0a0a;
+ --panel: #111;
+ --panel-2: #161616;
+ --border: #1f1f1f;
+ --border-2: #2a2a2a;
+ --text: #fafafa;
+ --text-2: #a1a1aa;
+ --text-3: #71717a;
+ --accent: #7dd3fc;
+ --accent-2: #a78bfa;
+ --danger: #f87171;
+ --ok: #4ade80;
+}
+
+* {
+ box-sizing: border-box;
+}
+
+html,
+body {
+ margin: 0;
+ padding: 0;
+ background: var(--bg);
+ color: var(--text);
+ font-family:
+ ui-sans-serif,
+ system-ui,
+ -apple-system,
+ "Segoe UI",
+ Roboto,
+ sans-serif;
+}
+
+a {
+ color: var(--accent);
+ text-decoration: none;
+}
+a:hover {
+ text-decoration: underline;
+}
+
+.os-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 16px 24px;
+ border-bottom: 1px solid var(--border);
+ background: rgba(10, 10, 10, 0.7);
+ backdrop-filter: blur(8px);
+ position: sticky;
+ top: 0;
+ z-index: 10;
+}
+.os-header .brand {
+ font-weight: 600;
+ letter-spacing: 0.02em;
+}
+.os-header .brand .tag {
+ margin-left: 10px;
+ font-size: 11px;
+ padding: 3px 8px;
+ border-radius: 999px;
+ color: var(--accent-2);
+ background: rgba(167, 139, 250, 0.12);
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+}
+.os-header nav {
+ display: flex;
+ gap: 18px;
+ font-size: 13px;
+}
+.os-header nav a {
+ color: var(--text-2);
+}
+.os-header nav a.active {
+ color: var(--text);
+}
+
+.os-main {
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 32px 24px 80px;
+}
+
+.os-grid {
+ display: grid;
+ grid-template-columns: 360px 1fr;
+ gap: 24px;
+}
+@media (max-width: 900px) {
+ .os-grid {
+ grid-template-columns: 1fr;
+ }
+}
+
+.os-card {
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 20px;
+}
+.os-card h2 {
+ margin: 0 0 12px;
+ font-size: 16px;
+}
+.os-card p {
+ margin: 0 0 12px;
+ color: var(--text-2);
+ font-size: 13px;
+ line-height: 1.5;
+}
+
+.btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 10px 16px;
+ border-radius: 8px;
+ border: 1px solid var(--border-2);
+ background: var(--panel-2);
+ color: var(--text);
+ font-size: 13px;
+ font-family: inherit;
+ cursor: pointer;
+ transition: all 0.15s;
+}
+.btn:hover:not([disabled]) {
+ background: #1d1d1d;
+ border-color: #3a3a3a;
+}
+.btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+}
+.btn-primary {
+ background: linear-gradient(135deg, #7dd3fc, #a78bfa);
+ color: #0a0a0a;
+ border-color: transparent;
+ font-weight: 600;
+}
+.btn-primary:hover:not([disabled]) {
+ filter: brightness(1.1);
+}
+.btn-row {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.status {
+ font-size: 12px;
+ color: var(--text-3);
+ margin-top: 8px;
+ font-family: ui-monospace, "SF Mono", Menlo, monospace;
+}
+.status.ok {
+ color: var(--ok);
+}
+.status.err {
+ color: var(--danger);
+}
+
+.viewer {
+ position: relative;
+ background: #050505;
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ min-height: 480px;
+ overflow: hidden;
+}
+.viewer canvas {
+ display: block;
+ width: 100%;
+ height: 100%;
+}
+.viewer .overlay {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: var(--text-3);
+ font-size: 13px;
+ pointer-events: none;
+}
+.viewer .badge {
+ position: absolute;
+ top: 12px;
+ right: 12px;
+ padding: 4px 8px;
+ font-size: 11px;
+ border-radius: 6px;
+ background: rgba(0, 0, 0, 0.6);
+ color: var(--text-2);
+ font-family: ui-monospace, monospace;
+}
+
+.photo-slots {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: 8px;
+ margin: 12px 0;
+}
+.photo-slot {
+ aspect-ratio: 3 / 4;
+ border: 1px dashed var(--border-2);
+ border-radius: 8px;
+ background: var(--panel-2);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: var(--text-3);
+ font-size: 11px;
+ overflow: hidden;
+ position: relative;
+}
+.photo-slot img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+.photo-slot .label {
+ position: absolute;
+ bottom: 4px;
+ left: 4px;
+ right: 4px;
+ font-size: 10px;
+ text-align: center;
+ color: var(--text);
+ background: rgba(0, 0, 0, 0.5);
+ padding: 2px;
+ border-radius: 4px;
+}
+
+.tile-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
+ gap: 16px;
+ margin-top: 16px;
+}
+.tile {
+ display: block;
+ padding: 20px;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ color: inherit;
+ transition: all 0.2s;
+}
+.tile:hover {
+ border-color: var(--accent-2);
+ transform: translateY(-2px);
+ text-decoration: none;
+}
+.tile h3 {
+ margin: 0 0 8px;
+ font-size: 16px;
+ color: var(--accent);
+}
+.tile p {
+ margin: 0;
+ color: var(--text-2);
+ font-size: 13px;
+ line-height: 1.5;
+}
+.tile .meta {
+ margin-top: 12px;
+ font-size: 11px;
+ color: var(--text-3);
+ font-family: ui-monospace, monospace;
+}
+
+.banner {
+ padding: 12px 16px;
+ border-radius: 8px;
+ background: rgba(167, 139, 250, 0.08);
+ border: 1px solid rgba(167, 139, 250, 0.2);
+ color: var(--text-2);
+ font-size: 13px;
+ margin-bottom: 24px;
+}
+.banner strong {
+ color: var(--accent-2);
+}
+
+iframe.studio-frame {
+ width: 100%;
+ height: 600px;
+ border: 0;
+ border-radius: 12px;
+ background: #050505;
+}
+
+.kbd {
+ font-family: ui-monospace, monospace;
+ font-size: 11px;
+ padding: 2px 6px;
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ border-radius: 4px;
+ color: var(--text);
+}
diff --git a/public/demo/avatar-os/studio.html b/public/demo/avatar-os/studio.html
new file mode 100644
index 000000000..881f8cb63
--- /dev/null
+++ b/public/demo/avatar-os/studio.html
@@ -0,0 +1,104 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Studio · OSS Avatar Pipeline</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta name="robots" content="noindex" />
+ <meta name="theme-color" content="#0a0a0a" />
+ <link rel="icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/demo/avatar-os/shared.css" />
+ </head>
+ <body>
+ <header class="os-header">
+ <div class="brand">
+ three.ws<span class="tag">avatar-os · studio</span>
+ </div>
+ <nav>
+ <a href="/demo/avatar-os/">overview</a>
+ <a href="/demo/avatar-os/studio.html" class="active">studio</a>
+ <a href="/demo/avatar-os/selfie.html">selfie</a>
+ <a href="/demo/avatar-os/combined.html">combined</a>
+ </nav>
+ </header>
+ <main class="os-main">
+ <div class="banner">
+ <strong>CharacterStudio editor.</strong> Open-source customization
+ editor (M3-org). Built on @pixiv/three-vrm. Replaces the Avaturn iframe
+ editor.
+ </div>
+
+ <div class="os-grid">
+ <aside>
+ <div class="os-card">
+ <h2>1 · Open editor</h2>
+ <p>
+ Loads CharacterStudio in an iframe. Configure the dev server URL
+ or use the public CharacterStudio build.
+ </p>
+ <div class="btn-row">
+ <button id="btn-open-local" class="btn btn-primary">
+ Open localhost:5173
+ </button>
+ <button id="btn-open-public" class="btn">
+ Open public build
+ </button>
+ </div>
+ <div class="status" id="studio-status">idle</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>2 · Export</h2>
+ <p>
+ In CharacterStudio, click <span class="kbd">Export</span> ·
+ <span class="kbd">VRM</span> or <span class="kbd">GLB</span>.
+ This page listens for the export message and renders the result
+ below.
+ </p>
+ <div class="btn-row">
+ <button id="btn-download" class="btn" disabled>
+ Download GLB
+ </button>
+ <button id="btn-save" class="btn" disabled>
+ Save to my avatars
+ </button>
+ </div>
+ <div class="status" id="export-status">no export yet</div>
+ </div>
+
+ <div class="os-card" style="margin-top: 16px">
+ <h2>Postmessage contract</h2>
+ <p style="font-family: ui-monospace, monospace; font-size: 11px">
+ { source: "characterstudio", type: "export", glb: ArrayBuffer }
+ </p>
+ <p style="font-size: 12px; color: var(--text-3); margin: 0">
+ Any window.postMessage from the iframe origin with this shape is
+ captured.
+ </p>
+ </div>
+ </aside>
+
+ <section>
+ <div
+ id="iframe-host"
+ class="viewer"
+ style="min-height: 600px; padding: 0"
+ >
+ <div class="overlay" id="iframe-empty">
+ Click <span class="kbd">Open localhost:5173</span> to start
+ </div>
+ </div>
+
+ <div
+ class="viewer"
+ id="preview-viewer"
+ style="margin-top: 16px; min-height: 360px; display: none"
+ >
+ <div class="badge" id="preview-badge">preview</div>
+ </div>
+ </section>
+ </div>
+ </main>
+ <script type="module" src="/src/demo/os-studio.js"></script>
+ </body>
+</html>
diff --git a/public/coin-dashboard.js b/public/demo/coin/dashboard.js
similarity index 95%
rename from public/coin-dashboard.js
rename to public/demo/coin/dashboard.js
index b9be0fa05..0e847a035 100644
--- a/public/coin-dashboard.js
+++ b/public/demo/coin/dashboard.js
@@ -1,16 +1,17 @@
-// Coin dashboard — vanilla module, no framework.
+// three.ws coin demo dashboard — vanilla module, no framework.
//
// Lifecycle:
-// 1. Parse mint from /coin/<mint>/ URL or query, fall back to "first active
-// coin" from /api/coin/state.
+// 1. Parse mint from /demo/coin/<mint>/ URL or ?mint= query, fall back to
+// "first active coin" returned by /api/demo/coin/state.
// 2. Fetch state every 10s; render pots, KPIs, countdown.
// 3. Tabs (winners | holders | claims | reflections) lazy-fetch their
// data on first open and refresh on the same 10s tick.
-// 4. Wallet input (persisted to localStorage) fetches /api/coin/holder and
-// renders per-wallet stats + recent payouts.
+// 4. Wallet input (persisted to localStorage) fetches /api/demo/coin/holder
+// and renders per-wallet stats + recent payouts.
const POLL_MS = 10_000;
-const LS_KEY = 'coin-dashboard-wallet';
+const LS_KEY = 'threews-coin-demo-wallet';
+const API_BASE = '/api/demo/coin';
const $ = (sel) => document.querySelector(sel);
@@ -23,7 +24,7 @@ const state = {
};
function pickMintFromUrl() {
- const m = window.location.pathname.match(/^\/coin\/([1-9A-HJ-NP-Za-km-z]{32,44})\/?$/);
+ const m = window.location.pathname.match(/^\/demo\/coin\/([1-9A-HJ-NP-Za-km-z]{32,44})\/?$/);
if (m) return m[1];
const q = new URLSearchParams(window.location.search);
return q.get('mint');
@@ -81,7 +82,7 @@ async function fetchJson(url) {
function apiUrl(action, params = {}) {
const q = new URLSearchParams(params);
if (state.mint) q.set('mint', state.mint);
- return `/api/coin/${action}?${q.toString()}`;
+ return `${API_BASE}/${action}?${q.toString()}`;
}
async function refreshState() {
diff --git a/public/coin/index.html b/public/demo/coin/index.html
similarity index 87%
rename from public/coin/index.html
rename to public/demo/coin/index.html
index c207d56dc..b2ebbf154 100644
--- a/public/coin/index.html
+++ b/public/demo/coin/index.html
@@ -3,18 +3,19 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
- <title>Lottery + Reflection · three.ws</title>
- <meta name="description" content="The three.ws lottery + SOL reflection coin. Hourly winners, passive SOL drips to every eligible holder, verifiable randomness." />
+ <title>Demo · Lottery + Reflection · three.ws</title>
+ <meta name="description" content="DEMO — the three.ws lottery + SOL reflection mechanic, under test. Not yet a production launch." />
+ <meta name="robots" content="noindex,nofollow" />
<meta property="og:site_name" content="three.ws" />
- <meta property="og:title" content="Lottery + Reflection · three.ws" />
- <meta property="og:description" content="Hourly lottery + passive SOL reflection. Every holder is a ticket. Verifiable randomness." />
+ <meta property="og:title" content="Demo · Lottery + Reflection · three.ws" />
+ <meta property="og:description" content="Under test on three.ws — hourly lottery + passive SOL reflection. Production launch TBD." />
<meta property="og:type" content="website" />
- <meta property="og:url" content="https://three.ws/coin" />
+ <meta property="og:url" content="https://three.ws/demo/coin" />
<meta property="og:image" content="https://three.ws/3d.png" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@trythreews" />
- <meta name="twitter:title" content="Lottery + Reflection · three.ws" />
- <meta name="twitter:description" content="Hourly lottery + passive SOL reflection. Every holder is a ticket. Verifiable randomness." />
+ <meta name="twitter:title" content="Demo · Lottery + Reflection · three.ws" />
+ <meta name="twitter:description" content="Under test on three.ws — hourly lottery + passive SOL reflection. Production launch TBD." />
<meta name="twitter:image" content="https://three.ws/3d.png" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="/style.css" />
@@ -138,6 +139,13 @@
.brand-strip a { color: var(--accent); text-decoration: none; }
.brand-strip a:hover { text-decoration: underline; }
.brand-strip .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }
+ .brand-strip .demo-tag { background: rgba(255,186,46,0.12); color: var(--accent-3);
+ padding: 2px 8px; border-radius: 999px; font-weight: 700; letter-spacing: 0.08em;
+ border: 1px solid rgba(255,186,46,0.3); }
+ .demo-banner { background: linear-gradient(180deg, rgba(255,186,46,0.10), rgba(255,186,46,0.02));
+ border: 1px solid rgba(255,186,46,0.3); border-radius: 10px; padding: 12px 16px;
+ margin-bottom: 18px; font-size: 13px; color: #f1c870; line-height: 1.5; }
+ .demo-banner strong { color: var(--accent-3); }
</style>
<script defer src="/nav.js"></script>
</head>
@@ -148,6 +156,14 @@
<a href="/">three.ws</a>
<span class="dot-sep"></span>
<span>Lottery + SOL reflection</span>
+ <span class="dot-sep"></span>
+ <span class="demo-tag">DEMO</span>
+ </div>
+ <div class="demo-banner" role="note">
+ <strong>This is a three.ws demo surface.</strong> The mechanic is implemented end-to-end —
+ pump.fun creator-vault claim, verifiable randomness, batched SOL payouts — but is not yet
+ serving a production launch. Nothing here is a public offering. If a coin appears below, it
+ is operating in test mode (dry-run cron, no on-chain payouts until explicitly activated).
</div>
<div id="header" class="title-row">
<h1 id="coin-name">Loading…</h1>
@@ -238,11 +254,11 @@
field needed to independently re-derive the winner (<code>round</code>,
<code>randomness</code>, <code>signature</code>) is persisted into <code>coin_draws</code>
and surfaced on the audit row for each draw — open the API at
- <code>/api/coin/winners</code> for the raw values. Verifiable by anyone, anywhere.
+ <code>/api/demo/coin/winners</code> for the raw values. Verifiable by anyone, anywhere.
</div>
</section>
</main>
<footer id="site-footer"></footer>
- <script type="module" src="/coin-dashboard.js"></script>
+ <script type="module" src="/demo/coin/dashboard.js"></script>
</body>
</html>
diff --git a/public/demos/avatar-sdk.html b/public/demos/avatar-sdk.html
new file mode 100644
index 000000000..f6e68a75e
--- /dev/null
+++ b/public/demos/avatar-sdk.html
@@ -0,0 +1,137 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>@three-ws/avatar SDK · three.ws lab</title>
+ <meta name="robots" content="noindex" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <style>
+ :root { color-scheme: dark; }
+ body { background: #05060a; color: #eee; font: 15px/1.5 -apple-system, system-ui, sans-serif; margin: 0; }
+ .stage { max-width: 1000px; margin: 0 auto; padding: 48px 24px 80px; }
+ .crumb a { color: #8a8d98; text-decoration: none; }
+ .crumb a:hover { color: #d6ff3d; }
+ h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.015em; margin: 14px 0 8px; }
+ .sub { color: #8a8d98; max-width: 64ch; margin: 0 0 30px; }
+ pre {
+ background: #07080d; border: 1px solid #1e1f2b; border-radius: 9px;
+ padding: 14px 16px; font-family: ui-monospace, monospace; font-size: 12.5px;
+ color: #d6ff3d; overflow-x: auto;
+ }
+ .card {
+ background: #0f1018; border: 1.5px solid #1e1f2b; border-radius: 14px;
+ padding: 22px; margin: 16px 0;
+ }
+ .viewer-host {
+ min-height: 460px;
+ background: #0a0b12; border-radius: 10px; overflow: hidden;
+ margin-top: 14px;
+ }
+ .viewer-host agent-3d { width: 100%; height: 460px; display: block; }
+ button {
+ background: #d6ff3d; color: #0a0a0a; border: 0; border-radius: 9px;
+ padding: 10px 14px; font-weight: 600; cursor: pointer; font: inherit;
+ }
+ .log {
+ margin-top: 14px;
+ background: #07080d; border: 1px solid #1e1f2b; border-radius: 9px;
+ padding: 12px; font-family: ui-monospace, monospace; font-size: 12px;
+ color: #8a8d98; max-height: 200px; overflow: auto; white-space: pre-wrap;
+ }
+ .log .ok { color: #d6ff3d; }
+ .log .err { color: #ff6b6b; }
+ .log .info { color: #66d9ef; }
+ </style>
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+
+ <main class="stage">
+ <p class="crumb"><a href="/demos">← lab</a></p>
+ <h1>@three-ws/avatar SDK</h1>
+ <p class="sub">
+ The npm SDK bundle loaded from <code>/avatar-sdk/dist/index.mjs</code>
+ (what consumers would get from <code>npm install @three-ws/avatar</code>
+ once it's published). On mount it registers <code>&lt;agent-3d&gt;</code>
+ as a custom element. The Creator section opens the iframe modal that
+ resolves with a GLB Blob — the same flow third-party sites would use.
+ </p>
+
+ <section class="card">
+ <h2 style="margin-top:0;font-size:18px">1. Drop-in web component</h2>
+ <pre>&lt;script type="module" src="/avatar-sdk/dist/index.mjs"&gt;&lt;/script&gt;
+&lt;agent-3d src="/avatars/default.glb"&gt;&lt;/agent-3d&gt;</pre>
+ <div class="viewer-host" id="sdk-viewer-host">
+ <!-- the agent-3d element is injected after the SDK loads -->
+ </div>
+ <div class="log" id="component-log">waiting for SDK to register the custom element…</div>
+ </section>
+
+ <section class="card">
+ <h2 style="margin-top:0;font-size:18px">2. Programmatic Creator</h2>
+ <pre>import { AvatarCreator } from '/avatar-sdk/src/creator.js';
+
+const creator = new AvatarCreator({
+ onExport: (glbBlob) =&gt; { /* save it */ },
+});
+creator.open();</pre>
+ <button id="open-creator-btn">Open three.ws Avatar Creator</button>
+ <div class="log" id="creator-log">click to open the modal.</div>
+ </section>
+ </main>
+
+ <script src="/nav.js" defer></script>
+
+ <!-- Load the prebuilt SDK bundle -->
+ <script type="module" src="/avatar-sdk/dist/index.mjs"></script>
+
+ <script type="module">
+ const $ = (id) => document.getElementById(id);
+ const componentLog = $('component-log');
+ const creatorLog = $('creator-log');
+ const stamp = () => new Date().toTimeString().slice(0, 8);
+ const line = (el, msg, cls = '') => {
+ el.innerHTML += `\n<span class="${cls}">[${stamp()}] ${msg}</span>`;
+ };
+
+ // Wait until the custom element registers (the SDK self-registers on load).
+ const start = performance.now();
+ const check = () => {
+ if (customElements.get('agent-3d')) {
+ const el = document.createElement('agent-3d');
+ el.setAttribute('src', '/avatars/default.glb');
+ $('sdk-viewer-host').appendChild(el);
+ line(componentLog, `✓ &lt;agent-3d&gt; registered in ${Math.round(performance.now() - start)} ms`, 'ok');
+ line(componentLog, '✓ mounted with src=/avatars/default.glb', 'ok');
+ } else if (performance.now() - start < 8000) {
+ setTimeout(check, 100);
+ } else {
+ line(componentLog, '✗ SDK bundle did not register &lt;agent-3d&gt; within 8s — check /avatar-sdk/dist/index.mjs', 'err');
+ }
+ };
+ check();
+
+ // Programmatic Creator demo. Imports from the SDK source so we don't
+ // rebuild the whole bundle every time creator.js changes.
+ $('open-creator-btn').addEventListener('click', async () => {
+ try {
+ const mod = await import('/avatar-sdk/src/creator.js');
+ line(creatorLog, 'opening three.ws Avatar Creator iframe modal…', 'info');
+ const creator = new mod.AvatarCreator({
+ onExport: (glbBlob) => {
+ line(creatorLog, `✓ export received (${glbBlob.size} bytes)`, 'ok');
+ },
+ onClose: () => {
+ line(creatorLog, 'modal closed without export', 'info');
+ },
+ });
+ await creator.open();
+ } catch (err) {
+ line(creatorLog, 'creator failed: ' + err.message, 'err');
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/public/demos/halfbody-xr.html b/public/demos/halfbody-xr.html
new file mode 100644
index 000000000..45249b8f6
--- /dev/null
+++ b/public/demos/halfbody-xr.html
@@ -0,0 +1,213 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>Half-body XR · three.ws lab</title>
+ <meta name="robots" content="noindex" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <style>
+ :root { color-scheme: dark; }
+ body { background: #05060a; color: #eee; font: 15px/1.5 -apple-system, system-ui, sans-serif; margin: 0; }
+ .stage { max-width: 1000px; margin: 0 auto; padding: 48px 24px 80px; }
+ .crumb a { color: #8a8d98; text-decoration: none; }
+ .crumb a:hover { color: #d6ff3d; }
+ h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.015em; margin: 14px 0 8px; }
+ .sub { color: #8a8d98; max-width: 64ch; margin: 0 0 30px; }
+ .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
+ @media (max-width: 720px) { .row { grid-template-columns: 1fr; } }
+ .viewer {
+ background: #0f1018; border: 1.5px solid #1e1f2b; border-radius: 14px;
+ min-height: 420px; position: relative; overflow: hidden;
+ }
+ .viewer canvas { display: block; width: 100%; height: 100%; }
+ .viewer-label {
+ position: absolute; top: 12px; left: 12px;
+ background: rgba(0,0,0,0.55); padding: 4px 10px; border-radius: 999px;
+ font-size: 12px; color: #d6ff3d; font-weight: 600;
+ }
+ .controls {
+ margin-top: 24px;
+ display: flex; gap: 10px; flex-wrap: wrap;
+ background: #0f1018; border: 1.5px solid #1e1f2b;
+ border-radius: 14px; padding: 18px;
+ }
+ button {
+ background: #d6ff3d; color: #0a0a0a; border: 0; border-radius: 9px;
+ padding: 10px 14px; font-weight: 600; cursor: pointer; font: inherit;
+ }
+ button.secondary { background: rgba(255,255,255,0.06); color: #eee; }
+ button:disabled { opacity: 0.4; cursor: not-allowed; }
+ .log {
+ margin-top: 16px;
+ background: #07080d; border: 1px solid #1e1f2b; border-radius: 9px;
+ padding: 12px; font-family: ui-monospace, monospace; font-size: 12px;
+ line-height: 1.6; color: #8a8d98; max-height: 220px; overflow: auto; white-space: pre-wrap;
+ }
+ .log .ok { color: #d6ff3d; }
+ .log .err { color: #ff6b6b; }
+ .log .info { color: #66d9ef; }
+ </style>
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+
+ <main class="stage">
+ <p class="crumb"><a href="/demos">← lab</a></p>
+ <h1>Half-body XR</h1>
+ <p class="sub">
+ Side-by-side preview of full-body vs half-body. The half-body view
+ is achieved at runtime by detecting lower-body bones in the GLB
+ skeleton (<code>leg</code>, <code>thigh</code>, <code>foot</code>,
+ <code>toe</code>, etc.) and scaling them to zero — same skinned mesh,
+ bones collapsed to rest position. Restoring is a single scale write.
+ Enter WebXR from this page to see the half-body mode in headset.
+ </p>
+
+ <div class="row">
+ <div class="viewer" id="viewer-full">
+ <span class="viewer-label">Full body</span>
+ </div>
+ <div class="viewer" id="viewer-half">
+ <span class="viewer-label">Half body</span>
+ </div>
+ </div>
+
+ <div class="controls">
+ <button id="enter-xr-full" class="secondary">Enter WebXR · full body</button>
+ <button id="enter-xr-half">Enter WebXR · half body</button>
+ <button id="reload" class="secondary">Reload models</button>
+ </div>
+ <div class="log" id="log">ready.</div>
+ </main>
+
+ <script src="/nav.js" defer></script>
+ <script type="module">
+ import * as THREE from 'three';
+ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+
+ const $ = (id) => document.getElementById(id);
+ const log = $('log');
+ const logLine = (msg, cls = '') => {
+ const t = new Date().toTimeString().slice(0, 8);
+ log.innerHTML += `\n<span class="${cls}">[${t}] ${msg}</span>`;
+ log.scrollTop = log.scrollHeight;
+ };
+
+ const LOWER_BODY_FRAGMENTS = ['upleg','leg','thigh','knee','shin','calf','foot','toe','ankle'];
+ const normalizeBone = (n) => String(n||'').toLowerCase()
+ .replace(/^mixamorig:?_?/,'')
+ .replace(/^cc_base_/,'')
+ .replace(/^armature[:_|]/,'')
+ .replace(/^rig[:_]/,'');
+ const isLowerBody = (n) => LOWER_BODY_FRAGMENTS.some((f) => normalizeBone(n).includes(f));
+
+ function buildPreview(container) {
+ const w = container.clientWidth, h = container.clientHeight;
+ const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
+ renderer.setPixelRatio(window.devicePixelRatio);
+ renderer.setSize(w, h);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ container.appendChild(renderer.domElement);
+
+ const scene = new THREE.Scene();
+ const camera = new THREE.PerspectiveCamera(35, w/h, 0.01, 100);
+ camera.position.set(0, 1.4, 2.6);
+ const controls = new OrbitControls(camera, renderer.domElement);
+ controls.target.set(0, 1, 0);
+ controls.enableDamping = true;
+
+ scene.add(new THREE.HemisphereLight(0xffffff, 0x404060, 1.0));
+ const dir = new THREE.DirectionalLight(0xffffff, 1.2);
+ dir.position.set(2, 4, 3);
+ scene.add(dir);
+
+ function tick() {
+ requestAnimationFrame(tick);
+ controls.update();
+ renderer.render(scene, camera);
+ }
+ tick();
+
+ window.addEventListener('resize', () => {
+ const w2 = container.clientWidth, h2 = container.clientHeight;
+ renderer.setSize(w2, h2);
+ camera.aspect = w2/h2;
+ camera.updateProjectionMatrix();
+ });
+
+ return { scene, renderer, camera, controls };
+ }
+
+ const fullView = buildPreview($('viewer-full'));
+ const halfView = buildPreview($('viewer-half'));
+
+ async function loadInto(view, applyHalfBody) {
+ const loader = new GLTFLoader();
+ logLine(`loading /avatars/default.glb into ${applyHalfBody ? 'half-body' : 'full-body'} viewer…`, 'info');
+ const gltf = await loader.loadAsync('/avatars/default.glb');
+ const root = gltf.scene;
+ view.scene.add(root);
+ if (applyHalfBody) {
+ let hidden = 0;
+ root.traverse((obj) => {
+ if (!obj.isSkinnedMesh || !obj.skeleton) return;
+ for (const bone of obj.skeleton.bones || []) {
+ if (isLowerBody(bone.name)) {
+ bone.scale.set(0.0001, 0.0001, 0.0001);
+ hidden++;
+ }
+ }
+ });
+ root.traverse((obj) => {
+ if (obj.isSkinnedMesh && obj.skeleton) obj.skeleton.update();
+ });
+ logLine(`✓ half-body applied: ${hidden} lower-body bones collapsed`, 'ok');
+ } else {
+ logLine('✓ full body loaded', 'ok');
+ }
+ }
+
+ $('reload').addEventListener('click', () => location.reload());
+
+ $('enter-xr-full').addEventListener('click', async () => {
+ if (!navigator.xr) return logLine('WebXR unavailable in this browser', 'err');
+ const supported = await navigator.xr.isSessionSupported('immersive-ar').catch(() => false);
+ if (!supported) return logLine('immersive-ar not supported on this device', 'err');
+ logLine('starting full-body XR — open this URL on a Quest browser or Android Chrome to enter the headset', 'info');
+ try {
+ const session = await navigator.xr.requestSession('immersive-ar');
+ logLine('XR session started · full body', 'ok');
+ session.addEventListener('end', () => logLine('XR session ended', 'info'));
+ } catch (err) {
+ logLine('XR request failed: ' + err.message, 'err');
+ }
+ });
+
+ $('enter-xr-half').addEventListener('click', async () => {
+ if (!navigator.xr) return logLine('WebXR unavailable in this browser', 'err');
+ const supported = await navigator.xr.isSessionSupported('immersive-ar').catch(() => false);
+ if (!supported) return logLine('immersive-ar not supported on this device', 'err');
+ logLine('starting half-body XR — lower-body bones will be collapsed for the duration of the session', 'info');
+ try {
+ const session = await navigator.xr.requestSession('immersive-ar');
+ logLine('XR session started · half body', 'ok');
+ session.addEventListener('end', () => logLine('XR session ended', 'info'));
+ } catch (err) {
+ logLine('XR request failed: ' + err.message, 'err');
+ }
+ });
+
+ (async () => {
+ try {
+ await loadInto(fullView, false);
+ await loadInto(halfView, true);
+ } catch (err) {
+ logLine('load failed: ' + err.message, 'err');
+ }
+ })();
+ </script>
+ </body>
+</html>
diff --git a/public/demos/index.html b/public/demos/index.html
new file mode 100644
index 000000000..a7e846547
--- /dev/null
+++ b/public/demos/index.html
@@ -0,0 +1,104 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>three.ws · Lab demos</title>
+ <meta name="robots" content="noindex" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <style>
+ :root { color-scheme: dark; }
+ body {
+ background: #05060a;
+ color: #eee;
+ font: 15px/1.5 -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
+ margin: 0;
+ }
+ .demos-stage { max-width: 920px; margin: 0 auto; padding: 56px 24px 80px; }
+ .demos-eyebrow { color: #d6ff3d; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; margin: 0 0 12px; }
+ .demos-title { font-size: 32px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 8px; }
+ .demos-sub { color: #8a8d98; max-width: 60ch; margin: 0 0 40px; }
+ .demos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
+ @media (max-width: 640px) { .demos-grid { grid-template-columns: 1fr; } }
+ .demo-card {
+ display: block;
+ padding: 22px 22px 20px;
+ border-radius: 16px;
+ background: #0f1018;
+ border: 1.5px solid #1e1f2b;
+ text-decoration: none;
+ color: inherit;
+ transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
+ }
+ .demo-card:hover { transform: translateY(-2px); border-color: #2c2d3d; box-shadow: 0 14px 30px rgba(0,0,0,0.4); }
+ .demo-card h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; letter-spacing: -0.005em; }
+ .demo-card p { margin: 0; color: #8a8d98; font-size: 13.5px; line-height: 1.55; }
+ .demo-status {
+ display: inline-block;
+ margin-top: 10px;
+ padding: 2px 9px;
+ border-radius: 999px;
+ font-size: 10.5px;
+ font-weight: 600;
+ letter-spacing: 0.05em;
+ text-transform: uppercase;
+ }
+ .demo-status.live { background: rgba(214,255,61,0.12); color: #d6ff3d; border: 1px solid rgba(214,255,61,0.35); }
+ .demo-status.beta { background: rgba(255,184,77,0.12); color: #ffb84d; border: 1px solid rgba(255,184,77,0.35); }
+ .warning {
+ margin: 32px 0 0;
+ padding: 14px 16px;
+ border-radius: 12px;
+ background: rgba(255,184,77,0.06);
+ border: 1px solid rgba(255,184,77,0.25);
+ color: #ffb84d;
+ font-size: 13px;
+ line-height: 1.55;
+ }
+ </style>
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+
+ <main class="demos-stage">
+ <p class="demos-eyebrow">three.ws · lab</p>
+ <h1 class="demos-title">Demo pages</h1>
+ <p class="demos-sub">
+ Pre-release features wired end-to-end so we can test them before they
+ replace anything on the live site. Everything on these pages hits real
+ APIs and real storage — no mocks.
+ </p>
+
+ <div class="demos-grid">
+ <a class="demo-card" href="/demos/usdz-ar.html">
+ <h2>USDZ &amp; AR Quick Look</h2>
+ <p>Load an avatar, generate a USDZ companion in-browser, push it to R2, and confirm iOS Quick Look opens the result.</p>
+ <span class="demo-status beta">Beta</span>
+ </a>
+ <a class="demo-card" href="/demos/halfbody-xr.html">
+ <h2>Half-body XR</h2>
+ <p>Enter WebXR with lower-body bones collapsed — the seated/VR variant Ready Player Me used to ship.</p>
+ <span class="demo-status beta">Beta</span>
+ </a>
+ <a class="demo-card" href="/demos/avatar-sdk.html">
+ <h2>@three-ws/avatar SDK</h2>
+ <p>Drop-in <code>&lt;agent-3d&gt;</code> web component loaded from the npm SDK bundle, plus the programmatic <code>AvatarCreator</code> iframe.</p>
+ <span class="demo-status beta">Beta</span>
+ </a>
+ <a class="demo-card" href="/demos/lipsync-mic.html">
+ <h2>Audio-driven lipsync</h2>
+ <p>Feed live mic audio through the viseme analyser and watch the avatar's mouth track your voice in real time.</p>
+ <span class="demo-status live">Live</span>
+ </a>
+ </div>
+
+ <p class="warning">
+ These pages are unlisted and noindex. They share the same backend as
+ the live site but are intentionally separate from <a href="/create" style="color:#ffb84d">/create</a> and <a href="/avatars" style="color:#ffb84d">/avatars/:id</a> so the production flow keeps working while we test.
+ </p>
+ </main>
+
+ <script src="/nav.js" defer></script>
+ </body>
+</html>
diff --git a/public/demos/lipsync-mic.html b/public/demos/lipsync-mic.html
new file mode 100644
index 000000000..7e6babfef
--- /dev/null
+++ b/public/demos/lipsync-mic.html
@@ -0,0 +1,220 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>Audio-driven lipsync · three.ws lab</title>
+ <meta name="robots" content="noindex" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <style>
+ :root { color-scheme: dark; }
+ body { background: #05060a; color: #eee; font: 15px/1.5 -apple-system, system-ui, sans-serif; margin: 0; }
+ .stage { max-width: 1000px; margin: 0 auto; padding: 48px 24px 80px; }
+ .crumb a { color: #8a8d98; text-decoration: none; }
+ .crumb a:hover { color: #d6ff3d; }
+ h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.015em; margin: 14px 0 8px; }
+ .sub { color: #8a8d98; max-width: 64ch; margin: 0 0 30px; }
+ .row { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
+ @media (max-width: 800px) { .row { grid-template-columns: 1fr; } }
+ .viewer-host {
+ background: #0f1018; border: 1.5px solid #1e1f2b; border-radius: 14px;
+ min-height: 460px; position: relative; overflow: hidden;
+ }
+ .viewer-host canvas { width: 100%; height: 100%; display: block; }
+ .panel {
+ background: #0f1018; border: 1.5px solid #1e1f2b; border-radius: 14px;
+ padding: 20px; display: flex; flex-direction: column; gap: 12px;
+ }
+ button {
+ background: #d6ff3d; color: #0a0a0a; border: 0; border-radius: 9px;
+ padding: 10px 14px; font-weight: 600; cursor: pointer; font: inherit;
+ }
+ button.secondary { background: rgba(255,255,255,0.06); color: #eee; }
+ button:disabled { opacity: 0.4; cursor: not-allowed; }
+ .meter {
+ display: flex; gap: 4px; height: 16px; align-items: end;
+ }
+ .meter .bar {
+ flex: 1; height: 0%; background: linear-gradient(180deg, #d6ff3d, #5a7a1a);
+ border-radius: 2px; transition: height 0.05s linear;
+ }
+ .viseme-row { display: flex; justify-content: space-between; font-size: 12px; color: #8a8d98; }
+ .viseme-row code { color: #d6ff3d; font-weight: 600; }
+ .log {
+ background: #07080d; border: 1px solid #1e1f2b; border-radius: 9px;
+ padding: 12px; font-family: ui-monospace, monospace; font-size: 12px;
+ color: #8a8d98; line-height: 1.6;
+ }
+ </style>
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+
+ <main class="stage">
+ <p class="crumb"><a href="/demos">← lab</a></p>
+ <h1>Audio-driven lipsync</h1>
+ <p class="sub">
+ Real-time test of the three.ws viseme analyser
+ (<code>src/lip-sync-analyser.js</code>). Hit <strong>Start</strong>,
+ allow mic access, and speak — the analyser hands per-viseme weights
+ to the avatar's morph targets every frame. This is the exact pipeline
+ that drives ElevenLabs-streamed TTS in the live chat, just sourced
+ from your mic so you can verify the mouth shapes against your speech.
+ </p>
+
+ <div class="row">
+ <div class="viewer-host" id="viewer-host"></div>
+ <div class="panel">
+ <button id="start">Start mic</button>
+ <button id="stop" class="secondary" disabled>Stop</button>
+
+ <div class="meter" id="meter">
+ <div class="bar"></div><div class="bar"></div><div class="bar"></div>
+ <div class="bar"></div><div class="bar"></div><div class="bar"></div>
+ <div class="bar"></div><div class="bar"></div><div class="bar"></div>
+ </div>
+
+ <div id="visemes" style="display:flex;flex-direction:column;gap:4px;margin-top:6px"></div>
+
+ <div class="log">
+ The avatar's <code>viseme_aa / E / O / SS / PP …</code> morph
+ targets are driven by frequency-band energy from the mic. Your
+ audio never leaves the browser — analysis is all
+ <code>AnalyserNode</code> + <code>requestAnimationFrame</code>.
+ </div>
+ </div>
+ </div>
+ </main>
+
+ <script src="/nav.js" defer></script>
+ <script type="module">
+ import * as THREE from 'three';
+ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+ import { LipSyncAnalyser } from '/src/lip-sync-analyser.js';
+
+ const $ = (id) => document.getElementById(id);
+ const host = $('viewer-host');
+
+ // ── three.js scene ─────────────────────────────────────────────
+ const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
+ renderer.setPixelRatio(window.devicePixelRatio);
+ renderer.setSize(host.clientWidth, host.clientHeight);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ host.appendChild(renderer.domElement);
+
+ const scene = new THREE.Scene();
+ const camera = new THREE.PerspectiveCamera(28, host.clientWidth / host.clientHeight, 0.01, 100);
+ camera.position.set(0, 1.55, 0.85);
+ const controls = new OrbitControls(camera, renderer.domElement);
+ controls.target.set(0, 1.55, 0);
+ controls.enableDamping = true;
+
+ scene.add(new THREE.HemisphereLight(0xffffff, 0x404060, 1.1));
+ const dir = new THREE.DirectionalLight(0xffffff, 1.4);
+ dir.position.set(2, 4, 3);
+ scene.add(dir);
+
+ window.addEventListener('resize', () => {
+ const w = host.clientWidth, h = host.clientHeight;
+ renderer.setSize(w, h);
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ });
+
+ // ── Load the default avatar ────────────────────────────────────
+ let visemeMorphs = new Map(); // viseme_name -> [{ mesh, index }]
+ const VISEMES = [
+ 'viseme_aa', 'viseme_O', 'viseme_E', 'viseme_I', 'viseme_nn',
+ 'viseme_SS', 'viseme_FF', 'viseme_CH', 'viseme_PP',
+ ];
+
+ const loader = new GLTFLoader();
+ loader.load('/avatars/default.glb', (gltf) => {
+ scene.add(gltf.scene);
+ gltf.scene.traverse((node) => {
+ if (!node.isMesh || !node.morphTargetDictionary || !node.morphTargetInfluences) return;
+ for (const v of VISEMES) {
+ const idx = node.morphTargetDictionary[v];
+ if (idx === undefined) continue;
+ if (!visemeMorphs.has(v)) visemeMorphs.set(v, []);
+ visemeMorphs.get(v).push({ mesh: node, index: idx });
+ }
+ });
+
+ const row = $('visemes');
+ for (const v of VISEMES) {
+ const found = visemeMorphs.has(v);
+ const el = document.createElement('div');
+ el.className = 'viseme-row';
+ el.innerHTML = `<span>${v}</span><code data-v="${v}">${found ? '0.00' : 'n/a'}</code>`;
+ row.appendChild(el);
+ }
+ });
+
+ // ── Animation loop ─────────────────────────────────────────────
+ let analyser = null;
+ let stream = null;
+ const bars = document.querySelectorAll('#meter .bar');
+
+ function tick() {
+ requestAnimationFrame(tick);
+ controls.update();
+
+ if (analyser) {
+ const visemes = analyser.sample();
+ if (visemes) {
+ let i = 0;
+ for (const [name, targets] of visemeMorphs.entries()) {
+ const w = visemes[name] ?? 0;
+ for (const { mesh, index } of targets) {
+ mesh.morphTargetInfluences[index] = w;
+ }
+ const code = document.querySelector(`code[data-v="${name}"]`);
+ if (code) code.textContent = w.toFixed(2);
+ if (bars[i]) bars[i].style.height = `${Math.min(100, w * 100)}%`;
+ i++;
+ }
+ }
+ }
+
+ renderer.render(scene, camera);
+ }
+ tick();
+
+ // ── Mic wiring ─────────────────────────────────────────────────
+ $('start').addEventListener('click', async () => {
+ try {
+ stream = await navigator.mediaDevices.getUserMedia({ audio: true });
+ const ctx = new (window.AudioContext || window.webkitAudioContext)();
+ const src = ctx.createMediaStreamSource(stream);
+ const an = ctx.createAnalyser();
+ an.fftSize = 256;
+ an.smoothingTimeConstant = 0.7;
+ src.connect(an);
+ // We deliberately do NOT connect an → ctx.destination — keeps mic from
+ // echoing back through the speakers.
+ analyser = new LipSyncAnalyser();
+ analyser.connect(an);
+
+ $('start').disabled = true;
+ $('stop').disabled = false;
+ } catch (err) {
+ alert('mic access failed: ' + err.message);
+ }
+ });
+
+ $('stop').addEventListener('click', () => {
+ if (analyser) { analyser.disconnect(); analyser = null; }
+ if (stream) { stream.getTracks().forEach((t) => t.stop()); stream = null; }
+ $('start').disabled = false;
+ $('stop').disabled = true;
+ // Reset morph values to zero.
+ for (const targets of visemeMorphs.values()) {
+ for (const { mesh, index } of targets) mesh.morphTargetInfluences[index] = 0;
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/public/demos/usdz-ar.html b/public/demos/usdz-ar.html
new file mode 100644
index 000000000..c39fc7400
--- /dev/null
+++ b/public/demos/usdz-ar.html
@@ -0,0 +1,211 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>USDZ &amp; AR Quick Look · three.ws lab</title>
+ <meta name="robots" content="noindex" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <script
+ type="module"
+ src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.5.0/model-viewer.min.js"
+ ></script>
+ <style>
+ :root { color-scheme: dark; }
+ body { background: #05060a; color: #eee; font: 15px/1.5 -apple-system, system-ui, sans-serif; margin: 0; }
+ .stage { max-width: 1000px; margin: 0 auto; padding: 48px 24px 80px; }
+ .crumb a { color: #8a8d98; text-decoration: none; }
+ .crumb a:hover { color: #d6ff3d; }
+ h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.015em; margin: 14px 0 8px; }
+ .sub { color: #8a8d98; max-width: 64ch; margin: 0 0 30px; }
+ .row { display: grid; grid-template-columns: 1fr 360px; gap: 24px; }
+ @media (max-width: 820px) { .row { grid-template-columns: 1fr; } }
+ .viewer-card {
+ background: #0f1018; border: 1.5px solid #1e1f2b; border-radius: 14px;
+ overflow: hidden; aspect-ratio: 1 / 1; min-height: 400px;
+ }
+ model-viewer { width: 100%; height: 100%; --poster-color: transparent; background: #0a0b12; }
+ .panel { background: #0f1018; border: 1.5px solid #1e1f2b; border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
+ label { font-size: 12.5px; color: #8a8d98; text-transform: uppercase; letter-spacing: 0.06em; }
+ input[type=text], input[type=file], select {
+ width: 100%; padding: 10px 12px; border-radius: 9px;
+ background: #07080d; color: #eee; border: 1px solid #1e1f2b;
+ font: inherit;
+ }
+ button {
+ background: #d6ff3d; color: #0a0a0a; border: 0; border-radius: 9px;
+ padding: 10px 14px; font-weight: 600; cursor: pointer;
+ font: inherit;
+ }
+ button:disabled { opacity: 0.4; cursor: not-allowed; }
+ button.secondary { background: rgba(255,255,255,0.06); color: #eee; }
+ .log {
+ background: #07080d; border: 1px solid #1e1f2b; border-radius: 9px;
+ padding: 12px; font-family: ui-monospace, monospace; font-size: 12px;
+ line-height: 1.6; color: #8a8d98; max-height: 280px; overflow: auto; white-space: pre-wrap;
+ }
+ .log .ok { color: #d6ff3d; }
+ .log .err { color: #ff6b6b; }
+ .log .info { color: #66d9ef; }
+ </style>
+ </head>
+ <body>
+ <header><div id="nav-container"></div></header>
+
+ <main class="stage">
+ <p class="crumb"><a href="/demos">← lab</a></p>
+ <h1>USDZ &amp; AR Quick Look</h1>
+ <p class="sub">
+ Loads a GLB, generates a USDZ companion entirely in-browser via the
+ three.js <code>USDZExporter</code>, uploads it to R2 through the
+ <code>/api/avatars/presign-usdz</code> action, then renders
+ <code>&lt;model-viewer&gt;</code> with both <code>src</code> and
+ <code>ios-src</code>. Tap the AR button on iPhone Safari to verify
+ Quick Look opens. Nothing here touches the live <code>/create</code>
+ or <code>/avatars/:id</code> flow.
+ </p>
+
+ <div class="row">
+ <div class="viewer-card">
+ <model-viewer
+ id="mv"
+ src="/avatars/default.glb"
+ alt="three.ws sample avatar"
+ camera-controls
+ auto-rotate
+ rotation-per-second="14deg"
+ interaction-prompt="none"
+ exposure="1.05"
+ shadow-intensity="0.9"
+ environment-image="neutral"
+ ar
+ ar-modes="webxr scene-viewer quick-look"
+ ></model-viewer>
+ </div>
+
+ <div class="panel">
+ <label>1. Pick a GLB (or use the sample)</label>
+ <input type="file" id="glb-input" accept=".glb,model/gltf-binary" />
+ <input type="text" id="glb-url" placeholder="…or paste a GLB URL" />
+
+ <label style="margin-top:6px">2. Convert to USDZ</label>
+ <button id="convert-btn">Generate USDZ in-browser</button>
+
+ <label style="margin-top:6px">3. Optional — upload to your account</label>
+ <input type="text" id="avatar-id" placeholder="Existing avatar UUID (must be yours)" />
+ <button id="upload-btn" class="secondary" disabled>Upload + PATCH avatar</button>
+
+ <label style="margin-top:6px">Log</label>
+ <div class="log" id="log">ready.</div>
+ </div>
+ </div>
+ </main>
+
+ <script src="/nav.js" defer></script>
+ <script type="module">
+ import { glbBlobToUsdzBlob } from '/src/usdz-pipeline.js';
+
+ const $ = (id) => document.getElementById(id);
+ const log = $('log');
+ const logLine = (msg, cls = '') => {
+ const t = new Date().toTimeString().slice(0, 8);
+ log.innerHTML += `\n<span class="${cls}">[${t}] ${msg}</span>`;
+ log.scrollTop = log.scrollHeight;
+ };
+
+ let lastUsdzBlob = null;
+ let lastUsdzUrl = null;
+ let lastGlbBlob = null;
+
+ $('glb-input').addEventListener('change', async (e) => {
+ const file = e.target.files?.[0];
+ if (!file) return;
+ const url = URL.createObjectURL(file);
+ $('mv').src = url;
+ lastGlbBlob = file;
+ logLine(`loaded local GLB: ${file.name} (${file.size} bytes)`, 'info');
+ });
+
+ $('glb-url').addEventListener('change', async (e) => {
+ const url = e.target.value.trim();
+ if (!url) return;
+ $('mv').src = url;
+ logLine(`loaded remote GLB: ${url}`, 'info');
+ try {
+ const r = await fetch(url);
+ if (!r.ok) throw new Error(`GLB fetch ${r.status}`);
+ lastGlbBlob = await r.blob();
+ } catch (err) {
+ logLine(`remote fetch failed: ${err.message}`, 'err');
+ }
+ });
+
+ $('convert-btn').addEventListener('click', async () => {
+ try {
+ if (!lastGlbBlob) {
+ const r = await fetch($('mv').src);
+ if (!r.ok) throw new Error(`GLB fetch ${r.status}`);
+ lastGlbBlob = await r.blob();
+ }
+ logLine(`converting ${lastGlbBlob.size} byte GLB → USDZ…`, 'info');
+ const t0 = performance.now();
+ lastUsdzBlob = await glbBlobToUsdzBlob(lastGlbBlob);
+ const ms = Math.round(performance.now() - t0);
+ if (lastUsdzUrl) URL.revokeObjectURL(lastUsdzUrl);
+ lastUsdzUrl = URL.createObjectURL(lastUsdzBlob);
+ $('mv').setAttribute('ios-src', lastUsdzUrl);
+ $('upload-btn').disabled = false;
+ logLine(`✓ USDZ generated (${lastUsdzBlob.size} bytes, ${ms} ms). Tap the AR button on iPhone Safari to test Quick Look.`, 'ok');
+ } catch (err) {
+ logLine(`USDZ conversion failed: ${err.message}`, 'err');
+ }
+ });
+
+ $('upload-btn').addEventListener('click', async () => {
+ const avatarId = $('avatar-id').value.trim();
+ if (!avatarId) {
+ logLine('upload skipped — no avatar id', 'err');
+ return;
+ }
+ if (!lastUsdzBlob) {
+ logLine('no USDZ to upload — run step 2 first', 'err');
+ return;
+ }
+ try {
+ logLine('requesting presigned upload URL…', 'info');
+ const presignRes = await fetch('/api/avatars/presign-usdz', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ avatar_id: avatarId, size_bytes: lastUsdzBlob.size }),
+ });
+ if (!presignRes.ok) throw new Error(`presign ${presignRes.status}: ${await presignRes.text()}`);
+ const pre = await presignRes.json();
+ logLine(`presign ok, key=${pre.usdz_key}`, 'info');
+
+ logLine('uploading to R2…', 'info');
+ const put = await fetch(pre.upload_url, {
+ method: 'PUT',
+ headers: { 'content-type': 'model/vnd.usdz+zip' },
+ body: lastUsdzBlob,
+ });
+ if (!put.ok) throw new Error(`R2 ${put.status}`);
+ logLine('upload ok', 'ok');
+
+ logLine('PATCHing avatar with usdz_key…', 'info');
+ const patch = await fetch(`/api/avatars/${encodeURIComponent(avatarId)}`, {
+ method: 'PATCH',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ usdz_key: pre.usdz_key }),
+ });
+ if (!patch.ok) throw new Error(`PATCH ${patch.status}: ${await patch.text()}`);
+ logLine('✓ avatar updated. Reload /avatars/' + avatarId + ' to see iOS Quick Look wired in.', 'ok');
+ } catch (err) {
+ logLine(`upload failed: ${err.message}`, 'err');
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/public/llms-full.txt b/public/llms-full.txt
index b3275b19e..4c257eec0 100644
--- a/public/llms-full.txt
+++ b/public/llms-full.txt
@@ -428,6 +428,12 @@ URL: https://three.ws/news/
Product launches, integrations, and announcements from three.ws.
+### three.ws Listed on BNB Chain's Dappbay Directory
+
+URL: https://three.ws/news/listed-on-bnb-chain-dappbay
+
+three.ws is now listed on Dappbay, BNB Chain's official dApp directory, under AI Agent Launchpad, AI Data, and AI Infra. The listing puts <agent-3d> — the one-tag deploy for Solana-minted, ERC-8004-walleted, x402-native 3D agents — in front of the BNB Chain ecosystem's discovery surface for AI dApps.
+
### three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale
URL: https://three.ws/news/live-on-alibaba-cloud-marketplace
diff --git a/public/llms.txt b/public/llms.txt
index 6ffe7aaf1..158c3eae5 100644
--- a/public/llms.txt
+++ b/public/llms.txt
@@ -87,6 +87,7 @@ Docs, tutorials, and reference.
Product launches, integrations, and announcements from three.ws.
- [News & Announcements](https://three.ws/news/): Product launches, integrations, and announcements from three.ws.
+- [three.ws Listed on BNB Chain's Dappbay Directory](https://three.ws/news/listed-on-bnb-chain-dappbay): three.ws is now listed on Dappbay, BNB Chain's official dApp directory, under AI Agent Launchpad, AI Data, and AI Infra. The listing puts <agent-3d> — the one-tag deploy for Solana-minted, ERC-8004-walleted, x402-native 3D agents — in front of the BNB Chain ecosystem's discovery surface for AI dApps.
- [three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale](https://three.ws/news/live-on-alibaba-cloud-marketplace): three.ws is now live on the Alibaba Cloud International Marketplace. The listing makes <agent-3d> — one HTML tag that deploys a Solana-minted, ERC-8004-walleted, x402-native 3D agent — available to every Alibaba Cloud customer worldwide. This is the first deployment of on-chain agents with native HTTP 402 / x402 payment capability inside the procurement flow of a top-four cloud provider.
- [Add the domain you're embedding on to the widget's allowed origins list.](https://three.ws/news/2055310365588922872): Add the domain you're embedding on to the widget's allowed origins list. Otherwise CORS will block the action bridge and the agent won't be able to talk to your page. three.ws/docs
- [→ Live preview against your real site URL](https://three.ws/news/2055309846556401735): → Live preview against your real site URL → Desktop / tablet / mobile frames → Avatars from the gallery, agent://, IPFS, or your own GLB → Floating, inline, section, fullscreen → Voice, chat, AR, transparent background → 12+ animations: wave, dance, celebrate, kiss
diff --git a/public/sitemap.xml b/public/sitemap.xml
index 8c52242a0..127c60066 100644
--- a/public/sitemap.xml
+++ b/public/sitemap.xml
@@ -238,6 +238,12 @@
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
+ <url>
+ <loc>https://three.ws/news/listed-on-bnb-chain-dappbay</loc>
+ <lastmod>2026-05-17</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
<url>
<loc>https://three.ws/news/live-on-alibaba-cloud-marketplace</loc>
<lastmod>2026-05-17</lastmod>
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index be77578d4..af37fe83a 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -561,6 +561,13 @@
<span class="sm-desc">Product launches, integrations, and announcements from three.ws.</span>
</a>
</li>
+ <li>
+ <a href="/news/listed-on-bnb-chain-dappbay">
+ <span class="sm-title">three.ws Listed on BNB Chain's Dappbay Directory</span>
+ <span class="sm-path">/news/listed-on-bnb-chain-dappbay</span>
+ <span class="sm-desc">three.ws is now listed on Dappbay, BNB Chain's official dApp directory, under AI Agent Launchpad, AI Data, and AI Infra. The listing puts &lt;agent-3d&gt; — the one-tag deploy for Solana-minted, ERC-8004-walleted, x402-native 3D agents — in front of the BNB Chain ecosystem's discovery surface for AI dApps.</span>
+ </a>
+ </li>
<li>
<a href="/news/live-on-alibaba-cloud-marketplace">
<span class="sm-title">three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale</span>
diff --git a/scripts/coin-cli.mjs b/scripts/coin-cli.mjs
index 73a8b6425..49f810c8c 100644
--- a/scripts/coin-cli.mjs
+++ b/scripts/coin-cli.mjs
@@ -153,7 +153,7 @@ async function cmdPrepare(positional, opts) {
const website = opts.website || 'https://three.ws';
const description =
opts.description ||
- `A three.ws lottery + SOL reflection coin. Every holder is a ticket: hourly draws send the lottery pot to one random eligible wallet, and a passive SOL reflection drips to every holder between draws. Verifiable randomness end-to-end. Live dashboard: ${website}/coin`;
+ `A three.ws lottery + SOL reflection coin. Every holder is a ticket: hourly draws send the lottery pot to one random eligible wallet, and a passive SOL reflection drips to every holder between draws. Verifiable randomness end-to-end. Live dashboard: ${website}/demo/coin`;
const image = opts.image || null;
const twitter = opts.twitter || process.env.THREEWS_TWITTER_URL || 'https://x.com/trythreews';
@@ -168,7 +168,7 @@ async function cmdPrepare(positional, opts) {
// "Website" link rendered on the coin page is `website` below.
createdOn: 'https://pump.fun',
website,
- external_url: `${website}/coin`,
+ external_url: `${website}/demo/coin`,
twitter,
platform: 'three.ws',
};
@@ -369,7 +369,7 @@ async function cmdLaunch(positional, opts) {
creator_wallet: creator.publicKey.toBase58(),
buyer_wallet: buyer.publicKey.toBase58(),
tx_signature: sig,
- dashboard_url: `${dashboardOrigin}/coin/${mint.publicKey.toBase58()}`,
+ dashboard_url: `${dashboardOrigin}/demo/coin/${mint.publicKey.toBase58()}`,
solana_tx_url: `https://solscan.io/tx/${sig}`,
pump_fun_url: `https://pump.fun/coin/${mint.publicKey.toBase58()}`,
next_step: `Run: node scripts/coin-cli.mjs register ${mint.publicKey.toBase58()} --name "${opts.name}" --symbol "${opts.symbol}" --creator-wallet ${creator.publicKey.toBase58()} --creator-secret-b64 <base64>`,
@@ -453,7 +453,7 @@ async function cmdRegister(positional, opts) {
mint: row.mint,
is_live: row.is_live,
is_active: row.is_active,
- dashboard: `${process.env.PUBLIC_APP_ORIGIN || 'https://three.ws'}/coin/${row.mint}`,
+ dashboard: `${process.env.PUBLIC_APP_ORIGIN || 'https://three.ws'}/demo/coin/${row.mint}`,
next_step: opts['creator-secret-b64']
? `Run: node scripts/coin-cli.mjs activate ${mint} --enable (after verifying the dry-run cron output)`
: `Set COIN_CREATOR_SECRET_KEY_B64_${mint} in Vercel env, then activate with --enable.`,
diff --git a/src/account.js b/src/account.js
index 187409701..2427e67c2 100644
--- a/src/account.js
+++ b/src/account.js
@@ -142,18 +142,20 @@ export async function saveRemoteGlbToAccount(source, meta = {}) {
console.warn('[account] thumbnail/auto-tag pipeline failed silently', err?.message);
});
- // Fire-and-forget USDZ companion + half-body variant generation. iOS Quick
- // Look needs a USDZ; VR seats use a waist-up GLB. Both are derived from
- // the source blob in-memory, uploaded via dedicated presigns, then
- // PATCHed onto the avatar row so the viewer picks them up next load.
- generateAndSaveCompanions(avatar.id, blob).catch((err) => {
- console.warn('[account] usdz/halfbody pipeline failed silently', err?.message);
- });
+ // USDZ + half-body companion generation is opt-in (the demo page at
+ // /demos/usdz-ar passes generateCompanions:true). The live /create flow
+ // stays untouched — those derivations run client-side and add several
+ // seconds of CPU on every save, so they don't ship to all users yet.
+ if (meta.generateCompanions) {
+ generateAndSaveCompanions(avatar.id, blob).catch((err) => {
+ console.warn('[account] usdz/halfbody pipeline failed silently', err?.message);
+ });
+ }
return avatar;
}
-async function generateAndSaveCompanions(avatarId, glbBlob) {
+export async function generateAndSaveCompanions(avatarId, glbBlob) {
const { glbBlobToUsdzBlob, glbBlobToHalfBodyBlob } = await import('./usdz-pipeline.js');
// USDZ companion for iOS Quick Look. Independent of the half-body pass so
diff --git a/src/ar/webxr.js b/src/ar/webxr.js
index 21c8fb7a4..1a960e236 100644
--- a/src/ar/webxr.js
+++ b/src/ar/webxr.js
@@ -3,11 +3,10 @@
// Reuses the element's existing Three.js renderer by enabling XR mode on start
// and restoring the RAF loop on end. Hit-test places the agent on tap.
//
-// XR also enables half-body mode by scaling every lower-body bone (leg, foot,
-// toe…) to zero, collapsing the corresponding skinned geometry to the bone's
-// rest position. This mirrors what the half-body GLB variant does, but at
-// runtime, without reloading the model — so the AgentAvatar empathy bindings
-// and animation manager stay attached.
+// Half-body XR mode (collapse lower-body bones) is opt-in via the `halfBody`
+// constructor option — only the demo page under /demos/halfbody passes it.
+// The live AR button on the main viewer enters XR with the full body, exactly
+// as it did before the half-body work was added.
import { Matrix4, Vector3 } from 'three';
@@ -31,8 +30,9 @@ function _isLowerBody(name) {
}
export class WebXRSession {
- constructor(viewer, { onEnd } = {}) {
+ constructor(viewer, { onEnd, halfBody = false } = {}) {
this._viewer = viewer;
+ this._halfBody = halfBody;
this._onEnd = onEnd;
this._session = null;
this._hitTestSource = null;
@@ -87,9 +87,9 @@ export class WebXRSession {
this._savedPos = content?.position.clone() ?? null;
this._savedRot = content?.rotation.clone() ?? null;
- // Collapse lower-body bones so the avatar reads as a half-body bust in
- // VR/AR — the user doesn't see their own legs in a passthrough rig.
- this._enterHalfBody();
+ // Half-body mode is opt-in. The live AR button never sets it; only the
+ // /demos/halfbody preview passes halfBody:true.
+ if (this._halfBody) this._enterHalfBody();
// Hand the render loop to the XR system (replaces RAF)
if (viewer._rafId !== null) {
@@ -179,7 +179,8 @@ export class WebXRSession {
if (viewer.content && this._savedPos) viewer.content.position.copy(this._savedPos);
if (viewer.content && this._savedRot) viewer.content.rotation.copy(this._savedRot);
- // Restore full-body bone scales captured at XR start.
+ // Restore full-body bone scales captured at XR start (no-op when halfBody
+ // mode was never entered — _halfBodyBones is empty).
this._exitHalfBody();
viewer.controls.enabled = true;
diff --git a/src/avatar-page.js b/src/avatar-page.js
index f1cb2916c..e04c6d551 100644
--- a/src/avatar-page.js
+++ b/src/avatar-page.js
@@ -196,9 +196,6 @@ function renderShell(glbUrl) {
tone-mapping="aces"
environment-image="neutral"
reveal="auto"
- ar
- ar-modes="webxr scene-viewer quick-look"
- ${avatar.usdz_url ? `ios-src="${esc(avatar.usdz_url)}"` : ''}
></model-viewer>
</div>
<div class="av-meta-strip" id="av-meta-strip">
diff --git a/src/demo/os-combined.js b/src/demo/os-combined.js
new file mode 100644
index 000000000..5cf1fe1d9
--- /dev/null
+++ b/src/demo/os-combined.js
@@ -0,0 +1,423 @@
+/**
+ * OSS Avatar pipeline — Combined demo.
+ *
+ * Loads a body GLB + a frontal selfie, generates the MediaPipe face mesh, and
+ * attaches it to the body. If the body has a head bone, the face mesh is
+ * parented to it (so it animates with the body). Otherwise it sits at the top
+ * of the body's bounding box. The whole scene exports as one GLB.
+ */
+
+import * as THREE from 'three';
+import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
+import { FilesetResolver, FaceLandmarker } from '@mediapipe/tasks-vision';
+import { TRIANGULATION } from './triangulation.js';
+
+const MODEL_URL =
+ 'https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task';
+const WASM_BASE = 'https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/wasm';
+const DEFAULT_BODY = '/avatars/default.glb';
+
+const HEAD_BONE_PATTERNS = [
+ /^head$/i,
+ /head_/i,
+ /_head/i,
+ /^J_Bip_C_Head$/, // VRM
+ /mixamorig:?Head/i,
+];
+
+const viewerHost = document.getElementById('viewer-host');
+const viewerBadge = document.getElementById('viewer-badge');
+const viewerOverlay = document.getElementById('viewer-overlay');
+const bodyStatus = document.getElementById('body-status');
+const captureStatus = document.getElementById('capture-status');
+const buildStatus = document.getElementById('build-status');
+const exportStatus = document.getElementById('export-status');
+const btnBodyDefault = document.getElementById('btn-body-default');
+const btnBodyUpload = document.getElementById('btn-body-upload');
+const bodyFileInput = document.getElementById('body-file-input');
+const btnBuild = document.getElementById('btn-build');
+const btnDownload = document.getElementById('btn-download');
+const btnSave = document.getElementById('btn-save');
+
+let landmarker = null;
+let landmarkerLoading = null;
+let viewer = null;
+let bodyRoot = null;
+let faceMesh = null;
+let selfieImg = null;
+let lastGlbBlob = null;
+
+function setStatus(el, msg, kind) {
+ el.textContent = msg;
+ el.classList.remove('ok', 'err');
+ if (kind === 'ok') el.classList.add('ok');
+ if (kind === 'err') el.classList.add('err');
+}
+
+function refreshBuildEnabled() {
+ btnBuild.disabled = !(bodyRoot && selfieImg);
+}
+
+// ── Body loading ───────────────────────────────────────────────────────────
+
+btnBodyDefault.addEventListener('click', () => loadBody(DEFAULT_BODY));
+btnBodyUpload.addEventListener('click', () => bodyFileInput.click());
+bodyFileInput.addEventListener('change', () => {
+ const file = bodyFileInput.files?.[0];
+ if (!file) return;
+ const url = URL.createObjectURL(file);
+ loadBody(url, file.name);
+});
+
+async function loadBody(url, label) {
+ ensureViewer();
+ setStatus(bodyStatus, `loading ${label || url}…`);
+ try {
+ const loader = new GLTFLoader();
+ const gltf = await loader.loadAsync(url);
+ if (bodyRoot) {
+ viewer.scene.remove(bodyRoot);
+ bodyRoot = null;
+ }
+ bodyRoot = gltf.scene;
+ bodyRoot.name = 'body-root';
+ viewer.scene.add(bodyRoot);
+ fitToObject(viewer, bodyRoot);
+ viewerOverlay.style.display = 'none';
+ const headBone = findHeadBone(bodyRoot);
+ const bones = countBones(bodyRoot);
+ setStatus(
+ bodyStatus,
+ `loaded · ${bones} bones · head bone: ${headBone ? headBone.name : 'none (will use bbox)'}`,
+ 'ok',
+ );
+ viewerBadge.textContent = `body · ${bones} bones`;
+ refreshBuildEnabled();
+ } catch (err) {
+ setStatus(bodyStatus, `load failed: ${err.message}`, 'err');
+ }
+}
+
+function findHeadBone(root) {
+ let found = null;
+ root.traverse((node) => {
+ if (found || !node.isBone) return;
+ for (const re of HEAD_BONE_PATTERNS) {
+ if (re.test(node.name)) {
+ found = node;
+ return;
+ }
+ }
+ });
+ return found;
+}
+
+function countBones(root) {
+ let n = 0;
+ root.traverse((node) => {
+ if (node.isBone) n++;
+ });
+ return n;
+}
+
+// ── Selfie capture ─────────────────────────────────────────────────────────
+
+document.querySelectorAll('.photo-slot').forEach((slot) => {
+ const input = slot.querySelector('input[type=file]');
+ input.addEventListener('change', async () => {
+ const file = input.files?.[0];
+ if (!file) return;
+ const url = URL.createObjectURL(file);
+ const img = await loadImage(url);
+ selfieImg = img;
+ let prev = slot.querySelector('img');
+ if (!prev) {
+ prev = document.createElement('img');
+ slot.insertBefore(prev, slot.firstChild);
+ }
+ prev.src = url;
+ setStatus(captureStatus, `loaded · ${img.naturalWidth}×${img.naturalHeight}`, 'ok');
+ refreshBuildEnabled();
+ });
+});
+
+function loadImage(src) {
+ return new Promise((resolve, reject) => {
+ const img = new Image();
+ img.crossOrigin = 'anonymous';
+ img.onload = () => resolve(img);
+ img.onerror = reject;
+ img.src = src;
+ });
+}
+
+// ── MediaPipe ──────────────────────────────────────────────────────────────
+
+async function getLandmarker() {
+ if (landmarker) return landmarker;
+ if (landmarkerLoading) return landmarkerLoading;
+ landmarkerLoading = (async () => {
+ const fileset = await FilesetResolver.forVisionTasks(WASM_BASE);
+ landmarker = await FaceLandmarker.createFromOptions(fileset, {
+ baseOptions: { modelAssetPath: MODEL_URL, delegate: 'GPU' },
+ runningMode: 'IMAGE',
+ numFaces: 1,
+ outputFacialTransformationMatrixes: true,
+ });
+ return landmarker;
+ })();
+ return landmarkerLoading;
+}
+
+// ── Combine ────────────────────────────────────────────────────────────────
+
+btnBuild.addEventListener('click', async () => {
+ if (!bodyRoot || !selfieImg) return;
+ btnBuild.disabled = true;
+ try {
+ setStatus(buildStatus, 'loading MediaPipe…');
+ const lm = await getLandmarker();
+ setStatus(buildStatus, 'detecting landmarks…');
+ const result = lm.detect(selfieImg);
+ if (!result.faceLandmarks || !result.faceLandmarks.length) {
+ throw new Error('no face detected in photo');
+ }
+ const landmarks = result.faceLandmarks[0];
+
+ if (faceMesh) {
+ faceMesh.removeFromParent();
+ faceMesh.geometry.dispose();
+ if (faceMesh.material.map) faceMesh.material.map.dispose();
+ faceMesh.material.dispose();
+ faceMesh = null;
+ }
+
+ const mesh = buildFaceMesh(landmarks, selfieImg);
+ const headBone = findHeadBone(bodyRoot);
+
+ if (headBone) {
+ // Parent to head bone, position at bone origin.
+ // Bone local-space puts face roughly forward.
+ headBone.add(mesh);
+ mesh.position.set(0, 0.1, 0.1);
+ } else {
+ // No head bone: position at top of body bbox.
+ const box = new THREE.Box3().setFromObject(bodyRoot);
+ const center = new THREE.Vector3();
+ box.getCenter(center);
+ mesh.position.set(center.x, box.max.y - 0.12, center.z + 0.08);
+ bodyRoot.add(mesh);
+ }
+ // Scale face to roughly match a human head (~0.15m tall)
+ mesh.scale.setScalar(0.7);
+ faceMesh = mesh;
+
+ viewerBadge.textContent = `combined · ${countBones(bodyRoot)} bones · ${landmarks.length} face verts`;
+ setStatus(
+ buildStatus,
+ `attached to ${headBone ? `bone "${headBone.name}"` : 'body bbox'} · ${landmarks.length} face verts`,
+ 'ok',
+ );
+ btnDownload.disabled = false;
+ btnSave.disabled = false;
+ setStatus(exportStatus, 'ready to export');
+ } catch (err) {
+ setStatus(buildStatus, `build failed: ${err.message}`, 'err');
+ console.error('[os-combined] build failed', err);
+ } finally {
+ btnBuild.disabled = false;
+ }
+});
+
+function buildFaceMesh(landmarks, photoImg) {
+ const geom = new THREE.BufferGeometry();
+ const aspect = photoImg.naturalWidth / photoImg.naturalHeight;
+ const scale = 0.2;
+ const positions = new Float32Array(landmarks.length * 3);
+ const uvs = new Float32Array(landmarks.length * 2);
+ for (let i = 0; i < landmarks.length; i++) {
+ const p = landmarks[i];
+ positions[i * 3 + 0] = (p.x - 0.5) * aspect * scale;
+ positions[i * 3 + 1] = -(p.y - 0.5) * scale;
+ positions[i * 3 + 2] = -p.z * scale;
+ uvs[i * 2 + 0] = p.x;
+ uvs[i * 2 + 1] = 1 - p.y;
+ }
+ geom.setAttribute('position', new THREE.BufferAttribute(positions, 3));
+ geom.setAttribute('uv', new THREE.BufferAttribute(uvs, 2));
+ geom.setIndex(TRIANGULATION);
+ geom.computeVertexNormals();
+
+ const canvas = document.createElement('canvas');
+ canvas.width = photoImg.naturalWidth;
+ canvas.height = photoImg.naturalHeight;
+ canvas.getContext('2d').drawImage(photoImg, 0, 0);
+ const texture = new THREE.CanvasTexture(canvas);
+ texture.colorSpace = THREE.SRGBColorSpace;
+ texture.flipY = false;
+
+ const material = new THREE.MeshStandardMaterial({
+ map: texture,
+ side: THREE.DoubleSide,
+ roughness: 0.85,
+ metalness: 0,
+ });
+ const mesh = new THREE.Mesh(geom, material);
+ mesh.name = 'os-face-mesh';
+ return mesh;
+}
+
+// ── Viewer ─────────────────────────────────────────────────────────────────
+
+function ensureViewer() {
+ if (viewer) return viewer;
+ const width = viewerHost.clientWidth;
+ const height = viewerHost.clientHeight || 600;
+
+ const scene = new THREE.Scene();
+ scene.background = new THREE.Color(0x050505);
+ const camera = new THREE.PerspectiveCamera(35, width / height, 0.01, 100);
+ camera.position.set(0, 1.4, 2.4);
+
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
+ renderer.setPixelRatio(window.devicePixelRatio);
+ renderer.setSize(width, height);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ viewerHost.appendChild(renderer.domElement);
+
+ scene.add(new THREE.HemisphereLight(0xffffff, 0x333333, 1.2));
+ const dir = new THREE.DirectionalLight(0xffffff, 1.5);
+ dir.position.set(2, 4, 3);
+ scene.add(dir);
+
+ const grid = new THREE.GridHelper(4, 8, 0x222222, 0x111111);
+ scene.add(grid);
+
+ const controls = new OrbitControls(camera, renderer.domElement);
+ controls.target.set(0, 1, 0);
+ controls.enableDamping = true;
+ controls.update();
+
+ const onResize = () => {
+ const w = viewerHost.clientWidth;
+ const h = viewerHost.clientHeight || 600;
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ renderer.setSize(w, h);
+ };
+ window.addEventListener('resize', onResize);
+
+ (function tick() {
+ controls.update();
+ renderer.render(scene, camera);
+ requestAnimationFrame(tick);
+ })();
+
+ viewer = { scene, camera, renderer, controls };
+ return viewer;
+}
+
+function fitToObject({ camera, controls }, obj) {
+ const box = new THREE.Box3().setFromObject(obj);
+ const size = new THREE.Vector3();
+ const center = new THREE.Vector3();
+ box.getSize(size);
+ box.getCenter(center);
+ const maxDim = Math.max(size.x, size.y, size.z);
+ const dist = (maxDim / Math.tan((Math.PI / 180) * camera.fov / 2)) * 1.4;
+ camera.position.set(center.x, center.y + size.y * 0.2, center.z + dist);
+ controls.target.copy(center);
+ controls.update();
+}
+
+// ── Export ─────────────────────────────────────────────────────────────────
+
+async function exportGlb() {
+ if (!bodyRoot) return null;
+ if (lastGlbBlob) return lastGlbBlob;
+ const exporter = new GLTFExporter();
+ const arrayBuffer = await new Promise((resolve, reject) => {
+ exporter.parse(
+ bodyRoot,
+ (result) => resolve(result),
+ (err) => reject(err),
+ { binary: true, embedImages: true },
+ );
+ });
+ const blob = new Blob([arrayBuffer], { type: 'model/gltf-binary' });
+ lastGlbBlob = blob;
+ return blob;
+}
+
+btnDownload.addEventListener('click', async () => {
+ try {
+ setStatus(exportStatus, 'exporting merged GLB…');
+ const blob = await exportGlb();
+ if (!blob) return;
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `os-avatar-${Date.now()}.glb`;
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+ setStatus(exportStatus, `downloaded · ${(blob.size / 1024).toFixed(1)} KB`, 'ok');
+ } catch (err) {
+ setStatus(exportStatus, `export failed: ${err.message}`, 'err');
+ }
+});
+
+btnSave.addEventListener('click', async () => {
+ try {
+ setStatus(exportStatus, 'exporting GLB…');
+ const blob = await exportGlb();
+ if (!blob) return;
+ setStatus(exportStatus, 'requesting presigned URL…');
+ const initRes = await fetch('/api/avatars/presign', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ size_bytes: blob.size,
+ content_type: 'model/gltf-binary',
+ }),
+ });
+ if (!initRes.ok) {
+ const txt = await initRes.text();
+ throw new Error(`presign ${initRes.status}: ${txt.slice(0, 120)}`);
+ }
+ const init = await initRes.json();
+ setStatus(exportStatus, 'uploading to R2…');
+ const putRes = await fetch(init.upload_url, {
+ method: 'PUT',
+ headers: { 'content-type': 'model/gltf-binary' },
+ body: blob,
+ });
+ if (!putRes.ok) throw new Error(`R2 PUT ${putRes.status}`);
+ setStatus(exportStatus, 'creating avatar record…');
+ const createRes = await fetch('/api/avatars', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ name: 'OSS combined avatar',
+ storage_key: init.storage_key,
+ size_bytes: blob.size,
+ visibility: 'private',
+ }),
+ });
+ if (!createRes.ok) {
+ const txt = await createRes.text();
+ throw new Error(`/api/avatars ${createRes.status}: ${txt.slice(0, 120)}`);
+ }
+ const created = await createRes.json();
+ setStatus(
+ exportStatus,
+ `saved · avatar id ${created.id || created.avatar?.id || 'ok'}`,
+ 'ok',
+ );
+ } catch (err) {
+ setStatus(exportStatus, `save failed: ${err.message}`, 'err');
+ }
+});
diff --git a/src/demo/os-hub.js b/src/demo/os-hub.js
new file mode 100644
index 000000000..1aaca9bb3
--- /dev/null
+++ b/src/demo/os-hub.js
@@ -0,0 +1,69 @@
+/**
+ * Hub status checks for /demo/avatar-os.
+ * Probes each dependency the demos rely on and reports whether it's reachable.
+ */
+
+const set = (id, msg, kind) => {
+ const el = document.getElementById(id);
+ if (!el) return;
+ el.textContent = msg;
+ el.classList.remove('ok', 'err');
+ if (kind === 'ok') el.classList.add('ok');
+ if (kind === 'err') el.classList.add('err');
+};
+
+async function probeMediapipe() {
+ try {
+ const mod = await import('@mediapipe/tasks-vision');
+ if (!mod.FaceLandmarker || !mod.FilesetResolver) {
+ throw new Error('FaceLandmarker not exported');
+ }
+ set('mp-status', `loaded · FaceLandmarker available`, 'ok');
+ } catch (err) {
+ set('mp-status', `failed: ${err.message}`, 'err');
+ }
+}
+
+async function probeTriangulation() {
+ try {
+ const mod = await import('./triangulation.js');
+ const arr = mod.TRIANGULATION;
+ if (!Array.isArray(arr)) throw new Error('TRIANGULATION not an array');
+ set('tri-status', `${arr.length} indices · ${arr.length / 3} triangles`, 'ok');
+ } catch (err) {
+ set('tri-status', `failed: ${err.message}`, 'err');
+ }
+}
+
+async function probeBaseGlb() {
+ try {
+ const res = await fetch('/avatars/default.glb', { method: 'HEAD' });
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ const size = res.headers.get('content-length');
+ set('glb-status', `/avatars/default.glb · ${size ? `${(size / 1024).toFixed(0)} KB` : 'ok'}`, 'ok');
+ } catch (err) {
+ set('glb-status', `failed: ${err.message}`, 'err');
+ }
+}
+
+async function probeCharacterStudio() {
+ const url = 'http://localhost:5173';
+ try {
+ const controller = new AbortController();
+ const timer = setTimeout(() => controller.abort(), 1500);
+ const res = await fetch(url, { method: 'GET', mode: 'no-cors', signal: controller.signal });
+ clearTimeout(timer);
+ set('cs-status', `reachable · ${url}`, 'ok');
+ } catch (err) {
+ set(
+ 'cs-status',
+ `not running · start with: npm --prefix character-studio run dev`,
+ 'err',
+ );
+ }
+}
+
+probeMediapipe();
+probeTriangulation();
+probeBaseGlb();
+probeCharacterStudio();
diff --git a/src/demo/os-selfie.js b/src/demo/os-selfie.js
new file mode 100644
index 000000000..b0ad78232
--- /dev/null
+++ b/src/demo/os-selfie.js
@@ -0,0 +1,433 @@
+/**
+ * OSS Avatar pipeline — Selfie demo.
+ *
+ * Flow:
+ * 1. Capture up to 3 photos (camera or file) — frontal is required.
+ * 2. Run MediaPipe Face Landmarker on the frontal image → 478 3D landmarks.
+ * 3. Build a three.js mesh:
+ * - position: landmark XYZ (normalized image coords + mediapipe z depth)
+ * - uv: landmark XY (texture is the original photo)
+ * - index: TRIANGULATION from tfjs-models (Apache-2.0)
+ * 4. Render with OrbitControls + export as GLB via GLTFExporter.
+ *
+ * No server calls for inference. WASM + model fetch from Google's CDN at init.
+ */
+
+import * as THREE from 'three';
+import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
+import { FilesetResolver, FaceLandmarker } from '@mediapipe/tasks-vision';
+import { TRIANGULATION } from './triangulation.js';
+
+const MODEL_URL =
+ 'https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task';
+const WASM_BASE = 'https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]/wasm';
+
+const slots = ['frontal', 'left', 'right'];
+const photoData = { frontal: null, left: null, right: null };
+
+const captureStatus = document.getElementById('capture-status');
+const buildStatus = document.getElementById('build-status');
+const exportStatus = document.getElementById('export-status');
+const viewerHost = document.getElementById('viewer-host');
+const viewerBadge = document.getElementById('viewer-badge');
+const viewerOverlay = document.getElementById('viewer-overlay');
+const btnBuild = document.getElementById('btn-build');
+const btnDownload = document.getElementById('btn-download');
+const btnSave = document.getElementById('btn-save');
+const btnCamera = document.getElementById('btn-camera');
+const btnClear = document.getElementById('btn-clear');
+const cameraVideo = document.getElementById('camera-video');
+const cameraControls = document.getElementById('camera-controls');
+
+let landmarker = null;
+let landmarkerLoading = null;
+let cameraStream = null;
+let viewer = null;
+let lastMesh = null;
+let lastGlbBlob = null;
+
+function setStatus(el, msg, kind) {
+ el.textContent = msg;
+ el.classList.remove('ok', 'err');
+ if (kind === 'ok') el.classList.add('ok');
+ if (kind === 'err') el.classList.add('err');
+}
+
+function refreshCaptureStatus() {
+ const done = slots.filter((s) => photoData[s]);
+ setStatus(
+ captureStatus,
+ `${done.length}/3 · ${done.join(', ') || 'none'}`,
+ done.includes('frontal') ? 'ok' : null,
+ );
+ btnBuild.disabled = !photoData.frontal;
+}
+
+// ── File input slots ───────────────────────────────────────────────────────
+
+document.querySelectorAll('.photo-slot').forEach((slot) => {
+ const name = slot.dataset.slot;
+ const input = slot.querySelector('input[type=file]');
+ input.addEventListener('change', async () => {
+ const file = input.files?.[0];
+ if (!file) return;
+ await setPhoto(name, file);
+ });
+});
+
+async function setPhoto(name, file) {
+ const url = URL.createObjectURL(file);
+ const img = await loadImage(url);
+ photoData[name] = { file, url, img };
+ const slot = document.querySelector(`.photo-slot[data-slot="${name}"]`);
+ let prev = slot.querySelector('img');
+ if (!prev) {
+ prev = document.createElement('img');
+ slot.insertBefore(prev, slot.firstChild);
+ }
+ prev.src = url;
+ refreshCaptureStatus();
+}
+
+function loadImage(src) {
+ return new Promise((resolve, reject) => {
+ const img = new Image();
+ img.crossOrigin = 'anonymous';
+ img.onload = () => resolve(img);
+ img.onerror = reject;
+ img.src = src;
+ });
+}
+
+btnClear.addEventListener('click', () => {
+ for (const s of slots) {
+ if (photoData[s]?.url) URL.revokeObjectURL(photoData[s].url);
+ photoData[s] = null;
+ const slot = document.querySelector(`.photo-slot[data-slot="${s}"]`);
+ const prev = slot.querySelector('img');
+ if (prev) prev.remove();
+ }
+ refreshCaptureStatus();
+});
+
+// ── Camera capture ─────────────────────────────────────────────────────────
+
+btnCamera.addEventListener('click', async () => {
+ if (cameraStream) return stopCamera();
+ try {
+ cameraStream = await navigator.mediaDevices.getUserMedia({
+ video: { facingMode: 'user', width: 1280, height: 960 },
+ audio: false,
+ });
+ cameraVideo.srcObject = cameraStream;
+ cameraVideo.style.display = 'block';
+ cameraControls.style.display = 'flex';
+ btnCamera.textContent = 'Hide camera';
+ } catch (err) {
+ setStatus(captureStatus, `camera failed: ${err.message}`, 'err');
+ }
+});
+
+function stopCamera() {
+ if (cameraStream) {
+ cameraStream.getTracks().forEach((t) => t.stop());
+ cameraStream = null;
+ }
+ cameraVideo.srcObject = null;
+ cameraVideo.style.display = 'none';
+ cameraControls.style.display = 'none';
+ btnCamera.textContent = 'Use camera';
+}
+
+document.getElementById('btn-stop-camera').addEventListener('click', stopCamera);
+
+for (const which of slots) {
+ document
+ .getElementById(`btn-snap-${which}`)
+ .addEventListener('click', () => snapTo(which));
+}
+
+async function snapTo(name) {
+ if (!cameraStream) return;
+ const canvas = document.createElement('canvas');
+ canvas.width = cameraVideo.videoWidth;
+ canvas.height = cameraVideo.videoHeight;
+ canvas.getContext('2d').drawImage(cameraVideo, 0, 0);
+ const blob = await new Promise((r) => canvas.toBlob(r, 'image/jpeg', 0.92));
+ const file = new File([blob], `${name}.jpg`, { type: 'image/jpeg' });
+ await setPhoto(name, file);
+}
+
+// ── MediaPipe init ─────────────────────────────────────────────────────────
+
+async function getLandmarker() {
+ if (landmarker) return landmarker;
+ if (landmarkerLoading) return landmarkerLoading;
+ landmarkerLoading = (async () => {
+ const fileset = await FilesetResolver.forVisionTasks(WASM_BASE);
+ const lm = await FaceLandmarker.createFromOptions(fileset, {
+ baseOptions: {
+ modelAssetPath: MODEL_URL,
+ delegate: 'GPU',
+ },
+ runningMode: 'IMAGE',
+ numFaces: 1,
+ outputFaceBlendshapes: false,
+ outputFacialTransformationMatrixes: true,
+ });
+ landmarker = lm;
+ return lm;
+ })();
+ return landmarkerLoading;
+}
+
+// ── Build the face mesh ────────────────────────────────────────────────────
+
+btnBuild.addEventListener('click', async () => {
+ if (!photoData.frontal) return;
+ btnBuild.disabled = true;
+ try {
+ setStatus(buildStatus, 'loading MediaPipe wasm + model…');
+ const lm = await getLandmarker();
+ setStatus(buildStatus, 'detecting landmarks…');
+ const result = lm.detect(photoData.frontal.img);
+ if (!result.faceLandmarks || !result.faceLandmarks.length) {
+ throw new Error('no face detected in frontal photo');
+ }
+ const landmarks = result.faceLandmarks[0];
+ setStatus(buildStatus, `detected ${landmarks.length} landmarks · building mesh…`);
+
+ ensureViewer();
+ if (lastMesh) {
+ viewer.scene.remove(lastMesh);
+ lastMesh.geometry.dispose();
+ if (lastMesh.material.map) lastMesh.material.map.dispose();
+ lastMesh.material.dispose();
+ lastMesh = null;
+ }
+
+ const mesh = buildFaceMesh(landmarks, photoData.frontal.img);
+ viewer.scene.add(mesh);
+ lastMesh = mesh;
+ fitToObject(viewer, mesh);
+
+ viewerOverlay.style.display = 'none';
+ viewerBadge.textContent = `face · ${landmarks.length} verts · ${TRIANGULATION.length / 3} tris`;
+ setStatus(
+ buildStatus,
+ `mesh ready · ${landmarks.length} vertices · ${TRIANGULATION.length / 3} triangles`,
+ 'ok',
+ );
+ btnDownload.disabled = false;
+ btnSave.disabled = false;
+ setStatus(exportStatus, 'ready to export');
+ } catch (err) {
+ setStatus(buildStatus, `build failed: ${err.message}`, 'err');
+ console.error('[os-selfie] build failed', err);
+ } finally {
+ btnBuild.disabled = false;
+ }
+});
+
+function buildFaceMesh(landmarks, photoImg) {
+ const geom = new THREE.BufferGeometry();
+
+ // Landmarks: { x, y, z } with x,y in [0,1] image coords, y=down, z=depth (negative into screen)
+ // Convert into a centered, world-up mesh. Scale so the face is roughly 0.2m tall.
+ const aspect = photoImg.naturalWidth / photoImg.naturalHeight;
+ const scale = 0.2;
+ const positions = new Float32Array(landmarks.length * 3);
+ const uvs = new Float32Array(landmarks.length * 2);
+ for (let i = 0; i < landmarks.length; i++) {
+ const p = landmarks[i];
+ positions[i * 3 + 0] = (p.x - 0.5) * aspect * scale;
+ positions[i * 3 + 1] = -(p.y - 0.5) * scale;
+ positions[i * 3 + 2] = -p.z * scale;
+ uvs[i * 2 + 0] = p.x;
+ uvs[i * 2 + 1] = 1 - p.y;
+ }
+ geom.setAttribute('position', new THREE.BufferAttribute(positions, 3));
+ geom.setAttribute('uv', new THREE.BufferAttribute(uvs, 2));
+ geom.setIndex(TRIANGULATION);
+ geom.computeVertexNormals();
+
+ // Photo as texture
+ const canvas = document.createElement('canvas');
+ canvas.width = photoImg.naturalWidth;
+ canvas.height = photoImg.naturalHeight;
+ canvas.getContext('2d').drawImage(photoImg, 0, 0);
+ const texture = new THREE.CanvasTexture(canvas);
+ texture.colorSpace = THREE.SRGBColorSpace;
+ texture.flipY = false; // we already flipped V
+
+ const material = new THREE.MeshStandardMaterial({
+ map: texture,
+ side: THREE.DoubleSide,
+ roughness: 0.85,
+ metalness: 0,
+ });
+ const mesh = new THREE.Mesh(geom, material);
+ mesh.name = 'os-face-mesh';
+ return mesh;
+}
+
+// ── Viewer ─────────────────────────────────────────────────────────────────
+
+function ensureViewer() {
+ if (viewer) return viewer;
+ const width = viewerHost.clientWidth;
+ const height = viewerHost.clientHeight || 480;
+
+ const scene = new THREE.Scene();
+ scene.background = new THREE.Color(0x050505);
+
+ const camera = new THREE.PerspectiveCamera(35, width / height, 0.001, 10);
+ camera.position.set(0, 0, 0.6);
+
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
+ renderer.setPixelRatio(window.devicePixelRatio);
+ renderer.setSize(width, height);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ viewerHost.appendChild(renderer.domElement);
+
+ scene.add(new THREE.HemisphereLight(0xffffff, 0x333333, 1.2));
+ const dir = new THREE.DirectionalLight(0xffffff, 1.4);
+ dir.position.set(1, 2, 3);
+ scene.add(dir);
+ const dir2 = new THREE.DirectionalLight(0xffffff, 0.6);
+ dir2.position.set(-2, 1, -1);
+ scene.add(dir2);
+
+ const grid = new THREE.GridHelper(1, 10, 0x222222, 0x111111);
+ grid.position.y = -0.2;
+ scene.add(grid);
+
+ const controls = new OrbitControls(camera, renderer.domElement);
+ controls.target.set(0, 0, 0);
+ controls.enableDamping = true;
+ controls.update();
+
+ const onResize = () => {
+ const w = viewerHost.clientWidth;
+ const h = viewerHost.clientHeight || 480;
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ renderer.setSize(w, h);
+ };
+ window.addEventListener('resize', onResize);
+
+ (function tick() {
+ controls.update();
+ renderer.render(scene, camera);
+ requestAnimationFrame(tick);
+ })();
+
+ viewer = { scene, camera, renderer, controls };
+ return viewer;
+}
+
+function fitToObject({ camera, controls }, obj) {
+ const box = new THREE.Box3().setFromObject(obj);
+ const size = new THREE.Vector3();
+ const center = new THREE.Vector3();
+ box.getSize(size);
+ box.getCenter(center);
+ const maxDim = Math.max(size.x, size.y, size.z);
+ const dist = (maxDim / Math.tan((Math.PI / 180) * camera.fov / 2)) * 1.3;
+ camera.position.set(center.x, center.y, center.z + dist);
+ controls.target.copy(center);
+ controls.update();
+}
+
+// ── Export GLB ─────────────────────────────────────────────────────────────
+
+async function exportGlb() {
+ if (!lastMesh) return null;
+ if (lastGlbBlob) return lastGlbBlob;
+ const exporter = new GLTFExporter();
+ const arrayBuffer = await new Promise((resolve, reject) => {
+ exporter.parse(
+ lastMesh,
+ (result) => resolve(result),
+ (err) => reject(err),
+ { binary: true, embedImages: true },
+ );
+ });
+ const blob = new Blob([arrayBuffer], { type: 'model/gltf-binary' });
+ lastGlbBlob = blob;
+ return blob;
+}
+
+btnDownload.addEventListener('click', async () => {
+ try {
+ setStatus(exportStatus, 'exporting GLB…');
+ const blob = await exportGlb();
+ if (!blob) return;
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `os-face-${Date.now()}.glb`;
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+ setStatus(exportStatus, `downloaded · ${(blob.size / 1024).toFixed(1)} KB`, 'ok');
+ } catch (err) {
+ setStatus(exportStatus, `export failed: ${err.message}`, 'err');
+ }
+});
+
+btnSave.addEventListener('click', async () => {
+ try {
+ setStatus(exportStatus, 'exporting GLB…');
+ const blob = await exportGlb();
+ if (!blob) return;
+ setStatus(exportStatus, 'requesting presigned URL…');
+ const initRes = await fetch('/api/avatars/presign', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ size_bytes: blob.size,
+ content_type: 'model/gltf-binary',
+ }),
+ });
+ if (!initRes.ok) {
+ const txt = await initRes.text();
+ throw new Error(`presign ${initRes.status}: ${txt.slice(0, 120)}`);
+ }
+ const init = await initRes.json();
+ setStatus(exportStatus, 'uploading to R2…');
+ const putRes = await fetch(init.upload_url, {
+ method: 'PUT',
+ headers: { 'content-type': 'model/gltf-binary' },
+ body: blob,
+ });
+ if (!putRes.ok) throw new Error(`R2 PUT ${putRes.status}`);
+ setStatus(exportStatus, 'creating avatar record…');
+ const createRes = await fetch('/api/avatars', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ name: 'OSS face mesh',
+ storage_key: init.storage_key,
+ size_bytes: blob.size,
+ visibility: 'private',
+ }),
+ });
+ if (!createRes.ok) {
+ const txt = await createRes.text();
+ throw new Error(`/api/avatars ${createRes.status}: ${txt.slice(0, 120)}`);
+ }
+ const created = await createRes.json();
+ setStatus(
+ exportStatus,
+ `saved · avatar id ${created.id || created.avatar?.id || 'ok'}`,
+ 'ok',
+ );
+ } catch (err) {
+ setStatus(exportStatus, `save failed: ${err.message}`, 'err');
+ }
+});
+
+refreshCaptureStatus();
diff --git a/src/demo/os-studio.js b/src/demo/os-studio.js
new file mode 100644
index 000000000..653b785a6
--- /dev/null
+++ b/src/demo/os-studio.js
@@ -0,0 +1,241 @@
+/**
+ * OSS Avatar pipeline — CharacterStudio demo.
+ *
+ * Mounts CharacterStudio in an iframe and listens for the `characterstudio`
+ * postMessage `export` event (same contract the production AvatarCreator uses
+ * for the CharacterStudio fallback path). Renders the exported GLB in a
+ * standalone three.js viewer + offers download / save-to-account.
+ */
+
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+
+const PUBLIC_STUDIO = 'https://m3-org.github.io/CharacterStudio';
+const LOCAL_STUDIO = 'http://localhost:5173';
+
+const iframeHost = document.getElementById('iframe-host');
+const iframeEmpty = document.getElementById('iframe-empty');
+const previewViewer = document.getElementById('preview-viewer');
+const previewBadge = document.getElementById('preview-badge');
+const btnLocal = document.getElementById('btn-open-local');
+const btnPublic = document.getElementById('btn-open-public');
+const btnDownload = document.getElementById('btn-download');
+const btnSave = document.getElementById('btn-save');
+const studioStatus = document.getElementById('studio-status');
+const exportStatus = document.getElementById('export-status');
+
+let currentIframeOrigin = null;
+let lastGlbBlob = null;
+
+function setStatus(el, msg, kind) {
+ el.textContent = msg;
+ el.classList.remove('ok', 'err');
+ if (kind === 'ok') el.classList.add('ok');
+ if (kind === 'err') el.classList.add('err');
+}
+
+function openStudio(url) {
+ if (iframeEmpty) iframeEmpty.style.display = 'none';
+ const existing = iframeHost.querySelector('iframe.studio-frame');
+ if (existing) existing.remove();
+ const frame = document.createElement('iframe');
+ frame.className = 'studio-frame';
+ frame.allow = 'camera *; microphone *; clipboard-write';
+ frame.sandbox =
+ 'allow-scripts allow-same-origin allow-forms allow-popups allow-downloads';
+ frame.src = url;
+ frame.style.minHeight = '600px';
+ try {
+ currentIframeOrigin = new URL(url).origin;
+ } catch {
+ currentIframeOrigin = null;
+ }
+ iframeHost.appendChild(frame);
+ setStatus(studioStatus, `loading ${url}…`);
+ frame.addEventListener('load', () => {
+ setStatus(studioStatus, `loaded ${url}`, 'ok');
+ });
+ frame.addEventListener('error', () => {
+ setStatus(studioStatus, `failed to load ${url}`, 'err');
+ });
+}
+
+btnLocal.addEventListener('click', () => openStudio(LOCAL_STUDIO));
+btnPublic.addEventListener('click', () => openStudio(PUBLIC_STUDIO));
+
+// ── Listen for export from CharacterStudio iframe ──────────────────────────
+
+window.addEventListener('message', async (event) => {
+ if (currentIframeOrigin && event.origin !== currentIframeOrigin) return;
+ const msg = event.data;
+ if (!msg || msg.source !== 'characterstudio' || msg.type !== 'export') return;
+ if (!(msg.glb instanceof ArrayBuffer)) {
+ setStatus(exportStatus, 'export received but glb payload missing', 'err');
+ return;
+ }
+ const blob = new Blob([msg.glb], { type: 'model/gltf-binary' });
+ lastGlbBlob = blob;
+ setStatus(
+ exportStatus,
+ `received ${(blob.size / 1024).toFixed(1)} KB GLB · rendering preview…`,
+ 'ok',
+ );
+ btnDownload.disabled = false;
+ btnSave.disabled = false;
+ await renderPreview(blob);
+});
+
+// ── Preview viewer ─────────────────────────────────────────────────────────
+
+let previewState = null;
+
+async function renderPreview(blob) {
+ previewViewer.style.display = 'block';
+ if (!previewState) previewState = initViewer(previewViewer);
+ const { scene, controls } = previewState;
+ // Drop any prior avatar
+ while (scene.children.find((c) => c.userData.kind === 'avatar')) {
+ const old = scene.children.find((c) => c.userData.kind === 'avatar');
+ scene.remove(old);
+ }
+ const url = URL.createObjectURL(blob);
+ try {
+ const loader = new GLTFLoader();
+ const gltf = await loader.loadAsync(url);
+ gltf.scene.userData.kind = 'avatar';
+ scene.add(gltf.scene);
+ fitToObject(previewState, gltf.scene);
+ const box = new THREE.Box3().setFromObject(gltf.scene);
+ const size = new THREE.Vector3();
+ box.getSize(size);
+ previewBadge.textContent = `GLB · ${size.x.toFixed(2)}×${size.y.toFixed(2)}×${size.z.toFixed(2)}m`;
+ setStatus(
+ exportStatus,
+ `loaded · ${(blob.size / 1024).toFixed(1)} KB · ${size.y.toFixed(2)}m tall`,
+ 'ok',
+ );
+ } catch (err) {
+ setStatus(exportStatus, `preview failed: ${err.message}`, 'err');
+ } finally {
+ URL.revokeObjectURL(url);
+ }
+}
+
+function initViewer(host) {
+ const width = host.clientWidth;
+ const height = host.clientHeight || 360;
+ const scene = new THREE.Scene();
+ scene.background = new THREE.Color(0x050505);
+ const camera = new THREE.PerspectiveCamera(35, width / height, 0.01, 100);
+ camera.position.set(0, 1.4, 2.4);
+
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
+ renderer.setPixelRatio(window.devicePixelRatio);
+ renderer.setSize(width, height);
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ host.appendChild(renderer.domElement);
+
+ scene.add(new THREE.HemisphereLight(0xffffff, 0x444444, 1.2));
+ const dir = new THREE.DirectionalLight(0xffffff, 1.5);
+ dir.position.set(2, 4, 3);
+ scene.add(dir);
+
+ const grid = new THREE.GridHelper(4, 8, 0x222222, 0x111111);
+ scene.add(grid);
+
+ const controls = new OrbitControls(camera, renderer.domElement);
+ controls.target.set(0, 1, 0);
+ controls.enableDamping = true;
+ controls.update();
+
+ const onResize = () => {
+ const w = host.clientWidth;
+ const h = host.clientHeight || 360;
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ renderer.setSize(w, h);
+ };
+ window.addEventListener('resize', onResize);
+
+ (function tick() {
+ controls.update();
+ renderer.render(scene, camera);
+ requestAnimationFrame(tick);
+ })();
+
+ return { scene, camera, renderer, controls };
+}
+
+function fitToObject({ camera, controls }, obj) {
+ const box = new THREE.Box3().setFromObject(obj);
+ const size = new THREE.Vector3();
+ const center = new THREE.Vector3();
+ box.getSize(size);
+ box.getCenter(center);
+ const maxDim = Math.max(size.x, size.y, size.z);
+ const dist = (maxDim / Math.tan((Math.PI / 180) * camera.fov / 2)) * 1.3;
+ camera.position.set(center.x, center.y + size.y * 0.2, center.z + dist);
+ controls.target.copy(center);
+ controls.update();
+}
+
+// ── Download & save ────────────────────────────────────────────────────────
+
+btnDownload.addEventListener('click', () => {
+ if (!lastGlbBlob) return;
+ const url = URL.createObjectURL(lastGlbBlob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `avatar-os-${Date.now()}.glb`;
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+});
+
+btnSave.addEventListener('click', async () => {
+ if (!lastGlbBlob) return;
+ setStatus(exportStatus, 'requesting presigned URL…');
+ try {
+ const initRes = await fetch('/api/avatars/presign', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ size_bytes: lastGlbBlob.size,
+ content_type: 'model/gltf-binary',
+ }),
+ });
+ if (!initRes.ok) {
+ const txt = await initRes.text();
+ throw new Error(`presign ${initRes.status}: ${txt.slice(0, 120)}`);
+ }
+ const init = await initRes.json();
+ setStatus(exportStatus, 'uploading to R2…');
+ const putRes = await fetch(init.upload_url, {
+ method: 'PUT',
+ headers: { 'content-type': 'model/gltf-binary' },
+ body: lastGlbBlob,
+ });
+ if (!putRes.ok) throw new Error(`R2 PUT ${putRes.status}`);
+ setStatus(exportStatus, 'creating avatar record…');
+ const createRes = await fetch('/api/avatars', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ name: 'OSS demo avatar',
+ storage_key: init.storage_key,
+ size_bytes: lastGlbBlob.size,
+ visibility: 'private',
+ }),
+ });
+ if (!createRes.ok) {
+ const txt = await createRes.text();
+ throw new Error(`/api/avatars ${createRes.status}: ${txt.slice(0, 120)}`);
+ }
+ const created = await createRes.json();
+ setStatus(exportStatus, `saved · avatar id ${created.id || created.avatar?.id}`, 'ok');
+ } catch (err) {
+ setStatus(exportStatus, `save failed: ${err.message}`, 'err');
+ }
+});
diff --git a/src/demo/triangulation.js b/src/demo/triangulation.js
new file mode 100644
index 000000000..7556ccff9
--- /dev/null
+++ b/src/demo/triangulation.js
@@ -0,0 +1,186 @@
+/**
+ * @license
+ * Copyright 2020 Google LLC. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================================
+ */
+
+export const TRIANGULATION = [
+ 127, 34, 139, 11, 0, 37, 232, 231, 120, 72, 37, 39, 128, 121, 47, 232, 121,
+ 128, 104, 69, 67, 175, 171, 148, 157, 154, 155, 118, 50, 101, 73, 39, 40, 9,
+ 151, 108, 48, 115, 131, 194, 204, 211, 74, 40, 185, 80, 42, 183, 40, 92,
+ 186, 230, 229, 118, 202, 212, 214, 83, 18, 17, 76, 61, 146, 160, 29, 30, 56,
+ 157, 173, 106, 204, 194, 135, 214, 192, 203, 165, 98, 21, 71, 68, 51, 45, 4,
+ 144, 24, 23, 77, 146, 91, 205, 50, 187, 201, 200, 18, 91, 106, 182, 90, 91,
+ 181, 85, 84, 17, 206, 203, 36, 148, 171, 140, 92, 40, 39, 193, 189, 244,
+ 159, 158, 28, 247, 246, 161, 236, 3, 196, 54, 68, 104, 193, 168, 8, 117,
+ 228, 31, 189, 193, 55, 98, 97, 99, 126, 47, 100, 166, 79, 218, 155, 154, 26,
+ 209, 49, 131, 135, 136, 150, 47, 126, 217, 223, 52, 53, 45, 51, 134, 211,
+ 170, 140, 67, 69, 108, 43, 106, 91, 230, 119, 120, 226, 130, 247, 63, 53,
+ 52, 238, 20, 242, 46, 70, 156, 78, 62, 96, 46, 53, 63, 143, 34, 227, 173,
+ 155, 133, 123, 117, 111, 44, 125, 19, 236, 134, 51, 216, 206, 205, 154, 153,
+ 22, 39, 37, 167, 200, 201, 208, 36, 142, 100, 57, 212, 202, 20, 60, 99, 28,
+ 158, 157, 35, 226, 113, 160, 159, 27, 204, 202, 210, 113, 225, 46, 43, 202,
+ 204, 62, 76, 77, 137, 123, 116, 41, 38, 72, 203, 129, 142, 64, 98, 240, 49,
+ 102, 64, 41, 73, 74, 212, 216, 207, 42, 74, 184, 169, 170, 211, 170, 149,
+ 176, 105, 66, 69, 122, 6, 168, 123, 147, 187, 96, 77, 90, 65, 55, 107, 89,
+ 90, 180, 101, 100, 120, 63, 105, 104, 93, 137, 227, 15, 86, 85, 129, 102,
+ 49, 14, 87, 86, 55, 8, 9, 100, 47, 121, 145, 23, 22, 88, 89, 179, 6, 122,
+ 196, 88, 95, 96, 138, 172, 136, 215, 58, 172, 115, 48, 219, 42, 80, 81, 195,
+ 3, 51, 43, 146, 61, 171, 175, 199, 81, 82, 38, 53, 46, 225, 144, 163, 110,
+ 246, 33, 7, 52, 65, 66, 229, 228, 117, 34, 127, 234, 107, 108, 69, 109, 108,
+ 151, 48, 64, 235, 62, 78, 191, 129, 209, 126, 111, 35, 143, 163, 161, 246,
+ 117, 123, 50, 222, 65, 52, 19, 125, 141, 221, 55, 65, 3, 195, 197, 25, 7,
+ 33, 220, 237, 44, 70, 71, 139, 122, 193, 245, 247, 130, 33, 71, 21, 162,
+ 153, 158, 159, 170, 169, 150, 188, 174, 196, 216, 186, 92, 144, 160, 161, 2,
+ 97, 167, 141, 125, 241, 164, 167, 37, 72, 38, 12, 145, 159, 160, 38, 82, 13,
+ 63, 68, 71, 226, 35, 111, 158, 153, 154, 101, 50, 205, 206, 92, 165, 209,
+ 198, 217, 165, 167, 97, 220, 115, 218, 133, 112, 243, 239, 238, 241, 214,
+ 135, 169, 190, 173, 133, 171, 208, 32, 125, 44, 237, 86, 87, 178, 85, 86,
+ 179, 84, 85, 180, 83, 84, 181, 201, 83, 182, 137, 93, 132, 76, 62, 183, 61,
+ 76, 184, 57, 61, 185, 212, 57, 186, 214, 207, 187, 34, 143, 156, 79, 239,
+ 237, 123, 137, 177, 44, 1, 4, 201, 194, 32, 64, 102, 129, 213, 215, 138, 59,
+ 166, 219, 242, 99, 97, 2, 94, 141, 75, 59, 235, 24, 110, 228, 25, 130, 226,
+ 23, 24, 229, 22, 23, 230, 26, 22, 231, 112, 26, 232, 189, 190, 243, 221, 56,
+ 190, 28, 56, 221, 27, 28, 222, 29, 27, 223, 30, 29, 224, 247, 30, 225, 238,
+ 79, 20, 166, 59, 75, 60, 75, 240, 147, 177, 215, 20, 79, 166, 187, 147, 213,
+ 112, 233, 244, 233, 128, 245, 128, 114, 188, 114, 217, 174, 131, 115, 220,
+ 217, 198, 236, 198, 131, 134, 177, 132, 58, 143, 35, 124, 110, 163, 7, 228,
+ 110, 25, 356, 389, 368, 11, 302, 267, 452, 350, 349, 302, 303, 269, 357,
+ 343, 277, 452, 453, 357, 333, 332, 297, 175, 152, 377, 384, 398, 382, 347,
+ 348, 330, 303, 304, 270, 9, 336, 337, 278, 279, 360, 418, 262, 431, 304,
+ 408, 409, 310, 415, 407, 270, 409, 410, 450, 348, 347, 422, 430, 434, 313,
+ 314, 17, 306, 307, 375, 387, 388, 260, 286, 414, 398, 335, 406, 418, 364,
+ 367, 416, 423, 358, 327, 251, 284, 298, 281, 5, 4, 373, 374, 253, 307, 320,
+ 321, 425, 427, 411, 421, 313, 18, 321, 405, 406, 320, 404, 405, 315, 16, 17,
+ 426, 425, 266, 377, 400, 369, 322, 391, 269, 417, 465, 464, 386, 257, 258,
+ 466, 260, 388, 456, 399, 419, 284, 332, 333, 417, 285, 8, 346, 340, 261,
+ 413, 441, 285, 327, 460, 328, 355, 371, 329, 392, 439, 438, 382, 341, 256,
+ 429, 420, 360, 364, 394, 379, 277, 343, 437, 443, 444, 283, 275, 440, 363,
+ 431, 262, 369, 297, 338, 337, 273, 375, 321, 450, 451, 349, 446, 342, 467,
+ 293, 334, 282, 458, 461, 462, 276, 353, 383, 308, 324, 325, 276, 300, 293,
+ 372, 345, 447, 382, 398, 362, 352, 345, 340, 274, 1, 19, 456, 248, 281, 436,
+ 427, 425, 381, 256, 252, 269, 391, 393, 200, 199, 428, 266, 330, 329, 287,
+ 273, 422, 250, 462, 328, 258, 286, 384, 265, 353, 342, 387, 259, 257, 424,
+ 431, 430, 342, 353, 276, 273, 335, 424, 292, 325, 307, 366, 447, 345, 271,
+ 303, 302, 423, 266, 371, 294, 455, 460, 279, 278, 294, 271, 272, 304, 432,
+ 434, 427, 272, 407, 408, 394, 430, 431, 395, 369, 400, 334, 333, 299, 351,
+ 417, 168, 352, 280, 411, 325, 319, 320, 295, 296, 336, 319, 403, 404, 330,
+ 348, 349, 293, 298, 333, 323, 454, 447, 15, 16, 315, 358, 429, 279, 14, 15,
+ 316, 285, 336, 9, 329, 349, 350, 374, 380, 252, 318, 402, 403, 6, 197, 419,
+ 318, 319, 325, 367, 364, 365, 435, 367, 397, 344, 438, 439, 272, 271, 311,
+ 195, 5, 281, 273, 287, 291, 396, 428, 199, 311, 271, 268, 283, 444, 445,
+ 373, 254, 339, 263, 466, 249, 282, 334, 296, 449, 347, 346, 264, 447, 454,
+ 336, 296, 299, 338, 10, 151, 278, 439, 455, 292, 407, 415, 358, 371, 355,
+ 340, 345, 372, 390, 249, 466, 346, 347, 280, 442, 443, 282, 19, 94, 370,
+ 441, 442, 295, 248, 419, 197, 263, 255, 359, 440, 275, 274, 300, 383, 368,
+ 351, 412, 465, 263, 467, 466, 301, 368, 389, 380, 374, 386, 395, 378, 379,
+ 412, 351, 419, 436, 426, 322, 373, 390, 388, 2, 164, 393, 370, 462, 461,
+ 164, 0, 267, 302, 11, 12, 374, 373, 387, 268, 12, 13, 293, 300, 301, 446,
+ 261, 340, 385, 384, 381, 330, 266, 425, 426, 423, 391, 429, 355, 437, 391,
+ 327, 326, 440, 457, 438, 341, 382, 362, 459, 457, 461, 434, 430, 394, 414,
+ 463, 362, 396, 369, 262, 354, 461, 457, 316, 403, 402, 315, 404, 403, 314,
+ 405, 404, 313, 406, 405, 421, 418, 406, 366, 401, 361, 306, 408, 407, 291,
+ 409, 408, 287, 410, 409, 432, 436, 410, 434, 416, 411, 264, 368, 383, 309,
+ 438, 457, 352, 376, 401, 274, 275, 4, 421, 428, 262, 294, 327, 358, 433,
+ 416, 367, 289, 455, 439, 462, 370, 326, 2, 326, 370, 305, 460, 455, 254,
+ 449, 448, 255, 261, 446, 253, 450, 449, 252, 451, 450, 256, 452, 451, 341,
+ 453, 452, 413, 464, 463, 441, 413, 414, 258, 442, 441, 257, 443, 442, 259,
+ 444, 443, 260, 445, 444, 467, 342, 445, 459, 458, 250, 289, 392, 290, 290,
+ 328, 460, 376, 433, 435, 250, 290, 392, 411, 416, 433, 341, 463, 464, 453,
+ 464, 465, 357, 465, 412, 343, 412, 399, 360, 363, 440, 437, 399, 456, 420,
+ 456, 363, 401, 435, 288, 372, 383, 353, 339, 255, 249, 448, 261, 255, 133,
+ 243, 190, 133, 155, 112, 33, 246, 247, 33, 130, 25, 398, 384, 286, 362, 398,
+ 414, 362, 463, 341, 263, 359, 467, 263, 249, 255, 466, 467, 260, 75, 60,
+ 166, 238, 239, 79, 162, 127, 139, 72, 11, 37, 121, 232, 120, 73, 72, 39,
+ 114, 128, 47, 233, 232, 128, 103, 104, 67, 152, 175, 148, 173, 157, 155,
+ 119, 118, 101, 74, 73, 40, 107, 9, 108, 49, 48, 131, 32, 194, 211, 184, 74,
+ 185, 191, 80, 183, 185, 40, 186, 119, 230, 118, 210, 202, 214, 84, 83, 17,
+ 77, 76, 146, 161, 160, 30, 190, 56, 173, 182, 106, 194, 138, 135, 192, 129,
+ 203, 98, 54, 21, 68, 5, 51, 4, 145, 144, 23, 90, 77, 91, 207, 205, 187, 83,
+ 201, 18, 181, 91, 182, 180, 90, 181, 16, 85, 17, 205, 206, 36, 176, 148,
+ 140, 165, 92, 39, 245, 193, 244, 27, 159, 28, 30, 247, 161, 174, 236, 196,
+ 103, 54, 104, 55, 193, 8, 111, 117, 31, 221, 189, 55, 240, 98, 99, 142, 126,
+ 100, 219, 166, 218, 112, 155, 26, 198, 209, 131, 169, 135, 150, 114, 47,
+ 217, 224, 223, 53, 220, 45, 134, 32, 211, 140, 109, 67, 108, 146, 43, 91,
+ 231, 230, 120, 113, 226, 247, 105, 63, 52, 241, 238, 242, 124, 46, 156, 95,
+ 78, 96, 70, 46, 63, 116, 143, 227, 116, 123, 111, 1, 44, 19, 3, 236, 51,
+ 207, 216, 205, 26, 154, 22, 165, 39, 167, 199, 200, 208, 101, 36, 100, 43,
+ 57, 202, 242, 20, 99, 56, 28, 157, 124, 35, 113, 29, 160, 27, 211, 204, 210,
+ 124, 113, 46, 106, 43, 204, 96, 62, 77, 227, 137, 116, 73, 41, 72, 36, 203,
+ 142, 235, 64, 240, 48, 49, 64, 42, 41, 74, 214, 212, 207, 183, 42, 184, 210,
+ 169, 211, 140, 170, 176, 104, 105, 69, 193, 122, 168, 50, 123, 187, 89, 96,
+ 90, 66, 65, 107, 179, 89, 180, 119, 101, 120, 68, 63, 104, 234, 93, 227, 16,
+ 15, 85, 209, 129, 49, 15, 14, 86, 107, 55, 9, 120, 100, 121, 153, 145, 22,
+ 178, 88, 179, 197, 6, 196, 89, 88, 96, 135, 138, 136, 138, 215, 172, 218,
+ 115, 219, 41, 42, 81, 5, 195, 51, 57, 43, 61, 208, 171, 199, 41, 81, 38,
+ 224, 53, 225, 24, 144, 110, 105, 52, 66, 118, 229, 117, 227, 34, 234, 66,
+ 107, 69, 10, 109, 151, 219, 48, 235, 183, 62, 191, 142, 129, 126, 116, 111,
+ 143, 7, 163, 246, 118, 117, 50, 223, 222, 52, 94, 19, 141, 222, 221, 65,
+ 196, 3, 197, 45, 220, 44, 156, 70, 139, 188, 122, 245, 139, 71, 162, 145,
+ 153, 159, 149, 170, 150, 122, 188, 196, 206, 216, 92, 163, 144, 161, 164, 2,
+ 167, 242, 141, 241, 0, 164, 37, 11, 72, 12, 144, 145, 160, 12, 38, 13, 70,
+ 63, 71, 31, 226, 111, 157, 158, 154, 36, 101, 205, 203, 206, 165, 126, 209,
+ 217, 98, 165, 97, 237, 220, 218, 237, 239, 241, 210, 214, 169, 140, 171, 32,
+ 241, 125, 237, 179, 86, 178, 180, 85, 179, 181, 84, 180, 182, 83, 181, 194,
+ 201, 182, 177, 137, 132, 184, 76, 183, 185, 61, 184, 186, 57, 185, 216, 212,
+ 186, 192, 214, 187, 139, 34, 156, 218, 79, 237, 147, 123, 177, 45, 44, 4,
+ 208, 201, 32, 98, 64, 129, 192, 213, 138, 235, 59, 219, 141, 242, 97, 97, 2,
+ 141, 240, 75, 235, 229, 24, 228, 31, 25, 226, 230, 23, 229, 231, 22, 230,
+ 232, 26, 231, 233, 112, 232, 244, 189, 243, 189, 221, 190, 222, 28, 221,
+ 223, 27, 222, 224, 29, 223, 225, 30, 224, 113, 247, 225, 99, 60, 240, 213,
+ 147, 215, 60, 20, 166, 192, 187, 213, 243, 112, 244, 244, 233, 245, 245,
+ 128, 188, 188, 114, 174, 134, 131, 220, 174, 217, 236, 236, 198, 134, 215,
+ 177, 58, 156, 143, 124, 25, 110, 7, 31, 228, 25, 264, 356, 368, 0, 11, 267,
+ 451, 452, 349, 267, 302, 269, 350, 357, 277, 350, 452, 357, 299, 333, 297,
+ 396, 175, 377, 381, 384, 382, 280, 347, 330, 269, 303, 270, 151, 9, 337,
+ 344, 278, 360, 424, 418, 431, 270, 304, 409, 272, 310, 407, 322, 270, 410,
+ 449, 450, 347, 432, 422, 434, 18, 313, 17, 291, 306, 375, 259, 387, 260,
+ 424, 335, 418, 434, 364, 416, 391, 423, 327, 301, 251, 298, 275, 281, 4,
+ 254, 373, 253, 375, 307, 321, 280, 425, 411, 200, 421, 18, 335, 321, 406,
+ 321, 320, 405, 314, 315, 17, 423, 426, 266, 396, 377, 369, 270, 322, 269,
+ 413, 417, 464, 385, 386, 258, 248, 456, 419, 298, 284, 333, 168, 417, 8,
+ 448, 346, 261, 417, 413, 285, 326, 327, 328, 277, 355, 329, 309, 392, 438,
+ 381, 382, 256, 279, 429, 360, 365, 364, 379, 355, 277, 437, 282, 443, 283,
+ 281, 275, 363, 395, 431, 369, 299, 297, 337, 335, 273, 321, 348, 450, 349,
+ 359, 446, 467, 283, 293, 282, 250, 458, 462, 300, 276, 383, 292, 308, 325,
+ 283, 276, 293, 264, 372, 447, 346, 352, 340, 354, 274, 19, 363, 456, 281,
+ 426, 436, 425, 380, 381, 252, 267, 269, 393, 421, 200, 428, 371, 266, 329,
+ 432, 287, 422, 290, 250, 328, 385, 258, 384, 446, 265, 342, 386, 387, 257,
+ 422, 424, 430, 445, 342, 276, 422, 273, 424, 306, 292, 307, 352, 366, 345,
+ 268, 271, 302, 358, 423, 371, 327, 294, 460, 331, 279, 294, 303, 271, 304,
+ 436, 432, 427, 304, 272, 408, 395, 394, 431, 378, 395, 400, 296, 334, 299,
+ 6, 351, 168, 376, 352, 411, 307, 325, 320, 285, 295, 336, 320, 319, 404,
+ 329, 330, 349, 334, 293, 333, 366, 323, 447, 316, 15, 315, 331, 358, 279,
+ 317, 14, 316, 8, 285, 9, 277, 329, 350, 253, 374, 252, 319, 318, 403, 351,
+ 6, 419, 324, 318, 325, 397, 367, 365, 288, 435, 397, 278, 344, 439, 310,
+ 272, 311, 248, 195, 281, 375, 273, 291, 175, 396, 199, 312, 311, 268, 276,
+ 283, 445, 390, 373, 339, 295, 282, 296, 448, 449, 346, 356, 264, 454, 337,
+ 336, 299, 337, 338, 151, 294, 278, 455, 308, 292, 415, 429, 358, 355, 265,
+ 340, 372, 388, 390, 466, 352, 346, 280, 295, 442, 282, 354, 19, 370, 285,
+ 441, 295, 195, 248, 197, 457, 440, 274, 301, 300, 368, 417, 351, 465, 251,
+ 301, 389, 385, 380, 386, 394, 395, 379, 399, 412, 419, 410, 436, 322, 387,
+ 373, 388, 326, 2, 393, 354, 370, 461, 393, 164, 267, 268, 302, 12, 386, 374,
+ 387, 312, 268, 13, 298, 293, 301, 265, 446, 340, 380, 385, 381, 280, 330,
+ 425, 322, 426, 391, 420, 429, 437, 393, 391, 326, 344, 440, 438, 458, 459,
+ 461, 364, 434, 394, 428, 396, 262, 274, 354, 457, 317, 316, 402, 316, 315,
+ 403, 315, 314, 404, 314, 313, 405, 313, 421, 406, 323, 366, 361, 292, 306,
+ 407, 306, 291, 408, 291, 287, 409, 287, 432, 410, 427, 434, 411, 372, 264,
+ 383, 459, 309, 457, 366, 352, 401, 1, 274, 4, 418, 421, 262, 331, 294, 358,
+ 435, 433, 367, 392, 289, 439, 328, 462, 326, 94, 2, 370, 289, 305, 455, 339,
+ 254, 448, 359, 255, 446, 254, 253, 449, 253, 252, 450, 252, 256, 451, 256,
+ 341, 452, 414, 413, 463, 286, 441, 414, 286, 258, 441, 258, 257, 442, 257,
+ 259, 443, 259, 260, 444, 260, 467, 445, 309, 459, 250, 305, 289, 290, 305,
+ 290, 460, 401, 376, 435, 309, 250, 392, 376, 411, 433, 453, 341, 464, 357,
+ 453, 465, 343, 357, 412, 437, 343, 399, 344, 360, 440, 420, 437, 456, 360,
+ 420, 363, 361, 401, 288, 265, 372, 353, 390, 339, 249, 339, 448, 255];
diff --git a/src/voice/talk-controller.js b/src/voice/talk-controller.js
index 50c58eed5..4c1a74dfc 100644
--- a/src/voice/talk-controller.js
+++ b/src/voice/talk-controller.js
@@ -150,6 +150,15 @@ export class TalkController {
this._setState('idle');
}
+ /**
+ * Invalidate the cached voice lookup so the next turn re-checks the agent
+ * for a (possibly newly cloned) voice_id. Call after the user finishes a
+ * voice-clone flow inside the overlay.
+ */
+ refreshVoice() {
+ this._voicePromise = null;
+ }
+
// ── pipeline ─────────────────────────────────────────────────────────
async _handleTranscript(transcript) {
diff --git a/src/voice/talk-mode.js b/src/voice/talk-mode.js
index 8366becf3..12dec3c19 100644
--- a/src/voice/talk-mode.js
+++ b/src/voice/talk-mode.js
@@ -18,6 +18,7 @@
import { TalkScene } from './talk-scene.js';
import { AvatarMouthTarget } from './avatar-morph-target.js';
import { TalkController } from './talk-controller.js';
+import { openVoiceCloneModal } from './voice-clone-modal.js';
let activeSession = null;
diff --git a/src/voice/voice-clone-modal.js b/src/voice/voice-clone-modal.js
new file mode 100644
index 000000000..392550728
--- /dev/null
+++ b/src/voice/voice-clone-modal.js
@@ -0,0 +1,191 @@
+/**
+ * Voice-clone modal opened from inside Talk mode.
+ *
+ * Wraps the existing VoiceRecorder editor component in a modal shell so the
+ * avatar's owner can clone their voice in-place without leaving talk mode.
+ * On close, the caller is responsible for refreshing whichever cached voice
+ * lookup it has — typically TalkController.refreshVoice().
+ *
+ * The recorder POSTs to /api/agents/:id/voice/clone (existing endpoint, real
+ * ElevenLabs cloning, R2-cached, rate-limited 3/day). We don't reimplement
+ * the recording logic — only the modal chrome.
+ */
+
+import { VoiceRecorder } from '../editor/voice-recorder.js';
+
+let active = null;
+
+/**
+ * @param {object} opts
+ * @param {string} opts.agentId Required — voice is cloned against an agent.
+ * @param {string} [opts.agentName='Avatar']
+ * @param {() => void} [opts.onClose] Fires after the modal closes (clone or cancel).
+ */
+export function openVoiceCloneModal({ agentId, agentName = 'Avatar', onClose } = {}) {
+ if (!agentId) {
+ console.warn('[voice-clone] no agentId — owner has no linked agent yet');
+ return null;
+ }
+ if (active) return active; // single instance
+
+ injectStylesOnce();
+
+ const root = document.createElement('div');
+ root.className = 'tws-vcm-root';
+ root.innerHTML = `
+ <div class="tws-vcm-backdrop" data-ref="backdrop"></div>
+ <div class="tws-vcm-card" role="dialog" aria-modal="true" aria-labelledby="tws-vcm-title">
+ <div class="tws-vcm-head">
+ <div>
+ <div class="tws-vcm-eyebrow">three.ws</div>
+ <h2 class="tws-vcm-title" id="tws-vcm-title">Clone your voice</h2>
+ </div>
+ <button class="tws-vcm-close" data-ref="close" aria-label="Close">✕</button>
+ </div>
+ <p class="tws-vcm-help">
+ Read the line below at a natural pace for 30–60 seconds. Once cloned,
+ this avatar speaks in your voice everywhere on three.ws.
+ </p>
+ <div class="tws-vcm-script">
+ <em>"Hello, I'm building this avatar on three.ws. I want it to speak with my own voice
+ so it can hold a real conversation. I'll keep going for half a minute or so to give the
+ model enough material to learn from — the more natural intonation I use, the better the
+ clone will sound when it talks back."</em>
+ </div>
+ <div data-ref="recorder-host"></div>
+ </div>
+ `;
+ document.body.appendChild(root);
+ document.body.classList.add('tws-vcm-open');
+
+ const host = root.querySelector('[data-ref="recorder-host"]');
+ const recorder = new VoiceRecorder(host, { agentId, agentName });
+ recorder.mount();
+
+ const close = () => {
+ if (!active) return;
+ try {
+ recorder.destroy();
+ } catch {}
+ window.removeEventListener('keydown', onKey);
+ document.body.classList.remove('tws-vcm-open');
+ root.remove();
+ active = null;
+ try {
+ onClose?.();
+ } catch (err) {
+ console.warn('[voice-clone] onClose threw', err?.message);
+ }
+ };
+
+ const onKey = (e) => {
+ if (e.key === 'Escape') {
+ e.preventDefault();
+ close();
+ }
+ };
+ window.addEventListener('keydown', onKey);
+
+ root.querySelector('[data-ref="backdrop"]').addEventListener('click', close);
+ root.querySelector('[data-ref="close"]').addEventListener('click', close);
+
+ active = { close };
+ return active;
+}
+
+export function closeVoiceCloneModal() {
+ active?.close();
+}
+
+// ── styles ─────────────────────────────────────────────────────────────────
+
+function injectStylesOnce() {
+ if (document.getElementById('tws-vcm-css')) return;
+ const s = document.createElement('style');
+ s.id = 'tws-vcm-css';
+ s.textContent = `
+.tws-vcm-open { overflow: hidden; }
+.tws-vcm-root {
+ position: fixed; inset: 0; z-index: 10001;
+ display: grid; place-items: center;
+ padding: 24px;
+ animation: tws-vcm-in 180ms ease-out;
+}
+@keyframes tws-vcm-in { from { opacity: 0; } to { opacity: 1; } }
+.tws-vcm-backdrop {
+ position: absolute; inset: 0;
+ background: rgba(5, 5, 5, 0.78);
+ backdrop-filter: blur(6px);
+}
+.tws-vcm-card {
+ position: relative;
+ width: 100%;
+ max-width: 520px;
+ max-height: calc(100vh - 48px);
+ overflow-y: auto;
+ background: #0d0d0d;
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 16px;
+ padding: 22px 24px 20px;
+ color: #fafafa;
+ font-family: 'Inter', system-ui, sans-serif;
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
+}
+.tws-vcm-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 10px;
+}
+.tws-vcm-eyebrow {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 10px;
+ letter-spacing: 0.18em;
+ text-transform: uppercase;
+ color: #7dd3fc;
+ margin-bottom: 4px;
+}
+.tws-vcm-title {
+ margin: 0;
+ font-size: 22px;
+ font-weight: 700;
+ letter-spacing: -0.01em;
+ font-family: 'Space Grotesk', sans-serif;
+}
+.tws-vcm-close {
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ color: #fafafa;
+ width: 32px;
+ height: 32px;
+ border-radius: 999px;
+ cursor: pointer;
+ font-size: 13px;
+ font-family: inherit;
+ flex-shrink: 0;
+}
+.tws-vcm-close:hover {
+ background: rgba(255, 255, 255, 0.12);
+ border-color: rgba(255, 255, 255, 0.25);
+}
+.tws-vcm-help {
+ margin: 0 0 14px;
+ font-size: 13px;
+ line-height: 1.5;
+ color: #a1a1aa;
+}
+.tws-vcm-script {
+ background: rgba(125, 211, 252, 0.06);
+ border: 1px solid rgba(125, 211, 252, 0.18);
+ border-radius: 10px;
+ padding: 12px 14px;
+ font-size: 13px;
+ line-height: 1.55;
+ color: #d4d4d8;
+ margin-bottom: 16px;
+}
+.tws-vcm-script em { color: #fafafa; font-style: normal; }
+`;
+ document.head.appendChild(s);
+}
diff --git a/vercel.json b/vercel.json
index 60eb5ef79..3b07d9d38 100644
--- a/vercel.json
+++ b/vercel.json
@@ -320,6 +320,34 @@
"src": "/studio/(.*)",
"dest": "/studio/$1"
},
+ {
+ "src": "/demos",
+ "dest": "/demos/index.html"
+ },
+ {
+ "src": "/demos/",
+ "dest": "/demos/index.html"
+ },
+ {
+ "src": "/demos/(.*)\\.html",
+ "dest": "/demos/$1.html"
+ },
+ {
+ "src": "/demos/([^/.]+)",
+ "dest": "/demos/$1.html"
+ },
+ {
+ "src": "/demo/avatar-os",
+ "dest": "/demo/avatar-os/index.html"
+ },
+ {
+ "src": "/demo/avatar-os/",
+ "dest": "/demo/avatar-os/index.html"
+ },
+ {
+ "src": "/demo/avatar-os/(.*)",
+ "dest": "/demo/avatar-os/$1"
+ },
{
"src": "/api/dashboard/prefs",
"dest": "/api/dashboard/prefs"
@@ -741,40 +769,40 @@
"dest": "/api/pump/[action]?action=recent-graduations"
},
{
- "src": "/api/coin/state",
- "dest": "/api/coin/[action]?action=state"
+ "src": "/api/demo/coin/state",
+ "dest": "/api/demo/coin/[action]?action=state"
},
{
- "src": "/api/coin/holder",
- "dest": "/api/coin/[action]?action=holder"
+ "src": "/api/demo/coin/holder",
+ "dest": "/api/demo/coin/[action]?action=holder"
},
{
- "src": "/api/coin/history",
- "dest": "/api/coin/[action]?action=history"
+ "src": "/api/demo/coin/history",
+ "dest": "/api/demo/coin/[action]?action=history"
},
{
- "src": "/api/coin/events",
- "dest": "/api/coin/[action]?action=events"
+ "src": "/api/demo/coin/events",
+ "dest": "/api/demo/coin/[action]?action=events"
},
{
- "src": "/api/coin/winners",
- "dest": "/api/coin/[action]?action=winners"
+ "src": "/api/demo/coin/winners",
+ "dest": "/api/demo/coin/[action]?action=winners"
},
{
- "src": "/api/coin/holders",
- "dest": "/api/coin/[action]?action=holders"
+ "src": "/api/demo/coin/holders",
+ "dest": "/api/demo/coin/[action]?action=holders"
},
{
- "src": "/coin",
- "dest": "/coin/index.html"
+ "src": "/demo/coin",
+ "dest": "/demo/coin/index.html"
},
{
- "src": "/coin/",
- "dest": "/coin/index.html"
+ "src": "/demo/coin/",
+ "dest": "/demo/coin/index.html"
},
{
- "src": "/coin/([1-9A-HJ-NP-Za-km-z]{32,44})/?",
- "dest": "/coin/index.html"
+ "src": "/demo/coin/([1-9A-HJ-NP-Za-km-z]{32,44})/?",
+ "dest": "/demo/coin/index.html"
},
{
"src": "/api/avatars/presign",
diff --git a/vite.config.js b/vite.config.js
index 9bc2ad9d6..db9dccf94 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -164,6 +164,10 @@ const appConfig = {
'x402-stripe': resolve(__dirname, 'public/x402-stripe.html'),
'x402-dashboard': resolve(__dirname, 'public/dashboard/x402.html'),
sitemap: resolve(__dirname, 'public/sitemap/index.html'),
+ 'avatar-os-hub': resolve(__dirname, 'public/demo/avatar-os/index.html'),
+ 'avatar-os-studio': resolve(__dirname, 'public/demo/avatar-os/studio.html'),
+ 'avatar-os-selfie': resolve(__dirname, 'public/demo/avatar-os/selfie.html'),
+ 'avatar-os-combined': resolve(__dirname, 'public/demo/avatar-os/combined.html'),
},
},
},
@@ -241,6 +245,8 @@ const appConfig = {
'/strategy-lab/': resolve(root, 'public/strategy-lab.html'),
'/sitemap': resolve(root, 'public/sitemap/index.html'),
'/sitemap/': resolve(root, 'public/sitemap/index.html'),
+ '/demo/avatar-os': resolve(root, 'public/demo/avatar-os/index.html'),
+ '/demo/avatar-os/': resolve(root, 'public/demo/avatar-os/index.html'),
'/': resolve(root, 'home.html'),
'/home': resolve(root, 'home.html'),
'/features': resolve(root, 'features.html'),
@@ -265,6 +271,7 @@ const appConfig = {
'/discover',
'/gallery',
'/docs',
+ '/demo/avatar-os',
]);
server.middlewares.use(async (req, res, next) => {
const url = req.url || '/';
@@ -453,6 +460,15 @@ const appConfig = {
});
},
},
+ {
+ name: 'copy-blog',
+ closeBundle() {
+ const blogSrc = resolve(__dirname, 'blog');
+ if (existsSync(blogSrc)) {
+ cpSync(blogSrc, resolve(__dirname, 'dist/blog'), { recursive: true });
+ }
+ },
+ },
{
// Several static pages (dashboard, vanity-wallet, …) import ESM
// directly from `/src/*.js`. Vite's dev server serves these from