3D engine that AI agents drive
Home hero B: three live world scenes (valley, ignition, port)
Nguyen Xuan An017b3af5b9d9
diff --git a/hero-b.html b/hero-b.htmlindex 55408432..4437875a 100644--- a/hero-b.html+++ b/hero-b.html@@ -5,9 +5,13 @@<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="theme-color" content="#09070f" /><meta name="robots" content="noindex" />- <title>Hero B · World · 67js</title>+ <title>Hero B · World scenes · 67js</title><link rel="icon" href="/favicon.svg" />- <link rel="preload" as="image" href="/hero-lab/poster-b.webp" media="(min-width: 701px)" fetchpriority="high" />+ <script>+ const scene = ["valley", "ignition", "port"].find(id => id === new URLSearchParams(location.search).get("scene")) ?? "valley";+ const mobile = matchMedia("(max-width: 700px)").matches ? "-mobile" : "";+ document.write(`<link rel="preload" as="image" href="/hero-lab/poster-b-${scene}${mobile}.webp" fetchpriority="high" />`);+ </script></head><body><a class="skip-link" href="#content">Skip to content</a>@@ -21,8 +25,9 @@<main id="content" class="hero-b"><div class="pin" id="pin"><div class="stage" id="stage">- <picture><source media="(max-width: 700px)" srcset="/hero-lab/poster-b-mobile.webp" /><img class="poster" src="/hero-lab/poster-b.webp" alt="" width="1440" height="900" fetchpriority="high" /></picture>- <canvas id="viewport" aria-label="A live 3D airport ramp. Scroll to move the camera."></canvas>+ <picture><source media="(max-width: 700px)" id="poster-mobile" /><img class="poster" id="poster" alt="" width="1440" height="900" fetchpriority="high" /></picture>+ <script>document.querySelector("#poster-mobile").srcset = `/hero-lab/poster-b-${scene}-mobile.webp`; document.querySelector("#poster").src = `/hero-lab/poster-b-${scene}.webp`;</script>+ <canvas id="viewport" aria-label="A live 3D scene. Scroll to move the camera."></canvas></div><div class="progress" aria-hidden="true"><i id="progress-fill"></i></div><div class="chapter chapter-one" id="chapter-one">@@ -36,7 +41,7 @@<div class="chapter chapter-two" id="chapter-two"><h2>Every frame is real geometry,<br />lit and shadowed in your browser.</h2><div class="lab-actions">- <a class="lab-button is-primary" href="/showcase.html?scene=airport"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3 3 8v9l9 5 9-5V8l-9-5ZM3 8l9 5 9-5M12 13v9"/></svg>Open this scene live<svg class="arrow" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14m-6-6 6 6-6 6"/></svg></a>+ <a class="lab-button is-primary" id="open-scene" href="/showcase.html"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3 3 8v9l9 5 9-5V8l-9-5ZM3 8l9 5 9-5M12 13v9"/></svg>Open this scene live<svg class="arrow" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14m-6-6 6 6-6 6"/></svg></a></div></div><p class="cue rise" style="--i:4" id="cue"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>Scroll</p>diff --git a/hero-lab.html b/hero-lab.htmlindex 8f7c628e..48c0aad3 100644--- a/hero-lab.html+++ b/hero-lab.html@@ -11,7 +11,9 @@<main class="lab-index"><h1>Home hero directions</h1><a href="/hero-a.html"><strong>A · Object</strong><span>One model that follows the pointer.</span></a>- <a href="/hero-b.html"><strong>B · World</strong><span>An airport ramp where scroll moves the camera.</span></a>+ <a href="/hero-b.html?scene=valley"><strong>B · Valley</strong><span>Golden hour over the Silverwater valley, down the river to the footbridge.</span></a>+ <a href="/hero-b.html?scene=ignition"><strong>B · Ignition</strong><span>A quiet night desert tower, then the fireball lights the mountains.</span></a>+ <a href="/hero-b.html?scene=port"><strong>B · Port</strong><span>Dusk over the cranes and ships of a container port.</span></a><a href="/hero-c.html"><strong>C · Type</strong><span>Big type, a small live scene that lights up with the call to action.</span></a></main><script type="module" src="/src/hero-lab/index.js"></script>diff --git a/public/hero-lab/poster-b-ignition-mobile.webp b/public/hero-lab/poster-b-ignition-mobile.webpnew file mode 100644index 00000000..0c8feb43Binary files /dev/null and b/public/hero-lab/poster-b-ignition-mobile.webp differdiff --git a/public/hero-lab/poster-b-ignition.webp b/public/hero-lab/poster-b-ignition.webpnew file mode 100644index 00000000..e6dd056cBinary files /dev/null and b/public/hero-lab/poster-b-ignition.webp differdiff --git a/public/hero-lab/poster-b-port-mobile.webp b/public/hero-lab/poster-b-port-mobile.webpnew file mode 100644index 00000000..ed672c77Binary files /dev/null and b/public/hero-lab/poster-b-port-mobile.webp differdiff --git a/public/hero-lab/poster-b-port.webp b/public/hero-lab/poster-b-port.webpnew file mode 100644index 00000000..461b0b6eBinary files /dev/null and b/public/hero-lab/poster-b-port.webp differdiff --git a/public/hero-lab/poster-b-valley-mobile.webp b/public/hero-lab/poster-b-valley-mobile.webpnew file mode 100644index 00000000..61dff0f9Binary files /dev/null and b/public/hero-lab/poster-b-valley-mobile.webp differdiff --git a/public/hero-lab/poster-b-valley.webp b/public/hero-lab/poster-b-valley.webpnew file mode 100644index 00000000..4fb850f7Binary files /dev/null and b/public/hero-lab/poster-b-valley.webp differdiff --git a/scripts/hero-lab-capture.mjs b/scripts/hero-lab-capture.mjsnew file mode 100644index 00000000..07c0c7b2--- /dev/null+++ b/scripts/hero-lab-capture.mjs@@ -0,0 +1,213 @@+// Captures and measures the home-hero prototypes (hero-b.html?scene=...) in headless Chrome on the GPU.+// node scripts/hero-lab-capture.mjs probe --scene port --cam "x,y,z,tx,ty,tz,fov" --out file.png+// node scripts/hero-lab-capture.mjs stills --scene valley --out dir 1440x900 at start, middle, end, plus 375x812+// node scripts/hero-lab-capture.mjs poster --scene valley --out dir writes public/hero-lab/poster-b-<scene>[-mobile].webp-source PNGs+// node scripts/hero-lab-capture.mjs measure --scene valley --out file.json bytes, first paint, first live frame, frame times+// node scripts/hero-lab-capture.mjs frames --scene valley --out dir a stepped scroll pass as numbered PNGs (encode with ffmpeg)+// stills also takes --steps "0,0.34,0.5" (scroll progress values). Options: --base http://127.0.0.1:5195 --chrome <path> --frames 210 --progress 0.5+import { chromium } from 'playwright';+import fs from 'node:fs';+import path from 'node:path';++const [mode, ...rest] = process.argv.slice(2);+const options = Object.fromEntries(rest.reduce((pairs, token, index) => (token.startsWith('--') ? [...pairs, [token.slice(2), rest[index + 1]]] : pairs), []));+const base = options.base ?? 'http://127.0.0.1:5195';+const scene = options.scene ?? 'valley';+const chromePath = options.chrome ?? 'C:/Program Files/Google/Chrome/Application/chrome.exe';+const GPU_ARGUMENTS = ['--use-angle=d3d11', '--enable-gpu', '--ignore-gpu-blocklist', '--disable-frame-rate-limit', '--disable-gpu-vsync'];++async function openHero(browser, { width, height, reducedMotion = false, record = false }) {+ const context = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: 1, reducedMotion: reducedMotion ? 'reduce' : 'no-preference' });+ const page = await context.newPage();+ page.on('pageerror', error => console.error('pageerror', error.message));+ page.on('console', message => { if (message.type() === 'error') console.error('console', message.text()); });+ return { context, page };+}++async function waitLive(page, { complete = false } = {}) {+ try {+ await page.waitForFunction(() => (window.__heroB && document.querySelector('#stage').dataset.live === 'true') || window.__hero.error, null, { timeout: 120000 });+ } catch (error) {+ console.error('stage never went live', await page.evaluate(() => window.__hero?.error));+ throw error;+ }+ const failure = await page.evaluate(() => window.__hero.error);+ if (failure) throw new Error(failure);+ if (complete && scene === 'port') await page.waitForFunction(() => window.__heroB.scene.state.complete || window.__heroB.scene.state.error, null, { timeout: 180000 });+}++async function scrollTo(page, progress) {+ await page.evaluate(value => {+ const root = document.querySelector('.hero-b');+ window.scrollTo(0, value * (root.offsetHeight - innerHeight));+ }, progress);+ await page.waitForFunction(() => window.__heroB.state.settled, null, { timeout: 20000 });+ await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));+}++async function probe() {+ const browser = await chromium.launch({ executablePath: chromePath, args: GPU_ARGUMENTS });+ const { page } = await openHero(browser, { width: 1440, height: 900 });+ await page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(page, { complete: !options.early });+ // Several cameras can be probed in one load: --cam "x,y,z,tx,ty,tz,fov;x,y,z,tx,ty,tz,fov" writes <out>-<n>.png.+ for (const [index, spec] of options.cam.split(';').entries()) {+ const [x, y, z, tx, ty, tz, fov] = spec.split(',').map(Number);+ await page.evaluate(([eye, target, field]) => { window.__heroB.state.override = { eye, target, fov: field }; window.__heroB.wake(); }, [[x, y, z], [tx, ty, tz], fov]);+ await page.waitForTimeout(500);+ await page.screenshot({ path: `${options.out}-${index}.png` });+ }+ await browser.close();+}++async function stills() {+ fs.mkdirSync(options.out, { recursive: true });+ const browser = await chromium.launch({ executablePath: chromePath, args: GPU_ARGUMENTS });+ const desktop = await openHero(browser, { width: 1440, height: 900 });+ await desktop.page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(desktop.page, { complete: true });+ const names = { 0: 'start', 0.5: 'middle', 1: 'end' };+ for (const progress of (options.steps ?? '0,0.5,1').split(',').map(Number)) {+ const name = names[progress] ?? `p${progress}`;+ await scrollTo(desktop.page, progress);+ await desktop.page.waitForTimeout(700);+ await desktop.page.screenshot({ path: path.join(options.out, `${scene}-${name}-1440.png`) });+ }+ const mobile = await openHero(browser, { width: 375, height: 812 });+ await mobile.page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(mobile.page, { complete: true });+ await mobile.page.waitForTimeout(700);+ await mobile.page.screenshot({ path: path.join(options.out, `${scene}-mobile-375.png`) });+ await browser.close();+}++// Posters are the opening frame without any text: hide the chapters, wait for the live canvas, screenshot the stage.+async function poster() {+ fs.mkdirSync(options.out, { recursive: true });+ const browser = await chromium.launch({ executablePath: chromePath, args: GPU_ARGUMENTS });+ for (const [suffix, width, height] of [['', 1440, 900], ['-mobile', 750, 1334]]) {+ const { page } = await openHero(browser, { width: width / (suffix ? 2 : 1), height: height / (suffix ? 2 : 1) });+ await page.setViewportSize({ width: suffix ? 375 : 1440, height: suffix ? 667 : 900 });+ await page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(page, { complete: true });+ await page.addStyleTag({ content: '.chapter,.cue,.progress,.lab-nav,.stage::after{display:none!important}.poster{display:none!important}' });+ await page.waitForTimeout(800);+ await page.locator('#stage').screenshot({ path: path.join(options.out, `poster-b-${scene}${suffix}.png`) });+ await page.close();+ }+ await browser.close();+}++async function measure() {+ const browser = await chromium.launch({ executablePath: chromePath, args: GPU_ARGUMENTS });+ const { context, page } = await openHero(browser, { width: 1440, height: 900 });+ const client = await context.newCDPSession(page);+ await client.send('Network.enable');+ await client.send('Network.setCacheDisabled', { cacheDisabled: true });+ const sizes = new Map();+ client.on('Network.loadingFinished', event => sizes.set(event.requestId, event.encodedDataLength));+ const urls = new Map();+ client.on('Network.requestWillBeSent', event => urls.set(event.requestId, event.request.url));+ await page.addInitScript(() => {+ window.__paints = [];+ new PerformanceObserver(list => { for (const entry of list.getEntries()) window.__paints.push([entry.name ?? entry.entryType, Math.round(entry.startTime)]); }).observe({ type: 'paint', buffered: true });+ new PerformanceObserver(list => { for (const entry of list.getEntries()) window.__paints.push(['lcp', Math.round(entry.startTime)]); }).observe({ type: 'largest-contentful-paint', buffered: true });+ });+ await page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(page);+ const afterFirstLive = [...sizes.values()].reduce((sum, bytes) => sum + bytes, 0);+ await page.waitForTimeout(500);+ const firstLive = await page.evaluate(() => ({ firstLiveFrameMs: window.__hero.firstLiveFrameMs, stageOneReadyMs: window.__hero.stageOneReadyMs ?? null, paints: window.__paints }));+ await waitLive(page, { complete: true });+ await page.waitForTimeout(1500);+ const total = [...sizes.values()].reduce((sum, bytes) => sum + bytes, 0);+ const completeAt = await page.evaluate(() => Math.round(performance.now()));++ // Method A: GPU readback. Render each scroll position, then read one pixel back so the GPU has finished before the clock stops.+ const readback = await page.evaluate(async frameCount => {+ const { scene: heroScene, canvas } = window.__heroB;+ const context = canvas.getContext('webgl2');+ const pixel = new Uint8Array(4);+ const times = [];+ for (let index = 0; index < frameCount; index++) {+ const started = performance.now();+ heroScene.render(index / (frameCount - 1), index / 60, null);+ context.readPixels(0, 0, 1, 1, context.RGBA, context.UNSIGNED_BYTE, pixel);+ times.push(performance.now() - started);+ await new Promise(resolve => setTimeout(resolve, 0));+ }+ return times;+ }, 400);+ // Method B: real scroll pass with vsync and the frame limit off; interval between animation frames and CPU time inside draw.+ const interval = await page.evaluate(async () => {+ window.__hero.frameIntervals.length = 0;+ window.__hero.renderMilliseconds.length = 0;+ const root = document.querySelector('.hero-b');+ const travel = root.offsetHeight - innerHeight;+ const started = performance.now();+ await new Promise(resolve => {+ const step = now => {+ const amount = Math.min(1, (now - started) / 5000);+ window.scrollTo(0, amount * travel);+ if (amount < 1) requestAnimationFrame(step); else resolve();+ };+ requestAnimationFrame(step);+ });+ return { frameIntervals: [...window.__hero.frameIntervals], renderMilliseconds: [...window.__hero.renderMilliseconds] };+ });+ const quantile = (values, fraction) => { const sorted = [...values].sort((a, b) => a - b); return sorted.length ? Number(sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * fraction))].toFixed(2)) : null; };+ const result = {+ scene,+ transferredBytesAtFirstLiveFrame: afterFirstLive,+ transferredBytesTotal: total,+ firstLiveFrameMs: firstLive.firstLiveFrameMs,+ stageOneReadyMs: firstLive.stageOneReadyMs,+ worldCompleteMs: completeAt,+ paints: firstLive.paints,+ gpuReadbackFrameMs: { median: quantile(readback, 0.5), p95: quantile(readback, 0.95), frames: readback.length },+ scrollPassIntervalMs: { median: quantile(interval.frameIntervals, 0.5), p95: quantile(interval.frameIntervals, 0.95), frames: interval.frameIntervals.length },+ scrollPassDrawCpuMs: { median: quantile(interval.renderMilliseconds, 0.5), p95: quantile(interval.renderMilliseconds, 0.95) },+ biggestFiles: [...sizes.entries()].map(([id, bytes]) => [path.basename(new URL(urls.get(id) ?? 'http://x/?').pathname), bytes]).sort((a, b) => b[1] - a[1]).slice(0, 6),+ };+ fs.writeFileSync(options.out, JSON.stringify(result, null, 2));+ console.log(JSON.stringify(result));+ await browser.close();+}++async function frames() {+ fs.mkdirSync(options.out, { recursive: true });+ const count = Number(options.frames ?? 210);+ const browser = await chromium.launch({ executablePath: chromePath, args: GPU_ARGUMENTS });+ const { page } = await openHero(browser, { width: 1280, height: 720 });+ await page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(page, { complete: true });+ await page.waitForTimeout(600);+ for (let index = 0; index < count; index++) {+ await scrollTo(page, index / (count - 1));+ await page.screenshot({ path: path.join(options.out, `frame-${String(index).padStart(4, '0')}.png`) });+ }+ await browser.close();+}++// Reduced motion: the canvas must hold one framing while scrolling and not animate on its own; the text chapters still swap.+async function reduced() {+ const browser = await chromium.launch({ executablePath: chromePath, args: GPU_ARGUMENTS });+ const { page } = await openHero(browser, { width: 1440, height: 900, reducedMotion: true });+ await page.goto(`${base}/hero-b.html?scene=${scene}`);+ await waitLive(page, { complete: true });+ await page.addStyleTag({ content: '.chapter,.cue,.progress,.lab-nav,.poster{visibility:hidden!important}' });+ const shots = [];+ for (const progress of [0, 0.5, 1]) {+ await scrollTo(page, progress);+ await page.waitForTimeout(600);+ const buffer = await page.locator('#stage').screenshot(options.out ? { path: `${options.out}-${progress}.png` } : {});+ shots.push(buffer.toString('base64'));+ }+ const chapterTwoOpacityAtEnd = await page.evaluate(() => document.querySelector('#chapter-two').style.opacity);+ console.log(JSON.stringify({ scene, canvasIdenticalAcrossScroll: shots[0] === shots[1] && shots[1] === shots[2], firstTwoEqual: shots[0] === shots[1], lastTwoEqual: shots[1] === shots[2], matches: await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches), chapterTwoOpacityAtEnd }));+ await browser.close();+}++const commands = { reduced, probe, stills, poster, measure, frames };+if (!commands[mode]) throw new Error(`Unknown mode ${mode}. Use probe, stills, poster, measure or frames.`);+await commands[mode]();diff --git a/src/hero-lab/camera-spline.js b/src/hero-lab/camera-spline.jsnew file mode 100644index 00000000..1ebbb4bb--- /dev/null+++ b/src/hero-lab/camera-spline.js@@ -0,0 +1,30 @@+// A smooth camera path through keyframes: Catmull-Rom through eye, target and field of view,+// so a scroll pass has no corners at the keys. Keys are { at, eye, target, fov } with `at` rising from 0 to 1.++function catmullRom(before, from, to, after, amount) {+ const squared = amount * amount;+ const cubed = squared * amount;+ return 0.5 * (2 * from + (to - before) * amount + (2 * before - 5 * from + 4 * to - after) * squared + (3 * from - before - 3 * to + after) * cubed);+}++function blendVectors(before, from, to, after, amount) {+ return from.map((value, axis) => catmullRom(before[axis], value, to[axis], after[axis], amount));+}++export function createCameraSpline(keys) {+ return function sample(progress) {+ const bounded = Math.max(0, Math.min(1, progress));+ let index = 0;+ while (index < keys.length - 2 && bounded > keys[index + 1].at) index++;+ const from = keys[index];+ const to = keys[index + 1];+ const before = keys[Math.max(0, index - 1)];+ const after = keys[Math.min(keys.length - 1, index + 2)];+ const amount = Math.max(0, Math.min(1, (bounded - from.at) / (to.at - from.at)));+ return {+ eye: blendVectors(before.eye, from.eye, to.eye, after.eye, amount),+ target: blendVectors(before.target, from.target, to.target, after.target, amount),+ fov: catmullRom(before.fov, from.fov, to.fov, after.fov, amount),+ };+ };+}diff --git a/src/hero-lab/hero-b.js b/src/hero-lab/hero-b.jsindex 3544861b..1bbfa023 100644--- a/src/hero-lab/hero-b.js+++ b/src/hero-lab/hero-b.js@@ -1,12 +1,16 @@-// Direction B: a world. Scroll position scrubs a camera path around the airport ramp.-// Only the first part of the showcase world loads (ground and hero aircraft) with the small preview sky, about 2.2 MB.+// Direction B: a world. Scroll position scrubs a camera through a live 67js scene while the text chapters swap.+// Three candidate scenes, picked with ?scene=valley | ignition | port (default valley). Each lives in ./scenes and loads on its own.import './lab.css';-import { Renderer67 } from '../renderer.js';-import { loadGltf } from '../gltf.js';-import { loadHdri } from '../hdri.js';-import { createCascadedShadows } from '../cascaded-shadows.js';import { clamp, damp, prefersReducedMotion, showStageError, smoothstep, startLoop } from './stage.js';+const SCENES = {+ valley: () => import('./scenes/valley.js'),+ ignition: () => import('./scenes/ignition.js'),+ port: () => import('./scenes/port.js'),+};+const requested = new URLSearchParams(location.search).get('scene');+const sceneId = Object.hasOwn(SCENES, requested) ? requested : 'valley';+const stage = document.querySelector('#stage');const canvas = document.querySelector('#viewport');const root = document.querySelector('.hero-b');@@ -14,79 +18,56 @@ const chapterOne = document.querySelector('#chapter-one');const chapterTwo = document.querySelector('#chapter-two');const cue = document.querySelector('#cue');const progressFill = document.querySelector('#progress-fill');+const openLink = document.querySelector('#open-scene');-// Camera path: [eye, target, field of view]. Linear blend between keys, eased by the page's own scroll.-const KEYS = [- { at: 0, eye: [138, 64, 36], target: [1, 3, -13], fov: 20 },- { at: 0.55, eye: [74, 26, 62], target: [-4, 6, -14], fov: 26 },- { at: 1, eye: [-30, 14, 70], target: [-12, 8, -14], fov: 34 },-];-const SCRUB_RATE = prefersReducedMotion ? 30 : 7;--function lerp(first, second, amount) {- return first + (second - first) * amount;-}--function pathAt(progress) {- let index = 0;- while (index < KEYS.length - 2 && progress > KEYS[index + 1].at) index++;- const from = KEYS[index];- const to = KEYS[index + 1];- const amount = smoothstep(0, 1, clamp((progress - from.at) / (to.at - from.at), 0, 1));- return {- eye: from.eye.map((value, axis) => lerp(value, to.eye[axis], amount)),- target: from.target.map((value, axis) => lerp(value, to.target[axis], amount)),- fov: lerp(from.fov, to.fov, amount),- };-}+const SCRUB_RATE = 7;+// Reduced motion freezes scene time at one fixed moment.+const STILL_TIME = 1;+root.dataset.scene = sceneId;function scrollProgress() {const travel = root.offsetHeight - innerHeight;return clamp(-root.getBoundingClientRect().top / travel, 0, 1);}-// Chapter copy is driven by the same progress value as the camera, using transform and opacity only.+// Chapter copy is driven by the scroll progress, using transform and opacity only. Reduced motion keeps the fades and drops the travel.function paintChapters(progress) {+ const travel = prefersReducedMotion ? 0 : 1;const leaving = smoothstep(0.12, 0.38, progress);chapterOne.style.opacity = String(1 - leaving);- chapterOne.style.transform = `translateY(${-28 * leaving}px)`;+ chapterOne.style.transform = `translateY(${-28 * leaving * travel}px)`;chapterOne.style.pointerEvents = leaving > 0.5 ? 'none' : '';const arriving = smoothstep(0.62, 0.9, progress);chapterTwo.style.opacity = String(arriving);- chapterTwo.style.transform = `translateY(${24 * (1 - arriving)}px)`;+ chapterTwo.style.transform = `translateY(${24 * (1 - arriving) * travel}px)`;cue.style.opacity = String(1 - smoothstep(0.02, 0.12, progress));progressFill.style.transform = `scaleY(${progress})`;}async function start() {- const description = await (await fetch('/showcase/airport/scene.json')).json();- const [asset, sky] = await Promise.all([- loadGltf(description.glb, description.gltfOptions),- loadHdri(description.hdriPreview, description.hdriOptions),- ]);- const options = description.renderer;- const renderer = new Renderer67(canvas, asset.parts, {- ...options,- pixelRatio: Math.min(devicePixelRatio, 1.25),- memoryBudgetMiB: 384,- shadowCascades: createCascadedShadows(options.shadowCascades),- environment: { ...options.environment, map: sky },- });+ const { createScene } = await SCENES[sceneId]();+ const scene = await createScene(canvas);+ // A scene may hold the poster until it is whole (the port waits for every part so no frame shows an unfinished world).+ await scene.ready;+ openLink.href = scene.openHref;+ canvas.setAttribute('aria-label', `A live 3D scene: ${scene.label}. Scroll to move the camera.`);- const state = { progress: scrollProgress(), aim: scrollProgress() };- const loop = startLoop(stage, seconds => {+ const state = { progress: scrollProgress(), aim: scrollProgress(), settled: false, override: null };+ // With reduced motion the camera holds one chosen framing; scrolling only swaps the text.+ const cameraProgress = () => (prefersReducedMotion ? scene.staticProgress : state.progress);+ const loop = startLoop(stage, (seconds, timestamp) => {state.aim = scrollProgress();- state.progress = damp(state.progress, state.aim, SCRUB_RATE, seconds);- const settled = Math.abs(state.progress - state.aim) < 0.0004;- if (settled) state.progress = state.aim;- const camera = pathAt(state.progress);- renderer.render({ ...description.frame, eye: camera.eye, target: camera.target, fov: camera.fov });+ state.progress = state.instant ? state.aim : damp(state.progress, state.aim, SCRUB_RATE, seconds);+ state.settled = Math.abs(state.progress - state.aim) < 0.0004;+ if (state.settled) state.progress = state.aim;+ const sceneTime = prefersReducedMotion ? STILL_TIME : timestamp / 1000;+ scene.render(cameraProgress(), sceneTime, state.override);paintChapters(state.progress);- return !settled;+ return !state.settled || (scene.ambient && !prefersReducedMotion);});window.addEventListener('scroll', loop.wake, { passive: true });- window.addEventListener('resize', loop.wake);- window.__heroState = { state, renderer };+ window.addEventListener('resize', () => { scene.resize?.(); loop.wake(); });+ window.__heroB = { sceneId, state, scene, wake: loop.wake, canvas };}paintChapters(scrollProgress());diff --git a/src/hero-lab/lab.css b/src/hero-lab/lab.cssindex 0e3930f7..89de9f0f 100644--- a/src/hero-lab/lab.css+++ b/src/hero-lab/lab.css@@ -87,7 +87,9 @@ h1 { margin: 0; font-weight: 640; letter-spacing: -0.04em; line-height: 0.98; te/* ---------- Direction B: a world, the scroll moves the camera ---------- */.hero-b { position: relative; height: 260svh; }.hero-b .pin { position: sticky; top: 0; height: 100svh; overflow: hidden; }-.hero-b .stage::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(to top, rgb(9 7 15 / 0.82) 0%, transparent 52%); }+.hero-b .stage::after { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(to top, rgb(9 7 15 / 0.72) 0%, transparent 46%), radial-gradient(75% 65% at 0% 100%, rgb(9 7 15 / 0.5), transparent 72%); }+/* The port is busy behind the words (crane legs, hull lettering), so it gets a stronger scrim from the left edge. */+.hero-b[data-scene='port'] .stage::after { background: linear-gradient(to top, rgb(9 7 15 / 0.78) 0%, transparent 52%), linear-gradient(to right, rgb(9 7 15 / 0.72) 0%, rgb(9 7 15 / 0.35) 38%, transparent 66%); }.hero-b .chapter { position: absolute; z-index: 3; left: clamp(16px, 6vw, 96px); bottom: clamp(32px, 9svh, 96px); max-width: 640px; display: flex; flex-direction: column; gap: 22px; will-change: transform, opacity; }.hero-b h1 { font-size: clamp(42px, 6vw, 88px); }.hero-b .chapter-two { pointer-events: none; opacity: 0; }diff --git a/src/hero-lab/scenes/ignition.js b/src/hero-lab/scenes/ignition.jsnew file mode 100644index 00000000..9a84b6a3--- /dev/null+++ b/src/hero-lab/scenes/ignition.js@@ -0,0 +1,94 @@+// Scene 2: a night desert test. The camera creeps in on a quiet tower under the stars, the sky flashes, a fireball climbs+// and the mountain ring lights up. Procedural, nothing to download. The fireball is the renderer's volumetric post pass.+import '../../world-material-shader.js';+import '../../explosion-shader.js';+import { Renderer67 } from '../../renderer.js';+import { createCameraSpline } from '../camera-spline.js';+import { createTestSiteParts } from '../test-site.js';++const NIGHT = {+ fogColor: [0.012, 0.02, 0.032],+ fogDensity: 0.005,+ skyTop: [0.05, 0.09, 0.15],+ skyBottom: [0.2, 0.26, 0.35],+ lightDirection: [-0.5, 0.6, 0.5],+ daylight: 0.32,+};+const BLAST_LIT = {+ fogColor: [0.34, 0.15, 0.06],+ fogDensity: 0.0045,+ skyTop: [0.18, 0.1, 0.1],+ skyBottom: [0.9, 0.42, 0.14],+ lightDirection: [-0.3, 0.55, 0.25],+ daylight: 0.95,+};+const SHADOWS = { extent: 55, target: [0, 6, 0], eye: [-35, 45, 35], near: 1, far: 140 };+const IGNITION_START = 0.5;+const IGNITION_END = 0.8;++// The tower sits right of centre so the headline has open sky and desert to its left; the camera then backs away to take in the whole fireball.+const cameraAt = createCameraSpline([+ { at: 0, eye: [20, 4, 30], target: [-7, 9, 0], fov: 38 },+ { at: 0.34, eye: [14, 3, 22], target: [-4, 10, 0], fov: 40 },+ { at: 0.5, eye: [15, 3.5, 23], target: [-4.5, 10, 0], fov: 42 },+ { at: 0.8, eye: [30, 8, 42], target: [-10, 14, 0], fov: 48 },+ { at: 1, eye: [40, 10, 56], target: [-12, 15, 0], fov: 50 },+]);++function smoothstep(start, end, value) {+ const amount = Math.max(0, Math.min(1, (value - start) / (end - start)));+ return amount * amount * (3 - 2 * amount);+}++function blend(from, to, amount) {+ return from.map((value, axis) => value + (to[axis] - value) * amount);+}++function environmentAt(lit) {+ return {+ fogColor: blend(NIGHT.fogColor, BLAST_LIT.fogColor, lit),+ fogDensity: NIGHT.fogDensity + (BLAST_LIT.fogDensity - NIGHT.fogDensity) * lit,+ skyTop: blend(NIGHT.skyTop, BLAST_LIT.skyTop, lit),+ skyBottom: blend(NIGHT.skyBottom, BLAST_LIT.skyBottom, lit),+ lightDirection: blend(NIGHT.lightDirection, BLAST_LIT.lightDirection, lit),+ daylight: NIGHT.daylight + (BLAST_LIT.daylight - NIGHT.daylight) * lit,+ };+}++export async function createScene(canvas) {+ const parts = createTestSiteParts();+ const renderer = new Renderer67(canvas, parts, {+ world: true,+ ground: false,+ hdr: true,+ depth: true,+ environment: environmentAt(0),+ shadowBounds: SHADOWS,+ pixelRatio: Math.min(devicePixelRatio, 1.25),+ memoryBudgetMiB: 256,+ samples: 4,+ });+ return {+ label: 'A night desert test site, the tower, then the ignition',+ openHref: '/film.html',+ ambient: false,+ staticProgress: 0.58,+ render(progress, seconds, override) {+ const fire = smoothstep(IGNITION_START, IGNITION_END, progress);+ const lit = smoothstep(IGNITION_START, IGNITION_START + 0.1, progress);+ const flash = progress >= IGNITION_START ? Math.exp(-(progress - IGNITION_START) * 30) : 0;+ renderer.render({+ ...(override ?? cameraAt(progress)),+ time: seconds + progress * 12,+ exposure: 0.95 + flash * 1.4,+ cinematic: true,+ volumeExplosion: fire > 0.001,+ explosionProgress: fire,+ environment: environmentAt(lit),+ effects: { bloom: { strength: 0.18 + flash * 0.3 }, saturation: 0.82, contrast: 1.12, temperature: 0.03, vignette: 0.14, grain: 0.014 },+ });+ },+ resize: () => renderer.resize(),+ dispose: () => renderer.dispose(),+ };+}diff --git a/src/hero-lab/scenes/port.js b/src/hero-lab/scenes/port.jsnew file mode 100644index 00000000..d211c133--- /dev/null+++ b/src/hero-lab/scenes/port.js@@ -0,0 +1,93 @@+// Scene 3: the container port at dusk. Staged like the showcase page: the first part of the world and a small sky draw the+// opening frame, the other parts stream in behind it and are swapped in whole, then the full sky replaces the small one.+import { Renderer67 } from '../../renderer.js';+import { createSharedTextures, loadGltf } from '../../gltf.js';+import { loadHdri } from '../../hdri.js';+import { createCascadedShadows } from '../../cascaded-shadows.js';+import { applyWaterReflection, attachWaterReflection } from '../../water-reflection.js';+import { readPartRanks } from '../../showcase-download.js';+import { createCameraSpline } from '../camera-spline.js';++const SCENE_URL = '/showcase/port/scene.json';++// A slow arc around the berth from the sea side: high over the ship and cranes, past the crane legs, then low along the quay road into the low sun.+const cameraAt = createCameraSpline([+ { at: 0, eye: [-20, 130, -300], target: [0, -10, 10], fov: 38 },+ { at: 0.35, eye: [-150, 60, -150], target: [0, 20, 20], fov: 40 },+ { at: 0.68, eye: [30, 34, -170], target: [20, 26, 10], fov: 42 },+ { at: 1, eye: [205, 24, -62], target: [0, 22, 0], fov: 45 },+]);++async function fetchBlob(url) {+ const response = await fetch(url);+ if (!response.ok) throw new Error(`${url} is not available (${response.status})`);+ return response.blob();+}++function inWholeWorldOrder(files) {+ if (files.some(file => !file.ranks || file.ranks.length !== file.parts.length)) return files.flatMap(file => file.parts);+ const ranked = files.flatMap(file => file.parts.map((part, index) => ({ part, rank: file.ranks[index] })));+ return ranked.sort((first, second) => first.rank - second.rank).map(entry => entry.part);+}++export async function createScene(canvas) {+ const description = await (await fetch(SCENE_URL)).json();+ const baseUrl = new URL('.', new URL(description.glb, location.href)).href;+ const restDownloads = Promise.all((description.glbRest ?? []).map(path => fetchBlob(path)));+ restDownloads.catch(() => {});+ const fullSkyDownload = fetchBlob(description.hdri);+ fullSkyDownload.catch(() => {});+ const [model, previewSky] = await Promise.all([fetchBlob(description.glb), loadHdri(description.hdriPreview, description.hdriOptions)]);+ const sharedTextures = createSharedTextures();+ const asset = await loadGltf(model, { baseUrl, sharedTextures, ...description.gltfOptions });+ const options = description.renderer;+ const reflection = description.waterReflection ? applyWaterReflection(asset.parts) : { parts: asset.parts, surface: null };+ const renderer = new Renderer67(canvas, reflection.parts, {+ ...options,+ pixelRatio: Math.min(devicePixelRatio, 1.25),+ memoryBudgetMiB: 512,+ shadowCascades: createCascadedShadows(options.shadowCascades),+ environment: { ...options.environment, map: previewSky },+ });+ window.__hero.stageOneReadyMs = Math.round(performance.now());+ let detachReflection = attachWaterReflection(renderer, reflection.surface);+ const frame = { ...description.frame, exposure: description.exposure ?? 1 };+ const state = { complete: false, frame };++ async function finishWorld() {+ const blobs = await restDownloads;+ const files = [{ parts: asset.parts, ranks: await readPartRanks(model) }];+ for (const [index, blob] of blobs.entries()) {+ const restBase = new URL('.', new URL(description.glbRest[index], location.href)).href;+ const remaining = await loadGltf(blob, { baseUrl: restBase, sharedTextures, ...description.gltfOptions });+ files.push({ parts: remaining.parts, ranks: await readPartRanks(blob) });+ }+ await import('../../replace-textured-parts.js');+ const allParts = inWholeWorldOrder(files);+ const whole = description.waterReflection ? applyWaterReflection(allParts) : { parts: allParts, surface: null };+ renderer.replaceParts(whole.parts);+ detachReflection();+ detachReflection = attachWaterReflection(renderer, whole.surface);+ const fullSky = await loadHdri(description.hdri, { ...description.hdriOptions, fetchImplementation: async () => new Response(await fullSkyDownload) });+ state.frame = { ...frame, environment: { map: fullSky } };+ state.complete = true;+ window.dispatchEvent(new Event('hero-scene-complete'));+ }+ const completion = finishWorld().catch(error => { state.error = error; });++ return {+ label: 'A container port at dusk',+ openHref: '/showcase.html?scene=port',+ ambient: false,+ staticProgress: 0.3,+ state,+ completion,+ // The poster stays up until the whole world is in: the first stage alone is a bare hull on open water.+ ready: completion,+ render(progress, seconds, override) {+ renderer.render({ ...state.frame, ...(override ?? cameraAt(progress)), time: seconds });+ },+ resize: () => renderer.resize(),+ dispose: () => renderer.dispose(),+ };+}diff --git a/src/hero-lab/scenes/valley.js b/src/hero-lab/scenes/valley.jsnew file mode 100644index 00000000..2569c4cd--- /dev/null+++ b/src/hero-lab/scenes/valley.js@@ -0,0 +1,60 @@+// Scene 1: the Silverwater valley at golden hour. Procedural, nothing to download.+// The camera starts high above the southern ridge line, looking along the valley at the snowfields, and glides north down the river to the footbridge.+import { mat4, quat } from 'gl-matrix';+import { Renderer67 } from '../../renderer.js';+import { createNatureWorld } from '../../nature.js';+import { box } from '../../geometry.js';+import { createCameraSpline } from '../camera-spline.js';++const GOLDEN = {+ daylight: 0.62,+ fogColor: [0.55, 0.36, 0.26],+ fogDensity: 0.0032,+ skyTop: [0.22, 0.32, 0.55],+ skyBottom: [1.0, 0.62, 0.36],+ lightDirection: [-0.78, 0.22, 0.42],+};++const cameraAt = createCameraSpline([+ { at: 0, eye: [16, 58, 52], target: [-4, 9, -80], fov: 36 },+ { at: 0.42, eye: [16, 17, 30], target: [-3, 5, -22], fov: 40 },+ { at: 0.78, eye: [5, 6.5, 16], target: [-3, 2.4, -6], fov: 40 },+ { at: 1, eye: [6.5, 3.4, 12], target: [-4.5, 1.8, -2], fov: 38 },+]);++export async function createScene(canvas) {+ const world = createNatureWorld();+ // The valley floor ends at a fixed edge; this meadow apron under it runs out to the haze so no view ends in an empty strip below the sky.+ const valleyFloor = world.parts.find(part => part.name === 'Wildflower valley');+ const apronMatrix = mat4.fromRotationTranslationScale(mat4.create(), quat.create(), [0, -1.25, -20], [1400, 1, 1200]);+ const apron = { name: 'Meadow apron', geometry: box(0.045, 2), matrix: apronMatrix, material: valleyFloor.material };+ const parts = [...world.parts, apron];+ const renderer = new Renderer67(canvas, parts, {+ world: true,+ ground: false,+ hdr: true,+ environment: { ...world.environment, ...GOLDEN },+ pixelRatio: Math.min(devicePixelRatio, 1.25),+ memoryBudgetMiB: 256,+ samples: 4,+ });+ return {+ label: 'Silverwater valley at golden hour',+ openHref: '/nature.html',+ ambient: true,+ staticProgress: 0.3,+ render(progress, seconds, override) {+ renderer.render({+ ...(override ?? cameraAt(progress)),+ time: seconds,+ wind: 0.35,+ waterRipple: [10000, 0, 10000],+ rippleTime: -1000,+ environment: { ...world.environment, ...GOLDEN },+ effects: { saturation: 1.1, contrast: 1.06, temperature: 0.06, vignette: 0.12, bloom: { strength: 0.16, threshold: 1.1, radius: 1.3 } },+ });+ },+ resize: () => renderer.resize(),+ dispose: () => renderer.dispose(),+ };+}diff --git a/src/hero-lab/test-site.js b/src/hero-lab/test-site.jsnew file mode 100644index 00000000..64e88dfb--- /dev/null+++ b/src/hero-lab/test-site.js@@ -0,0 +1,124 @@+// A night desert test site: flat alluvial plain, ring of mountains, a steel tower with a suspended vessel and amber signal lamps.+// The geometry follows the film's desert set, rebuilt here so the hero does not pull the whole film module (rig, recordings, characters) into its bundle.+import { mat4, quat, vec3 } from 'gl-matrix';+import { cylinder, sphere, torus } from '../geometry.js';++const FULL_TURN = Math.PI * 2;+const HALF_PI = Math.PI / 2;++const MATERIALS = {+ terrain: { tag: 'terrain', color: [0.38, 0.255, 0.12], metallic: 0, roughness: 0.94, emission: 0 },+ rock: { tag: 'terrain', color: [0.24, 0.19, 0.14], metallic: 0, roughness: 0.95, emission: 0 },+ mountain: { tag: 'terrain', color: [0.18, 0.2, 0.19], metallic: 0, roughness: 0.95, emission: 0 },+ sage: { tag: 'terrain', color: [0.115, 0.125, 0.068], metallic: 0, roughness: 1, emission: 0 },+ steel: { tag: 'steel', color: [0.35, 0.39, 0.42], metallic: 0.94, roughness: 0.25, emission: 0 },+ graphite: { tag: 'graphite', color: [0.035, 0.043, 0.05], metallic: 0.7, roughness: 0.34, emission: 0 },+ amber: { tag: 'indicator', color: [1, 0.34, 0.035], metallic: 0.1, roughness: 0.3, emission: 4 },+ lamp: { tag: 'window', color: [0.51, 0.57, 0.51], metallic: 0, roughness: 0.8, emission: 1.8 },+};++function sampledSurface(columns, rows, sample) {+ const positions = [];+ const normals = [];+ const indices = [];+ const epsilon = 0.0001;+ for (let row = 0; row <= rows; row++) {+ for (let column = 0; column <= columns; column++) {+ const horizontal = column / columns;+ const vertical = row / rows;+ const tangent = vec3.subtract(vec3.create(), sample(horizontal + epsilon, vertical), sample(horizontal - epsilon, vertical));+ const bitangent = vec3.subtract(vec3.create(), sample(horizontal, vertical + epsilon), sample(horizontal, vertical - epsilon));+ positions.push(...sample(horizontal, vertical));+ normals.push(...vec3.normalize(vec3.create(), vec3.cross(vec3.create(), tangent, bitangent)));+ }+ }+ for (let row = 0; row < rows; row++) {+ for (let column = 0; column < columns; column++) {+ const first = row * (columns + 1) + column;+ const below = first + columns + 1;+ indices.push(first, first + 1, below, first + 1, below + 1, below);+ }+ }+ return { positions: new Float32Array(positions), normals: new Float32Array(normals), indices: new Uint32Array(indices) };+}++function desertHeight(horizontal, depth) {+ const flats = Math.min(1, Math.hypot(horizontal, depth) / 24);+ return -0.12 + flats * (Math.sin(horizontal * 0.071 + depth * 0.041) * 0.35 + Math.sin(depth * 0.17 - horizontal * 0.11) * 0.12 + Math.sin(horizontal * 0.91) * Math.cos(depth * 0.83) * 0.035);+}++function ridgeHeightAt(angle, vertical) {+ const peaks = 7 + 8 * Math.abs(Math.sin(angle * 3.1 + 0.4)) + 4 * Math.abs(Math.sin(angle * 11.5)) + 1.7 * Math.sin(angle * 47) + 0.8 * Math.cos(angle * 83);+ return -1 + Math.max(0, 1 - Math.abs(vertical * 2 - 1)) ** 0.63 * peaks + Math.sin(vertical * 33 + angle * 51) * Math.sin(vertical * Math.PI) * 0.8;+}++export function createTestSiteParts() {+ const meshes = {+ landscape: sampledSurface(140, 140, (horizontal, vertical) => {+ const x = (horizontal - 0.5) * 400;+ const z = (0.5 - vertical) * 400;+ return [x, desertHeight(x, z), z];+ }),+ ridge: sampledSurface(180, 20, (horizontal, vertical) => {+ const angle = horizontal * FULL_TURN;+ const radius = 145 + vertical * 72;+ return [Math.cos(angle) * radius, ridgeHeightAt(angle, vertical), Math.sin(angle) * radius];+ }),+ cylinder: cylinder(16, 0.02, 2),+ sphere: sphere(32, 20),+ rock: sphere(12, 8),+ ring: torus(0.055, 64, 8),+ };+ const parts = [];++ function add(name, mesh, position, scale, material, rotation = [0, 0, 0]) {+ const orientation = quat.fromEuler(quat.create(), ...rotation.map(angle => angle * 180 / Math.PI));+ parts.push({ name, geometry: meshes[mesh], matrix: mat4.fromRotationTranslationScale(mat4.create(), orientation, position, scale), material });+ }++ function beam(name, start, end, radius, material = MATERIALS.steel) {+ const difference = vec3.subtract(vec3.create(), end, start);+ const length = vec3.length(difference);+ const orientation = quat.rotationTo(quat.create(), [0, 1, 0], vec3.scale(vec3.create(), difference, 1 / length));+ const center = start.map((value, axis) => (value + end[axis]) / 2);+ parts.push({ name, geometry: meshes.cylinder, matrix: mat4.fromRotationTranslationScale(mat4.create(), orientation, center, [radius, length, radius]), material });+ }++ add('Alluvial plain', 'landscape', [0, 0, 0], [1, 1, 1], MATERIALS.terrain);+ add('Mountain ring', 'ridge', [0, 0, 0], [0.85, 2.4, 0.85], MATERIALS.rock);+ add('Distant mountain ring', 'ridge', [0, 1, 0], [1.15, 2.1, 1.15], MATERIALS.mountain, [0, 0.12, 0]);+ for (let index = 0; index < 180; index++) {+ const angle = index * 2.399963;+ const radius = 3 + (index / 180) ** 0.7 * 93;+ const horizontal = Math.cos(angle) * radius;+ const depth = Math.sin(angle) * radius;+ const ground = desertHeight(horizontal, depth);+ const size = 0.12 + index % 7 * 0.07;+ add('Weathered shale', 'rock', [horizontal, ground, depth], [size * 2, size * 0.4, size], MATERIALS.rock, [0.2, angle, 0.1]);+ for (let stem = 0; stem < 3; stem++) {+ const lean = angle + stem * 2.1;+ beam('Sagebrush stem', [horizontal + 0.8, ground, depth], [horizontal + 0.8 + Math.cos(lean) * size, ground + size * (0.5 + stem * 0.15), depth + Math.sin(lean) * size], 0.0045, MATERIALS.sage);+ }+ }+ for (const horizontal of [-1.3, 1.3]) {+ for (const depth of [-1.3, 1.3]) {+ beam('Tower leg', [horizontal * 1.5, 0, depth * 1.5], [horizontal, 10, depth], 0.065);+ for (let level = 0; level < 5; level++) {+ beam('Tower diagonal brace', [horizontal, level * 2, depth], [-horizontal, level * 2 + 2, depth], 0.035);+ beam('Tower transverse brace', [horizontal, level * 2, depth], [horizontal, level * 2 + 2, -depth], 0.035);+ }+ }+ }+ add('Tower platform', 'cylinder', [0, 10, 0], [2.3, 0.09, 2.3], MATERIALS.steel);+ add('Suspended vessel', 'sphere', [0, 11, 0], [0.85, 0.95, 0.85], MATERIALS.graphite);+ add('Vessel seam', 'ring', [0, 11, 0], [0.87, 0.87, 0.87], MATERIALS.steel, [HALF_PI, 0, 0]);+ for (let index = 0; index < 10; index++) add('Ladder rung', 'cylinder', [1.5, 0.5 + index, 1.4], [0.027, 0.7, 0.027], MATERIALS.steel, [0, 0, HALF_PI]);+ for (let index = 0; index < 19; index++) add('Signal lamp', 'sphere', [1.8, 0.07, 3 + index * 3.4], [0.055, 0.035, 0.055], MATERIALS.amber);+ for (const side of [-1, 1]) {+ add('Tower work lamp', 'sphere', [side * 1.15, 10.25, 0.95], [0.055, 0.08, 0.055], MATERIALS.lamp);+ beam('Hoist upright', [side * 1.3, 10, -0.5], [side * 1.3, 14.6, -0.5], 0.045);+ beam('Guy wire', [side * 1.3, 9.6, 0], [side * 17, 0, 9], 0.012, MATERIALS.graphite);+ }+ beam('Hoist lintel', [-1.3, 14.6, -0.5], [1.3, 14.6, -0.5], 0.045);+ return parts;+}diff --git a/vite.hero-lab.config.js b/vite.hero-lab.config.jsnew file mode 100644index 00000000..e42c1d08--- /dev/null+++ b/vite.hero-lab.config.js@@ -0,0 +1,12 @@+import { defineConfig } from 'vite';++// Builds only the hero prototype page so its bundle bytes can be measured as shipped (minified, split by scene):+// npx vite build --config vite.hero-lab.config.js && npx vite preview --config vite.hero-lab.config.js --port 5196+export default defineConfig({+ build: {+ outDir: 'artifacts/hero-lab-dist',+ emptyOutDir: true,+ rolldownOptions: { input: { heroB: 'hero-b.html' } },+ },+ preview: { host: '127.0.0.1' },+});