Skip to content

3D engine that AI agents drive

Add a recipes section to the site with three technique pages (#1985)

Nguyen Xuan Anb316a558fd5c
diff --git a/FEATURES.md b/FEATURES.md
index 91f34fd6..6e5cdfca 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -62,6 +62,20 @@ optional `Ready` expression the driver waits for, and `Drive`.
- Source: `site/marketplace.html`, `src/marketplace.js`
- Drive: `node scripts/drive.mjs shot marketplace`
+### `recipes`
+- Name: Recipes
+- Surface: Site
+- Reach: `/recipes.html`
+- Source: `site/recipes.html`, `site/recipe-*.html`, `public/recipes/`, `scripts/recipe-catalog.mjs`, `scripts/make-recipe-pages.mjs`, `src/recipes.js`
+- Drive: `node scripts/drive.mjs shot recipes`
+
+### `recipe-dolly-zoom`
+- Name: Recipe page, dolly zoom
+- Surface: Site
+- Reach: `/recipe-dolly-zoom.html`
+- Source: `site/recipe-dolly-zoom.html`, `public/recipes/dolly-zoom.json`
+- Drive: `node scripts/drive.mjs shot recipe-dolly-zoom`
+
### `object`
- Name: Object studio
- Surface: Site
diff --git a/changes/1985.md b/changes/1985.md
new file mode 100644
index 00000000..685b4919
--- /dev/null
+++ b/changes/1985.md
@@ -0,0 +1 @@
+- Add a Recipes section to the site: an index and three pages (HDRI lighting against a flat key light, ACES against AgX on a warm lamp, a dolly zoom from FOV 75 to FOV 20), each with a before and after picture or clip, a few plain lines and the copyable scene recipe that drew it, also downloadable from `/recipes/<name>.json`.
diff --git a/public/recipes/dolly-zoom-after.webp b/public/recipes/dolly-zoom-after.webp
new file mode 100644
index 00000000..f584fd90
Binary files /dev/null and b/public/recipes/dolly-zoom-after.webp differ
diff --git a/public/recipes/dolly-zoom-before.webp b/public/recipes/dolly-zoom-before.webp
new file mode 100644
index 00000000..e21bf4ac
Binary files /dev/null and b/public/recipes/dolly-zoom-before.webp differ
diff --git a/public/recipes/dolly-zoom.json b/public/recipes/dolly-zoom.json
new file mode 100644
index 00000000..60618cdc
--- /dev/null
+++ b/public/recipes/dolly-zoom.json
@@ -0,0 +1,43 @@
+{
+ "format": "crucible.scene",
+ "schemaVersion": 1,
+ "geometries": [
+ { "id": "post", "type": "cylinder", "segments": 32 },
+ { "id": "ball", "type": "sphere", "segments": 48, "rings": 32 },
+ { "id": "floor", "type": "box", "bevel": 0 }
+ ],
+ "materials": [
+ { "id": "subject", "color": [0.9, 0.35, 0.12], "metallic": 0, "roughness": 0.45 },
+ { "id": "stone", "color": [0.62, 0.6, 0.56], "metallic": 0, "roughness": 0.8 },
+ { "id": "ground", "color": [0.3, 0.32, 0.34], "metallic": 0, "roughness": 0.9 }
+ ],
+ "nodes": [
+ { "id": "ground", "geometry": "floor", "material": "ground", "translation": [0, -0.05, -8], "scale": [14, 0.1, 30] },
+ { "id": "figure-body", "geometry": "post", "material": "subject", "translation": [0, 0.55, 0], "scale": [0.28, 1.1, 0.28] },
+ { "id": "figure-head", "geometry": "ball", "material": "subject", "translation": [0, 1.3, 0], "scale": [0.3, 0.3, 0.3] },
+ { "id": "left-1", "geometry": "post", "material": "stone", "translation": [-2.2, 1.2, -2], "scale": [0.35, 2.4, 0.35] },
+ { "id": "left-2", "geometry": "post", "material": "stone", "translation": [-2.2, 1.2, -5], "scale": [0.35, 2.4, 0.35] },
+ { "id": "left-3", "geometry": "post", "material": "stone", "translation": [-2.2, 1.2, -8], "scale": [0.35, 2.4, 0.35] },
+ { "id": "left-4", "geometry": "post", "material": "stone", "translation": [-2.2, 1.2, -11], "scale": [0.35, 2.4, 0.35] },
+ { "id": "right-1", "geometry": "post", "material": "stone", "translation": [2.2, 1.2, -2], "scale": [0.35, 2.4, 0.35] },
+ { "id": "right-2", "geometry": "post", "material": "stone", "translation": [2.2, 1.2, -5], "scale": [0.35, 2.4, 0.35] },
+ { "id": "right-3", "geometry": "post", "material": "stone", "translation": [2.2, 1.2, -8], "scale": [0.35, 2.4, 0.35] },
+ { "id": "right-4", "geometry": "post", "material": "stone", "translation": [2.2, 1.2, -11], "scale": [0.35, 2.4, 0.35] }
+ ],
+ "camera": { "eye": [0, 0.8, 1.759],"target": [0, 0.8, 0], "fov": 75 },
+ "environment": { "world": true, "lightDirection": [-0.5, 1, 0.6], "keyIntensity": 1.6, "ambientIntensity": 0.5, "skyTop": [0.55, 0.7, 0.9], "skyBottom": [0.85, 0.88, 0.9] },
+ "motion": {
+ "duration": 4.8,
+ "loop": false,
+ "tracks": [
+ {
+ "kind": "camera", "property": "fov", "interpolation": "LINEAR",
+ "keyframes": [{ "time": 0, "value": 75 }, { "time": 0.4, "value": 70.42 }, { "time": 0.8, "value": 65.83 }, { "time": 1.2, "value": 61.25 }, { "time": 1.6, "value": 56.67 }, { "time": 2, "value": 52.08 }, { "time": 2.4, "value": 47.5 }, { "time": 2.8, "value": 42.92 }, { "time": 3.2, "value": 38.33 }, { "time": 3.6, "value": 33.75 }, { "time": 4, "value": 29.17 }, { "time": 4.4, "value": 24.58 }, { "time": 4.8, "value": 20 }]
+ },
+ {
+ "kind": "camera", "property": "eye", "interpolation": "LINEAR",
+ "keyframes": [{ "time": 0, "value": [0, 0.8, 1.759] }, { "time": 0.4, "value": [0, 0.8, 1.913] }, { "time": 0.8, "value": [0, 0.8, 2.086] }, { "time": 1.2, "value": [0, 0.8, 2.28] }, { "time": 1.6, "value": [0, 0.8, 2.504] }, { "time": 2, "value": [0, 0.8, 2.763] }, { "time": 2.4, "value": [0, 0.8, 3.068] }, { "time": 2.8, "value": [0, 0.8, 3.434] }, { "time": 3.2, "value": [0, 0.8, 3.884] }, { "time": 3.6, "value": [0, 0.8, 4.45] }, { "time": 4, "value": [0, 0.8, 5.188] }, { "time": 4.4, "value": [0, 0.8, 6.197] }, { "time": 4.8, "value": [0, 0.8, 7.656] }]
+ }
+ ]
+ }
+}
diff --git a/public/recipes/dolly-zoom.mp4 b/public/recipes/dolly-zoom.mp4
new file mode 100644
index 00000000..66b0a835
Binary files /dev/null and b/public/recipes/dolly-zoom.mp4 differ
diff --git a/public/recipes/hdri-lighting-after.webp b/public/recipes/hdri-lighting-after.webp
new file mode 100644
index 00000000..57239460
Binary files /dev/null and b/public/recipes/hdri-lighting-after.webp differ
diff --git a/public/recipes/hdri-lighting-before.webp b/public/recipes/hdri-lighting-before.webp
new file mode 100644
index 00000000..96d4ee0b
Binary files /dev/null and b/public/recipes/hdri-lighting-before.webp differ
diff --git a/public/recipes/hdri-lighting.before.json b/public/recipes/hdri-lighting.before.json
new file mode 100644
index 00000000..fcea157e
--- /dev/null
+++ b/public/recipes/hdri-lighting.before.json
@@ -0,0 +1 @@
+{ "hdri": null, "world": false, "lightDirection": [-0.4, 0.8, 0.5], "keyColor": [1, 0.97, 0.92], "keyIntensity": 2.4, "ambientIntensity": 0.6 }
diff --git a/public/recipes/hdri-lighting.json b/public/recipes/hdri-lighting.json
new file mode 100644
index 00000000..d3a2e265
--- /dev/null
+++ b/public/recipes/hdri-lighting.json
@@ -0,0 +1,26 @@
+{
+ "format": "crucible.scene",
+ "schemaVersion": 1,
+ "geometries": [
+ { "id": "body", "type": "lathe", "segments": 96, "profile": [[0, 0], [0.38, 0], [0.43, 0.04], [0.46, 0.25], [0.43, 0.52], [0.32, 0.7], [0.18, 0.77], [0, 0.77]] },
+ { "id": "lid", "type": "lathe", "segments": 64, "profile": [[0, 0], [0.19, 0], [0.17, 0.03], [0.06, 0.05], [0.05, 0.09], [0.025, 0.12], [0, 0.12]] },
+ { "id": "spout", "type": "cylinder", "segments": 32 },
+ { "id": "handle", "type": "torus", "tubeRadius": 0.09, "segments": 64, "sides": 16 },
+ { "id": "floor", "type": "box", "bevel": 0 }
+ ],
+ "materials": [
+ { "id": "steel", "color": [0.82, 0.83, 0.86], "metallic": 1, "roughness": 0.16 },
+ { "id": "grip", "color": [0.03, 0.03, 0.035], "metallic": 0, "roughness": 0.6 },
+ { "id": "table", "color": [0.3, 0.26, 0.22], "metallic": 0, "roughness": 0.85 }
+ ],
+ "nodes": [
+ { "id": "table", "geometry": "floor", "material": "table", "translation": [0, -0.05, 0], "scale": [6, 0.1, 4] },
+ { "id": "kettle", "translation": [0, 0, 0] },
+ { "id": "body", "parent": "kettle", "geometry": "body", "material": "steel" },
+ { "id": "lid", "parent": "kettle", "geometry": "lid", "material": "steel", "translation": [0, 0.76, 0] },
+ { "id": "spout", "parent": "kettle", "geometry": "spout", "material": "steel", "translation": [0.73, 0.46, 0], "rotation": [0, 0, -0.342, 0.94], "scale": [0.07, 0.55, 0.07] },
+ { "id": "handle", "parent": "kettle", "geometry": "handle", "material": "grip", "translation": [-0.66, 0.42, 0], "rotation": [0.7071, 0, 0, 0.7071], "scale": [0.28, 0.28, 0.28] }
+ ],
+ "camera": { "eye": [1.9, 1.1, 2.6], "target": [0.1, 0.38, 0], "fov": 30 },
+ "environment": { "world": true, "hdri": "studio-softbox", "environmentIntensity": 0.35, "keyIntensity": 0, "fillIntensity": 0 }
+}
diff --git a/public/recipes/view-transform-after.webp b/public/recipes/view-transform-after.webp
new file mode 100644
index 00000000..c5de8ad4
Binary files /dev/null and b/public/recipes/view-transform-after.webp differ
diff --git a/public/recipes/view-transform-before.webp b/public/recipes/view-transform-before.webp
new file mode 100644
index 00000000..ebafb075
Binary files /dev/null and b/public/recipes/view-transform-before.webp differ
diff --git a/public/recipes/view-transform.before.json b/public/recipes/view-transform.before.json
new file mode 100644
index 00000000..0d8d09ff
--- /dev/null
+++ b/public/recipes/view-transform.before.json
@@ -0,0 +1 @@
+{ "viewTransform": "aces" }
diff --git a/public/recipes/view-transform.json b/public/recipes/view-transform.json
new file mode 100644
index 00000000..79ebc0c3
--- /dev/null
+++ b/public/recipes/view-transform.json
@@ -0,0 +1,36 @@
+{
+ "format": "crucible.scene",
+ "schemaVersion": 1,
+ "geometries": [
+ { "id": "base", "type": "lathe", "segments": 64, "profile": [[0, 0], [0.36, 0], [0.38, 0.03], [0.3, 0.07], [0.06, 0.1], [0, 0.1]] },
+ { "id": "stem", "type": "cylinder", "segments": 32 },
+ { "id": "shade", "type": "lathe", "segments": 64, "profile": [[0.12, 0], [0.4, 0], [0.4, 0.02], [0.14, 0.34], [0.1, 0.34]] },
+ { "id": "bulb", "type": "sphere", "segments": 48, "rings": 32 },
+ { "id": "floor", "type": "box", "bevel": 0 }
+ ],
+ "materials": [
+ { "id": "brass", "color": [0.6, 0.38, 0.12], "metallic": 0.9, "roughness": 0.3 },
+ { "id": "shade", "color": [0.9, 0.45, 0.12], "metallic": 0, "roughness": 0.7, "emission": 0.7, "emissiveColor": [1, 0.35, 0.05] },
+ { "id": "glow", "color": [1, 0.35, 0.05], "emission": 3, "emissiveColor": [1, 0.35, 0.05] },
+ { "id": "table", "color": [0.36, 0.22, 0.14], "metallic": 0, "roughness": 0.5 },
+ { "id": "wall", "color": [0.12, 0.1, 0.1], "metallic": 0, "roughness": 0.9 }
+ ],
+ "nodes": [
+ { "id": "table", "geometry": "floor", "material": "table", "translation": [0, -0.05, 0], "scale": [5, 0.1, 3] },
+ { "id": "wall", "geometry": "floor", "material": "wall", "translation": [0, 1.5, -1.4], "scale": [8, 3.2, 0.1] },
+ { "id": "lamp", "translation": [0, 0, 0] },
+ { "id": "base", "parent": "lamp", "geometry": "base", "material": "brass" },
+ { "id": "stem", "parent": "lamp", "geometry": "stem", "material": "brass", "translation": [0, 0.5, 0], "scale": [0.04, 0.8, 0.04] },
+ { "id": "shade", "parent": "lamp", "geometry": "shade", "material": "shade", "translation": [0, 0.9, 0] },
+ { "id": "bulb", "parent": "lamp", "geometry": "bulb", "material": "glow", "translation": [0, 0.98, 0], "scale": [0.2, 0.22, 0.2] }
+ ],
+ "camera": { "eye": [0.4, 0.95, 2.6], "target": [0, 0.55, 0], "fov": 32 },
+ "environment": {
+ "world": false,
+ "viewTransform": "agx",
+ "keyIntensity": 0.1,
+ "ambientIntensity": 0.1,
+ "pointLights": [{ "position": [0, 0.98, 0.35], "color": [1, 0.5, 0.15], "intensity": 3 }]
+ },
+ "effects": { "exposure": 1 }
+}
diff --git a/scripts/make-recipe-pages.mjs b/scripts/make-recipe-pages.mjs
new file mode 100644
index 00000000..ebb598d4
--- /dev/null
+++ b/scripts/make-recipe-pages.mjs
@@ -0,0 +1,122 @@
+// Writes the recipe pages of the site (site/recipes.html and site/recipe-<slug>.html) from scripts/recipe-catalog.mjs and the recipe
+// files in public/recipes/. The code block on a page is the recipe file's own text, so the page shows exactly what the pictures were
+// drawn from; tests/site-recipes.test.js fails when a page and its file disagree.
+// Usage: node scripts/make-recipe-pages.mjs write the pages
+import { writeFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { beforeSource, RECIPES, recipeSource } from './recipe-catalog.mjs';
+
+const siteFolder = fileURLToPath(new URL('../site/', import.meta.url));
+const ORIGIN = 'https://crucible.codepawl.com';
+
+const NAVIGATION_LINKS = [
+ { href: '/docs.html', label: 'Docs' },
+ { href: '/recipes.html', label: 'Recipes' },
+ { href: '/marketplace.html', label: 'Marketplace' },
+ { href: '/changelog.html', label: 'Changelog' },
+];
+
+export function pageFileName(slug) {
+ return `recipe-${slug}.html`;
+}
+
+export function escapeHtml(text) {
+ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
+}
+
+function navigation(currentHref) {
+ const links = NAVIGATION_LINKS.map(link => `<a href="${link.href}"${link.href === currentHref ? ' aria-current="page"' : ''}>${link.label}</a>`).join('');
+ return `<a class="brand" href="/" aria-label="Crucible home">Crucible</a>
+ <nav aria-label="Library">${links}</nav>
+ <a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>`;
+}
+
+function pageShell({ title, description, path, currentHref, body }) {
+ return `<!doctype html>
+<html lang="en" data-theme="crucible">
+ <head>
+ <meta charset="UTF-8" /><script>try{var saved=localStorage.getItem("crucible-color");if(saved==="light"||saved==="dark")document.documentElement.dataset.color=saved}catch(error){}</script>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="${escapeHtml(description)}" />
+ <link rel="canonical" href="${ORIGIN}${path}" />
+ <title>${escapeHtml(title)} · Crucible</title>
+ <link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml" /><link rel="icon" href="/favicon.ico?v=2" sizes="48x48" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ </head>
+ <body class="site recipes">
+ <a class="skip-link" href="#content">Skip to content</a>
+ <header class="navigation">
+ ${navigation(currentHref)}
+ </header>
+ <main id="content">
+${body}
+ </main>
+ <footer class="site-footer" aria-label="Site footer">
+ <p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>
+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/codepawl/crucible"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/crucible"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>
+ </footer>
+ <script type="module" src="/src/recipes.js"></script>
+ </body>
+</html>
+`;
+}
+
+function frameFigure(recipe, frame) {
+ return `<figure><img src="/recipes/${recipe.slug}-${frame.id}.webp" width="960" height="540" alt="${escapeHtml(`${recipe.title}: ${frame.label}`)}" /><figcaption>${escapeHtml(frame.label)}</figcaption></figure>`;
+}
+
+function codeBlock({ id, heading, source }) {
+ return ` <section class="recipe-code" aria-labelledby="${id}-title">
+ <div class="recipe-code-heading"><h2 id="${id}-title">${escapeHtml(heading)}</h2><button type="button" data-copy-code="${id}">Copy</button></div>
+ <pre><code id="${id}">${escapeHtml(source)}</code></pre>
+ </section>`;
+}
+
+function mediaSection(recipe) {
+ const [before, after] = recipe.frames;
+ const stills = `<div class="recipe-pair">${frameFigure(recipe, before)}${frameFigure(recipe, after)}</div>`;
+ if (!recipe.clip) return ` ${stills}`;
+ const poster = `/recipes/${recipe.slug}-${before.id}.webp`;
+ const clip = `<video class="recipe-clip" src="/recipes/${recipe.slug}.mp4" poster="${poster}" width="960" height="540" muted loop playsinline autoplay aria-label="${escapeHtml(`${recipe.title}, rendered by Crucible`)}"></video>`;
+ return ` ${clip}\n ${stills}`;
+}
+
+export function renderRecipePage(recipe) {
+ const path = `/${pageFileName(recipe.slug)}`;
+ const whyLines = recipe.why.map(line => `<p>${escapeHtml(line)}</p>`).join('');
+ const before = beforeSource(recipe.slug);
+ const blocks = [codeBlock({ id: 'scene-code', heading: 'Scene code', source: recipeSource(recipe.slug) })];
+ if (before) blocks.push(codeBlock({ id: 'before-code', heading: `Merge into the environment for “${recipe.frames[0].label}”`, source: before }));
+ const body = ` <p class="recipe-back"><a href="/recipes.html"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg>Recipes</a></p>
+ <h1>${escapeHtml(recipe.title)}</h1>
+${mediaSection(recipe)}
+ <div class="recipe-why">${whyLines}</div>
+${blocks.join('\n')}
+ <p class="recipe-file"><a href="/recipes/${recipe.slug}.json" download>Download ${recipe.slug}.json</a><span>Paste it into <code>scene_create</code> as <code>recipe</code>.</span></p>`;
+ return pageShell({ title: recipe.title, description: recipe.summary, path, currentHref: '/recipes.html', body });
+}
+
+export function renderIndexPage() {
+ const cards = RECIPES.map(recipe => ` <a class="recipe-card" href="/${pageFileName(recipe.slug)}">
+ <img src="/recipes/${recipe.slug}-after.webp" width="960" height="540" alt="" loading="lazy" />
+ <h2>${escapeHtml(recipe.title)}</h2>
+ <p>${escapeHtml(recipe.summary)}</p>
+ </a>`).join('\n');
+ const body = ` <h1>Recipes</h1>
+ <div class="recipe-list">
+${cards}
+ </div>`;
+ return pageShell({ title: 'Recipes', description: 'One rendering technique per page: a before and after picture, why it matters and the scene code that made it.', path: '/recipes.html', currentHref: '/recipes.html', body });
+}
+
+export function renderRecipePages() {
+ const pages = { 'recipes.html': renderIndexPage() };
+ for (const recipe of RECIPES) pages[pageFileName(recipe.slug)] = renderRecipePage(recipe);
+ return pages;
+}
+
+if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
+ for (const [fileName, html] of Object.entries(renderRecipePages())) {
+ writeFileSync(`${siteFolder}${fileName}`, html);
+ console.log(`wrote site/${fileName}`);
+ }
+}
diff --git a/scripts/recipe-catalog.mjs b/scripts/recipe-catalog.mjs
new file mode 100644
index 00000000..22f4fd35
--- /dev/null
+++ b/scripts/recipe-catalog.mjs
@@ -0,0 +1,75 @@
+// The recipes of the site's /recipes.html: one scene recipe per rendering technique, kept as JSON in public/recipes/ so a reader can
+// fetch it from the site and the picture on the page is drawn from the same bytes the page shows. A recipe file is the finished
+// scene. A `<slug>.before.json` file, where a page has one, holds the `environment` fields that undo the technique; the "before"
+// picture is the recipe with those fields merged into its environment, which is what a `scene_apply` `set-environment` call does.
+import { readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+
+const recipesFolder = fileURLToPath(new URL('../public/recipes/', import.meta.url));
+
+export const RECIPES = [
+ {
+ slug: 'hdri-lighting',
+ title: 'HDRI lighting against a flat key light',
+ summary: 'A metal kettle lit by one key light and flat ambient, then by a studio HDRI.',
+ why: [
+ 'Metal shows what is around it. With one light and flat ambient there is nothing to reflect, so steel reads as grey plastic.',
+ 'An HDRI gives the metal a room to reflect: soft boxes, a bright window, a dark floor. Set the key light to 0, because the HDRI already carries the light.',
+ ],
+ frames: [
+ { id: 'before', label: 'Flat key and ambient', time: 0 },
+ { id: 'after', label: 'studio-softbox HDRI', time: 0 },
+ ],
+ },
+ {
+ slug: 'view-transform',
+ title: 'View transform: ACES against AgX on a warm lamp',
+ summary: 'The same lamp, the same light, two display curves.',
+ why: [
+ 'The view transform turns scene light into the pixels on screen. ACES pushes a strong orange toward yellow and adds contrast. AgX keeps the orange orange and rolls bright areas off gently.',
+ 'Pick it on purpose: ACES is the default, AgX suits lit scenes and matches Blender, neutral keeps product colours as authored.',
+ ],
+ frames: [
+ { id: 'before', label: 'ACES', time: 0 },
+ { id: 'after', label: 'AgX', time: 0 },
+ ],
+ },
+ {
+ slug: 'dolly-zoom',
+ title: 'Field of view: a dolly zoom from FOV 75 to FOV 20',
+ summary: 'The figure keeps its size while the room behind it changes shape.',
+ why: [
+ 'A wide lens up close and a long lens far away frame the subject the same, but the background does not agree: the colonnade is stretched at FOV 75 and squeezed flat at FOV 20.',
+ 'Two camera tracks do it. One animates the FOV. The other moves the camera back to distance 1.35 / tan(FOV / 2) from the figure, so the frame always covers 2.7 m at the figure and the figure keeps its size.',
+ ],
+ clip: { duration: 4.8, fps: 30 },
+ frames: [
+ { id: 'before', label: 'FOV 75', time: 0 },
+ { id: 'after', label: 'FOV 20', time: 4.8 },
+ ],
+ },
+];
+
+export function loadRecipe(slug) {
+ return JSON.parse(readFileSync(`${recipesFolder}${slug}.json`, 'utf8'));
+}
+
+export function recipeSource(slug) {
+ return readFileSync(`${recipesFolder}${slug}.json`, 'utf8').trimEnd();
+}
+
+export function beforeSource(slug) {
+ try {
+ return readFileSync(`${recipesFolder}${slug}.before.json`, 'utf8').trimEnd();
+ } catch {
+ return null;
+ }
+}
+
+/** The recipe a frame is drawn from: the finished scene, or the scene with its before environment fields merged in. */
+export function recipeForFrame(slug, frameId) {
+ const recipe = loadRecipe(slug);
+ const before = beforeSource(slug);
+ if (frameId !== 'before' || !before) return recipe;
+ return { ...recipe, environment: { ...recipe.environment, ...JSON.parse(before) } };
+}
diff --git a/scripts/render-recipes.mjs b/scripts/render-recipes.mjs
new file mode 100644
index 00000000..0717cbbe
--- /dev/null
+++ b/scripts/render-recipes.mjs
@@ -0,0 +1,87 @@
+// Renders the pictures and clips of the site's recipe pages (public/recipes/*.json, listed in scripts/recipe-catalog.mjs) through the
+// MCP render job tools, from the same recipe files the pages show.
+// Usage: node scripts/render-recipes.mjs <output directory> [--size <width>x<height>] [--no-clip] [slug ...]
+// Writes <slug>-<frame id>.png for each frame and, for a recipe with a clip, <slug>.mp4. The default size is 1280x720; run it through gpu-lock.
+import { copyFile, mkdir } from 'node:fs/promises';
+import { existsSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { setTimeout as delay } from 'node:timers/promises';
+import { Client } from '@modelcontextprotocol/client';
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
+import { RECIPES, recipeForFrame } from './recipe-catalog.mjs';
+
+const serverEntry = new URL('../bin/crucible-mcp.mjs', import.meta.url).pathname.replace(/^\/(\w:)/, '$1');
+
+function parseArguments(argumentList) {
+ const options = { directory: null, width: 1280, height: 720, clip: true, slugs: [] };
+ for (let index = 0; index < argumentList.length; index++) {
+ const argument = argumentList[index];
+ if (argument === '--size') {
+ const match = /^(\d+)x(\d+)$/.exec(argumentList[++index] ?? '');
+ if (!match) throw new Error('Pass --size as <width>x<height>, for example --size 1920x1080.');
+ options.width = Number(match[1]);
+ options.height = Number(match[2]);
+ } else if (argument === '--no-clip') options.clip = false;
+ else if (!options.directory) options.directory = resolve(argument);
+ else options.slugs.push(argument);
+ }
+ if (!options.directory) throw new Error('Pass the output directory: node scripts/render-recipes.mjs <directory> [slug ...]');
+ const known = RECIPES.map(recipe => recipe.slug);
+ for (const slug of options.slugs) if (!known.includes(slug)) throw new Error(`Unknown recipe "${slug}". Pass one of: ${known.join(', ')}.`);
+ return options;
+}
+
+async function renderJob(call, sessionId, settings) {
+ const submitted = await call('scene_render_submit', { sessionId, expectedRevision: 0, settings });
+ if (submitted.isError) throw new Error(submitted.content?.[0]?.text);
+ const { jobId } = submitted.structuredContent;
+ for (;;) {
+ const record = (await call('scene_render_status', { jobId })).structuredContent;
+ if (record.state === 'completed') break;
+ if (['cancelled', 'failed'].includes(record.state)) throw new Error(`Render job ${record.state}: ${record.error}`);
+ await delay(250);
+ }
+ const result = (await call('scene_render_result', { jobId })).structuredContent;
+ return result.artifacts[0].path;
+}
+
+async function renderRecipe(call, recipe, options) {
+ for (const frame of recipe.frames) {
+ const created = await call('scene_create', { recipe: recipeForFrame(recipe.slug, frame.id) });
+ if (created.isError) throw new Error(`${recipe.slug} ${frame.id}: ${created.content?.[0]?.text}`);
+ const { sessionId } = created.structuredContent;
+ const settings = { kind: 'image', width: options.width, height: options.height };
+ if (recipe.clip) settings.motion = { start: frame.time };
+ const artifact = await renderJob(call, sessionId, settings);
+ await copyFile(artifact, join(options.directory, `${recipe.slug}-${frame.id}.png`));
+ if (frame.id === 'after' && recipe.clip && options.clip) {
+ const video = await renderJob(call, sessionId, { kind: 'video', width: options.width, height: options.height, fps: recipe.clip.fps, duration: recipe.clip.duration, motion: { start: 0 } });
+ await copyFile(video, join(options.directory, `${recipe.slug}.mp4`));
+ }
+ await call('scene_dispose', { sessionId });
+ console.log(`${recipe.slug} ${frame.id} rendered`);
+ }
+}
+
+async function main() {
+ const options = parseArguments(process.argv.slice(2));
+ if (!existsSync(new URL('../build/mcp/server.mjs', import.meta.url))) throw new Error('Run npm run build and node scripts/build-mcp.mjs first: the MCP server is not built.');
+ await mkdir(options.directory, { recursive: true });
+ const transport = new StdioClientTransport({ command: process.execPath, args: [serverEntry, '--jobs', join(tmpdir(), `crucible-recipes-${process.pid}`)], stderr: 'ignore' });
+ const client = new Client({ name: 'render-recipes', version: '1.0.0' });
+ await client.connect(transport);
+ try {
+ const call = (name, toolArguments) => client.callTool({ name, arguments: toolArguments }, { timeout: 600000 });
+ for (const recipe of RECIPES) {
+ if (options.slugs.length === 0 || options.slugs.includes(recipe.slug)) await renderRecipe(call, recipe, options);
+ }
+ } finally {
+ await client.close();
+ }
+}
+
+main().catch(error => {
+ console.error(error.message);
+ process.exitCode = 1;
+});
diff --git a/site/changelog.html b/site/changelog.html
index 2b0c1514..e5015725 100644
--- a/site/changelog.html
+++ b/site/changelog.html
@@ -6,7 +6,7 @@
<header class="navigation">
<a class="brand" href="/">Crucible</a>
<span class="version" data-release-version>Loading release</span>
- <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html" aria-current="page">Changelog</a></nav>
+ <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/recipes.html">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html" aria-current="page">Changelog</a></nav>
<a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
</header>
<main id="content" class="docs docs-page">
diff --git a/site/docs.html b/site/docs.html
index 5774ff13..e4dd9da4 100644
--- a/site/docs.html
+++ b/site/docs.html
@@ -6,7 +6,7 @@
<header class="navigation">
<a class="brand" href="/">Crucible</a>
<span class="version" data-release-version>Loading release</span>
- <nav aria-label="Library"><a href="/docs.html" aria-current="page">Docs</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>
+ <nav aria-label="Library"><a href="/docs.html" aria-current="page">Docs</a><a href="/recipes.html">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>
<a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
</header>
<main id="content" class="docs docs-page">
diff --git a/site/index.html b/site/index.html
index b0c7742a..ced54683 100644
--- a/site/index.html
+++ b/site/index.html
@@ -70,7 +70,7 @@
<a class="brand" href="/" aria-label="Crucible home">Crucible</a>
<span class="version" data-release-version>Loading release</span>
<nav aria-label="Library">
- <a href="/docs.html">Docs</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a>
+ <a href="/docs.html">Docs</a><a href="/recipes.html">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a>
</nav>
<a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
</header>
diff --git a/site/marketplace.html b/site/marketplace.html
index 305391cf..8cf9c021 100644
--- a/site/marketplace.html
+++ b/site/marketplace.html
@@ -13,7 +13,7 @@
<header class="navigation">
<a class="brand" href="/" aria-label="Crucible home">Crucible</a>
<nav aria-label="Library">
- <a href="/docs.html">Docs</a><a href="/marketplace.html" aria-current="page">Marketplace</a><a href="/changelog.html">Changelog</a>
+ <a href="/docs.html">Docs</a><a href="/recipes.html">Recipes</a><a href="/marketplace.html" aria-current="page">Marketplace</a><a href="/changelog.html">Changelog</a>
</nav>
<a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
</header>
diff --git a/site/recipe-dolly-zoom.html b/site/recipe-dolly-zoom.html
new file mode 100644
index 00000000..e7217a55
--- /dev/null
+++ b/site/recipe-dolly-zoom.html
@@ -0,0 +1,78 @@
+<!doctype html>
+<html lang="en" data-theme="crucible">
+ <head>
+ <meta charset="UTF-8" /><script>try{var saved=localStorage.getItem("crucible-color");if(saved==="light"||saved==="dark")document.documentElement.dataset.color=saved}catch(error){}</script>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="The figure keeps its size while the room behind it changes shape." />
+ <link rel="canonical" href="https://crucible.codepawl.com/recipe-dolly-zoom.html" />
+ <title>Field of view: a dolly zoom from FOV 75 to FOV 20 · Crucible</title>
+ <link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml" /><link rel="icon" href="/favicon.ico?v=2" sizes="48x48" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ </head>
+ <body class="site recipes">
+ <a class="skip-link" href="#content">Skip to content</a>
+ <header class="navigation">
+ <a class="brand" href="/" aria-label="Crucible home">Crucible</a>
+ <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/recipes.html" aria-current="page">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>
+ <a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
+ </header>
+ <main id="content">
+ <p class="recipe-back"><a href="/recipes.html"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg>Recipes</a></p>
+ <h1>Field of view: a dolly zoom from FOV 75 to FOV 20</h1>
+ <video class="recipe-clip" src="/recipes/dolly-zoom.mp4" poster="/recipes/dolly-zoom-before.webp" width="960" height="540" muted loop playsinline autoplay aria-label="Field of view: a dolly zoom from FOV 75 to FOV 20, rendered by Crucible"></video>
+ <div class="recipe-pair"><figure><img src="/recipes/dolly-zoom-before.webp" width="960" height="540" alt="Field of view: a dolly zoom from FOV 75 to FOV 20: FOV 75" /><figcaption>FOV 75</figcaption></figure><figure><img src="/recipes/dolly-zoom-after.webp" width="960" height="540" alt="Field of view: a dolly zoom from FOV 75 to FOV 20: FOV 20" /><figcaption>FOV 20</figcaption></figure></div>
+ <div class="recipe-why"><p>A wide lens up close and a long lens far away frame the subject the same, but the background does not agree: the colonnade is stretched at FOV 75 and squeezed flat at FOV 20.</p><p>Two camera tracks do it. One animates the FOV. The other moves the camera back to distance 1.35 / tan(FOV / 2) from the figure, so the frame always covers 2.7 m at the figure and the figure keeps its size.</p></div>
+ <section class="recipe-code" aria-labelledby="scene-code-title">
+ <div class="recipe-code-heading"><h2 id="scene-code-title">Scene code</h2><button type="button" data-copy-code="scene-code">Copy</button></div>
+ <pre><code id="scene-code">{
+ &quot;format&quot;: &quot;crucible.scene&quot;,
+ &quot;schemaVersion&quot;: 1,
+ &quot;geometries&quot;: [
+ { &quot;id&quot;: &quot;post&quot;, &quot;type&quot;: &quot;cylinder&quot;, &quot;segments&quot;: 32 },
+ { &quot;id&quot;: &quot;ball&quot;, &quot;type&quot;: &quot;sphere&quot;, &quot;segments&quot;: 48, &quot;rings&quot;: 32 },
+ { &quot;id&quot;: &quot;floor&quot;, &quot;type&quot;: &quot;box&quot;, &quot;bevel&quot;: 0 }
+ ],
+ &quot;materials&quot;: [
+ { &quot;id&quot;: &quot;subject&quot;, &quot;color&quot;: [0.9, 0.35, 0.12], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.45 },
+ { &quot;id&quot;: &quot;stone&quot;, &quot;color&quot;: [0.62, 0.6, 0.56], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.8 },
+ { &quot;id&quot;: &quot;ground&quot;, &quot;color&quot;: [0.3, 0.32, 0.34], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.9 }
+ ],
+ &quot;nodes&quot;: [
+ { &quot;id&quot;: &quot;ground&quot;, &quot;geometry&quot;: &quot;floor&quot;, &quot;material&quot;: &quot;ground&quot;, &quot;translation&quot;: [0, -0.05, -8], &quot;scale&quot;: [14, 0.1, 30] },
+ { &quot;id&quot;: &quot;figure-body&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;subject&quot;, &quot;translation&quot;: [0, 0.55, 0], &quot;scale&quot;: [0.28, 1.1, 0.28] },
+ { &quot;id&quot;: &quot;figure-head&quot;, &quot;geometry&quot;: &quot;ball&quot;, &quot;material&quot;: &quot;subject&quot;, &quot;translation&quot;: [0, 1.3, 0], &quot;scale&quot;: [0.3, 0.3, 0.3] },
+ { &quot;id&quot;: &quot;left-1&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [-2.2, 1.2, -2], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;left-2&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [-2.2, 1.2, -5], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;left-3&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [-2.2, 1.2, -8], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;left-4&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [-2.2, 1.2, -11], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;right-1&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [2.2, 1.2, -2], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;right-2&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [2.2, 1.2, -5], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;right-3&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [2.2, 1.2, -8], &quot;scale&quot;: [0.35, 2.4, 0.35] },
+ { &quot;id&quot;: &quot;right-4&quot;, &quot;geometry&quot;: &quot;post&quot;, &quot;material&quot;: &quot;stone&quot;, &quot;translation&quot;: [2.2, 1.2, -11], &quot;scale&quot;: [0.35, 2.4, 0.35] }
+ ],
+ &quot;camera&quot;: { &quot;eye&quot;: [0, 0.8, 1.759],&quot;target&quot;: [0, 0.8, 0], &quot;fov&quot;: 75 },
+ &quot;environment&quot;: { &quot;world&quot;: true, &quot;lightDirection&quot;: [-0.5, 1, 0.6], &quot;keyIntensity&quot;: 1.6, &quot;ambientIntensity&quot;: 0.5, &quot;skyTop&quot;: [0.55, 0.7, 0.9], &quot;skyBottom&quot;: [0.85, 0.88, 0.9] },
+ &quot;motion&quot;: {
+ &quot;duration&quot;: 4.8,
+ &quot;loop&quot;: false,
+ &quot;tracks&quot;: [
+ {
+ &quot;kind&quot;: &quot;camera&quot;, &quot;property&quot;: &quot;fov&quot;, &quot;interpolation&quot;: &quot;LINEAR&quot;,
+ &quot;keyframes&quot;: [{ &quot;time&quot;: 0, &quot;value&quot;: 75 }, { &quot;time&quot;: 0.4, &quot;value&quot;: 70.42 }, { &quot;time&quot;: 0.8, &quot;value&quot;: 65.83 }, { &quot;time&quot;: 1.2, &quot;value&quot;: 61.25 }, { &quot;time&quot;: 1.6, &quot;value&quot;: 56.67 }, { &quot;time&quot;: 2, &quot;value&quot;: 52.08 }, { &quot;time&quot;: 2.4, &quot;value&quot;: 47.5 }, { &quot;time&quot;: 2.8, &quot;value&quot;: 42.92 }, { &quot;time&quot;: 3.2, &quot;value&quot;: 38.33 }, { &quot;time&quot;: 3.6, &quot;value&quot;: 33.75 }, { &quot;time&quot;: 4, &quot;value&quot;: 29.17 }, { &quot;time&quot;: 4.4, &quot;value&quot;: 24.58 }, { &quot;time&quot;: 4.8, &quot;value&quot;: 20 }]
+ },
+ {
+ &quot;kind&quot;: &quot;camera&quot;, &quot;property&quot;: &quot;eye&quot;, &quot;interpolation&quot;: &quot;LINEAR&quot;,
+ &quot;keyframes&quot;: [{ &quot;time&quot;: 0, &quot;value&quot;: [0, 0.8, 1.759] }, { &quot;time&quot;: 0.4, &quot;value&quot;: [0, 0.8, 1.913] }, { &quot;time&quot;: 0.8, &quot;value&quot;: [0, 0.8, 2.086] }, { &quot;time&quot;: 1.2, &quot;value&quot;: [0, 0.8, 2.28] }, { &quot;time&quot;: 1.6, &quot;value&quot;: [0, 0.8, 2.504] }, { &quot;time&quot;: 2, &quot;value&quot;: [0, 0.8, 2.763] }, { &quot;time&quot;: 2.4, &quot;value&quot;: [0, 0.8, 3.068] }, { &quot;time&quot;: 2.8, &quot;value&quot;: [0, 0.8, 3.434] }, { &quot;time&quot;: 3.2, &quot;value&quot;: [0, 0.8, 3.884] }, { &quot;time&quot;: 3.6, &quot;value&quot;: [0, 0.8, 4.45] }, { &quot;time&quot;: 4, &quot;value&quot;: [0, 0.8, 5.188] }, { &quot;time&quot;: 4.4, &quot;value&quot;: [0, 0.8, 6.197] }, { &quot;time&quot;: 4.8, &quot;value&quot;: [0, 0.8, 7.656] }]
+ }
+ ]
+ }
+}</code></pre>
+ </section>
+ <p class="recipe-file"><a href="/recipes/dolly-zoom.json" download>Download dolly-zoom.json</a><span>Paste it into <code>scene_create</code> as <code>recipe</code>.</span></p>
+ </main>
+ <footer class="site-footer" aria-label="Site footer">
+ <p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>
+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/codepawl/crucible"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/crucible"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>
+ </footer>
+ <script type="module" src="/src/recipes.js"></script>
+ </body>
+</html>
diff --git a/site/recipe-hdri-lighting.html b/site/recipe-hdri-lighting.html
new file mode 100644
index 00000000..5c9bf230
--- /dev/null
+++ b/site/recipe-hdri-lighting.html
@@ -0,0 +1,64 @@
+<!doctype html>
+<html lang="en" data-theme="crucible">
+ <head>
+ <meta charset="UTF-8" /><script>try{var saved=localStorage.getItem("crucible-color");if(saved==="light"||saved==="dark")document.documentElement.dataset.color=saved}catch(error){}</script>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="A metal kettle lit by one key light and flat ambient, then by a studio HDRI." />
+ <link rel="canonical" href="https://crucible.codepawl.com/recipe-hdri-lighting.html" />
+ <title>HDRI lighting against a flat key light · Crucible</title>
+ <link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml" /><link rel="icon" href="/favicon.ico?v=2" sizes="48x48" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ </head>
+ <body class="site recipes">
+ <a class="skip-link" href="#content">Skip to content</a>
+ <header class="navigation">
+ <a class="brand" href="/" aria-label="Crucible home">Crucible</a>
+ <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/recipes.html" aria-current="page">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>
+ <a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
+ </header>
+ <main id="content">
+ <p class="recipe-back"><a href="/recipes.html"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg>Recipes</a></p>
+ <h1>HDRI lighting against a flat key light</h1>
+ <div class="recipe-pair"><figure><img src="/recipes/hdri-lighting-before.webp" width="960" height="540" alt="HDRI lighting against a flat key light: Flat key and ambient" /><figcaption>Flat key and ambient</figcaption></figure><figure><img src="/recipes/hdri-lighting-after.webp" width="960" height="540" alt="HDRI lighting against a flat key light: studio-softbox HDRI" /><figcaption>studio-softbox HDRI</figcaption></figure></div>
+ <div class="recipe-why"><p>Metal shows what is around it. With one light and flat ambient there is nothing to reflect, so steel reads as grey plastic.</p><p>An HDRI gives the metal a room to reflect: soft boxes, a bright window, a dark floor. Set the key light to 0, because the HDRI already carries the light.</p></div>
+ <section class="recipe-code" aria-labelledby="scene-code-title">
+ <div class="recipe-code-heading"><h2 id="scene-code-title">Scene code</h2><button type="button" data-copy-code="scene-code">Copy</button></div>
+ <pre><code id="scene-code">{
+ &quot;format&quot;: &quot;crucible.scene&quot;,
+ &quot;schemaVersion&quot;: 1,
+ &quot;geometries&quot;: [
+ { &quot;id&quot;: &quot;body&quot;, &quot;type&quot;: &quot;lathe&quot;, &quot;segments&quot;: 96, &quot;profile&quot;: [[0, 0], [0.38, 0], [0.43, 0.04], [0.46, 0.25], [0.43, 0.52], [0.32, 0.7], [0.18, 0.77], [0, 0.77]] },
+ { &quot;id&quot;: &quot;lid&quot;, &quot;type&quot;: &quot;lathe&quot;, &quot;segments&quot;: 64, &quot;profile&quot;: [[0, 0], [0.19, 0], [0.17, 0.03], [0.06, 0.05], [0.05, 0.09], [0.025, 0.12], [0, 0.12]] },
+ { &quot;id&quot;: &quot;spout&quot;, &quot;type&quot;: &quot;cylinder&quot;, &quot;segments&quot;: 32 },
+ { &quot;id&quot;: &quot;handle&quot;, &quot;type&quot;: &quot;torus&quot;, &quot;tubeRadius&quot;: 0.09, &quot;segments&quot;: 64, &quot;sides&quot;: 16 },
+ { &quot;id&quot;: &quot;floor&quot;, &quot;type&quot;: &quot;box&quot;, &quot;bevel&quot;: 0 }
+ ],
+ &quot;materials&quot;: [
+ { &quot;id&quot;: &quot;steel&quot;, &quot;color&quot;: [0.82, 0.83, 0.86], &quot;metallic&quot;: 1, &quot;roughness&quot;: 0.16 },
+ { &quot;id&quot;: &quot;grip&quot;, &quot;color&quot;: [0.03, 0.03, 0.035], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.6 },
+ { &quot;id&quot;: &quot;table&quot;, &quot;color&quot;: [0.3, 0.26, 0.22], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.85 }
+ ],
+ &quot;nodes&quot;: [
+ { &quot;id&quot;: &quot;table&quot;, &quot;geometry&quot;: &quot;floor&quot;, &quot;material&quot;: &quot;table&quot;, &quot;translation&quot;: [0, -0.05, 0], &quot;scale&quot;: [6, 0.1, 4] },
+ { &quot;id&quot;: &quot;kettle&quot;, &quot;translation&quot;: [0, 0, 0] },
+ { &quot;id&quot;: &quot;body&quot;, &quot;parent&quot;: &quot;kettle&quot;, &quot;geometry&quot;: &quot;body&quot;, &quot;material&quot;: &quot;steel&quot; },
+ { &quot;id&quot;: &quot;lid&quot;, &quot;parent&quot;: &quot;kettle&quot;, &quot;geometry&quot;: &quot;lid&quot;, &quot;material&quot;: &quot;steel&quot;, &quot;translation&quot;: [0, 0.76, 0] },
+ { &quot;id&quot;: &quot;spout&quot;, &quot;parent&quot;: &quot;kettle&quot;, &quot;geometry&quot;: &quot;spout&quot;, &quot;material&quot;: &quot;steel&quot;, &quot;translation&quot;: [0.73, 0.46, 0], &quot;rotation&quot;: [0, 0, -0.342, 0.94], &quot;scale&quot;: [0.07, 0.55, 0.07] },
+ { &quot;id&quot;: &quot;handle&quot;, &quot;parent&quot;: &quot;kettle&quot;, &quot;geometry&quot;: &quot;handle&quot;, &quot;material&quot;: &quot;grip&quot;, &quot;translation&quot;: [-0.66, 0.42, 0], &quot;rotation&quot;: [0.7071, 0, 0, 0.7071], &quot;scale&quot;: [0.28, 0.28, 0.28] }
+ ],
+ &quot;camera&quot;: { &quot;eye&quot;: [1.9, 1.1, 2.6], &quot;target&quot;: [0.1, 0.38, 0], &quot;fov&quot;: 30 },
+ &quot;environment&quot;: { &quot;world&quot;: true, &quot;hdri&quot;: &quot;studio-softbox&quot;, &quot;environmentIntensity&quot;: 0.35, &quot;keyIntensity&quot;: 0, &quot;fillIntensity&quot;: 0 }
+}</code></pre>
+ </section>
+ <section class="recipe-code" aria-labelledby="before-code-title">
+ <div class="recipe-code-heading"><h2 id="before-code-title">Merge into the environment for “Flat key and ambient”</h2><button type="button" data-copy-code="before-code">Copy</button></div>
+ <pre><code id="before-code">{ &quot;hdri&quot;: null, &quot;world&quot;: false, &quot;lightDirection&quot;: [-0.4, 0.8, 0.5], &quot;keyColor&quot;: [1, 0.97, 0.92], &quot;keyIntensity&quot;: 2.4, &quot;ambientIntensity&quot;: 0.6 }</code></pre>
+ </section>
+ <p class="recipe-file"><a href="/recipes/hdri-lighting.json" download>Download hdri-lighting.json</a><span>Paste it into <code>scene_create</code> as <code>recipe</code>.</span></p>
+ </main>
+ <footer class="site-footer" aria-label="Site footer">
+ <p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>
+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/codepawl/crucible"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/crucible"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>
+ </footer>
+ <script type="module" src="/src/recipes.js"></script>
+ </body>
+</html>
diff --git a/site/recipe-view-transform.html b/site/recipe-view-transform.html
new file mode 100644
index 00000000..7bf7e35c
--- /dev/null
+++ b/site/recipe-view-transform.html
@@ -0,0 +1,74 @@
+<!doctype html>
+<html lang="en" data-theme="crucible">
+ <head>
+ <meta charset="UTF-8" /><script>try{var saved=localStorage.getItem("crucible-color");if(saved==="light"||saved==="dark")document.documentElement.dataset.color=saved}catch(error){}</script>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="The same lamp, the same light, two display curves." />
+ <link rel="canonical" href="https://crucible.codepawl.com/recipe-view-transform.html" />
+ <title>View transform: ACES against AgX on a warm lamp · Crucible</title>
+ <link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml" /><link rel="icon" href="/favicon.ico?v=2" sizes="48x48" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ </head>
+ <body class="site recipes">
+ <a class="skip-link" href="#content">Skip to content</a>
+ <header class="navigation">
+ <a class="brand" href="/" aria-label="Crucible home">Crucible</a>
+ <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/recipes.html" aria-current="page">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>
+ <a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
+ </header>
+ <main id="content">
+ <p class="recipe-back"><a href="/recipes.html"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg>Recipes</a></p>
+ <h1>View transform: ACES against AgX on a warm lamp</h1>
+ <div class="recipe-pair"><figure><img src="/recipes/view-transform-before.webp" width="960" height="540" alt="View transform: ACES against AgX on a warm lamp: ACES" /><figcaption>ACES</figcaption></figure><figure><img src="/recipes/view-transform-after.webp" width="960" height="540" alt="View transform: ACES against AgX on a warm lamp: AgX" /><figcaption>AgX</figcaption></figure></div>
+ <div class="recipe-why"><p>The view transform turns scene light into the pixels on screen. ACES pushes a strong orange toward yellow and adds contrast. AgX keeps the orange orange and rolls bright areas off gently.</p><p>Pick it on purpose: ACES is the default, AgX suits lit scenes and matches Blender, neutral keeps product colours as authored.</p></div>
+ <section class="recipe-code" aria-labelledby="scene-code-title">
+ <div class="recipe-code-heading"><h2 id="scene-code-title">Scene code</h2><button type="button" data-copy-code="scene-code">Copy</button></div>
+ <pre><code id="scene-code">{
+ &quot;format&quot;: &quot;crucible.scene&quot;,
+ &quot;schemaVersion&quot;: 1,
+ &quot;geometries&quot;: [
+ { &quot;id&quot;: &quot;base&quot;, &quot;type&quot;: &quot;lathe&quot;, &quot;segments&quot;: 64, &quot;profile&quot;: [[0, 0], [0.36, 0], [0.38, 0.03], [0.3, 0.07], [0.06, 0.1], [0, 0.1]] },
+ { &quot;id&quot;: &quot;stem&quot;, &quot;type&quot;: &quot;cylinder&quot;, &quot;segments&quot;: 32 },
+ { &quot;id&quot;: &quot;shade&quot;, &quot;type&quot;: &quot;lathe&quot;, &quot;segments&quot;: 64, &quot;profile&quot;: [[0.12, 0], [0.4, 0], [0.4, 0.02], [0.14, 0.34], [0.1, 0.34]] },
+ { &quot;id&quot;: &quot;bulb&quot;, &quot;type&quot;: &quot;sphere&quot;, &quot;segments&quot;: 48, &quot;rings&quot;: 32 },
+ { &quot;id&quot;: &quot;floor&quot;, &quot;type&quot;: &quot;box&quot;, &quot;bevel&quot;: 0 }
+ ],
+ &quot;materials&quot;: [
+ { &quot;id&quot;: &quot;brass&quot;, &quot;color&quot;: [0.6, 0.38, 0.12], &quot;metallic&quot;: 0.9, &quot;roughness&quot;: 0.3 },
+ { &quot;id&quot;: &quot;shade&quot;, &quot;color&quot;: [0.9, 0.45, 0.12], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.7, &quot;emission&quot;: 0.7, &quot;emissiveColor&quot;: [1, 0.35, 0.05] },
+ { &quot;id&quot;: &quot;glow&quot;, &quot;color&quot;: [1, 0.35, 0.05], &quot;emission&quot;: 3, &quot;emissiveColor&quot;: [1, 0.35, 0.05] },
+ { &quot;id&quot;: &quot;table&quot;, &quot;color&quot;: [0.36, 0.22, 0.14], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.5 },
+ { &quot;id&quot;: &quot;wall&quot;, &quot;color&quot;: [0.12, 0.1, 0.1], &quot;metallic&quot;: 0, &quot;roughness&quot;: 0.9 }
+ ],
+ &quot;nodes&quot;: [
+ { &quot;id&quot;: &quot;table&quot;, &quot;geometry&quot;: &quot;floor&quot;, &quot;material&quot;: &quot;table&quot;, &quot;translation&quot;: [0, -0.05, 0], &quot;scale&quot;: [5, 0.1, 3] },
+ { &quot;id&quot;: &quot;wall&quot;, &quot;geometry&quot;: &quot;floor&quot;, &quot;material&quot;: &quot;wall&quot;, &quot;translation&quot;: [0, 1.5, -1.4], &quot;scale&quot;: [8, 3.2, 0.1] },
+ { &quot;id&quot;: &quot;lamp&quot;, &quot;translation&quot;: [0, 0, 0] },
+ { &quot;id&quot;: &quot;base&quot;, &quot;parent&quot;: &quot;lamp&quot;, &quot;geometry&quot;: &quot;base&quot;, &quot;material&quot;: &quot;brass&quot; },
+ { &quot;id&quot;: &quot;stem&quot;, &quot;parent&quot;: &quot;lamp&quot;, &quot;geometry&quot;: &quot;stem&quot;, &quot;material&quot;: &quot;brass&quot;, &quot;translation&quot;: [0, 0.5, 0], &quot;scale&quot;: [0.04, 0.8, 0.04] },
+ { &quot;id&quot;: &quot;shade&quot;, &quot;parent&quot;: &quot;lamp&quot;, &quot;geometry&quot;: &quot;shade&quot;, &quot;material&quot;: &quot;shade&quot;, &quot;translation&quot;: [0, 0.9, 0] },
+ { &quot;id&quot;: &quot;bulb&quot;, &quot;parent&quot;: &quot;lamp&quot;, &quot;geometry&quot;: &quot;bulb&quot;, &quot;material&quot;: &quot;glow&quot;, &quot;translation&quot;: [0, 0.98, 0], &quot;scale&quot;: [0.2, 0.22, 0.2] }
+ ],
+ &quot;camera&quot;: { &quot;eye&quot;: [0.4, 0.95, 2.6], &quot;target&quot;: [0, 0.55, 0], &quot;fov&quot;: 32 },
+ &quot;environment&quot;: {
+ &quot;world&quot;: false,
+ &quot;viewTransform&quot;: &quot;agx&quot;,
+ &quot;keyIntensity&quot;: 0.1,
+ &quot;ambientIntensity&quot;: 0.1,
+ &quot;pointLights&quot;: [{ &quot;position&quot;: [0, 0.98, 0.35], &quot;color&quot;: [1, 0.5, 0.15], &quot;intensity&quot;: 3 }]
+ },
+ &quot;effects&quot;: { &quot;exposure&quot;: 1 }
+}</code></pre>
+ </section>
+ <section class="recipe-code" aria-labelledby="before-code-title">
+ <div class="recipe-code-heading"><h2 id="before-code-title">Merge into the environment for “ACES”</h2><button type="button" data-copy-code="before-code">Copy</button></div>
+ <pre><code id="before-code">{ &quot;viewTransform&quot;: &quot;aces&quot; }</code></pre>
+ </section>
+ <p class="recipe-file"><a href="/recipes/view-transform.json" download>Download view-transform.json</a><span>Paste it into <code>scene_create</code> as <code>recipe</code>.</span></p>
+ </main>
+ <footer class="site-footer" aria-label="Site footer">
+ <p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>
+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/codepawl/crucible"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/crucible"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>
+ </footer>
+ <script type="module" src="/src/recipes.js"></script>
+ </body>
+</html>
diff --git a/site/recipes.html b/site/recipes.html
new file mode 100644
index 00000000..3bcbed10
--- /dev/null
+++ b/site/recipes.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<html lang="en" data-theme="crucible">
+ <head>
+ <meta charset="UTF-8" /><script>try{var saved=localStorage.getItem("crucible-color");if(saved==="light"||saved==="dark")document.documentElement.dataset.color=saved}catch(error){}</script>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="One rendering technique per page: a before and after picture, why it matters and the scene code that made it." />
+ <link rel="canonical" href="https://crucible.codepawl.com/recipes.html" />
+ <title>Recipes · Crucible</title>
+ <link rel="icon" href="/favicon.svg?v=2" type="image/svg+xml" /><link rel="icon" href="/favicon.ico?v=2" sizes="48x48" /><link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ </head>
+ <body class="site recipes">
+ <a class="skip-link" href="#content">Skip to content</a>
+ <header class="navigation">
+ <a class="brand" href="/" aria-label="Crucible home">Crucible</a>
+ <nav aria-label="Library"><a href="/docs.html">Docs</a><a href="/recipes.html" aria-current="page">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a></nav>
+ <a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
+ </header>
+ <main id="content">
+ <h1>Recipes</h1>
+ <div class="recipe-list">
+ <a class="recipe-card" href="/recipe-hdri-lighting.html">
+ <img src="/recipes/hdri-lighting-after.webp" width="960" height="540" alt="" loading="lazy" />
+ <h2>HDRI lighting against a flat key light</h2>
+ <p>A metal kettle lit by one key light and flat ambient, then by a studio HDRI.</p>
+ </a>
+ <a class="recipe-card" href="/recipe-view-transform.html">
+ <img src="/recipes/view-transform-after.webp" width="960" height="540" alt="" loading="lazy" />
+ <h2>View transform: ACES against AgX on a warm lamp</h2>
+ <p>The same lamp, the same light, two display curves.</p>
+ </a>
+ <a class="recipe-card" href="/recipe-dolly-zoom.html">
+ <img src="/recipes/dolly-zoom-after.webp" width="960" height="540" alt="" loading="lazy" />
+ <h2>Field of view: a dolly zoom from FOV 75 to FOV 20</h2>
+ <p>The figure keeps its size while the room behind it changes shape.</p>
+ </a>
+ </div>
+ </main>
+ <footer class="site-footer" aria-label="Site footer">
+ <p><a class="brand" href="/" aria-label="Crucible home">Crucible</a> by <a href="https://codepawl.com">CodePawl</a></p>
+ <nav class="footer-links" aria-label="Project links"><a href="https://github.com/codepawl/crucible"><span class="package-logo package-logo-github" aria-hidden="true"></span>GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/crucible"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a></nav>
+ </footer>
+ <script type="module" src="/src/recipes.js"></script>
+ </body>
+</html>
diff --git a/site/showcase.html b/site/showcase.html
index 22af332c..14f294de 100644
--- a/site/showcase.html
+++ b/site/showcase.html
@@ -13,7 +13,7 @@
<header class="navigation">
<a class="brand" href="/" aria-label="Crucible home">Crucible</a>
<nav aria-label="Library">
- <a href="/docs.html">Docs</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a>
+ <a href="/docs.html">Docs</a><a href="/recipes.html">Recipes</a><a href="/marketplace.html">Marketplace</a><a href="/changelog.html">Changelog</a>
</nav>
<a class="site-nav-cta" href="https://github.com/codepawl/crucible" aria-label="GitHub"><span class="package-logo package-logo-github" aria-hidden="true"></span><span class="site-nav-cta-label">GitHub</span></a>
</header>
diff --git a/src/recipes.css b/src/recipes.css
new file mode 100644
index 00000000..a454e787
--- /dev/null
+++ b/src/recipes.css
@@ -0,0 +1,39 @@
+/* The recipe pages: the picture first, a few plain lines, then the scene code. Quiet surfaces, spacing instead of rules. */
+body.recipes > main { gap: 32px; width: var(--page); margin-inline: auto; padding-block: 24px 64px; }
+.recipes main > h1 { font-size: clamp(30px, 4.2vw, 48px); letter-spacing: -1.2px; max-width: 22ch; }
+
+.recipe-back a { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: var(--muted); font-size: 15px; }
+.recipe-back a:hover { color: var(--text); }
+.recipe-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
+
+.recipe-clip { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: var(--panel-radius); background: var(--surface); }
+.recipe-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; }
+.recipe-pair figure { position: relative; margin: 0; }
+.recipe-pair img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: var(--panel-radius); background: var(--surface); }
+.recipe-pair figcaption { position: absolute; left: 12px; bottom: 12px; padding: 4px 10px; border-radius: 6px; background: var(--primary); color: var(--primary-text); font-size: 13px; font-weight: 500; }
+
+.recipe-why { display: grid; gap: 12px; max-width: 68ch; font-size: 17px; }
+.recipe-why p { color: var(--muted); }
+.recipe-why p:first-child { color: var(--text); }
+
+.recipe-code { display: grid; gap: 12px; min-width: 0; }
+.recipe-code-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
+.recipe-code h2 { font-size: 20px; }
+.recipe-code pre { margin: 0; padding: 16px 20px; max-height: 480px; overflow: auto; border-radius: var(--panel-radius); background: var(--bg); font-size: 13px; line-height: 1.7; tab-size: 2; user-select: text; }
+.recipe-code pre code { display: block; width: max-content; min-width: 100%; color: var(--text); }
+
+.recipe-file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; color: var(--muted); font-size: 15px; }
+.recipe-file a { color: var(--text); text-decoration: underline; }
+.recipe-file code { color: var(--text); font-size: 13px; }
+
+.recipe-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 20px; }
+.recipe-card { display: grid; align-content: start; gap: 10px; padding: 12px 12px 20px; border-radius: var(--panel-radius); background: var(--bg); }
+.recipe-card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: var(--radius); background: var(--surface); }
+.recipe-card h2 { padding-inline: 6px; font-size: 19px; letter-spacing: -0.02em; }
+.recipe-card p { padding-inline: 6px; color: var(--muted); font-size: 15px; }
+.recipe-card:hover { background: var(--tint-strong); }
+
+@media (max-width: 640px) {
+ .recipe-pair { grid-template-columns: minmax(0, 1fr); }
+ .recipe-code pre { padding: 14px; font-size: 12px; }
+}
diff --git a/src/recipes.js b/src/recipes.js
new file mode 100644
index 00000000..e839d6b4
--- /dev/null
+++ b/src/recipes.js
@@ -0,0 +1,29 @@
+import './site.css';
+import './brand.js';
+import './recipes.css';
+
+const COPIED_LABEL_MILLISECONDS = 2000;
+
+function mountCopyButton(button) {
+ const source = document.getElementById(button.dataset.copyCode);
+ button.addEventListener('click', async () => {
+ try {
+ await navigator.clipboard.writeText(source.textContent);
+ button.textContent = 'Copied';
+ setTimeout(() => { button.textContent = 'Copy'; }, COPIED_LABEL_MILLISECONDS);
+ } catch {
+ getSelection().selectAllChildren(source);
+ }
+ });
+}
+
+document.querySelectorAll('[data-copy-code]').forEach(mountCopyButton);
+
+// A clip that moves on its own stops for people who asked for less motion; its first frame stays as the picture.
+if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
+ document.querySelectorAll('.recipe-clip').forEach(video => {
+ video.removeAttribute('autoplay');
+ video.pause();
+ video.controls = true;
+ });
+}
diff --git a/src/site.css b/src/site.css
index 73e8d8a0..645d3e47 100644
--- a/src/site.css
+++ b/src/site.css
@@ -173,6 +173,7 @@ body.site .icon { width: 18px; height: 18px; margin: 0; }
.site .brand .brand-mark { width: 28px; height: 28px; margin: 0; }
.site .version { padding: 2px 8px; border-radius: 6px; background: var(--tint); color: var(--muted); font-family: var(--mono); font-size: 12px; }
.site .navigation nav { display: flex; align-items: center; gap: 20px; margin-left: auto; }
+@media (max-width: 480px) { .site .navigation nav { gap: 12px; } .site .navigation nav a .icon { display: none; } }
.site .navigation nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; color: var(--muted); font-size: 15px; }
.site .navigation nav a:hover, .site .navigation nav a[aria-current] { color: var(--text); }
.site .navigation .icon { width: 16px; height: 16px; }
diff --git a/tests/site-recipes.test.js b/tests/site-recipes.test.js
new file mode 100644
index 00000000..cc9aadbe
--- /dev/null
+++ b/tests/site-recipes.test.js
@@ -0,0 +1,59 @@
+import './support/load-agent-scene-modules.mjs';
+import assert from 'node:assert/strict';
+import { existsSync, readFileSync } from 'node:fs';
+import test from 'node:test';
+import { createAgentScene } from '../src/agent-scene.js';
+import { parseRadianceHdr } from '../src/hdri.js';
+import { BUNDLED_ENVIRONMENT_NAMES, registerCatalogEnvironment } from '../src/look-catalog.js';
+import { RECIPES, recipeForFrame, recipeSource } from '../scripts/recipe-catalog.mjs';
+import { escapeHtml, pageFileName, renderRecipePages } from '../scripts/make-recipe-pages.mjs';
+
+for (const name of BUNDLED_ENVIRONMENT_NAMES) registerCatalogEnvironment(name, parseRadianceHdr(readFileSync(new URL(`../assets/looks/${name}.hdr`, import.meta.url))));
+
+const read = relativePath => readFileSync(new URL(`../${relativePath}`, import.meta.url), 'utf8');
+
+test('every committed recipe page is what the generator writes, so the code shown is the code in the file', () => {
+ for (const [fileName, html] of Object.entries(renderRecipePages())) {
+ assert.equal(read(`site/${fileName}`), html, `site/${fileName} is stale: run node scripts/make-recipe-pages.mjs`);
+ }
+ for (const recipe of RECIPES) {
+ const page = read(`site/${pageFileName(recipe.slug)}`);
+ assert.ok(page.includes(`<code id="scene-code">${escapeHtml(recipeSource(recipe.slug))}</code>`), `${recipe.slug} page must hold its recipe file text`);
+ }
+});
+
+test('each recipe file builds a scene, has its pictures, and its before frame differs only in the environment', () => {
+ for (const recipe of RECIPES) {
+ assert.doesNotThrow(() => createAgentScene(recipeForFrame(recipe.slug, 'after')), recipe.slug);
+ assert.doesNotThrow(() => createAgentScene(recipeForFrame(recipe.slug, 'before')), recipe.slug);
+ const after = recipeForFrame(recipe.slug, 'after');
+ const before = recipeForFrame(recipe.slug, 'before');
+ assert.deepEqual({ ...before, environment: null }, { ...after, environment: null });
+ for (const frame of recipe.frames) assert.ok(existsSync(new URL(`../public/recipes/${recipe.slug}-${frame.id}.webp`, import.meta.url)), `${recipe.slug}-${frame.id}.webp`);
+ if (recipe.clip) assert.ok(existsSync(new URL(`../public/recipes/${recipe.slug}.mp4`, import.meta.url)));
+ }
+ assert.notDeepEqual(recipeForFrame('hdri-lighting', 'before').environment, recipeForFrame('hdri-lighting', 'after').environment);
+ assert.equal(recipeForFrame('view-transform', 'before').environment.viewTransform, 'aces');
+ assert.equal(recipeForFrame('view-transform', 'after').environment.viewTransform, 'agx');
+});
+
+test('the dolly zoom keeps the figure the same size from FOV 75 to FOV 20', () => {
+ const scene = createAgentScene(recipeForFrame('dolly-zoom', 'after'));
+ const frameHeights = [];
+ for (let time = 0; time <= 4.8001; time += 0.1) {
+ scene.sampleMotion(time);
+ const distance = scene.camera.eye[2] - scene.camera.target[2];
+ frameHeights.push(2 * distance * Math.tan(scene.camera.fov * Math.PI / 360));
+ }
+ scene.sampleMotion(0);
+ assert.ok(Math.abs(scene.camera.fov - 75) < 1e-6);
+ scene.sampleMotion(4.8);
+ assert.ok(Math.abs(scene.camera.fov - 20) < 1e-6);
+ for (const height of frameHeights) assert.ok(Math.abs(height - 2.7) < 0.05, `frame height ${height} at the figure drifted from 2.7 m`);
+});
+
+test('the site navigation and the build list the recipe pages', () => {
+ for (const page of ['docs', 'changelog', 'marketplace', 'index', 'showcase']) assert.ok(read(`site/${page}.html`).includes('<a href="/recipes.html">Recipes</a>'), `${page} nav`);
+ const viteConfig = read('vite.config.js');
+ for (const fileName of Object.keys(renderRecipePages())) assert.ok(viteConfig.includes(`site/${fileName}`), `${fileName} missing from vite.config.js input`);
+});
diff --git a/vite.config.js b/vite.config.js
index 6f0c78ac..f882a825 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -54,6 +54,10 @@ export default defineConfig({
view2d: 'site/view2d.html',
assets: 'site/assets.html',
guide: 'site/getting-started.html',
+ recipes: 'site/recipes.html',
+ recipeHdriLighting: 'site/recipe-hdri-lighting.html',
+ recipeViewTransform: 'site/recipe-view-transform.html',
+ recipeDollyZoom: 'site/recipe-dolly-zoom.html',
docs: 'site/docs.html',
changelog: 'site/changelog.html',
showcase: 'site/showcase.html',