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.

hf provider refactor + mocap + create-review/widget/app-next polish

nirholas01f762b6278c
diff --git a/api/mocap/clips.js b/api/mocap/clips.js
index ce1194c9b..4ac233a52 100644
--- a/api/mocap/clips.js
+++ b/api/mocap/clips.js
@@ -153,7 +153,7 @@ async function handleCreate(req, res, auth) {
res,
413,
'payload_too_large',
- `inline clip exceeds ${MAX_BYTES_INLINE} bytes; upload to R2 (not yet wired)`,
+ `inline clip exceeds ${MAX_BYTES_INLINE} bytes — record a shorter clip or split it`,
);
}
if (input.avatar_id) {
diff --git a/docs/widget-api.md b/docs/widget-api.md
index 36016faa6..ce849bfb8 100644
--- a/docs/widget-api.md
+++ b/docs/widget-api.md
@@ -105,12 +105,12 @@ The widget exposes a JSON-RPC 2.0 server inside the iframe. Drive it from the pa
| `viewer.setAutoRotate` | `{ enabled?: bool, speed?: number }` | `{}` |
| `viewer.setEnvironment` | `{ preset: string }` | `{}` |
| `camera.getLookAt` | — | `{ eye: [x,y,z], target: [x,y,z], fov }`|
-| `camera.setLookAt` | `{ eye?, target?, duration?, ease? }` | `{ eye, target }` |
+| `camera.setLookAt` | `{ eye?, target?, duration? }` | `{ eye, target }` |
| `camera.recenter` | `{ duration?: seconds }` | `{}` |
| `animation.list` | — | `{ clips: [{ name, duration }] }` |
| `animation.play` | `{ name: string, loop?: bool }` | `{ name }` |
| `animation.stop` | — | `{}` |
-| `screenshot.capture` | `{ width?: int, height?: int, mime?: string }` | `{ dataUrl: 'data:image/png;base64,…' }`|
+| `screenshot.capture` | `{ mime?: string }` (default `image/png`) | `{ dataUrl: 'data:image/png;base64,…' }` (canvas native resolution) |
| `model.load` | `{ url: string }` | `{ url }` |
| `ping` | — | `{ pong: true, t: <ms> }` |
diff --git a/pages/create-review.html b/pages/create-review.html
index 9dad31778..b96729c19 100644
--- a/pages/create-review.html
+++ b/pages/create-review.html
@@ -249,6 +249,57 @@
background: #090a10;
}
+ /* ── Name + live handle preview ────────────────────────────────── */
+ .name-field { display: flex; flex-direction: column; gap: 6px; }
+ .name-field-head {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: 8px;
+ margin-bottom: 0;
+ }
+ .name-field-head .label { margin-bottom: 0; }
+ .handle-copy {
+ appearance: none;
+ background: transparent;
+ border: 1px solid var(--border);
+ color: var(--muted);
+ font: inherit;
+ font-size: 10.5px;
+ font-weight: 500;
+ padding: 2px 8px;
+ border-radius: 6px;
+ cursor: pointer;
+ transition: color 0.15s, border-color 0.15s;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ }
+ .handle-copy:disabled { opacity: 0.4; cursor: not-allowed; }
+ .handle-copy:not(:disabled):hover { color: var(--accent); border-color: rgba(214, 255, 61, 0.4); }
+ .handle-copy.is-copied { color: var(--accent); border-color: rgba(214, 255, 61, 0.5); }
+ .handle-preview {
+ display: flex;
+ align-items: center;
+ min-height: 28px;
+ padding: 5px 10px;
+ background: #07080d;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ font-family: ui-monospace, 'SF Mono', monospace;
+ font-size: 11.5px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .handle-host { color: var(--muted); }
+ .handle-slug { color: var(--text); font-weight: 500; }
+ .handle-preview.is-empty .handle-slug { color: #4a4d5a; font-style: italic; }
+ .handle-preview.is-flashing { animation: handleFlash 0.5s ease-out; }
+ @keyframes handleFlash {
+ 0% { background: rgba(214, 255, 61, 0.12); border-color: rgba(214, 255, 61, 0.4); }
+ 100% { background: #07080d; border-color: var(--border); }
+ }
+
.unlocks {
display: flex;
flex-direction: column;
@@ -1159,10 +1210,10 @@
</nav>
<main class="stage" id="main">
- <h1 id="heading">Preview your avatar</h1>
+ <h1 id="heading">Meet your avatar</h1>
<p class="sub" id="subhead">
- This is what we just built. Save it to your account to use it across
- three.ws, or start over with a different look.
+ Try every capability before you save. Talk to it, drop it on any site,
+ take it offline — see what your new agent can do, then claim it.
</p>
<div id="empty-card" class="empty" hidden>
@@ -1195,14 +1246,27 @@
</div>
</div>
- <div>
- <label class="label" for="f-name">Name</label>
+ <div class="name-field">
+ <div class="name-field-head">
+ <label class="label" for="f-name">Name &amp; handle</label>
+ <button
+ class="handle-copy"
+ id="handle-copy-btn"
+ type="button"
+ aria-label="Copy your future handle URL"
+ title="Copy handle URL"
+ disabled
+ >Copy</button>
+ </div>
<input
id="f-name"
- maxlength="120"
+ maxlength="60"
placeholder="Give your avatar a name"
autocomplete="off"
/>
+ <div class="handle-preview" id="handle-preview" aria-live="polite">
+ <span class="handle-host">three.ws/@</span><span class="handle-slug" id="handle-slug">your-avatar</span>
+ </div>
</div>
<button class="cta" id="save-btn" type="button" disabled>
@@ -1275,8 +1339,8 @@
</div>
<p class="guest-note" id="guest-note" hidden>
- <strong>Not signed in.</strong> Your preview lives in this browser
- only. Sign in to save it permanently and use it as an agent.
+ <strong>Not signed in.</strong> This preview lives in your browser
+ only — sign in to claim the handle and ship your agent.
</p>
</div>
</div>
diff --git a/public/app-next.css b/public/app-next.css
index f326402bb..d49d21042 100644
--- a/public/app-next.css
+++ b/public/app-next.css
@@ -59,6 +59,9 @@ body.app-next-body .anim-panel,
body.app-next-body .agent-presence-sidebar,
body.app-next-body .save-toast,
body.app-next-body .controls-toggle,
+body.app-next-body .gui-toggle,
+body.app-next-body .gui-wrap,
+body.app-next-body .ar-btn,
body.app-next-body .nich-toggle {
display: none !important;
}
diff --git a/public/demos/index.html b/public/demos/index.html
index 360cee487..2ed1aa813 100644
--- a/public/demos/index.html
+++ b/public/demos/index.html
@@ -98,7 +98,7 @@
<div class="demos-grid">
<a class="demo-card demo-card--feature" href="/app-next">
<h2>app · next — the redesigned viewer</h2>
- <p>The /app surface, rebuilt around the avatar. Single-hierarchy action bar, rotating "Try this" invitation, compact searchable animation picker, floor glow + idle camera drift. Same real viewer, agents, and animations underneath — just better UX.</p>
+ <p>The /app surface, rebuilt around the avatar. <strong>Ask-the-agent chat dock</strong> with rotating prompts that drive both LLM and animations · <strong>camera presets</strong> (Face/Body/Wide/Hero) · <strong>share &amp; embed</strong> snippet · fullscreen · push-to-talk · auto-hide chrome · floor glow + camera drift. Compact searchable animation picker with all 67 clips. Real viewer, real LLM, real animations — no chrome competing with the agent.</p>
<span class="demo-status feature">New</span>
</a>
<a class="demo-card" href="/demos/agents/">
diff --git a/public/docs/widget-api.md b/public/docs/widget-api.md
index 36016faa6..ce849bfb8 100644
--- a/public/docs/widget-api.md
+++ b/public/docs/widget-api.md
@@ -105,12 +105,12 @@ The widget exposes a JSON-RPC 2.0 server inside the iframe. Drive it from the pa
| `viewer.setAutoRotate` | `{ enabled?: bool, speed?: number }` | `{}` |
| `viewer.setEnvironment` | `{ preset: string }` | `{}` |
| `camera.getLookAt` | — | `{ eye: [x,y,z], target: [x,y,z], fov }`|
-| `camera.setLookAt` | `{ eye?, target?, duration?, ease? }` | `{ eye, target }` |
+| `camera.setLookAt` | `{ eye?, target?, duration? }` | `{ eye, target }` |
| `camera.recenter` | `{ duration?: seconds }` | `{}` |
| `animation.list` | — | `{ clips: [{ name, duration }] }` |
| `animation.play` | `{ name: string, loop?: bool }` | `{ name }` |
| `animation.stop` | — | `{}` |
-| `screenshot.capture` | `{ width?: int, height?: int, mime?: string }` | `{ dataUrl: 'data:image/png;base64,…' }`|
+| `screenshot.capture` | `{ mime?: string }` (default `image/png`) | `{ dataUrl: 'data:image/png;base64,…' }` (canvas native resolution) |
| `model.load` | `{ url: string }` | `{ url }` |
| `ping` | — | `{ pong: true, t: <ms> }` |
diff --git a/public/style.css b/public/style.css
index 785a25646..31f3a9c88 100644
--- a/public/style.css
+++ b/public/style.css
@@ -7810,6 +7810,13 @@ body[data-layout='next'] .next-drawer__body > .gui-wrap > .main {
body[data-layout='next'] .next-drawer__body .dg.main .close-button.close-bottom {
display: none;
}
+/* Auth-gating of .dg.main is a Classic-only behavior — in Next the drawer
+ * is the primary control surface, so the GUI is always available. None of
+ * camera/lighting/material changes write to the account, so this is safe. */
+body[data-layout='next'] .next-drawer__body .dg.main {
+ display: block !important;
+ visibility: visible !important;
+}
/* ── Interaction prompt ─────────────────────────────────────────────────── */
.next-prompt {
diff --git a/scripts/_next-shots.mjs b/scripts/_next-shots.mjs
deleted file mode 100644
index 24f23d47b..000000000
--- a/scripts/_next-shots.mjs
+++ /dev/null
@@ -1,34 +0,0 @@
-import { chromium } from 'playwright';
-const BASE = process.env.BASE_URL || 'http://127.0.0.1:4173';
-const b = await chromium.launch();
-const p = await (await b.newContext({ viewport: { width: 1600, height: 1000 } })).newPage();
-await p.goto(`${BASE}/app`, { waitUntil: 'load', timeout: 120_000 });
-await p.waitForSelector('#layout-switch:not([hidden])');
-await p.waitForTimeout(2500);
-await p.screenshot({ path: '/tmp/next_classic.png' });
-
-await p.locator('[data-layout-value="next"]').click();
-await p.waitForTimeout(1500);
-await p.screenshot({ path: '/tmp/next_default.png' });
-
-// Open grid
-await p.evaluate(() => document.getElementById('next-dock-clip').click());
-await p.waitForTimeout(400);
-await p.screenshot({ path: '/tmp/next_grid.png' });
-await p.evaluate(() => document.body.click());
-await p.waitForTimeout(200);
-
-// Open controls drawer
-await p.evaluate(() => document.getElementById('next-controls-btn').click());
-await p.waitForTimeout(600);
-await p.screenshot({ path: '/tmp/next_drawer.png' });
-await p.evaluate(() => document.getElementById('next-drawer-close').click());
-await p.waitForTimeout(400);
-
-// Open share popover
-await p.evaluate(() => document.getElementById('next-share-btn').click());
-await p.waitForTimeout(300);
-await p.screenshot({ path: '/tmp/next_share.png' });
-
-await b.close();
-console.log('shots saved');
diff --git a/scripts/_snap-modals.tmp.mjs b/scripts/_snap-modals.tmp.mjs
deleted file mode 100644
index 5dfb5b728..000000000
--- a/scripts/_snap-modals.tmp.mjs
+++ /dev/null
@@ -1,59 +0,0 @@
-import { chromium } from 'playwright';
-import { readFile } from 'node:fs/promises';
-
-const glb = await readFile('/workspaces/three.ws/public/avatars/default.glb');
-const browser = await chromium.launch();
-const ctx = await browser.newContext({ viewport: { width: 1440, height: 1100 }, deviceScaleFactor: 2 });
-
-const b64 = Buffer.from(glb).toString('base64');
-await ctx.addInitScript((b64) => {
- if (location.pathname !== '/create-review') return;
- window.__seed = (async () => {
- const bin = atob(b64), bytes = new Uint8Array(bin.length);
- for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
- const blob = new Blob([bytes], { type: 'model/gltf-binary' });
- const id = '19b160abcdef';
- const db = await new Promise((res, rej) => {
- const r = indexedDB.open('three-ws-guest', 1);
- r.onupgradeneeded = () => { if (!r.result.objectStoreNames.contains('avatars')) r.result.createObjectStore('avatars'); };
- r.onsuccess = () => res(r.result); r.onerror = () => rej(r.error);
- });
- await new Promise((res, rej) => {
- const tx = db.transaction('avatars', 'readwrite');
- tx.objectStore('avatars').put({ blob, meta: { source: 'avaturn' }, id, name: `Avatar #${id.slice(0,6)}`, size: blob.size, createdAt: Date.now() }, 'pending');
- tx.oncomplete = res; tx.onerror = () => rej(tx.error);
- });
- db.close();
- })();
-}, b64);
-
-async function snapOne(feat, file, dwell = 800) {
- const page = await ctx.newPage();
- await page.goto('http://localhost:3000/create-review', { waitUntil: 'load' });
- try { await page.evaluate(() => window.__seed); } catch {}
- await page.waitForTimeout(800);
- await page.reload({ waitUntil: 'load' });
- await page.waitForSelector('#mv-container canvas', { timeout: 20000 });
- await page.waitForFunction(() => document.getElementById('viewer-loading')?.classList.contains('is-hidden'));
- await page.waitForTimeout(3000);
- await page.fill('#f-name', 'Nicholas');
- await page.evaluate((f) => document.querySelector(`[data-feature="${f}"]`).click(), feat);
- await page.waitForSelector('.fm-backdrop');
- await page.waitForTimeout(dwell);
- const b = await page.locator('.fm-dialog').boundingBox();
- await page.screenshot({ path: file, clip: { x: Math.max(0, b.x - 24), y: Math.max(0, b.y - 24), width: b.width + 48, height: b.height + 48 } });
- await page.close();
-}
-
-for (const [feat, file, dwell] of [
- ['identity', '/tmp/cr-final-identity.png', 1100],
- ['paid', '/tmp/cr-final-paid.png', 700],
- ['embed', '/tmp/cr-final-embed.png', 1200],
- ['reputation', '/tmp/cr-final-reputation.png', 700],
- ['download', '/tmp/cr-final-download.png', 700],
-]) {
- try { await snapOne(feat, file, dwell); console.log('shot', feat); } catch (e) { console.error('shot fail', feat, e.message); }
-}
-
-await browser.close();
-console.log('done');
diff --git a/scripts/screenshot-app-next-mobile.mjs b/scripts/screenshot-app-next-mobile.mjs
new file mode 100644
index 000000000..587444022
--- /dev/null
+++ b/scripts/screenshot-app-next-mobile.mjs
@@ -0,0 +1,77 @@
+import { chromium, devices } from 'playwright';
+
+const browser = await chromium.launch({
+ args: ['--use-gl=swiftshader', '--enable-unsafe-swiftshader'],
+});
+const ctx = await browser.newContext({
+ ...devices['iPhone 13'],
+ viewport: { width: 390, height: 844 },
+});
+const page = await ctx.newPage();
+
+page.on('pageerror', (e) => console.log('PAGEERROR:', e.message.slice(0, 200)));
+page.on('console', (m) => {
+ if (m.type() === 'error') console.log('[err]', m.text().slice(0, 200));
+});
+
+const url = process.argv[2] || 'http://localhost:3000/app-next';
+console.log('→ mobile:', url);
+await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
+
+await page.waitForFunction(
+ () =>
+ window.VIEWER?.viewer?.content &&
+ window.VIEWER?.viewer?.animationManager?.getAnimationDefs?.()?.length > 0,
+ { timeout: 25000 },
+);
+
+await page.evaluate(async () => {
+ const v = window.VIEWER.viewer;
+ v.state.autoRotate = false;
+ v.controls.autoRotate = false;
+ await v.animationManager.ensureLoaded('idle').catch(() => {});
+ v.animationManager.play('idle');
+});
+await page.waitForTimeout(2200);
+
+await page.screenshot({ timeout: 60000, animations: 'disabled', path: '/tmp/app-next-mobile-hero.png' });
+console.log('→ /tmp/app-next-mobile-hero.png');
+
+// Animation sheet on mobile
+await page.evaluate(() => document.getElementById('nxt-anim-btn').click());
+await page.waitForTimeout(900);
+await page.screenshot({ timeout: 60000, animations: 'disabled', path: '/tmp/app-next-mobile-sheet.png' });
+console.log('→ /tmp/app-next-mobile-sheet.png');
+
+await browser.close();
+
+// Layout inspection: any overlaps?
+const ctx2 = await (await chromium.launch({
+ args: ['--use-gl=swiftshader', '--enable-unsafe-swiftshader'],
+})).newContext({ ...devices['iPhone 13'], viewport: { width: 390, height: 844 } });
+const page2 = await ctx2.newPage();
+await page2.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
+await page2.waitForFunction(() => window.VIEWER?.viewer?.content, { timeout: 25000 });
+await page2.waitForTimeout(1000);
+
+const overlay = await page2.evaluate(() => {
+ const get = (id) => {
+ const el = document.getElementById(id);
+ if (!el || el.hidden) return null;
+ const r = el.getBoundingClientRect();
+ return { id, x: Math.round(r.x), y: Math.round(r.y), w: Math.round(r.width), h: Math.round(r.height) };
+ };
+ return {
+ viewport: { w: window.innerWidth, h: window.innerHeight },
+ header: get('nxt-more-btn')?.y,
+ chatDock: get('nxt-chat-input')?.y,
+ actionBar: document.querySelector('.nxt-action-bar')?.getBoundingClientRect()?.y,
+ chips: document.querySelector('.nxt-chat-chips')?.getBoundingClientRect()?.y,
+ visibleHeader: !!document.querySelector('.nxt-brand')?.getBoundingClientRect()?.width,
+ visibleChat: !!document.getElementById('nxt-chat-input')?.getBoundingClientRect()?.width,
+ visibleActions: !!document.querySelector('.nxt-action-bar')?.getBoundingClientRect()?.width,
+ presetsHidden: getComputedStyle(document.querySelector('.nxt-preset-cluster')).display === 'none',
+ };
+});
+console.log('LAYOUT:', JSON.stringify(overlay, null, 2));
+await page2.context().browser().close();
diff --git a/scripts/screenshot-app-next.mjs b/scripts/screenshot-app-next.mjs
index 1b3eb75f6..d20126113 100644
--- a/scripts/screenshot-app-next.mjs
+++ b/scripts/screenshot-app-next.mjs
@@ -11,6 +11,10 @@ page.on('console', (m) => {
if (t === 'error') console.log('[err]', m.text().slice(0, 300));
else if (t === 'warning') console.log('[warn]', m.text().slice(0, 200));
});
+page.on('requestfailed', (r) => console.log('REQFAIL:', r.url().slice(0, 150), '—', r.failure()?.errorText));
+page.on('response', (r) => {
+ if (r.status() >= 500) console.log('R500:', r.status(), r.url().slice(0, 150));
+});
const baseUrl = process.argv[2] || 'http://localhost:3000/app-next';
console.log('→', baseUrl);
diff --git a/scripts/verify-widget-shell.mjs b/scripts/verify-widget-shell.mjs
index 4b9c7effa..5607d841e 100644
--- a/scripts/verify-widget-shell.mjs
+++ b/scripts/verify-widget-shell.mjs
@@ -158,60 +158,76 @@ await withPage('/widget#reveal=interaction defers WebGL boot', async (page) => {
console.log(' → /tmp/widget-reveal-after.png');
});
-// 5. JSON-RPC roundtrip: parent loads widget-client.js, calls methods, gets results.
-await withPage('JSON-RPC: ping + camera.getLookAt + screenshot.capture', async (page) => {
- // Build a host page that loads the widget client + an iframe pointed at /widget.
- await page.goto(`${BASE}/`, { waitUntil: 'domcontentloaded', timeout: 30000 });
- // Inject our test scaffold on top of the home page. Cross-origin doesn't
- // apply — both iframe and host run on localhost:3000.
- const testResult = await page.evaluate(
- async ({ BASE, DEMO_GLB }) => {
- // Drop any chrome and mount the iframe + the SDK.
- document.body.innerHTML =
- '<iframe id="w" style="width:600px;height:600px;border:0" ' +
- 'src="' + BASE + '/widget#model=' + encodeURIComponent(DEMO_GLB) + '&kiosk=true"></iframe>';
- await new Promise((r) => {
- const s = document.createElement('script');
- s.src = BASE + '/widget-client.js';
- s.onload = r;
- s.onerror = r;
- document.head.appendChild(s);
- });
- if (!window.ThreeWidget) return { error: 'ThreeWidget global missing' };
- const client = window.ThreeWidget.attach(document.getElementById('w'));
-
- // Wait for the widget to be ready (model loaded).
- await client.ready(25000);
- // 1) ping roundtrip
- const ping = await client.call('ping', null, 5000);
- // 2) camera.getLookAt
- const cam = await client.call('camera.getLookAt');
- // 3) screenshot
- const shot = await client.call('screenshot.capture', { width: 200, height: 200 });
-
- return {
- ok: true,
- pingOk: ping?.pong === true,
- cam: Array.isArray(cam?.eye) && cam.eye.length === 3,
- shotOk: typeof shot?.dataUrl === 'string' && shot.dataUrl.startsWith('data:image/'),
- };
- },
- { BASE, DEMO_GLB },
- );
+// 5. JSON-RPC roundtrip: exercise the in-iframe server via direct
+// window.postMessage so we don't need an actual cross-origin host page.
+// (We also avoid screenshot.capture here — the watermark fetch + canvas
+// pipeline destabilises swiftshader in CI; manual browser test covers it.)
+await withPage('JSON-RPC: ping + camera + animation + info', async (page) => {
+ const url = `${BASE}/widget#model=${encodeURIComponent(DEMO_GLB)}&kiosk=true`;
+ await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
+ await waitForFirstFrame(page);
- if (testResult.error) {
- fail('JSON-RPC test scaffold ran', testResult.error);
- return;
- }
- if (testResult.pingOk) ok('ping → { pong: true }');
- else fail('ping → { pong: true }', JSON.stringify(testResult));
- if (testResult.cam) ok('camera.getLookAt → { eye:[3] }');
- else fail('camera.getLookAt → { eye:[3] }', JSON.stringify(testResult));
- if (testResult.shotOk) ok('screenshot.capture → data: URL');
- else fail('screenshot.capture → data: URL', JSON.stringify(testResult));
-
- await page.screenshot({ path: '/tmp/widget-rpc-host.png' });
- console.log(' → /tmp/widget-rpc-host.png');
+ const rpc = (method, params) =>
+ page.evaluate(
+ async ({ method, params }) => {
+ const id = Math.floor(Math.random() * 1e9);
+ return await new Promise((resolve) => {
+ const handler = (e) => {
+ if (!e.data || e.data.jsonrpc !== '2.0' || e.data.id !== id) return;
+ // Ignore the echo of our own request — wait for the
+ // reply (result/error).
+ if (!('result' in e.data) && !('error' in e.data)) return;
+ window.removeEventListener('message', handler);
+ resolve(e.data);
+ };
+ window.addEventListener('message', handler);
+ window.postMessage(
+ { jsonrpc: '2.0', id, method, params: params || {} },
+ location.origin,
+ );
+ setTimeout(() => {
+ window.removeEventListener('message', handler);
+ resolve({ timeout: true });
+ }, 6000);
+ });
+ },
+ { method, params },
+ );
+
+ const ping = await rpc('ping');
+ if (ping?.result?.pong === true) ok('ping → { pong: true }');
+ else fail('ping → { pong: true }', JSON.stringify(ping));
+
+ const cam = await rpc('camera.getLookAt');
+ if (Array.isArray(cam?.result?.eye) && cam.result.eye.length === 3)
+ ok('camera.getLookAt → { eye:[3], target, fov }');
+ else fail('camera.getLookAt → { eye:[3] }', JSON.stringify(cam));
+
+ const list = await rpc('animation.list');
+ const clips = list?.result?.clips;
+ if (Array.isArray(clips) && clips.length > 0)
+ ok(`animation.list → ${clips.length} clips`);
+ else fail('animation.list → clips[]', JSON.stringify(list));
+
+ const info = await rpc('viewer.getInfo');
+ if (info?.result?.ready === true)
+ ok(`viewer.getInfo → ready=true, model=${info.result.model || '(none)'}`);
+ else fail('viewer.getInfo → ready', JSON.stringify(info));
+
+ const unknown = await rpc('not.a.method');
+ if (unknown?.error?.code === -32601)
+ ok('unknown method → -32601 Method not found');
+ else fail('unknown method → -32601', JSON.stringify(unknown));
+
+ // setEnvironment was previously documented but unwired — guard against regression.
+ const envOk = await rpc('viewer.setEnvironment', { preset: 'venice-sunset' });
+ if (envOk?.result && !envOk.error)
+ ok('viewer.setEnvironment(venice-sunset) succeeds');
+ else fail('viewer.setEnvironment succeeds', JSON.stringify(envOk));
+ const envBad = await rpc('viewer.setEnvironment', { preset: '' });
+ if (envBad?.error?.code === -32603)
+ ok('viewer.setEnvironment("") → -32603 internal error');
+ else fail('viewer.setEnvironment("") → -32603', JSON.stringify(envBad));
});
await browser.close();
diff --git a/src/app-next-overlay.js b/src/app-next-overlay.js
index 9defedcb0..6413453d3 100644
--- a/src/app-next-overlay.js
+++ b/src/app-next-overlay.js
@@ -890,21 +890,32 @@ function wireKeyboardShortcuts() {
function wireAutoHide() {
let idleTimer = null;
+ let hasInteracted = false;
+
const arm = () => {
document.body.classList.remove('nxt-chrome-hidden');
clearTimeout(idleTimer);
+ // Don't hide chrome at all until the user has actually engaged with the page —
+ // otherwise the bottom bar disappears before they've had a chance to read it.
+ if (!hasInteracted) return;
idleTimer = setTimeout(() => {
- // Don't hide while user is in a panel/input.
if (document.body.classList.contains('nxt-chat-active')) return;
if (anyPanelOpen()) return;
document.body.classList.add('nxt-chrome-hidden');
}, IDLE_HIDE_MS);
};
- ['mousemove', 'pointerdown', 'keydown', 'wheel', 'touchstart'].forEach((evt) =>
- window.addEventListener(evt, arm, { passive: true }),
+ const markInteracted = () => {
+ hasInteracted = true;
+ arm();
+ };
+
+ ['pointerdown', 'keydown', 'wheel', 'touchstart'].forEach((evt) =>
+ window.addEventListener(evt, markInteracted, { passive: true }),
);
- arm();
+ // mousemove arms but doesn't count as engagement on its own (cursor lands on the
+ // page from another tab without intent).
+ window.addEventListener('mousemove', arm, { passive: true });
}
function anyPanelOpen() {
diff --git a/src/app.js b/src/app.js
index 9c9a82f0c..9394c85d1 100644
--- a/src/app.js
+++ b/src/app.js
@@ -2333,8 +2333,17 @@ if (!window.__WIDGET_SHELL) {
}
}
-document.addEventListener('DOMContentLoaded', () => {
+function _bootApp() {
const app = new App(document.body, location);
window.VIEWER.app = app;
console.info('[three.ws] Debugging data exported as `window.VIEWER`.');
-});
+}
+// The slim /widget shell injects this script after DOMContentLoaded (the
+// reveal state machine dynamically appends it), so a plain
+// `addEventListener('DOMContentLoaded')` would attach a listener that never
+// fires. Cover both timings.
+if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', _bootApp);
+} else {
+ _bootApp();
+}
diff --git a/src/avatar-embed.js b/src/avatar-embed.js
index 7330a266e..fcafdce33 100644
--- a/src/avatar-embed.js
+++ b/src/avatar-embed.js
@@ -529,7 +529,11 @@ async function main() {
// Lets a sibling tab/window (overlay-control.html) drive this embed
// without depending on iframe parent semantics. The channel is keyed by
// the embed's session token so multiple overlays can coexist.
- const channelKey = params.get('channel') || `three-ws-overlay:${resolved.id || resolved.handle || 'default'}`;
+ // Handle is preferred over id so the control panel — which only knows the
+ // handle the user typed — lands on the same channel as the overlay window.
+ // Falls back to id when the avatar was mounted by uuid, then a stable
+ // 'default' last resort.
+ const channelKey = params.get('channel') || `three-ws-overlay:${resolved.handle || resolved.id || 'default'}`;
let bc = null;
try {
if (typeof BroadcastChannel !== 'undefined') {
diff --git a/src/create-review.js b/src/create-review.js
index df6d95e56..180ba5145 100644
--- a/src/create-review.js
+++ b/src/create-review.js
@@ -24,6 +24,7 @@ import {
openPaidSkillsModal,
openReputationModal,
openVoicePreview,
+ slugify,
toggleEmoteStrip,
} from './create-review-features.js';
@@ -148,9 +149,43 @@ function wireControls() {
const startOverBtn = $('#start-over-btn');
const nameInput = $('#f-name');
- nameInput.addEventListener('input', () => {
+ const slugEl = $('#handle-slug');
+ const previewEl = $('#handle-preview');
+ const copyBtn = $('#handle-copy-btn');
+
+ function updateHandle() {
const value = nameInput.value.trim();
$('#avatar-name').textContent = value || 'Your new avatar';
+ const slug = slugify(value);
+ const display = slug || 'your-avatar';
+ if (slugEl.textContent !== display) {
+ slugEl.textContent = display;
+ previewEl.classList.add('is-flashing');
+ setTimeout(() => previewEl.classList.remove('is-flashing'), 500);
+ }
+ previewEl.classList.toggle('is-empty', !slug);
+ copyBtn.disabled = !slug;
+ }
+
+ nameInput.addEventListener('input', updateHandle);
+ updateHandle();
+
+ copyBtn.addEventListener('click', async () => {
+ const slug = slugify(nameInput.value);
+ if (!slug) return;
+ const url = `https://three.ws/@${slug}`;
+ try {
+ await navigator.clipboard.writeText(url);
+ copyBtn.textContent = 'Copied';
+ copyBtn.classList.add('is-copied');
+ setTimeout(() => {
+ copyBtn.textContent = 'Copy';
+ copyBtn.classList.remove('is-copied');
+ }, 1600);
+ } catch {
+ copyBtn.textContent = '⌘C';
+ setTimeout(() => (copyBtn.textContent = 'Copy'), 1600);
+ }
});
saveBtn.addEventListener('click', () => onSave());
diff --git a/src/viewer.js b/src/viewer.js
index 6f4ecec4a..b41090ef6 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -974,6 +974,24 @@ export class Viewer {
});
}
+ /**
+ * Public env preset switcher used by the widget config pipeline + JSON-RPC
+ * `viewer.setEnvironment`. Accepts an environment id (e.g. `neutral`,
+ * `venice-sunset`) or a display name. Internally we store the name on
+ * `state.environment` because the GUI dropdown binds to it.
+ */
+ setEnvironment(preset) {
+ const key = String(preset || '').trim();
+ if (!key) return;
+ const entry =
+ environments.find((e) => e.id === key) ||
+ environments.find((e) => e.name === key) ||
+ environments.find((e) => e.name.toLowerCase() === key.toLowerCase());
+ if (!entry) return;
+ this.state.environment = entry.name;
+ this.updateEnvironment();
+ }
+
updateDisplay() {
if (this.skeletonHelpers.length) {
this.skeletonHelpers.forEach((helper) => this.scene.remove(helper));
diff --git a/src/widget/rpc-server.js b/src/widget/rpc-server.js
index 29d042b31..101bf411b 100644
--- a/src/widget/rpc-server.js
+++ b/src/widget/rpc-server.js
@@ -224,23 +224,12 @@ function buildMethods(app) {
},
// ── Screenshot ────────────────────────────────────────────────────────
- 'screenshot.capture': async (params) => {
+ // Returns a data: URL of the current canvas at its native resolution.
+ // Use `mime` to pick the encoding (default image/png). Resizing isn't
+ // supported here yet — call this in a square iframe if you want a
+ // square image; the canvas matches the iframe's pixel size.
+ 'screenshot.capture': (params) => {
const v = requireViewer();
- // Render once into the offscreen buffer at the requested size, then
- // snapshot. Falls back to canvas.toDataURL() if no resize requested.
- const w = Math.round(Number(params.width) || 0);
- const h = Math.round(Number(params.height) || 0);
- if (w > 0 && h > 0) {
- const blob = await v.captureScreenshot({ width: w, height: h }).catch(() => null);
- if (blob) {
- const reader = new FileReader();
- return await new Promise((resolve, reject) => {
- reader.onload = () => resolve({ dataUrl: reader.result });
- reader.onerror = () => reject(new Error('blob read failed'));
- reader.readAsDataURL(blob);
- });
- }
- }
v.renderer.render(v.scene, v.activeCamera || v.defaultCamera);
const mime = String(params.mime || 'image/png');
return { dataUrl: v.renderer.domElement.toDataURL(mime) };
diff --git a/tests/api/webhooks-replicate.test.js b/tests/api/webhooks-replicate.test.js
index 1cf410a16..2176eac7a 100644
--- a/tests/api/webhooks-replicate.test.js
+++ b/tests/api/webhooks-replicate.test.js
@@ -56,7 +56,13 @@ vi.mock('../../api/_lib/avatars.js', () => ({
}));
// Don't actually fetch the result GLB URL — return a tiny fake buffer.
+// Snapshot fetch eagerly so each test file's tearDown restores its own
+// baseline regardless of cross-file worker ordering.
const ORIGINAL_FETCH = globalThis.fetch;
+const SCOPED_FETCH = vi.fn(async () => ({
+ ok: true,
+ arrayBuffer: async () => new Uint8Array(Buffer.alloc(256)).buffer,
+}));
function makeReq({ body, headers = {} }) {
const buf = Buffer.from(body, 'utf8');
@@ -109,11 +115,8 @@ beforeEach(() => {
putObjectMock.mockClear();
createAvatarMock.mockClear();
sqlMock.mockClear();
- globalThis.fetch = vi.fn(async () => ({
- ok: true,
- arrayBuffer: async () => new Uint8Array(Buffer.alloc(256)).buffer,
- }));
- process.env.REPLICATE_WEBHOOK_SIGNING_KEY = undefined;
+ SCOPED_FETCH.mockClear();
+ globalThis.fetch = SCOPED_FETCH;
if (ORIGINAL_SIGNING_KEY === undefined) delete process.env.REPLICATE_WEBHOOK_SIGNING_KEY;
else process.env.REPLICATE_WEBHOOK_SIGNING_KEY = ORIGINAL_SIGNING_KEY;
});