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: avatar studio demo, walk multiplayer sync, voice morph targets, review/create enhancements

nirholas3b5ffa106013
diff --git a/api/app-og.js b/api/app-og.js
new file mode 100644
index 000000000..1bf68f5d9
--- /dev/null
+++ b/api/app-og.js
@@ -0,0 +1,161 @@
+/**
+ * Server-rendered OG page for /app?agent=<id>
+ * -------------------------------------------
+ * GET /api/app-og?agent=<agentId>
+ *
+ * Wired via vercel.json: when a social crawler hits /app?agent=<uuid>,
+ * a "has" condition on User-Agent rewrites the request here. Returns
+ * a minimal HTML page with Open Graph + Twitter Card + oEmbed tags so
+ * the shared link shows the agent's name, description, and thumbnail.
+ *
+ * Real browsers never reach this route — the rewrite only fires for
+ * known bot User-Agents.
+ */
+
+import { sql } from './_lib/db.js';
+import { publicUrl } from './_lib/r2.js';
+import { env } from './_lib/env.js';
+import { cors, wrap } from './_lib/http.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
+
+ const url = new URL(req.url, 'http://x');
+ const agentId = url.searchParams.get('agent');
+
+ if (!agentId || !isUuid(agentId)) {
+ return passthrough(res);
+ }
+
+ const [agent] = await sql`
+ SELECT i.id, i.name, i.description, i.avatar_id, i.skills,
+ a.thumbnail_key AS avatar_thumbnail_key,
+ a.storage_key AS avatar_storage_key,
+ a.visibility AS avatar_visibility
+ FROM agent_identities i
+ LEFT JOIN avatars a ON a.id = i.avatar_id AND a.deleted_at IS NULL
+ WHERE i.id = ${agentId} AND i.deleted_at IS NULL
+ LIMIT 1
+ `;
+
+ if (!agent) return passthrough(res);
+
+ const origin = env.APP_ORIGIN || 'https://three.ws';
+ const pageUrl = `${origin}/app?agent=${agentId}`;
+ const title = agent.name || 'Agent';
+ const desc = agent.description || 'An embodied AI agent on three.ws — with a body, a place, and an identity.';
+
+ const thumbnailUrl = agent.avatar_thumbnail_key
+ ? publicUrl(agent.avatar_thumbnail_key)
+ : null;
+ const ogImage = thumbnailUrl
+ || `${origin}/api/agent/${agentId}/og`
+ || `${origin}/assets/og-image.png`;
+
+ const skills = agent.skills || [];
+ const skillText = skills.length
+ ? ` Skills: ${skills.slice(0, 5).join(', ')}${skills.length > 5 ? '…' : ''}.`
+ : '';
+ const fullDesc = desc + skillText;
+
+ res.statusCode = 200;
+ res.setHeader('content-type', 'text/html; charset=utf-8');
+ res.setHeader('cache-control', 'public, max-age=60, s-maxage=600, stale-while-revalidate=3600');
+ res.end(renderHtml({ title, desc: fullDesc, pageUrl, ogImage, origin, agentId }));
+});
+
+function passthrough(res) {
+ res.statusCode = 302;
+ res.setHeader('location', '/app');
+ res.setHeader('cache-control', 'no-cache');
+ res.end();
+}
+
+function renderHtml(p) {
+ const t = esc(p.title);
+ const d = esc(p.desc);
+ const spaUrl = `/app?agent=${p.agentId}`;
+ return `<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <title>${t} — three.ws</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
+ <meta name="description" content="${d}">
+ <meta name="theme-color" content="#06070a">
+
+ <meta property="og:type" content="profile">
+ <meta property="og:site_name" content="three.ws">
+ <meta property="og:title" content="${t} — three.ws">
+ <meta property="og:description" content="${d}">
+ <meta property="og:url" content="${esc(p.pageUrl)}">
+ <meta property="og:image" content="${esc(p.ogImage)}">
+ <meta property="og:image:width" content="1200">
+ <meta property="og:image:height" content="630">
+ <meta property="og:image:alt" content="${t} on three.ws">
+
+ <meta name="twitter:card" content="summary_large_image">
+ <meta name="twitter:title" content="${t} — three.ws">
+ <meta name="twitter:description" content="${d}">
+ <meta name="twitter:image" content="${esc(p.ogImage)}">
+ <meta name="twitter:creator" content="@nichxbt">
+
+ <meta property="fc:frame" content="vNext">
+ <meta property="fc:frame:image" content="${esc(p.ogImage)}">
+ <meta property="fc:frame:image:aspect_ratio" content="1.91:1">
+ <meta property="fc:frame:button:1" content="Meet ${t}">
+ <meta property="fc:frame:button:1:action" content="link">
+ <meta property="fc:frame:button:1:target" content="${esc(p.pageUrl)}">
+
+ <link rel="canonical" href="${esc(p.pageUrl)}">
+ <link rel="shortcut icon" href="/favicon.ico">
+
+ <style>
+ html,body{margin:0;padding:0;background:#06070a;color:#e0e0e0;font-family:Inter,system-ui,sans-serif;height:100%;overflow:hidden}
+ .shell{display:grid;place-items:center;height:100vh;text-align:center;padding:2rem;gap:1rem}
+ .shell a{color:#8b5cf6;text-decoration:none}
+ .shell a:hover{text-decoration:underline}
+ .spinner{width:32px;height:32px;border:2px solid rgba(255,255,255,0.1);border-top-color:#8b5cf6;border-radius:50%;animation:spin 1s linear infinite}
+ @keyframes spin{to{transform:rotate(360deg)}}
+ </style>
+</head>
+<body>
+ <noscript>
+ <div class="shell">
+ <h1>${t}</h1>
+ <p>${d}</p>
+ <p><a href="${esc(p.pageUrl)}">Open agent</a> · <a href="/discover">Browse agents</a></p>
+ </div>
+ </noscript>
+ <div class="shell" id="loading" aria-live="polite">
+ <div class="spinner" aria-hidden="true"></div>
+ <p>Loading ${t}…</p>
+ </div>
+ <script>(function(){window.location.replace(${JSON.stringify(spaUrl)});})()</script>
+ <script type="application/ld+json">
+${escJsonLd({
+ '@context': 'https://schema.org',
+ '@type': 'SoftwareApplication',
+ name: p.title,
+ description: p.desc,
+ url: p.pageUrl,
+ image: p.ogImage,
+ applicationCategory: 'AIApplication',
+ operatingSystem: 'Web',
+ provider: { '@type': 'Organization', name: 'three.ws', url: p.origin },
+})}
+ </script>
+</body>
+</html>`;
+}
+
+function isUuid(s) {
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(s));
+}
+function esc(s) {
+ return String(s).replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
+}
+function escJsonLd(obj) {
+ return JSON.stringify(obj, null, 2).replace(/</g, '\\u003c');
+}
diff --git a/multiplayer/src/rooms/WalkRoom.js b/multiplayer/src/rooms/WalkRoom.js
index 6b2269c26..fcc412826 100644
Binary files a/multiplayer/src/rooms/WalkRoom.js and b/multiplayer/src/rooms/WalkRoom.js differ
diff --git a/multiplayer/src/schemas.js b/multiplayer/src/schemas.js
index aaa9e5a11..dfb4b815e 100644
--- a/multiplayer/src/schemas.js
+++ b/multiplayer/src/schemas.js
@@ -17,6 +17,8 @@ export class Player extends Schema {
this.z = 0;
this.yaw = 0;
this.motion = 'idle'; // 'idle' | 'walk' | 'run'
+ this.emote = ''; // animation name or '' when not emoting
+ this.emoteTs = 0; // epoch ms when the emote was triggered
this.tsServer = 0; // server-side last-update epoch ms (for interpolation)
}
}
@@ -29,6 +31,8 @@ defineTypes(Player, {
z: 'float32',
yaw: 'float32',
motion: 'string',
+ emote: 'string',
+ emoteTs: 'float64',
tsServer: 'float64',
});
diff --git a/pages/app-next.html b/pages/app-next.html
index a330c0ed8..067deb179 100644
--- a/pages/app-next.html
+++ b/pages/app-next.html
@@ -246,6 +246,63 @@
<div class="nxt-stage-floor" aria-hidden="true"></div>
<div class="nxt-stage-vignette" aria-hidden="true"></div>
+ <!-- Visitor agent card — shown to unauthenticated visitors when ?agent= is present -->
+ <aside class="nxt-visitor-card" id="nxt-visitor-card" hidden>
+ <div class="nxt-visitor-card__inner">
+ <div class="nxt-visitor-card__head">
+ <div class="nxt-visitor-card__avatar" id="nxt-visitor-avatar">
+ <div class="nxt-visitor-card__avatar-shimmer"></div>
+ </div>
+ <div class="nxt-visitor-card__info">
+ <h2 class="nxt-visitor-card__name" id="nxt-visitor-name"></h2>
+ <div class="nxt-visitor-card__status">
+ <span class="nxt-visitor-card__dot"></span>
+ <span id="nxt-visitor-status">Online</span>
+ </div>
+ </div>
+ </div>
+ <p class="nxt-visitor-card__desc" id="nxt-visitor-desc"></p>
+ <div class="nxt-visitor-card__skills" id="nxt-visitor-skills" hidden></div>
+ <div class="nxt-visitor-card__actions">
+ <a class="nxt-visitor-card__btn nxt-visitor-card__btn--primary" href="/register">Create your own agent</a>
+ <button class="nxt-visitor-card__btn nxt-visitor-card__btn--share" id="nxt-visitor-share" type="button">
+ <svg viewBox="0 0 16 16" width="13" height="13" aria-hidden="true">
+ <circle cx="4" cy="8" r="1.6" stroke="currentColor" stroke-width="1.4" fill="none" />
+ <circle cx="12" cy="3.5" r="1.6" stroke="currentColor" stroke-width="1.4" fill="none" />
+ <circle cx="12" cy="12.5" r="1.6" stroke="currentColor" stroke-width="1.4" fill="none" />
+ <path d="M5.4 7.2l5.2-3M5.4 8.8l5.2 3" stroke="currentColor" stroke-width="1.4" fill="none" />
+ </svg>
+ Share
+ </button>
+ </div>
+ </div>
+ </aside>
+
+ <!-- Mobile agent info strip — compact bar visible on small screens for agent pages -->
+ <div class="nxt-mobile-agent-strip" id="nxt-mobile-agent-strip" hidden>
+ <div class="nxt-mobile-agent-strip__avatar" id="nxt-mobile-avatar">
+ <span class="nxt-mobile-agent-strip__dot"></span>
+ </div>
+ <div class="nxt-mobile-agent-strip__info">
+ <span class="nxt-mobile-agent-strip__name" id="nxt-mobile-name"></span>
+ <span class="nxt-mobile-agent-strip__desc" id="nxt-mobile-desc"></span>
+ </div>
+ <button class="nxt-mobile-agent-strip__share" id="nxt-mobile-share" type="button" aria-label="Share agent">
+ <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true">
+ <circle cx="4" cy="8" r="1.6" stroke="currentColor" stroke-width="1.4" fill="none" />
+ <circle cx="12" cy="3.5" r="1.6" stroke="currentColor" stroke-width="1.4" fill="none" />
+ <circle cx="12" cy="12.5" r="1.6" stroke="currentColor" stroke-width="1.4" fill="none" />
+ <path d="M5.4 7.2l5.2-3M5.4 8.8l5.2 3" stroke="currentColor" stroke-width="1.4" fill="none" />
+ </svg>
+ </button>
+ </div>
+
+ <!-- Loading poster skeleton — shown when no thumbnail is available during load -->
+ <div class="nxt-poster-skeleton" id="nxt-poster-skeleton" hidden aria-hidden="true">
+ <div class="nxt-poster-skeleton__silhouette"></div>
+ <div class="nxt-poster-skeleton__shimmer"></div>
+ </div>
+
<!-- Live agent chat reply — speech-bubble style above the avatar -->
<div class="nxt-agent-bubble" id="nxt-agent-bubble" hidden>
<div class="nxt-agent-bubble__inner">
@@ -407,6 +464,21 @@
</label>
<p class="nxt-share-hint">Drop the snippet on any site. Same agent, same animations, same identity — embedded.</p>
+ <div class="nxt-share-social" id="nxt-share-social">
+ <span class="nxt-share-label">Share on</span>
+ <div class="nxt-share-social__row">
+ <button class="nxt-share-social__btn" id="nxt-share-twitter" type="button" title="Share on X / Twitter">
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
+ </button>
+ <button class="nxt-share-social__btn" id="nxt-share-farcaster" type="button" title="Share on Farcaster">
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M5.362 2h13.276v2.227h-1.554l.685 2.226H19.2l-.685 2.227h-.685v10.548c0 .37-.146.724-.407.985a1.394 1.394 0 01-.984.407h-.068c-.37 0-.724-.147-.985-.407a1.394 1.394 0 01-.407-.985v-5.82a2.786 2.786 0 00-2.786-2.786h-.396a2.786 2.786 0 00-2.786 2.786v5.82c0 .37-.147.724-.407.985a1.394 1.394 0 01-.985.407h-.068c-.37 0-.724-.147-.985-.407a1.394 1.394 0 01-.407-.985V8.68h-.685L5.8 6.453h1.43l.686-2.226H6.362z"/></svg>
+ </button>
+ <button class="nxt-share-social__btn" id="nxt-share-telegram" type="button" title="Share on Telegram">
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.479.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>
+ </button>
+ </div>
+ </div>
+
<div class="nxt-share-divider" id="nxt-share-deploy-divider" hidden role="presentation"></div>
<a
class="nxt-share-deploy"
diff --git a/pages/avatar-studio-demo.html b/pages/avatar-studio-demo.html
new file mode 100644
index 000000000..e24985352
--- /dev/null
+++ b/pages/avatar-studio-demo.html
@@ -0,0 +1,74 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Avatar Studio · three.ws</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="Create and customize 3D avatars — face sculpting, body morphs, outfits, and accessories. No third-party dependency." />
+ <meta name="theme-color" content="#000000" />
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/mobile.css" />
+ <link rel="stylesheet" href="/avatar-studio-demo.css" />
+ </head>
+ <body>
+ <!-- ── Header ──────────────────────────────────────────── -->
+ <header class="as-bar">
+ <a href="/" class="as-logo" aria-label="three.ws home">
+ <img src="/three-ws-icon.svg" alt="" width="28" height="28" />
+ <span>Avatar Studio</span>
+ </a>
+ <div class="as-bar-actions">
+ <button class="as-btn as-btn-ghost" type="button" id="as-reset-all" title="Reset everything to default">Reset</button>
+ <button class="as-btn as-btn-primary" type="button" id="as-export" title="Download avatar as .glb">Export GLB</button>
+ </div>
+ </header>
+
+ <!-- ── Main layout ─────────────────────────────────────── -->
+ <main class="as-main">
+ <!-- 3D viewport -->
+ <section class="as-viewport" id="as-viewport">
+ <div class="as-viewport-loader" id="as-viewport-loader">
+ <div class="as-spinner"></div>
+ <span>Loading avatar…</span>
+ </div>
+ <!-- Camera presets -->
+ <div class="as-cam-bar" id="as-cam-bar">
+ <button class="as-cam-btn active" type="button" data-preset="full" title="Full body">Full</button>
+ <button class="as-cam-btn" type="button" data-preset="head" title="Head closeup">Head</button>
+ <button class="as-cam-btn" type="button" data-preset="tight" title="Tight portrait">Portrait</button>
+ </div>
+ <!-- Animation controls -->
+ <div class="as-anim-bar" id="as-anim-bar">
+ <select class="as-anim-select" id="as-anim-select" title="Preview animation">
+ <option value="">Idle</option>
+ </select>
+ </div>
+ </section>
+
+ <!-- Side panel -->
+ <aside class="as-panel" id="as-panel">
+ <!-- Tabs -->
+ <nav class="as-tabs" id="as-tabs" role="tablist">
+ <button class="as-tab active" role="tab" aria-selected="true" data-tab="outfit">Outfits</button>
+ <button class="as-tab" role="tab" aria-selected="false" data-tab="hat">Hats</button>
+ <button class="as-tab" role="tab" aria-selected="false" data-tab="glasses">Glasses</button>
+ <button class="as-tab" role="tab" aria-selected="false" data-tab="earrings">Earrings</button>
+ <button class="as-tab" role="tab" aria-selected="false" data-tab="sculpt">Sculpt</button>
+ </nav>
+
+ <!-- Active chips -->
+ <div class="as-chips" id="as-chips"></div>
+
+ <!-- Tab content -->
+ <div class="as-tab-content" id="as-tab-content"></div>
+
+ <!-- Status -->
+ <div class="as-status" id="as-status"></div>
+ </aside>
+ </main>
+
+ <script type="module" src="/src/avatar-studio-demo.js"></script>
+ </body>
+</html>
diff --git a/pages/create-review.html b/pages/create-review.html
index eb7042e9a..a10739b23 100644
--- a/pages/create-review.html
+++ b/pages/create-review.html
@@ -133,6 +133,47 @@
@keyframes fmSheet { from { transform: translateY(20px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.fm-head h3 { font-size: 17px; }
.fm-head p { font-size: 12.5px; }
+
+ /* Flow diagram: stack vertically on mobile */
+ .fm-flow {
+ flex-direction: column;
+ align-items: stretch;
+ gap: 0;
+ padding: 14px;
+ }
+ .fm-flow-step {
+ flex-direction: row;
+ align-items: center;
+ text-align: left;
+ gap: 10px;
+ padding: 4px 0;
+ }
+ .fm-flow-detail { max-width: none; }
+ .fm-flow-badge { margin-top: 0; margin-left: auto; }
+ .fm-flow-connector {
+ width: auto;
+ height: 20px;
+ justify-content: flex-start;
+ padding-left: 12px;
+ }
+ .fm-flow-line {
+ width: 1.5px;
+ height: 100%;
+ background: linear-gradient(180deg, var(--border) 0%, rgba(214, 255, 61, 0.3) 50%, var(--border) 100%);
+ }
+ .fm-flow-pulse {
+ animation: flowPulseMobile 2.4s ease-in-out infinite;
+ }
+ @keyframes flowPulseMobile {
+ 0%, 100% { transform: translateY(-8px); opacity: 0; }
+ 15% { opacity: 1; }
+ 85% { opacity: 1; }
+ 100% { transform: translateY(8px); opacity: 0; }
+ }
+
+ .fm-pricing-row { padding: 8px 12px; font-size: 12px; }
+ .fm-pricing-head { padding: 9px 12px; }
+ .fm-pricing-foot { padding: 7px 12px; }
}
.viewer {
@@ -588,7 +629,7 @@
color: var(--muted);
line-height: 1.45;
}
- .fm-note code, .fm-bullets code, .fm-handshake code {
+ .fm-note code, .fm-bullets code, .fm-flow-detail code {
background: rgba(255, 255, 255, 0.06);
border: 1px solid var(--border);
border-radius: 4px;
@@ -649,16 +690,48 @@
rgba(255, 255, 255, 0.025);
border: 1px solid var(--border);
border-radius: 12px;
- padding: 14px 16px;
+ padding: 16px;
display: flex;
flex-direction: column;
- gap: 12px;
+ gap: 14px;
+ }
+ .fm-id-card-top {
+ display: flex;
+ align-items: flex-start;
+ gap: 14px;
+ }
+ .fm-id-avatar {
+ width: 64px;
+ height: 64px;
+ border-radius: 10px;
+ object-fit: cover;
+ border: 1px solid var(--border);
+ background: #0a0b12;
+ flex-shrink: 0;
+ }
+ .fm-id-avatar--fallback {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 22px;
+ font-weight: 700;
+ color: var(--muted);
+ background:
+ linear-gradient(135deg, rgba(153, 69, 255, 0.15) 0%, rgba(214, 255, 61, 0.08) 100%),
+ #0a0b12;
+ }
+ .fm-id-card-top-right {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
}
.fm-id-head {
display: flex;
align-items: center;
justify-content: space-between;
- gap: 12px;
+ gap: 10px;
}
.fm-id-chain {
font-size: 11px;
@@ -674,7 +747,7 @@
width: 5px;
height: 5px;
border-radius: 50%;
- background: #9945FF; /* Solana purple */
+ background: #9945FF;
box-shadow: 0 0 6px rgba(153, 69, 255, 0.6);
}
.fm-id-pill {
@@ -693,92 +766,262 @@
border-color: var(--border);
}
.fm-id-card[data-state='error'] .fm-id-pill { color: #ffb3b3; border-color: rgba(255, 92, 92, 0.4); background: rgba(255, 92, 92, 0.08); }
- .fm-id-addr {
- font-family: ui-monospace, 'SF Mono', monospace;
+ .fm-id-meta {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 10px;
font-size: 12px;
- color: var(--text);
- word-break: break-all;
+ }
+ .fm-id-meta > div { display: flex; flex-direction: column; gap: 2px; }
+ .fm-id-meta .muted { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
+ .fm-id-meta strong { font-size: 13px; font-weight: 600; }
+ .fm-id-addr-link {
+ display: flex;
+ align-items: center;
+ gap: 10px;
background: #07080d;
border: 1px solid var(--border);
border-radius: 8px;
padding: 10px 12px;
- min-height: 36px;
+ text-decoration: none;
+ transition: border-color 0.15s, background 0.15s;
+ cursor: pointer;
}
- .fm-id-card[data-state='loading'] .fm-id-addr {
- color: var(--muted);
+ .fm-id-addr-link:hover,
+ .fm-id-addr-link:focus-visible {
+ border-color: rgba(153, 69, 255, 0.5);
+ background: rgba(153, 69, 255, 0.06);
+ }
+ .fm-id-addr-link:focus-visible { outline: 2px solid rgba(153, 69, 255, 0.5); outline-offset: 2px; }
+ .fm-id-addr {
+ font-family: ui-monospace, 'SF Mono', monospace;
+ font-size: 12px;
+ color: var(--text);
+ word-break: break-all;
+ flex: 1;
+ min-width: 0;
+ }
+ .fm-id-explorer-hint {
+ font-size: 11px;
+ color: #9945FF;
+ white-space: nowrap;
+ flex-shrink: 0;
+ opacity: 0.7;
+ transition: opacity 0.15s;
+ }
+ .fm-id-addr-link:hover .fm-id-explorer-hint { opacity: 1; }
+ .fm-id-card[data-state='loading'] .fm-id-addr-link { pointer-events: none; }
+ .fm-id-card[data-state='loading'] .fm-id-addr { color: var(--muted); }
+ .fm-id-card[data-state='loading'] .fm-id-explorer-hint { display: none; }
+ .fm-id-card[data-state='loading'] .fm-id-addr-link {
background: repeating-linear-gradient(110deg, rgba(255,255,255,0.02) 0 12px, transparent 12px 24px);
background-size: 200% 100%;
animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { from { background-position: 0 0; } to { background-position: -200% 0; } }
- .fm-id-meta {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: 12px;
- font-size: 12px;
- }
- .fm-id-meta > div { display: flex; flex-direction: column; gap: 2px; }
- .fm-id-meta .muted { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
- .fm-id-meta strong { font-size: 13px; font-weight: 600; }
- .fm-id-copy {
- align-self: flex-start;
+ .fm-id-sample-note {
+ font-size: 11px;
+ color: var(--muted);
margin: 0;
- position: static;
+ line-height: 1.4;
+ padding: 0 2px;
+ }
+ @media (max-width: 560px) {
+ .fm-id-card { padding: 14px; gap: 12px; }
+ .fm-id-card-top { gap: 12px; }
+ .fm-id-avatar { width: 52px; height: 52px; border-radius: 8px; }
+ .fm-id-meta { gap: 8px; }
+ .fm-id-addr { font-size: 11px; }
+ .fm-id-explorer-hint { font-size: 10px; }
+ .fm-id-addr-link { padding: 8px 10px; gap: 8px; }
}
- .fm-id-copy:disabled { opacity: 0.4; cursor: not-allowed; }
- /* ── x402 handshake strip ──────────────────────────────────────── */
- .fm-handshake {
- display: grid;
- grid-template-columns: 1fr auto 1fr auto 1fr;
- gap: 6px;
+ /* ── x402 flow diagram ─────────────────────────────────────────── */
+ .fm-flow {
+ display: flex;
align-items: stretch;
- background: rgba(255, 255, 255, 0.025);
+ gap: 0;
+ background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--border);
border-radius: 12px;
- padding: 12px;
+ padding: 16px 14px;
}
- .fm-handshake-step {
+ .fm-flow-step {
+ flex: 1;
display: flex;
- align-items: flex-start;
- gap: 8px;
- font-size: 12px;
+ flex-direction: column;
+ align-items: center;
+ gap: 6px;
+ text-align: center;
min-width: 0;
}
- .fm-handshake-step > div { min-width: 0; }
- .fm-handshake-step strong { font-size: 12.5px; font-weight: 600; display: block; }
- .fm-handshake-step .muted { font-size: 11px; line-height: 1.35; display: block; margin-top: 2px; }
- .fm-handshake-num {
- width: 18px;
- height: 18px;
+ .fm-flow-num {
+ width: 26px;
+ height: 26px;
border-radius: 50%;
- background: rgba(214, 255, 61, 0.15);
+ background: rgba(214, 255, 61, 0.12);
+ border: 1.5px solid rgba(214, 255, 61, 0.25);
color: var(--accent);
- font-size: 11px;
- font-weight: 600;
+ font-size: 12px;
+ font-weight: 700;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
- .fm-handshake-code {
- font-family: ui-monospace, monospace;
+ .fm-flow-step--mid .fm-flow-num {
+ background: rgba(255, 190, 60, 0.12);
+ border-color: rgba(255, 190, 60, 0.3);
+ color: #ffbe3c;
+ }
+ .fm-flow-step--end .fm-flow-num {
+ background: rgba(40, 200, 64, 0.12);
+ border-color: rgba(40, 200, 64, 0.3);
+ color: #28c840;
+ }
+ .fm-flow-label {
+ font-size: 13px;
+ font-weight: 600;
+ color: var(--text);
+ }
+ .fm-flow-detail {
+ font-size: 11px;
+ line-height: 1.4;
+ color: var(--muted);
+ max-width: 140px;
+ }
+ .fm-flow-detail code {
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid var(--border);
+ border-radius: 4px;
+ padding: 0 4px;
+ font-size: 0.92em;
+ font-family: ui-monospace, 'SF Mono', monospace;
+ color: var(--text);
+ }
+ .fm-flow-badge {
+ font-family: ui-monospace, 'SF Mono', monospace;
font-size: 10px;
+ font-weight: 600;
color: var(--muted);
background: #07080d;
border: 1px solid var(--border);
border-radius: 5px;
- padding: 1px 5px;
- align-self: flex-start;
- margin-left: auto;
+ padding: 2px 8px;
+ margin-top: auto;
+ }
+ .fm-flow-badge--warn {
+ color: #ffbe3c;
+ border-color: rgba(255, 190, 60, 0.35);
+ background: rgba(255, 190, 60, 0.08);
+ }
+ .fm-flow-badge--ok {
+ color: #28c840;
+ border-color: rgba(40, 200, 64, 0.35);
+ background: rgba(40, 200, 64, 0.08);
+ }
+ .fm-flow-connector {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 32px;
flex-shrink: 0;
+ position: relative;
+ }
+ .fm-flow-line {
+ width: 100%;
+ height: 1.5px;
+ background: linear-gradient(90deg, var(--border) 0%, rgba(214, 255, 61, 0.3) 50%, var(--border) 100%);
+ }
+ .fm-flow-pulse {
+ position: absolute;
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: var(--accent);
+ box-shadow: 0 0 8px rgba(214, 255, 61, 0.5);
+ animation: flowPulse 2.4s ease-in-out infinite;
+ }
+ @keyframes flowPulse {
+ 0%, 100% { transform: translateX(-12px); opacity: 0; }
+ 15% { opacity: 1; }
+ 85% { opacity: 1; }
+ 100% { transform: translateX(12px); opacity: 0; }
}
- .fm-handshake-arrow {
+
+ /* ── Pricing preview card ─────────────────────────────────────── */
+ .fm-pricing-preview {
+ background:
+ linear-gradient(135deg, rgba(214, 255, 61, 0.04) 0%, rgba(106, 92, 255, 0.04) 100%),
+ rgba(255, 255, 255, 0.02);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ overflow: hidden;
+ }
+ .fm-pricing-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ padding: 10px 14px;
+ border-bottom: 1px solid var(--border);
+ }
+ .fm-pricing-title {
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--text);
+ letter-spacing: 0.01em;
+ }
+ .fm-pricing-pill {
+ font-size: 9px;
color: var(--muted);
- font-size: 14px;
- align-self: center;
- opacity: 0.5;
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid var(--border);
+ border-radius: 999px;
+ padding: 2px 8px;
+ letter-spacing: 0.05em;
+ text-transform: uppercase;
+ }
+ .fm-pricing-rows {
+ display: flex;
+ flex-direction: column;
+ }
+ .fm-pricing-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 9px 14px;
+ font-size: 12.5px;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.03);
+ }
+ .fm-pricing-row:last-child { border-bottom: none; }
+ .fm-pricing-skill {
+ color: var(--text);
+ font-weight: 500;
}
+ .fm-pricing-amount {
+ font-family: ui-monospace, 'SF Mono', monospace;
+ font-size: 12px;
+ color: var(--accent);
+ font-weight: 600;
+ }
+ .fm-pricing-amount .muted {
+ font-weight: 400;
+ font-family: inherit;
+ }
+ .fm-pricing-foot {
+ padding: 8px 14px;
+ font-size: 11px;
+ color: var(--muted);
+ border-top: 1px solid var(--border);
+ background: rgba(255, 255, 255, 0.015);
+ }
+
+ /* ── Syntax highlighting (code blocks) ────────────────────────── */
+ .fm-code--highlighted pre { color: #cdd; }
+ .syn-comment { color: #6a6d82; font-style: italic; }
+ .syn-keyword { color: #c792ea; }
+ .syn-string { color: #c3e88d; }
/* ── Browser-chrome iframe preview ─────────────────────────────── */
.fm-browser {
diff --git a/pages/create.html b/pages/create.html
index 4f7d0453a..ad63d2ee8 100644
--- a/pages/create.html
+++ b/pages/create.html
@@ -745,14 +745,14 @@
<path d="M18 3l3 3-9 9-4 1 1-4 9-9z" />
</svg>
</div>
- <h2 class="card-title">Start with a template</h2>
+ <h2 class="card-title">Avatar Studio</h2>
</div>
<p class="card-subtitle">
- Pick a ready-made character and customize it in our web editor. No
- download required.
+ Build a custom avatar from scratch. Sculpt face and body, pick
+ outfits, add accessories — all in your browser.
</p>
<span class="card-cta">
- Open editor
+ Open studio
<svg
width="13"
height="13"
diff --git a/pages/walk.html b/pages/walk.html
index 2a7c5f91e..ce448190c 100644
--- a/pages/walk.html
+++ b/pages/walk.html
@@ -119,7 +119,7 @@
#walk-hud {
position: fixed;
- top: env(safe-area-inset-top, 0);
+ top: calc(env(safe-area-inset-top, 0) + 56px);
left: 0;
right: 0;
z-index: 4;
@@ -407,6 +407,224 @@
font-weight: 700;
}
+ /* ── Site header (glass overlay) ───────────────────────────── */
+ .walk-site-header {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ z-index: 10;
+ display: flex;
+ align-items: center;
+ padding: 0 24px;
+ height: 52px;
+ background: rgba(10, 10, 10, 0.55);
+ backdrop-filter: blur(16px);
+ -webkit-backdrop-filter: blur(16px);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
+ }
+ .walk-site-header h1 { margin: 0; font-size: inherit; font-weight: inherit; line-height: inherit; }
+ .walk-site-header a { color: var(--text); text-decoration: none; }
+
+ /* ── Loading overlay ───────────────────────────────────────── */
+ .walk-loading {
+ position: fixed;
+ inset: 0;
+ z-index: 9;
+ background: var(--bg);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ transition: opacity 0.4s ease;
+ }
+ .walk-loading.is-done {
+ opacity: 0;
+ pointer-events: none;
+ }
+ .walk-loading-inner {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 20px;
+ }
+ .walk-loading-spinner {
+ width: 40px;
+ height: 40px;
+ border: 2.5px solid rgba(255, 255, 255, 0.08);
+ border-top-color: var(--accent);
+ border-radius: 50%;
+ animation: walk-spin 0.8s linear infinite;
+ }
+ @keyframes walk-spin { to { transform: rotate(360deg); } }
+ .walk-loading-text {
+ margin: 0;
+ color: var(--text-2);
+ font-size: 14px;
+ font-weight: 500;
+ letter-spacing: 0.02em;
+ }
+
+ /* ── Name input ────────────────────────────────────────────── */
+ .walk-identity-row {
+ margin-bottom: 4px;
+ }
+ .walk-name-input {
+ background: transparent;
+ border: none;
+ border-bottom: 1.5px solid rgba(255, 255, 255, 0.12);
+ color: var(--text);
+ font: 600 15px/1.3 inherit;
+ padding: 2px 0 4px;
+ width: 100%;
+ max-width: 180px;
+ outline: none;
+ transition: border-color 0.15s;
+ }
+ .walk-name-input:focus {
+ border-color: var(--accent);
+ }
+ .walk-name-input::placeholder {
+ color: var(--text-2);
+ font-weight: 400;
+ }
+
+ /* ── Players panel ─────────────────────────────────────────── */
+ .walk-players-panel {
+ position: fixed;
+ z-index: 6;
+ top: calc(env(safe-area-inset-top, 0) + 68px);
+ right: 16px;
+ width: 220px;
+ max-height: 60vh;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ backdrop-filter: blur(12px);
+ -webkit-backdrop-filter: blur(12px);
+ overflow: hidden;
+ animation: walk-panel-in 0.18s ease;
+ }
+ @keyframes walk-panel-in {
+ from { opacity: 0; transform: translateY(-8px); }
+ to { opacity: 1; transform: none; }
+ }
+ .walk-players-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 10px 14px;
+ font-size: 12px;
+ font-weight: 600;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: var(--text-2);
+ border-bottom: 1px solid var(--border);
+ }
+ .walk-players-header button {
+ background: none;
+ border: none;
+ color: var(--text-2);
+ cursor: pointer;
+ font-size: 18px;
+ line-height: 1;
+ padding: 0 2px;
+ }
+ .walk-players-header button:hover { color: var(--text); }
+ .walk-players-list {
+ list-style: none;
+ margin: 0;
+ padding: 6px 0;
+ overflow-y: auto;
+ max-height: calc(60vh - 44px);
+ }
+ .walk-players-list li {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 7px 14px;
+ font-size: 13px;
+ color: var(--text);
+ }
+ .walk-players-list .player-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ flex-shrink: 0;
+ }
+ .walk-players-list .player-motion {
+ margin-left: auto;
+ font-size: 11px;
+ color: var(--text-2);
+ }
+ .walk-players-list li.is-you {
+ color: var(--accent);
+ }
+
+ /* ── Emote tray ────────────────────────────────────────────── */
+ .walk-emote-tray {
+ position: fixed;
+ z-index: 5;
+ right: 16px;
+ bottom: calc(28px + env(safe-area-inset-bottom, 0));
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ align-items: flex-end;
+ }
+ .walk-emote-btn {
+ appearance: none;
+ width: 44px;
+ height: 44px;
+ border-radius: 50%;
+ border: 1px solid var(--border);
+ background: var(--panel);
+ backdrop-filter: blur(10px);
+ -webkit-backdrop-filter: blur(10px);
+ cursor: pointer;
+ font-size: 20px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ transition: transform 0.1s, border-color 0.1s, background 0.1s;
+ position: relative;
+ }
+ .walk-emote-btn:hover {
+ border-color: rgba(255, 255, 255, 0.2);
+ background: rgba(34, 34, 34, 0.85);
+ transform: scale(1.08);
+ }
+ .walk-emote-btn:active { transform: scale(0.95); }
+ .walk-emote-btn[aria-pressed="true"] {
+ border-color: var(--accent);
+ background: rgba(125, 211, 252, 0.18);
+ }
+ .walk-emote-btn .emote-label {
+ position: absolute;
+ right: calc(100% + 8px);
+ top: 50%;
+ transform: translateY(-50%);
+ font-size: 11px;
+ color: var(--text-2);
+ white-space: nowrap;
+ pointer-events: none;
+ opacity: 0;
+ transition: opacity 0.15s;
+ }
+ .walk-emote-btn:hover .emote-label { opacity: 1; }
+
+ @media (hover: none), (max-width: 640px) {
+ .walk-emote-tray {
+ right: auto;
+ left: 50%;
+ transform: translateX(-50%);
+ bottom: calc(180px + env(safe-area-inset-bottom, 0));
+ flex-direction: row;
+ gap: 8px;
+ }
+ .walk-emote-btn { width: 40px; height: 40px; font-size: 18px; }
+ .walk-emote-btn .emote-label { display: none; }
+ }
+
/* ── Recording UI ──────────────────────────────────────────── */
#walk-record-btn .dot { transition: background 0.15s ease, box-shadow 0.15s ease; }
#walk-record-btn[data-recording="true"] .dot {
diff --git a/public/avatar-studio-demo.css b/public/avatar-studio-demo.css
new file mode 100644
index 000000000..d143f0019
--- /dev/null
+++ b/public/avatar-studio-demo.css
@@ -0,0 +1,687 @@
+/* ── Avatar Studio Demo ─────────────────────────────────────────────────── */
+
+:root {
+ --as-bg: #050505;
+ --as-panel-bg: #0c0c0c;
+ --as-panel-2: #141414;
+ --as-border: #1c1c1c;
+ --as-border-2: #282828;
+ --as-text: #f5f5f5;
+ --as-text-2: #a1a1aa;
+ --as-text-3: #71717a;
+ --as-accent: #7dd3fc;
+ --as-accent-hover: #bae6fd;
+ --as-success: #34d399;
+ --as-danger: #f43f5e;
+ --as-radius: 12px;
+ --as-radius-sm: 8px;
+ --as-transition: 180ms ease;
+}
+
+html, body {
+ margin: 0;
+ padding: 0;
+ background: var(--as-bg);
+ color: var(--as-text);
+ font-family: 'Inter', system-ui, -apple-system, sans-serif;
+ -webkit-font-smoothing: antialiased;
+ overflow: hidden;
+ height: 100%;
+}
+
+/* ── Header bar ───────────────────────────────────────────────────────────── */
+
+.as-bar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0 20px;
+ height: 56px;
+ border-bottom: 1px solid var(--as-border);
+ background: rgba(5, 5, 5, 0.9);
+ backdrop-filter: blur(12px);
+ flex-shrink: 0;
+}
+
+.as-logo {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ text-decoration: none;
+ color: var(--as-text);
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 15px;
+ font-weight: 600;
+ letter-spacing: -0.02em;
+}
+.as-logo img { border-radius: 6px; }
+
+.as-bar-actions {
+ display: flex;
+ gap: 8px;
+}
+
+/* ── Buttons ──────────────────────────────────────────────────────────────── */
+
+.as-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 7px 16px;
+ border-radius: var(--as-radius-sm);
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all var(--as-transition);
+ border: 1px solid transparent;
+ line-height: 1.4;
+}
+.as-btn:disabled {
+ opacity: 0.4;
+ pointer-events: none;
+}
+
+.as-btn-ghost {
+ background: transparent;
+ border-color: var(--as-border-2);
+ color: var(--as-text-2);
+}
+.as-btn-ghost:hover {
+ border-color: var(--as-text-3);
+ color: var(--as-text);
+}
+
+.as-btn-primary {
+ background: var(--as-accent);
+ color: #0a0a0a;
+ font-weight: 600;
+}
+.as-btn-primary:hover {
+ background: var(--as-accent-hover);
+}
+
+.as-btn-sm {
+ padding: 4px 10px;
+ font-size: 12px;
+}
+
+/* ── Main layout ──────────────────────────────────────────────────────────── */
+
+.as-main {
+ display: grid;
+ grid-template-columns: 1fr 380px;
+ flex: 1;
+ min-height: 0;
+ height: calc(100vh - 57px);
+}
+
+/* ── 3D viewport ──────────────────────────────────────────────────────────── */
+
+.as-viewport {
+ position: relative;
+ background: var(--as-bg);
+ overflow: hidden;
+}
+
+.as-viewport canvas {
+ display: block;
+ width: 100%;
+ height: 100%;
+}
+
+.as-viewport-loader {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 14px;
+ color: var(--as-text-2);
+ font-size: 13px;
+ z-index: 5;
+ transition: opacity 300ms ease;
+}
+.as-viewport-loader.hidden {
+ opacity: 0;
+ pointer-events: none;
+}
+
+.as-spinner {
+ width: 28px;
+ height: 28px;
+ border: 2px solid var(--as-border-2);
+ border-top-color: var(--as-accent);
+ border-radius: 50%;
+ animation: as-spin 0.8s linear infinite;
+}
+@keyframes as-spin { to { transform: rotate(360deg); } }
+
+/* Camera preset bar */
+.as-cam-bar {
+ position: absolute;
+ bottom: 16px;
+ left: 50%;
+ transform: translateX(-50%);
+ display: flex;
+ gap: 4px;
+ background: rgba(10, 10, 10, 0.75);
+ backdrop-filter: blur(8px);
+ border: 1px solid var(--as-border);
+ border-radius: var(--as-radius);
+ padding: 4px;
+ z-index: 4;
+}
+.as-cam-btn {
+ padding: 5px 14px;
+ border: none;
+ border-radius: var(--as-radius-sm);
+ background: transparent;
+ color: var(--as-text-3);
+ font-size: 12px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all var(--as-transition);
+}
+.as-cam-btn:hover { color: var(--as-text-2); }
+.as-cam-btn.active {
+ background: var(--as-border-2);
+ color: var(--as-text);
+}
+
+/* Animation select */
+.as-anim-bar {
+ position: absolute;
+ bottom: 16px;
+ right: 16px;
+ z-index: 4;
+}
+.as-anim-select {
+ appearance: none;
+ background: rgba(10, 10, 10, 0.75);
+ backdrop-filter: blur(8px);
+ border: 1px solid var(--as-border);
+ border-radius: var(--as-radius-sm);
+ color: var(--as-text-2);
+ font-size: 12px;
+ padding: 6px 28px 6px 12px;
+ cursor: pointer;
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
+ background-repeat: no-repeat;
+ background-position: right 8px center;
+}
+.as-anim-select:hover { border-color: var(--as-border-2); }
+.as-anim-select option { background: #111; }
+
+/* ── Side panel ───────────────────────────────────────────────────────────── */
+
+.as-panel {
+ display: flex;
+ flex-direction: column;
+ background: var(--as-panel-bg);
+ border-left: 1px solid var(--as-border);
+ overflow: hidden;
+}
+
+/* Tabs */
+.as-tabs {
+ display: flex;
+ border-bottom: 1px solid var(--as-border);
+ padding: 0 12px;
+ gap: 0;
+ overflow-x: auto;
+ -webkit-overflow-scrolling: touch;
+ scrollbar-width: none;
+ flex-shrink: 0;
+}
+.as-tabs::-webkit-scrollbar { display: none; }
+
+.as-tab {
+ padding: 12px 14px;
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--as-text-3);
+ background: none;
+ border: none;
+ border-bottom: 2px solid transparent;
+ cursor: pointer;
+ white-space: nowrap;
+ transition: all var(--as-transition);
+}
+.as-tab:hover { color: var(--as-text-2); }
+.as-tab.active {
+ color: var(--as-accent);
+ border-bottom-color: var(--as-accent);
+}
+
+/* Chips bar */
+.as-chips {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ padding: 10px 16px;
+ min-height: 18px;
+ border-bottom: 1px solid var(--as-border);
+ flex-shrink: 0;
+}
+.as-chips:empty {
+ padding: 6px 16px;
+ min-height: 0;
+}
+
+.as-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 4px 10px;
+ background: var(--as-panel-2);
+ border: 1px solid var(--as-border-2);
+ border-radius: 20px;
+ font-size: 12px;
+ color: var(--as-text-2);
+}
+.as-chip-remove {
+ background: none;
+ border: none;
+ color: var(--as-text-3);
+ cursor: pointer;
+ font-size: 14px;
+ line-height: 1;
+ padding: 0 2px;
+}
+.as-chip-remove:hover { color: var(--as-danger); }
+
+/* Tab content */
+.as-tab-content {
+ flex: 1;
+ overflow-y: auto;
+ padding: 16px;
+ scrollbar-width: thin;
+ scrollbar-color: var(--as-border-2) transparent;
+}
+.as-tab-content::-webkit-scrollbar { width: 6px; }
+.as-tab-content::-webkit-scrollbar-track { background: transparent; }
+.as-tab-content::-webkit-scrollbar-thumb {
+ background: var(--as-border-2);
+ border-radius: 3px;
+}
+
+/* ── Preset grid ──────────────────────────────────────────────────────────── */
+
+.as-preset-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
+ gap: 10px;
+}
+
+.as-preset-card {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
+ padding: 14px 8px 10px;
+ background: var(--as-panel-2);
+ border: 1px solid var(--as-border);
+ border-radius: var(--as-radius);
+ cursor: pointer;
+ transition: all var(--as-transition);
+}
+.as-preset-card:hover {
+ border-color: var(--as-border-2);
+ background: #181818;
+}
+.as-preset-card.active {
+ border-color: var(--as-accent);
+ box-shadow: 0 0 0 1px var(--as-accent);
+}
+
+.as-preset-icon {
+ width: 48px;
+ height: 48px;
+ border-radius: 8px;
+ background: var(--as-border);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 24px;
+ color: var(--as-text-3);
+ overflow: hidden;
+}
+.as-preset-icon img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.as-preset-name {
+ font-size: 11px;
+ color: var(--as-text-2);
+ text-align: center;
+ line-height: 1.3;
+}
+
+.as-preset-clear {
+ grid-column: 1 / -1;
+}
+.as-preset-clear .as-preset-card {
+ flex-direction: row;
+ padding: 10px 14px;
+ gap: 10px;
+}
+.as-preset-clear .as-preset-icon {
+ width: 32px;
+ height: 32px;
+ font-size: 16px;
+}
+
+/* ── Sculpt panel ─────────────────────────────────────────────────────────── */
+
+.as-sculpt-head {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 14px;
+ flex-wrap: wrap;
+}
+
+.as-sculpt-mirror {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ font-size: 12px;
+ color: var(--as-text-2);
+ cursor: pointer;
+ user-select: none;
+}
+.as-sculpt-mirror input { accent-color: var(--as-accent); }
+
+.as-sculpt-note {
+ font-size: 11px;
+ color: var(--as-text-3);
+ line-height: 1.5;
+ margin: 0 0 16px;
+}
+
+/* Blend wheel */
+.as-blend-group { margin-bottom: 16px; }
+
+.as-blend-canvas {
+ position: relative;
+ width: 100%;
+ aspect-ratio: 1;
+ max-width: 240px;
+ margin: 0 auto 12px;
+ border-radius: 50%;
+ background: radial-gradient(circle, var(--as-panel-2) 0%, var(--as-bg) 100%);
+ border: 1px solid var(--as-border);
+ touch-action: none;
+ user-select: none;
+ cursor: crosshair;
+}
+
+.as-blend-label {
+ position: absolute;
+ transform: translate(-50%, -50%);
+ font-size: 10px;
+ color: var(--as-text-3);
+ pointer-events: none;
+ white-space: nowrap;
+}
+
+.as-blend-puck {
+ position: absolute;
+ width: 18px;
+ height: 18px;
+ margin: -9px 0 0 -9px;
+ left: 50%;
+ top: 50%;
+ border-radius: 50%;
+ background: var(--as-accent);
+ box-shadow: 0 0 8px rgba(125, 211, 252, 0.4);
+ cursor: grab;
+ touch-action: none;
+ z-index: 2;
+}
+.as-blend-puck:active { cursor: grabbing; }
+
+.as-blend-desc {
+ text-align: center;
+ font-size: 11px;
+ color: var(--as-text-3);
+ margin: 0 0 8px;
+}
+
+.as-blend-reset {
+ display: block;
+ margin: 0 auto;
+}
+
+/* Sculpt groups */
+.as-sculpt-group {
+ margin-bottom: 8px;
+ border: 1px solid var(--as-border);
+ border-radius: var(--as-radius-sm);
+ overflow: hidden;
+}
+.as-sculpt-group > summary {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 10px 14px;
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--as-text-2);
+ cursor: pointer;
+ background: var(--as-panel-2);
+ user-select: none;
+ list-style: none;
+}
+.as-sculpt-group > summary::-webkit-details-marker { display: none; }
+.as-sculpt-group > summary::before {
+ content: '';
+ display: inline-block;
+ width: 6px;
+ height: 6px;
+ border-right: 1.5px solid var(--as-text-3);
+ border-bottom: 1.5px solid var(--as-text-3);
+ transform: rotate(-45deg);
+ margin-right: 10px;
+ transition: transform 180ms ease;
+}
+.as-sculpt-group[open] > summary::before {
+ transform: rotate(45deg);
+}
+
+.as-sculpt-count {
+ font-size: 11px;
+ color: var(--as-text-3);
+ font-weight: 400;
+}
+
+.as-sculpt-rows {
+ padding: 8px 14px 12px;
+}
+
+.as-sculpt-row {
+ display: grid;
+ grid-template-columns: 120px 1fr 42px;
+ align-items: center;
+ gap: 8px;
+ padding: 3px 0;
+}
+
+.as-sculpt-label {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+.as-sculpt-name {
+ font-size: 12px;
+ color: var(--as-text-2);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.as-sculpt-meta {
+ font-size: 9px;
+ color: var(--as-text-3);
+ background: var(--as-border);
+ padding: 1px 5px;
+ border-radius: 4px;
+ flex-shrink: 0;
+}
+
+.as-sculpt-row input[type="range"] {
+ -webkit-appearance: none;
+ appearance: none;
+ width: 100%;
+ height: 4px;
+ background: var(--as-border-2);
+ border-radius: 2px;
+ outline: none;
+}
+.as-sculpt-row input[type="range"]::-webkit-slider-thumb {
+ -webkit-appearance: none;
+ width: 14px;
+ height: 14px;
+ border-radius: 50%;
+ background: var(--as-accent);
+ cursor: pointer;
+ border: none;
+}
+.as-sculpt-row input[type="range"]::-moz-range-thumb {
+ width: 14px;
+ height: 14px;
+ border-radius: 50%;
+ background: var(--as-accent);
+ cursor: pointer;
+ border: none;
+}
+
+.as-sculpt-value {
+ font-size: 11px;
+ color: var(--as-text-3);
+ text-align: right;
+ font-variant-numeric: tabular-nums;
+}
+
+/* ── Status bar ───────────────────────────────────────────────────────────── */
+
+.as-status {
+ padding: 8px 16px;
+ font-size: 11px;
+ color: var(--as-text-3);
+ border-top: 1px solid var(--as-border);
+ min-height: 16px;
+ flex-shrink: 0;
+}
+
+/* ── Empty state ──────────────────────────────────────────────────────────── */
+
+.as-empty {
+ text-align: center;
+ padding: 40px 20px;
+ color: var(--as-text-3);
+ font-size: 13px;
+ line-height: 1.6;
+}
+
+/* ── Face capture modal ───────────────────────────────────────────────────── */
+
+.as-face-backdrop {
+ position: fixed;
+ inset: 0;
+ background: rgba(0, 0, 0, 0.7);
+ backdrop-filter: blur(4px);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 100;
+}
+.as-face-dialog {
+ background: var(--as-panel-bg);
+ border: 1px solid var(--as-border);
+ border-radius: var(--as-radius);
+ padding: 28px;
+ max-width: 440px;
+ width: 90%;
+ position: relative;
+}
+.as-face-dialog h3 {
+ margin: 0 0 8px;
+ font-size: 16px;
+ font-weight: 600;
+}
+.as-face-lede {
+ font-size: 12px;
+ color: var(--as-text-2);
+ line-height: 1.5;
+ margin: 0 0 16px;
+}
+.as-face-close {
+ position: absolute;
+ top: 12px;
+ right: 12px;
+ background: none;
+ border: none;
+ color: var(--as-text-3);
+ font-size: 18px;
+ cursor: pointer;
+ padding: 4px;
+}
+.as-face-close:hover { color: var(--as-text); }
+.as-face-stage {
+ position: relative;
+ background: #000;
+ border-radius: var(--as-radius-sm);
+ overflow: hidden;
+ margin-bottom: 16px;
+ aspect-ratio: 1;
+}
+.as-face-stage video {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+}
+.as-face-status {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ padding: 10px;
+ background: rgba(0, 0, 0, 0.6);
+ font-size: 12px;
+ color: var(--as-text-2);
+ text-align: center;
+}
+.as-face-actions {
+ display: flex;
+ gap: 8px;
+ justify-content: flex-end;
+}
+
+/* ── Responsive ───────────────────────────────────────────────────────────── */
+
+@media (max-width: 860px) {
+ html, body { overflow: auto; }
+
+ .as-main {
+ grid-template-columns: 1fr;
+ grid-template-rows: 55vh 1fr;
+ height: auto;
+ min-height: 100vh;
+ }
+ .as-panel {
+ border-left: none;
+ border-top: 1px solid var(--as-border);
+ }
+ .as-tab-content {
+ min-height: 300px;
+ }
+ .as-sculpt-row {
+ grid-template-columns: 100px 1fr 36px;
+ }
+}
diff --git a/public/dashboard-next/tokens.css b/public/dashboard-next/tokens.css
index 8611daebb..d8ceeb39f 100644
--- a/public/dashboard-next/tokens.css
+++ b/public/dashboard-next/tokens.css
@@ -14,16 +14,16 @@
--nxt-ink: #e7e8ec;
--nxt-ink-dim: #9ca0aa;
--nxt-ink-fade: #6b6f78;
- --nxt-accent: #9a7cff;
- --nxt-accent-soft: rgba(154, 124, 255, 0.18);
- --nxt-accent-strong: #b39bff;
+ --nxt-accent: #c8cad0;
+ --nxt-accent-soft: rgba(200, 202, 208, 0.14);
+ --nxt-accent-strong: #dddfe4;
--nxt-glass: rgba(14, 15, 22, 0.55);
--nxt-glass-strong: rgba(14, 15, 22, 0.82);
--nxt-stroke: rgba(255, 255, 255, 0.08);
--nxt-stroke-strong: rgba(255, 255, 255, 0.14);
- --nxt-success: #4ec38a;
- --nxt-warn: #ffb454;
- --nxt-danger: #ff6b8a;
+ --nxt-success: #b8bcc4;
+ --nxt-warn: #a8adb5;
+ --nxt-danger: #969ba3;
--nxt-radius: 14px;
--nxt-radius-sm: 10px;
diff --git a/public/home-v4.css b/public/home-v4.css
index 380ddbbcd..c255e16c7 100644
--- a/public/home-v4.css
+++ b/public/home-v4.css
@@ -6,11 +6,7 @@
:root {
--v4-gold: #ffd76a;
--v4-gold-dim: rgba(255, 215, 106, 0.15);
- --v4-mint: #6ee7b7;
- --v4-violet: #a78bfa;
--v4-bg: #050505;
- --v4-surface: rgba(10, 8, 6, 0.72);
- --v4-glass: blur(20px) saturate(140%);
--v4-ink: #f0efe8;
--v4-ink-dim: rgba(240, 239, 232, 0.5);
--v4-stroke: rgba(255, 255, 255, 0.08);
@@ -755,3 +751,23 @@
animation: none;
}
}
+
+/* ══════════════════════════════════════════════════════════════
+ Accessibility — focus-visible
+ ══════════════════════════════════════════════════════════════ */
+.v4-btn-primary:focus-visible,
+.v4-btn-ghost:focus-visible {
+ outline: 2px solid var(--v4-gold);
+ outline-offset: 2px;
+}
+
+.v4-model-btn:focus-visible,
+.v4-chip:focus-visible {
+ outline: 2px solid var(--v4-gold);
+ outline-offset: 1px;
+}
+
+.v4-step-card:focus-visible {
+ outline: 2px solid var(--v4-gold);
+ outline-offset: -2px;
+}
diff --git a/public/nav.html b/public/nav.html
index c93a2cafa..bdf288ab9 100644
--- a/public/nav.html
+++ b/public/nav.html
@@ -237,6 +237,12 @@
><span class="nav-mi-sub">Stream deck — emote hotkeys, mic, expressions</span></a
>
</li>
+ <li role="none">
+ <a href="/walk" role="menuitem"
+ ><span class="nav-mi-title">Walk<span class="nav-pill" aria-hidden="true">NEW</span></span
+ ><span class="nav-mi-sub">Walk your avatar — multiplayer + AR</span></a
+ >
+ </li>
<li role="none">
<a href="/pretext-demo" role="menuitem"
><span class="nav-mi-title">Pretext demo</span
diff --git a/src/app-next-overlay.js b/src/app-next-overlay.js
index a8793296e..acea69286 100644
--- a/src/app-next-overlay.js
+++ b/src/app-next-overlay.js
@@ -64,6 +64,8 @@ function boot() {
wireHelp();
wireAutoHide();
wireDeployMirror();
+ wireVisitorCard();
+ wirePosterSkeleton();
waitForViewer().then((viewer) => {
if (!viewer) {
@@ -533,18 +535,20 @@ function wireShare() {
if (!btn || !pop) return;
const refresh = () => {
- // Page URL: use current location stripped of hash demo-state.
const baseUrl = location.origin + '/app';
const params = new URLSearchParams();
- const currentModelUrl = window.VIEWER?.app?._currentModelUrl;
- if (currentModelUrl && !currentModelUrl.includes('/avatars/cz.glb')) {
- // Only surface non-default avatars in the share URL.
- params.set('model', currentModelUrl);
+ const agentId = new URLSearchParams(location.search).get('agent');
+ if (agentId) {
+ params.set('agent', agentId);
+ } else {
+ const currentModelUrl = window.VIEWER?.app?._currentModelUrl;
+ if (currentModelUrl && !currentModelUrl.includes('/avatars/cz.glb')) {
+ params.set('model', currentModelUrl);
+ }
}
const share = params.toString() ? `${baseUrl}?${params.toString()}` : baseUrl;
urlEl.value = share;
- // Embed snippet — iframe pointing at the same viewer in kiosk mode.
const kiosk = share + (share.includes('?') ? '&' : '?') + 'kiosk=1';
embedEl.value =
`<iframe src="${kiosk}" width="540" height="720" ` +
@@ -590,6 +594,36 @@ function wireShare() {
urlCopyBtn?.addEventListener('click', () => copy(urlEl, urlCopyBtn));
embedCopyBtn?.addEventListener('click', () => copy(embedEl, embedCopyBtn));
+
+ // Social share buttons
+ const twitterBtn = document.getElementById('nxt-share-twitter');
+ const farcasterBtn = document.getElementById('nxt-share-farcaster');
+ const telegramBtn = document.getElementById('nxt-share-telegram');
+
+ const shareText = () => {
+ const app = window.VIEWER?.app;
+ const name = app?.identity?.name;
+ return name
+ ? `Meet ${name} — an embodied AI agent on @threews_`
+ : 'Check out this embodied AI agent on @threews_';
+ };
+
+ const shareUrl = () => urlEl?.value || location.href;
+
+ twitterBtn?.addEventListener('click', () => {
+ const url = `https://x.com/intent/tweet?text=${encodeURIComponent(shareText())}&url=${encodeURIComponent(shareUrl())}`;
+ window.open(url, '_blank', 'noopener,noreferrer,width=600,height=400');
+ });
+
+ farcasterBtn?.addEventListener('click', () => {
+ const url = `https://warpcast.com/~/compose?text=${encodeURIComponent(shareText() + ' ' + shareUrl())}`;
+ window.open(url, '_blank', 'noopener,noreferrer,width=600,height=600');
+ });
+
+ telegramBtn?.addEventListener('click', () => {
+ const url = `https://t.me/share/url?url=${encodeURIComponent(shareUrl())}&text=${encodeURIComponent(shareText())}`;
+ window.open(url, '_blank', 'noopener,noreferrer,width=600,height=400');
+ });
}
// ── Fullscreen ────────────────────────────────────────────────────────────
diff --git a/src/avatar-studio-demo.js b/src/avatar-studio-demo.js
new file mode 100644
index 000000000..2f7dc2368
--- /dev/null
+++ b/src/avatar-studio-demo.js
@@ -0,0 +1,430 @@
+/**
+ * Avatar Studio Demo — standalone avatar customization without Avaturn.
+ *
+ * Wires TalkScene (Three.js renderer), AccessoryManager (outfit/accessory
+ * presets), IdleAnimation (breathing/blink/saccade/weight shift), and the
+ * sculpt system (ARKit-52 sliders + face-type blend wheel) into a single
+ * self-contained page. No auth, no database — pure client-side.
+ */
+
+import { TalkScene } from './voice/talk-scene.js';
+import { AccessoryManager } from './agent-accessories.js';
+import { IdleAnimation } from './idle-animation.js';
+import {
+ discoverMorphs,
+ applyMorphsToRoot,
+ renderSculptPanel,
+} from './avatar-sculpt.js';
+import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
+
+const BASE_GLB = '/avatars/default.glb';
+const PRESETS_URL = '/accessories/presets.json';
+
+let scene = null;
+let accessoryMgr = null;
+let idle = null;
+let presets = [];
+let activeTab = 'outfit';
+let appearance = { outfit: null, accessories: [], morphs: {} };
+
+const $ = (sel) => document.querySelector(sel);
+const $$ = (sel) => document.querySelectorAll(sel);
+
+// ── Boot ──────────────────────────────────────────────────────────────────────
+
+async function boot() {
+ const [presetsData] = await Promise.all([
+ fetch(PRESETS_URL).then((r) => r.json()),
+ mountScene(),
+ ]);
+ presets = presetsData;
+
+ wireAccessoryManager();
+ wireIdleAnimation();
+ wireTabNav();
+ wireCameraPresets();
+ wireAnimationSelect();
+ wireExport();
+ wireResetAll();
+
+ renderActiveTab();
+ renderChips();
+ setStatus('Ready — customize your avatar');
+}
+
+// ── Scene mount ───────────────────────────────────────────────────────────────
+
+async function mountScene() {
+ const container = $('#as-viewport');
+ scene = new TalkScene();
+ await scene.mount({ container, glbUrl: BASE_GLB, cameraPreset: 'full' });
+ $('#as-viewport-loader')?.classList.add('hidden');
+}
+
+// ── AccessoryManager adapter ──────────────────────────────────────────────────
+// AccessoryManager expects a viewer-like object with .content and .invalidate().
+
+function wireAccessoryManager() {
+ const viewerAdapter = {
+ get content() { return scene.root; },
+ invalidate() {},
+ };
+ accessoryMgr = new AccessoryManager(viewerAdapter);
+}
+
+// ── Idle animation ────────────────────────────────────────────────────────────
+
+function wireIdleAnimation() {
+ idle = new IdleAnimation({
+ getRoot: () => scene.root,
+ seed: 'studio-demo',
+ });
+ scene.addOnTick((dt) => idle.update(dt));
+}
+
+// ── Tab navigation ────────────────────────────────────────────────────────────
+
+function wireTabNav() {
+ $('#as-tabs').addEventListener('click', (e) => {
+ const tab = e.target.closest('[data-tab]');
+ if (!tab) return;
+ activeTab = tab.dataset.tab;
+ $$('.as-tab').forEach((t) => {
+ const isActive = t.dataset.tab === activeTab;
+ t.classList.toggle('active', isActive);
+ t.setAttribute('aria-selected', isActive);
+ });
+ renderActiveTab();
+ });
+}
+
+// ── Camera presets ────────────────────────────────────────────────────────────
+
+function wireCameraPresets() {
+ $('#as-cam-bar').addEventListener('click', (e) => {
+ const btn = e.target.closest('[data-preset]');
+ if (!btn) return;
+ $$('.as-cam-btn').forEach((b) => b.classList.remove('active'));
+ btn.classList.add('active');
+ scene.setCameraPreset(btn.dataset.preset);
+ });
+}
+
+// ── Animation select ──────────────────────────────────────────────────────────
+
+async function wireAnimationSelect() {
+ const select = $('#as-anim-select');
+ const emotes = scene.getEmoteController();
+ if (!emotes) return;
+
+ try {
+ await emotes.loadManifest();
+ } catch {
+ return;
+ }
+
+ const names = emotes.listNames?.() || [];
+ for (const name of names) {
+ const opt = document.createElement('option');
+ opt.value = name;
+ opt.textContent = name;
+ select.appendChild(opt);
+ }
+
+ select.addEventListener('change', () => {
+ const val = select.value;
+ if (!val) return;
+ scene.playEmote(val);
+ setTimeout(() => { select.value = ''; }, 2000);
+ });
+}
+
+// ── Export GLB ─────────────────────────────────────────────────────────────────
+
+function wireExport() {
+ $('#as-export').addEventListener('click', async () => {
+ if (!scene.root) return;
+ setStatus('Exporting GLB…');
+ const btn = $('#as-export');
+ btn.disabled = true;
+
+ try {
+ const exporter = new GLTFExporter();
+ const glb = await new Promise((resolve, reject) => {
+ exporter.parse(
+ scene.root,
+ (result) => resolve(result),
+ (err) => reject(err),
+ { binary: true, animations: scene._clips || [] },
+ );
+ });
+ const blob = new Blob([glb], { type: 'model/gltf-binary' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = 'avatar.glb';
+ a.click();
+ URL.revokeObjectURL(url);
+ setStatus('Exported avatar.glb');
+ } catch (err) {
+ console.error('[studio] export failed:', err);
+ setStatus(`Export failed: ${err.message}`);
+ } finally {
+ btn.disabled = false;
+ }
+ });
+}
+
+// ── Reset all ─────────────────────────────────────────────────────────────────
+
+function wireResetAll() {
+ $('#as-reset-all').addEventListener('click', async () => {
+ for (const id of accessoryMgr.list()) {
+ accessoryMgr.removePreset(id);
+ }
+ const allMorphs = discoverMorphs(scene.root);
+ applyMorphsToRoot(scene.root, Object.fromEntries(allMorphs.map((n) => [n, 0])));
+ appearance = { outfit: null, accessories: [], morphs: {} };
+ renderActiveTab();
+ renderChips();
+ setStatus('Reset to default');
+ });
+}
+
+// ── Tab rendering ─────────────────────────────────────────────────────────────
+
+function renderActiveTab() {
+ const container = $('#as-tab-content');
+ if (activeTab === 'sculpt') {
+ renderSculptTab(container);
+ } else {
+ renderPresetTab(container, activeTab);
+ }
+}
+
+function renderPresetTab(container, kind) {
+ const items = presets.filter((p) => p.kind === kind);
+ if (!items.length) {
+ container.innerHTML = '<div class="as-empty">No presets available for this category.</div>';
+ return;
+ }
+
+ const iconFallback = { outfit: 'O', hat: 'H', glasses: 'G', earrings: 'E' };
+ const isActive = (preset) => {
+ if (preset.kind === 'outfit') return appearance.outfit === preset.id;
+ return appearance.accessories.includes(preset.id);
+ };
+
+ container.innerHTML = `
+ <div class="as-preset-grid">
+ ${items.map((p) => `
+ <div class="as-preset-card ${isActive(p) ? 'active' : ''}" data-preset-id="${esc(p.id)}">
+ <div class="as-preset-icon">
+ ${p.thumbnail
+ ? `<img src="${esc(p.thumbnail)}" alt="" loading="lazy" onerror="this.replaceWith(document.createTextNode('${iconFallback[p.kind] || '?'}'))">`
+ : iconFallback[p.kind] || '?'}
+ </div>
+ <span class="as-preset-name">${esc(p.name)}</span>
+ </div>
+ `).join('')}
+ </div>
+ `;
+
+ container.addEventListener('click', handlePresetClick);
+ container.addEventListener('pointerenter', handlePresetHover, true);
+ container.addEventListener('pointerleave', handlePresetLeave, true);
+}
+
+// ── Preset interaction ────────────────────────────────────────────────────────
+// Hover → live preview (temporary). Click → commit. Leave → revert to committed.
+
+let _hoverPreview = null;
+
+async function handlePresetHover(e) {
+ const card = e.target.closest('.as-preset-card');
+ if (!card) return;
+ const id = card.dataset.presetId;
+ const preset = presets.find((p) => p.id === id);
+ if (!preset) return;
+
+ _hoverPreview = id;
+ await accessoryMgr.applyPreset(preset);
+}
+
+async function handlePresetLeave(e) {
+ const card = e.target.closest('.as-preset-card');
+ if (!card || !_hoverPreview) return;
+
+ _hoverPreview = null;
+ await revertToCommitted();
+}
+
+async function handlePresetClick(e) {
+ const card = e.target.closest('.as-preset-card');
+ if (!card) return;
+ const id = card.dataset.presetId;
+ const preset = presets.find((p) => p.id === id);
+ if (!preset) return;
+
+ _hoverPreview = null;
+
+ if (preset.kind === 'outfit') {
+ if (appearance.outfit === id) {
+ appearance.outfit = null;
+ accessoryMgr.removePreset(id);
+ } else {
+ if (appearance.outfit) accessoryMgr.removePreset(appearance.outfit);
+ appearance.outfit = id;
+ await accessoryMgr.applyPreset(preset);
+ }
+ } else {
+ const idx = appearance.accessories.indexOf(id);
+ if (idx >= 0) {
+ appearance.accessories.splice(idx, 1);
+ accessoryMgr.removePreset(id);
+ } else {
+ const isSingle = ['hat', 'glasses'].includes(preset.kind);
+ if (isSingle) {
+ const existing = appearance.accessories.find((aid) => {
+ const p = presets.find((pp) => pp.id === aid);
+ return p && p.kind === preset.kind;
+ });
+ if (existing) {
+ appearance.accessories = appearance.accessories.filter((a) => a !== existing);
+ }
+ }
+ appearance.accessories.push(id);
+ await accessoryMgr.applyPreset(preset);
+ }
+ }
+
+ renderActiveTab();
+ renderChips();
+ setStatus(`${preset.name} ${isPresetActive(preset) ? 'applied' : 'removed'}`);
+}
+
+function isPresetActive(preset) {
+ if (preset.kind === 'outfit') return appearance.outfit === preset.id;
+ return appearance.accessories.includes(preset.id);
+}
+
+async function revertToCommitted() {
+ for (const id of accessoryMgr.list()) {
+ const isCommitted = id === appearance.outfit || appearance.accessories.includes(id);
+ if (!isCommitted) accessoryMgr.removePreset(id);
+ }
+
+ const byId = new Map(presets.map((p) => [p.id, p]));
+ const committed = [];
+ if (appearance.outfit) committed.push(appearance.outfit);
+ committed.push(...appearance.accessories);
+
+ for (const id of committed) {
+ if (!accessoryMgr.list().includes(id)) {
+ const preset = byId.get(id);
+ if (preset) await accessoryMgr.applyPreset(preset);
+ }
+ }
+}
+
+// ── Sculpt tab ────────────────────────────────────────────────────────────────
+
+function renderSculptTab(container) {
+ renderSculptPanel({
+ container,
+ root: scene.root,
+ working: appearance,
+ onDirty: () => {},
+ });
+
+ container.querySelectorAll('.ae-sculpt-group').forEach((el) => {
+ el.classList.add('as-sculpt-group');
+ });
+ container.querySelectorAll('.ae-sculpt-row').forEach((el) => {
+ el.classList.add('as-sculpt-row');
+ });
+ container.querySelectorAll('.ae-sculpt-head').forEach((el) => {
+ el.classList.add('as-sculpt-head');
+ });
+ container.querySelectorAll('.ae-blend-canvas').forEach((el) => {
+ el.classList.add('as-blend-canvas');
+ });
+ container.querySelectorAll('.ae-blend-puck').forEach((el) => {
+ el.classList.add('as-blend-puck');
+ });
+ container.querySelectorAll('.ae-blend-label').forEach((el) => {
+ el.classList.add('as-blend-label');
+ });
+ container.querySelectorAll('.ae-btn').forEach((el) => {
+ el.classList.add('as-btn', 'as-btn-ghost', 'as-btn-sm');
+ });
+}
+
+// ── Chips ─────────────────────────────────────────────────────────────────────
+
+function renderChips() {
+ const container = $('#as-chips');
+ const chips = [];
+
+ if (appearance.outfit) {
+ const p = presets.find((pp) => pp.id === appearance.outfit);
+ if (p) chips.push(chipHtml(p));
+ }
+ for (const id of appearance.accessories) {
+ const p = presets.find((pp) => pp.id === id);
+ if (p) chips.push(chipHtml(p));
+ }
+
+ container.innerHTML = chips.join('');
+
+ container.querySelectorAll('.as-chip-remove').forEach((btn) => {
+ btn.addEventListener('click', async (e) => {
+ const id = e.currentTarget.dataset.presetId;
+ const preset = presets.find((p) => p.id === id);
+ if (!preset) return;
+
+ if (preset.kind === 'outfit') {
+ appearance.outfit = null;
+ } else {
+ appearance.accessories = appearance.accessories.filter((a) => a !== id);
+ }
+ accessoryMgr.removePreset(id);
+ renderActiveTab();
+ renderChips();
+ setStatus(`${preset.name} removed`);
+ });
+ });
+}
+
+function chipHtml(preset) {
+ return `
+ <span class="as-chip">
+ ${esc(preset.name)}
+ <button class="as-chip-remove" data-preset-id="${esc(preset.id)}" aria-label="Remove ${esc(preset.name)}">×</button>
+ </span>
+ `;
+}
+
+// ── Utilities ─────────────────────────────────────────────────────────────────
+
+function setStatus(msg) {
+ const el = $('#as-status');
+ if (el) el.textContent = msg;
+}
+
+function esc(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&#39;');
+}
+
+// ── Init ──────────────────────────────────────────────────────────────────────
+
+boot().catch((err) => {
+ console.error('[avatar-studio] boot failed:', err);
+ setStatus(`Failed to initialize: ${err.message}`);
+ $('#as-viewport-loader')?.classList.add('hidden');
+});
diff --git a/src/avatar-studio.js b/src/avatar-studio.js
new file mode 100644
index 000000000..a55cf7c07
--- /dev/null
+++ b/src/avatar-studio.js
@@ -0,0 +1,640 @@
+/**
+ * Avatar Studio — /create/studio
+ *
+ * Build a custom 3D avatar from a base template without needing a selfie.
+ * Loads the base GLB, lets the user sculpt face/body morphs, pick outfits
+ * and accessories, then saves the result to their account (upload base GLB +
+ * create avatar record + PATCH appearance for server-side bake).
+ *
+ * Reuses the same building blocks as avatar-edit.js:
+ * - TalkScene for the 3D viewport
+ * - AccessoryManager for outfit/accessory application
+ * - renderSculptPanel from avatar-sculpt.js for face/body morphs
+ * - IdleAnimation for ambient breathing/blinking
+ *
+ * The save flow mirrors create.js → create-review.js: upload the base GLB
+ * via presign + direct R2 PUT, create the avatar record, then PATCH it with
+ * the appearance JSON so the server bakes a canonical GLB.
+ */
+
+import { TalkScene } from './voice/talk-scene.js';
+import { AccessoryManager } from './agent-accessories.js';
+import { IdleAnimation } from './idle-animation.js';
+import { renderSculptPanel, applyMorphsToRoot } from './avatar-sculpt.js';
+import { saveRemoteGlbToAccount, apiFetch } from './account.js';
+import { uploadAvatarSnapshot } from './voice/avatar-snapshot.js';
+
+const BASE_GLB_URL = '/avatars/default.glb';
+
+const $ = (id) => document.getElementById(id);
+const esc = (s) =>
+ String(s ?? '').replace(
+ /[&<>"']/g,
+ (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+
+// ── State ────────────────────────────────────────────────────────────
+
+let scene = null;
+let accessoryManager = null;
+let idle = null;
+let presets = [];
+let presetsById = new Map();
+
+let workingAppearance = { outfit: null, accessories: [], morphs: {} };
+let previewedId = null;
+let previewToken = 0;
+let opQueue = Promise.resolve();
+let searchQuery = '';
+let bodyType = 'male';
+
+function queueOp(fn) {
+ const next = opQueue.then(fn).catch((err) => {
+ console.warn('[avatar-studio] queued op failed:', err);
+ });
+ opQueue = next;
+ return next;
+}
+
+const TABS = [
+ { id: 'outfit', label: 'Outfits', kinds: ['outfit'], emoji: '👕', single: true },
+ { id: 'hat', label: 'Hats', kinds: ['hat'], emoji: '🎩', single: true },
+ { id: 'glasses', label: 'Glasses', kinds: ['glasses'], emoji: '🕶️', single: true },
+ { id: 'earrings', label: 'Earrings', kinds: ['earrings'], emoji: '💎', single: false },
+ { id: 'sculpt', label: 'Sculpt', kinds: [], emoji: '✨', single: true, sculpt: true },
+];
+const KIND_EMOJI = { outfit: '👕', hat: '🎩', glasses: '🕶️', earrings: '💎' };
+const KIND_LABEL = { outfit: 'Outfit', hat: 'Hat', glasses: 'Glasses', earrings: 'Earrings' };
+let activeTab = 'outfit';
+
+// ── Init ─────────────────────────────────────────────────────────────
+
+init().catch((err) => {
+ console.error('[avatar-studio] init', err);
+ $('as-shell').innerHTML = `<div class="as-error">${esc(err.message || 'Failed to load')}</div>`;
+});
+
+async function init() {
+ const scenePromise = bootScene();
+
+ presets = await fetchPresets();
+ presetsById = new Map(presets.map((p) => [p.id, p]));
+
+ renderTabs();
+ renderChips();
+ renderActivePanel();
+ bindHeader();
+ bindBodyType();
+
+ await scenePromise;
+}
+
+async function bootScene() {
+ scene = new TalkScene();
+ try {
+ await scene.mount({
+ container: $('as-stage'),
+ glbUrl: BASE_GLB_URL,
+ });
+ $('as-loading')?.remove();
+ accessoryManager = new AccessoryManager({
+ content: scene.root,
+ invalidate: () => {},
+ });
+
+ idle = new IdleAnimation({
+ getRoot: () => scene.root,
+ seed: 'avatar-studio',
+ });
+ scene.addOnTick((dt) => idle.update(dt));
+
+ setStatus('', 'Choose a style below to get started.');
+ } catch (err) {
+ const loadingEl = $('as-loading');
+ if (loadingEl) loadingEl.textContent = `Could not load base avatar: ${err.message}`;
+ }
+}
+
+// ── API ──────────────────────────────────────────────────────────────
+
+async function fetchPresets() {
+ const r = await fetch('/accessories/presets.json');
+ if (!r.ok) throw new Error(`Could not load presets (${r.status})`);
+ return r.json();
+}
+
+// ── Rendering ────────────────────────────────────────────────────────
+
+function renderTabs() {
+ const el = $('as-tabs');
+ el.innerHTML = TABS.map(
+ (t) => `
+ <button class="as-tab${t.id === activeTab ? ' active' : ''}" data-tab="${t.id}" role="tab">
+ ${t.label}
+ </button>
+ `,
+ ).join('');
+ el.querySelectorAll('.as-tab').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ activeTab = btn.dataset.tab;
+ searchQuery = '';
+ el.querySelectorAll('.as-tab').forEach((b) => b.classList.toggle('active', b === btn));
+ renderActivePanel();
+ });
+ });
+}
+
+function renderActivePanel() {
+ const tab = TABS.find((t) => t.id === activeTab);
+ const panel = $('as-panel');
+
+ if (tab.sculpt) {
+ if (!scene?.root) {
+ panel.innerHTML = `<div class="as-empty">Waiting for avatar to load...</div>`;
+ return;
+ }
+ renderSculptPanel({
+ container: panel,
+ root: scene.root,
+ working: workingAppearance,
+ onDirty: () => {
+ renderChips();
+ },
+ });
+ return;
+ }
+
+ const q = searchQuery.trim().toLowerCase();
+ const items = presets.filter(
+ (p) => tab.kinds.includes(p.kind) && (!q || p.name.toLowerCase().includes(q)),
+ );
+
+ const searchHtml = `
+ <div class="as-search-wrap">
+ <input class="as-search" id="as-search" type="search"
+ placeholder="Search ${esc(tab.label.toLowerCase())}..."
+ value="${esc(searchQuery)}" autocomplete="off" />
+ </div>`;
+
+ if (items.length === 0 && q) {
+ panel.innerHTML = searchHtml + `<div class="as-empty">No matches for "${esc(searchQuery)}".</div>`;
+ bindSearch();
+ return;
+ }
+
+ const tiles = [];
+ if (!q) {
+ tiles.push(`
+ <button class="as-tile as-tile-none${tileSelected(tab, null) ? ' selected' : ''}"
+ type="button" data-id="" data-kind="${tab.id}">
+ <div class="as-tile-preview" aria-hidden="true">∅</div>
+ <div class="as-tile-name">None</div>
+ <div class="as-tile-kind">remove</div>
+ </button>
+ `);
+ }
+ for (const p of items) {
+ const previewing = previewedId === p.id;
+ const selected = tileSelected(tab, p.id);
+ tiles.push(`
+ <button class="as-tile${selected ? ' selected' : ''}${previewing ? ' previewing' : ''}"
+ type="button" data-id="${esc(p.id)}" data-kind="${tab.id}">
+ <div class="as-tile-preview" aria-hidden="true">
+ ${tilePreviewMarkup(p)}
+ </div>
+ <div class="as-tile-name">${esc(p.name)}</div>
+ <div class="as-tile-kind">${esc(KIND_LABEL[p.kind] || p.kind)}</div>
+ </button>
+ `);
+ }
+
+ panel.innerHTML = searchHtml + `<div class="as-grid">${tiles.join('')}</div>`;
+ bindSearch();
+ bindTiles(panel, tab);
+}
+
+function tilePreviewMarkup(preset) {
+ const emoji = KIND_EMOJI[preset.kind] || '◇';
+ if (!preset.thumbnail) return emoji;
+ return `
+ <span style="position:absolute;inset:0;display:flex;align-items:center;justify-content:center;">${emoji}</span>
+ <img src="${esc(preset.thumbnail)}" alt="" loading="lazy"
+ style="position:absolute;inset:0;"
+ onerror="this.remove()" />
+ `;
+}
+
+function bindSearch() {
+ const input = $('as-search');
+ if (!input) return;
+ input.addEventListener('input', (e) => {
+ searchQuery = e.target.value;
+ renderActivePanel();
+ const next = $('as-search');
+ if (next) {
+ next.focus();
+ next.setSelectionRange(searchQuery.length, searchQuery.length);
+ }
+ });
+}
+
+function bindTiles(panel, tab) {
+ panel.querySelectorAll('.as-tile').forEach((btn) => {
+ const presetId = btn.dataset.id;
+ btn.addEventListener('click', () => onTileClick(tab, presetId));
+ if (!presetId) return;
+ btn.addEventListener('mouseenter', () => onTileHover(tab, presetId));
+ btn.addEventListener('mouseleave', () => onTileLeave());
+ btn.addEventListener('focus', () => onTileHover(tab, presetId));
+ btn.addEventListener('blur', () => onTileLeave());
+ });
+}
+
+function renderChips() {
+ const el = $('as-chips');
+ const picks = [];
+ if (workingAppearance.outfit) picks.push(workingAppearance.outfit);
+ for (const id of workingAppearance.accessories) picks.push(id);
+
+ el.innerHTML = picks
+ .map((id) => {
+ const p = presetsById.get(id);
+ if (!p) return '';
+ return `
+ <span class="as-chip" data-id="${esc(id)}">
+ <span class="as-chip-kind">${esc(KIND_LABEL[p.kind] || p.kind)}</span>
+ <span>${esc(p.name)}</span>
+ <button type="button" aria-label="Remove ${esc(p.name)}" data-remove="${esc(id)}">×</button>
+ </span>
+ `;
+ })
+ .join('');
+
+ el.querySelectorAll('button[data-remove]').forEach((btn) => {
+ btn.addEventListener('click', async () => {
+ await removeCommitted(btn.dataset.remove);
+ });
+ });
+}
+
+function tileSelected(tab, presetId) {
+ if (tab.kinds.includes('outfit')) {
+ return presetId
+ ? workingAppearance.outfit === presetId
+ : !workingAppearance.outfit;
+ }
+ const matching = workingAppearance.accessories.filter((id) => {
+ const preset = presetsById.get(id);
+ return preset && tab.kinds.includes(preset.kind);
+ });
+ if (!presetId) return matching.length === 0;
+ return matching.includes(presetId);
+}
+
+// ── Hover preview ────────────────────────────────────────────────────
+
+function onTileHover(tab, presetId) {
+ if (isCommitted(presetId)) {
+ previewedId = null;
+ return;
+ }
+ if (previewedId === presetId) return;
+ previewedId = presetId;
+ highlightPreviewingTile(presetId);
+
+ const myToken = ++previewToken;
+ const preset = presetsById.get(presetId);
+ if (!preset) return;
+
+ if (!accessoryManager) {
+ setStatus('', `${preset.name} · waiting for avatar to load...`);
+ return;
+ }
+
+ queueOp(async () => {
+ if (myToken !== previewToken) return;
+ await accessoryManager.applyPreset(preset);
+ if (myToken === previewToken) {
+ setStatus('', `Previewing ${preset.name} · click to keep`);
+ }
+ });
+}
+
+function onTileLeave() {
+ if (!previewedId) return;
+ const leavingId = previewedId;
+ previewedId = null;
+ const myToken = ++previewToken;
+ highlightPreviewingTile(null);
+
+ if (isCommitted(leavingId)) {
+ setStatusDefault();
+ return;
+ }
+
+ const preset = presetsById.get(leavingId);
+ if (!preset) {
+ setStatusDefault();
+ return;
+ }
+
+ queueOp(async () => {
+ if (myToken !== previewToken) return;
+ if (!accessoryManager) {
+ setStatusDefault();
+ return;
+ }
+ accessoryManager.removePreset(leavingId);
+ if (preset.kind !== 'earrings') {
+ const committedInSlot = committedIdForKind(preset.kind);
+ if (committedInSlot && committedInSlot !== leavingId) {
+ const restore = presetsById.get(committedInSlot);
+ if (restore) await accessoryManager.applyPreset(restore);
+ }
+ }
+ if (myToken === previewToken) setStatusDefault();
+ });
+}
+
+function highlightPreviewingTile(id) {
+ document.querySelectorAll('.as-tile.previewing').forEach((el) => el.classList.remove('previewing'));
+ if (!id) return;
+ const el = document.querySelector(`.as-tile[data-id="${cssEscape(id)}"]`);
+ el?.classList.add('previewing');
+}
+
+function cssEscape(s) {
+ return String(s).replace(/["\\]/g, '\\$&');
+}
+
+function isCommitted(presetId) {
+ if (!presetId) return false;
+ return (
+ workingAppearance.outfit === presetId ||
+ workingAppearance.accessories.includes(presetId)
+ );
+}
+
+function committedIdForKind(kind) {
+ if (kind === 'outfit') return workingAppearance.outfit || null;
+ for (const id of workingAppearance.accessories) {
+ const p = presetsById.get(id);
+ if (p && p.kind === kind) return id;
+ }
+ return null;
+}
+
+// ── Commit / remove ──────────────────────────────────────────────────
+
+async function onTileClick(tab, presetId) {
+ previewedId = null;
+ previewToken++;
+
+ await queueOp(async () => {
+ if (tab.kinds.includes('outfit')) {
+ await applyOutfit(presetId || null);
+ } else {
+ await applyAccessory(tab, presetId || null);
+ }
+ });
+ renderActivePanel();
+ renderChips();
+}
+
+async function removeCommitted(id) {
+ const preset = presetsById.get(id);
+ if (!preset) return;
+ previewedId = null;
+ previewToken++;
+ await queueOp(async () => {
+ accessoryManager?.removePreset(id);
+ });
+ if (workingAppearance.outfit === id) {
+ workingAppearance.outfit = null;
+ } else {
+ workingAppearance.accessories = workingAppearance.accessories.filter((a) => a !== id);
+ }
+ renderActivePanel();
+ renderChips();
+}
+
+async function applyOutfit(presetId) {
+ if (!presetId) {
+ if (workingAppearance.outfit) accessoryManager?.removePreset(workingAppearance.outfit);
+ workingAppearance.outfit = null;
+ return;
+ }
+ const preset = presetsById.get(presetId);
+ if (!preset) return;
+ if (accessoryManager) await accessoryManager.applyPreset(preset);
+ workingAppearance.outfit = presetId;
+}
+
+async function applyAccessory(tab, presetId) {
+ const inSlot = workingAppearance.accessories.filter((id) => {
+ const p = presetsById.get(id);
+ return p && tab.kinds.includes(p.kind);
+ });
+
+ if (!presetId) {
+ for (const id of inSlot) {
+ accessoryManager?.removePreset(id);
+ workingAppearance.accessories = workingAppearance.accessories.filter((a) => a !== id);
+ }
+ return;
+ }
+
+ if (tab.single) {
+ for (const id of inSlot) {
+ if (id === presetId) continue;
+ accessoryManager?.removePreset(id);
+ workingAppearance.accessories = workingAppearance.accessories.filter((a) => a !== id);
+ }
+ const preset = presetsById.get(presetId);
+ if (preset && accessoryManager) await accessoryManager.applyPreset(preset);
+ if (!workingAppearance.accessories.includes(presetId)) {
+ workingAppearance.accessories.push(presetId);
+ }
+ return;
+ }
+
+ if (inSlot.includes(presetId)) {
+ accessoryManager?.removePreset(presetId);
+ workingAppearance.accessories = workingAppearance.accessories.filter((a) => a !== presetId);
+ return;
+ }
+ const preset = presetsById.get(presetId);
+ if (preset && accessoryManager) await accessoryManager.applyPreset(preset);
+ if (!workingAppearance.accessories.includes(presetId)) {
+ workingAppearance.accessories.push(presetId);
+ }
+}
+
+// ── Header / body type / status ──────────────────────────────────────
+
+function bindHeader() {
+ $('as-save').addEventListener('click', () => saveAvatar());
+ $('as-reset').addEventListener('click', () => resetAll());
+}
+
+function bindBodyType() {
+ const btns = document.querySelectorAll('.as-body-toggle button[data-body]');
+ btns.forEach((btn) => {
+ btn.addEventListener('click', () => {
+ bodyType = btn.dataset.body;
+ btns.forEach((b) => b.setAttribute('aria-pressed', b === btn ? 'true' : 'false'));
+ });
+ });
+}
+
+async function resetAll() {
+ previewedId = null;
+ previewToken++;
+ await queueOp(async () => {
+ const wasIds = [
+ workingAppearance.outfit,
+ ...workingAppearance.accessories,
+ ].filter(Boolean);
+ if (accessoryManager) {
+ for (const id of wasIds) accessoryManager.removePreset(id);
+ }
+ workingAppearance = { outfit: null, accessories: [], morphs: {} };
+ if (scene?.root) {
+ applyMorphsToRoot(scene.root, {});
+ }
+ if (accessoryManager) await accessoryManager.hydrateFromAppearance(workingAppearance);
+ });
+ renderChips();
+ renderActivePanel();
+ setStatus('', 'Reset to default.');
+}
+
+function setStatusDefault() {
+ setStatus('', 'Hover any item to try it on. Click to keep.');
+}
+
+function setStatus(kind, text) {
+ const el = $('as-status');
+ el.className = `as-status${kind ? ' ' + kind : ''}`;
+ el.innerHTML = kind === 'spin' ? `<span class="spin"></span>${esc(text)}` : esc(text);
+}
+
+// ── Save flow ────────────────────────────────────────────────────────
+
+function collapseAppearance(a) {
+ const out = {};
+ if (a.outfit) out.outfit = a.outfit;
+ if (a.accessories?.length) out.accessories = [...a.accessories];
+ if (a.morphs && Object.keys(a.morphs).length) out.morphs = { ...a.morphs };
+ return Object.keys(out).length ? out : null;
+}
+
+function showSaveOverlay(label, sublabel) {
+ let el = document.getElementById('as-save-overlay');
+ if (!el) {
+ el = document.createElement('div');
+ el.id = 'as-save-overlay';
+ el.className = 'as-save-overlay';
+ el.innerHTML = `
+ <div class="spin-lg"></div>
+ <div class="as-save-label"></div>
+ <div class="as-save-sublabel"></div>
+ <div class="as-progress-bar"><div class="as-progress-fill" id="as-progress-fill"></div></div>
+ `;
+ document.body.appendChild(el);
+ }
+ el.querySelector('.as-save-label').textContent = label;
+ el.querySelector('.as-save-sublabel').textContent = sublabel || '';
+}
+
+function updateSaveOverlay(label, sublabel) {
+ const el = document.getElementById('as-save-overlay');
+ if (!el) return;
+ if (label) el.querySelector('.as-save-label').textContent = label;
+ if (sublabel !== undefined) el.querySelector('.as-save-sublabel').textContent = sublabel;
+}
+
+function updateProgress(pct) {
+ const fill = document.getElementById('as-progress-fill');
+ if (fill) fill.style.width = `${Math.round(pct)}%`;
+}
+
+function hideSaveOverlay() {
+ const el = document.getElementById('as-save-overlay');
+ if (el) el.remove();
+}
+
+async function saveAvatar() {
+ const name = ($('as-name')?.value || '').trim() || 'My Avatar';
+ const saveBtn = $('as-save');
+ const resetBtn = $('as-reset');
+ saveBtn.disabled = true;
+ resetBtn.disabled = true;
+ showSaveOverlay('Uploading avatar...', 'This may take a moment');
+
+ try {
+ const glbRes = await fetch(BASE_GLB_URL);
+ if (!glbRes.ok) throw new Error(`Failed to fetch base GLB: ${glbRes.status}`);
+ const glbBlob = await glbRes.blob();
+
+ updateSaveOverlay('Uploading base model...');
+
+ const avatar = await saveRemoteGlbToAccount(
+ glbBlob,
+ {
+ name,
+ source: 'studio',
+ source_meta: { generator: 'avatar-studio', body_type: bodyType },
+ visibility: 'public',
+ },
+ {
+ onProgress: (pct) => updateProgress(pct * 0.7),
+ },
+ );
+
+ const appearance = collapseAppearance(workingAppearance);
+ if (appearance) {
+ updateSaveOverlay('Applying customizations...', 'Baking appearance into GLB');
+ updateProgress(75);
+
+ const patchRes = await apiFetch(`/api/avatars/${encodeURIComponent(avatar.id)}`, {
+ method: 'PATCH',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ appearance }),
+ });
+ if (!patchRes.ok) {
+ const err = await patchRes.json().catch(() => ({}));
+ console.warn('[avatar-studio] appearance PATCH failed:', err);
+ }
+ }
+
+ updateProgress(90);
+ updateSaveOverlay('Capturing thumbnail...');
+
+ try {
+ await uploadAvatarSnapshot({ avatarId: avatar.id, scene });
+ } catch (err) {
+ console.warn('[avatar-studio] snapshot upload failed:', err?.message);
+ }
+
+ updateProgress(100);
+ updateSaveOverlay('Done! Redirecting...');
+
+ await new Promise((r) => setTimeout(r, 600));
+
+ window.location.href = `/avatars/${encodeURIComponent(avatar.id)}`;
+ } catch (err) {
+ hideSaveOverlay();
+ console.error('[avatar-studio] save failed:', err);
+
+ if (err.code === 'not_signed_in' || err.stage === 'auth') {
+ const next = encodeURIComponent('/create/studio');
+ window.location.replace(`/login?next=${next}`);
+ return;
+ }
+
+ setStatus('err', `Save failed: ${err.message || 'Unknown error'}`);
+ saveBtn.disabled = false;
+ resetBtn.disabled = false;
+ }
+}
diff --git a/src/create-review-features.js b/src/create-review-features.js
index 496e2a288..167604a3f 100644
--- a/src/create-review-features.js
+++ b/src/create-review-features.js
@@ -256,9 +256,31 @@ export function openVoicePreview({ glbBlob, glbUrl, name }) {
// ── Static info modals (identity / paid / embed / reputation) ────────────────
export async function openIdentityModal(ctx = {}) {
- // Render the shell synchronously so the modal opens instantly. The keypair
- // generation is fast (~ms) but the import is a fat dependency — load it
- // in the background and patch the address in once it resolves.
+ const displayName = escapeHtml(ctx.name || 'Your new avatar');
+
+ let thumbSrc = '';
+ if (ctx.canvas) {
+ try {
+ const size = 96;
+ const tmp = document.createElement('canvas');
+ tmp.width = tmp.height = size;
+ const tc = tmp.getContext('2d');
+ if (tc) {
+ const src = ctx.canvas;
+ const ar = src.width / src.height || 1;
+ let dw = size, dh = size;
+ if (ar > 1) dh = Math.round(size / ar);
+ else dw = Math.round(size * ar);
+ tc.drawImage(src, (size - dw) / 2, (size - dh) / 2, dw, dh);
+ thumbSrc = tmp.toDataURL('image/png');
+ }
+ } catch { /* fallback initial renders fine */ }
+ }
+
+ const avatarHtml = thumbSrc
+ ? `<img class="fm-id-avatar" src="${thumbSrc}" alt="${displayName}" />`
+ : `<div class="fm-id-avatar fm-id-avatar--fallback">${displayName.charAt(0).toUpperCase()}</div>`;
+
const body = document.createElement('div');
body.innerHTML = `
<ul class="fm-bullets">
@@ -267,18 +289,25 @@ export async function openIdentityModal(ctx = {}) {
<li>Discoverable in the agent registry by capability, price, and reputation.</li>
</ul>
<div class="fm-id-card" data-state="loading">
- <div class="fm-id-head">
- <span class="fm-id-chain">Solana mainnet</span>
- <span class="fm-id-pill" data-pill>generating…</span>
- </div>
- <div class="fm-id-addr" data-addr>—</div>
- <div class="fm-id-meta">
- <div><span class="muted">Name</span><strong data-name>${escapeHtml(ctx.name || 'Your new avatar')}</strong></div>
- <div><span class="muted">Asset standard</span><strong>Metaplex Core</strong></div>
+ <div class="fm-id-card-top">
+ ${avatarHtml}
+ <div class="fm-id-card-top-right">
+ <div class="fm-id-head">
+ <span class="fm-id-chain">Solana mainnet</span>
+ <span class="fm-id-pill" data-pill>generating…</span>
+ </div>
+ <div class="fm-id-meta">
+ <div><span class="muted">Name</span><strong data-name>${displayName}</strong></div>
+ <div><span class="muted">Asset standard</span><strong>Metaplex Core</strong></div>
+ </div>
+ </div>
</div>
- <button class="fm-copy fm-id-copy" type="button" data-copy-addr disabled>Copy address</button>
+ <a class="fm-id-addr-link" data-addr-link target="_blank" rel="noopener noreferrer">
+ <span class="fm-id-addr" data-addr>—</span>
+ <span class="fm-id-explorer-hint" data-explorer-hint>View on Solscan</span>
+ </a>
+ <p class="fm-id-sample-note" data-sample-note>Sample keypair — your real address is created on save</p>
</div>
- <p class="fm-note">Sample keypair generated locally — your real agent gets a unique address on save. Nothing is broadcast.</p>
`;
openFeatureModal({
@@ -289,10 +318,6 @@ export async function openIdentityModal(ctx = {}) {
actions: [{ label: 'Got it' }],
});
- // Generate a real, throwaway sample keypair in-browser so the preview
- // shows a *real-shaped* base58 address rather than an obvious placeholder.
- // Private key is discarded — this is purely a visual proof of "real Solana
- // addresses, not lorem ipsum".
try {
const { Keypair } = await import('@solana/web3.js');
const kp = Keypair.generate();
@@ -300,28 +325,22 @@ export async function openIdentityModal(ctx = {}) {
const card = body.querySelector('.fm-id-card');
card.dataset.state = 'ready';
card.querySelector('[data-pill]').textContent = 'preview';
+
card.querySelector('[data-addr]').textContent = addr;
- const copy = card.querySelector('[data-copy-addr]');
- copy.disabled = false;
- copy.addEventListener('click', async () => {
- try {
- await navigator.clipboard.writeText(addr);
- copy.textContent = 'Copied';
- copy.classList.add('copied');
- setTimeout(() => {
- copy.textContent = 'Copy address';
- copy.classList.remove('copied');
- }, 1600);
- } catch {
- copy.textContent = 'Press ⌘C';
- }
- });
+
+ const link = card.querySelector('[data-addr-link]');
+ link.href = `https://solscan.io/account/${addr}`;
+ link.title = 'Open in Solscan (sample address)';
} catch (err) {
const card = body.querySelector('.fm-id-card');
card.dataset.state = 'error';
card.querySelector('[data-pill]').textContent = 'unavailable';
card.querySelector('[data-addr]').textContent =
- 'Couldn\'t load keypair generator — your real address is created on save.';
+ 'Couldn\'t generate preview — your real address is created on save.';
+ const link = card.querySelector('[data-addr-link]');
+ link.removeAttribute('href');
+ link.style.pointerEvents = 'none';
+ card.querySelector('[data-explorer-hint]').hidden = true;
console.warn('[identity-preview] keypair gen failed', err);
}
}
diff --git a/src/create.js b/src/create.js
index 1fe39b251..f6bd19515 100644
--- a/src/create.js
+++ b/src/create.js
@@ -76,7 +76,43 @@ function markSelfieUnavailable() {
}
}
+async function handleFork(avatarId) {
+ showSaveOverlay('Loading avatar…');
+ try {
+ const metaRes = await fetch(`/api/avatars/${encodeURIComponent(avatarId)}`);
+ if (!metaRes.ok) throw new Error('Could not load the original avatar.');
+ const { avatar } = await metaRes.json();
+
+ const glbUrl = avatar.url || avatar.model_url;
+ if (!glbUrl) throw new Error('Original avatar has no downloadable model.');
+
+ updateSaveOverlay('Downloading model…');
+ const glbRes = await fetch(glbUrl, { mode: 'cors' });
+ if (!glbRes.ok) throw new Error('Could not download the avatar model.');
+ const blob = await glbRes.blob();
+
+ updateSaveOverlay('Preparing remix…');
+ await stageGuestAvatar(blob, {
+ source: 'import',
+ name: avatar.name || 'Remixed avatar',
+ source_meta: { provider: 'remix', fork_of: avatarId },
+ });
+
+ window.location.href = '/create-review';
+ } catch (err) {
+ hideSaveOverlay();
+ console.error('[create] fork failed:', err);
+ showStatus(err.message || 'Could not remix this avatar. Try again.', 'error');
+ }
+}
+
async function boot() {
+ const forkId = new URLSearchParams(location.search).get('fork');
+ if (forkId) {
+ await handleFork(forkId);
+ return;
+ }
+
probeReconstruct();
const creator = new AvatarCreator(document.body, (blob, meta = {}) => {
const provider = meta.provider || 'avaturn';
@@ -96,7 +132,7 @@ async function boot() {
wireCard('card-default-editor', async () => {
if (window.__authed && (await isAtAvatarLimit())) return;
- creator.openDefaultEditor();
+ window.location.href = '/create/studio';
});
wireCard('card-selfie', async () => {
if (!_reconstructReady) {
diff --git a/src/dashboard-next/pages/agents.js b/src/dashboard-next/pages/agents.js
index 79700d8bf..576d6a900 100644
--- a/src/dashboard-next/pages/agents.js
+++ b/src/dashboard-next/pages/agents.js
@@ -180,7 +180,7 @@ function agentCard(a, avatars) {
const pumpMint = a.meta?.pumpfun?.mint || a.meta?.token?.mint || a.meta?.token?.ca;
return `
- <div class="dn-panel" style="display:grid;grid-template-columns:auto 1fr auto;gap:16px;align-items:start" data-agent-id="${esc(a.id)}">
+ <div class="dn-panel dn-agent-card" data-agent-id="${esc(a.id)}">
<div style="
width:56px;height:56px;border-radius:12px;overflow:hidden;
background:linear-gradient(135deg,rgba(154,124,255,0.3),rgba(109,193,255,0.2));
@@ -203,18 +203,25 @@ function agentCard(a, avatars) {
${a.persona?.tagline || a.tagline ? `<div style="font-size:13px;color:var(--nxt-ink-dim);margin-top:6px;font-style:italic">${esc((a.persona?.tagline || a.tagline).slice(0, 120))}</div>` : ''}
</div>
- <div style="display:flex;flex-direction:column;gap:6px;flex-shrink:0;align-items:flex-end">
- <div style="display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end">
+ <div class="dn-agent-actions">
+ <div class="dn-agent-actions-primary">
${a.avatar_id ? `<a class="dn-btn primary" href="/agent-next?id=${encodeURIComponent(a.avatar_id)}" target="_blank" rel="noopener" style="padding:5px 10px;font-size:12px">Live page ↗</a>` : ''}
- <a class="dn-btn ghost" href="/app?agent=${encodeURIComponent(a.id)}" target="_blank" rel="noopener" style="padding:5px 10px;font-size:12px">3D Studio ↗</a>
- <button class="dn-btn" data-action="edit-agent" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Edit</button>
- <button class="dn-btn" data-action="persona-agent" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Persona</button>
- <button class="dn-btn" data-action="view-reputation" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Reputation</button>
+ <a class="dn-btn" href="/app?agent=${encodeURIComponent(a.id)}" target="_blank" rel="noopener" style="padding:5px 10px;font-size:12px">3D Studio ↗</a>
+ </div>
+ <div class="dn-agent-actions-secondary">
+ <button class="dn-btn ghost" data-action="edit-agent" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Edit</button>
+ <button class="dn-btn ghost" data-action="persona-agent" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Persona</button>
+ <button class="dn-btn ghost" data-action="view-reputation" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Reputation</button>
<button class="dn-btn danger" data-action="delete-agent" data-id="${esc(a.id)}" style="padding:5px 10px;font-size:12px">Delete</button>
</div>
- ${onchain ? `<a href="/onchain?agent=${encodeURIComponent(a.id)}" style="font-size:11.5px;color:var(--nxt-accent)">ERC-8004 registry ↗</a>` : ''}
- ${pumpMint ? `<a href="https://pump.fun/coin/${encodeURIComponent(pumpMint)}" target="_blank" rel="noopener" style="font-size:11.5px;color:#ffb454">View on Pump.fun ↗</a>` : ''}
</div>
+
+ ${onchain || pumpMint ? `
+ <div class="dn-agent-links">
+ ${onchain ? `<a href="/onchain?agent=${encodeURIComponent(a.id)}" style="font-size:11.5px;color:var(--nxt-accent)">ERC-8004 registry ↗</a>` : ''}
+ ${pumpMint ? `<a href="https://pump.fun/coin/${encodeURIComponent(pumpMint)}" target="_blank" rel="noopener" style="font-size:11.5px;color:#ffb454">View on Pump.fun ↗</a>` : ''}
+ </div>
+ ` : ''}
</div>
`;
}
diff --git a/src/home-v4-scroll.js b/src/home-v4-scroll.js
index ac80f4139..91adb8b64 100644
--- a/src/home-v4-scroll.js
+++ b/src/home-v4-scroll.js
@@ -1,9 +1,5 @@
/**
- * home-v4 scroll orchestration:
- * - Scroll reveal animations
- * - Experience section: Act2Viewer + animation chips + model picker
- * - Stats bar from /api/home-stats
- * - CTA section wave avatar
+ * home-v4 scroll orchestration.
*/
const LOW_MEMORY = typeof navigator.deviceMemory === 'number' && navigator.deviceMemory < 2;
@@ -41,7 +37,7 @@ const LOW_MEMORY = typeof navigator.deviceMemory === 'number' && navigator.devic
const onchainEl = document.querySelector('[data-stat="onchain"]');
if (agentEl && data.agents != null) agentEl.textContent = formatNum(data.agents);
if (onchainEl && data.onchain != null) onchainEl.textContent = formatNum(data.onchain);
- } catch { /* non-critical */ }
+ } catch { /* stats are non-critical enhancement */ }
})();
function formatNum(n) {
@@ -49,6 +45,35 @@ function formatNum(n) {
return String(n);
}
+/* ── Off-screen pause helper for Act2Viewer instances ── */
+function observeViewerVisibility(canvas, viewer) {
+ let visible = true;
+ let paused = false;
+ const original = viewer._tick.bind(viewer);
+
+ const observer = new IntersectionObserver(
+ (entries) => {
+ visible = entries[0].isIntersecting;
+ if (visible && paused) {
+ paused = false;
+ viewer._clock.start();
+ requestAnimationFrame(original);
+ }
+ },
+ { rootMargin: '200px' },
+ );
+ observer.observe(canvas);
+
+ const originalTick = viewer._tick;
+ viewer._tick = function () {
+ if (!visible) {
+ paused = true;
+ return;
+ }
+ originalTick.call(viewer);
+ };
+}
+
/* ── Experience section: Act2Viewer + animation chips ── */
(function initExperience() {
const canvas = document.getElementById('v4-exp-canvas');
@@ -72,6 +97,7 @@ function formatNum(n) {
function boot() {
if (!window.Act2Viewer) return;
viewer = new window.Act2Viewer(canvas, { fov: 14 });
+ observeViewerVisibility(canvas, viewer);
viewer.onClipsReady = (clips) => {
buildChips(clips);
@@ -132,6 +158,7 @@ function formatNum(n) {
async function boot() {
if (!window.Act2Viewer) return;
const viewer = new window.Act2Viewer(canvas, { fov: 14 });
+ observeViewerVisibility(canvas, viewer);
await viewer.loadModel('/avatars/cz.glb', { autoPlay: false });
const waveClip = viewer.listAvailableClips().find(c => /wave|waving/i.test(c.name));
if (waveClip) {
diff --git a/src/manifest.js b/src/manifest.js
index d72ba5a04..59f1a1bb1 100644
--- a/src/manifest.js
+++ b/src/manifest.js
@@ -160,11 +160,16 @@ export function normalize(json, { baseURI = '' } = {}) {
uri: bodyURI,
format: json.body?.format || json.content_type || 'gltf-binary',
},
- brain: json.brain || { provider: 'none' },
+ brain: json.brain || {
+ provider: json.id ? 'anthropic' : 'none',
+ instructions: json.id
+ ? `You are ${json.name || 'an AI agent'} on three.ws — a living, embodied 3D avatar.${json.description ? ' ' + json.description : ''} Be friendly and conversational. You can wave, play animations, and change expressions using your tools. When greeting someone, use the wave tool. Only use play_clip when the user explicitly asks for an animation.`
+ : undefined,
+ },
voice: json.voice || { tts: { provider: 'browser' }, stt: { provider: 'browser' } },
skills: json.skills || [],
memory: json.memory || { mode: 'local' },
- tools: json.tools || ['wave', 'lookAt', 'play_clip', 'setExpression'],
+ tools: json.tools || ['wave', 'lookAt', 'play_clip', 'setExpression', 'speak', 'remember'],
version: json.version || '0.1.0',
};
}
diff --git a/src/voice/avatar-morph-target.js b/src/voice/avatar-morph-target.js
index caf0ac4c1..37916b7a1 100644
--- a/src/voice/avatar-morph-target.js
+++ b/src/voice/avatar-morph-target.js
@@ -53,18 +53,50 @@ const MORPH_ROUND = [
'pucker',
];
-const JAW_BONE_NAMES = ['Jaw', 'jaw', 'mixamorig:Jaw', 'mixamorigJaw', 'CC_Base_JawRoot', 'Bip01_Jaw'];
+const JAW_BONE_NAMES = [
+ 'Jaw', 'jaw',
+ 'mixamorig:Jaw', 'mixamorigJaw',
+ 'CC_Base_JawRoot',
+ 'Bip01_Jaw',
+ 'J_Bip_C_Jaw',
+ 'lowerJaw', 'LowerJaw',
+ 'jaw_01',
+ 'FACIAL_C_Jaw',
+ 'JawBone', 'jaw_bone', 'Jaw_bone',
+ 'lowerFaceJnt',
+ 'DEF-jaw',
+ 'ORG-jaw',
+];
+
+const HEAD_BONE_NAMES = [
+ 'Head', 'head',
+ 'mixamorig:Head', 'mixamorigHead',
+ 'CC_Base_Head',
+ 'Bip01_Head',
+ 'J_Bip_C_Head',
+ 'head_01',
+ 'HeadBone', 'head_bone',
+ 'DEF-spine.006',
+ 'DEF-head',
+ 'ORG-head',
+];
// Max jaw rotation in radians when there's no morph available. ~12° looks
// like talking without crossing into rictus territory.
const MAX_JAW_ROT = 0.21;
+// Max head nod in radians for the head-bone fallback. ~2.5° — subtle enough
+// to read as speech cadence without looking like a deliberate nod.
+const MAX_HEAD_NOD = 0.044;
+
export class AvatarMouthTarget {
constructor() {
// Each entry: { mesh, idx, channel: 'open'|'wide'|'wideRight'|'round' }
this._morphBindings = [];
this._jawBone = null;
this._jawBaseRotX = 0;
+ this._headBone = null;
+ this._headBaseRotX = 0;
this._attached = false;
}
@@ -78,21 +110,30 @@ export class AvatarMouthTarget {
attach(root) {
this._morphBindings = [];
this._jawBone = null;
+ this._headBone = null;
this._attached = false;
if (!root || typeof root.traverse !== 'function') return;
const meshesWithMorphs = [];
+ let headCandidate = null;
root.traverse((node) => {
if (node.isMesh && node.morphTargetDictionary && node.morphTargetInfluences) {
meshesWithMorphs.push(node);
}
- if (!this._jawBone && (node.isBone || node.type === 'Bone')) {
- if (JAW_BONE_NAMES.some((n) => n.toLowerCase() === String(node.name).toLowerCase())) {
- this._jawBone = node;
- this._jawBaseRotX = node.rotation.x;
- }
+ if (!(node.isBone || node.type === 'Bone')) return;
+ const name = String(node.name).toLowerCase();
+ if (!this._jawBone && JAW_BONE_NAMES.some((n) => n.toLowerCase() === name)) {
+ this._jawBone = node;
+ this._jawBaseRotX = node.rotation.x;
+ }
+ if (!headCandidate && HEAD_BONE_NAMES.some((n) => n.toLowerCase() === name)) {
+ headCandidate = node;
}
});
+ if (!this._jawBone && headCandidate) {
+ this._headBone = headCandidate;
+ this._headBaseRotX = headCandidate.rotation.x;
+ }
// Per channel: find the first morph name from the priority list that
// exists on any mesh; bind every mesh that has it.
@@ -114,6 +155,14 @@ export class AvatarMouthTarget {
return !!this._jawBone;
}
+ hasHeadFallback() {
+ return !this._jawBone && !!this._headBone;
+ }
+
+ hasAnyMouthDriver() {
+ return this.hasMouthMorphs() || this.hasJawBone() || this.hasHeadFallback();
+ }
+
/** Channel diagnostics for debugging which shapes are wired. */
describe() {
const channels = {};
@@ -123,6 +172,7 @@ export class AvatarMouthTarget {
return {
morphs: channels,
jawBone: this._jawBone ? this._jawBone.name : null,
+ headFallback: this._headBone ? this._headBone.name : null,
};
}
@@ -151,11 +201,18 @@ export class AvatarMouthTarget {
if (this._jawBone && !this._channelBound('open')) {
this._jawBone.rotation.x = this._jawBaseRotX + open * MAX_JAW_ROT;
}
+
+ // Head micro-nod — last resort when neither morphs nor jaw bone exist.
+ // Subtle chin dip (~2.5°) that reads as speech without looking like nodding.
+ if (this._headBone && !this._jawBone && !this._channelBound('open')) {
+ this._headBone.rotation.x = this._headBaseRotX + open * MAX_HEAD_NOD;
+ }
}
dispose() {
this._morphBindings = [];
this._jawBone = null;
+ this._headBone = null;
this._attached = false;
}
diff --git a/src/voice/talk-mode.js b/src/voice/talk-mode.js
index 95d9fdba9..41f1ee436 100644
--- a/src/voice/talk-mode.js
+++ b/src/voice/talk-mode.js
@@ -60,6 +60,7 @@ export function openTalkMode({ avatar, systemPromptFn }) {
const frameBtn = overlay.querySelector('.tws-talk-frame');
const frameLabel = frameBtn?.querySelector('.tws-talk-frame-label');
const emoteBar = overlay.querySelector('.tws-talk-emotes');
+ const lipsyncNotice = overlay.querySelector('.tws-talk-lipsync-notice');
nameEl.textContent = avatar.name || 'Avatar';
// Owner-only affordance: `owner_id` is stripped from the API response for
@@ -80,16 +81,18 @@ export function openTalkMode({ avatar, systemPromptFn }) {
.mount({ container: stage, glbUrl: glbBlob ? undefined : glbUrl, glbBlob, cameraPreset: 'half' })
.then(async (root) => {
scene.attachMouthTarget(mouthTarget);
- // Log what we found so debugging mismatched rigs in the field is easy.
const diag = mouthTarget.describe();
- if (!mouthTarget.hasMouthMorphs() && !mouthTarget.hasJawBone()) {
- console.warn('[talk] avatar has no mouth morphs or jaw bone — speech will play but the mouth won\'t move. Diagnostics:', diag);
+ if (!mouthTarget.hasAnyMouthDriver()) {
+ console.warn('[talk] avatar has no mouth morphs, jaw bone, or head fallback. Diagnostics:', diag);
+ showLipsyncNotice(lipsyncNotice, 'none');
+ } else if (!mouthTarget.hasMouthMorphs() && !mouthTarget.hasJawBone() && mouthTarget.hasHeadFallback()) {
+ console.info('[talk] mouth binding (head fallback):', diag);
+ showLipsyncNotice(lipsyncNotice, 'head');
} else {
console.info('[talk] mouth binding:', diag);
}
setStatus(statusEl, 'idle');
- // Render the emote bar once the animation manifest is available.
const emotes = scene.getEmoteController();
if (emotes) {
await emotes.loadManifest();
@@ -213,6 +216,7 @@ const TEMPLATE = `
</div>
</div>
<div class="tws-talk-stage"></div>
+ <div class="tws-talk-lipsync-notice" hidden role="status"></div>
<div class="tws-talk-emotes" hidden role="toolbar" aria-label="Emote shortcuts"></div>
<div class="tws-talk-transcript" aria-live="polite"></div>
<div class="tws-talk-controls">
@@ -279,6 +283,22 @@ function showError(el, message) {
}, 4000);
}
+function showLipsyncNotice(el, level) {
+ if (!el) return;
+ if (level === 'head') {
+ el.dataset.level = 'limited';
+ el.innerHTML =
+ '<span class="tws-lipsync-icon" aria-hidden="true">◐</span>' +
+ '<span class="tws-lipsync-text">Limited lip sync — this avatar has no mouth blend shapes. Using subtle head motion as a fallback.</span>';
+ } else {
+ el.dataset.level = 'none';
+ el.innerHTML =
+ '<span class="tws-lipsync-icon" aria-hidden="true">○</span>' +
+ '<span class="tws-lipsync-text">No lip sync — this avatar\'s model doesn\'t include mouth shapes or a jaw bone. Voice will still play normally.</span>';
+ }
+ el.hidden = false;
+}
+
function injectStylesOnce() {
if (document.getElementById('tws-talk-mode-css')) return;
const css = document.createElement('style');
@@ -298,7 +318,7 @@ const TALK_CSS = `
color: #fafafa;
font-family: 'Inter', system-ui, sans-serif;
display: grid;
- grid-template-rows: auto 1fr auto auto;
+ grid-template-rows: auto 1fr auto auto auto auto;
animation: tws-talk-in 200ms ease-out;
}
@keyframes tws-talk-in { from { opacity: 0; } to { opacity: 1; } }
@@ -474,8 +494,42 @@ const TALK_CSS = `
padding: 8px 14px; border-radius: 10px;
font-size: 13px;
}
+.tws-talk-lipsync-notice {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ margin: 0 24px;
+ padding: 10px 14px;
+ border-radius: 10px;
+ font-size: 13px;
+ line-height: 1.45;
+ animation: tws-notice-in 300ms ease-out;
+}
+@keyframes tws-notice-in {
+ from { opacity: 0; transform: translateY(-4px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+.tws-talk-lipsync-notice[data-level="limited"] {
+ background: rgba(250,204,21,0.08);
+ border: 1px solid rgba(250,204,21,0.22);
+ color: rgba(253,224,71,0.9);
+}
+.tws-talk-lipsync-notice[data-level="none"] {
+ background: rgba(161,161,170,0.08);
+ border: 1px solid rgba(161,161,170,0.18);
+ color: rgba(161,161,170,0.9);
+}
+.tws-lipsync-icon {
+ flex-shrink: 0;
+ font-size: 16px;
+ line-height: 1;
+}
+.tws-lipsync-text {
+ min-width: 0;
+}
@media (max-width: 600px) {
.tws-talk-header { padding: 12px 16px 0; }
+ .tws-talk-lipsync-notice { margin: 0 16px; padding: 8px 12px; font-size: 12px; }
.tws-talk-transcript { padding: 8px 16px; max-height: 120px; }
.tws-talk-controls { padding: 12px 16px 20px; }
.tws-talk-hold { padding: 12px 22px; font-size: 14px; }
diff --git a/src/walk-net.js b/src/walk-net.js
index e211c8302..e87cfcd06 100644
--- a/src/walk-net.js
+++ b/src/walk-net.js
@@ -173,6 +173,10 @@ export class WalkNet {
this.room?.send('rename', { name });
}
+ sendEmote(name) {
+ this.room?.send('emote', { name });
+ }
+
/** Force a reconnect (e.g. after the user clicks the offline pill). */
retry() {
if (this._reconnectTimer) {
diff --git a/src/walk.js b/src/walk.js
index 8700d4a5e..ebf8c7774 100644
--- a/src/walk.js
+++ b/src/walk.js
@@ -91,6 +91,16 @@ const recordStatusLabel = recordStatus?.querySelector('[data-label]');
const statusEl = document.getElementById('walk-status');
const onlinePill = document.getElementById('walk-online');
const onlineCountEl = document.getElementById('walk-online-count');
+const loadingOverlay = document.getElementById('walk-loading');
+const loadingText = document.getElementById('walk-loading-text');
+const nameInput = /** @type {HTMLInputElement|null} */ (document.getElementById('walk-name-input'));
+const playersPanelEl = document.getElementById('walk-players-panel');
+const playersListEl = document.getElementById('walk-players-list');
+const playersCloseBtn = document.getElementById('walk-players-close');
+const helpToggleBtn = document.getElementById('walk-help-toggle');
+const emoteTrayEl = document.getElementById('walk-emote-tray');
+
+const NAME_STORAGE_KEY = 'walk:player-name';
function setStatus(text, { error = false, sticky = false } = {}) {
if (!statusEl) return;
@@ -103,6 +113,79 @@ function setStatus(text, { error = false, sticky = false } = {}) {
}
}
+function setLoadingText(text) {
+ if (loadingText) loadingText.textContent = text;
+}
+
+function dismissLoading() {
+ if (!loadingOverlay) return;
+ loadingOverlay.classList.add('is-done');
+ loadingOverlay.addEventListener('transitionend', () => loadingOverlay.remove(), { once: true });
+}
+
+// ── Name persistence ─────────────────────────────────────────────────────
+function getStoredName() {
+ const params = new URLSearchParams(location.search);
+ return params.get('name')
+ || (typeof localStorage !== 'undefined' && localStorage.getItem(NAME_STORAGE_KEY))
+ || '';
+}
+function storeName(name) {
+ try { localStorage.setItem(NAME_STORAGE_KEY, name); } catch {}
+}
+if (nameInput) {
+ const initial = getStoredName();
+ if (initial) nameInput.value = initial;
+ const commitName = () => {
+ const v = nameInput.value.trim().slice(0, 24);
+ if (v) {
+ storeName(v);
+ if (net) net.rename(v);
+ }
+ };
+ nameInput.addEventListener('blur', commitName);
+ nameInput.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') { nameInput.blur(); }
+ });
+}
+
+// ── Help toggle ──────────────────────────────────────────────────────────
+const helpEl = document.getElementById('walk-help');
+let helpAutoHideTimer = null;
+if (helpToggleBtn && helpEl) {
+ helpToggleBtn.addEventListener('click', () => {
+ const show = helpEl.style.display === 'none';
+ helpEl.style.display = show ? '' : 'none';
+ if (helpAutoHideTimer) { clearTimeout(helpAutoHideTimer); helpAutoHideTimer = null; }
+ });
+}
+
+// ── Players panel ────────────────────────────────────────────────────────
+let playersPanelOpen = false;
+function togglePlayersPanel() {
+ playersPanelOpen = !playersPanelOpen;
+ if (playersPanelEl) playersPanelEl.hidden = !playersPanelOpen;
+ if (playersPanelOpen) renderPlayerList();
+}
+if (playersCloseBtn) playersCloseBtn.addEventListener('click', togglePlayersPanel);
+
+function renderPlayerList() {
+ if (!playersListEl) return;
+ playersListEl.innerHTML = '';
+ const localName = nameInput?.value?.trim() || 'you';
+ const li = document.createElement('li');
+ li.className = 'is-you';
+ li.innerHTML = `<span class="player-dot" style="background:var(--accent)"></span>${esc(localName)}<span class="player-motion">${currentMotion}</span>`;
+ playersListEl.appendChild(li);
+ for (const [sid, rp] of remotePlayers) {
+ const row = document.createElement('li');
+ const colorHex = '#' + (rp._color ?? 0xffffff).toString(16).padStart(6, '0');
+ row.innerHTML = `<span class="player-dot" style="background:${colorHex}"></span>${esc(rp.label?.textContent || sid.slice(0, 6))}<span class="player-motion">${rp.motion}</span>`;
+ playersListEl.appendChild(row);
+ }
+}
+function esc(s) { return String(s).replace(/[<>&"']/g, c => ({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;', "'": '&#39;' })[c]); }
+
// ── Renderer / scene ──────────────────────────────────────────────────────
// preserveDrawingBuffer is required so the canvas pixels remain readable for
// the "Record" feature — without it, drawImage(renderer.domElement, …) into
@@ -350,7 +433,7 @@ helpOverlay.addEventListener('click', (e) => {
});
window.addEventListener('keydown', (e) => {
- // Don't steal events from text inputs.
+ if (e.target?.tagName === 'INPUT' || e.target?.tagName === 'TEXTAREA') return;
if (e.target !== document.body && e.target !== canvas) return;
switch (e.code) {
case 'KeyW': case 'ArrowUp': input.keys.forward = 1; break;
@@ -417,9 +500,9 @@ let avatarTemplate = null;
let animationDefs = null;
async function loadAvatar() {
- setStatus('loading avatar…', { sticky: true });
-
+ setLoadingText('Resolving avatar...');
const avatarUrl = await resolveAvatarUrl();
+ setLoadingText('Loading 3D model...');
const loader = new GLTFLoader();
const gltf = await loader.loadAsync(avatarUrl);
avatar = gltf.scene;
@@ -449,13 +532,14 @@ async function loadAvatar() {
animationManager.attach(avatar);
- // Load only the three clips the controller actually uses — keeps startup
- // fast and avoids fetching ~30MB of dance/jump clips we don't need.
+ setLoadingText('Preparing animations...');
const manifest = await fetch(ANIMATIONS_MANIFEST_URL, { cache: 'force-cache' })
.then((r) => {
if (!r.ok) throw new Error(`HTTP ${r.status} fetching animation manifest`);
return r.json();
});
+ // Store the full manifest for emote tray population.
+ _fullManifest = manifest;
const needed = manifest.filter((d) =>
d.name === CLIP_IDLE || d.name === CLIP_WALK || d.name === CLIP_RUN,
);
@@ -469,7 +553,93 @@ async function loadAvatar() {
await animationManager.crossfadeTo(CLIP_IDLE, 0.0);
currentMotion = 'idle';
- setStatus('walk it', { sticky: false });
+ dismissLoading();
+ buildEmoteTray();
+
+ // Auto-hide help hints after 5 seconds.
+ if (helpEl) {
+ helpAutoHideTimer = setTimeout(() => {
+ helpEl.style.display = 'none';
+ helpAutoHideTimer = null;
+ }, 5000);
+ }
+}
+
+// ── Emote tray ───────────────────────────────────────────────────────────
+let _fullManifest = null;
+let _emoteActive = false;
+
+const EMOTE_CLIPS = [
+ { name: 'wave', icon: '👋', label: 'Wave' },
+ { name: 'dance', icon: '💃', label: 'Dance' },
+ { name: 'celebrate', icon: '🎉', label: 'Celebrate' },
+ { name: 'angry', icon: '😠', label: 'Angry' },
+ { name: 'silly', icon: '🤪', label: 'Silly' },
+ { name: 'pray', icon: '🙏', label: 'Pray' },
+ { name: 'taunt', icon: '😏', label: 'Taunt' },
+ { name: 'kiss', icon: '😘', label: 'Kiss' },
+];
+
+function buildEmoteTray() {
+ if (!emoteTrayEl || !_fullManifest) return;
+ const available = EMOTE_CLIPS.filter(e =>
+ _fullManifest.some(d => d.name === e.name),
+ );
+ if (available.length === 0) return;
+ emoteTrayEl.hidden = false;
+ emoteTrayEl.innerHTML = '';
+ for (const emote of available) {
+ const btn = document.createElement('button');
+ btn.type = 'button';
+ btn.className = 'walk-emote-btn';
+ btn.title = emote.label;
+ btn.setAttribute('aria-pressed', 'false');
+ btn.innerHTML = `<span>${emote.icon}</span><span class="emote-label">${emote.label}</span>`;
+ btn.addEventListener('click', () => playEmote(emote.name, btn));
+ emoteTrayEl.appendChild(btn);
+ }
+}
+
+async function playEmote(name, btn) {
+ if (_emoteActive) return;
+ _emoteActive = true;
+
+ emoteTrayEl?.querySelectorAll('.walk-emote-btn').forEach(b => b.setAttribute('aria-pressed', 'false'));
+ if (btn) btn.setAttribute('aria-pressed', 'true');
+
+ const def = _fullManifest?.find(d => d.name === name);
+ if (!def) { _emoteActive = false; return; }
+
+ if (!animationDefs.some(d => d.name === name)) {
+ animationDefs.push(def);
+ animationManager.setAnimationDefs(animationDefs);
+ }
+ try {
+ await animationManager.ensureLoaded(name);
+ } catch {
+ _emoteActive = false;
+ return;
+ }
+
+ await animationManager.crossfadeTo(name, 0.2);
+ if (net) net.sendEmote(name);
+
+ const action = animationManager.currentAction;
+ if (action && !action.loop) {
+ const dur = action.getClip().duration * 1000;
+ setTimeout(() => {
+ if (!_emoteActive) return;
+ _emoteActive = false;
+ animationManager.crossfadeTo(motionToClipName(currentMotion), 0.25);
+ if (btn) btn.setAttribute('aria-pressed', 'false');
+ }, dur + 100);
+ } else {
+ setTimeout(() => {
+ _emoteActive = false;
+ animationManager.crossfadeTo(motionToClipName(currentMotion), 0.25);
+ if (btn) btn.setAttribute('aria-pressed', 'false');
+ }, 3000);
+ }
}
// ── AR depth: light estimation ────────────────────────────────────────────
@@ -1043,6 +1213,10 @@ class RemotePlayer {
}
});
+ this._color = initial?.color ?? 0xffffff;
+ this._lastEmoteTs = 0;
+ this._emoting = false;
+
this.rig = new Group();
this.rig.add(root);
scene.add(this.rig);
@@ -1081,11 +1255,36 @@ class RemotePlayer {
this.targetYaw = player.yaw;
if (player.motion !== this.motion) {
this.motion = player.motion;
- this.anim.crossfadeTo(motionToClipName(player.motion), 0.18);
+ if (!this._emoting) {
+ this.anim.crossfadeTo(motionToClipName(player.motion), 0.18);
+ }
}
if (this.label.textContent !== player.name && player.name) {
this.label.textContent = player.name;
}
+ if (player.emote && player.emoteTs !== this._lastEmoteTs) {
+ this._lastEmoteTs = player.emoteTs;
+ this._playRemoteEmote(player.emote);
+ }
+ }
+
+ async _playRemoteEmote(name) {
+ if (!_fullManifest) return;
+ const def = _fullManifest.find(d => d.name === name);
+ if (!def) return;
+ if (!animationDefs.some(d => d.name === name)) {
+ animationDefs.push(def);
+ this.anim.setAnimationDefs(animationDefs);
+ }
+ try { await this.anim.ensureLoaded(name); } catch { return; }
+ this._emoting = true;
+ this.anim.crossfadeTo(name, 0.2);
+ const action = this.anim.currentAction;
+ const dur = (action && !action.loop) ? action.getClip().duration * 1000 : 3000;
+ setTimeout(() => {
+ this._emoting = false;
+ this.anim.crossfadeTo(motionToClipName(this.motion), 0.25);
+ }, dur + 100);
}
tick(dt) {
@@ -1144,6 +1343,8 @@ function setupOnlinePill() {
if (!net) return;
if (net.status === 'failed' || net.status === 'offline') {
net.retry();
+ } else {
+ togglePlayersPanel();
}
});
}
@@ -1173,10 +1374,11 @@ function setOnlineStatus(status) {
}
function startNet() {
- if (!avatarTemplate || !animationDefs) return; // wait until loadAvatar finished
+ if (!avatarTemplate || !animationDefs) return;
if (net) return;
- const params = new URLSearchParams(location.search);
- const name = (params.get('name') || `guest-${Math.random().toString(36).slice(2, 6)}`).slice(0, 24);
+ const stored = getStoredName();
+ const name = (stored || `guest-${Math.random().toString(36).slice(2, 6)}`).slice(0, 24);
+ if (nameInput && !nameInput.value) nameInput.value = name;
net = new WalkNet({ name });
net.on('status', ({ status }) => {
@@ -1196,7 +1398,10 @@ function startNet() {
net.on('change', (player, sessionId) => {
if (sessionId === net.mySessionId) return;
const r = remotePlayers.get(sessionId);
- if (r) r.applyServerState(player);
+ if (r) {
+ r.applyServerState(player);
+ if (playersPanelOpen) renderPlayerList();
+ }
});
net.on('remove', (sessionId) => {
const r = remotePlayers.get(sessionId);
diff --git a/vercel.json b/vercel.json
index 0295409c4..83e3f3a3b 100644
--- a/vercel.json
+++ b/vercel.json
@@ -285,6 +285,10 @@
"src": "/avatar-artifact/?",
"dest": "/avatar-artifact.html"
},
+ {
+ "src": "/avatar-studio-demo/?",
+ "dest": "/avatar-studio-demo.html"
+ },
{
"src": "/walk/?",
"dest": "/walk.html"
@@ -2034,6 +2038,22 @@
},
"dest": "/llms-full.txt"
},
+ {
+ "src": "/app",
+ "has": [
+ {
+ "type": "query",
+ "key": "agent",
+ "value": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
+ },
+ {
+ "type": "header",
+ "key": "user-agent",
+ "value": "(?i).*(Twitterbot|facebookexternalhit|Slackbot|LinkedInBot|Discordbot|TelegramBot|WhatsApp|Googlebot|bingbot|Applebot|Pinterestbot|redditbot|Embedly|Quora|outbrain|vkShare|Iframely).*"
+ }
+ ],
+ "dest": "/api/app-og?agent=$agent"
+ },
{
"src": "/app",
"dest": "/app-next.html"
@@ -2085,6 +2105,14 @@
"src": "/create/video/?",
"dest": "/create/video.html"
},
+ {
+ "src": "/create/studio",
+ "dest": "/avatar-studio.html"
+ },
+ {
+ "src": "/create/studio/",
+ "dest": "/avatar-studio.html"
+ },
{
"src": "/create/selfie",
"dest": "/create-selfie.html"
diff --git a/vite.config.js b/vite.config.js
index 49f57a33a..23208badd 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -159,6 +159,7 @@ const appConfig = {
launchpad: resolve(__dirname, 'pages/launchpad.html'),
create: resolve(__dirname, 'pages/create.html'),
'create-selfie': resolve(__dirname, 'pages/create-selfie.html'),
+ 'avatar-studio': resolve(__dirname, 'pages/avatar-studio.html'),
'create-review': resolve(__dirname, 'pages/create-review.html'),
'import-rpm': resolve(__dirname, 'pages/import-rpm.html'),
'agent-home': resolve(__dirname, 'pages/agent-home.html'),
@@ -189,6 +190,7 @@ creating: resolve(__dirname, 'pages/creating.html'),
'home-v4': resolve(__dirname, 'pages/home-v4.html'),
'agent-next': resolve(__dirname, 'pages/agent-next.html'),
'discover-next': resolve(__dirname, 'pages/discover-next.html'),
+ 'avatar-studio-demo': resolve(__dirname, 'pages/avatar-studio-demo.html'),
walk: resolve(__dirname, 'pages/walk.html'),
'walk-embed': resolve(__dirname, 'pages/walk-embed.html'),
pose: resolve(__dirname, 'pages/pose.html'),
@@ -353,6 +355,8 @@ creating: resolve(__dirname, 'pages/creating.html'),
'/create': resolve(root, 'pages/create.html'),
'/create/selfie': resolve(root, 'pages/create-selfie.html'),
'/create/selfie/': resolve(root, 'pages/create-selfie.html'),
+ '/create/studio': resolve(root, 'pages/avatar-studio.html'),
+ '/create/studio/': resolve(root, 'pages/avatar-studio.html'),
'/create-review': resolve(root, 'pages/create-review.html'),
'/create-review/': resolve(root, 'pages/create-review.html'),
'/import/rpm': resolve(root, 'pages/import-rpm.html'),