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.

completionist pass: kill fake data + fake-loading on new surfaces

nirholas6a87147e3842
diff --git a/pages/create-review.html b/pages/create-review.html
index 9667597fa..11959d37b 100644
--- a/pages/create-review.html
+++ b/pages/create-review.html
@@ -258,7 +258,10 @@
grid-template-columns: 1fr 1fr;
gap: 6px;
}
+ .feature-grid > li { display: flex; }
+ .feature-grid .feature-tile { flex: 1; width: 100%; }
.feature-tile {
+ appearance: none;
display: flex;
flex-direction: column;
gap: 3px;
@@ -266,13 +269,23 @@
background: rgba(255, 255, 255, 0.025);
border: 1px solid transparent;
border-radius: 9px;
- transition: background 0.15s, border-color 0.15s, transform 0.15s;
- cursor: default;
+ transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
+ cursor: pointer;
+ color: var(--text);
+ text-align: left;
+ font: inherit;
+ position: relative;
}
- .feature-tile:hover {
- background: rgba(214, 255, 61, 0.04);
- border-color: rgba(214, 255, 61, 0.18);
+ .feature-tile:hover, .feature-tile:focus-visible {
+ background: rgba(214, 255, 61, 0.06);
+ border-color: rgba(214, 255, 61, 0.28);
transform: translateY(-1px);
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
+ outline: none;
+ }
+ .feature-tile:hover .feature-try, .feature-tile:focus-visible .feature-try {
+ opacity: 1;
+ transform: translateX(0);
}
.feature-icon {
font-size: 17px;
@@ -289,6 +302,315 @@
color: var(--muted);
line-height: 1.35;
}
+ .feature-try {
+ position: absolute;
+ top: 8px;
+ right: 9px;
+ font-size: 10px;
+ color: var(--accent);
+ opacity: 0;
+ transform: translateX(-3px);
+ transition: opacity 0.15s, transform 0.15s;
+ font-weight: 600;
+ letter-spacing: 0.02em;
+ }
+
+ /* ── Feature-preview modal ─────────────────────────────────────── */
+ .fm-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 200;
+ background: rgba(2, 3, 6, 0.72);
+ backdrop-filter: blur(6px);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 20px;
+ animation: fmFadeIn 0.18s ease-out;
+ }
+ @keyframes fmFadeIn { from { opacity: 0; } to { opacity: 1; } }
+ .fm-dialog {
+ background: var(--panel);
+ border: 1.5px solid var(--border);
+ border-radius: 16px;
+ width: 100%;
+ max-width: 520px;
+ max-height: calc(100vh - 40px);
+ overflow-y: auto;
+ padding: 28px;
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
+ animation: fmRise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
+ }
+ @keyframes fmRise { from { transform: translateY(8px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
+ .fm-head {
+ display: flex;
+ align-items: flex-start;
+ gap: 14px;
+ }
+ .fm-icon {
+ font-size: 28px;
+ line-height: 1;
+ flex-shrink: 0;
+ }
+ .fm-head-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
+ .fm-head-text h3 {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 600;
+ letter-spacing: -0.01em;
+ }
+ .fm-head-text p {
+ margin: 0;
+ color: var(--muted);
+ font-size: 13px;
+ line-height: 1.5;
+ }
+ .fm-close {
+ margin-left: auto;
+ background: rgba(255, 255, 255, 0.05);
+ border: 1px solid var(--border);
+ color: var(--text);
+ width: 30px;
+ height: 30px;
+ border-radius: 999px;
+ cursor: pointer;
+ font-size: 14px;
+ font-family: inherit;
+ flex-shrink: 0;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ transition: background 0.15s, border-color 0.15s;
+ }
+ .fm-close:hover { background: rgba(255, 255, 255, 0.1); border-color: #2c2d3d; }
+ .fm-body { display: flex; flex-direction: column; gap: 14px; }
+ .fm-bullets { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
+ .fm-bullets li {
+ display: flex;
+ align-items: flex-start;
+ gap: 10px;
+ font-size: 13px;
+ color: var(--text);
+ line-height: 1.5;
+ }
+ .fm-bullets li::before {
+ content: '';
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: var(--accent);
+ margin-top: 7px;
+ flex-shrink: 0;
+ box-shadow: 0 0 6px rgba(214, 255, 61, 0.5);
+ }
+ .fm-code {
+ background: #07080d;
+ border: 1px solid var(--border);
+ border-radius: 9px;
+ padding: 12px 14px;
+ font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
+ font-size: 12px;
+ color: #cdd;
+ overflow-x: auto;
+ white-space: pre;
+ position: relative;
+ }
+ .fm-copy {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid var(--border);
+ color: var(--muted);
+ border-radius: 6px;
+ padding: 3px 8px;
+ font-size: 10.5px;
+ cursor: pointer;
+ font-family: inherit;
+ transition: color 0.15s, border-color 0.15s;
+ }
+ .fm-copy:hover { color: var(--accent); border-color: rgba(214, 255, 61, 0.4); }
+ .fm-copy.copied { color: var(--accent); }
+ .fm-row {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 12px;
+ padding: 10px 12px;
+ background: rgba(255, 255, 255, 0.025);
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ font-size: 13px;
+ }
+ .fm-row strong { font-weight: 600; }
+ .fm-row .muted { color: var(--muted); font-size: 12px; }
+ /* Schematic placeholder for "this is the value you'll get on save"
+ rendering — clearly inert so it doesn't read as a real address. */
+ .fm-placeholder {
+ font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
+ font-size: 11px;
+ color: var(--muted);
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px dashed var(--border);
+ border-radius: 6px;
+ padding: 3px 7px;
+ letter-spacing: 0.02em;
+ }
+ .fm-actions { display: flex; gap: 8px; }
+ .fm-cta {
+ flex: 1;
+ background: var(--accent);
+ color: var(--accent-ink);
+ border: none;
+ border-radius: 9px;
+ padding: 10px 14px;
+ font: inherit;
+ font-weight: 600;
+ cursor: pointer;
+ transition: filter 0.15s;
+ }
+ .fm-cta:hover { filter: brightness(1.05); }
+ .fm-cta.ghost {
+ background: transparent;
+ color: var(--text);
+ border: 1.5px solid var(--border);
+ }
+ .fm-cta.ghost:hover { border-color: #2c2d3d; }
+ .fm-note {
+ font-size: 11.5px;
+ color: var(--muted);
+ line-height: 1.45;
+ }
+
+ .fm-download-list {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ }
+ .fm-download-row {
+ width: 100%;
+ appearance: none;
+ background: rgba(255, 255, 255, 0.025);
+ border: 1.5px solid var(--border);
+ border-radius: 10px;
+ padding: 12px 14px;
+ color: var(--text);
+ text-align: left;
+ font: inherit;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ cursor: pointer;
+ transition: background 0.15s, border-color 0.15s, transform 0.1s;
+ }
+ .fm-download-row:hover:not([data-busy='1']) {
+ background: rgba(214, 255, 61, 0.06);
+ border-color: rgba(214, 255, 61, 0.4);
+ transform: translateY(-1px);
+ }
+ .fm-download-row[data-busy='1'] {
+ cursor: progress;
+ opacity: 0.7;
+ }
+ .fm-download-head {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: 8px;
+ }
+ .fm-download-head strong {
+ font-size: 14px;
+ font-weight: 600;
+ letter-spacing: -0.005em;
+ }
+ .fm-download-ext {
+ font-family: ui-monospace, 'SF Mono', monospace;
+ font-size: 11px;
+ color: var(--muted);
+ }
+ .fm-download-blurb {
+ font-size: 12px;
+ color: var(--muted);
+ line-height: 1.4;
+ }
+ .fm-download-status {
+ font-size: 11.5px;
+ color: var(--muted);
+ min-height: 1em;
+ margin-top: 2px;
+ }
+ .fm-download-status[data-tone='busy'] { color: #b9c0ff; }
+ .fm-download-status[data-tone='ok'] { color: var(--accent); }
+ .fm-download-status[data-tone='err'] { color: #ffb3b3; }
+
+ /* ── Emote chip strip on viewer ────────────────────────────────── */
+ .emote-strip {
+ position: absolute;
+ bottom: 12px;
+ left: 50%;
+ transform: translateX(-50%) translateY(6px);
+ display: flex;
+ gap: 6px;
+ padding: 7px 9px;
+ background: rgba(10, 11, 18, 0.85);
+ border: 1px solid var(--border);
+ border-radius: 999px;
+ backdrop-filter: blur(8px);
+ z-index: 4;
+ max-width: calc(100% - 24px);
+ overflow-x: auto;
+ scrollbar-width: none;
+ opacity: 0;
+ transition: opacity 0.2s, transform 0.2s;
+ pointer-events: none;
+ }
+ .emote-strip::-webkit-scrollbar { display: none; }
+ .emote-strip.is-visible {
+ opacity: 1;
+ transform: translateX(-50%) translateY(0);
+ pointer-events: auto;
+ }
+ .emote-chip {
+ appearance: none;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid transparent;
+ border-radius: 999px;
+ color: var(--text);
+ font: inherit;
+ font-size: 14px;
+ cursor: pointer;
+ width: 32px;
+ height: 32px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ transition: background 0.15s, border-color 0.15s, transform 0.15s;
+ }
+ .emote-chip:hover { background: rgba(214, 255, 61, 0.12); border-color: rgba(214, 255, 61, 0.4); transform: scale(1.05); }
+ .emote-chip.is-active { background: rgba(214, 255, 61, 0.2); border-color: var(--accent); }
+ .emote-strip-close {
+ appearance: none;
+ background: transparent;
+ border: none;
+ color: var(--muted);
+ font-size: 16px;
+ cursor: pointer;
+ width: 26px;
+ height: 32px;
+ padding: 0;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ }
+ .emote-strip-close:hover { color: var(--text); }
.cta {
background: var(--accent);
@@ -352,8 +674,64 @@
gap: 16px;
}
#save-loading img { width: 56px; height: 56px; animation: pulse 1.6s ease-in-out infinite; }
+ #save-loading[data-state='error'] img { animation: none; opacity: 0.5; }
#save-loading .label { color: rgba(255, 255, 255, 0.82); font-size: 15px; font-weight: 500; }
- #save-loading .sublabel { color: rgba(255, 255, 255, 0.42); font-size: 12.5px; }
+ #save-loading[data-state='error'] .label { color: #ffb3b3; }
+ #save-loading .sublabel {
+ color: rgba(255, 255, 255, 0.42);
+ font-size: 12.5px;
+ max-width: 360px;
+ text-align: center;
+ line-height: 1.5;
+ }
+ #save-loading .progress {
+ width: min(320px, 70vw);
+ height: 4px;
+ background: rgba(255, 255, 255, 0.08);
+ border-radius: 999px;
+ overflow: hidden;
+ margin-top: 4px;
+ }
+ #save-loading .progress[hidden] { display: none; }
+ #save-loading .progress-bar {
+ height: 100%;
+ width: 0%;
+ background: var(--accent);
+ border-radius: 999px;
+ transition: width 0.18s ease-out;
+ }
+ #save-loading .error-actions {
+ display: flex;
+ gap: 10px;
+ margin-top: 8px;
+ }
+ #save-loading .error-actions[hidden] { display: none; }
+ #save-loading .retry-btn {
+ background: var(--accent);
+ color: var(--accent-ink);
+ border: none;
+ border-radius: 10px;
+ padding: 10px 18px;
+ font: inherit;
+ font-weight: 600;
+ cursor: pointer;
+ transition: filter 0.15s;
+ }
+ #save-loading .retry-btn:hover { filter: brightness(1.06); }
+ #save-loading .cancel-btn {
+ background: transparent;
+ color: rgba(255, 255, 255, 0.72);
+ border: 1.5px solid rgba(255, 255, 255, 0.18);
+ border-radius: 10px;
+ padding: 10px 16px;
+ font: inherit;
+ cursor: pointer;
+ transition: border-color 0.15s, color 0.15s;
+ }
+ #save-loading .cancel-btn:hover {
+ border-color: rgba(255, 255, 255, 0.32);
+ color: #fff;
+ }
@keyframes pulse {
0%, 100% { opacity: 0.55; transform: scale(1); }
50% { opacity: 1; transform: scale(1.06); }
@@ -438,6 +816,7 @@
4.x does not expose morphTargetInfluences as a stable API.
-->
<div id="mv-container" class="mv-container" aria-label="Avatar preview"></div>
+ <div id="emote-strip" class="emote-strip" role="toolbar" aria-label="Animations"></div>
</div>
<div class="panel">
@@ -469,35 +848,61 @@
<div class="unlocks" aria-label="What saving unlocks">
<p class="unlocks-title">Your avatar unlocks</p>
<ul class="feature-grid">
- <li class="feature-tile" title="glTF / GLB body with animations, expressions, and a posable rig — mobile, desktop, and XR-ready.">
- <span class="feature-icon" aria-hidden="true">🧍</span>
- <span class="feature-name">3D Body</span>
- <span class="feature-desc">Animations, expressions, posable rig</span>
+ <li>
+ <button class="feature-tile" type="button" data-feature="body" aria-label="Try animations on your avatar">
+ <span class="feature-icon" aria-hidden="true">🧍</span>
+ <span class="feature-name">3D Body</span>
+ <span class="feature-desc">Animations, expressions, posable rig</span>
+ <span class="feature-try" aria-hidden="true">Try →</span>
+ </button>
+ </li>
+ <li>
+ <button class="feature-tile" type="button" data-feature="voice" aria-label="Try talking to your avatar">
+ <span class="feature-icon" aria-hidden="true">🗣️</span>
+ <span class="feature-name">Voice &amp; Persona</span>
+ <span class="feature-desc">Mic in, LiveKit voice out, pinned memory</span>
+ <span class="feature-try" aria-hidden="true">Try →</span>
+ </button>
</li>
- <li class="feature-tile" title="Low-latency voice via LiveKit, ElevenLabs voices, and a system prompt you control.">
- <span class="feature-icon" aria-hidden="true">🗣️</span>
- <span class="feature-name">Voice &amp; Persona</span>
- <span class="feature-desc">Mic in, LiveKit voice out, pinned memory</span>
+ <li>
+ <button class="feature-tile" type="button" data-feature="identity" aria-label="See on-chain identity details">
+ <span class="feature-icon" aria-hidden="true">🪪</span>
+ <span class="feature-name">On-Chain Identity</span>
+ <span class="feature-desc">Solana wallet, transferable asset</span>
+ <span class="feature-try" aria-hidden="true">See →</span>
+ </button>
</li>
- <li class="feature-tile" title="Each agent is a Metaplex Core asset on Solana — transferable, composable, browsable in any wallet.">
- <span class="feature-icon" aria-hidden="true">🪪</span>
- <span class="feature-name">On-Chain Identity</span>
- <span class="feature-desc">Solana wallet, transferable asset</span>
+ <li>
+ <button class="feature-tile" type="button" data-feature="paid" aria-label="See paid-skills pricing example">
+ <span class="feature-icon" aria-hidden="true">💸</span>
+ <span class="feature-name">Paid Skills</span>
+ <span class="feature-desc">Earn USDC per call via x402</span>
+ <span class="feature-try" aria-hidden="true">See →</span>
+ </button>
</li>
- <li class="feature-tile" title="Charge per call in USDC over the x402 protocol. Other agents pay yours automatically.">
- <span class="feature-icon" aria-hidden="true">💸</span>
- <span class="feature-name">Paid Skills</span>
- <span class="feature-desc">Earn USDC per call via x402</span>
+ <li>
+ <button class="feature-tile" type="button" data-feature="embed" aria-label="See embed snippet">
+ <span class="feature-icon" aria-hidden="true">🧩</span>
+ <span class="feature-name">Embed Anywhere</span>
+ <span class="feature-desc">One snippet, any site or app</span>
+ <span class="feature-try" aria-hidden="true">See →</span>
+ </button>
</li>
- <li class="feature-tile" title="One-tag embed via /embed.js, or the agent-3d Web Component. Drop your agent on any page.">
- <span class="feature-icon" aria-hidden="true">🧩</span>
- <span class="feature-name">Embed Anywhere</span>
- <span class="feature-desc">One snippet, any site or app</span>
+ <li>
+ <button class="feature-tile" type="button" data-feature="reputation" aria-label="See reputation system">
+ <span class="feature-icon" aria-hidden="true">⭐</span>
+ <span class="feature-name">Reputation</span>
+ <span class="feature-desc">Reviews, history, and validation</span>
+ <span class="feature-try" aria-hidden="true">See →</span>
+ </button>
</li>
- <li class="feature-tile" title="Signed feedback, call history, and validation events accrue to your agent — visible to anyone deciding whether to trust it.">
- <span class="feature-icon" aria-hidden="true">⭐</span>
- <span class="feature-name">Reputation</span>
- <span class="feature-desc">Reviews, history, and validation</span>
+ <li>
+ <button class="feature-tile" type="button" data-feature="download" aria-label="Download this avatar as GLB or USDZ">
+ <span class="feature-icon" aria-hidden="true">📦</span>
+ <span class="feature-name">Download</span>
+ <span class="feature-desc">GLB for the web, USDZ for iOS AR</span>
+ <span class="feature-try" aria-hidden="true">Save →</span>
+ </button>
</li>
</ul>
</div>
diff --git a/public/widgets-gallery/gallery.js b/public/widgets-gallery/gallery.js
index fc1107a9e..f3281e812 100644
--- a/public/widgets-gallery/gallery.js
+++ b/public/widgets-gallery/gallery.js
@@ -15,6 +15,9 @@ const TYPE_COLORS = {
'talking-agent': '#10b981',
passport: '#a78bfa',
'hotspot-tour': '#f97316',
+ 'pumpfun-feed': '#ec4899',
+ 'kol-trades': '#22d3ee',
+ 'live-trades-canvas': '#f43f5e',
};
// Fade-in cards as they scroll into view
@@ -150,7 +153,7 @@ function renderShowcase(w) {
root.dataset.type = w.type;
root.setAttribute('aria-labelledby', `sc-${w.id}-title`);
- const widgetUrl = `${ORIGIN}/app#widget=${encodeURIComponent(w.id)}&kiosk=true`;
+ const widgetUrl = `${ORIGIN}/widget#widget=${encodeURIComponent(w.id)}&kiosk=true`;
const pageUrl = `${ORIGIN}/w/${encodeURIComponent(w.id)}`;
const allowAttr =
@@ -203,11 +206,13 @@ function renderShowcase(w) {
placeholder.querySelector('.play-btn').addEventListener('click', loadIframe);
frame.appendChild(placeholder);
- // Auto-load when the frame is 50 % visible for 1 s
+ // Auto-load when the frame becomes 50% visible. No artificial delay —
+ // IntersectionObserver only fires after layout, so by the time we get
+ // here the user has actually scrolled the tile into view.
const autoObs = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting) {
- setTimeout(() => loadIframe(), 1000);
+ loadIframe();
autoObs.disconnect();
}
},
diff --git a/public/widgets-gallery/showcase.json b/public/widgets-gallery/showcase.json
index c75e46d12..dbcfce09c 100644
--- a/public/widgets-gallery/showcase.json
+++ b/public/widgets-gallery/showcase.json
@@ -1,5 +1,5 @@
{
- "_comment": "Each entry is a showcase widget. Replace placeholder ids with real wdgt_ ids once created in Studio.",
+ "_comment": "Each entry is a showcase widget. wdgt_demo_* ids are resolved server-side by api/widgets/_demo-fixtures.js.",
"widgets": [
{
"type": "turntable",
@@ -45,6 +45,33 @@
"width": 800,
"height": 600,
"features": ["Click hotspots to explore", "Guided camera transitions", "Great for product showcases"]
+ },
+ {
+ "type": "pumpfun-feed",
+ "label": "Pump.fun Live Feed",
+ "tagline": "Solana agent narrates pump.fun claims and graduations in real time.",
+ "id": "wdgt_demo_pumpfun",
+ "width": 520,
+ "height": 640,
+ "features": ["Streams live from pump.fun", "Agent reacts and speaks", "Filter by tier and event kind"]
+ },
+ {
+ "type": "kol-trades",
+ "label": "Smart Money Feed",
+ "tagline": "Live buy/sell activity from KOL and whale wallets for any token.",
+ "id": "wdgt_demo_koltrad",
+ "width": 520,
+ "height": 560,
+ "features": ["Per-token KOL flow", "Polls every 30s", "Wallet labels and PnL"]
+ },
+ {
+ "type": "live-trades-canvas",
+ "label": "Live Trades Canvas",
+ "tagline": "Particle visualization of pump.fun buys and sells.",
+ "id": "wdgt_demo_livetrd",
+ "width": 600,
+ "height": 400,
+ "features": ["Real-time WebGL canvas", "Green/red particles for buys/sells", "Size scales with USD"]
}
]
}
diff --git a/src/app-next-overlay.js b/src/app-next-overlay.js
new file mode 100644
index 000000000..08d2c2ed4
--- /dev/null
+++ b/src/app-next-overlay.js
@@ -0,0 +1,586 @@
+/**
+ * app-next overlay — UX preview layer for /app-next demo.
+ *
+ * Boots after /src/app.js (the real production viewer + agent system) and
+ * adds the new UX surface:
+ * 1. Stage polish — transparent canvas so the CSS floor-glow shows through.
+ * 2. Camera idle drift — gentle auto-rotate that pauses on interaction.
+ * 3. "Try X" rotating invitation pill (driven by the real animation manifest).
+ * 4. Compact animation picker sheet with search + grid (replaces the strip).
+ * 5. Single-hierarchy action bar: Animations, Upload, Save / Sign-in.
+ * 6. Header menus (explore + auth) with open/close + outside-click dismiss.
+ * 7. Keyboard shortcuts: A (animations), U (upload), Esc (close sheet).
+ * 8. First-visit hint shown once per browser.
+ *
+ * This file deliberately does NOT touch any other surface — same /src/app.js
+ * bootstraps the viewer, same animation manifest, same auth APIs.
+ */
+
+import { getMe, readAuthHint, saveRemoteGlbToAccount } from './account.js';
+
+const STORAGE_HINT_KEY = 'nxt:first-hint-dismissed';
+const TRY_ROTATE_MS = 8000;
+
+// Curated subset for the rotating "Try X" prompt — these clips look great as
+// 2-second teasers and crossfade cleanly back to idle. Names match the entries
+// in /public/animations/manifest.json.
+const TRY_PICKS = [
+ { name: 'av-waving', icon: '👋', label: 'Wave' },
+ { name: 'av-superhero-jump', icon: '🦸', label: 'Superhero jump' },
+ { name: 'boxer-dance', icon: '🥊', label: 'Boxer dance' },
+ { name: 'av-brag-and-clap', icon: '👏', label: 'Brag & clap' },
+ { name: 'facepalm', icon: '🤦', label: 'Facepalm' },
+ { name: 'av-flex-arm', icon: '💪', label: 'Flex' },
+ { name: 'covereyes', icon: '🙈', label: 'Cover eyes' },
+ { name: 'av-walk-crouching', icon: '🚶', label: 'Sneak walk' },
+];
+
+// Animation defs ship with an `icon` field that's usually right, but a few
+// common ones are missing or have wrong glyphs — patch them here so the grid
+// always reads cleanly. Fallback chain: icon override → manifest icon → ✨.
+const ICON_OVERRIDES = {
+ idle: '🧍',
+ lookdown: '👀',
+ covereyes: '🙈',
+ facepalm: '🤦',
+ 'av-waving': '👋',
+ 'av-superhero-jump': '🦸',
+ 'boxer-dance': '🥊',
+ 'av-brag-and-clap': '👏',
+ 'av-flex-arm': '💪',
+ 'av-walk-crouching': '🚶',
+ 'av-idle-breath': '🧘',
+ 'av-waiting': '🕰️',
+};
+
+document.addEventListener('DOMContentLoaded', boot);
+
+function boot() {
+ console.info('[nxt] boot');
+ wireExploreMenu();
+ wireUserMenu();
+ wireFirstHint();
+ wireKeyboardShortcuts();
+ wirePrimaryCTA();
+ wireAnimationSheet();
+
+ // The viewer is created asynchronously by App. Poll briefly until it's
+ // ready, then attach stage polish + start the Try pill rotation.
+ waitForViewer().then((viewer) => {
+ if (!viewer) {
+ console.warn('[nxt] viewer never appeared — stage polish skipped');
+ return;
+ }
+ console.info('[nxt] viewer ready');
+ polishStage(viewer);
+ startTryPillRotation(viewer);
+ startCameraDrift(viewer);
+ });
+
+ // Auth state can resolve before or after viewer; refresh CTA when ready.
+ refreshAuthState();
+ // Refresh once more when other tabs sign in/out.
+ window.addEventListener('storage', (e) => {
+ if (e.key === 'nxt-auth-touch' || e.key?.startsWith('auth')) refreshAuthState();
+ });
+}
+
+// ── Viewer wait ───────────────────────────────────────────────────────────
+
+function waitForViewer(timeoutMs = 15000) {
+ return new Promise((resolve) => {
+ const started = Date.now();
+ const tick = () => {
+ const v = window.VIEWER?.viewer;
+ if (v && v.scene && v.renderer && v.controls) return resolve(v);
+ if (Date.now() - started > timeoutMs) return resolve(null);
+ setTimeout(tick, 120);
+ };
+ tick();
+ });
+}
+
+// ── Stage polish ──────────────────────────────────────────────────────────
+
+function polishStage(viewer) {
+ // Make the canvas transparent so the CSS radial floor-glow + vignette
+ // (rendered behind via the same stacking context) show through. The viewer
+ // owns its own transparentBg state — flipping it directly survives any
+ // subsequent updateBackground() call (saved scene prefs, brand sync, etc).
+ try {
+ viewer.state.transparentBg = true;
+ viewer.updateBackground();
+ } catch (err) {
+ console.warn('[nxt] could not set transparent canvas', err);
+ }
+}
+
+// ── Camera idle drift ─────────────────────────────────────────────────────
+
+function startCameraDrift(viewer) {
+ if (!viewer.controls) return;
+
+ let userInteracted = false;
+ let resumeTimer = null;
+
+ const enableDrift = () => {
+ // Mirror viewer.state so updateDisplay() doesn't undo us later.
+ viewer.state.autoRotate = true;
+ viewer.controls.autoRotate = true;
+ viewer.controls.autoRotateSpeed = 0.35; // very slow — alive, not spinning
+ viewer.invalidate?.();
+ };
+
+ const pauseDrift = () => {
+ viewer.state.autoRotate = false;
+ viewer.controls.autoRotate = false;
+ userInteracted = true;
+ clearTimeout(resumeTimer);
+ // Resume after 10s of no interaction
+ resumeTimer = setTimeout(() => {
+ if (userInteracted) {
+ userInteracted = false;
+ enableDrift();
+ }
+ }, 10000);
+ };
+
+ enableDrift();
+ viewer.controls.addEventListener('start', pauseDrift);
+}
+
+// ── Try pill ──────────────────────────────────────────────────────────────
+
+function startTryPillRotation(viewer) {
+ const pill = document.getElementById('nxt-try-pill');
+ const iconEl = document.getElementById('nxt-try-pill-icon');
+ const nameEl = document.getElementById('nxt-try-pill-name');
+ const btn = document.getElementById('nxt-try-pill-btn');
+ const nextBtn = document.getElementById('nxt-try-pill-next');
+ if (!pill || !btn) return;
+
+ let order = TRY_PICKS.slice();
+ let cursor = Math.floor(Math.random() * order.length);
+ let intervalId = null;
+
+ const render = () => {
+ const pick = order[cursor % order.length];
+ iconEl.textContent = pick.icon;
+ nameEl.textContent = pick.label;
+ pill.dataset.clip = pick.name;
+ };
+
+ const advance = () => {
+ cursor = (cursor + 1) % order.length;
+ render();
+ };
+
+ // Wait until at least one clip is loadable before showing the pill.
+ pollForClips(viewer).then((defs) => {
+ console.info('[nxt] pollForClips resolved, defs=', defs?.length || 0);
+ // Filter picks down to clips that exist in this avatar's manifest.
+ const available = new Set(getAvailableClipNames(viewer));
+ if (available.size > 0) {
+ order = TRY_PICKS.filter((p) => available.has(p.name));
+ if (order.length === 0) order = TRY_PICKS.slice(); // fall back
+ }
+ console.info('[nxt] try pill picks count=', order.length);
+ cursor = Math.floor(Math.random() * order.length);
+ render();
+ pill.hidden = false;
+ intervalId = setInterval(advance, TRY_ROTATE_MS);
+ });
+
+ btn.addEventListener('click', () => {
+ const pick = order[cursor % order.length];
+ playClip(viewer, pick.name);
+ // Pause rotation after explicit try — let the user enjoy what they picked
+ clearInterval(intervalId);
+ intervalId = null;
+ // Resume after 12s if no further interaction
+ setTimeout(() => {
+ if (!intervalId) intervalId = setInterval(advance, TRY_ROTATE_MS);
+ }, 12000);
+ });
+
+ nextBtn.addEventListener('click', advance);
+}
+
+function pollForClips(viewer, timeoutMs = 12000) {
+ return new Promise((resolve) => {
+ const started = Date.now();
+ const tick = () => {
+ const defs = viewer.animationManager?.getAnimationDefs?.() || [];
+ if (defs.length > 0) return resolve(defs);
+ if (Date.now() - started > timeoutMs) return resolve([]);
+ setTimeout(tick, 300);
+ };
+ tick();
+ });
+}
+
+function getAvailableClipNames(viewer) {
+ const defs = viewer.animationManager?.getAnimationDefs?.() || [];
+ return defs.map((d) => d.name);
+}
+
+function playClip(viewer, name) {
+ const mgr = viewer.animationManager;
+ if (!mgr) return;
+
+ const defs = mgr.getAnimationDefs();
+ const def = defs.find((d) => d.name === name);
+ if (!def) return;
+
+ // ensureLoaded fetches the JSON clip if not yet cached, then play() runs it.
+ mgr.ensureLoaded(name)
+ .then(() => mgr.play(name))
+ .catch((err) => console.warn('[app-next] clip play failed', name, err));
+}
+
+// ── Animation sheet ───────────────────────────────────────────────────────
+
+function wireAnimationSheet() {
+ const btn = document.getElementById('nxt-anim-btn');
+ const sheet = document.getElementById('nxt-anim-sheet');
+ const closeBtn = document.getElementById('nxt-anim-sheet-close');
+ const search = document.getElementById('nxt-anim-search');
+ const grid = document.getElementById('nxt-anim-grid');
+ if (!btn || !sheet || !grid) return;
+
+ let rendered = false;
+
+ const open = () => {
+ sheet.hidden = false;
+ sheet.setAttribute('aria-hidden', 'false');
+ btn.setAttribute('aria-expanded', 'true');
+ if (!rendered) {
+ renderGrid().then(() => {
+ rendered = true;
+ });
+ }
+ setTimeout(() => search?.focus(), 60);
+ };
+
+ const close = () => {
+ sheet.hidden = true;
+ sheet.setAttribute('aria-hidden', 'true');
+ btn.setAttribute('aria-expanded', 'false');
+ };
+
+ btn.addEventListener('click', () => {
+ if (sheet.hidden) open();
+ else close();
+ });
+
+ closeBtn?.addEventListener('click', close);
+
+ // Esc closes; outside click closes.
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape' && !sheet.hidden) close();
+ });
+
+ document.addEventListener('pointerdown', (e) => {
+ if (sheet.hidden) return;
+ if (sheet.contains(e.target) || btn.contains(e.target)) return;
+ close();
+ });
+
+ search?.addEventListener('input', filterGrid);
+
+ async function renderGrid() {
+ const viewer = await waitForViewer();
+ if (!viewer) {
+ grid.innerHTML =
+ '<div class="nxt-anim-empty">Viewer not ready — reload to try again.</div>';
+ return;
+ }
+ await pollForClips(viewer);
+ const defs = viewer.animationManager.getAnimationDefs();
+ if (!defs || defs.length === 0) {
+ grid.innerHTML =
+ '<div class="nxt-anim-empty">This avatar has no animations.</div>';
+ return;
+ }
+
+ grid.innerHTML = '';
+ const activeName = viewer.animationManager.currentName;
+ for (const def of defs) {
+ const card = document.createElement('button');
+ card.type = 'button';
+ card.className = 'nxt-anim-card';
+ card.dataset.name = def.name;
+ card.setAttribute('aria-pressed', activeName === def.name ? 'true' : 'false');
+ const icon = ICON_OVERRIDES[def.name] || def.icon || '✨';
+ const label = def.label || prettify(def.name);
+ card.innerHTML =
+ `<span class="nxt-anim-card__icon">${escHtml(icon)}</span>` +
+ `<span>${escHtml(label)}</span>`;
+ card.addEventListener('click', () => {
+ playClip(viewer, def.name);
+ // Sync aria-pressed across all cards
+ grid.querySelectorAll('.nxt-anim-card').forEach((c) => {
+ c.setAttribute('aria-pressed', c.dataset.name === def.name ? 'true' : 'false');
+ });
+ });
+ grid.appendChild(card);
+ }
+
+ // Keep card pressed-state in sync when clip changes from elsewhere
+ // (try-pill, keyboard shortcut, programmatic). Chain through any prior
+ // onChange handler so we don't clobber a subscriber the production
+ // viewer (or another overlay) may have installed.
+ const prevOnChange = viewer.animationManager.onChange;
+ viewer.animationManager.onChange = (...args) => {
+ try { prevOnChange?.(...args); } catch (e) { console.warn('[nxt] prior onChange threw', e); }
+ const current = viewer.animationManager.currentName;
+ grid.querySelectorAll('.nxt-anim-card').forEach((c) => {
+ c.setAttribute('aria-pressed', c.dataset.name === current ? 'true' : 'false');
+ });
+ };
+ }
+
+ function filterGrid() {
+ const q = (search?.value || '').trim().toLowerCase();
+ const cards = grid.querySelectorAll('.nxt-anim-card');
+ let visible = 0;
+ cards.forEach((c) => {
+ const hay = (c.textContent + ' ' + c.dataset.name).toLowerCase();
+ const match = !q || hay.includes(q);
+ c.style.display = match ? '' : 'none';
+ if (match) visible++;
+ });
+ // Remove any prior "no matches" hint
+ grid.querySelectorAll('.nxt-anim-empty[data-search]').forEach((n) => n.remove());
+ if (visible === 0) {
+ const empty = document.createElement('div');
+ empty.className = 'nxt-anim-empty';
+ empty.dataset.search = '1';
+ empty.textContent = `No clips matching "${q}".`;
+ grid.appendChild(empty);
+ }
+ }
+}
+
+// ── Header menus ──────────────────────────────────────────────────────────
+
+function wireExploreMenu() {
+ const btn = document.getElementById('nxt-more-btn');
+ const menu = document.getElementById('nxt-more-menu');
+ if (!btn || !menu) return;
+
+ const close = () => {
+ menu.hidden = true;
+ btn.setAttribute('aria-expanded', 'false');
+ };
+
+ btn.addEventListener('click', (e) => {
+ e.stopPropagation();
+ if (menu.hidden) {
+ menu.hidden = false;
+ btn.setAttribute('aria-expanded', 'true');
+ } else {
+ close();
+ }
+ });
+
+ document.addEventListener('pointerdown', (e) => {
+ if (menu.hidden) return;
+ if (menu.contains(e.target) || btn.contains(e.target)) return;
+ close();
+ });
+
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape' && !menu.hidden) close();
+ });
+}
+
+function wireUserMenu() {
+ const btn = document.getElementById('nav-user-btn');
+ const menu = document.getElementById('nav-user-menu');
+ if (!btn || !menu) return;
+
+ const close = () => {
+ menu.hidden = true;
+ btn.setAttribute('aria-expanded', 'false');
+ };
+
+ btn.addEventListener('click', (e) => {
+ e.stopPropagation();
+ if (menu.hidden) {
+ menu.hidden = false;
+ btn.setAttribute('aria-expanded', 'true');
+ } else {
+ close();
+ }
+ });
+
+ document.addEventListener('pointerdown', (e) => {
+ if (menu.hidden) return;
+ if (menu.contains(e.target) || btn.contains(e.target)) return;
+ close();
+ });
+}
+
+// ── Auth state + primary CTA ──────────────────────────────────────────────
+
+async function refreshAuthState() {
+ const signinEl = document.getElementById('nav-sign-in');
+ const userWrap = document.getElementById('nav-user-wrap');
+ const userLabel = document.getElementById('nav-user-label');
+ const profileLink = document.getElementById('nav-my-profile-link');
+ const primary = document.getElementById('nxt-primary');
+ const primaryLabel = document.getElementById('nxt-primary-label');
+
+ // readAuthHint is a synchronous local-storage lookup — useful for the first
+ // paint before getMe() resolves. We always confirm with the real API.
+ const hint = readAuthHint?.();
+ if (hint?.username && userLabel) {
+ userLabel.textContent = hint.username;
+ }
+
+ let me = null;
+ try {
+ me = await getMe();
+ } catch {
+ me = null;
+ }
+
+ if (me?.username) {
+ if (signinEl) signinEl.hidden = true;
+ if (userWrap) userWrap.hidden = false;
+ if (userLabel) userLabel.textContent = me.username;
+ if (profileLink) profileLink.href = `/profile/${encodeURIComponent(me.username)}`;
+ if (primaryLabel) primaryLabel.textContent = 'Save to account';
+ if (primary) primary.dataset.mode = 'save';
+ } else {
+ if (signinEl) signinEl.hidden = false;
+ if (userWrap) userWrap.hidden = true;
+ if (primaryLabel) primaryLabel.textContent = 'Sign in to save';
+ if (primary) primary.dataset.mode = 'signin';
+ }
+}
+
+function wirePrimaryCTA() {
+ const primary = document.getElementById('nxt-primary');
+ const primaryLabel = document.getElementById('nxt-primary-label');
+ if (!primary) return;
+
+ // Held outside the closure so a rapid second save can clear the prior
+ // "Saved ✓ → Save to account" revert before it fires.
+ let revertTimer = null;
+
+ primary.addEventListener('click', async () => {
+ const mode = primary.dataset.mode || 'signin';
+ if (mode !== 'save') {
+ location.href = '/login?return=' + encodeURIComponent(location.pathname);
+ return;
+ }
+
+ // Save the current model to the signed-in user's account.
+ const viewer = window.VIEWER?.viewer;
+ const app = window.VIEWER?.app;
+ const url = app?._currentModelUrl;
+ if (!viewer || !url) {
+ toast('Nothing to save yet — load a model first.');
+ return;
+ }
+
+ const original = 'Save to account';
+ if (revertTimer) {
+ clearTimeout(revertTimer);
+ revertTimer = null;
+ }
+ if (primaryLabel) primaryLabel.textContent = 'Saving…';
+ primary.disabled = true;
+ try {
+ const res = await saveRemoteGlbToAccount(url, {
+ name: app?._currentModelName || 'Avatar',
+ });
+ if (res?.ok && res.id) {
+ if (primaryLabel) primaryLabel.textContent = 'Saved ✓';
+ toast(`Saved to your account.`, `/avatars/${res.id}`);
+ } else {
+ throw new Error(res?.error || 'save failed');
+ }
+ } catch (err) {
+ console.warn('[app-next] save failed', err);
+ if (primaryLabel) primaryLabel.textContent = original;
+ toast('Save failed — try again.');
+ } finally {
+ revertTimer = setTimeout(() => {
+ revertTimer = null;
+ if (primaryLabel && primaryLabel.textContent === 'Saved ✓') {
+ primaryLabel.textContent = original;
+ }
+ primary.disabled = false;
+ }, 2400);
+ }
+ });
+}
+
+function toast(message, href) {
+ const el = document.createElement('div');
+ el.className = 'save-toast';
+ el.style.zIndex = 9999;
+ el.innerHTML = href
+ ? `${escHtml(message)} <a href="${escHtml(href)}">View →</a>`
+ : escHtml(message);
+ document.body.appendChild(el);
+ setTimeout(() => el.remove(), 4200);
+}
+
+// ── First-visit hint ──────────────────────────────────────────────────────
+
+function wireFirstHint() {
+ const hint = document.getElementById('nxt-first-hint');
+ const close = document.getElementById('nxt-first-hint-close');
+ if (!hint || !close) return;
+ try {
+ if (localStorage.getItem(STORAGE_HINT_KEY) === '1') return;
+ } catch {}
+ hint.hidden = false;
+ const dismiss = () => {
+ hint.hidden = true;
+ try {
+ localStorage.setItem(STORAGE_HINT_KEY, '1');
+ } catch {}
+ };
+ close.addEventListener('click', dismiss);
+ setTimeout(dismiss, 14000);
+}
+
+// ── Keyboard shortcuts ────────────────────────────────────────────────────
+
+function wireKeyboardShortcuts() {
+ document.addEventListener('keydown', (e) => {
+ if (e.target.matches('input, textarea, select, [contenteditable="true"]')) return;
+ if (e.metaKey || e.ctrlKey || e.altKey) return;
+ if (e.key === 'a' || e.key === 'A') {
+ e.preventDefault();
+ document.getElementById('nxt-anim-btn')?.click();
+ } else if (e.key === 'u' || e.key === 'U') {
+ e.preventDefault();
+ document.getElementById('file-input')?.click();
+ }
+ });
+}
+
+// ── Helpers ───────────────────────────────────────────────────────────────
+
+function escHtml(s) {
+ return String(s ?? '').replace(/[&<>"']/g, (ch) => ({
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#39;',
+ })[ch]);
+}
+
+function prettify(name) {
+ return String(name)
+ .replace(/^av-/, '')
+ .replace(/[-_]/g, ' ')
+ .replace(/\b\w/g, (c) => c.toUpperCase());
+}
diff --git a/src/create-review-features.js b/src/create-review-features.js
new file mode 100644
index 000000000..793ac1fc2
--- /dev/null
+++ b/src/create-review-features.js
@@ -0,0 +1,399 @@
+/**
+ * Interactive "try it" actions for the /create-review feature grid.
+ *
+ * Each of the six capability tiles on /create-review opens a real preview of
+ * that capability — not a marketing modal. Voice spins up the actual talk
+ * overlay against the staged GLB; the others render concrete, copy-able
+ * examples (embed snippet, USDC pricing, Solana wallet shape, reputation
+ * card) so the user sees what they're signing up for *before* the auth wall.
+ *
+ * Wiring lives in create-review.js. This module only owns: feature-modal DOM,
+ * emote-strip behaviour, and the talk-overlay invocation.
+ */
+
+import { openTalkMode } from './voice/talk-mode.js';
+import { downloadAvatar } from './avatar-export.js';
+
+// ── Feature-preview modal ────────────────────────────────────────────────────
+
+let activeModal = null;
+let escHandler = null;
+
+/** Open a feature-preview modal. Body may be an HTMLElement or HTML string. */
+export function openFeatureModal({ icon, title, lede, body, actions }) {
+ closeFeatureModal();
+
+ const backdrop = document.createElement('div');
+ backdrop.className = 'fm-backdrop';
+ backdrop.setAttribute('role', 'dialog');
+ backdrop.setAttribute('aria-modal', 'true');
+ backdrop.innerHTML = `
+ <div class="fm-dialog">
+ <div class="fm-head">
+ <div class="fm-icon" aria-hidden="true">${icon}</div>
+ <div class="fm-head-text">
+ <h3></h3>
+ <p></p>
+ </div>
+ <button class="fm-close" type="button" aria-label="Close">✕</button>
+ </div>
+ <div class="fm-body"></div>
+ <div class="fm-actions"></div>
+ </div>
+ `;
+ backdrop.querySelector('.fm-head-text h3').textContent = title;
+ backdrop.querySelector('.fm-head-text p').textContent = lede;
+
+ const bodyEl = backdrop.querySelector('.fm-body');
+ if (body instanceof HTMLElement) bodyEl.appendChild(body);
+ else if (typeof body === 'string') bodyEl.innerHTML = body;
+
+ const actionsEl = backdrop.querySelector('.fm-actions');
+ if (Array.isArray(actions) && actions.length) {
+ for (const a of actions) {
+ const btn = document.createElement('button');
+ btn.type = 'button';
+ btn.className = 'fm-cta' + (a.ghost ? ' ghost' : '');
+ btn.textContent = a.label;
+ btn.addEventListener('click', () => {
+ a.onClick?.();
+ if (a.dismiss !== false) closeFeatureModal();
+ });
+ actionsEl.appendChild(btn);
+ }
+ } else {
+ actionsEl.remove();
+ }
+
+ backdrop.addEventListener('click', (e) => {
+ if (e.target === backdrop) closeFeatureModal();
+ });
+ backdrop.querySelector('.fm-close').addEventListener('click', closeFeatureModal);
+
+ escHandler = (e) => {
+ if (e.key === 'Escape') closeFeatureModal();
+ };
+ document.addEventListener('keydown', escHandler);
+
+ document.body.appendChild(backdrop);
+ activeModal = backdrop;
+
+ // Wire any "Copy" buttons rendered inside the body.
+ for (const copyBtn of backdrop.querySelectorAll('.fm-copy')) {
+ copyBtn.addEventListener('click', async () => {
+ const codeEl = copyBtn.closest('.fm-code');
+ const text = codeEl?.dataset.copy ?? codeEl?.textContent.replace(/Copy\s*$/, '').trim();
+ if (!text) return;
+ try {
+ await navigator.clipboard.writeText(text);
+ copyBtn.classList.add('copied');
+ copyBtn.textContent = 'Copied';
+ setTimeout(() => {
+ copyBtn.classList.remove('copied');
+ copyBtn.textContent = 'Copy';
+ }, 1600);
+ } catch {
+ copyBtn.textContent = 'Press ⌘C';
+ }
+ });
+ }
+
+ return backdrop;
+}
+
+export function closeFeatureModal() {
+ if (!activeModal) return;
+ activeModal.remove();
+ activeModal = null;
+ if (escHandler) {
+ document.removeEventListener('keydown', escHandler);
+ escHandler = null;
+ }
+}
+
+// ── 3D Body: emote chip strip on the viewer ──────────────────────────────────
+
+// Hand-picked subset of the talk-emote bar that reads as "show me the moves"
+// rather than "play a 30-second cutscene". Wave/celebrate/dance/pray cover
+// happy/social/expressive ranges; idle is the return-to-rest.
+const PREVIEW_EMOTES = [
+ { name: 'av-idle-breath', icon: '🧍', label: 'Idle' },
+ { name: 'wave', icon: '👋', label: 'Wave' },
+ { name: 'celebrate', icon: '🎉', label: 'Celebrate' },
+ { name: 'dance', icon: '💃', label: 'Dance' },
+ { name: 'av-arm-flex', icon: '💪', label: 'Flex' },
+ { name: 'reaction', icon: '😲', label: 'React' },
+ { name: 'pray', icon: '🙏', label: 'Pray' },
+];
+
+let emoteStripWired = false;
+
+export async function toggleEmoteStrip({ scene, stripEl }) {
+ if (!scene || !stripEl) return;
+ const emotes = scene.getEmoteController();
+ if (!emotes) return;
+
+ // First call: populate the chips. Subsequent calls just toggle visibility.
+ if (!emoteStripWired) {
+ await emotes.loadManifest();
+ const present = new Set(emotes.getAllDefs().map((d) => d.name));
+ const available = PREVIEW_EMOTES.filter((e) => present.has(e.name));
+ stripEl.innerHTML =
+ available
+ .map(
+ (e) => `
+ <button class="emote-chip" type="button" data-emote="${e.name}" title="${e.label}" aria-label="${e.label}">
+ <span aria-hidden="true">${e.icon}</span>
+ </button>
+ `,
+ )
+ .join('') +
+ `<button class="emote-strip-close" type="button" aria-label="Close animations">✕</button>`;
+
+ stripEl.addEventListener('click', async (ev) => {
+ const close = ev.target.closest('.emote-strip-close');
+ if (close) {
+ stripEl.classList.remove('is-visible');
+ return;
+ }
+ const chip = ev.target.closest('.emote-chip');
+ if (!chip) return;
+ stripEl.querySelectorAll('.emote-chip.is-active').forEach((c) => c.classList.remove('is-active'));
+ chip.classList.add('is-active');
+ const name = chip.dataset.emote;
+ const ok = await scene.playEmote(name);
+ if (!ok) chip.classList.remove('is-active');
+ });
+
+ emoteStripWired = true;
+ }
+
+ stripEl.classList.toggle('is-visible');
+}
+
+// ── Voice: open the existing talk overlay against the staged GLB ─────────────
+
+/**
+ * Spin up the live talk overlay with the user's in-progress (unsaved) avatar.
+ * No agent_id means TalkController falls back to edge TTS for voice and the
+ * anonymous Groq tier for chat — both work without sign-in.
+ */
+export function openVoicePreview({ glbUrl, name }) {
+ const previewName = name?.trim() || 'Your new avatar';
+ const previewAvatar = {
+ id: 'preview-' + Date.now(),
+ name: previewName,
+ model_url: glbUrl,
+ };
+ openTalkMode({
+ avatar: previewAvatar,
+ systemPromptFn: () =>
+ `You are a friendly 3D avatar named "${previewName}" being previewed inside three.ws ` +
+ `before its owner saves it. Keep replies short (1–2 sentences), warm, and curious. ` +
+ `If asked what you can do, mention: voice, animations, on-chain identity on Solana, ` +
+ `paid skills via x402, embedding anywhere with one snippet, and a public reputation.`,
+ });
+}
+
+// ── Static info modals (identity / paid / embed / reputation) ────────────────
+
+export function openIdentityModal() {
+ openFeatureModal({
+ icon: '🪪',
+ title: 'On-Chain Identity',
+ lede: 'Your agent becomes a Metaplex Core asset on Solana the moment you save — transferable, composable, browsable in any wallet.',
+ body: `
+ <ul class="fm-bullets">
+ <li>Owned by your wallet, not by three.ws — transfer or sell at any time.</li>
+ <li>Metadata (avatar URL, persona, voice) is mutable by you, signed on-chain.</li>
+ <li>Discoverable in the registry by capability, price, and reputation.</li>
+ </ul>
+ <div class="fm-row">
+ <div>
+ <strong>Agent wallet</strong>
+ <div class="muted">Solana address · generated when you save</div>
+ </div>
+ <code class="fm-placeholder">&lt;your·agent·wallet&gt;</code>
+ </div>
+ <p class="fm-note">No network calls happen until you save — this preview is local.</p>
+ `,
+ actions: [{ label: 'Got it' }],
+ });
+}
+
+export function openPaidSkillsModal() {
+ openFeatureModal({
+ icon: '💸',
+ title: 'Paid Skills (x402)',
+ lede: 'Charge per call in USDC over the x402 protocol. Other agents (and apps) pay yours automatically — no API keys, no invoicing.',
+ body: `
+ <ul class="fm-bullets">
+ <li>Set a price per skill — chat, render, custom endpoint, anything.</li>
+ <li>Payments settle on Base in USDC, signed and verifiable.</li>
+ <li>Your earnings stream into your agent's wallet, withdrawable any time.</li>
+ </ul>
+ <div class="fm-row">
+ <div>
+ <strong>Example pricing</strong>
+ <div class="muted">You set this after saving</div>
+ </div>
+ <code style="color: var(--accent); font-weight: 600;">$0.05 / chat call</code>
+ </div>
+ <p class="fm-note">Listing your agent is free — you only pay if/when it earns.</p>
+ `,
+ actions: [{ label: 'Got it' }],
+ });
+}
+
+export function openEmbedModal() {
+ // Template, not a fake value: the placeholder reads as a parameter the user
+ // has to fill in after saving. Copy still works — they get the exact tag
+ // shape they'll need.
+ const snippet = `<script src="https://three.ws/embed.js"
+ data-agent="<your-agent-id>"
+ data-mode="full"
+ async></script>`;
+ openFeatureModal({
+ icon: '🧩',
+ title: 'Embed Anywhere',
+ lede: 'One tag drops your agent on any site — Webflow, Framer, raw HTML, React, Squarespace, you name it.',
+ body: `
+ <ul class="fm-bullets">
+ <li>WebGL renders in-browser. No install, no plugin.</li>
+ <li>Modes: floating bubble, fullscreen, inline card, or sidebar.</li>
+ <li>The <code>agent-3d</code> Web Component works in any framework.</li>
+ </ul>
+ <div class="fm-code" data-copy='${snippet.replace(/'/g, '&apos;')}'>${escapeHtml(snippet)}<button class="fm-copy" type="button">Copy</button></div>
+ <p class="fm-note">Save your avatar to get a real <code>data-agent</code> ID and a one-click copy of the live snippet.</p>
+ `,
+ actions: [{ label: 'Got it' }],
+ });
+}
+
+// ── Download: real GLB / USDZ / VRM export from the staged blob ──────────────
+
+const DOWNLOAD_FORMATS = [
+ {
+ id: 'glb',
+ label: 'GLB',
+ blurb: 'Universal 3D format. Works in Unity, Unreal, Blender, Sketchfab, model-viewer, every browser.',
+ ext: '.glb',
+ size: 'original',
+ },
+ {
+ id: 'vrm',
+ label: 'VRM',
+ blurb: 'Humanoid avatar standard. Plug into VRChat, Resonite, Mozilla Hubs, Warudo, VTube Studio, TalkingHead.',
+ ext: '.vrm',
+ size: 'similar to GLB',
+ },
+ {
+ id: 'usdz',
+ label: 'USDZ',
+ blurb: 'Apple AR. Tap-to-view in Safari on iPhone/iPad via Quick Look.',
+ ext: '.usdz',
+ size: 'similar to GLB',
+ },
+];
+
+/**
+ * @param {{ blob: Blob, name: string }} ctx
+ */
+export function openDownloadModal(ctx) {
+ const safeName = (ctx?.name || 'avatar').trim() || 'avatar';
+ const body = document.createElement('div');
+ body.innerHTML = `
+ <ul class="fm-download-list" role="list">
+ ${DOWNLOAD_FORMATS.map(
+ (f) => `
+ <li>
+ <button class="fm-download-row" type="button" data-format="${f.id}">
+ <div class="fm-download-head">
+ <strong>${f.label}</strong>
+ <span class="fm-download-ext">${f.ext}</span>
+ </div>
+ <div class="fm-download-blurb">${f.blurb}</div>
+ <div class="fm-download-status" data-status></div>
+ </button>
+ </li>
+ `,
+ ).join('')}
+ </ul>
+ <p class="fm-note">All conversion runs in your browser — no upload, no server.</p>
+ `;
+
+ openFeatureModal({
+ icon: '📦',
+ title: 'Download your avatar',
+ lede: 'Take your avatar anywhere — game engine, VR world, AR scene, sticker pack pipeline.',
+ body,
+ actions: [{ label: 'Done', ghost: true }],
+ });
+
+ body.querySelectorAll('.fm-download-row').forEach((row) => {
+ row.addEventListener('click', async () => {
+ const format = row.dataset.format;
+ const statusEl = row.querySelector('[data-status]');
+ if (row.dataset.busy === '1') return;
+ row.dataset.busy = '1';
+ statusEl.textContent = 'Preparing…';
+ statusEl.dataset.tone = 'busy';
+ try {
+ const result = await downloadAvatar(ctx.blob, {
+ format,
+ filename: safeName,
+ meta: { name: safeName },
+ });
+ statusEl.textContent = `Saved ${result.filename} · ${prettyBytes(result.size)}`;
+ statusEl.dataset.tone = 'ok';
+ } catch (err) {
+ console.error('[create-review] download failed', err);
+ statusEl.textContent =
+ err?.message?.includes('humanoid') && format === 'vrm'
+ ? "Couldn't write VRM — this avatar's skeleton isn't humanoid enough. Try GLB instead."
+ : `Couldn't export ${format.toUpperCase()}: ${err?.message || 'unknown error'}`;
+ statusEl.dataset.tone = 'err';
+ } finally {
+ row.dataset.busy = '0';
+ }
+ });
+ });
+}
+
+function prettyBytes(n) {
+ if (n < 1024) return `${n} B`;
+ if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
+ return `${(n / 1024 / 1024).toFixed(2)} MB`;
+}
+
+export function openReputationModal() {
+ openFeatureModal({
+ icon: '⭐',
+ title: 'Reputation',
+ lede: 'Signed feedback, call history, and validation events accrue to your agent — visible to anyone deciding whether to trust it.',
+ body: `
+ <ul class="fm-bullets">
+ <li>Every paid call is logged with a signed receipt — verifiable, non-repudiable.</li>
+ <li>Users can leave reviews; reviews carry the reviewer's own reputation weight.</li>
+ <li>Validators can attest to capability (e.g. "this agent reliably ships valid SQL").</li>
+ </ul>
+ <div class="fm-row">
+ <div>
+ <strong>Your starting rep</strong>
+ <div class="muted">Reviews accrue as your agent is used</div>
+ </div>
+ <code style="color: var(--muted);">★★★★★ · 0 reviews</code>
+ </div>
+ <p class="fm-note">Your reputation lives on-chain alongside your agent — it travels with the asset.</p>
+ `,
+ actions: [{ label: 'Got it' }],
+ });
+}
+
+function escapeHtml(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+}