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(forge): reel capture, live stage, and render lab

nirholas2be97f3f18e1
diff --git a/.probe-wt.mjs b/.probe-wt.mjs
new file mode 100644
index 000000000..8f81de926
--- /dev/null
+++ b/.probe-wt.mjs
@@ -0,0 +1,46 @@
+// Scratch probe: dump stable anchor candidates from live three.ws pages.
+import { chromium } from 'playwright';
+
+const BASE = 'https://three.ws';
+const paths = process.argv.slice(2);
+
+const browser = await chromium.launch();
+const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
+const page = await ctx.newPage();
+
+for (const p of paths) {
+ try {
+ await page.goto(BASE + p, { waitUntil: 'domcontentloaded', timeout: 45000 });
+ await page.waitForTimeout(3500);
+ const out = await page.evaluate(() => {
+ const rows = [];
+ const seen = new Set();
+ const push = (sel, el) => {
+ if (seen.has(sel)) return;
+ seen.add(sel);
+ const r = el.getBoundingClientRect();
+ if (r.width < 24 || r.height < 12) return;
+ rows.push({
+ sel,
+ tag: el.tagName.toLowerCase(),
+ text: (el.textContent || '').trim().replace(/\s+/g, ' ').slice(0, 70),
+ box: [Math.round(r.x), Math.round(r.y), Math.round(r.width), Math.round(r.height)],
+ });
+ };
+ document.querySelectorAll('[id]').forEach((el) => push('#' + el.id, el));
+ document.querySelectorAll('main h1, main h2, main .hero, main section').forEach((el) => {
+ if (el.id) return;
+ const cls = (el.className || '').toString().trim().split(/\s+/)[0];
+ if (cls) push(el.tagName.toLowerCase() + '.' + cls, el);
+ });
+ return { title: document.title, rows };
+ });
+ console.log('\n=== ' + p + ' :: ' + out.title + ' ===');
+ for (const r of out.rows.slice(0, 60)) {
+ console.log(`${r.sel} [${r.box.join(',')}] <${r.tag}> ${r.text}`);
+ }
+ } catch (e) {
+ console.log('\n=== ' + p + ' FAILED: ' + e.message);
+ }
+}
+await browser.close();
diff --git a/.reel-probe.mjs b/.reel-probe.mjs
new file mode 100644
index 000000000..f556d0717
--- /dev/null
+++ b/.reel-probe.mjs
@@ -0,0 +1,38 @@
+import { chromium } from 'playwright';
+const browser = await chromium.launch({ args: ['--use-gl=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
+const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+page.on('pageerror', e => console.log('pageerror', e.message));
+await page.goto('http://localhost:3000/forge', { waitUntil: 'domcontentloaded' });
+await page.waitForTimeout(3000);
+await page.evaluate(() => document.dispatchEvent(new CustomEvent('forge:open-creation', { detail: { creation: { id:'p', prompt:'probe', glb_url:'https://three.ws/avatars/default.glb', backend:'trellis_selfhost' } } })));
+await page.waitForFunction(() => document.getElementById('viewer')?.loaded === true, null, { timeout: 90000 });
+await page.waitForTimeout(1500);
+const out = await page.evaluate(async () => {
+ const v = document.getElementById('viewer');
+ const cs = [...v.shadowRoot.querySelectorAll('canvas')]; const c = cs.find(x => x.id === 'webgl-canvas' && x.classList.contains('show')) || cs[0];
+ const info = { hasCanvas: !!c, w: c?.width, h: c?.height, hasCapture: typeof c?.captureStream === 'function', mp4: MediaRecorder.isTypeSupported('video/mp4;codecs=avc1.42E01E') };
+ if (!c) return info;
+ info.results = {};
+ for (const mime of ['video/mp4;codecs=avc1.42E01E','video/mp4','video/webm;codecs=vp9','video/webm;codecs=vp8','video/webm']) {
+ if (!MediaRecorder.isTypeSupported(mime)) { info.results[mime] = 'unsupported'; continue; }
+ const stream = c.captureStream(30);
+ const rec = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 8_000_000 });
+ let total = 0; let err = '';
+ rec.ondataavailable = e => { total += e.data.size; };
+ rec.onerror = e => { err = e.error?.name || 'error'; };
+ const done = new Promise(r => rec.onstop = r);
+ rec.start(200);
+ const t0 = performance.now();
+ while (performance.now() - t0 < 900) {
+ await new Promise(r => requestAnimationFrame(r));
+ const a = (performance.now() - t0) / 900 * 360;
+ v.cameraOrbit = `${a}deg 78deg auto`; v.jumpCameraToGoal?.();
+ }
+ rec.stop(); await done;
+ for (const t of stream.getTracks()) t.stop();
+ info.results[mime] = err ? `err:${err}` : total;
+ }
+ return info;
+});
+console.log(JSON.stringify(out, null, 2));
+await browser.close();
diff --git a/.reel-probe2.mjs b/.reel-probe2.mjs
new file mode 100644
index 000000000..ea33dfc06
--- /dev/null
+++ b/.reel-probe2.mjs
@@ -0,0 +1,39 @@
+import { chromium } from 'playwright';
+const browser = await chromium.launch({ args: ['--use-gl=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
+const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+await page.goto('http://localhost:3000/forge', { waitUntil: 'domcontentloaded' });
+await page.waitForTimeout(3000);
+await page.evaluate(() => document.dispatchEvent(new CustomEvent('forge:open-creation', { detail: { creation: { id:'p', prompt:'probe', glb_url:'https://three.ws/avatars/default.glb', backend:'trellis_selfhost' } } })));
+await page.waitForFunction(() => document.getElementById('viewer')?.loaded === true, null, { timeout: 90000 });
+await page.waitForTimeout(1500);
+const out = await page.evaluate(async () => {
+ const v = document.getElementById('viewer');
+ const canvases = [...v.shadowRoot.querySelectorAll('canvas')].map((c, i) => ({
+ i, w: c.width, h: c.height, cls: c.className, id: c.id,
+ ctx2d: !!c.getContext, parent: c.parentElement?.className,
+ style: c.getAttribute('style')?.slice(0, 120) || '',
+ }));
+ // Also look for a canvas anywhere in the document that three's renderer owns
+ const docCanvases = [...document.querySelectorAll('canvas')].map((c,i)=>({i,w:c.width,h:c.height,cls:c.className}));
+
+ // Sanity: does MediaRecorder work at all here, on a plain 2D canvas?
+ const plain = document.createElement('canvas');
+ plain.width = 320; plain.height = 240;
+ const ctx = plain.getContext('2d');
+ const stream = plain.captureStream(30);
+ const rec = new MediaRecorder(stream, { mimeType: 'video/webm;codecs=vp8' });
+ let total = 0;
+ rec.ondataavailable = e => { total += e.data.size; };
+ const done = new Promise(r => rec.onstop = r);
+ rec.start(200);
+ const t0 = performance.now();
+ while (performance.now() - t0 < 900) {
+ await new Promise(r => requestAnimationFrame(r));
+ ctx.fillStyle = `hsl(${(performance.now()/5)%360} 80% 50%)`;
+ ctx.fillRect(0,0,320,240);
+ }
+ rec.stop(); await done;
+ return { canvases, docCanvases, plainCanvasBytes: total };
+});
+console.log(JSON.stringify(out, null, 2));
+await browser.close();
diff --git a/.reel-probe3.mjs b/.reel-probe3.mjs
new file mode 100644
index 000000000..344e41385
--- /dev/null
+++ b/.reel-probe3.mjs
@@ -0,0 +1,37 @@
+import { chromium } from 'playwright';
+const browser = await chromium.launch({ args: ['--use-gl=swiftshader','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
+const page = await browser.newPage();
+await page.goto('http://localhost:3000/forge', { waitUntil: 'domcontentloaded' });
+const out = await page.evaluate(async () => {
+ async function capture(kind) {
+ const c = document.createElement('canvas');
+ c.width = 320; c.height = 240; document.body.appendChild(c);
+ let draw;
+ if (kind === '2d') {
+ const ctx = c.getContext('2d');
+ draw = (t) => { ctx.fillStyle = `hsl(${t%360} 80% 50%)`; ctx.fillRect(0,0,320,240); };
+ } else {
+ const gl = c.getContext('webgl2') || c.getContext('webgl');
+ if (!gl) return { kind, error: 'no webgl' };
+ draw = (t) => { gl.clearColor((t%100)/100, 0.3, 0.7, 1); gl.clear(gl.COLOR_BUFFER_BIT); };
+ }
+ const stream = c.captureStream(30);
+ const rec = new MediaRecorder(stream, { mimeType: 'video/webm;codecs=vp8' });
+ let total = 0;
+ rec.ondataavailable = e => { total += e.data.size; };
+ const done = new Promise(r => rec.onstop = r);
+ rec.start(200);
+ const t0 = performance.now();
+ while (performance.now() - t0 < 1200) {
+ await new Promise(r => requestAnimationFrame(r));
+ draw(performance.now() - t0);
+ }
+ rec.stop(); await done;
+ for (const t of stream.getTracks()) t.stop();
+ c.remove();
+ return { kind, total };
+ }
+ return [await capture('2d'), await capture('webgl')];
+});
+console.log(JSON.stringify(out, null, 2));
+await browser.close();
diff --git a/.reel-verify.mjs b/.reel-verify.mjs
new file mode 100644
index 000000000..b7b3bec6c
--- /dev/null
+++ b/.reel-verify.mjs
@@ -0,0 +1,125 @@
+// Real-browser verification of Forge Reel: load /forge, drop a real model into
+// the result viewer, open the Reel dialog, record an actual reel, and assert
+// the produced files are real bytes of the right type.
+import { chromium } from 'playwright';
+import { mkdirSync, writeFileSync } from 'node:fs';
+
+const OUT = '/tmp/claude-1000/-workspaces-three-ws/54abdcf2-c800-40d7-8c4b-205b55327f21/scratchpad/reel-shots';
+mkdirSync(OUT, { recursive: true });
+
+const errors = [];
+const browser = await chromium.launch({
+ args: ['--use-gl=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'],
+});
+const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
+page.on('console', (m) => {
+ if (m.type() === 'error') errors.push(m.text());
+});
+page.on('pageerror', (e) => errors.push(`pageerror: ${e.message}`));
+
+await page.goto('http://localhost:3000/forge', { waitUntil: 'domcontentloaded' });
+await page.waitForTimeout(3000);
+
+// Put a real GLB in the result viewer through the page's own hook.
+await page.evaluate(() => {
+ document.dispatchEvent(
+ new CustomEvent('forge:open-creation', {
+ detail: {
+ creation: {
+ id: 'verify-reel',
+ prompt: 'a brass lantern',
+ glb_url: 'https://three.ws/avatars/default.glb',
+ backend: 'trellis_selfhost',
+ },
+ },
+ }),
+ );
+});
+
+await page.waitForSelector('#viewer[src]', { timeout: 20000 });
+await page.waitForFunction(() => document.getElementById('viewer')?.loaded === true, {
+ timeout: 60000,
+});
+await page.waitForTimeout(1500);
+await page.screenshot({ path: `${OUT}/01-result.png` });
+
+const triggerVisible = await page.isVisible('#reel-open');
+console.log('reel trigger visible:', triggerVisible);
+
+await page.click('#reel-open');
+await page.waitForTimeout(500);
+await page.screenshot({ path: `${OUT}/02-dialog.png` });
+
+console.log('summary:', await page.textContent('.reel-summary'));
+
+// Shortest reel so verification stays quick.
+await page.click('.reel-durations .reel-chip[data-id="4"]');
+await page.click('.reel-start');
+await page.waitForTimeout(1800);
+await page.screenshot({ path: `${OUT}/03-recording.png` });
+
+await page.waitForSelector('.reel-done:not([hidden]) .reel-file, .reel-fallback:not([hidden]) .reel-file', {
+ timeout: 60000,
+});
+await page.waitForTimeout(800);
+await page.screenshot({ path: `${OUT}/04-done.png` });
+
+// Pull the real bytes back out and write them to disk so the files can be
+// inspected outside the browser.
+const files = await page.evaluate(async () => {
+ const rows = [...document.querySelectorAll('.reel-file')];
+ const out = [];
+ for (const row of rows) {
+ const blob = await (await fetch(row.href)).blob();
+ const buf = new Uint8Array(await blob.arrayBuffer());
+ out.push({
+ name: row.download,
+ type: blob.type,
+ size: blob.size,
+ head: [...buf.slice(0, 16)],
+ b64: btoa(String.fromCharCode(...buf.slice(0, 3_000_000))),
+ });
+ }
+ return out;
+});
+
+for (const f of files) {
+ writeFileSync(`${OUT}/${f.name}`, Buffer.from(f.b64, 'base64'));
+ console.log(`file ${f.name} type=${f.type} size=${f.size}`);
+}
+
+// The stage must have been handed back: camera controls restored, no leftover
+// fixed positioning, no leftover backdrop.
+const restored = await page.evaluate(() => {
+ const shell = document.getElementById('viewer-shell');
+ const viewer = document.getElementById('viewer');
+ return {
+ stageClass: shell.classList.contains('is-reel-stage'),
+ bodyClass: document.body.classList.contains('forge-reel-capturing'),
+ cameraControls: viewer.hasAttribute('camera-controls'),
+ autoRotate: viewer.hasAttribute('auto-rotate'),
+ shellPosition: getComputedStyle(shell).position,
+ };
+});
+console.log('restored:', JSON.stringify(restored));
+
+// Close with Escape, then confirm the keyboard shortcut reopens it.
+await page.keyboard.press('Escape');
+await page.waitForTimeout(400);
+console.log('closed after Esc:', !(await page.isVisible('.reel-panel')));
+await page.keyboard.press('r');
+await page.waitForTimeout(400);
+console.log('reopened with R:', await page.isVisible('.reel-panel'));
+await page.keyboard.press('Escape');
+
+// Narrow viewport: the dialog and the stage must both fit.
+await page.setViewportSize({ width: 320, height: 720 });
+await page.waitForTimeout(400);
+await page.click('#reel-open');
+await page.waitForTimeout(400);
+await page.screenshot({ path: `${OUT}/05-320.png` });
+const overflow = await page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 1);
+console.log('320px horizontal overflow:', overflow);
+
+console.log('console errors:', JSON.stringify(errors, null, 2));
+await browser.close();
diff --git a/pages/forge.html b/pages/forge.html
index cc95b80ff..ec6350ea3 100644
--- a/pages/forge.html
+++ b/pages/forge.html
@@ -4137,6 +4137,7 @@
<script type="module" src="/src/forge-optimize.js"></script>
<script type="module" src="/src/forge-gameready.js"></script>
<script type="module" src="/src/forge-export.js"></script>
+ <script type="module" src="/src/forge-reel.js"></script>
<script type="module" src="/src/forge-embed-panel.js"></script>
<script type="module" src="/src/forge-ar.js"></script>
<script type="module" src="/src/forge-showcase.js"></script>
diff --git a/pages/render-lab.html b/pages/render-lab.html
new file mode 100644
index 000000000..f67b87592
--- /dev/null
+++ b/pages/render-lab.html
@@ -0,0 +1,194 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script>/* three.ws theme boot: no-flash */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
+ <title>Render Lab · three.ws</title>
+ <meta name="description" content="Compose a real avatar render in the browser and copy the exact API call. Render Lab reads what each model can actually do (ARKit morphs, skeleton coverage, geometry) and only offers controls it will honor, so nothing you build here silently fails in production." />
+ <link rel="canonical" href="https://three.ws/render-lab" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/manifest.webmanifest" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/nav.css" />
+ <link rel="stylesheet" href="/mobile.css" />
+ <link rel="stylesheet" href="/src/render-lab.css" />
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="Render Lab · three.ws" />
+ <meta property="og:description" content="Compose a real avatar render, see what the model can actually do, and copy the exact API call. No signup." />
+ <meta property="og:url" content="https://three.ws/render-lab" />
+ <meta property="og:image" content="https://three.ws/api/page-og?s=build&amp;t=Render+Lab&amp;d=Compose+a+real+avatar+render+and+copy+the+exact+API+call.+Controls+adapt+to+what+each+model+can+actually+do.&amp;p=%2Frender-lab" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Render Lab · three.ws" />
+ <meta name="twitter:description" content="Compose a real avatar render, see what the model can actually do, and copy the exact API call." />
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=build&amp;t=Render+Lab&amp;d=Compose+a+real+avatar+render+and+copy+the+exact+API+call.&amp;p=%2Frender-lab" />
+ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" />
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image:alt" content="Render Lab / three.ws" />
+ <meta name="twitter:site" content="@trythreews" />
+</head>
+<body>
+ <header class="site-header"><div id="nav-container"></div></header>
+ <script src="/nav.js"></script>
+
+ <main class="rl-wrap">
+ <section class="rl-hero">
+ <h1>Render Lab</h1>
+ <p>
+ Compose a real render against the live API, then copy the exact call. Every control here maps to
+ one parameter of <a href="/docs/media-api">GET /api/avatar/render</a>, and the lab reads each model
+ first: shapes it does not have and poses its skeleton cannot hold are switched off with the reason,
+ instead of failing quietly at render time. No account, no SDK, no key.
+ </p>
+ </section>
+
+ <div class="rl-grid">
+ <!-- ── stage ──────────────────────────────────────────────────── -->
+ <section class="rl-stage-col">
+ <div class="rl-stage" id="stage" data-state="idle">
+ <div class="rl-stage-frame" id="stageFrame">
+ <img id="stageImg" alt="" hidden />
+ <div class="rl-skeleton" id="stageSkeleton" aria-hidden="true"></div>
+ <p class="rl-stage-msg" id="stageMsg">Pick an avatar to start.</p>
+ </div>
+ <div class="rl-stage-bar">
+ <span class="rl-stage-meta" id="stageMeta"></span>
+ <div class="rl-stage-actions">
+ <button type="button" class="rl-btn rl-btn-ghost" id="btnSheet" data-tip="Render this configuration across every camera framing and pose at once. Click any tile to adopt it.">Contact sheet</button>
+ <button type="button" class="rl-btn rl-btn-ghost" id="btnPermalink" data-tip="Copy a link that reopens this exact configuration.">Copy link</button>
+ <a class="rl-btn rl-btn-primary" id="btnOpen" href="#" target="_blank" rel="noopener" data-tip="Open the raw image the API returned, in a new tab.">Open image</a>
+ </div>
+ </div>
+ </div>
+
+ <div class="rl-sheet" id="sheet" hidden>
+ <div class="rl-sheet-head">
+ <h2 id="sheetTitle">Contact sheet</h2>
+ <div class="rl-seg" role="group" aria-label="Contact sheet axis">
+ <button type="button" class="rl-seg-btn is-on" data-axis="scene">Framing</button>
+ <button type="button" class="rl-seg-btn" data-axis="pose">Poses</button>
+ <button type="button" class="rl-seg-btn" data-axis="expression">Expressions</button>
+ </div>
+ <button type="button" class="rl-btn rl-btn-ghost" id="btnSheetClose" aria-label="Close contact sheet">Close</button>
+ </div>
+ <div class="rl-sheet-grid" id="sheetGrid"></div>
+ <p class="rl-sheet-note" id="sheetNote"></p>
+ </div>
+
+ <!-- ── code ───────────────────────────────────────────────── -->
+ <section class="rl-code">
+ <div class="rl-code-head">
+ <div class="rl-tabs" role="tablist" aria-label="Code format">
+ <button type="button" class="rl-tab is-on" role="tab" aria-selected="true" data-lang="url">URL</button>
+ <button type="button" class="rl-tab" role="tab" aria-selected="false" data-lang="html">HTML</button>
+ <button type="button" class="rl-tab" role="tab" aria-selected="false" data-lang="curl">curl</button>
+ <button type="button" class="rl-tab" role="tab" aria-selected="false" data-lang="js">JavaScript</button>
+ <button type="button" class="rl-tab" role="tab" aria-selected="false" data-lang="component">Web component</button>
+ <button type="button" class="rl-tab" role="tab" aria-selected="false" data-lang="mcp">MCP</button>
+ </div>
+ <button type="button" class="rl-btn rl-btn-secondary" id="btnCopyCode">Copy</button>
+ </div>
+ <pre class="rl-code-body"><code id="codeOut"></code></pre>
+ <p class="rl-code-note" id="codeNote"></p>
+ </section>
+ </section>
+
+ <!-- ── controls ───────────────────────────────────────────────── -->
+ <aside class="rl-rail">
+ <section class="rl-panel">
+ <h2 class="rl-panel-h">Model</h2>
+ <div class="rl-avatars" id="avatarStrip" role="radiogroup" aria-label="Choose an avatar"></div>
+ <label class="rl-field">
+ <span class="rl-label" data-tip="Any three.ws avatar ID, or a public .glb URL from anywhere on the web.">Avatar ID or GLB URL</span>
+ <span class="rl-input-row">
+ <input type="text" id="customInput" class="rl-input" placeholder="13f259c7-… or https://…/model.glb" spellcheck="false" autocomplete="off" />
+ <button type="button" class="rl-btn rl-btn-secondary" id="btnLoadCustom">Load</button>
+ </span>
+ </label>
+ </section>
+
+ <section class="rl-panel" id="capPanel" hidden>
+ <h2 class="rl-panel-h">What this model can do</h2>
+ <div class="rl-cap-head" id="capHead"></div>
+ <div class="rl-meters" id="capMeters"></div>
+ <ul class="rl-verdicts" id="capVerdicts"></ul>
+ <p class="rl-cap-src">Read from the GLB itself via <a href="/docs/media-api#capabilities">/api/avatar/capabilities</a>.</p>
+ </section>
+
+ <section class="rl-panel">
+ <h2 class="rl-panel-h">Framing</h2>
+ <div class="rl-chips" id="sceneChips" role="radiogroup" aria-label="Camera framing"></div>
+
+ <label class="rl-field">
+ <span class="rl-label" data-tip="Square output dimension in pixels. width/height override it when you need a non-square image.">Size <b id="sizeVal">512</b> px</span>
+ <input type="range" id="sizeInput" min="128" max="2048" step="64" value="512" class="rl-range" />
+ </label>
+
+ <label class="rl-field">
+ <span class="rl-label" data-tip="Any CSS color, or transparent for a cut-out PNG you can drop on any background.">Background</span>
+ <span class="rl-input-row">
+ <input type="color" id="bgColor" class="rl-color" value="#0a0a0a" aria-label="Background color" />
+ <input type="text" id="bgInput" class="rl-input" value="transparent" spellcheck="false" autocomplete="off" />
+ </span>
+ </label>
+
+ <label class="rl-field">
+ <span class="rl-label" data-tip="PNG keeps transparency. WebP and JPEG are smaller; quality applies to those two only.">Format</span>
+ <span class="rl-input-row">
+ <select id="formatInput" class="rl-select">
+ <option value="png">png</option>
+ <option value="webp">webp</option>
+ <option value="jpeg">jpeg</option>
+ </select>
+ <input type="number" id="qualityInput" class="rl-input rl-input-num" min="1" max="100" value="90" disabled aria-label="Quality" />
+ </span>
+ </label>
+ </section>
+
+ <section class="rl-panel" id="posePanel">
+ <h2 class="rl-panel-h">
+ Pose
+ <span class="rl-panel-state" id="poseState"></span>
+ </h2>
+ <div class="rl-chips rl-chips-scroll" id="poseChips" role="radiogroup" aria-label="Pose preset"></div>
+ </section>
+
+ <section class="rl-panel" id="exprPanel">
+ <h2 class="rl-panel-h">
+ Expression
+ <span class="rl-panel-state" id="exprState"></span>
+ </h2>
+ <div class="rl-presets" id="exprPresets"></div>
+ <div class="rl-sliders" id="exprSliders"></div>
+ <p class="rl-empty" id="exprEmpty" hidden></p>
+ </section>
+
+ <button type="button" class="rl-btn rl-btn-secondary rl-reset" id="btnReset">Reset everything</button>
+ </aside>
+ </div>
+
+ <section class="rl-next">
+ <h2>Next</h2>
+ <div class="rl-next-grid">
+ <a class="rl-next-card" href="/docs/media-api">
+ <strong>Media API reference</strong>
+ <span>Every parameter, response header, and cache rule for the render and capability endpoints.</span>
+ </a>
+ <a class="rl-next-card" href="/docs/tutorials/render-avatar-images">
+ <strong>Tutorial: render avatar images</strong>
+ <span>Ship avatar images into a real page, from first request to CDN-cached production use.</span>
+ </a>
+ <a class="rl-next-card" href="/create">
+ <strong>Make your own avatar</strong>
+ <span>Generate a rigged avatar from a prompt or a photo, then render it here.</span>
+ </a>
+ </div>
+ </section>
+ </main>
+
+ <script type="module" src="/src/render-lab.js"></script>
+ <script type="module" src="/i18n.js"></script>
+</body>
+</html>
diff --git a/src/forge-reel.js b/src/forge-reel.js
new file mode 100644
index 000000000..7bf653270
--- /dev/null
+++ b/src/forge-reel.js
@@ -0,0 +1,1044 @@
+/**
+ * Forge Reel: turn a forged model into shareable media without leaving the page.
+ *
+ * A text-to-3D site normally hands back a GLB and stops there. That is the
+ * wrong last mile: almost nobody's next step is "open Blender", it is "show
+ * someone". Cinema mode already gave /forge a clean fullscreen turntable, but
+ * it still assumed the user owned a screen recorder, knew how to crop it, and
+ * would accept whatever framerate their capture tool felt like.
+ *
+ * This module removes that entire detour. It drives the result <model-viewer>
+ * along a scripted camera track, records the live WebGL canvas through
+ * MediaRecorder, and hands back three real files:
+ *
+ * - a looping video (MP4 where the browser can encode it, WebM otherwise)
+ * - a hero still at the reel's aspect
+ * - a square still sized for link previews and app icons
+ *
+ * Everything runs client side. No upload, no queue, no worker, no server cost,
+ * and the pixels are the exact pixels the user is looking at: same GLB, same
+ * HDRI environment, same tone mapping. The camera track is expressed in
+ * multiples of the model's own framed radius, so a teacup and a cathedral get
+ * the same shot rather than the same numbers.
+ *
+ * The pure pieces (the shot tracks, the sampler, the codec choice, the output
+ * dimensions) are exported and covered by tests/forge-reel.test.js. The mount
+ * is DOM guarded so importing this file in Node is safe.
+ */
+
+/** Frames per second requested from the canvas stream. */
+export const REEL_FPS = 30;
+
+/** Video bitrate. High enough that a dark model on a dark stage stays clean. */
+const VIDEO_BITRATE = 12_000_000;
+
+/**
+ * Output sizes, in CSS pixels.
+ *
+ * The recorded canvas is this multiplied by devicePixelRatio, so a 2x display
+ * yields a 2560x1440 file from the 16:9 entry. The stage is scaled down with a
+ * CSS transform when the viewport is smaller, which changes what the user sees
+ * and not what gets encoded.
+ */
+export const REEL_ASPECTS = [
+ { id: 'wide', label: '16:9', hint: 'Landscape, for sites and decks', width: 1280, height: 720 },
+ { id: 'square', label: '1:1', hint: 'Square, for link previews', width: 900, height: 900 },
+ { id: 'tall', label: '9:16', hint: 'Vertical, for phone video', width: 540, height: 960 },
+];
+
+/** Reel lengths offered. Short is the default: most people rewatch, few wait. */
+export const REEL_DURATIONS = [4, 8, 12];
+
+/**
+ * Camera tracks.
+ *
+ * A keyframe is `{ t, theta, phi, radius, fov }`:
+ * t 0..1 position along the reel
+ * theta yaw in degrees, allowed to exceed 360 so a spin reads as a spin
+ * phi polar angle in degrees (90 is eye level, smaller looks down)
+ * radius multiple of the model's own framed distance, so scale is irrelevant
+ * fov multiple of the viewer's default field of view
+ *
+ * `ease` names the curve used to reach that keyframe from the previous one.
+ * `heroT` marks the moment the stills are taken: the frame the shot was built
+ * to arrive at.
+ */
+export const REEL_PRESETS = [
+ {
+ id: 'turntable',
+ label: 'Turntable',
+ blurb: 'One clean revolution. Loops seamlessly, reads as a product shot.',
+ heroT: 0.12,
+ track: [
+ { t: 0, theta: 0, phi: 78, radius: 1, fov: 1, ease: 'linear' },
+ { t: 1, theta: 360, phi: 78, radius: 1, fov: 1, ease: 'linear' },
+ ],
+ },
+ {
+ id: 'hero',
+ label: 'Hero push',
+ blurb: 'Opens wide, pushes in, settles on a three-quarter hero angle.',
+ heroT: 1,
+ track: [
+ { t: 0, theta: -58, phi: 88, radius: 1.55, fov: 1.14, ease: 'linear' },
+ { t: 0.55, theta: -16, phi: 72, radius: 1.02, fov: 1, ease: 'out' },
+ { t: 1, theta: 16, phi: 68, radius: 0.95, fov: 0.95, ease: 'inout' },
+ ],
+ },
+ {
+ id: 'reveal',
+ label: 'Low reveal',
+ blurb: 'Rises from below the horizon into the hero angle. Good for props.',
+ heroT: 1,
+ track: [
+ { t: 0, theta: 200, phi: 104, radius: 1.4, fov: 1.1, ease: 'linear' },
+ { t: 0.55, theta: 300, phi: 84, radius: 1.08, fov: 1, ease: 'out' },
+ { t: 1, theta: 382, phi: 70, radius: 1, fov: 0.96, ease: 'inout' },
+ ],
+ },
+];
+
+const EASINGS = {
+ linear: (x) => x,
+ out: (x) => 1 - (1 - x) ** 3,
+ in: (x) => x ** 3,
+ inout: (x) => (x < 0.5 ? 4 * x ** 3 : 1 - (-2 * x + 2) ** 3 / 2),
+};
+
+/**
+ * Sample a camera track at normalised time `t`.
+ *
+ * Returns `{ theta, phi, radius, fov }` with radius and fov still expressed as
+ * multiples. Out-of-range `t` clamps to the endpoints rather than extrapolating,
+ * because an extrapolated camera flies through the model.
+ */
+export function sampleTrack(track, t) {
+ if (!Array.isArray(track) || track.length === 0) {
+ throw new Error('sampleTrack needs at least one keyframe');
+ }
+ const clamped = Math.min(1, Math.max(0, Number(t) || 0));
+ if (clamped <= track[0].t) return frameOf(track[0]);
+ const last = track[track.length - 1];
+ if (clamped >= last.t) return frameOf(last);
+
+ let i = 0;
+ while (i < track.length - 1 && track[i + 1].t < clamped) i++;
+ const a = track[i];
+ const b = track[i + 1];
+ const span = b.t - a.t;
+ const local = span <= 0 ? 1 : (clamped - a.t) / span;
+ const ease = EASINGS[b.ease] || EASINGS.inout;
+ const k = ease(local);
+ return {
+ theta: lerp(a.theta, b.theta, k),
+ phi: lerp(a.phi, b.phi, k),
+ radius: lerp(a.radius, b.radius, k),
+ fov: lerp(a.fov, b.fov, k),
+ };
+}
+
+const lerp = (a, b, k) => a + (b - a) * k;
+const frameOf = (kf) => ({ theta: kf.theta, phi: kf.phi, radius: kf.radius, fov: kf.fov });
+
+/**
+ * Candidate recording formats, best first.
+ *
+ * MP4 is preferred because it drops straight into a slide, a phone, or an X
+ * post without conversion. Chrome gained MP4 recording only recently and Safari
+ * spells its codecs differently, so VP9 WebM stays as the universal floor.
+ */
+export const REEL_MIME_CANDIDATES = [
+ { mime: 'video/mp4;codecs=avc1.42E01E', ext: 'mp4' },
+ { mime: 'video/mp4', ext: 'mp4' },
+ { mime: 'video/webm;codecs=vp9', ext: 'webm' },
+ { mime: 'video/webm;codecs=vp8', ext: 'webm' },
+ { mime: 'video/webm', ext: 'webm' },
+];
+
+/**
+ * Pick the first candidate the browser will actually encode.
+ *
+ * `isSupported` is injected so the choice is testable without a MediaRecorder.
+ * Returns null when nothing is supported, which is a real state: the caller
+ * falls back to stills instead of pretending a recording happened.
+ */
+export function pickVideoFormat(isSupported, candidates = REEL_MIME_CANDIDATES) {
+ if (typeof isSupported !== 'function') return null;
+ for (const candidate of candidates) {
+ try {
+ if (isSupported(candidate.mime)) return candidate;
+ } catch {
+ // A browser that throws on an unknown codec string is saying "no".
+ }
+ }
+ return null;
+}
+
+/**
+ * Build the download filename for one reel artefact.
+ *
+ * Keeps the model's own name so a folder of downloads stays sorted next to the
+ * GLB it came from, and strips anything a filesystem would object to.
+ */
+export function reelFilename(base, presetId, kind, ext) {
+ const safe =
+ String(base || 'forge')
+ .replace(/\.[a-z0-9]+$/i, '')
+ .replace(/[^\w.-]+/g, '-')
+ .replace(/-{2,}/g, '-')
+ .replace(/^-|-$/g, '')
+ .slice(0, 64) || 'forge';
+ return `${safe}-${presetId}-${kind}.${ext}`;
+}
+
+/** Human file size for the result panel. Bytes are never the useful unit here. */
+export function formatBytes(bytes) {
+ const n = Number(bytes) || 0;
+ if (n < 1024) return `${n} B`;
+ if (n < 1024 * 1024) return `${Math.round(n / 1024)} KB`;
+ return `${(n / (1024 * 1024)).toFixed(n < 10 * 1024 * 1024 ? 1 : 0)} MB`;
+}
+
+/**
+ * Fit an output size inside the viewport without changing the output size.
+ *
+ * Returns the CSS transform scale for the stage. Capped at 1 so a small reel
+ * is never blown up past its own resolution on a large screen.
+ */
+export function stageScale(output, viewport, padding = { x: 48, y: 210 }) {
+ const availW = Math.max(160, viewport.width - padding.x);
+ const availH = Math.max(160, viewport.height - padding.y);
+ return Math.min(1, availW / output.width, availH / output.height);
+}
+
+// ---------------------------------------------------------------------------
+// Mount
+// ---------------------------------------------------------------------------
+
+function mountForgeReel() {
+ const viewer = document.getElementById('viewer');
+ const download = document.getElementById('download');
+ const cinema = document.getElementById('cinema');
+ const shell = document.getElementById('viewer-shell');
+ const resultPanel = document.getElementById('state-result');
+ if (!viewer || !shell || !resultPanel || !download) return;
+
+ injectStyles();
+
+ // ---- trigger ----------------------------------------------------------
+
+ const trigger = document.createElement('button');
+ trigger.type = 'button';
+ trigger.className = 'btn btn-ghost reel-trigger';
+ trigger.id = 'reel-open';
+ trigger.title = 'Reel: record a cinematic video and stills of this model (R)';
+ trigger.setAttribute('aria-haspopup', 'dialog');
+ trigger.innerHTML = `${ICON_REEL}Reel`;
+ if (cinema && cinema.parentNode) cinema.parentNode.insertBefore(trigger, cinema);
+ else download.parentNode.insertBefore(trigger, download);
+
+ // ---- dialog -----------------------------------------------------------
+
+ const dialog = document.createElement('div');
+ dialog.className = 'reel-dialog';
+ dialog.setAttribute('role', 'dialog');
+ dialog.setAttribute('aria-modal', 'true');
+ dialog.setAttribute('aria-label', 'Record a reel of this model');
+ dialog.hidden = true;
+ dialog.innerHTML = dialogMarkup();
+ document.body.appendChild(dialog);
+
+ const el = {
+ panel: dialog.querySelector('.reel-panel'),
+ close: dialog.querySelector('.reel-close'),
+ setup: dialog.querySelector('.reel-setup'),
+ presets: dialog.querySelector('.reel-presets'),
+ aspects: dialog.querySelector('.reel-aspects'),
+ durations: dialog.querySelector('.reel-durations'),
+ start: dialog.querySelector('.reel-start'),
+ summary: dialog.querySelector('.reel-summary'),
+ recording: dialog.querySelector('.reel-recording'),
+ bar: dialog.querySelector('.reel-bar-fill'),
+ clock: dialog.querySelector('.reel-clock'),
+ cancel: dialog.querySelector('.reel-cancel'),
+ done: dialog.querySelector('.reel-done'),
+ video: dialog.querySelector('.reel-video'),
+ files: dialog.querySelector('.reel-files'),
+ again: [...dialog.querySelectorAll('.reel-again')],
+ fallback: dialog.querySelector('.reel-fallback'),
+ fallbackShots: dialog.querySelector('.reel-fallback-shots'),
+ recordingTitle: dialog.querySelector('.reel-recording-title'),
+ };
+
+ // ---- capture stage ----------------------------------------------------
+
+ const backdrop = document.createElement('div');
+ backdrop.className = 'reel-stage-backdrop';
+ backdrop.hidden = true;
+ backdrop.innerHTML =
+ '<p class="reel-stage-note" role="status" aria-live="polite">Recording. Do not switch tabs: a background tab stops painting and the reel stops with it.</p>';
+ document.body.appendChild(backdrop);
+
+ const spacer = document.createElement('div');
+ spacer.className = 'reel-spacer';
+ spacer.hidden = true;
+ shell.parentNode.insertBefore(spacer, shell);
+
+ // ---- state ------------------------------------------------------------
+
+ const choice = { preset: REEL_PRESETS[0], aspect: REEL_ASPECTS[0], duration: REEL_DURATIONS[0] };
+ let capturing = false;
+ let cancelled = false;
+ let lastFocus = null;
+ const artefacts = [];
+
+ buildChoiceRow(el.presets, REEL_PRESETS, 'preset');
+ buildChoiceRow(el.aspects, REEL_ASPECTS, 'aspect');
+ buildDurationRow(el.durations);
+ syncSummary();
+
+ function buildChoiceRow(host, items, kind) {
+ for (const item of items) {
+ const b = document.createElement('button');
+ b.type = 'button';
+ b.className = 'reel-chip';
+ b.dataset.kind = kind;
+ b.dataset.id = item.id;
+ b.setAttribute('aria-pressed', String(item.id === choice[kind].id));
+ b.innerHTML = `<span class="reel-chip-label">${item.label}</span><span class="reel-chip-hint">${item.blurb || item.hint || ''}</span>`;
+ b.addEventListener('click', () => {
+ choice[kind] = item;
+ for (const sib of host.querySelectorAll('.reel-chip')) {
+ sib.setAttribute('aria-pressed', String(sib.dataset.id === item.id));
+ }
+ syncSummary();
+ });
+ host.appendChild(b);
+ }
+ }
+
+ function buildDurationRow(host) {
+ for (const seconds of REEL_DURATIONS) {
+ const b = document.createElement('button');
+ b.type = 'button';
+ b.className = 'reel-chip is-compact';
+ b.dataset.id = String(seconds);
+ b.setAttribute('aria-pressed', String(seconds === choice.duration));
+ b.innerHTML = `<span class="reel-chip-label">${seconds}s</span>`;
+ b.addEventListener('click', () => {
+ choice.duration = seconds;
+ for (const sib of host.querySelectorAll('.reel-chip')) {
+ sib.setAttribute('aria-pressed', String(Number(sib.dataset.id) === seconds));
+ }
+ syncSummary();
+ });
+ host.appendChild(b);
+ }
+ }
+
+ function syncSummary() {
+ const fmt = pickVideoFormat(supportsMime);
+ const { width, height } = outputSize();
+ el.summary.textContent = fmt
+ ? `${width}x${height} ${fmt.ext.toUpperCase()}, ${choice.duration}s, plus two PNG stills.`
+ : 'This browser cannot record video. Reel will still capture the stills.';
+ }
+
+ function supportsMime(mime) {
+ return typeof MediaRecorder !== 'undefined' && MediaRecorder.isTypeSupported(mime);
+ }
+
+ /** Output pixels, which is CSS size multiplied by the display's pixel ratio. */
+ function outputSize() {
+ const dpr = Math.min(2, Math.max(1, window.devicePixelRatio || 1));
+ return {
+ width: Math.round(choice.aspect.width * dpr),
+ height: Math.round(choice.aspect.height * dpr),
+ };
+ }
+
+ // ---- open / close -----------------------------------------------------
+
+ function open() {
+ if (capturing) return;
+ lastFocus = document.activeElement;
+ resetArtefacts();
+ showStep('setup');
+ dialog.hidden = false;
+ requestAnimationFrame(() => dialog.classList.add('is-open'));
+ syncSummary();
+ el.start.focus();
+ document.addEventListener('keydown', onDialogKey, true);
+ }
+
+ function close() {
+ if (capturing) {
+ cancelled = true;
+ return;
+ }
+ dialog.classList.remove('is-open');
+ document.removeEventListener('keydown', onDialogKey, true);
+ const hide = () => {
+ dialog.hidden = true;
+ };
+ if (prefersReducedMotion()) hide();
+ else setTimeout(hide, 180);
+ if (lastFocus && document.contains(lastFocus)) lastFocus.focus();
+ }
+
+ function onDialogKey(event) {
+ if (event.key === 'Escape') {
+ event.preventDefault();
+ close();
+ return;
+ }
+ if (event.key !== 'Tab' || dialog.hidden) return;
+ const focusables = [...el.panel.querySelectorAll(FOCUSABLE)].filter(
+ (node) => !node.disabled && node.offsetParent !== null,
+ );
+ if (focusables.length === 0) return;
+ const first = focusables[0];
+ const last = focusables[focusables.length - 1];
+ if (event.shiftKey && document.activeElement === first) {
+ event.preventDefault();
+ last.focus();
+ } else if (!event.shiftKey && document.activeElement === last) {
+ event.preventDefault();
+ first.focus();
+ }
+ }
+
+ function showStep(step) {
+ el.setup.hidden = step !== 'setup';
+ el.recording.hidden = step !== 'recording';
+ el.done.hidden = step !== 'done';
+ el.fallback.hidden = step !== 'fallback';
+ }
+
+ function resetArtefacts() {
+ for (const a of artefacts.splice(0)) URL.revokeObjectURL(a.url);
+ el.files.textContent = '';
+ el.fallbackShots.textContent = '';
+ el.video.removeAttribute('src');
+ }
+
+ trigger.addEventListener('click', open);
+ el.close.addEventListener('click', close);
+ for (const button of el.again) button.addEventListener('click', () => showStep('setup'));
+ el.cancel.addEventListener('click', () => {
+ cancelled = true;
+ });
+ dialog.addEventListener('click', (event) => {
+ if (event.target === dialog) close();
+ });
+ el.start.addEventListener('click', () => {
+ run().catch((err) => fail(err));
+ });
+
+ // `R` mirrors cinema mode's `F`. Ignored while typing, and only while a
+ // result is actually on screen.
+ document.addEventListener('keydown', (event) => {
+ if (event.key !== 'r' && event.key !== 'R') return;
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
+ if (isTypingTarget(event.target)) return;
+ if (resultPanel.classList.contains('is-hidden')) return;
+ if (!dialog.hidden) return;
+ event.preventDefault();
+ open();
+ });
+
+ // ---- the capture itself ------------------------------------------------
+
+ async function run() {
+ const format = pickVideoFormat(supportsMime);
+ const probe = findCanvas(viewer);
+ const canRecord = Boolean(format && probe && typeof probe.captureStream === 'function');
+
+ capturing = true;
+ cancelled = false;
+ trigger.disabled = true;
+ resetArtefacts();
+ el.recordingTitle.textContent = canRecord ? 'Rolling' : 'Capturing stills';
+ showStep('recording');
+ setProgress(0);
+
+ const restore = enterStage();
+ try {
+ const baseline = await frameModel();
+ if (canRecord) {
+ // Re-resolve after the stage is up: the shared canvas can move
+ // between shadow roots when viewer visibility changes.
+ const video = await recordVideo(findCanvas(viewer), format, baseline);
+ if (video) addArtefact('Video', video.blob, video.filename);
+ }
+ if (!cancelled) {
+ el.recordingTitle.textContent = 'Capturing stills';
+ const stills = await captureStills(baseline);
+ for (const still of stills) addArtefact(still.label, still.blob, still.filename);
+ setProgress(1, choice.duration * 1000);
+ }
+ } finally {
+ restore();
+ capturing = false;
+ trigger.disabled = false;
+ }
+
+ if (cancelled && artefacts.length === 0) {
+ showStep('setup');
+ return;
+ }
+ presentResults(canRecord);
+ }
+
+ function fail(err) {
+ capturing = false;
+ trigger.disabled = false;
+ showStep('fallback');
+ el.fallbackShots.textContent = '';
+ const p = document.createElement('p');
+ p.className = 'reel-error';
+ p.textContent = `Recording stopped: ${err?.message || err}. The stills below still work, and the GLB download is unaffected.`;
+ el.fallbackShots.appendChild(p);
+ }
+
+ /**
+ * Take the viewer over for the duration of the capture.
+ *
+ * The shell is pinned to the exact output size so the encoded frames are the
+ * size we advertise rather than whatever the layout happened to be. A spacer
+ * holds the vacated height so the page underneath does not jump, and the
+ * returned function puts everything back including the user's camera.
+ */
+ function enterStage() {
+ const heldOrbit = viewer.getCameraOrbit?.();
+ const heldFov = viewer.getFieldOfView?.();
+ const heldRotate = viewer.hasAttribute('auto-rotate');
+ const heldControls = viewer.hasAttribute('camera-controls');
+ const heldDecay = viewer.getAttribute('interpolation-decay');
+
+ spacer.style.height = `${shell.getBoundingClientRect().height}px`;
+ spacer.hidden = false;
+ backdrop.hidden = false;
+ requestAnimationFrame(() => backdrop.classList.add('is-open'));
+
+ const { width, height } = choice.aspect;
+ const scale = stageScale(
+ { width, height },
+ { width: window.innerWidth, height: window.innerHeight },
+ );
+ shell.style.setProperty('--reel-w', `${width}px`);
+ shell.style.setProperty('--reel-h', `${height}px`);
+ shell.style.setProperty('--reel-scale', String(scale));
+ shell.classList.add('is-reel-stage');
+ document.body.classList.add('forge-reel-capturing');
+
+ // Auto-rotate and user drag both fight the scripted track, so both go
+ // away for the take. `interpolation-decay` at 1ms makes model-viewer
+ // honour our easing instead of smoothing on top of it.
+ viewer.removeAttribute('auto-rotate');
+ viewer.removeAttribute('camera-controls');
+ viewer.setAttribute('interpolation-decay', '1');
+
+ return () => {
+ shell.classList.remove('is-reel-stage');
+ shell.style.removeProperty('--reel-w');
+ shell.style.removeProperty('--reel-h');
+ shell.style.removeProperty('--reel-scale');
+ document.body.classList.remove('forge-reel-capturing');
+ backdrop.classList.remove('is-open');
+ backdrop.hidden = true;
+ spacer.hidden = true;
+ if (heldControls) viewer.setAttribute('camera-controls', '');
+ if (heldRotate) viewer.setAttribute('auto-rotate', '');
+ if (heldDecay === null) viewer.removeAttribute('interpolation-decay');
+ else viewer.setAttribute('interpolation-decay', heldDecay);
+ if (heldOrbit) {
+ viewer.cameraOrbit = `${heldOrbit.theta}rad ${heldOrbit.phi}rad ${heldOrbit.radius}m`;
+ }
+ if (typeof heldFov === 'number') viewer.fieldOfView = `${heldFov}rad`;
+ viewer.jumpCameraToGoal?.();
+ };
+ }
+
+ /**
+ * Reset to the viewer's own framing and read the numbers the track scales.
+ *
+ * Radius has to come from the model, not from a constant: the same "1.55x"
+ * pull-back has to work for a ring and for a building.
+ */
+ async function frameModel() {
+ viewer.cameraOrbit = '0deg 78deg auto';
+ viewer.fieldOfView = 'auto';
+ viewer.jumpCameraToGoal?.();
+ await nextFrame();
+ await nextFrame();
+ const orbit = viewer.getCameraOrbit?.();
+ const fov = viewer.getFieldOfView?.();
+ return {
+ radius: orbit?.radius || 1,
+ fov: typeof fov === 'number' && fov > 0 ? fov : 45,
+ };
+ }
+
+ function applyFrame(sample, baseline) {
+ viewer.cameraOrbit = `${sample.theta}deg ${sample.phi}deg ${sample.radius * baseline.radius}m`;
+ viewer.fieldOfView = `${sample.fov * baseline.fov}deg`;
+ viewer.jumpCameraToGoal?.();
+ }
+
+ async function recordVideo(canvas, format, baseline) {
+ const stream = canvas.captureStream(REEL_FPS);
+ const recorder = new MediaRecorder(stream, {
+ mimeType: format.mime,
+ videoBitsPerSecond: VIDEO_BITRATE,
+ });
+ const chunks = [];
+ recorder.ondataavailable = (event) => {
+ if (event.data && event.data.size > 0) chunks.push(event.data);
+ };
+ const finished = new Promise((resolve) => {
+ recorder.onstop = () => resolve();
+ });
+
+ // One frame on the mark before the recorder opens, so the first encoded
+ // frame is the shot's opening frame and not the previous camera.
+ applyFrame(sampleTrack(choice.preset.track, 0), baseline);
+ await nextFrame();
+
+ recorder.start(250);
+ const totalMs = choice.duration * 1000;
+ const startedAt = performance.now();
+
+ for (;;) {
+ await nextFrame();
+ const elapsed = performance.now() - startedAt;
+ const t = elapsed / totalMs;
+ if (cancelled || t >= 1) break;
+ applyFrame(sampleTrack(choice.preset.track, t), baseline);
+ setProgress(t, elapsed, totalMs);
+ }
+
+ setProgress(1, totalMs, totalMs);
+ // Flush before tearing the stream down. Killing the tracks first drops
+ // whatever the encoder had not handed over yet, which reads as a
+ // successful recording that produced no file.
+ recorder.stop();
+ await finished;
+ for (const track of stream.getTracks()) track.stop();
+
+ if (cancelled || chunks.length === 0) return null;
+ const blob = new Blob(chunks, { type: format.mime.split(';')[0] });
+ return {
+ blob,
+ filename: reelFilename(baseName(), choice.preset.id, 'reel', format.ext),
+ };
+ }
+
+ /**
+ * Two stills from the shot's own hero frame.
+ *
+ * The square one is taken by briefly restaging at 1:1 rather than by cropping
+ * the wide frame, because cropping a 16:9 hero to a square cuts the model's
+ * head off exactly as often as not.
+ */
+ async function captureStills(baseline) {
+ const out = [];
+ const hero = sampleTrack(choice.preset.track, choice.preset.heroT);
+ applyFrame(hero, baseline);
+ await nextFrame();
+ await nextFrame();
+
+ const wide = await snapshot();
+ if (wide) {
+ out.push({
+ label: `Hero still ${choice.aspect.label}`,
+ blob: wide,
+ filename: reelFilename(baseName(), choice.preset.id, 'hero', 'png'),
+ });
+ }
+
+ if (choice.aspect.id !== 'square') {
+ shell.style.setProperty('--reel-w', '1080px');
+ shell.style.setProperty('--reel-h', '1080px');
+ shell.style.setProperty(
+ '--reel-scale',
+ String(
+ stageScale(
+ { width: 1080, height: 1080 },
+ { width: window.innerWidth, height: window.innerHeight },
+ ),
+ ),
+ );
+ await nextFrame();
+ await nextFrame();
+ applyFrame(hero, baseline);
+ await nextFrame();
+ const square = await snapshot();
+ if (square) {
+ out.push({
+ label: 'Square still 1:1',
+ blob: square,
+ filename: reelFilename(baseName(), choice.preset.id, 'square', 'png'),
+ });
+ }
+ }
+ return out;
+ }
+
+ async function snapshot() {
+ try {
+ if (typeof viewer.toBlob === 'function') {
+ return await viewer.toBlob({ mimeType: 'image/png', idealAspect: false });
+ }
+ const url = viewer.toDataURL?.('image/png');
+ if (!url) return null;
+ return await (await fetch(url)).blob();
+ } catch {
+ return null;
+ }
+ }
+
+ function setProgress(t, elapsed = 0, total = choice.duration * 1000) {
+ const pct = Math.round(Math.min(1, Math.max(0, t)) * 100);
+ el.bar.style.width = `${pct}%`;
+ el.bar.parentElement.setAttribute('aria-valuenow', String(pct));
+ el.clock.textContent = `${(elapsed / 1000).toFixed(1)}s of ${(total / 1000).toFixed(0)}s`;
+ }
+
+ function addArtefact(label, blob, filename) {
+ const url = URL.createObjectURL(blob);
+ artefacts.push({ label, blob, filename, url });
+ }
+
+ function presentResults(hadVideo) {
+ showStep(artefacts.some((a) => a.label === 'Video') ? 'done' : 'fallback');
+ const host = artefacts.some((a) => a.label === 'Video') ? el.files : el.fallbackShots;
+ host.textContent = '';
+
+ const video = artefacts.find((a) => a.label === 'Video');
+ if (video) {
+ el.video.src = video.url;
+ el.video.play().catch(() => {
+ // Autoplay refusal is fine: the controls are right there.
+ });
+ } else if (hadVideo) {
+ const p = document.createElement('p');
+ p.className = 'reel-error';
+ p.textContent =
+ 'The recorder produced no frames, which usually means the tab lost focus mid-take. The stills below are from the same shot.';
+ host.appendChild(p);
+ } else {
+ const p = document.createElement('p');
+ p.className = 'reel-note';
+ p.textContent =
+ 'This browser has no canvas video recording, so Reel captured the shot as stills instead. Chrome, Edge and Firefox record video.';
+ host.appendChild(p);
+ }
+
+ for (const artefact of artefacts) {
+ const row = document.createElement('a');
+ row.className = 'reel-file';
+ row.href = artefact.url;
+ row.download = artefact.filename;
+ row.innerHTML = `
+ <span class="reel-file-kind">${escapeHtml(artefact.label)}</span>
+ <span class="reel-file-name">${escapeHtml(artefact.filename)}</span>
+ <span class="reel-file-size">${formatBytes(artefact.blob.size)}</span>
+ <span class="reel-file-cta">Download</span>`;
+ host.appendChild(row);
+ }
+ }
+
+ function baseName() {
+ return (download.getAttribute('download') || 'forge.glb').replace(/\.glb$/i, '') || 'forge';
+ }
+}
+
+// ---------------------------------------------------------------------------
+// helpers
+// ---------------------------------------------------------------------------
+
+const FOCUSABLE = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
+
+/**
+ * Choose which of a model-viewer's canvases is actually being painted.
+ *
+ * There are two, and picking the wrong one is silent: the recording completes,
+ * reports success, and contains zero frames. model-viewer runs a single shared
+ * WebGL renderer whose canvas carries `id="webgl-canvas"`. While one viewer is
+ * on screen that shared canvas is moved into its shadow root and marked `show`,
+ * and the viewer's own 2D canvas sits idle. As soon as a second viewer becomes
+ * visible the shared canvas is pulled back out and each element's own canvas is
+ * blitted into instead.
+ *
+ * So: record the shared canvas when it is the one being shown here, otherwise
+ * record this element's own canvas. Items are `{ id, shown }` so the rule can
+ * be tested without a browser.
+ */
+export function pickCaptureCanvas(canvases) {
+ if (!Array.isArray(canvases) || canvases.length === 0) return -1;
+ const shared = canvases.findIndex((c) => c.id === 'webgl-canvas' && c.shown);
+ if (shared !== -1) return shared;
+ const own = canvases.findIndex((c) => c.id !== 'webgl-canvas');
+ return own !== -1 ? own : 0;
+}
+
+function findCanvas(viewer) {
+ const nodes = [...(viewer.shadowRoot?.querySelectorAll('canvas') || [])];
+ if (nodes.length === 0) return null;
+ const index = pickCaptureCanvas(
+ nodes.map((node) => ({ id: node.id, shown: node.classList.contains('show') })),
+ );
+ return nodes[index] || null;
+}
+
+const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => resolve()));
+
+const prefersReducedMotion = () =>
+ typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
+
+function isTypingTarget(node) {
+ if (!node) return false;
+ const tag = node.tagName;
+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || node.isContentEditable;
+}
+
+function escapeHtml(text) {
+ return String(text).replace(
+ /[&<>"']/g,
+ (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+}
+
+const ICON_REEL =
+ '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m22 8-6 4 6 4V8Z"/><rect x="2" y="6" width="14" height="12" rx="2"/></svg>';
+
+function dialogMarkup() {
+ return `
+ <div class="reel-panel">
+ <header class="reel-head">
+ <div>
+ <h2 class="reel-title">Record a reel</h2>
+ <p class="reel-sub">A cinematic pass over this model, encoded in your browser. Nothing is uploaded.</p>
+ </div>
+ <button type="button" class="reel-close" aria-label="Close">&times;</button>
+ </header>
+
+ <section class="reel-setup">
+ <h3 class="reel-legend">Shot</h3>
+ <div class="reel-presets reel-row"></div>
+ <h3 class="reel-legend">Aspect</h3>
+ <div class="reel-aspects reel-row"></div>
+ <h3 class="reel-legend">Length</h3>
+ <div class="reel-durations reel-row is-tight"></div>
+ <p class="reel-summary"></p>
+ <button type="button" class="btn btn-primary reel-start">Record reel</button>
+ </section>
+
+ <section class="reel-recording" hidden>
+ <p class="reel-recording-title">Rolling</p>
+ <div class="reel-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-label="Recording progress">
+ <span class="reel-bar-fill"></span>
+ </div>
+ <p class="reel-clock" aria-live="polite">0.0s</p>
+ <button type="button" class="btn btn-ghost reel-cancel">Cancel</button>
+ </section>
+
+ <section class="reel-done" hidden>
+ <video class="reel-video" playsinline muted loop controls></video>
+ <div class="reel-files"></div>
+ <button type="button" class="btn btn-ghost reel-again">Record another</button>
+ </section>
+
+ <section class="reel-fallback" hidden>
+ <div class="reel-fallback-shots"></div>
+ <button type="button" class="btn btn-ghost reel-again">Back</button>
+ </section>
+ </div>`;
+}
+
+function injectStyles() {
+ const style = document.createElement('style');
+ style.id = 'forge-reel-styles';
+ style.textContent = `
+ .reel-trigger svg { margin-right: 0.35rem; }
+
+ /* Stage: the viewer is pinned to the exact output size while recording, and
+ scaled to fit the viewport without changing the encoded resolution. */
+ .viewer-shell.is-reel-stage {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ width: var(--reel-w);
+ height: var(--reel-h);
+ margin: 0;
+ transform: translate(-50%, -50%) scale(var(--reel-scale, 1));
+ transform-origin: center center;
+ z-index: 10001;
+ border-radius: 14px;
+ overflow: hidden;
+ box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65);
+ }
+ .viewer-shell.is-reel-stage model-viewer { width: 100%; height: 100%; }
+ body.forge-reel-capturing { overflow: hidden; }
+
+ .reel-stage-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 10000;
+ background: rgba(6, 6, 10, 0.94);
+ opacity: 0;
+ transition: opacity 0.2s ease;
+ }
+ .reel-stage-backdrop.is-open { opacity: 1; }
+ .reel-stage-note {
+ position: absolute;
+ left: 50%;
+ bottom: 2.2rem;
+ transform: translateX(-50%);
+ margin: 0;
+ max-width: min(90vw, 44ch);
+ text-align: center;
+ font-size: 0.8rem;
+ line-height: 1.5;
+ color: rgba(255, 255, 255, 0.62);
+ }
+
+ /* Dialog */
+ .reel-dialog {
+ position: fixed;
+ inset: 0;
+ z-index: 10002;
+ display: grid;
+ place-items: center;
+ padding: 1.25rem;
+ background: rgba(6, 6, 10, 0.72);
+ backdrop-filter: blur(6px);
+ opacity: 0;
+ transition: opacity 0.18s ease;
+ }
+ .reel-dialog.is-open { opacity: 1; }
+ .reel-panel {
+ width: min(560px, 100%);
+ max-height: min(88vh, 760px);
+ overflow-y: auto;
+ padding: 1.25rem 1.35rem 1.45rem;
+ border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
+ border-radius: 18px;
+ background: var(--surface-1, #14141b);
+ box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
+ transform: translateY(10px);
+ transition: transform 0.18s ease;
+ }
+ .reel-dialog.is-open .reel-panel { transform: translateY(0); }
+
+ .reel-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; }
+ .reel-title { margin: 0; font-size: 1.08rem; letter-spacing: -0.01em; }
+ .reel-sub { margin: 0.3rem 0 0; font-size: 0.82rem; line-height: 1.5; opacity: 0.7; }
+ .reel-close {
+ margin-left: auto;
+ width: 32px; height: 32px;
+ border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
+ border-radius: 9px;
+ background: transparent; color: inherit;
+ font-size: 1.15rem; line-height: 1; cursor: pointer;
+ transition: background 0.14s ease, border-color 0.14s ease;
+ }
+ .reel-close:hover { background: var(--surface-3, rgba(255, 255, 255, 0.09)); }
+ .reel-close:focus-visible { outline: 2px solid var(--accent, #7c6cff); outline-offset: 2px; }
+
+ .reel-legend {
+ margin: 0 0 0.5rem;
+ font-size: 0.7rem;
+ font-weight: 600;
+ letter-spacing: 0.09em;
+ text-transform: uppercase;
+ opacity: 0.55;
+ }
+ .reel-row { display: grid; gap: 0.5rem; margin-bottom: 1.05rem; }
+ .reel-row.is-tight { grid-auto-flow: column; grid-auto-columns: 1fr; }
+ @media (min-width: 520px) {
+ .reel-aspects { grid-template-columns: repeat(3, 1fr); }
+ }
+
+ .reel-chip {
+ display: block;
+ width: 100%;
+ padding: 0.62rem 0.75rem;
+ border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
+ border-radius: 11px;
+ background: var(--surface-2, rgba(255, 255, 255, 0.04));
+ color: inherit;
+ text-align: left;
+ cursor: pointer;
+ transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
+ }
+ .reel-chip:hover { background: var(--surface-3, rgba(255, 255, 255, 0.08)); transform: translateY(-1px); }
+ .reel-chip:focus-visible { outline: 2px solid var(--accent, #7c6cff); outline-offset: 2px; }
+ .reel-chip[aria-pressed='true'] {
+ border-color: var(--accent, #7c6cff);
+ background: color-mix(in srgb, var(--accent, #7c6cff) 16%, transparent);
+ }
+ .reel-chip.is-compact { text-align: center; }
+ .reel-chip-label { display: block; font-size: 0.87rem; font-weight: 600; }
+ .reel-chip-hint { display: block; margin-top: 0.16rem; font-size: 0.74rem; line-height: 1.4; opacity: 0.66; }
+ .reel-chip.is-compact .reel-chip-hint { display: none; }
+
+ .reel-summary { margin: 0 0 0.95rem; font-size: 0.78rem; opacity: 0.66; }
+ .reel-start { width: 100%; }
+
+ .reel-recording-title { margin: 0 0 0.75rem; font-size: 0.92rem; font-weight: 600; }
+ .reel-bar {
+ height: 6px;
+ border-radius: 999px;
+ background: var(--surface-3, rgba(255, 255, 255, 0.1));
+ overflow: hidden;
+ }
+ .reel-bar-fill {
+ display: block;
+ height: 100%;
+ width: 0%;
+ border-radius: inherit;
+ background: var(--accent, #7c6cff);
+ transition: width 0.1s linear;
+ }
+ .reel-clock { margin: 0.55rem 0 1rem; font-size: 0.78rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
+
+ .reel-video {
+ width: 100%;
+ border-radius: 12px;
+ background: #06060a;
+ margin-bottom: 0.9rem;
+ }
+ .reel-files, .reel-fallback-shots { display: grid; gap: 0.5rem; margin-bottom: 0.95rem; }
+ .reel-file {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ gap: 0.15rem 0.75rem;
+ align-items: center;
+ padding: 0.6rem 0.75rem;
+ border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
+ border-radius: 11px;
+ background: var(--surface-2, rgba(255, 255, 255, 0.04));
+ color: inherit;
+ text-decoration: none;
+ transition: background 0.14s ease, border-color 0.14s ease;
+ }
+ .reel-file:hover { background: var(--surface-3, rgba(255, 255, 255, 0.09)); border-color: var(--accent, #7c6cff); }
+ .reel-file:focus-visible { outline: 2px solid var(--accent, #7c6cff); outline-offset: 2px; }
+ .reel-file-kind { font-size: 0.85rem; font-weight: 600; }
+ .reel-file-cta { grid-row: 1 / span 2; font-size: 0.78rem; opacity: 0.8; }
+ .reel-file-name { grid-column: 1; font-size: 0.73rem; opacity: 0.6; word-break: break-all; }
+ .reel-file-size { display: none; }
+
+ .reel-note, .reel-error { margin: 0 0 0.6rem; font-size: 0.8rem; line-height: 1.5; opacity: 0.75; }
+ .reel-error { color: var(--danger, #ff6b6b); opacity: 0.95; }
+
+ @media (prefers-reduced-motion: reduce) {
+ .reel-dialog, .reel-panel, .reel-chip, .reel-stage-backdrop, .reel-bar-fill { transition: none; }
+ .reel-chip:hover { transform: none; }
+ }`;
+ document.head.appendChild(style);
+}
+
+if (typeof document !== 'undefined') mountForgeReel();
diff --git a/src/render-lab.css b/src/render-lab.css
new file mode 100644
index 000000000..8ac33e582
--- /dev/null
+++ b/src/render-lab.css
@@ -0,0 +1,214 @@
+/* Render Lab — live composer for the public avatar render API.
+ Everything rides the platform tokens in public/tokens.css, so light and dark
+ themes both follow the site toggle with no per-theme overrides here. */
+
+:root {
+ --rl-maxw: 1280px;
+ --rl-rail: 380px;
+ --rl-gap: 18px;
+}
+
+* { box-sizing: border-box; }
+html, body { margin: 0; background: var(--bg-0); color: var(--ink); }
+body { font-family: var(--font-body, 'Inter', system-ui, sans-serif); min-height: 100vh; }
+.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg-0) 82%, transparent); backdrop-filter: blur(10px); }
+
+.rl-wrap { max-width: var(--rl-maxw); margin: 0 auto; padding: 0 18px 96px; }
+
+/* ── hero ───────────────────────────────────────────────────────────── */
+.rl-hero { padding: 34px 0 20px; }
+.rl-hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.02em; color: var(--ink-bright, var(--ink)); }
+.rl-hero p { margin: 0; max-width: 74ch; color: var(--ink-dim); line-height: 1.65; }
+.rl-hero a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
+.rl-hero a:hover { color: var(--ink-bright, var(--ink)); }
+
+/* ── layout ─────────────────────────────────────────────────────────── */
+.rl-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--rl-rail); gap: var(--rl-gap); align-items: start; }
+.rl-stage-col { display: flex; flex-direction: column; gap: var(--rl-gap); min-width: 0; }
+.rl-rail { display: flex; flex-direction: column; gap: var(--rl-gap); position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
+.rl-rail::-webkit-scrollbar { width: 8px; }
+.rl-rail::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }
+
+@media (max-width: 1080px) {
+ .rl-grid { grid-template-columns: minmax(0, 1fr); }
+ .rl-rail { position: static; max-height: none; overflow: visible; }
+}
+
+/* ── panels ─────────────────────────────────────────────────────────── */
+.rl-panel { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-card, 14px); padding: 16px; }
+.rl-panel-h { margin: 0 0 12px; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
+.rl-panel-state { font-size: 0.72rem; letter-spacing: 0; text-transform: none; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; }
+.rl-panel-state.is-ok { color: var(--success); background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.28); }
+.rl-panel-state.is-off { color: var(--warn); background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.28); }
+.rl-panel[data-disabled="true"] { opacity: 0.62; }
+.rl-panel[data-disabled="true"] .rl-chips, .rl-panel[data-disabled="true"] .rl-sliders, .rl-panel[data-disabled="true"] .rl-presets { pointer-events: none; filter: saturate(0.4); }
+
+/* ── stage ──────────────────────────────────────────────────────────── */
+.rl-stage { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-card, 14px); overflow: hidden; }
+.rl-stage-frame {
+ position: relative; display: grid; place-items: center; min-height: 460px; padding: 20px;
+ background-color: var(--surface-1);
+ /* Checkerboard so a transparent render reads as transparent, not as a
+ solid panel the user mistakes for an opaque background. */
+ background-image:
+ linear-gradient(45deg, var(--surface-2) 25%, transparent 25%),
+ linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, var(--surface-2) 75%),
+ linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%);
+ background-size: 22px 22px;
+ background-position: 0 0, 0 11px, 11px -11px, -11px 0;
+}
+.rl-stage-frame img { max-width: 100%; max-height: 62vh; display: block; border-radius: 8px; opacity: 0; transition: opacity 220ms ease; }
+.rl-stage[data-state="ready"] .rl-stage-frame img { opacity: 1; }
+.rl-stage-msg { margin: 0; color: var(--ink-dim); font-size: 0.9rem; text-align: center; max-width: 46ch; line-height: 1.6; }
+.rl-stage[data-state="ready"] .rl-stage-msg, .rl-stage[data-state="loading"] .rl-stage-msg { display: none; }
+.rl-stage[data-state="error"] .rl-stage-msg { color: var(--danger); }
+
+.rl-skeleton { position: absolute; inset: 20px; border-radius: 10px; background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-sheen) 37%, var(--skeleton-base) 63%); background-size: 400% 100%; animation: rl-shimmer 1.3s ease-in-out infinite; display: none; }
+.rl-stage[data-state="loading"] .rl-skeleton { display: block; }
+@keyframes rl-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
+@media (prefers-reduced-motion: reduce) { .rl-skeleton { animation: none; } .rl-stage-frame img { transition: none; } }
+
+.rl-stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--stroke); flex-wrap: wrap; }
+.rl-stage-meta { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.74rem; color: var(--ink-dim); }
+.rl-stage-actions { display: flex; gap: 8px; flex-wrap: wrap; }
+
+/* ── buttons ────────────────────────────────────────────────────────── */
+.rl-btn { font: inherit; font-size: 0.8rem; line-height: 1; padding: 8px 13px; border-radius: var(--radius-control, 10px); border: 1px solid transparent; cursor: pointer; transition: background 140ms ease, border-color 140ms ease, transform 90ms ease; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
+.rl-btn:active { transform: translateY(1px); }
+.rl-btn:focus-visible { outline: var(--focus-ring-width, 2px) solid var(--focus-ring-color, var(--accent)); outline-offset: var(--focus-ring-offset, 2px); }
+.rl-btn-primary { background: var(--btn-primary-bg, var(--accent)); color: var(--btn-primary-fg, #0a0a0a); font-weight: 600; }
+.rl-btn-primary:hover { background: var(--btn-primary-bg-hover, var(--accent)); }
+.rl-btn-secondary { background: var(--btn-secondary-bg, var(--surface-3)); color: var(--btn-secondary-fg, var(--ink)); border-color: var(--btn-secondary-border, var(--stroke-strong)); }
+.rl-btn-secondary:hover { background: var(--btn-secondary-bg-hover, var(--surface-3)); }
+.rl-btn-ghost { background: transparent; color: var(--ink); border-color: var(--stroke-strong); }
+.rl-btn-ghost:hover { background: var(--surface-2); }
+.rl-btn[disabled], .rl-btn[aria-disabled="true"] { opacity: var(--disabled-opacity, 0.4); cursor: var(--disabled-cursor, not-allowed); pointer-events: none; }
+.rl-reset { align-self: flex-start; }
+
+/* ── model strip ────────────────────────────────────────────────────── */
+.rl-avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; margin-bottom: 14px; }
+.rl-av { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--stroke); background: var(--surface-2); cursor: pointer; padding: 0; transition: border-color 140ms ease, transform 120ms ease; }
+.rl-av:hover { border-color: var(--stroke-strong); transform: translateY(-1px); }
+.rl-av[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
+.rl-av:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+.rl-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
+.rl-av-name { position: absolute; inset: auto 0 0 0; font-size: 0.6rem; padding: 3px 4px; background: linear-gradient(180deg, transparent, rgba(0,0,0,0.75)); color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+
+/* ── fields ─────────────────────────────────────────────────────────── */
+.rl-field { display: block; margin-bottom: 14px; }
+.rl-field:last-child { margin-bottom: 0; }
+.rl-label { display: block; font-size: 0.78rem; color: var(--ink-dim); margin-bottom: 6px; }
+.rl-label b { color: var(--ink); font-variant-numeric: tabular-nums; }
+.rl-input-row { display: flex; gap: 8px; align-items: center; }
+.rl-input, .rl-select { flex: 1; min-width: 0; font: inherit; font-size: 0.82rem; padding: 8px 10px; border-radius: var(--radius-control, 10px); border: 1px solid var(--stroke-strong); background: var(--surface-1); color: var(--ink); }
+.rl-input:focus, .rl-select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
+.rl-input-num { flex: 0 0 74px; }
+.rl-color { width: 38px; height: 36px; padding: 0; border: 1px solid var(--stroke-strong); border-radius: var(--radius-control, 10px); background: var(--surface-1); cursor: pointer; flex: none; }
+.rl-range { width: 100%; accent-color: var(--accent); }
+
+/* ── chips ──────────────────────────────────────────────────────────── */
+.rl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
+.rl-chips-scroll { max-height: 188px; overflow-y: auto; padding-right: 4px; }
+.rl-chip { font: inherit; font-size: 0.76rem; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--stroke-strong); background: var(--surface-1); color: var(--ink-dim); cursor: pointer; transition: background 130ms ease, color 130ms ease, border-color 130ms ease; }
+.rl-chip:hover { background: var(--surface-2); color: var(--ink); }
+.rl-chip[aria-checked="true"] { background: var(--accent); color: var(--btn-primary-fg, #0a0a0a); border-color: var(--accent); font-weight: 600; }
+.rl-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+.rl-chip-group { width: 100%; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); margin: 8px 0 2px; }
+.rl-chip-group:first-child { margin-top: 0; }
+
+/* ── capability card ────────────────────────────────────────────────── */
+.rl-cap-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
+.rl-tag { font-size: 0.7rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--stroke-strong); background: var(--surface-2); color: var(--ink-dim); font-family: var(--font-mono, ui-monospace, monospace); }
+.rl-tag b { color: var(--ink); font-weight: 600; }
+
+.rl-meters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
+.rl-meter-top { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--ink-dim); margin-bottom: 4px; }
+.rl-meter-top b { color: var(--ink); font-variant-numeric: tabular-nums; }
+.rl-meter-track { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
+.rl-meter-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 320ms cubic-bezier(0.4, 0, 0.2, 1); }
+.rl-meter-fill.is-low { background: var(--warn); }
+.rl-meter-fill.is-none { background: var(--danger); }
+
+.rl-verdicts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
+.rl-verdict { display: grid; grid-template-columns: 16px 1fr; gap: 9px; font-size: 0.78rem; line-height: 1.5; color: var(--ink-dim); }
+.rl-verdict-icon { font-size: 0.8rem; line-height: 1.5; }
+.rl-verdict.is-yes .rl-verdict-icon { color: var(--success); }
+.rl-verdict.is-partial .rl-verdict-icon { color: var(--warn); }
+.rl-verdict.is-no .rl-verdict-icon { color: var(--danger); }
+.rl-verdict strong { color: var(--ink); font-weight: 600; display: block; }
+.rl-cap-src { margin: 12px 0 0; font-size: 0.7rem; color: var(--ink-dim); }
+.rl-cap-src a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
+
+/* ── expression ─────────────────────────────────────────────────────── */
+.rl-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
+.rl-sliders { display: flex; flex-direction: column; gap: 9px; max-height: 300px; overflow-y: auto; padding-right: 4px; }
+.rl-slider-row { display: grid; grid-template-columns: 1fr 34px; gap: 8px; align-items: center; }
+.rl-slider-row label { font-size: 0.74rem; color: var(--ink-dim); font-family: var(--font-mono, ui-monospace, monospace); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.rl-slider-row input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
+.rl-slider-val { font-size: 0.72rem; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
+.rl-empty { margin: 0; font-size: 0.78rem; color: var(--ink-dim); line-height: 1.6; }
+.rl-empty a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
+
+/* ── contact sheet ──────────────────────────────────────────────────── */
+.rl-sheet { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-card, 14px); padding: 16px; }
+.rl-sheet-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
+.rl-sheet-head h2 { margin: 0; font-size: 0.95rem; flex: 1; }
+.rl-seg { display: inline-flex; border: 1px solid var(--stroke-strong); border-radius: var(--radius-control, 10px); overflow: hidden; }
+.rl-seg-btn { font: inherit; font-size: 0.76rem; padding: 6px 12px; border: 0; background: transparent; color: var(--ink-dim); cursor: pointer; }
+.rl-seg-btn:hover { background: var(--surface-2); color: var(--ink); }
+.rl-seg-btn.is-on { background: var(--accent); color: var(--btn-primary-fg, #0a0a0a); font-weight: 600; }
+.rl-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
+.rl-sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
+.rl-cell { position: relative; padding: 0; border: 1px solid var(--stroke); border-radius: 10px; overflow: hidden; background: var(--surface-1); cursor: pointer; aspect-ratio: 1; transition: border-color 140ms ease, transform 120ms ease; }
+.rl-cell:hover { border-color: var(--accent); transform: translateY(-2px); }
+.rl-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+.rl-cell img { width: 100%; height: 100%; object-fit: contain; display: block; opacity: 0; transition: opacity 200ms ease; }
+.rl-cell img.is-in { opacity: 1; }
+.rl-cell-label { position: absolute; inset: auto 0 0 0; font-size: 0.66rem; padding: 4px 6px; background: linear-gradient(180deg, transparent, rgba(0,0,0,0.78)); color: #fff; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.rl-sheet-note { margin: 12px 0 0; font-size: 0.74rem; color: var(--ink-dim); }
+
+/* ── code panel ─────────────────────────────────────────────────────── */
+.rl-code { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-card, 14px); overflow: hidden; }
+.rl-code-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--stroke); flex-wrap: wrap; }
+.rl-tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
+.rl-tab { font: inherit; font-size: 0.76rem; padding: 5px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--ink-dim); cursor: pointer; }
+.rl-tab:hover { background: var(--surface-2); color: var(--ink); }
+.rl-tab.is-on { background: var(--surface-3); color: var(--ink); border-color: var(--stroke-strong); font-weight: 600; }
+.rl-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+.rl-code-body { margin: 0; padding: 14px; overflow-x: auto; background: var(--surface-1); }
+.rl-code-body code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.76rem; line-height: 1.65; color: var(--ink); white-space: pre; }
+.rl-code-note { margin: 0; padding: 10px 14px; border-top: 1px solid var(--stroke); font-size: 0.72rem; color: var(--ink-dim); }
+
+/* ── next ───────────────────────────────────────────────────────────── */
+.rl-next { margin-top: 40px; }
+.rl-next h2 { font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); margin: 0 0 12px; }
+.rl-next-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
+.rl-next-card { display: flex; flex-direction: column; gap: 5px; padding: 14px; border-radius: var(--radius-card, 14px); border: 1px solid var(--card-border); background: var(--card-bg); text-decoration: none; color: inherit; transition: border-color 140ms ease, transform 120ms ease; }
+.rl-next-card:hover { border-color: var(--card-border-hover, var(--stroke-strong)); transform: translateY(-2px); }
+.rl-next-card strong { font-size: 0.9rem; }
+.rl-next-card span { font-size: 0.78rem; color: var(--ink-dim); line-height: 1.55; }
+
+/* ── tooltips ───────────────────────────────────────────────────────── */
+/* Pure CSS so a tooltip can never be the thing that breaks the page, and so
+ it works on any element that carries the attribute. Touch devices get the
+ same text via the title fallback set alongside it in JS. */
+[data-tip] { position: relative; }
+[data-tip]::after {
+ content: attr(data-tip);
+ position: absolute; bottom: calc(100% + 8px); left: 0;
+ width: max-content; max-width: 260px;
+ padding: 7px 10px; border-radius: 8px;
+ background: var(--bg-1); color: var(--ink); border: 1px solid var(--stroke-strong);
+ box-shadow: var(--shadow-2); font-size: 0.72rem; font-weight: 400; line-height: 1.45;
+ white-space: normal; text-transform: none; letter-spacing: 0;
+ opacity: 0; visibility: hidden; transform: translateY(3px);
+ transition: opacity 130ms ease, transform 130ms ease, visibility 130ms;
+ pointer-events: none; z-index: 60;
+}
+[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; visibility: visible; transform: translateY(0); }
+@media (max-width: 640px) { [data-tip]::after { display: none; } }
+
+/* ── toast ──────────────────────────────────────────────────────────── */
+.rl-toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 12px); background: var(--bg-1); color: var(--ink); border: 1px solid var(--stroke-strong); border-radius: 999px; padding: 9px 18px; font-size: 0.8rem; box-shadow: var(--shadow-3); opacity: 0; transition: opacity 180ms ease, transform 180ms ease; pointer-events: none; z-index: 90; }
+.rl-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
diff --git a/tests/forge-reel.test.js b/tests/forge-reel.test.js
new file mode 100644
index 000000000..58f8c88fb
--- /dev/null
+++ b/tests/forge-reel.test.js
@@ -0,0 +1,197 @@
+// Forge Reel's pure core: the camera sampler, the codec choice, the filenames
+// and the stage fit. Everything here is a decision that would be invisible in
+// the recorded file until someone watched it back and found the camera inside
+// the model, so each boundary is pinned.
+import { describe, it, expect } from 'vitest';
+import {
+ REEL_PRESETS,
+ REEL_ASPECTS,
+ REEL_MIME_CANDIDATES,
+ sampleTrack,
+ pickVideoFormat,
+ reelFilename,
+ formatBytes,
+ stageScale,
+} from '../src/forge-reel.js';
+
+const track = [
+ { t: 0, theta: 0, phi: 80, radius: 2, fov: 1, ease: 'linear' },
+ { t: 1, theta: 100, phi: 60, radius: 1, fov: 0.5, ease: 'linear' },
+];
+
+describe('sampleTrack', () => {
+ it('returns the first keyframe at t=0 and the last at t=1', () => {
+ expect(sampleTrack(track, 0)).toEqual({ theta: 0, phi: 80, radius: 2, fov: 1 });
+ expect(sampleTrack(track, 1)).toEqual({ theta: 100, phi: 60, radius: 1, fov: 0.5 });
+ });
+
+ it('interpolates linearly across a linear segment', () => {
+ expect(sampleTrack(track, 0.5)).toEqual({ theta: 50, phi: 70, radius: 1.5, fov: 0.75 });
+ });
+
+ // Extrapolation is the failure that puts the camera inside the mesh, so out
+ // of range input clamps rather than continuing the line.
+ it('clamps rather than extrapolating outside 0..1', () => {
+ expect(sampleTrack(track, -3)).toEqual(sampleTrack(track, 0));
+ expect(sampleTrack(track, 9)).toEqual(sampleTrack(track, 1));
+ });
+
+ it('eases toward the keyframe that declares the curve', () => {
+ const eased = [
+ { t: 0, theta: 0, phi: 0, radius: 1, fov: 1, ease: 'linear' },
+ { t: 1, theta: 100, phi: 0, radius: 1, fov: 1, ease: 'out' },
+ ];
+ // An ease-out is past the halfway mark at the halfway time.
+ expect(sampleTrack(eased, 0.5).theta).toBeGreaterThan(50);
+ });
+
+ it('picks the right segment in a multi-keyframe track', () => {
+ const three = [
+ { t: 0, theta: 0, phi: 0, radius: 1, fov: 1, ease: 'linear' },
+ { t: 0.5, theta: 10, phi: 0, radius: 1, fov: 1, ease: 'linear' },
+ { t: 1, theta: 110, phi: 0, radius: 1, fov: 1, ease: 'linear' },
+ ];
+ expect(sampleTrack(three, 0.25).theta).toBeCloseTo(5);
+ expect(sampleTrack(three, 0.75).theta).toBeCloseTo(60);
+ });
+
+ it('refuses an empty track instead of returning a silent default', () => {
+ expect(() => sampleTrack([], 0.5)).toThrow();
+ });
+});
+
+describe('presets', () => {
+ it('every preset starts at 0, ends at 1, and has ascending keyframes', () => {
+ for (const preset of REEL_PRESETS) {
+ expect(preset.track[0].t).toBe(0);
+ expect(preset.track[preset.track.length - 1].t).toBe(1);
+ for (let i = 1; i < preset.track.length; i++) {
+ expect(preset.track[i].t).toBeGreaterThan(preset.track[i - 1].t);
+ }
+ }
+ });
+
+ it('every preset takes its stills from a point on its own track', () => {
+ for (const preset of REEL_PRESETS) {
+ expect(preset.heroT).toBeGreaterThanOrEqual(0);
+ expect(preset.heroT).toBeLessThanOrEqual(1);
+ }
+ });
+
+ // The turntable is the one shot users will loop, so its last frame has to
+ // land back on its first. A non-multiple of 360 would visibly jump.
+ it('the turntable loops seamlessly', () => {
+ const turntable = REEL_PRESETS.find((p) => p.id === 'turntable');
+ const start = sampleTrack(turntable.track, 0);
+ const end = sampleTrack(turntable.track, 1);
+ expect((end.theta - start.theta) % 360).toBe(0);
+ expect(end.phi).toBe(start.phi);
+ expect(end.radius).toBe(start.radius);
+ });
+
+ it('keeps every camera above the ground and outside the model', () => {
+ for (const preset of REEL_PRESETS) {
+ for (let t = 0; t <= 1; t += 0.05) {
+ const s = sampleTrack(preset.track, t);
+ expect(s.phi).toBeGreaterThan(0);
+ expect(s.phi).toBeLessThan(180);
+ expect(s.radius).toBeGreaterThan(0.5);
+ }
+ }
+ });
+});
+
+describe('pickVideoFormat', () => {
+ it('prefers MP4 when the browser can encode it', () => {
+ const chosen = pickVideoFormat((mime) => mime.startsWith('video/mp4'));
+ expect(chosen.ext).toBe('mp4');
+ });
+
+ it('falls back to VP9 WebM when MP4 is unavailable', () => {
+ const chosen = pickVideoFormat((mime) => mime.includes('vp9'));
+ expect(chosen).toEqual({ mime: 'video/webm;codecs=vp9', ext: 'webm' });
+ });
+
+ // A null return is a real state the UI renders (stills only), not an error
+ // to swallow, so it must not degrade into a guess.
+ it('returns null when nothing is supported', () => {
+ expect(pickVideoFormat(() => false)).toBeNull();
+ expect(pickVideoFormat(undefined)).toBeNull();
+ });
+
+ it('treats a browser that throws on an unknown codec as a no', () => {
+ const chosen = pickVideoFormat((mime) => {
+ if (mime.startsWith('video/mp4')) throw new TypeError('bad codec');
+ return mime.includes('vp9');
+ });
+ expect(chosen.ext).toBe('webm');
+ });
+
+ it('offers only candidates with a matching container extension', () => {
+ for (const candidate of REEL_MIME_CANDIDATES) {
+ expect(candidate.mime.startsWith(`video/${candidate.ext}`)).toBe(true);
+ }
+ });
+});
+
+describe('reelFilename', () => {
+ it('keeps the model name and drops its extension', () => {
+ expect(reelFilename('brass-lantern.glb', 'hero', 'reel', 'mp4')).toBe(
+ 'brass-lantern-hero-reel.mp4',
+ );
+ });
+
+ it('strips characters a filesystem would reject', () => {
+ expect(reelFilename('a knight / "armor"', 'turntable', 'square', 'png')).toBe(
+ 'a-knight-armor-turntable-square.png',
+ );
+ });
+
+ it('falls back to a usable name when nothing survives', () => {
+ expect(reelFilename('///', 'hero', 'reel', 'webm')).toBe('forge-hero-reel.webm');
+ expect(reelFilename('', 'hero', 'reel', 'webm')).toBe('forge-hero-reel.webm');
+ });
+});
+
+describe('formatBytes', () => {
+ it('scales the unit to the number', () => {
+ expect(formatBytes(900)).toBe('900 B');
+ expect(formatBytes(2048)).toBe('2 KB');
+ expect(formatBytes(3.5 * 1024 * 1024)).toBe('3.5 MB');
+ expect(formatBytes(42 * 1024 * 1024)).toBe('42 MB');
+ });
+});
+
+describe('stageScale', () => {
+ // Scaling the stage down is how a 1280x720 reel stays recordable on a phone.
+ // Scaling it UP would upsample the encode, so 1 is the ceiling.
+ it('never enlarges past the native output size', () => {
+ expect(stageScale({ width: 540, height: 960 }, { width: 3000, height: 3000 })).toBe(1);
+ });
+
+ it('shrinks to fit a small viewport', () => {
+ const scale = stageScale({ width: 1280, height: 720 }, { width: 375, height: 812 });
+ expect(scale).toBeLessThan(1);
+ expect(1280 * scale).toBeLessThanOrEqual(375 - 48 + 0.001);
+ });
+
+ it('stays positive even on an absurdly short viewport', () => {
+ expect(stageScale({ width: 1280, height: 720 }, { width: 200, height: 100 })).toBeGreaterThan(0);
+ });
+});
+
+describe('aspects', () => {
+ it('declares the three orientations the labels promise', () => {
+ const byId = Object.fromEntries(REEL_ASPECTS.map((a) => [a.id, a]));
+ expect(byId.wide.width).toBeGreaterThan(byId.wide.height);
+ expect(byId.square.width).toBe(byId.square.height);
+ expect(byId.tall.height).toBeGreaterThan(byId.tall.width);
+ });
+
+ it('uses even dimensions, which every H.264 encoder requires', () => {
+ for (const aspect of REEL_ASPECTS) {
+ expect(aspect.width % 2).toBe(0);
+ expect(aspect.height % 2).toBe(0);
+ }
+ });
+});