3D engine that AI agents drive
Smooth WALL-E assembly and motion, stabilize film seeking, rebuild trailer
Nguyen Xuan An8aed7120f1d5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d5e88904..ba44be1b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,15 @@# Changelog+## 0.3.3++- Smooth WALL·E assembly changes when visitors tap or drag the slider+- Pause driving during assembly changes and gradually resume after complete reassembly+- Add head tracking, articulated arms and claws, suspension and continuous forward caterpillar movement+- Keep the camera and shadows aligned with the moving robot+- Prevent trailer playback and delayed audio seeks from overriding timeline input+- Rebuild the trailer with detailed machinery, silhouettes, moving vehicles and practical lighting+- Add filtered terrain grain and surface relief without additional textures+## 0.3.2- Add transparent render targets with MSAA coverage and continuous homepage animation.diff --git a/README.md b/README.mdindex 4ca53180..9271c1eb 100644--- a/README.md+++ b/README.md@@ -38,6 +38,9 @@ The studio submits eight geometry draws, including the floor.Its slider separates all 574 components, including individual fasteners, tread shoes, gears and electronics, to expose batteries, circuit boards, motors, gears and optical mechanisms.The layer controls show the shell, the interior or both. GLB export preserves the selected layers, finish and explosion amount.+The homepage character rolls forward, looks around and moves its arms and claws.+Its assembly slider approaches each selected position smoothly, pauses driving and resumes gradually after complete reassembly.+The renderer uses sampled fillets, GGX lighting, shadows, explicit MSAA, FXAA, specular filtering and ACES tone mapping.It reuses geometry buffers during explosion and refreshes shadows without allocating another shadow texture.The studio renders on demand. Continuous animation pauses in hidden tabs.@@ -91,7 +94,7 @@ npm run render -- --kind video --scene assets --asset model.glb --duration 2 --oVideo exports default to JPEG capture at quality 95 and automatically use NVENC when its preflight succeeds, with a CPU encoder fallback. `--backend cpu` defaults to CPU encoding as well. Use `--capture png` for lossless frame capture or `--jpeg-quality 100` for a higher JPEG quality. H.264 delivery remains compressed in either mode.-Progress reports frames per second, speed relative to playback and estimated remaining time. The JSON sidecar separates rendering, capture, encoder backpressure and encoder finalization, alongside peak memory. Capture keeps one pending frame; the encoder applies backpressure rather than buffering a film in memory.+Progress reports frames per second, speed relative to playback and estimated remaining time. The JSON sidecar separates rendering, capture, encoder backpressure and encoder finalization, alongside peak memory. Capture keeps one pending frame. The encoder applies backpressure rather than buffering a film in memory.| Preset | Dimensions | MSAA samples | FPS | Target budget || --- | --- | ---: | ---: | ---: |diff --git a/docs/film-storyboard.md b/docs/film-storyboard.mdindex 29efd364..ce9039b1 100644--- a/docs/film-storyboard.md+++ b/docs/film-storyboard.md@@ -1,49 +1,96 @@-# Oppenheimer — a 67.js trailer study+# Oppenheimer: a 67.js trailer study-A 187-second procedural 3D reconstruction study inspired by [Universal Pictures’ Oppenheimer New Trailer](https://www.youtube.com/watch?v=uYPbbksJxIg). The sets, stylized figures and synthesized score are authored for 67.js. No source footage, dialogue or soundtrack is included. This is an unofficial study, not a photorealistic reproduction.+This 187-second procedural reconstruction follows the visual structure of [Universal Pictures’ Oppenheimer New Trailer](https://www.youtube.com/watch?v=uYPbbksJxIg).+The study uses 33 authored cuts across 13 sets, rendered through the actual 67.js WebGL engine.+All geometry, camera moves and motion come from the scene code.+The output contains no source footage, dialogue or soundtrack.++## Visual direction++The visual language combines dark mechanical closeups, window silhouettes, desert scale and a final night test.+Figures use continuous head and coat meshes with adult proportions, presented as graphic silhouettes.+They do not reproduce the actors’ faces.+The terrain has a contoured surface, broken mountain ridges, scattered shale and dry sage stems.+The shared terrain shader adds restrained surface detail.++The Gadget uses curved individual leads, connector sockets, labels, bolts and a moving suspension assembly.+The laboratory uses narrow valve filaments and grid hoops instead of glowing solid tubes.+The jeep has separate tires, hubs, fasteners, fenders, seats and a steering assembly.+Night work lights keep the tower readable before the detonation.## Shot timeline-| Seconds | Set |-| --- | --- |-| 0–7 | `apparatus` |-| 7–13 | `control` |-| 13–20 | `apparatus` |-| 20–29 | `office` |-| 29–34 | `sparks` |-| 34–39 | `laboratory` |-| 39–45 | `desert` |-| 45–56 | `settlement` |-| 56–64 | `settlement` |-| 64–73 | `settlement` |-| 73–85 | `office` |-| 85–91 | `waves` |-| 91–98 | `atom` |-| 98–105 | `gadget` |-| 105–110 | `office` |-| 110–118 | `desert` |-| 118–126 | `gadget` |-| 126–133 | `laboratory` |-| 133–140 | `control` |-| 140–145 | `desert` |-| 145–154 | `portrait` |-| 154–161 | `night` |-| 161–165 | `portrait` |-| 165–168 | `control` |-| 168–170 | `gadget` |-| 170–172 | `sparks` |-| 172–174 | `night` |-| 174–176 | `office` |-| 176–178 | `control` |-| 178–179.5 | `sparks` |-| 179.5–181 | `night` |-| 181–184 | `ignition` |-| 184–187 | `ignition` |--## Playback and rendering--`FILM_DURATION` is 187. `FILM_SHOTS` lists 33 cuts; `createFilmScenes()` constructs 13 sets once. `sampleFilm(seconds)` is deterministic, rejects non-finite values and clamps to the timeline. It returns camera, scene, sceneTime, grading, fade, flash, explosion progress and title fields.--Only the active set owns GPU resources; the player disposes it before uploading a different set. Sets share mesh identities for instancing. Cameras interpolate within shots; cuts are intentional. Ignition begins at 181 seconds, followed by the title and a fade to black at 187 seconds.--The film uses HDR with 4× MSAA when supported. Export uses one pending frame, FFmpeg backpressure and explicit renderer, browser heap and Node memory guards. Video capture uses JPEG at quality 95; PNG stills remain lossless. The original WAV score is generated by `scripts/score.mjs`. The legacy URL `/media/critical.mp4` serves the replacement film to preserve existing links.+| Seconds | Set | Composition and action |+| --- | --- | --- |+| 0 to 7 | `apparatus` | A slow move across the machined iris and its illuminated rim. |+| 7 to 13 | `control` | Meter needles and pilot lights establish the control circuit. |+| 13 to 20 | `apparatus` | The wider pressure chamber reveals collars, bolts and copper feedthroughs. |+| 20 to 29 | `office` | A fedora silhouette stands against the slatted office windows. |+| 29 to 34 | `sparks` | Heated particles travel outward through a dark volume. |+| 34 to 39 | `laboratory` | A low laboratory move reveals valve grids and thin glowing filaments. |+| 39 to 45 | `desert` | The test tower sits small against the mountain horizon. |+| 45 to 56 | `settlement` | A forward move follows the research town street. |+| 56 to 64 | `settlement` | A low camera tracks the moving jeep and its suspension vibration. |+| 64 to 73 | `settlement` | Two distant silhouettes place the machinery at human scale. |+| 73 to 85 | `office` | A monochrome office angle returns to the isolated figure. |+| 85 to 91 | `waves` | Metallic ripple crests spread across a dark reflecting pool. |+| 91 to 98 | `atom` | Rotating filaments cross a field of luminous dust. |+| 98 to 105 | `gadget` | The suspended Gadget reveals its terminals, taped labels and curved cables. |+| 105 to 110 | `office` | A monochrome silhouette interrupts the mechanical sequence. |+| 110 to 118 | `desert` | A rising tower angle approaches the suspended vessel. |+| 118 to 126 | `gadget` | A closer lateral move follows the Gadget wiring and its slow pendulum motion. |+| 126 to 133 | `laboratory` | The laboratory returns through a second camera angle. |+| 133 to 140 | `control` | Meter needles and signal lamps tighten the countdown. |+| 140 to 145 | `desert` | A low tower view emphasizes the steel structure above the desert. |+| 145 to 154 | `portrait` | A figure watches the distant tower from the foreground. |+| 154 to 161 | `night` | The night tower appears through its practical work lights and ground signals. |+| 161 to 165 | `portrait` | The fedora silhouette fills the foreground before the final cuts. |+| 165 to 168 | `control` | The camera approaches the firing control. |+| 168 to 170 | `gadget` | An extreme Gadget detail holds on the wiring. |+| 170 to 172 | `sparks` | Accelerating particles interrupt the countdown. |+| 172 to 174 | `night` | A short night insert approaches the tower platform. |+| 174 to 176 | `office` | The monochrome figure returns for one final interruption. |+| 176 to 178 | `control` | The controls complete the mechanical countdown. |+| 178 to 179.5 | `sparks` | A brief particle burst leads into darkness. |+| 179.5 to 181 | `night` | The wide night tower holds before ignition. |+| 181 to 184 | `ignition` | The volumetric fireball expands before the title begins at 183.3 seconds. |+| 184 to 187 | `ignition` | The title holds over the fireball before the terminal fade. |++## Deterministic playback++`FILM_DURATION` remains 187.+`FILM_SHOTS` owns the camera endpoints and cut boundaries.+`createFilmScenes()` constructs shared meshes and retained part identities.+`sampleFilm(seconds)` returns the camera, set, local time, grade, fade, flash, explosion progress and title state.++Each animated set resets its retained matrices from fixed bases before sampling its motion.+Backward seeking therefore produces the same geometry state as forward playback.+Motion includes the Gadget suspension, meter needles, pilot lights, jeep travel, ripple crests, rotating filaments and particles.+Only the active set owns GPU resources.++Ignition begins at 181 seconds and reaches full volume by 182.7 seconds.+The title begins at 183.3 seconds, after the fireball has an unobstructed moment.+The final frame is black at 187 seconds.++## Render evidence++The final keyframe captures use hardware WebGL on an RTX 3060, HDR and four MSAA samples at 1280 × 720.+The eight standard samples cover the office, town, jeep, Gadget, tower, silhouette, night test and ignition.+Eight supplemental samples cover the iris, controls, sparks, laboratory, ripples, atomic filaments, close silhouette and title.+The reports record no browser errors or WebGL errors.++The measured set maximum is 1,347 parts and 390,128 submitted triangles.+The highest shared geometry count is 11.+The renderer allocation estimate stays below 85 MiB at these capture settings, within the configured 384 MiB target budget.+This estimate does not measure total driver or browser memory.++The local evidence is in `artifacts/astra-trailer/final/contact.png`, `details-contact.png` and the adjacent JSON reports.+The six film tests cover cuts, finite camera samples, camera continuity, geometry budgets, deterministic motion and outward coat surfaces.++## Reproduction++1. Run `node --test tests/film.test.js`.+2. Run `node scripts/render-media.mjs --kind stills --scene film --backend gpu --preset balanced --output artifacts/film-review/frame.png`.++This is an unofficial stylized reconstruction study.+The figures, architecture and materials remain procedural, without photorealistic character assets or recorded performances.diff --git a/docs/release-verification.md b/docs/release-verification.mdindex d1e5e6c8..3964cc64 100644--- a/docs/release-verification.md+++ b/docs/release-verification.md@@ -1,5 +1,30 @@# Release verification+## 0.3.3++These checks used Windows Chrome, ANGLE D3D11 and an RTX 3060.++| Check | Measured result |+| --- | --- |+| Node tests | 78 tests passed, including articulated joints, forward track contact, deterministic film motion and assembly interpolation. |+| Assembly | Native slider taps and interrupted transitions passed at 1440, 390 and 320 pixels. Driving remained paused until complete reassembly. |+| Motion preferences | Reduced motion snapped assembly to the selected position and kept driving paused. |+| Moving character | Head, arms and claws rendered correctly at four poses. Camera and shadow bounds followed the root at 120 seconds. |+| Film transport | Held pointer input, coalesced seeks, delayed audio, keyboard input and paused seeking passed. Real playback resumed without moving behind the selected time. |+| Terrain | Film sand and nature terrain compiled and rendered without WebGL errors. |+| Trailer | Sixteen inspected frames cover the rebuilt machinery, silhouettes, jeep, desert, night lighting and ignition. |+| Full export | 4,488 frames at 1280 × 720 and 24 FPS rendered in 110.13 seconds. The film lasts 187 seconds. |+| Memory | The export kept one pending frame. Peak renderer allocation was 84.34 MiB, observed Node RSS was 217.34 MiB and sampled browser heap was 19.42 MiB. |+| Delivery | FFprobe verified H.264, BT.709, 48 kHz stereo AAC and 187 seconds. The delivery file contains 22,729,620 bytes. |++The export used JPEG capture at quality 95 and NVENC encoding.+The browser player renders the same procedural scene directly through WebGL.+The downloadable file uses a lower bitrate to fit the hosting asset limit.+Its encoded Gadget closeup was inspected after compression.++Renderer estimates exclude driver memory and browser RSS.+The figures remain stylized silhouettes, without photorealistic character assets or recorded performances.+## 0.3.0The package is `@codepawlhq/67js`, installed locally through the `67js` alias. The display name remains 67.js.diff --git a/package-lock.json b/package-lock.jsonindex dabf615b..680ada3a 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "@codepawlhq/67js",- "version": "0.3.2",+ "version": "0.3.3","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@codepawlhq/67js",- "version": "0.3.2",+ "version": "0.3.3","license": "MIT","devDependencies": {"gl-matrix": "3.4.4",diff --git a/package.json b/package.jsonindex 232b037c..fc314133 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "@codepawlhq/67js",- "version": "0.3.2",+ "version": "0.3.3","private": false,"type": "module","description": "A browser graphics engine for interactive worlds, animation and cinematic media, with memory-aware CPU/GPU export",@@ -46,6 +46,7 @@"test": "node --test","smoke": "node scripts/smoke.mjs","smoke:scenes": "node scripts/smoke-scenes.mjs",+ "smoke:transport": "node scripts/smoke-film-transport.mjs","render": "node scripts/render-media.mjs","score": "node scripts/score.mjs","export:model": "node scripts/export-model.mjs",diff --git a/public/media/critical.mp4 b/public/media/critical.mp4index c96db1bb..120fce66 100644Binary files a/public/media/critical.mp4 and b/public/media/critical.mp4 differdiff --git a/public/media/critical.mp4.json b/public/media/critical.mp4.jsonindex 2d378910..7e26a9e1 100644--- a/public/media/critical.mp4.json+++ b/public/media/critical.mp4.json@@ -6,6 +6,18 @@"aspect": "landscape","start": 0,"encoder": "gpu",+ "requestedEncoder": "auto",+ "captureFormat": "jpeg",+ "jpegQuality": 95,+ "capturedFrames": 4488,+ "stageTimings": {+ "renderSeconds": 13.233183899999782,+ "captureSeconds": 92.94667900000034,+ "encoderBackpressureSeconds": 1.5668255999998477,+ "encoderFinishSeconds": 0.6182017000000051+ },+ "effectiveFPS": 40.75366571254871,+ "speedRatio": 1.6980694046895295,"assembly": null,"width": 1280,"height": 720,@@ -17,12 +29,12 @@"fps": 24,"duration": 187,"memoryBudgetMiB": 384,- "peakEstimatedRenderBytes": 86978764,- "peakNodeBytes": 226672640,- "peakBrowserHeap": 10947796,+ "peakEstimatedRenderBytes": 88437868,+ "peakNodeBytes": 227901440,+ "peakBrowserHeap": 20362648,"maximumPendingFrames": 1,"firstFrameBytes": 6158,- "elapsedSeconds": 134.85767690000003,+ "elapsedSeconds": 110.1250629,"graphics": {"gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)","samples": 4,@@ -35,14 +47,14 @@},"glError": 0},- "output": "critical.mp4",+ "output": "oppenheimer-master.mp4","errors": [],"webDelivery": {"codec": "h264_nvenc","targetVideoBitrate": 800000,"maxVideoBitrate": 850000,"audioBitrate": 128000,- "bytes": 22757045,+ "bytes": 22729620,"verifiedDuration": 187,"verifiedFrames": 4488}diff --git a/public/previews/film-contact.png b/public/previews/film-contact.pngindex 6f1be52f..3a208cbb 100644Binary files a/public/previews/film-contact.png and b/public/previews/film-contact.png differdiff --git a/public/previews/film-contact.webp b/public/previews/film-contact.webpindex 5925c452..4a96dac8 100644Binary files a/public/previews/film-contact.webp and b/public/previews/film-contact.webp differdiff --git a/scripts/smoke-film-transport.mjs b/scripts/smoke-film-transport.mjsnew file mode 100644index 00000000..5a3cde58--- /dev/null+++ b/scripts/smoke-film-transport.mjs@@ -0,0 +1,71 @@+import assert from 'node:assert/strict';+import { chromium } from 'playwright';+import { spawn } from 'node:child_process';+import { setPriority, constants } from 'node:os';+import { existsSync } from 'node:fs';++setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);+const server = spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1', '--port', '5191', '--strictPort'], { windowsHide:true, stdio:'pipe' });+let browser;+try {+ await new Promise((resolve, reject) => {+ const timeout = setTimeout(() => reject(new Error('Transport test server did not start.')), 15000);+ server.stdout.on('data', bytes => {+ if (bytes.toString().includes('127.0.0.1:5191')) { clearTimeout(timeout); resolve(); }+ });+ server.on('error', reject);+ });+ const chrome = 'C:/Program Files/Google/Chrome/Application/chrome.exe';+ browser = await chromium.launch({ headless:true, ...(existsSync(chrome) ? { executablePath:chrome } : {}) });+ const page = await browser.newPage();+ // Isolate transport races from GPU cost and intentionally delay media seeks.+ await page.route('**/src/renderer.js', route => route.fulfill({ contentType:'text/javascript', body:'export class Renderer67 { render(){} dispose(){} resize(){} }' }));+ await page.route('**/src/film.js', route => route.fulfill({ contentType:'text/javascript', body:`export const FILM_DURATION=187; export function createFilmScenes(){return {test:{parts:[]}};} export function sampleFilm(time){return {scene:'test',camera:{},time,sceneTime:time,title:'',subtitle:'',titleOpacity:0,flash:0};}` }));+ await page.addInitScript(() => {+ window.Audio = class {+ constructor() { this.paused = true; this.readyState = 2; this.position = 0; this.seeking = false; this.deferSeek = false; }+ get currentTime() { return this.position; }+ set currentTime(value) { if (this.deferSeek) this.seeking = true; else this.position = value; }+ play() { this.paused = false; return Promise.resolve(); }+ pause() { this.paused = true; }+ };+ });+ await page.goto('http://127.0.0.1:5191/film.html');+ await page.waitForFunction(() => window.__filmReady);+ await page.getByRole('button', { name:'Play film', exact:true }).click();+ await page.evaluate(() => {+ const slider = document.querySelector('#film-time');+ slider.dispatchEvent(new PointerEvent('pointerdown', { bubbles:true, pointerId:1 }));+ slider.value = '137';+ });+ await page.waitForTimeout(80);+ assert.equal(await page.locator('#film-time').inputValue(), '137', 'Playback overwrote the held timeline');+ assert.equal(await page.evaluate(() => window.__film.score.paused), true);+ await page.evaluate(() => {+ const slider = document.querySelector('#film-time');+ for (const destination of [90, 140]) { slider.value = destination; slider.dispatchEvent(new Event('input', { bubbles:true })); }+ });+ await page.waitForFunction(() => window.__film.currentTime === 140);+ assert.equal(await page.locator('#film-time').inputValue(), '140');+ await page.evaluate(() => {+ window.__film.score.deferSeek = true;+ window.dispatchEvent(new PointerEvent('pointerup', { pointerId:1 }));+ });+ await page.waitForTimeout(80);+ assert.equal(await page.evaluate(() => window.__film.currentTime), 140, 'Stale audio seek moved the film backwards');+ assert.equal(await page.evaluate(() => window.__film.playing), true);+ await page.evaluate(() => { window.__film.score.position = 140.1; window.__film.score.seeking = false; });+ await page.waitForFunction(() => window.__film.currentTime >= 140.1);+ await page.getByRole('button', { name:'Pause film', exact:true }).click();+ await page.locator('#film-time').fill('32');+ await page.waitForFunction(() => window.__film.currentTime === 32);+ assert.equal(await page.evaluate(() => window.__film.playing), false);+ await page.locator('#film-time').focus();+ await page.keyboard.press('ArrowRight');+ assert.ok(await page.evaluate(() => window.__film.currentTime) > 32);+ assert.equal(await page.evaluate(() => window.__film.scrubbing), false);+ console.log('Transport passed: held pointer, coalesced seeks, delayed audio, resume, paused seeks and keyboard.');+} finally {+ await browser?.close();+ server.kill();+}diff --git a/scripts/smoke-scenes.mjs b/scripts/smoke-scenes.mjsindex 4d9d54d8..f3dda385 100644--- a/scripts/smoke-scenes.mjs+++ b/scripts/smoke-scenes.mjs@@ -69,6 +69,21 @@ try {await page.locator('#film-time').fill('1');await page.getByRole('button', { name: 'Play film', exact: true }).click();await page.waitForFunction(() => window.__film.score.readyState >= 2 && window.__film.score.currentTime > 1.1);+ const timeline = await page.locator('#film-time').boundingBox();+ await page.mouse.move(timeline.x + timeline.width * 0.7, timeline.y + timeline.height / 2);+ await page.mouse.down();+ await page.mouse.move(timeline.x + timeline.width * 0.25, timeline.y + timeline.height / 2);+ await page.waitForFunction(() => window.__film.scrubbing && !window.__film.playing);+ await page.waitForTimeout(150);+ const heldTime = Number(await page.locator('#film-time').inputValue());+ assert.ok(heldTime > 40 && heldTime < 55);+ assert.ok(Math.abs(await page.evaluate(() => window.__film.currentTime) - heldTime) < 0.1);+ await page.waitForTimeout(100);+ assert.equal(Number(await page.locator('#film-time').inputValue()), heldTime);+ await page.mouse.up();+ await page.waitForFunction(() => window.__film.playing && !window.__film.scrubbing);+ await page.waitForTimeout(150);+ assert.ok(await page.evaluate(() => window.__film.currentTime) >= heldTime);await page.getByRole('button', { name: 'Pause film', exact: true }).click();assert.equal(await page.evaluate(() => window.__film.score.paused), true);await page.setViewportSize({ width: 320, height: 700 });diff --git a/scripts/smoke-site.mjs b/scripts/smoke-site.mjsindex aab3ea47..73614d1d 100644--- a/scripts/smoke-site.mjs+++ b/scripts/smoke-site.mjs@@ -79,11 +79,13 @@ try {slider.dispatchEvent(new Event('input', { bubbles:true }));slider.dispatchEvent(new Event('change', { bubbles:true }));});- assert.equal(await page.evaluate(() => window.__homePreview.state.assembly), 1);+ assert.equal(await page.evaluate(() => window.__homePreview.state.assemblyTarget), 1);+ assert.ok(await page.evaluate(() => window.__homePreview.state.assembly) < 1, 'Assembly jumped to the target');assert.equal(await page.evaluate(() => window.__homePreview.state.playing), false);const frozenTime = await page.evaluate(() => window.__homePreview.state.time);await page.waitForTimeout(150);assert.equal(await page.evaluate(() => window.__homePreview.state.time), frozenTime);+ await page.waitForFunction(() => window.__homePreview.state.assembly === 1);await page.locator('#home-preview').focus();await page.keyboard.press('Space');assert.equal(await page.evaluate(() => window.__homePreview.state.playing), false, 'Exploded model resumes from Space');@@ -92,7 +94,8 @@ try {slider.dispatchEvent(new Event('input', { bubbles:true }));slider.dispatchEvent(new Event('change', { bubbles:true }));});- assert.equal(await page.evaluate(() => window.__homePreview.state.playing), true);+ assert.equal(await page.evaluate(() => window.__homePreview.state.playing), false, 'Drive resumed before reassembly completed');+ await page.waitForFunction(() => window.__homePreview.state.playing);assert.ok(await page.evaluate(() => window.__homePreview.state.speed) < 0.4, 'Drive restarts at full speed');await page.waitForFunction(() => window.__homePreview.state.speed === 1);await page.emulateMedia({ reducedMotion:'reduce' });diff --git a/scripts/smoke.mjs b/scripts/smoke.mjsindex 64dcc3eb..9ddd6067 100644--- a/scripts/smoke.mjs+++ b/scripts/smoke.mjs@@ -52,6 +52,8 @@ try {assert.equal(await page.locator('#finish-name').textContent(), 'Ceramic');await page.screenshot({ path: fileURLToPath(new URL('ceramic.png', artifactDirectory)) });await page.getByRole('button', { name: 'Yellow finish' }).click();+ await page.evaluate(() => document.fonts.ready);+ await page.waitForFunction(() => window.__studio.state.assembly === 0 && window.__studio.renderer.assemblyAmount === 0);const assembled = await modelPixels();await page.evaluate(() => { window.__shadowBefore = window.__studio.renderer.shadowTexture; });for (const value of ['50', '100']) {diff --git a/src/film-player.js b/src/film-player.jsindex df2d3b03..b9240daa 100644--- a/src/film-player.js+++ b/src/film-player.js@@ -35,6 +35,11 @@ let currentTime = 0;let playing = false;let animationFrame = 0;let playbackOrigin = 0;+let scrubbing = false;+let resumeAfterScrub = false;+let seekFrame = 0;+let pendingSeek = null;+let audioSeekTarget = null;if (exporting) {document.body.classList.add('export-mode');@@ -81,7 +86,7 @@ function renderAt(time) {environment: scene.environment,});currentTime = sample.time;- slider.value = String(currentTime);+ if (!scrubbing) slider.value = String(currentTime);slider.setAttribute('aria-valuetext', `${currentTime.toFixed(1)} of ${FILM_DURATION} seconds`);clock.value = `${displayTime(currentTime)} / ${displayTime(FILM_DURATION)}`;titleText.textContent = sample.title;@@ -101,8 +106,10 @@ function setPlaying(value) {if (playing) {if (currentTime >= FILM_DURATION) renderAt(0);if (score) {+ audioSeekTarget = currentTime;score.currentTime = currentTime;- score.play().catch(() => {+ score.play().catch(error => {+ if (!playing || error.name === 'AbortError') return;document.querySelector('.film-caption').textContent = '⚠ Score unavailable. The 3D film continues.';});}@@ -120,10 +127,18 @@ function showError(error) {}function advance(timestamp) {- if (!playing) return;+ if (!playing || scrubbing) return;try {- const seconds = score && !score.paused && score.readyState >= 2 ? score.currentTime : (timestamp - playbackOrigin) / 1000;- renderAt(seconds);+ if (audioSeekTarget !== null && score && !score.paused && score.readyState >= 2) {+ if (score.seeking || score.currentTime < audioSeekTarget - 0.1) {+ animationFrame = requestAnimationFrame(advance);+ return;+ }+ audioSeekTarget = null;+ playbackOrigin = timestamp - currentTime * 1000;+ }+ const seconds = score && !score.paused && score.readyState >= 2 && !score.seeking ? score.currentTime : (timestamp - playbackOrigin) / 1000;+ renderAt(Math.max(currentTime, seconds));if (currentTime >= FILM_DURATION) setPlaying(false);else animationFrame = requestAnimationFrame(advance);} catch (error) {@@ -131,23 +146,68 @@ function advance(timestamp) {}}-playButton.addEventListener('click', () => setPlaying(!playing));+playButton.addEventListener('click', () => {+ if (scrubbing) finishScrub(false);+ setPlaying(!playing);+});document.querySelector('#film-replay').addEventListener('click', () => {+ finishScrub(false);setPlaying(false);renderAt(0);setPlaying(true);});-slider.addEventListener('input', () => {+function beginScrub() {+ if (scrubbing) return;+ resumeAfterScrub = playing;+ scrubbing = true;setPlaying(false);- renderAt(Number(slider.value));+}++function flushSeek() {+ cancelAnimationFrame(seekFrame);+ seekFrame = 0;+ if (pendingSeek === null) return;+ const destination = pendingSeek;+ pendingSeek = null;+ renderAt(destination);+}++function finishScrub(resume = true) {+ if (!scrubbing) return;+ flushSeek();+ scrubbing = false;+ slider.value = String(currentTime);+ const shouldResume = resume && resumeAfterScrub;+ resumeAfterScrub = false;+ if (shouldResume) setPlaying(true);+}++slider.addEventListener('pointerdown', beginScrub);+slider.addEventListener('input', () => {+ const destination = Number(slider.value);+ beginScrub();+ pendingSeek = destination;+ if (!seekFrame) seekFrame = requestAnimationFrame(flushSeek);+});+slider.addEventListener('change', () => finishScrub());+window.addEventListener('pointerup', () => finishScrub());+window.addEventListener('pointercancel', () => finishScrub(false));+window.addEventListener('blur', () => finishScrub(false));+slider.addEventListener('blur', () => finishScrub(false));+slider.addEventListener('keydown', event => {+ if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(event.key)) beginScrub();});+slider.addEventListener('keyup', () => finishScrub());document.addEventListener('keydown', event => {if (event.code !== 'Space' || event.target.closest('input, button, a')) return;event.preventDefault();setPlaying(!playing);});document.addEventListener('visibilitychange', () => {- if (document.hidden) setPlaying(false);+ if (document.hidden) {+ finishScrub(false);+ setPlaying(false);+ }});window.addEventListener('resize', () => {if (!renderer || exporting) return;@@ -155,6 +215,10 @@ window.addEventListener('resize', () => {renderAt(currentTime);});window.addEventListener('pagehide', () => {+ cancelAnimationFrame(seekFrame);+ seekFrame = 0;+ pendingSeek = null;+ scrubbing = false;setPlaying(false);renderer?.dispose();renderer = null;@@ -170,6 +234,9 @@ window.__film = {renderAt,duration: FILM_DURATION,score,+ get playing() { return playing; },+ get scrubbing() { return scrubbing; },+ get currentTime() { return currentTime; },exporting,options: { width, height, samples, memoryBudgetMiB },};diff --git a/src/film.js b/src/film.jsindex 6ebd1d78..5bbe3bca 100644--- a/src/film.js+++ b/src/film.js@@ -9,30 +9,122 @@ const materials = {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 },copper: { tag: 'copper', color: [0.63, 0.25, 0.08], metallic: 0.92, roughness: 0.28, emission: 0 },- ceramic: { tag: 'armor', color: [0.78, 0.75, 0.65], metallic: 0.12, roughness: 0.38, emission: 0 },+ ceramic: { tag: 'ceramic', color: [0.62, 0.57, 0.43], metallic: 0.12, roughness: 0.38, emission: 0 },orbit: { tag: 'light', color: [0.63, 0.83, 1], metallic: 0.15, roughness: 0.24, emission: 5 },amber: { tag: 'indicator', color: [1, 0.34, 0.035], metallic: 0.1, roughness: 0.3, emission: 4 },- terrain: { tag: 'terrain', color: [0.38, 0.27, 0.17], metallic: 0, roughness: 0.94, emission: 0 },+ 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 },fire: { tag: 'fire', color: [1, 0.24, 0.012], metallic: 0, roughness: 0.7, emission: 8 },core: { tag: 'fire', color: [1, 0.75, 0.26], metallic: 0, roughness: 0.5, emission: 18 },smoke: { tag: 'smoke', color: [0.2, 0.14, 0.1], metallic: 0, roughness: 1, emission: 0.04 },particle: { tag: 'particle', color: [1, 0.37, 0.035], metallic: 0, roughness: 0.65, emission: 6 },wood: { tag: 'wood', color: [0.17, 0.085, 0.035], metallic: 0, roughness: 0.82, emission: 0 },- plaster: { tag: 'plaster', color: [0.42, 0.38, 0.29], metallic: 0, roughness: 0.95, emission: 0 },- cloth: { tag: 'cloth', color: [0.045, 0.055, 0.049], metallic: 0, roughness: 0.91, emission: 0 },- skin: { tag: 'skin', color: [0.44, 0.26, 0.16], metallic: 0, roughness: 0.76, emission: 0 },+ plaster: { tag: 'plaster', color: [0.115, 0.125, 0.105], metallic: 0, roughness: 0.95, emission: 0 },+ cloth: { tag: 'cloth', color: [0.022, 0.027, 0.025], metallic: 0, roughness: 0.91, emission: 0 },+ skin: { tag: 'skin', color: [0.29, 0.175, 0.115], metallic: 0, roughness: 0.76, emission: 0 },paper: { tag: 'paper', color: [0.73, 0.66, 0.48], metallic: 0, roughness: 0.96, emission: 0 },- window: { tag: 'window', color: [0.48, 0.66, 0.71], metallic: 0, roughness: 0.8, emission: 1.2 },+ window: { tag: 'window', color: [0.51, 0.57, 0.51], metallic: 0, roughness: 0.8, emission: 1.8 },+ black: { tag: 'cloth', color: [0.003, 0.004, 0.004], metallic: 0, roughness: 1, emission: 0 },+ sage: { tag: 'terrain', color: [0.115, 0.125, 0.068], metallic: 0, roughness: 1, emission: 0 },+ water: { tag: 'water', color: [0.018, 0.025, 0.023], metallic: 0.7, roughness: 0.2, emission: 0 },olive: { tag: 'paint', color: [0.13, 0.16, 0.08], metallic: 0.2, roughness: 0.65, emission: 0 },};+// Sculpted surfaces and landscape meshes are shared by every set.+function sampledSurface(columns, rows, sample) {+ const positions = [];+ const normals = [];+ const indices = [];+ for (let row = 0; row <= rows; row++) {+ for (let column = 0; column <= columns; column++) {+ const horizontal = column / columns;+ const vertical = row / rows;+ const point = sample(horizontal, vertical);+ const epsilon = 0.0001;+ 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));+ const normal = vec3.normalize(vec3.create(), vec3.cross(vec3.create(), tangent, bitangent));+ positions.push(...point);+ normals.push(...normal);+ }+ }+ 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 radius = Math.hypot(horizontal, depth);+ const flats = Math.min(1, radius / 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 createLandscape() {+ return sampledSurface(140, 140, (horizontal, vertical) => {+ const position = [(horizontal - 0.5) * 400, 0, (0.5 - vertical) * 400];+ position[1] = desertHeight(position[0], position[2]);+ return position;+ });+}++function createRidge() {+ return sampledSurface(180, 20, (horizontal, vertical) => {+ const angle = horizontal * FULL_TURN;+ 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);+ const radius = 145 + vertical * 72;+ return [Math.cos(angle) * radius, -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, Math.sin(angle) * radius];+ });+}++function createSculptedHead() {+ return sampledSurface(64, 48, (horizontal, vertical) => {+ const angle = horizontal * FULL_TURN;+ const elevation = 0.015 + vertical * (Math.PI - 0.03);+ const height = Math.cos(elevation);+ const radius = Math.sin(elevation);+ const jaw = 0.77 + 0.23 * Math.min(1, (height + 1) / 0.75);+ const front = Math.max(0, Math.sin(angle));+ const horizontalPoint = Math.cos(angle) * radius * jaw;+ let depth = Math.sin(angle) * radius;+ // Nose, brow, cheek and chin belong to the continuous surface, without separate cartoon features.+ depth += front ** 28 * (0.24 * Math.exp(-1 * ((height + 0.08) / 0.23) ** 2) + 0.12 * Math.exp(-1 * ((height - 0.29) / 0.10) ** 2));+ depth -= front ** 6 * 0.15 * Math.exp(-1 * ((height - 0.12) / 0.13) ** 2) * (1 - Math.exp(-1 * ((horizontalPoint / 0.24) ** 2)));+ depth += front ** 12 * 0.11 * Math.exp(-1 * ((height + 0.68) / 0.16) ** 2);+ return [horizontalPoint, height, depth];+ });+}++function createCoat() {+ const mesh = sampledSurface(32, 20, (horizontal, vertical) => {+ const angle = horizontal * FULL_TURN;+ const shoulder = Math.exp(-1 * ((vertical - 0.83) / 0.2) ** 2);+ const width = 0.76 + 0.25 * shoulder - 0.48 * Math.exp(-1 * ((vertical - 1.04) / 0.13) ** 2);+ const fold = 1 + 0.024 * Math.sin(angle * 7 + vertical * 3);+ return [Math.cos(angle) * width * fold, vertical - 0.5, Math.sin(angle) * (0.81 + 0.1 * shoulder) * fold];+ });+ // Unlike the head latitude, the coat profile runs upward. Reverse its winding and normals.+ for (let index = 0; index < mesh.normals.length; index++) mesh.normals[index] *= -1;+ for (let index = 0; index < mesh.indices.length; index += 3) {+ const second = mesh.indices[index + 1];+ mesh.indices[index + 1] = mesh.indices[index + 2];+ mesh.indices[index + 2] = second;+ }+ return mesh;+}+function createBuilder(meshes) {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));const matrix = mat4.fromRotationTranslationScale(mat4.create(), orientation, position, scale);- parts.push({ name, geometry: meshes[mesh], matrix, material: materials[material] });+ const part = { name, geometry: meshes[mesh], matrix, material: typeof material === 'string' ? materials[material] : material };+ parts.push(part);+ return part;}function beam(name, start, end, radius, material = 'steel') {const difference = vec3.subtract(vec3.create(), end, start);@@ -47,7 +139,17 @@ function createBuilder(meshes) {material: materials[material],});}- return { parts, add, beam };+ function cable(name, points, radius, material = 'graphite', segments = 8) {+ const [start, bend, end] = points;+ let previous = start;+ for (let index = 1; index <= segments; index++) {+ const fraction = index / segments;+ const next = start.map((value, axis) => (1 - fraction) ** 2 * value + 2 * (1 - fraction) * fraction * bend[axis] + fraction ** 2 * end[axis]);+ beam(name, previous, next, radius, material);+ previous = next;+ }+ }+ return { parts, add, beam, cable };}function createApparatus(meshes) {@@ -88,58 +190,51 @@ function createApparatus(meshes) {function createAtom(meshes) {const { parts, add } = createBuilder(meshes);- for (let orbit = 0; orbit < 5; orbit++) {- add('Intersecting luminous orbit', 'thinRing', [0, 0, 0], [2.9, 1.7, 2.5], 'orbit', [orbit * 0.58, orbit * 0.81, orbit * 0.39]);- const angle = orbit * 1.37;- add('Orbital electron', 'sphere', [Math.cos(angle) * 2.6, Math.sin(angle) * 1.7, Math.sin(orbit * 2.4) * 1.2], [0.07, 0.07, 0.07], 'core');+ // A practical-looking tangle of heated filaments, with depth and a dark center.+ for (let index = 0; index < 32; index++) {+ const radius = 0.7 + index * 0.052;+ add('Heated filament orbit', 'thinRing', [Math.sin(index * 2.3) * 0.3, 0, Math.cos(index * 1.7) * 0.3], [radius * 1.9, radius * 0.7, radius], index % 7 ? 'steel' : 'orbit', [index * 0.127, index * 0.207, index * 0.043]);}- for (let index = 0; index < 39; index++) {+ for (let index = 0; index < 190; index++) {const angle = index * 2.399963;- const elevation = 1 - 2 * (index + 0.5) / 39;- const radius = Math.sqrt(1 - elevation * elevation) * 0.53;- add('Nucleus cluster', 'sphere', [Math.cos(angle) * radius, elevation * 0.53, Math.sin(angle) * radius], [0.19, 0.19, 0.19], index % 3 ? 'copper' : 'steel');- }- for (let index = 0; index < 110; index++) {- const angle = index * 2.399963;- const radius = 4 + index % 7 * 0.48;- add('Suspended speck', 'sphere', [Math.cos(angle) * radius, Math.sin(index * 1.7) * 3.5, Math.sin(angle) * radius], [0.008, 0.008, 0.008], 'orbit');+ const radius = 1.8 + index % 13 * 0.23;+ add('Suspended luminous dust', 'rock', [Math.cos(angle) * radius, Math.sin(index * 1.7) * 2.5, Math.sin(angle) * radius], [0.009, 0.009, 0.009], index % 6 ? 'particle' : 'orbit');}return parts;}function createWaveChamber(meshes) {- const { parts, add, beam } = createBuilder(meshes);- add('Wave chamber slab', 'box', [0, -0.12, 0], [12, 0.16, 7], 'graphite');- for (let index = -24; index <= 24; index++) {- beam('Scientific grid', [index * 0.22, 0, -3], [index * 0.22, 0, 3], 0.007, 'steel');- }- for (let index = -14; index <= 14; index++) {- beam('Scientific grid', [-5.3, 0, index * 0.22], [5.3, 0, index * 0.22], 0.007, 'steel');- }- for (let index = 0; index < 170; index++) {- const horizontal = -5 + index * 10 / 169;- const next = -5 + (index + 1) * 10 / 169;- const wave = value => Math.sin(value * 5.2) * Math.exp(-value * value * 0.055);- beam('Wave trace', [horizontal, 0.12 + wave(horizontal) * 0.75, 0], [next, 0.12 + wave(next) * 0.75, 0], 0.023, 'orbit');+ const { parts, add } = createBuilder(meshes);+ add('Black reflecting pool', 'box', [0, -0.08, 0], [30, 0.08, 30], 'water');+ for (let index = 0; index < 36; index++) {+ const radius = 0.18 + index * 0.097;+ add('Interference ripple crest', 'thinRing', [0, -0.012, 0], [radius, radius * 0.91, 0.14], index % 4 ? 'steel' : 'copper', [HALF_PI, 0, 0]);}- for (let index = 0; index < 14; index++) {- add('Concentric interference shell', 'thinRing', [0, 0.1, -0.6], [0.2 + index * 0.21, 0.2 + index * 0.21, 0.3], 'steel', [HALF_PI, 0, 0]);+ for (let index = 0; index < 100; index++) {+ const angle = index * 2.399963;+ const radius = 0.6 + index % 19 * 0.15;+ add('Suspended droplet', 'sphere', [Math.cos(angle) * radius, 0.12 + index % 17 * 0.031, Math.sin(angle) * radius], [0.008, 0.021, 0.008], 'steel');}return parts;}function addDesert(builder) {- const { add } = builder;- add('Desert floor', 'box', [0, -0.65, 0], [260, 1, 260], 'terrain');+ const { add, beam } = builder;+ add('Undulating alluvial plain', 'landscape', [0, 0, 0], [1, 1, 1], 'terrain');+ add('Layered mountain horizon', 'ridge', [0, 0, 0], [1, 1, 1], 'rock');+ add('Distant blue mountain horizon', 'ridge', [0, 1, 0], [1.42, 0.8, 1.42], { ...materials.rock, color: [0.18, 0.2, 0.19] }, [0, 0.12, 0]);for (let index = 0; index < 180; index++) {const angle = index * 2.399963;- const radius = 14 + Math.sqrt(index / 180) * 108;- const width = 0.5 + (index % 9) * 0.22;- add('Weathered desert stone', 'rock', [Math.cos(angle) * radius, -0.05, Math.sin(angle) * radius], [width, width * 0.3, width * 0.7], 'rock', [0.12, angle, 0.1]);- }- for (let index = 0; index < 24; index++) {- const angle = index / 24 * FULL_TURN;- add('Distant broken ridge', 'rock', [Math.cos(angle) * 114, 0.7, Math.sin(angle) * 114], [14 + index % 4 * 4, 3 + index % 5 * 1.8, 9], 'rock', [0, angle, 0]);+ 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('Scattered weathered shale', 'rock', [horizontal, ground, depth], [size * 2, size * 0.4, size], 'rock', [0.2, angle, 0.1]);+ for (let stem = 0; stem < 3; stem++) {+ const lean = angle + stem * 2.1;+ beam('Dry 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, 'sage');+ }}}@@ -164,130 +259,152 @@ function createDesert(meshes) {}beam('Signal cable', [0.15, 10, 0], [9, 0, 2], 0.021, 'graphite');add('Remote junction box', 'box', [9, 0.3, 2], [0.8, 0.7, 0.8], 'graphite');+ for (let index = 0; index < 19; index++) {+ const depth = 3 + index * 3.4;+ add('Amber ground signal lamp', 'sphere', [1.8, 0.07, depth], [0.055, 0.035, 0.055], '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], 'window');+ beam('Tower hoist upright', [side * 1.3, 10, -0.5], [side * 1.3, 14.6, -0.5], 0.045, 'steel');+ beam('Guy wire', [side * 1.3, 9.6, 0], [side * 17, 0, 9], 0.012, 'graphite');+ }+ beam('Tower hoist lintel', [-1.3, 14.6, -0.5], [1.3, 14.6, -0.5], 0.045, 'steel');return builder.parts;}function createIgnition(meshes) {const builder = createBuilder(meshes);- const { add } = builder;addDesert(builder);- add('Incandescent ignition core', 'sphere', [0, 7, 0], [6.8, 7, 6.8], 'core');- for (let index = 0; index < 160; index++) {- const angle = index * 2.399963;- const elevation = 1 - 2 * (index + 0.5) / 160;- const radius = Math.sqrt(1 - elevation * elevation) * (6.2 + index % 5 * 0.18);- const size = 0.8 + index % 7 * 0.19;- add('Boiling fire cell', 'sphere', [Math.cos(angle) * radius, 7.5 + elevation * 6.6, Math.sin(angle) * radius], [size, size * 1.16, size], index % 4 ? 'fire' : 'core');- }- for (let index = 0; index < 110; index++) {- const angle = index * 2.399963;- const radius = 2 + index % 11 * 0.48;- const height = 12 + index / 110 * 10;- const size = 1.4 + index % 6 * 0.22;- add('Rolling smoke crown', 'sphere', [Math.cos(angle) * radius, height, Math.sin(angle) * radius], [size * 1.3, size, size * 1.3], 'smoke');- }- for (let index = 0; index < 6; index++) {- add('Dust shock ring', 'gasRing', [0, 0.12 + index * 0.03, 0], [10 + index * 2.3, 10 + index * 2.3, 0.12], 'smoke', [HALF_PI, 0, 0]);- }- for (let index = 0; index < 130; index++) {- const angle = index * 2.399963;- const radius = 8 + index % 19 * 0.56;- add('Ejected ember', 'sphere', [Math.cos(angle) * radius, 1 + index % 17 * 0.6, Math.sin(angle) * radius], [0.035, 0.09, 0.035], 'particle');- }+ // The player removes these proxy surfaces when enabling the volumetric explosion pass.+ builder.add('Ignition fallback core', 'sphere', [0, 7, 0], [6.8, 7, 6.8], 'fire');+ builder.add('Ignition fallback cloud', 'sphere', [0, 13, 0], [7, 4, 7], 'smoke');return builder.parts;}function addScientist(builder, position = [0, 0, 0], hat = true, rotation = 0) {- const { add, beam } = builder;+ const { add } = builder;const transform = point => [position[0] + point[0] * Math.cos(rotation) + point[2] * Math.sin(rotation), position[1] + point[1], position[2] - point[0] * Math.sin(rotation) + point[2] * Math.cos(rotation)];- const shape = (name, mesh, point, scale, material, angles = [0, 0, 0]) => add(name, mesh, transform(point), scale, material, [angles[0], rotation + angles[1], angles[2]]);+ const silhouette = {+ tag: 'unlit', color: [0.0045, 0.0055, 0.005], metallic: 0, roughness: 1, emission: 0,+ };+ const collar = { ...silhouette, color: [0.045, 0.042, 0.031] };+ const shape = (name, mesh, point, scale, material, angles = [0, 0, 0]) => {+ const surface = material === 'paper' ? collar : silhouette;+ const part = add(name, mesh, transform(point), scale, surface);+ const local = quat.fromEuler(quat.create(), ...angles.map(angle => angle * 180 / Math.PI));+ const orientation = quat.multiply(quat.create(), quat.setAxisAngle(quat.create(), [0, 1, 0], rotation), local);+ mat4.fromRotationTranslationScale(part.matrix, orientation, transform(point), scale);+ return part;+ };for (const side of [-1, 1]) {- shape('Polished leather shoe', 'sphere', [side * 0.14, 0.09, 0.09], [0.11, 0.08, 0.22], 'graphite');- beam('Trouser leg', transform([side * 0.14, 0.18, 0]), transform([side * 0.12, 0.88, 0]), 0.095, 'cloth');- shape('Coat shoulder', 'sphere', [side * 0.24, 1.43, 0], [0.14, 0.15, 0.15], 'cloth');- beam('Coat sleeve', transform([side * 0.27, 1.4, 0]), transform([side * 0.33, 0.9, 0.04]), 0.09, 'cloth');- shape('Resting hand', 'sphere', [side * 0.33, 0.85, 0.04], [0.07, 0.1, 0.065], 'skin');- shape('Wool lapel', 'box', [side * 0.095, 1.36, 0.17], [0.09, 0.29, 0.025], 'graphite', [0, 0, side * 0.25]);- shape('Eye socket', 'sphere', [side * 0.068, 1.805, 0.13], [0.043, 0.02, 0.025], 'graphite');- shape('Catchlight', 'sphere', [side * 0.068, 1.807, 0.151], [0.009, 0.009, 0.009], 'ceramic');- shape('Brow ridge', 'sphere', [side * 0.07, 1.846, 0.124], [0.065, 0.025, 0.034], 'skin');- shape('Ear', 'sphere', [side * 0.149, 1.77, 0], [0.034, 0.065, 0.039], 'skin');- }- shape('Coat body', 'sphere', [0, 1.19, 0], [0.28, 0.4, 0.17], 'cloth');- shape('Coat skirt', 'sphere', [0, 0.88, -0.02], [0.27, 0.3, 0.16], 'cloth');- shape('Ivory shirt front', 'box', [0, 1.42, 0.16], [0.11, 0.26, 0.035], 'paper');- shape('Narrow tie', 'box', [0, 1.39, 0.19], [0.027, 0.25, 0.017], 'graphite', [0, 0, -0.05]);- shape('Neck', 'cylinder', [0, 1.6, 0], [0.075, 0.15, 0.075], 'skin');- shape('Long angular head', 'sphere', [0, 1.79, 0], [0.15, 0.225, 0.14], 'skin');- shape('Cheek plane', 'sphere', [0, 1.75, 0.088], [0.115, 0.12, 0.065], 'skin');- shape('Bridge of nose', 'sphere', [0, 1.795, 0.156], [0.024, 0.07, 0.033], 'skin');- shape('Mouth line', 'box', [0, 1.7, 0.137], [0.063, 0.008, 0.007], 'wood');- shape('Combed hair', 'sphere', [0, 1.94, -0.023], [0.154, 0.09, 0.132], 'graphite');+ shape('Leather oxford', 'sphere', [side * 0.115, 0.062, 0.052], [0.073, 0.06, 0.15], 'graphite');+ shape('Tailored wool trouser', 'cylinder', [side * 0.108, 0.48, -0.01], [0.084, 0.81, 0.077], 'cloth');+ shape('Jacket sleeve', 'sphere', [side * 0.245, 1.18, -0.018], [0.076, 0.295, 0.089], 'cloth', [0.04, 0, side * 0.105]);+ shape('Shirt cuff', 'cylinder', [side * 0.276, 0.94, 0.007], [0.052, 0.04, 0.052], 'paper');+ shape('Resting hand silhouette', 'sphere', [side * 0.28, 0.858, 0.016], [0.047, 0.079, 0.035], 'skin');+ shape('Notched wool lapel', 'box', [side * 0.059, 1.38, 0.127], [0.06, 0.26, 0.015], 'graphite', [0.14, 0, side * 0.3]);+ shape('Shirt collar', 'box', [side * 0.039, 1.47, 0.103], [0.064, 0.065, 0.015], 'paper', [0.3, 0, side * 0.36]);+ shape('Ear silhouette', 'sphere', [side * 0.104, 1.668, -0.004], [0.018, 0.036, 0.026], 'skin');+ }+ shape('Sculpted tailored jacket', 'coat', [0, 1.16, 0], [0.25, 0.68, 0.145], 'cloth');+ shape('Tailored shoulder line', 'sphere', [0, 1.442, -0.005], [0.237, 0.055, 0.117], 'cloth');+ shape('Shirt front', 'box', [0, 1.385, 0.116], [0.098, 0.205, 0.013], 'paper');+ shape('Tie knot', 'sphere', [0, 1.444, 0.139], [0.021, 0.021, 0.012], 'graphite');+ shape('Narrow silk tie', 'box', [0, 1.346, 0.143], [0.022, 0.19, 0.009], 'graphite');+ shape('Neck', 'cylinder', [0, 1.533, -0.005], [0.053, 0.11, 0.057], 'skin');+ shape('Continuous sculpted head', 'head', [0, 1.686, -0.01], [0.11, 0.163, 0.106], 'skin');+ shape('Swept hair', 'sphere', [0, 1.795, -0.038], [0.109, 0.055, 0.086], 'graphite', [-0.2, 0, 0]);if (hat) {- shape('Fedora sweeping brim', 'cylinder', [0, 1.983, 0], [0.29, 0.025, 0.235], 'cloth', [0.035, 0, -0.04]);- shape('Fedora pinched crown', 'sphere', [0, 2.075, -0.015], [0.168, 0.16, 0.145], 'cloth');- shape('Fedora grosgrain band', 'cylinder', [0, 2.012, -0.012], [0.168, 0.046, 0.145], 'graphite');+ shape('Fedora sweeping brim', 'cylinder', [0, 1.809, 0], [0.225, 0.014, 0.187], 'cloth', [-0.06, 0, -0.035]);+ shape('Fedora tapered felt crown', 'cylinder', [0, 1.879, -0.022], [0.132, 0.128, 0.117], 'cloth');+ shape('Fedora grosgrain band', 'cylinder', [0, 1.827, -0.022], [0.137, 0.034, 0.121], 'graphite');+ shape('Fedora crown crease', 'sphere', [0, 1.944, -0.014], [0.082, 0.002, 0.023], 'black');}}function addRoom(builder, laboratory = false) {const { add, beam } = builder;- add('Timber floor', 'box', [0, -0.09, 0], [12, 0.15, 10], 'wood');- add('Rear plaster wall', 'box', [0, 2.2, -4.8], [12, 4.5, 0.15], 'plaster');- add('Side plaster wall', 'box', [-5.8, 2.2, 0], [0.15, 4.5, 10], 'plaster');- for (let index = 0; index < 4; index++) {- const horizontal = -4.2 + index * 2.8;- add('Tall daylight window', 'box', [horizontal, 2.75, -4.69], [1.8, 2.35, 0.04], 'window');+ add('Shadowed floor', 'box', [0, -0.1, 0], [12, 0.15, 12], 'wood');+ add('Rear plaster wall', 'box', [0, 2.3, -4.8], [12, 4.7, 0.15], 'plaster');+ add('Side plaster wall', 'box', [-5.8, 2.3, 0], [0.15, 4.7, 12], 'plaster');+ add('Ceiling in shadow', 'box', [0, 4.65, 0], [12, 0.12, 12], 'black');+ for (let plank = 0; plank < 30; plank++) {+ add('Floorboard joint', 'box', [-5.8 + plank * 0.4, -0.018, 0], [0.013, 0.006, 12], 'graphite');+ }+ for (let index = 0; index < 3; index++) {+ const horizontal = -3.6 + index * 3.3;+ add('Tall luminous window', 'box', [horizontal, 2.65, -4.69], [1.65, 2.8, 0.04], 'window');for (const side of [-1, 1]) {- add('Window jamb', 'box', [horizontal + side * 0.94, 2.75, -4.61], [0.08, 2.5, 0.12], 'wood');+ add('Window jamb', 'box', [horizontal + side * 0.86, 2.65, -4.61], [0.09, 2.95, 0.15], 'wood');}- for (let pane = 0; pane < 3; pane++) {- add('Window sash', 'box', [horizontal, 1.6 + pane * 1.15, -4.6], [1.9, 0.065, 0.12], 'wood');+ for (let slat = 0; slat < 19; slat++) {+ add('Venetian blind slat', 'box', [horizontal, 1.31 + slat * 0.148, -4.49], [1.72, 0.059, 0.13], 'wood', [-0.3, 0, 0]);}- add('Window mullion', 'box', [horizontal, 2.75, -4.6], [0.055, 2.4, 0.1], 'wood');+ add('Window central mullion', 'box', [horizontal, 2.65, -4.42], [0.06, 2.8, 0.1], 'wood');+ add('Window sill', 'box', [horizontal, 1.2, -4.4], [1.95, 0.12, 0.52], 'wood');+ }+ for (let index = 0; index < 8; index++) {+ add('Timber wall batten', 'box', [-5.3 + index * 1.5, 1.05, -4.63], [0.05, 2, 0.05], 'wood');}- add('Work desk top', 'box', [0, 0.84, 0], [3.5, 0.13, 1.65], laboratory ? 'steel' : 'wood');- for (const horizontal of [-1.5, 1.5]) {- for (const depth of [-0.65, 0.65]) {- beam('Desk leg', [horizontal, 0, depth], [horizontal, 0.78, depth], 0.055, 'wood');+ add('Work desk top', 'box', [0, 0.79, 0], [3.8, 0.10, 1.6], laboratory ? 'graphite' : 'wood');+ for (const horizontal of [-1.65, 1.65]) {+ for (const depth of [-0.63, 0.63]) {+ add('Square desk leg', 'box', [horizontal, 0.39, depth], [0.075, 0.78, 0.075], 'wood');}}- add('Chalkboard frame', 'box', [3.2, 2.2, -4.5], [3.1, 1.6, 0.15], 'wood');- add('Slate chalkboard', 'box', [3.2, 2.2, -4.4], [2.92, 1.4, 0.035], 'cloth');- for (let index = 0; index < 44; index++) {- const horizontal = 1.9 + index % 11 * 0.23;- const height = 1.72 + Math.floor(index / 11) * 0.27;- beam('Chalk calculation', [horizontal, height, -4.36], [horizontal + 0.12, height + Math.sin(index * 2.7) * 0.1, -4.36], 0.007, 'paper');+ add('Slate chalkboard frame', 'box', [3.4, 2.55, -4.36], [2.4, 1.55, 0.16], 'wood');+ add('Slate chalkboard surface', 'box', [3.4, 2.55, -4.25], [2.28, 1.41, 0.025], 'black');+ for (let index = 0; index < 65; index++) {+ const horizontal = 2.38 + index % 13 * 0.15;+ const height = 1.98 + Math.floor(index / 13) * 0.24;+ beam('Chalk equation stroke', [horizontal, height, -4.224], [horizontal + 0.07, height + Math.sin(index * 2.7) * 0.065, -4.224], 0.003, 'paper');}- for (let index = 0; index < 12; index++) {- add('Loose research sheet', 'box', [-1 + index % 4 * 0.48, 0.916 + index * 0.003, -0.4 + Math.floor(index / 4) * 0.3], [0.4, 0.004, 0.26], 'paper', [0, index * 0.13, 0]);+ for (let index = 0; index < 14; index++) {+ add('Loose research sheet', 'box', [-1.1 + index % 4 * 0.48, 0.846 + index * 0.002, -0.42 + Math.floor(index / 4) * 0.25], [0.4, 0.002, 0.26], 'paper', [0, index * 0.13, 0]);}- for (let shelf = 0; shelf < 3; shelf++) {- add('Bookshelf', 'box', [-4, 0.45 + shelf * 0.52, -3.5], [2.5, 0.06, 0.4], 'wood');- for (let index = 0; index < 16; index++) {- add('Cloth bound volume', 'box', [-5 + index * 0.135, 0.68 + shelf * 0.52, -3.5], [0.095, 0.4 + index % 3 * 0.025, 0.32], index % 3 ? 'wood' : 'cloth');+ for (let shelf = 0; shelf < 4; shelf++) {+ add('Bookshelf plank', 'box', [-4.6, 0.4 + shelf * 0.48, -3.8], [1.5, 0.055, 0.35], 'wood');+ for (let index = 0; index < 11; index++) {+ add('Cloth bound volume', 'box', [-5.2 + index * 0.12, 0.61 + shelf * 0.48, -3.8], [0.086, 0.34 + index % 3 * 0.02, 0.29], index % 3 ? 'wood' : 'cloth', [0, 0, index % 5 === 0 ? 0.09 : 0]);}}+ for (let index = 0; index < 3; index++) {+ const horizontal = -2.8 + index * 2.8;+ beam('Pendant lamp cable', [horizontal, 4.6, -1], [horizontal, 3.45, -1], 0.014, 'graphite');+ add('Pendant reflector', 'sphere', [horizontal, 3.4, -1], [0.28, 0.08, 0.28], 'graphite');+ add('Pendant warm bulb', 'sphere', [horizontal, 3.34, -1], [0.066, 0.045, 0.066], 'amber');+ }}function createOffice(meshes, laboratory = false) {const builder = createBuilder(meshes);addRoom(builder, laboratory);- addScientist(builder, [0, 0, -1.7], !laboratory);+ addScientist(builder, [0, 0, -1.7], !laboratory, laboratory ? 0.85 : -0.6);if (laboratory) {addScientist(builder, [2.8, 0, -1], false, -0.7);for (let index = 0; index < 8; index++) {builder.add('Vacuum amplifier housing', 'box', [-1.2 + index % 4 * 0.8, 1.09, -0.4 + Math.floor(index / 4) * 0.8], [0.54, 0.32, 0.4], 'graphite');- builder.add('Glowing glass tube', 'cylinder', [-1.2 + index % 4 * 0.8, 1.45, -0.4 + Math.floor(index / 4) * 0.8], [0.1, 0.42, 0.1], 'amber');+ const horizontal = -1.2 + index % 4 * 0.8;+ const depth = -0.4 + Math.floor(index / 4) * 0.8;+ builder.add('Bakelite valve socket', 'cylinder', [horizontal, 1.27, depth], [0.12, 0.055, 0.12], 'graphite');+ builder.add('Vacuum tube cathode', 'cylinder', [horizontal, 1.43, depth], [0.032, 0.24, 0.032], 'steel');+ for (let ring = 0; ring < 4; ring++) {+ builder.add('Vacuum tube grid hoop', 'thinRing', [horizontal, 1.31 + ring * 0.07, depth], [0.073, 0.073, 0.28], 'steel', [HALF_PI, 0, 0]);+ }+ for (const side of [-1, 1]) {+ builder.beam('Glowing valve filament', [horizontal + side * 0.048, 1.32, depth + 0.025], [horizontal + side * 0.045, 1.54, depth + 0.025], 0.004, 'amber');+ builder.beam('Valve glass edge reflection', [horizontal + side * 0.078, 1.29, depth], [horizontal + side * 0.071, 1.57, depth], 0.003, 'steel');+ }}} else {- builder.add('Brass desk lamp stem', 'cylinder', [1.3, 1.25, -0.3], [0.035, 0.7, 0.035], 'copper');- builder.add('Lamp shade', 'sphere', [1.3, 1.57, -0.3], [0.3, 0.1, 0.2], 'olive');+ builder.add('Brass desk lamp stem', 'cylinder', [-1.45, 1.11, 0.25], [0.035, 0.7, 0.035], 'copper');+ builder.add('Lamp shade', 'sphere', [-1.45, 1.43, 0.25], [0.24, 0.075, 0.17], 'olive');}return builder.parts;}function addVehicle(builder, position) {+ const firstPart = builder.parts.length;const { add, beam } = builder;const place = point => point.map((value, axis) => value + position[axis]);add('Army jeep chassis', 'box', place([0, 0.54, 0]), [1.6, 0.26, 3.1], 'olive');@@ -296,8 +413,14 @@ function addVehicle(builder, position) {for (const side of [-1, 1]) {add('Jeep body side', 'box', place([side * 0.73, 0.84, -0.5]), [0.12, 0.42, 1.55], 'olive');for (const depth of [-1, 1]) {- add('Rubber road tire', 'cylinder', place([side * 0.85, 0.47, depth]), [0.42, 0.22, 0.42], 'graphite', [0, 0, HALF_PI]);- add('Steel wheel hub', 'cylinder', place([side * 0.98, 0.47, depth]), [0.2, 0.025, 0.2], 'olive', [0, 0, HALF_PI]);+ add('Rubber road tire', 'tire', place([side * 0.85, 0.47, depth]), [0.33, 0.33, 0.45], 'black', [0, HALF_PI, 0]);+ add('Steel wheel hub', 'cylinder', place([side * 0.98, 0.47, depth]), [0.26, 0.025, 0.26], 'olive', [0, 0, HALF_PI]);+ add('Wheel axle cap', 'cylinder', place([side * 1.0, 0.47, depth]), [0.073, 0.045, 0.073], 'graphite', [0, 0, HALF_PI]);+ for (let lug = 0; lug < 6; lug++) {+ const angle = lug * FULL_TURN / 6;+ add('Wheel lug bolt', 'bolt', place([side * 1.02, 0.47 + Math.cos(angle) * 0.11, depth + Math.sin(angle) * 0.11]), [0.014, 0.023, 0.014], 'steel', [0, 0, HALF_PI]);+ }+ add('Rolled steel wheel fender', 'box', place([side * 0.74, 0.96, depth]), [0.5, 0.065, 0.93], 'olive');}beam('Windshield pillar', place([side * 0.7, 1.05, 0.3]), place([side * 0.7, 1.9, 0.15]), 0.035, 'olive');add('Headlight', 'sphere', place([side * 0.53, 1.01, 1.54]), [0.14, 0.14, 0.04], 'ceramic');@@ -306,8 +429,18 @@ function addVehicle(builder, position) {for (let index = 0; index < 8; index++) {add('Radiator grille slot', 'box', place([-0.4 + index * 0.115, 0.9, 1.56]), [0.04, 0.34, 0.025], 'graphite');}- add('Spare wheel', 'cylinder', place([0, 0.95, -1.54]), [0.42, 0.24, 0.42], 'graphite', [HALF_PI, 0, 0]);+ add('Spare wheel', 'tire', place([0, 0.95, -1.54]), [0.33, 0.33, 0.45], 'black');add('Driver seat', 'box', place([-0.38, 0.98, -0.55]), [0.55, 0.14, 0.65], 'cloth');+ add('Passenger seat cushion', 'box', place([0.37, 0.99, -0.55]), [0.55, 0.13, 0.65], 'cloth');+ for (const side of [-1, 1]) {+ add('Seat back', 'box', place([side * 0.37, 1.23, -0.82]), [0.55, 0.45, 0.12], 'cloth', [-0.12, 0, 0]);+ add('Hood fold seam', 'box', place([side * 0.69, 1.167, 0.9]), [0.012, 0.007, 1.05], 'graphite');+ beam('Body grab handle', place([side * 0.81, 0.91, -1.0]), place([side * 0.81, 0.91, -0.74]), 0.02, 'steel');+ }+ add('Steering wheel', 'thinRing', place([-0.37, 1.3, -0.15]), [0.21, 0.21, 0.8], 'graphite', [0.52, 0, 0]);+ beam('Steering column', place([-0.37, 1.3, -0.15]), place([-0.37, 0.82, 0.25]), 0.025, 'graphite');+ beam('Front bumper', place([-1.02, 0.6, 1.68]), place([1.02, 0.6, 1.68]), 0.07, 'olive');+ for (const part of builder.parts.slice(firstPart)) part.motionGroup = 'vehicle';}function createSettlement(meshes) {@@ -324,9 +457,13 @@ function createSettlement(meshes) {add('Pitched corrugated roof', 'box', [horizontal + pitch * 1.8, 3.15, depth], [4.15, 0.11, 6.2], 'graphite', [0, 0, pitch * -0.36]);}for (const offset of [-2.2, 0, 2.2]) {- add('Research hut window', 'box', [horizontal + offset, 1.6, depth + 2.83], [1, 0.9, 0.05], 'window');+ add('Research hut window', 'box', [horizontal + offset, 1.6, depth + 2.83], [1, 0.9, 0.05], { ...materials.graphite, color: [0.035, 0.055, 0.067], metallic: 0.35, roughness: 0.2 });add('Window divider', 'box', [horizontal + offset, 1.6, depth + 2.87], [0.06, 0.95, 0.06], 'wood');}+ add('Dark hut doorway', 'box', [horizontal - 1.1, 1.05, depth + 2.86], [0.8, 2.1, 0.035], 'black');+ for (let siding = 0; siding < 9; siding++) {+ add('Weatherboard siding seam', 'box', [horizontal, 0.25 + siding * 0.29, depth + 2.84], [7, 0.018, 0.018], 'graphite');+ }beam('Telephone pole', [side * 5.5, 0, depth], [side * 5.5, 6, depth], 0.095, 'wood');beam('Pole crossbar', [side * 4.5, 5.5, depth], [side * 6.5, 5.5, depth], 0.055, 'wood');if (index < 6) {@@ -334,43 +471,71 @@ function createSettlement(meshes) {}}}- addVehicle(builder, [1, 0, 8]);- addVehicle(builder, [-2, 0, -12]);+ addVehicle(builder, [1, -0.17, 8]);+ addVehicle(builder, [-2, -0.17, -12]);addScientist(builder, [4, 0, 6]);addScientist(builder, [5.3, 0, 5.5], false, -0.8);return builder.parts;}function addGadget(builder, center = [0, 2, 0]) {- const { add, beam } = builder;+ const firstPart = builder.parts.length;+ const { add, beam, cable } = builder;const place = point => point.map((value, axis) => value + center[axis]);- add('Gadget explosive vessel', 'sphere', center, [1, 1, 1], 'graphite');+ add('Gadget steel pressure vessel', 'sphere', center, [0.97, 1.02, 0.97], 'graphite');for (let latitude = 0; latitude < 5; latitude++) {- const elevation = -0.8 + latitude * 0.4;+ const elevation = -0.78 + latitude * 0.39;const radius = Math.sqrt(1 - elevation * elevation);- add('Spherical seam collar', 'ring', place([0, elevation, 0]), [radius, radius, radius], 'steel', [HALF_PI, 0, 0]);- for (let terminal = 0; terminal < 12; terminal++) {- const angle = terminal / 12 * FULL_TURN + latitude * 0.17;- const tip = [Math.cos(angle) * radius * 1.09, elevation * 1.09, Math.sin(angle) * radius * 1.09];- add('Gadget electrical terminal', 'sphere', place(tip), [0.075, 0.075, 0.075], 'ceramic');- const anchor = [Math.cos(angle) * 1.4, 1.5, Math.sin(angle) * 1.4];- const bend = [tip[0] * 1.22, tip[1] + 0.45, tip[2] * 1.22];- beam('Detonator cable lower', place(tip), place(bend), 0.017, 'copper');- beam('Detonator cable upper', place(bend), place(anchor), 0.017, 'graphite');+ add('Gadget circumferential seam', 'thinRing', place([0, elevation, 0]), [radius * 0.975, radius * 0.975, 1], 'steel', [HALF_PI, 0, 0]);+ for (let terminal = 0; terminal < 10; terminal++) {+ const angle = terminal / 10 * FULL_TURN + latitude * 0.18;+ const tip = [Math.cos(angle) * radius * 1.015, elevation * 1.015, Math.sin(angle) * radius * 1.015];+ const outer = [tip[0] * 1.11, tip[1] * 1.04, tip[2] * 1.11];+ beam('Radial connector socket', place(tip), place(outer), 0.055, 'steel');+ add('Ivory connector insulator', 'sphere', place(outer), [0.042, 0.042, 0.042], 'ceramic');+ const anchor = [Math.cos(angle) * 0.51, 1.73, Math.sin(angle) * 0.51];+ const bend = [tip[0] * (1.25 + latitude * 0.07), tip[1] + 0.6, tip[2] * (1.28 + latitude * 0.09)];+ cable('Sagging detonator lead', [place(outer), place(bend), place(anchor)], 0.011, terminal % 3 ? 'graphite' : 'copper', 7);+ add('Connector taped label', 'box', place([outer[0] * 1.04, outer[1], outer[2] * 1.04]), [0.037, 0.13, 0.018], 'paper', [0, HALF_PI - angle, 0.1]);}}- add('Suspension yoke', 'box', place([0, 1.55, 0]), [3, 0.12, 0.12], 'steel');- beam('Gadget hoist', place([0, 1.55, 0]), place([0, 3.2, 0]), 0.04, 'steel');+ for (let index = 0; index < 28; index++) {+ const angle = index / 28 * FULL_TURN;+ add('Equatorial hexagonal bolt', 'bolt', place([Math.cos(angle), 0, Math.sin(angle)]), [0.028, 0.058, 0.028], 'steel', [HALF_PI, 0, angle]);+ }+ add('Gadget top junction plate', 'cylinder', place([0, 1.72, 0]), [0.6, 0.045, 0.6], 'steel');+ for (const side of [-1, 1]) {+ beam('Suspension sling', place([side * 0.63, 0.8, 0]), place([side * 0.14, 2.03, 0]), 0.038, 'steel');+ }+ add('Hoist shackle', 'ring', place([0, 2.07, 0]), [0.15, 0.21, 0.25], 'steel');+ beam('Suspension cable', place([0, 2.28, 0]), place([0, 3.25, 0]), 0.026, 'steel');+ for (const part of builder.parts.slice(firstPart)) {+ part.motionGroup = 'gadget';+ part.motionPivot = place([0, 3.25, 0]);+ }}function createGadget(meshes) {const builder = createBuilder(meshes);- addRoom(builder, true);- addGadget(builder, [0, 2.25, -1.3]);+ const { add, beam } = builder;+ add('Assembly shed floor', 'box', [0, -0.12, 0], [10, 0.2, 12], 'wood');+ add('Dark shed rear wall', 'box', [0, 3, -4.6], [10, 6, 0.14], 'black');+ for (let index = 0; index < 28; index++) {+ add('Rough vertical wall plank', 'box', [-4.8 + index * 0.36, 2.7, -4.43], [0.31, 5.4, 0.07], 'wood');+ }for (const horizontal of [-2, 2]) {- builder.beam('Assembly gantry upright', [horizontal, 0, -1.3], [horizontal, 5.7, -1.3], 0.095);+ add('Heavy assembly gantry upright', 'box', [horizontal, 2.75, -1.3], [0.18, 5.5, 0.22], 'steel');+ beam('Gantry diagonal strut', [horizontal, 1.2, -1.3], [horizontal * 0.5, 5.5, -1.3], 0.038, 'steel');+ }+ add('Assembly gantry crossbar', 'box', [0, 5.5, -1.3], [4.5, 0.24, 0.24], 'steel');+ add('Slender side window', 'box', [-3.45, 3.25, -4.29], [1, 3.6, 0.025], 'window');+ for (let index = 0; index < 11; index++) {+ add('Shed window slat', 'box', [-3.45, 1.6 + index * 0.31, -4.24], [1.1, 0.065, 0.075], 'wood');+ }+ addGadget(builder, [0, 2.25, -1.3]);+ for (let index = 0; index < 10; index++) {+ add('Spare wire coil', 'thinRing', [-1.6 + index % 3 * 0.22, 0.04 + index * 0.006, 1.1], [0.25, 0.22, 0.4], 'graphite', [HALF_PI, 0, 0]);}- builder.beam('Assembly gantry lintel', [-2, 5.7, -1.3], [2, 5.7, -1.3], 0.095);return builder.parts;}@@ -385,85 +550,156 @@ function createControl(meshes) {add('Ivory meter face', 'cylinder', [horizontal, 1.26, -0.12], [0.177, 0.014, 0.177], 'paper');beam('Meter pointer', [horizontal, 1.277, -0.12], [horizontal - 0.08, 1.277, -0.02], 0.006, 'graphite');add('Console switch', 'cylinder', [horizontal, 1.32, 0.35], [0.035, 0.1, 0.035], 'steel');- add('Signal pilot light', 'sphere', [horizontal, 1.29, -0.48], [0.045, 0.025, 0.045], 'amber');+ add('Signal pilot light', 'sphere', [horizontal, 1.29, -0.48], [0.028, 0.019, 0.028], 'amber');+ for (let mark = 0; mark < 18; mark++) {+ const angle = 0.18 + mark * 0.15;+ const start = [horizontal + Math.cos(angle) * 0.14, 1.278, -0.12 + Math.sin(angle) * 0.14];+ const end = [horizontal + Math.cos(angle) * 0.12, 1.278, -0.12 + Math.sin(angle) * 0.12];+ beam('Engraved meter scale', start, end, 0.002, 'graphite');+ }+ add('Instrument label plate', 'box', [horizontal, 1.258, 0.12], [0.23, 0.008, 0.06], 'paper');}add('Red firing button', 'cylinder', [0.9, 1.31, 0.38], [0.12, 0.065, 0.12], 'copper');- addScientist(builder, [0, 0, -1.5], false);+ addScientist(builder, [0, 0, -1.5], false, 0.65);return builder.parts;}function createPortrait(meshes) {const builder = createBuilder(meshes);addDesert(builder);- addScientist(builder);- for (let index = 0; index < 20; index++) {- builder.add('Out of focus fence post', 'cylinder', [-12 + index * 1.3, 0.9, -12], [0.07, 1.8, 0.07], 'wood');+ addScientist(builder, [0, 0, 0], true, 3.36);+ const distantTower = createDesert(meshes).filter(part =>+ part.name.startsWith('Test tower') || part.name.startsWith('Tower') || part.name === 'Suspended test vessel');+ for (const part of distantTower) {+ part.matrix[12] += 15;+ part.matrix[14] -= 55;+ builder.parts.push(part);}return builder.parts;}function createSparks(meshes) {const builder = createBuilder(meshes);- for (let index = 0; index < 360; index++) {+ for (let index = 0; index < 480; index++) {const angle = index * 2.399963;- const radius = 0.15 + (index % 47) / 47 * 4.7;- const start = [Math.cos(angle) * radius, Math.sin(angle) * radius * 0.6, Math.sin(index * 1.31) * 2];- const end = [start[0] * 1.045, start[1] * 1.045 + 0.015, start[2] + 0.03];- builder.beam('Incandescent particle streak', start, end, 0.008 + index % 4 * 0.002, index % 7 ? 'particle' : 'core');+ const radius = 0.15 + (index % 67) / 67 * 5.7;+ const start = [Math.cos(angle) * radius, Math.sin(angle) * radius * 0.65, Math.sin(index * 1.31) * 2.5];+ const end = [start[0] * 1.08, start[1] * 1.08 + 0.015, start[2] + 0.04];+ builder.beam('Incandescent particle streak', start, end, 0.005 + index % 4 * 0.003, index % 7 ? 'particle' : 'core');}return builder.parts;}+function animateSet(parts, sceneName) {+ const moving = parts.filter(part =>+ sceneName === 'sparks' || sceneName === 'atom' ||+ (sceneName === 'waves' && part.name !== 'Black reflecting pool') ||+ Boolean(part.motionGroup) || part.name === 'Meter pointer' || part.name === 'Signal pilot light' ||+ part.name === 'Continuous sculpted head' || part.name === 'Fedora sweeping brim' ||+ part.name === 'Fedora tapered felt crown' || part.name === 'Fedora grosgrain band' || part.name === 'Fedora crown crease');+ const bases = moving.map(part => new Float32Array(part.matrix));+ const pivots = moving.map((part, index) => part.motionPivot ?? [bases[index][12] + 0.04, bases[index][13], bases[index][14] - 0.05]);+ const inversePivots = pivots.map(pivot => pivot.map(value => -value));+ const transform = mat4.create();+ const waveScale = [1, 1, 1];+ for (const part of moving) {+ if (part.name === 'Signal pilot light') part.material = { ...materials.amber };+ }+ return function animate(time) {+ moving.forEach((part, index) => {+ const base = bases[index];+ part.matrix.set(base);+ if (sceneName === 'sparks') {+ const cycle = (time * 0.27 + index * 0.037) % 1;+ const expansion = 0.12 + cycle * 1.65;+ part.matrix[12] = base[12] * expansion;+ part.matrix[13] = base[13] * expansion - cycle * cycle * 1.4;+ part.matrix[14] = base[14] + cycle * 2;+ } else if (sceneName === 'atom') {+ mat4.fromYRotation(transform, time * 0.13);+ mat4.multiply(part.matrix, transform, base);+ } else if (sceneName === 'waves') {+ const expansion = 1 + Math.sin(time * 0.65 + index * 0.12) * 0.07;+ waveScale[0] = expansion;+ waveScale[2] = expansion;+ mat4.scale(part.matrix, base, waveScale);+ part.matrix[13] += Math.sin(time * 1.2 + index * 0.22) * 0.006;+ } else if (part.motionGroup === 'gadget') {+ mat4.fromTranslation(transform, pivots[index]);+ mat4.rotateZ(transform, transform, Math.sin(time * 0.82) * 0.012);+ mat4.translate(transform, transform, inversePivots[index]);+ mat4.multiply(part.matrix, transform, base);+ } else if (part.motionGroup === 'vehicle') {+ part.matrix[14] += Math.sin(time * 0.065) * 1.8;+ part.matrix[13] += Math.sin(time * 5) * 0.012;+ } else if (part.name === 'Meter pointer') {+ mat4.fromTranslation(transform, pivots[index]);+ mat4.rotateY(transform, transform, Math.sin(time * 1.7 + index) * 0.25);+ mat4.translate(transform, transform, inversePivots[index]);+ mat4.multiply(part.matrix, transform, base);+ } else if (part.name === 'Signal pilot light') {+ part.material.emission = 1.8 + Math.sin(time * 2 + index * 0.7) * 0.6;+ } else {+ part.matrix[13] += Math.sin(time * 0.8) * 0.003;+ }+ });+ };+}+export function createFilmScenes() {const meshes = {- box: box(0.04, 3),- cylinder: cylinder(24),- bolt: cylinder(6),- sphere: sphere(24, 16),+ box: box(0.025, 2),+ head: createSculptedHead(),+ coat: createCoat(),+ landscape: createLandscape(),+ ridge: createRidge(),+ cylinder: cylinder(16, 0.02, 2),+ bolt: cylinder(6, 0.03, 1),+ sphere: sphere(32, 20),rock: sphere(12, 8),ring: torus(0.055, 64, 8),thinRing: torus(0.008, 96, 6),- gasRing: torus(0.045, 96, 8),+ tire: torus(0.25, 48, 12),};const studio = {- fogColor: [0.014, 0.018, 0.018], fogDensity: 0.018,+ fogColor: [0.014, 0.018, 0.018], fogDensity: 0.011,skyTop: [0.024, 0.035, 0.035], skyBottom: [0.1, 0.12, 0.11],- lightDirection: [-0.4, 0.8, 0.5], daylight: 0.85,+ lightDirection: [-0.4, 0.8, 0.5], daylight: 0.65,};const interior = {- ...studio, fogDensity: 0.008, daylight: 1.05,+ ...studio, fogDensity: 0.006, daylight: 0.75,skyTop: [0.12, 0.17, 0.18], skyBottom: [0.22, 0.23, 0.18],- lightDirection: [-0.45, 0.65, 0.8],+ lightDirection: [-0.85, 0.5, -0.35],};const desert = {- fogColor: [0.23, 0.18, 0.12], fogDensity: 0.004,- skyTop: [0.25, 0.36, 0.42], skyBottom: [0.62, 0.52, 0.35],- lightDirection: [-0.65, 0.48, 0.5], daylight: 1.1,+ fogColor: [0.25, 0.20, 0.13], fogDensity: 0.0035,+ skyTop: [0.11, 0.28, 0.38], skyBottom: [0.64, 0.57, 0.39],+ lightDirection: [-0.8, 0.29, -0.48], daylight: 1.05,};const night = {fogColor: [0.004, 0.007, 0.012], fogDensity: 0.007,- skyTop: [0.004, 0.009, 0.017], skyBottom: [0.04, 0.06, 0.08],- lightDirection: [-0.5, 0.6, 0.5], daylight: 0.42,+ skyTop: [0.035, 0.057, 0.083], skyBottom: [0.16, 0.19, 0.23],+ lightDirection: [-0.5, 0.6, 0.5], daylight: 0.24,};const desertShadows = { extent: 55, target: [0, 6, 0], eye: [-35, 45, 35], near: 1, far: 140 };- const set = (parts, environment, shadowBounds) => ({ parts, environment, ground: false, ...(shadowBounds ? { shadowBounds } : {}) });+ const set = (parts, environment, shadowBounds, name) => ({ parts, environment, ground: false, ...(shadowBounds ? { shadowBounds } : {}), ...(name ? { animate: animateSet(parts, name) } : {}) });const towerParts = createDesert(meshes);const towerBuilder = createBuilder(meshes);addGadget(towerBuilder, [0, 11.3, 0]);towerParts.push(...towerBuilder.parts);return {apparatus: set(createApparatus(meshes), studio),- office: set(createOffice(meshes), interior),- laboratory: set(createOffice(meshes, true), interior),- settlement: set(createSettlement(meshes), desert, desertShadows),- portrait: set(createPortrait(meshes), desert, desertShadows),- gadget: set(createGadget(meshes), interior),- control: set(createControl(meshes), interior),- atom: set(createAtom(meshes), { ...studio, daylight: 0.25, fogDensity: 0.035 }),- waves: set(createWaveChamber(meshes), studio),- sparks: set(createSparks(meshes), { ...night, daylight: 0.1 }),- desert: set(towerParts, desert, desertShadows),- night: set(towerParts, night, desertShadows),+ office: set(createOffice(meshes), interior, { extent: 7, target: [0, 1.6, -1], eye: [-8, 7, -4], near: 0.1, far: 30 }, 'office'),+ laboratory: set(createOffice(meshes, true), interior, { extent: 7, target: [0, 1.6, -1], eye: [-8, 7, -4], near: 0.1, far: 30 }, 'laboratory'),+ settlement: set(createSettlement(meshes), desert, desertShadows, 'settlement'),+ portrait: set(createPortrait(meshes), desert, { extent: 6, target: [0, 1, 0], eye: [-8, 5, -6], near: 0.1, far: 35 }, 'portrait'),+ gadget: set(createGadget(meshes), { ...interior, lightDirection: [-0.8, 0.4, 0.5], daylight: 0.9 }, { extent: 5, target: [0, 2.5, -1], eye: [-8, 7, 4], near: 0.1, far: 30 }, 'gadget'),+ control: set(createControl(meshes), { ...interior, lightDirection: [-0.4, 0.9, 0.3] }, { extent: 5, target: [0, 1, 0], eye: [-3, 8, 4], near: 0.1, far: 25 }, 'control'),+ atom: set(createAtom(meshes), { ...studio, daylight: 0.25, fogDensity: 0.035 }, undefined, 'atom'),+ waves: set(createWaveChamber(meshes), studio, undefined, 'waves'),+ sparks: set(createSparks(meshes), { ...night, daylight: 0.1 }, undefined, 'sparks'),+ desert: set(towerParts, desert, desertShadows, 'desert'),+ night: set(towerParts, night, desertShadows, 'night'),ignition: set(createIgnition(meshes), night, desertShadows),};}@@ -474,39 +710,39 @@ function shot(start, end, scene, eye, nextEye, target, nextTarget = target, fov}export const FILM_SHOTS = [- shot(0, 7, 'apparatus', [0.37, 0.73, 2.12], [0.65, 0.8, 2.5], [0, 0.5, 1.28], [0, 0.48, 1.1], [34, 36], 0.2),+ shot(0, 7, 'apparatus', [-1, 1.3, 2.5], [-0.75, 1.1, 2.35], [-0.45, 0.6, 1.0], [-0.3, 0.55, 1.05], [34, 36], 0.2),shot(7, 13, 'control', [1.8, 2.2, 2.2], [1.4, 1.9, 1.8], [0.3, 1.25, 0], [0.1, 1.25, 0], [35, 32]),shot(13, 20, 'apparatus', [-3.5, 1.8, 3.4], [-2.8, 1.3, 2.7], [-0.5, 0.5, 0], [0, 0.5, 0], [43, 40]),- shot(20, 29, 'office', [1.1, 1.9, 2.3], [0.8, 1.8, 1.3], [0, 1.65, -1.7], [0, 1.72, -1.7], [35, 32]),+ shot(20, 29, 'office', [2.4, 1.75, 0.6], [1.85, 1.72, 0.25], [-0.22, 1.52, -1.7], [-0.18, 1.56, -1.7], [30, 29]),shot(29, 34, 'sparks', [0, 0.3, 7], [0.6, 0.5, 6], [0, 0, 0], [0.2, 0, 0], [47, 45]),shot(34, 39, 'laboratory', [-3, 2.1, 3.7], [-2.5, 1.7, 2.8], [0, 1.25, 0], [0.4, 1.4, -0.5], [43, 39]),- shot(39, 45, 'desert', [29, 6, 37], [24, 7, 30], [0, 6, 0], [0, 7, 0], [44, 40]),- shot(45, 56, 'settlement', [0, 6.5, 46], [0.6, 4, 34], [0, 1.8, -9], [0, 1.8, -12], [48, 45]),- shot(56, 64, 'settlement', [7, 2.5, 16], [5.5, 2.1, 12], [1, 0.8, 8], [1, 1, 8], [41, 38]),- shot(64, 73, 'settlement', [8.4, 1.8, 11], [7.2, 1.8, 9.5], [4.6, 1.4, 5.7], [4.5, 1.6, 5.7], [36, 33]),- shot(73, 85, 'office', [-3.2, 1.8, 3], [-2.2, 1.9, 2], [0, 1.4, -1.7], [0, 1.6, -1.7], [41, 36], 1),- shot(85, 91, 'waves', [-3.8, 3.4, 5.3], [0.5, 2.2, 4.4], [-0.8, 0, 0], [0.8, 0.05, 0], [49, 42], 0.4),+ shot(39, 45, 'desert', [48, 2.1, 66], [43, 2.4, 60], [-12, 5.8, 0], [-10, 5.9, 0], [38, 37]),+ shot(45, 56, 'settlement', [0, 3.6, 54], [0.6, 2.8, 41], [1, 1.5, -9], [1, 1.5, -12], [41, 40]),+ shot(56, 64, 'settlement', [5.8, 1.2, 15], [4.8, 1.1, 13.5], [1, 0.8, 8.8], [1, 0.85, 9.2], [38, 36]),+ shot(64, 73, 'settlement', [8.4, 1.45, 10.8], [7.5, 1.5, 9.7], [4.5, 1.1, 5.7], [4.5, 1.2, 5.7], [33, 31]),+ shot(73, 85, 'office', [-3.1, 1.55, -0.5], [-2.6, 1.65, -0.8], [0.1, 1.38, -1.7], [0.1, 1.45, -1.7], [34, 32], 1),+ shot(85, 91, 'waves', [-2.8, 0.8, 4.2], [-1.8, 0.65, 3.8], [-0.3, 0, 0], [0.2, 0.02, 0], [40, 37], 0.4),shot(91, 98, 'atom', [0.5, 0.3, 6.8], [4.8, 2.5, 5.1], [0, 0, 0], [0, 0, 0], [48, 43]),shot(98, 105, 'gadget', [2.8, 3.1, 3.2], [2.2, 2.8, 2.6], [0, 2.25, -1.3], [0, 2.4, -1.3], [36, 32]),- shot(105, 110, 'office', [0.65, 1.85, -0.1], [0.45, 1.82, -0.4], [0, 1.8, -1.7], [0, 1.8, -1.7], [31, 28], 1),+ shot(105, 110, 'office', [1.25, 1.71, -0.95], [1.05, 1.71, -1.05], [0, 1.66, -1.7], [0, 1.66, -1.7], [30, 29], 1),shot(110, 118, 'desert', [4.7, 9.1, 6.2], [3.8, 10, 4.8], [0, 11, 0], [0, 11.3, 0], [36, 31]),shot(118, 126, 'gadget', [-1.6, 2.9, 1.4], [-1.2, 2.7, 1], [0, 2.5, -1.3], [0.1, 2.4, -1.3], [33, 30]),shot(126, 133, 'laboratory', [3.6, 2.2, 3.4], [2.8, 1.8, 2.6], [1.2, 1.4, -1.1], [1, 1.6, -1.4], [40, 35]),shot(133, 140, 'control', [-1.5, 2.1, 1.9], [-0.8, 1.8, 1.4], [0, 1.25, 0], [0.3, 1.25, 0], [35, 32]),- shot(140, 145, 'desert', [14, 1.5, 20], [11, 1.8, 16], [0, 8, 0], [0, 9, 0], [43, 40]),- shot(145, 154, 'portrait', [0.55, 1.9, 3], [0.3, 1.85, 2.6], [0, 1.76, 0], [0, 1.8, 0], [30, 27]),- shot(154, 161, 'night', [31, 4.4, 40], [27, 5, 35], [0, 7, 0], [0, 8, 0], [42, 39], 0.1, 1.05),- shot(161, 165, 'portrait', [0.2, 1.83, 1.5], [0.1, 1.82, 1.35], [0, 1.8, 0], [0, 1.8, 0], [28, 26]),+ shot(140, 145, 'desert', [16, 0.55, 25], [14, 0.7, 22], [0, 6.5, 0], [0, 7, 0], [40, 39]),+ shot(145, 154, 'portrait', [-0.4, 1.7, 3.7], [-0.2, 1.7, 3.3], [0.27, 1.48, 0], [0.28, 1.51, 0], [30, 28]),+ shot(154, 161, 'night', [50, 1.7, 74], [46, 2, 68], [-12, 6, 0], [-10, 6, 0], [38, 37], 0.1, 1.05),+ shot(161, 165, 'portrait', [0, 1.74, 1.8], [0.12, 1.74, 1.65], [0.12, 1.69, 0], [0.15, 1.69, 0], [28, 27]),shot(165, 168, 'control', [1.35, 1.85, 1.65], [1.1, 1.65, 1.3], [0.8, 1.27, 0.28], [0.85, 1.27, 0.3], [32, 28]),shot(168, 170, 'gadget', [1.7, 2.5, 0.8], [1.5, 2.5, 0.6], [0, 2.4, -1.3], [0, 2.4, -1.3], [30, 28]),shot(170, 172, 'sparks', [-0.3, 0.2, 5], [0.2, 0.1, 4.6], [0, 0, 0], [0, 0, 0], [45, 43]),shot(172, 174, 'night', [5, 10, 7], [4.5, 10.4, 6.5], [0, 11.3, 0], [0, 11.3, 0], [35, 32]),- shot(174, 176, 'office', [0.5, 1.83, -0.2], [0.35, 1.83, -0.4], [0, 1.8, -1.7], [0, 1.8, -1.7], [30, 28], 1),+ shot(174, 176, 'office', [1.2, 1.72, -0.95], [1.05, 1.72, -1.08], [0, 1.66, -1.7], [0, 1.66, -1.7], [30, 29], 1),shot(176, 178, 'control', [-0.3, 1.9, 1.5], [0.2, 1.8, 1.35], [0, 1.26, 0], [0.1, 1.26, 0], [32, 29]),shot(178, 179.5, 'sparks', [0, 0, 4.5], [0.3, 0.1, 4.1], [0, 0, 0], [0, 0, 0], [44, 42]),shot(179.5, 181, 'night', [28, 5, 38], [26, 5.5, 36], [0, 9, 0], [0, 9, 0], [42, 40]),- shot(181, 184, 'ignition', [28, 7, 39], [32, 9, 43], [0, 7, 0], [0, 11, 0], [48, 51], 0, 0.72),- shot(184, 187, 'ignition', [37, 11, 49], [40, 13, 53], [0, 11, 0], [0, 12, 0], [51, 53], 0, 0.72),+ shot(181, 184, 'ignition', [13, 5, 18], [16, 8, 22], [0, 6, 0], [0, 10, 0], [48, 51], 0, 0.85),+ shot(184, 187, 'ignition', [20, 10, 28], [23, 12, 32], [0, 12, 0], [0, 12, 0], [51, 53], 0, 0.85),];function smoothstep(value) {@@ -532,7 +768,7 @@ export function sampleFilm(time) {const ignitionTime = boundedTime - 181;const flash = ignitionTime >= 0 && ignitionTime < 0.7 ? Math.exp(-ignitionTime * 7) : 0;const visibility = smoothstep(boundedTime / 0.8) * (1 - smoothstep((boundedTime - 185.8) / 1.2));- const titleVisible = boundedTime >= 181;+ const titleVisible = boundedTime >= 183.3;return {scene: selected.scene,shotIndex: shotIndex < 0 ? FILM_SHOTS.length - 1 : shotIndex,@@ -544,16 +780,16 @@ export function sampleFilm(time) {subtitle: titleVisible ? 'A 67.js trailer study' : '',time: boundedTime,sceneTime: boundedTime - FILM_SHOTS.find(candidate => candidate.scene === selected.scene).start,- explosionProgress: selected.scene === 'ignition' ? smoothstep(ignitionTime / 3.6) : 0,+ explosionProgress: selected.scene === 'ignition' ? smoothstep(ignitionTime / 1.7) : 0,flash,- titleOpacity: titleVisible ? smoothstep((boundedTime - 181.65) / 1.15) * visibility : 0,+ titleOpacity: titleVisible ? smoothstep((boundedTime - 183.3) / 0.65) * visibility : 0,effects: {bloom: { strength: selected.scene === 'sparks' || selected.scene === 'atom' ? 0.3 : 0.12 },- saturation: 0.82,- contrast: 1.08,+ saturation: 0.72,+ contrast: 1.14,temperature: selected.scene === 'night' ? -0.08 : 0.035,- vignette: 0.22,- grain: 0.035,+ vignette: 0.12,+ grain: 0.018,},};}diff --git a/src/home-preview.js b/src/home-preview.jsindex 9c452405..51df37a6 100644--- a/src/home-preview.js+++ b/src/home-preview.js@@ -1,12 +1,16 @@import { Renderer67 } from './renderer.js';import { createWallEPreviewScene } from './wall-e-preview-scene.js';+import { approachValue } from './preview-transition.js';const canvas = document.querySelector('#home-preview');const status = document.querySelector('#home-preview-status');const assemblySlider = document.querySelector('#preview-assembly');const assemblyValue = document.querySelector('#preview-assembly-value');const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)');-const state = { yaw:0.6, pitch:0.28, distance:7.5, time:0, playing:!reducedMotion.matches, visible:false, assembly:0, speed:0, interacting:false };+const state = { yaw:0.6, pitch:0.28, distance:7.5, time:0, playing:!reducedMotion.matches, visible:false, assembly:0, assemblyTarget:0, speed:0, interacting:false, gaze:[0,0], gazeTarget:[0,0] };+const shadowEye = [-3,6,4];+const shadowTarget = [0,1,0];+const shadowBounds = { eye:[...shadowEye], target:[...shadowTarget], extent:6, near:0.1, far:20 };let renderer;let scene;let scheduledFrame = 0;@@ -25,13 +29,17 @@ function showError(error) {function draw() {if (!renderer || disposed || document.hidden || !state.visible) return;try {- const frame = scene.sample(state.time);+ const frame = scene.sample(state.time, { gaze:state.gaze });+ for (let axis = 0; axis < 3; axis++) {+ shadowBounds.eye[axis] = shadowEye[axis] + frame.rootOffset[axis];+ shadowBounds.target[axis] = shadowTarget[axis] + frame.rootOffset[axis];+ }renderer.updateParts(scene.parts);const distance = state.distance * (canvas.clientWidth < 500 ? 1.05 : 1) + state.assembly * 10;- const targetHeight = 1.5 + state.assembly * 0.35;+ const targetHeight = frame.target[1] + state.assembly * 0.35;renderer.render({- eye:[Math.sin(state.yaw) * Math.cos(state.pitch) * distance, targetHeight + Math.sin(state.pitch) * distance, Math.cos(state.yaw) * Math.cos(state.pitch) * distance],- target:[0,targetHeight,0], fov:40, time:state.time, exposure:1, armorColor:[0.73,0.43,0.065], armorSurface:[0.62,0.43], assemblyAmount:state.assembly, effects:{ ...frame.effects, vignette:0, grain:0 },+ eye:[frame.target[0] + Math.sin(state.yaw) * Math.cos(state.pitch) * distance, targetHeight + Math.sin(state.pitch) * distance, frame.target[2] + Math.cos(state.yaw) * Math.cos(state.pitch) * distance],+ target:[frame.target[0],targetHeight,frame.target[2]], fov:40, time:state.time, exposure:1, armorColor:[0.73,0.43,0.065], armorSurface:[0.62,0.43], assemblyAmount:state.assembly, effects:{ ...frame.effects, vignette:0, grain:0 },});} catch (error) {showError(error);@@ -40,20 +48,29 @@ function draw() {function animate(timestamp) {scheduledFrame = 0;- if (!state.playing || !state.visible || document.hidden || disposed) return;+ if ((!state.playing && state.assembly === state.assemblyTarget) || !state.visible || document.hidden || disposed) return;const elapsedSeconds = previousTime ? Math.min(0.1, (timestamp - previousTime) / 1000) : 0;- state.speed = Math.min(1, state.speed + elapsedSeconds / 1.2);- state.time += elapsedSeconds * state.speed;+ const wasTransitioning = state.assembly !== state.assemblyTarget;+ state.assembly = approachValue(state.assembly, state.assemblyTarget, elapsedSeconds);+ if (wasTransitioning && state.assembly === 0 && state.assemblyTarget === 0 && !state.interacting && !reducedMotion.matches) {+ state.playing = true;+ state.speed = 0;+ }+ if (state.playing) {+ state.speed = Math.min(1, state.speed + elapsedSeconds / 1.2);+ state.time += elapsedSeconds * state.speed;+ for (let axis = 0; axis < 2; axis++) state.gaze[axis] = approachValue(state.gaze[axis], state.gazeTarget[axis], elapsedSeconds, 0.22);+ }previousTime = timestamp;draw();- if (state.playing) scheduledFrame = requestAnimationFrame(animate);+ if (state.playing || state.assembly !== state.assemblyTarget) scheduledFrame = requestAnimationFrame(animate);}function synchronizePlayback() {cancelAnimationFrame(scheduledFrame);scheduledFrame = 0;previousTime = 0;- if (state.playing && state.visible && !document.hidden && !disposed) {+ if ((state.playing || state.assembly !== state.assemblyTarget) && state.visible && !document.hidden && !disposed) {scheduledFrame = requestAnimationFrame(animate);}}@@ -63,7 +80,7 @@ function initialize() {try {scene = createWallEPreviewScene();renderer = new Renderer67(canvas, scene.parts, {- ground:false, transparent:true, hdr:true, samples:4, pixelRatio:1.25, memoryBudgetMiB:192,+ ground:false, transparent:true, hdr:true, samples:4, pixelRatio:1.25, memoryBudgetMiB:192, shadowBounds,});window.__homePreview = { renderer, scene, state, draw };status.hidden = true;@@ -84,14 +101,15 @@ function reset() {}function pauseForAssembly() {+ const wasPlaying = state.playing;state.playing = false;state.speed = 0;- synchronizePlayback();+ if (wasPlaying || !scheduledFrame) synchronizePlayback();}function finishAssemblyInteraction() {state.interacting = false;- state.playing = state.assembly === 0 && !reducedMotion.matches;+ state.playing = state.assembly === 0 && state.assemblyTarget === 0 && !reducedMotion.matches;synchronizePlayback();}@@ -100,9 +118,10 @@ assemblySlider.addEventListener('pointerdown', () => {pauseForAssembly();});assemblySlider.addEventListener('input', () => {+ state.assemblyTarget = Number(assemblySlider.value) / 100;+ if (reducedMotion.matches) state.assembly = state.assemblyTarget;pauseForAssembly();- state.assembly = Number(assemblySlider.value) / 100;- const description = state.assembly === 0 ? 'Assembled' : Math.round(state.assembly * 100) + '% exploded';+ const description = state.assemblyTarget === 0 ? 'Assembled' : Math.round(state.assemblyTarget * 100) + '% exploded';assemblyValue.textContent = description;assemblySlider.setAttribute('aria-valuetext', description);draw();@@ -126,7 +145,13 @@ canvas.addEventListener('pointerdown', event => {canvas.setPointerCapture(event.pointerId);});canvas.addEventListener('pointermove', event => {- if (!pointer || pointer.id !== event.pointerId) return;+ if (!pointer) {+ const bounds = canvas.getBoundingClientRect();+ state.gazeTarget[0] = Math.max(-1, Math.min(1, (event.clientX - bounds.left) / bounds.width * 2 - 1));+ state.gazeTarget[1] = Math.max(-1, Math.min(1, 1 - (event.clientY - bounds.top) / bounds.height * 2));+ return;+ }+ if (pointer.id !== event.pointerId) return;state.yaw -= (event.clientX - pointer.x) * 0.008;if (event.pointerType !== 'touch') {state.pitch = Math.max(-1.1, Math.min(1.1, state.pitch + (event.clientY - pointer.y) * 0.008));@@ -135,6 +160,7 @@ canvas.addEventListener('pointermove', event => {pointer.y = event.clientY;draw();});+canvas.addEventListener('pointerleave', () => { state.gazeTarget.fill(0); });canvas.addEventListener('lostpointercapture', () => { pointer = undefined; });canvas.addEventListener('pointercancel', () => { pointer = undefined; });canvas.addEventListener('pointerup', event => {@@ -149,7 +175,7 @@ canvas.addEventListener('wheel', event => {canvas.addEventListener('keydown', event => {if (event.code === 'Space') {event.preventDefault();- if (state.assembly === 0 && !state.interacting) {+ if (state.assembly === 0 && state.assemblyTarget === 0 && !state.interacting) {state.playing = !state.playing;state.speed = 0;synchronizePlayback();@@ -201,8 +227,10 @@ document.addEventListener('visibilitychange', () => {synchronizePlayback();});reducedMotion.addEventListener('change', () => {- state.playing = !reducedMotion.matches && state.assembly === 0 && !state.interacting;+ if (reducedMotion.matches) state.assembly = state.assemblyTarget;+ state.playing = !reducedMotion.matches && state.assembly === 0 && state.assemblyTarget === 0 && !state.interacting;state.speed = 0;+ draw();synchronizePlayback();});window.addEventListener('pagehide', event => {diff --git a/src/main.js b/src/main.jsindex d491bc6d..8305417c 100644--- a/src/main.js+++ b/src/main.js@@ -4,6 +4,7 @@ import { Renderer67 } from './renderer.js';import { createModel } from './model.js';import { downloadGlb } from './export.js';import { assemblyOffset } from './assembly.js';+import { approachValue } from './preview-transition.js';const canvas = document.querySelector('#viewport');const renderParameters = new URLSearchParams(location.search);@@ -17,6 +18,7 @@ const state = { azimuth: 0.48, elevation: 0.18, distance: 7.8, finish: 'yellow',state.look = 'studio';state.targetHeight = 1.35;state.touring = false;+state.assemblyTarget = state.assembly;const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)');const looks = {studio: { lightDirection: [-3, 6, 4], temperature: 0, contrast: 1.02 },@@ -66,6 +68,8 @@ function draw(time) {state.assembly = Math.sin(progress * Math.PI) ** 2;syncAssembly();if (progress === 1) stopTour();+ } else if (!state.exporting && state.assembly !== state.assemblyTarget) {+ state.assembly = approachValue(state.assembly, state.assemblyTarget, Math.max(0, Math.min(0.05, (time - lastTime) / 1000)));}if (state.rotating && !dragging) state.azimuth += Math.min((time - lastTime) / 1000, 0.05) * 0.16;lastTime = time;@@ -74,7 +78,7 @@ function draw(time) {frameCount++;document.querySelector('#cpu').textContent = `${(cpuTotal / frameCount).toFixed(2)} ms CPU`;if (frameCount > 60) { cpuTotal = renderer.cpuMilliseconds; frameCount = 1; }- if (state.rotating || state.touring) invalidate();+ if (state.rotating || state.touring || state.assembly !== state.assemblyTarget) invalidate();}function invalidate() {@@ -98,19 +102,23 @@ try { initialize(); } catch (error) { notify(error.message, true); }document.querySelector('#assembly').addEventListener('input', (event) => {stopTour();- state.assembly = Number(event.target.value) / 100;+ state.assemblyTarget = Number(event.target.value) / 100;+ if (reducedMotion.matches) state.assembly = state.assemblyTarget;+ if (!scheduledFrame) lastTime = performance.now();document.querySelector('#assembly-value').textContent = `${event.target.value}%`;- event.target.setAttribute('aria-valuetext', state.assembly === 0 ? 'Assembled' : state.assembly === 1 ? 'Fully exploded' : `${event.target.value}% exploded`);+ event.target.setAttribute('aria-valuetext', state.assemblyTarget === 0 ? 'Assembled' : state.assemblyTarget === 1 ? 'Fully exploded' : `${event.target.value}% exploded`);invalidate();});function syncAssembly() {+ state.assemblyTarget = state.assembly;const percent = Math.round(state.assembly * 100);document.querySelector('#assembly').value = String(percent);document.querySelector('#assembly-value').textContent = `${percent}%`;document.querySelector('#assembly').setAttribute('aria-valuetext', `${percent}% exploded`);}function stopTour() {+ if (state.touring) state.assemblyTarget = state.assembly;state.touring = false;document.querySelector('#assembly-tour').textContent = 'Play assembly';}@@ -127,7 +135,7 @@ document.querySelectorAll('[data-view]').forEach(button => button.addEventListenstopTour();const views = { hero: [0.48, 0.18, 7.8, 1.35, 0], face: [0.12, 0.12, 3.8, 2.55, 0], machine: [0.7, 0.34, 6.8, 1.35, 0.65] };const [azimuth, elevation, distance, targetHeight, assembly] = views[button.dataset.view];- Object.assign(state, { azimuth, elevation, distance, targetHeight, assembly });+ Object.assign(state, { azimuth, elevation, distance, targetHeight, assembly, assemblyTarget:assembly });document.querySelectorAll('[data-view]').forEach(control => control.setAttribute('aria-pressed', String(control === button)));syncAssembly(); invalidate();}));@@ -143,7 +151,14 @@ document.querySelector('#save-model').addEventListener('click', () => {}, 'image/png');});document.addEventListener('visibilitychange', () => { if (document.hidden) stopTour(); });-reducedMotion.addEventListener('change', event => { if (event.matches) { stopTour(); state.rotating = false; document.querySelector('#rotate').setAttribute('aria-pressed', 'false'); } });+reducedMotion.addEventListener('change', event => {+ if (!event.matches) return;+ stopTour();+ state.rotating = false;+ state.assembly = state.assemblyTarget;+ document.querySelector('#rotate').setAttribute('aria-pressed', 'false');+ invalidate();+});document.querySelectorAll('[data-layer]').forEach((button) => button.addEventListener('click', () => {state.layer = button.dataset.layer;document.querySelectorAll('[data-layer]').forEach((control) => control.setAttribute('aria-pressed', String(control === button)));diff --git a/src/preview-transition.js b/src/preview-transition.jsnew file mode 100644index 00000000..f74958a8--- /dev/null+++ b/src/preview-transition.js@@ -0,0 +1,7 @@+export function approachValue(current, target, elapsedSeconds, responseSeconds = 0.14) {+ if (![current, target, elapsedSeconds, responseSeconds].every(Number.isFinite) || elapsedSeconds < 0 || responseSeconds <= 0) {+ throw new TypeError('Transitions require finite values, nonnegative time and a positive response.');+ }+ const next = current + (target - current) * -Math.expm1(-elapsedSeconds / responseSeconds);+ return Math.abs(next - target) < 0.0005 ? target : next;+}diff --git a/src/shaders.js b/src/shaders.jsindex 6ca8344d..454322b2 100644--- a/src/shaders.js+++ b/src/shaders.js@@ -118,6 +118,29 @@ uniform float hdrEnabled;out vec4 outputColor;const float PI = 3.14159265359;+float terrainHash(vec2 position) {+ vec3 seed = fract(vec3(position.xyx) * 0.1031);+ seed += dot(seed, seed.yzx + 33.33);+ return fract((seed.x + seed.y) * seed.z);+}++// Value noise and its analytic gradient avoid extra texture fetches for sand relief.+vec3 terrainNoise(vec2 position) {+ vec2 cell = floor(position);+ vec2 fraction = fract(position);+ vec2 blend = fraction * fraction * (3.0 - 2.0 * fraction);+ vec2 derivative = 6.0 * fraction * (1.0 - fraction);+ float lowerLeft = terrainHash(cell);+ float lowerRight = terrainHash(cell + vec2(1.0, 0.0));+ float upperLeft = terrainHash(cell + vec2(0.0, 1.0));+ float upperRight = terrainHash(cell + vec2(1.0, 1.0));+ float lower = mix(lowerLeft, lowerRight, blend.x);+ float upper = mix(upperLeft, upperRight, blend.x);+ return vec3(mix(lower, upper, blend.y),+ mix(lowerRight - lowerLeft, upperRight - upperLeft, blend.y) * derivative.x,+ (upper - lower) * derivative.y);+}+vec3 fresnel(float cosine, vec3 reflectance) {return reflectance + (1.0 - reflectance) * pow(1.0 - cosine, 5.0);}@@ -202,8 +225,19 @@ void main() {normal = normalize(normal + vec3(sin(worldPosition.z * 12.0), sin(worldPosition.x * 9.0), cos(worldPosition.y * 11.0)) * 0.06);}if (surface.w == 5.0) {- float mottling = sin(worldPosition.x * 3.3) * sin(worldPosition.z * 4.1) * 0.5 + sin(worldPosition.x * 0.9 + worldPosition.z * 1.7) * 0.5;- color *= 0.94 + mottling * 0.06;+ vec2 terrainPosition = worldPosition.xz + worldPosition.y * vec2(0.31, 0.43);+ float footprint = max(fwidth(terrainPosition.x), fwidth(terrainPosition.y));+ vec3 broad = terrainNoise(terrainPosition * 0.32);+ vec3 ridges = terrainNoise(terrainPosition * 3.2 + vec2(5.2, 11.7));+ vec3 grains = terrainNoise(terrainPosition * 32.0 + vec2(17.1, 4.3));+ float ridgeWeight = 1.0 - smoothstep(0.25, 0.8, footprint * 3.2);+ float grainWeight = 1.0 - smoothstep(0.2, 0.7, footprint * 32.0);+ float ridgeColor = 1.0 - abs(ridges.x * 2.0 - 1.0);+ color *= 0.82 + broad.x * 0.26 + (ridgeColor - 0.5) * 0.12 * ridgeWeight + (grains.x - 0.5) * 0.1 * grainWeight;+ vec2 relief = ridges.yz * 0.08 * ridgeWeight + grains.yz * 0.11 * grainWeight;+ vec3 perturbation = vec3(-relief.x, 0.0, -relief.y);+ normal = normalize(normal + perturbation - normal * dot(perturbation, normal));+ roughness = clamp(roughness + (grains.x - 0.5) * 0.06 * grainWeight, 0.075, 1.0);}float visibility = shadowVisibility(normal);vec3 keyColor = mix(vec3(5.2, 4.7, 4.1), vec3(3.7, 3.4, 2.9) * daylight, worldMode);diff --git a/src/wall-e-preview-scene.js b/src/wall-e-preview-scene.jsindex 7cdb10b9..270c45cf 100644--- a/src/wall-e-preview-scene.js+++ b/src/wall-e-preview-scene.js@@ -3,7 +3,7 @@ import { createModel } from './model.js';import { EFFECT_PRESETS } from './effects.js';const DURATION = 12;-const TRAVEL = 0.28;+const DRIVE_SPEED = 0.16;// Keep this shoe centerline aligned with the polygon in createModel().const TRACK_OUTLINE = [[0.095, -0.59], [0.095, 0.6], [0.32, 0.73], [0.66, 0.48], [0.7, -0.37], [0.38, -0.73]];const WHEEL_PART_NAMES = new Set([@@ -68,10 +68,45 @@ function sampleTrack(path, distance, result) {result.angle = angle;}+function createJoint(pivot, entries) {+ return { pivot, inversePivot: pivot.map(value => -value), entries, local: mat4.create(), world: mat4.create() };+}++function poseJoint(joint, parent, pitch, yaw = 0, roll = 0) {+ mat4.fromTranslation(joint.local, joint.pivot);+ mat4.rotateY(joint.local, joint.local, yaw);+ mat4.rotateX(joint.local, joint.local, pitch);+ mat4.rotateZ(joint.local, joint.local, roll);+ mat4.translate(joint.local, joint.local, joint.inversePivot);+ mat4.multiply(joint.world, parent, joint.local);+ for (const entry of joint.entries) mat4.multiply(entry.part.matrix, joint.world, entry.base);+}++function createCharacterRig(entries) {+ const body = createJoint([0, 0.72, 0], entries.filter(entry => !entry.part.assembly.section.endsWith('track assembly')));+ const neckEntries = body.entries.filter(entry => entry.part.assembly.section === 'Neck linkage' || /eye housing|optical mechanism|lens assembly/.test(entry.part.assembly.section));+ const neck = createJoint([0, 1.86, -0.04], neckEntries.filter(entry => entry.part.name !== 'Neck yaw bearing'));+ const head = createJoint([0, 2.38, 0.12], neck.entries.filter(entry => entry.part.assembly.section !== 'Neck linkage' || entry.part.name === 'Binocular central bridge'));+ const arms = [-1, 1].map(side => {+ const section = side < 0 ? 'Left arm and claw' : 'Right arm and claw';+ const armEntries = entries.filter(entry => entry.part.assembly.section === section);+ const shoulder = createJoint([side * 0.8, 1.55, 0.07], armEntries.filter(entry => entry.part.name !== 'Shoulder pivot'));+ const elbow = createJoint([side * 1.015, 1.25, 0.22], shoulder.entries.filter(entry => /^(Forearm|Claw)/.test(entry.part.name)));+ const wrist = createJoint([side * 1.065, 1.13, 0.49], elbow.entries.filter(entry => entry.part.name.startsWith('Claw')));+ const fingers = [-1, 1].map(finger => createJoint(+ [side * 1.065 + finger * 0.09, 1.13, 0.675],+ wrist.entries.filter(entry => entry.part.name !== 'Claw palm' && Math.sign(entry.base[12] - side * 1.065) === finger),+ ));+ return { side, shoulder, elbow, wrist, fingers };+ });+ return { body, neck, head, arms };+}+export function createWallEPreviewScene() {const parts = createModel();const entries = parts.map(part => ({ part, base: mat4.clone(part.matrix) }));const path = createTrackPath();+ const rig = createCharacterRig(entries);const shoes = entries.filter(({ part }) => part.name === 'Caterpillar steel shoe' || part.name === 'Caterpillar rubber traction pad');for (const shoe of shoes) {shoe.distance = trackDistance(shoe.base, path.edges);@@ -88,17 +123,44 @@ export function createWallEPreviewScene() {wheel.radius = Math.hypot(wheel.center.base[0], wheel.center.base[1], wheel.center.base[2]);}const rotation = mat4.create();+ const root = mat4.create();const trackPosition = {};- const frame = { target: [0, 1.5, 0], effects: EFFECT_PRESETS.neutral };+ const frame = { target: [0, 1.5, 0], rootOffset: [0, 0, 0], effects: EFFECT_PRESETS.neutral };- function sample(time) {+ // Gaze is normalized screen input: positive x looks right, positive y looks up.+ // The caller owns gaze smoothing and playback/assembly pauses.+ function sample(time, interaction = {}) {if (!Number.isFinite(time)) throw new TypeError('WALL·E preview time must be finite seconds.');+ const gaze = interaction.gaze;+ if (gaze !== undefined && (!Array.isArray(gaze) || gaze.length !== 2 || !gaze.every(Number.isFinite))) {+ throw new TypeError('WALL·E gaze must contain two finite normalized coordinates.');+ }+ const gazeX = gaze ? Math.max(-1, Math.min(1, gaze[0])) : 0;+ const gazeY = gaze ? Math.max(-1, Math.min(1, gaze[1])) : 0;const phase = (time % DURATION) / DURATION * Math.PI * 2;- const travel = TRAVEL * Math.sin(phase);+ const travel = time * DRIVE_SPEED;+ if (!Number.isFinite(Math.fround(travel))) throw new RangeError('WALL·E travel exceeds the Float32 scene coordinate range.');+ frame.rootOffset[2] = travel;+ frame.target[2] = travel;+ mat4.fromTranslation(root, frame.rootOffset);for (const { part, base } of entries) {part.matrix.set(base);part.matrix[14] += travel;}+ const curiosity = Math.sin(phase);+ const secondary = Math.sin(phase * 2);+ poseJoint(rig.body, root, 0.009 * secondary, 0, 0.012 * curiosity);+ rig.body.world[13] += 0.008 * Math.sin(phase * 4);+ for (const entry of rig.body.entries) mat4.multiply(entry.part.matrix, rig.body.world, entry.base);+ poseJoint(rig.neck, rig.body.world, 0, 0.38 * curiosity + 0.32 * gazeX);+ poseJoint(rig.head, rig.neck.world, 0.13 * secondary - 0.18 * gazeY, 0, 0.09 * curiosity);+ for (const arm of rig.arms) {+ const gesture = arm.side * curiosity;+ poseJoint(arm.shoulder, rig.body.world, -0.16 * gesture, 0, arm.side * 0.035 * secondary);+ poseJoint(arm.elbow, arm.shoulder.world, -0.2 * gesture);+ poseJoint(arm.wrist, arm.elbow.world, 0.08 * secondary, 0.07 * gesture);+ arm.fingers.forEach((finger, index) => poseJoint(finger, arm.wrist.world, 0, (index === 0 ? -1 : 1) * 0.14 * gesture));+ }for (const shoe of shoes) {sampleTrack(path, shoe.distance - travel, trackPosition);mat4.fromXRotation(rotation, trackPosition.angle - shoe.angle);@@ -108,7 +170,7 @@ export function createWallEPreviewScene() {shoe.part.matrix[14] = trackPosition.depth + travel;}for (const wheel of wheels) {- const angle = travel / wheel.radius;+ const angle = (travel % (Math.PI * 2 * wheel.radius)) / wheel.radius;const cosine = Math.cos(angle);const sine = Math.sin(angle);const height = wheel.base[13] - wheel.center.base[13];@@ -122,5 +184,5 @@ export function createWallEPreviewScene() {return frame;}- return { parts, duration: DURATION, sample };+ return { parts, duration: DURATION, driveSpeed: DRIVE_SPEED, sample };}diff --git a/tests/film.test.js b/tests/film.test.jsindex 8be78a00..c9a6c2e9 100644--- a/tests/film.test.js+++ b/tests/film.test.js@@ -24,13 +24,15 @@ test('187-second study has contiguous authored cuts, a late detonation and termiassert.equal(sampleFilm(2).fade, 0);assert.equal(sampleFilm(FILM_DURATION).fade, 1);assert.equal(sampleFilm(180.9).title, '');- assert.equal(sampleFilm(183).title, 'OPPENHEIMER');- assert.equal(sampleFilm(183).subtitle, 'A 67.js trailer study');- assert.equal(sampleFilm(183).titleOpacity, 1);+ assert.equal(sampleFilm(183).title, '');+ assert.equal(sampleFilm(185).title, 'OPPENHEIMER');+ assert.equal(sampleFilm(185).subtitle, 'A 67.js trailer study');+ assert.equal(sampleFilm(185).titleOpacity, 1);assert.equal(sampleFilm(180.9).explosionProgress, 0);assert.equal(sampleFilm(181).sceneTime, 0);assert.equal(sampleFilm(181).flash, 1);- assert.equal(sampleFilm(185).explosionProgress, 1);+ assert.equal(sampleFilm(183).explosionProgress, 1);+ assert.ok(sampleFilm(182).explosionProgress > 0.6);});test('random-access frame samples are finite and independent of playback order', () => {@@ -68,7 +70,7 @@ test('camera motion is continuous and eases to rest within each shot', () => {}});-test('sets keep shared static geometry, valid surfaces and the 384 MiB target budget', () => {+test('sets keep shared geometry, valid surfaces and the 384 MiB target budget', () => {const scenes = createFilmScenes();assert.ok(Object.keys(scenes).length >= 8);const referencedSets = new Set(FILM_SHOTS.map(shot => shot.scene));@@ -121,3 +123,38 @@ test('sets keep shared static geometry, valid surfaces and the 384 MiB target buassert.ok(scenes.settlement.parts.some(part => part.name === 'Army jeep chassis'));console.log(JSON.stringify(budgets));});+++test('physical motion is visible, deterministic and retains render identities across seeks', () => {+ const scenes = createFilmScenes();+ const snapshot = scene => scene.parts.map(part => ({ matrix: Array.from(part.matrix), color: [...part.material.color], emission: part.material.emission }));+ for (const name of ['sparks', 'atom', 'waves', 'control', 'gadget', 'settlement', 'portrait', 'desert', 'night']) {+ const scene = scenes[name];+ const identities = scene.parts.map(part => ({ part, geometry: part.geometry, matrix: part.matrix }));+ scene.animate(2.75);+ const expected = snapshot(scene);+ scene.animate(7.3);+ assert.notDeepEqual(snapshot(scene), expected, name);+ scene.animate(0);+ scene.animate(2.75);+ assert.deepEqual(snapshot(scene), expected, name);+ scene.parts.forEach((part, index) => {+ assert.equal(part, identities[index].part);+ assert.equal(part.geometry, identities[index].geometry);+ assert.equal(part.matrix, identities[index].matrix);+ assert.ok(Array.from(part.matrix).every(Number.isFinite));+ });+ }+});+++test('tailored figure surfaces face outward and keep a closed shoulder silhouette', () => {+ const scene = createFilmScenes().portrait;+ const coat = scene.parts.find(part => part.name === 'Sculpted tailored jacket').geometry;+ let farthest = 0;+ for (let index = 3; index < coat.positions.length; index += 3) {+ if (coat.positions[index] > coat.positions[farthest]) farthest = index;+ }+ assert.ok(coat.normals[farthest] > 0.5);+ assert.ok(scene.parts.some(part => part.name === 'Tailored shoulder line'));+});diff --git a/tests/preview-transition.test.js b/tests/preview-transition.test.jsnew file mode 100644index 00000000..e6aca48f--- /dev/null+++ b/tests/preview-transition.test.js@@ -0,0 +1,25 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { approachValue } from '../src/preview-transition.js';++test('assembly approaches arbitrary targets smoothly without overshooting', () => {+ let position = 0;+ position = approachValue(position, 0.73, 1 / 60);+ assert.ok(position > 0 && position < 0.73);+ for (let frame = 0; frame < 120; frame++) position = approachValue(position, 0.73, 1 / 60);+ assert.equal(position, 0.73);+ const reversed = approachValue(position, 0.12, 1 / 60);+ assert.ok(reversed < position && reversed > 0.12);+});++test('transition timing is independent of display refresh and reaches fully assembled', () => {+ const sample = frequency => {+ let position = 1;+ for (let frame = 0; frame < frequency / 2; frame++) position = approachValue(position, 0, 1 / frequency);+ return position;+ };+ assert.ok(Math.abs(sample(60) - sample(144)) < 1e-12);+ assert.equal(approachValue(0.001, 0, 0.2), 0);+ assert.throws(() => approachValue(0, 1, -1), TypeError);+ assert.throws(() => approachValue(0, NaN, 0.1), TypeError);+});diff --git a/tests/wall-e-preview-scene.test.js b/tests/wall-e-preview-scene.test.jsindex 35cfdb60..9222ffb2 100644--- a/tests/wall-e-preview-scene.test.js+++ b/tests/wall-e-preview-scene.test.js@@ -34,19 +34,21 @@ test('preview preserves the assembled model, all instance identities and assembl}});-test('absolute sampling is deterministic, periodic and rejects invalid seconds', () => {+test('absolute sampling and gaze are deterministic and reject invalid input', () => {const scene = createWallEPreviewScene();- const frame = scene.sample(1.25);+ const interaction = { gaze: [0.5, -0.3] };+ const frame = structuredClone(scene.sample(1.25, interaction));const first = snapshot(scene);scene.sample(8);scene.sample(-100);- assert.deepEqual(scene.sample(1.25), frame);+ assert.deepEqual(scene.sample(1.25, interaction), frame);assert.deepEqual(snapshot(scene), first);- scene.sample(scene.duration + 1.25);- assert.deepEqual(snapshot(scene), first);- assert.deepEqual(frame.target, [0, 1.5, 0]);+ assert.deepEqual(frame.target, [0, 1.5, 1.25 * scene.driveSpeed]);+ assert.deepEqual(frame.rootOffset, [0, 0, 1.25 * scene.driveSpeed]);assert.equal(frame.effects.bloom.strength, 0);for (const invalid of [NaN, Infinity, -Infinity, undefined, '1']) assert.throws(() => scene.sample(invalid), TypeError);+ for (const gaze of [[NaN, 0], [0], '1', [0, Infinity]]) assert.throws(() => scene.sample(1, { gaze }), TypeError);+ assert.throws(() => scene.sample(Number.MAX_VALUE), RangeError);});test('both caterpillars circulate with coherent shoe/pad pairs and stationary ground contact', () => {@@ -89,11 +91,11 @@ test('wheel bolts orbit their own sprockets and retain their radius and x coordiconst radius = Math.hypot(base[index][13] - base[centerIndex][13], base[index][14] - base[centerIndex][14]);close(Math.hypot(part.matrix[13] - center.matrix[13], part.matrix[14] - center.matrix[14]), radius);close(part.matrix[12], base[index][12]);- assert.ok(Math.hypot(part.matrix[13] - base[index][13], part.matrix[14] - base[index][14] - 0.28) > 0.02);+ assert.ok(Math.hypot(part.matrix[13] - base[index][13], part.matrix[14] - base[index][14] - 3 * scene.driveSpeed) > 0.02);}});-test('travel eases through reversals and every transform stays continuous across the loop seam', () => {+test('forward travel never reverses or resets and articulation stays continuous at period boundaries', () => {const scene = createWallEPreviewScene();for (const boundary of [3, 9, 12]) {scene.sample(boundary - 0.0001);@@ -101,12 +103,62 @@ test('travel eases through reversals and every transform stays continuous acrossscene.sample(boundary + 0.0001);scene.parts.forEach((part, index) => part.matrix.forEach((value, axis) => close(value, before[index][axis], 0.0002)));}- scene.sample(3);- close(scene.parts[0].matrix[14], 0.28);- scene.sample(9);- close(scene.parts[0].matrix[14], -0.28);- for (let time = 0; time < scene.duration; time += 0.125) {+ let previousTravel = -Infinity;+ for (let time = -1; time < scene.duration * 2; time += 0.125) {scene.sample(time);+ const travel = scene.parts[0].matrix[14];+ assert.ok(travel > previousTravel);+ close(travel, time * scene.driveSpeed);+ previousTravel = travel;for (const part of scene.parts) assert.ok(Array.from(part.matrix).every(Number.isFinite));}});++test('head, neck, arm and finger joints move attached groups and repeat relative to forward root', () => {+ const scene = createWallEPreviewScene();+ const base = snapshot(scene);+ scene.sample(2.5);+ const posed = snapshot(scene);+ const names = ['Neck articulated spine', 'Eye dark glass', 'Upper arm yellow housing', 'Forearm steel linkage', 'Claw palm', 'Claw finger root'];+ for (const name of names) {+ const index = scene.parts.findIndex(part => part.name === name);+ assert.ok(posed[index].slice(0, 12).some((value, axis) => Math.abs(value - base[index][axis]) > 0.001), name);+ }+ const eyeParts = scene.parts.flatMap((part, index) => part.name === 'Eye dark glass' || part.name === 'Eye central pupil' ? [index] : []);+ for (let index = 0; index < eyeParts.length; index += 2) {+ const glass = eyeParts[index];+ const pupil = eyeParts[index + 1];+ const distance = matrices => Math.hypot(...[12, 13, 14].map(axis => matrices[glass][axis] - matrices[pupil][axis]));+ close(distance(posed), distance(base));+ }+ scene.sample(2.5 + scene.duration);+ for (let index = 0; index < scene.parts.length; index++) {+ if (scene.parts[index].assembly.section.endsWith('track assembly')) continue;+ scene.parts[index].matrix.forEach((value, axis) => close(value - (axis === 14 ? scene.duration * scene.driveSpeed : 0), posed[index][axis]));+ }+ const root = scene.sample(10000).rootOffset;+ for (const part of scene.parts) {+ assert.ok(Math.abs(part.matrix[12]) < 1.6);+ assert.ok(part.matrix[13] > 0 && part.matrix[13] < 3.3);+ assert.ok(Math.abs(part.matrix[14] - root[2]) < 1.6);+ }+});++test('pointer gaze changes the attached head without changing the drive or arms', () => {+ const scene = createWallEPreviewScene();+ scene.sample(2, { gaze: [-1, -1] });+ const left = snapshot(scene);+ scene.sample(2, { gaze: [1, 1] });+ const right = snapshot(scene);+ for (let index = 0; index < scene.parts.length; index++) {+ const part = scene.parts[index];+ if (part.assembly.section.endsWith('track assembly') || part.assembly.section.endsWith('arm and claw')) {+ assert.deepEqual(right[index], left[index]);+ }+ }+ const eye = scene.parts.findIndex(part => part.name === 'Eye dark glass');+ assert.ok(Math.abs(right[eye][12] - left[eye][12]) > 0.05);+ assert.ok(Math.abs(right[eye][13] - left[eye][13]) > 0.02);+ scene.sample(2, { gaze: [10, 10] });+ assert.deepEqual(snapshot(scene), right);+});