3D engine that AI agents drive
Refresh trailer study, streamline Downloads and optimize bounded video export
Nguyen Xuan Anc36ddba2a986
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7c5d3896..d5e88904 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,16 @@# Changelog+## 0.3.2++- Add transparent render targets with MSAA coverage and continuous homepage animation.+- Showcase WALL·E with moving caterpillars and a slider that pauses driving until reassembly.+- Replace the short film with a 187-second Oppenheimer trailer study, 33 shots and 13 procedural sets.+- Enable HDR in the film player and extend bounded video exports to four minutes.+- Speed up video capture using high-quality JPEG frames while keeping PNG stills lossless.+- Add direct CDP capture, fast lossless PNG mode, automatic encoder preflight, stage timings and progress estimates.+- Simplify Downloads and unify the homepage, Docs and Downloads footer.++## 0.3.1- Rebuild the homepage around the scene-to-film workflow and a real video showcase.diff --git a/README.md b/README.mdindex c759cd4e..4ca53180 100644--- a/README.md+++ b/README.md@@ -64,12 +64,12 @@ The library is ESM and bundles its runtime dependencies. Core exports include `R| `/` | Installation, downloads, release metadata and examples. || `/object.html` | WALL·E studio with orbit, zoom, explosion, layers, finishes and GLB export. || `/nature.html` | Silverwater valley with viewpoints, daylight, wind, detail settings and water ripples. |-| `/film.html` | CRITICAL, a 32-second procedural film with playback and timeline controls. |+| `/film.html` | Oppenheimer, a 187-second procedural trailer study with playback and timeline controls. || `/motion.html` | Clockwork orbit, a 12-second keyframe animation with HDR and landscape, portrait and square framing. || `/view2d.html` | Flat vector scenes and front, right, top or perspective model inspection. || `/assets.html` | GLB loading, texture inspection, rigid animation, orbit controls and PNG capture. |-CRITICAL combines mechanical details, atomic orbits, waves, a desert test tower and a volumetric ignition sequence.+The Oppenheimer study contains 33 shots across 13 procedural sets: a laboratory, research town, scientist portraits, atomic imagery, a wired Gadget and the night test.It uses an original synthesized score. The playable MP4 is in `public/media/critical.mp4`.The nature world uses seeded terrain and instanced vegetation. Its balanced preset contains 2,673 parts and 585,470 triangles.@@ -89,6 +89,10 @@ npm run render -- --kind image --scene view2d --aspect square --backend cpu --prnpm run render -- --kind video --scene assets --asset model.glb --duration 2 --output artifacts/model.mp4```+Video 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.+| Preset | Dimensions | MSAA samples | FPS | Target budget || --- | --- | ---: | ---: | ---: || `preview` | 960 × 540 | 2 | 24 | 256 MiB |@@ -157,7 +161,7 @@ Blender-level realism remains a visual target. 67.js does not provide Three.js A## CreditsWALL·E is a Disney/Pixar character. This repository authors its study as procedural geometry without external model assets.-CRITICAL draws inspiration from the visual themes of the [official Oppenheimer trailer](https://www.youtube.com/watch?v=bK6ldnjE3Y0).+The Oppenheimer study follows the shot progression of [Universal Pictures’ New Trailer](https://www.youtube.com/watch?v=uYPbbksJxIg) using stylized procedural sets and an original synthesized score.It includes no film footage, dialogue or soundtrack samples.- [Three.js](https://threejs.org/) and its [source](https://github.com/mrdoob/three.js/) provide the benchmark reference.diff --git a/docs.html b/docs.htmlindex 7c0af3be..d2235bbe 100644--- a/docs.html+++ b/docs.html@@ -22,5 +22,9 @@<noscript><p>Read the <a href="/guide.md">complete plain-text guide</a> with JavaScript disabled.</p></noscript></div></main>+ <footer class="site-footer" aria-label="Site footer">+ <div class="footer-introduction"><a class="brand" href="/" aria-label="67.js home">67<span>.js</span></a><p>Browser 3D, from scene to film.<br>Made by <a href="https://codepawl.com">CodePawl</a>.</p></div>+ <div class="footer-links"><a href="https://github.com/anxuanng/67.js" data-icon="github">GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/67js"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a><a href="/logo.svg" download>Logo SVG</a></div>+ </footer><script type="module" src="/src/documentation.js"></script></body></html>diff --git a/docs/film-storyboard.md b/docs/film-storyboard.mdindex 90f1a7ff..29efd364 100644--- a/docs/film-storyboard.md+++ b/docs/film-storyboard.md@@ -1,88 +1,49 @@-# CRITICAL+# Oppenheimer — a 67.js trailer study-`CRITICAL` is an original 32-second short rendered from procedural 3D geometry in 67.js.-The film moves from intimate scientific detail through an ignition to an empty, scorched landscape.-Its visual motifs include machined metal, intersecting atomic orbits, interference waves, an isolated tower, fire, and smoke.-The film contains no copied footage, dialogue, music, logos, or claims of official affiliation.+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.-## Timeline+## Shot timeline-| Seconds | Set | Image and camera | Grade |-| --- | --- | --- | --- |-| 0 to 5 | `apparatus` | A close view of the optical aperture withdraws to reveal the pressure chamber, fasteners, copper pipes, and ceramic feedthroughs. | Cool metal with one amber filament. |-| 5 to 10 | `atom` | The camera arcs around a clustered nucleus inside five luminous, intersecting orbital rings. | Blue light in a dark field. |-| 10 to 13.5 | `waves` | A lateral dolly crosses a physical interference chamber with a suspended wave trace and calibrated grid. | Full monochrome. |-| 13.5 to 17 | `desert` | A wide camera approaches a skeletal test tower below a dusk horizon. | Restrained warm earth. |-| 17 to 19 | `desert` | A hard cut moves close to the suspended vessel. The camera advances and tightens its field of view. | Darker, partly monochrome. |-| 19 to 26 | `ignition` | A flash reveals an expanding incandescent core, boiling fire cells, a smoke crown, dust rings, and ejected embers. | Orange fire against a cool sky. |-| 26 to 32 | `aftermath` | The camera withdraws from collapsed struts, low embers, and drifting smoke. The title appears at 28 seconds. | Muted earth and black ash. |--The opening fades from black during the first 0.8 seconds.-The ending fades to black from 31 to 32 seconds.-The only text is `CRITICAL` and `A 67.js short`.-The title reaches full opacity at 29.2 seconds.--## Renderer contract--`FILM_DURATION` equals `32`.-`createFilmScenes()` returns six sets keyed by the names in the timeline.-Each set contains `parts`, `environment`, and `ground: false`.-The desert sets contain their own terrain and supply `shadowBounds`.--Each part uses the existing renderer shape `{ name, geometry, matrix, material }`.-Repeated details share geometry objects for instancing.-Matrices use `gl-matrix` column-major transforms.-Materials contain `tag`, `color`, `metallic`, `roughness`, and `emission`.-The ignition includes the `fire`, `smoke`, and `particle` tags for procedural shader animation.--The environment contains linear `fogColor`, `fogDensity`, display-space `skyTop` and `skyBottom`, `lightDirection`, and `daylight`.-The shadow bounds contain `extent`, `target`, `eye`, `near`, and `far`.--`sampleFilm(time)` accepts a finite number in seconds and clamps it to `[0, 32]`.-Invalid values throw a `TypeError`.-The return value contains these fields:--| Field | Meaning |+| Seconds | Set || --- | --- |-| `scene` | The set key. |-| `camera` | World-space `eye`, world-space `target`, and `fov` in degrees. |-| `time` | Clamped absolute film time. |-| `sceneTime` | Seconds since the set first appeared. It continues across the desert camera cut. |-| `exposure` | Authored exposure, including the brief ignition lift. |-| `monochrome` | Grade blend from zero for color to one for monochrome. |-| `fade` | Black-overlay opacity. Zero is visible. One is black. |-| `flash` | White-overlay opacity. It peaks at 19 seconds and decays exponentially. |-| `explosionProgress` | An eased zero-to-one ignition expansion. The aftermath holds one. |-| `title`, `subtitle` | Empty strings before 28 seconds, then the final title. |-| `titleOpacity` | Title opacity including its fade and the terminal black. |--The ignition geometry describes its final size.-Its core sits at `[0, 7, 0]` with radius approximately seven units.-Fire cells surround the core, and the smoke crown reaches approximately 24 units high.--The renderer expands ignition positions around the world origin using `explosionProgress`.-Scaling only individual mesh radii leaves separated cells at the beginning of ignition.-Terrain keeps its authored position and scale.-The aftermath smoke uses full expansion and its own local `sceneTime`.--The renderer can use `time` for continuous noise and `sceneTime` for shot-specific effects.-All scene construction and sampling are deterministic.-The source uses no random generator, clock, browser state, or mutable playback state.--## Measured scene budgets--Triangle counts include every instance, including repeated meshes.--| Set | Parts | Triangles |-| --- | ---: | ---: |-| `apparatus` | 280 | 46,316 |-| `atom` | 159 | 116,640 |-| `waves` | 263 | 40,044 |-| `desert` | 264 | 41,620 |-| `ignition` | 612 | 332,316 |-| `aftermath` | 313 | 100,284 |--`node --test tests/film.test.js` passed four tests.-The tests check exact cuts, deterministic samples, finite cameras, camera continuity within shots, material contracts, and scene budgets.-The tests sample the full timeline at 60 frames per second.-The parent renderer integration owns rendered-frame inspection, the final color grade, and audiovisual export.+| 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.diff --git a/downloads.html b/downloads.htmlindex 4250c64e..e6aa771d 100644--- a/downloads.html+++ b/downloads.html@@ -30,13 +30,15 @@<button data-package-manager="bun" aria-pressed="false"><span class="package-logo package-logo-bun" aria-hidden="true"></span><span>Bun</span></button></div><div class="command-row"><code data-install-command>Loading the release command…</code><button data-copy-install disabled>Copy command</button></div>- <div class="release-feedback"><p data-release-status role="status">Loading release information</p><button data-release-retry hidden>Retry</button></div>- <p class="package-note">The alias keeps imports short: <code>import { Renderer67 } from '67js'</code></p>- <div class="package-links"><a href="https://www.npmjs.com/package/@codepawlhq/67js" data-icon="package">View on npm</a><a href="https://github.com/anxuanng/67.js" data-icon="github">Source on GitHub</a><a href="/docs.html#getting-started" data-icon="book">Build your first scene</a></div>+ <div class="release-feedback" hidden><p data-release-status role="status">Loading release information</p><button data-release-retry hidden>Retry</button></div>+ <div class="package-links"><a href="https://www.npmjs.com/package/@codepawlhq/67js" data-icon="package">View on npm</a><a href="https://github.com/anxuanng/67.js" data-icon="github">Source on GitHub</a><a href="/docs.html" data-icon="book">Docs</a></div></div>- <div class="release-links"><a href="./docs.html">Documentation</a><a href="./logo.svg" download>Logo SVG</a><a href="./changelog.md">Changelog</a><span data-release-commit>Release commit</span><a data-release-api aria-disabled="true">API reference ↗</a></div></section></main>- <script type="module" src="/src/home.js"></script>+ <footer class="site-footer" aria-label="Site footer">+ <div class="footer-introduction"><a class="brand" href="/" aria-label="67.js home">67<span>.js</span></a><p>Browser 3D, from scene to film.<br>Made by <a href="https://codepawl.com">CodePawl</a>.</p></div>+ <div class="footer-links"><a href="https://github.com/anxuanng/67.js" data-icon="github">GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/67js"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a><a href="/logo.svg" download>Logo SVG</a></div>+ </footer>+<script type="module" src="/src/home.js"></script></body></html>diff --git a/film.html b/film.htmlindex 8a8e39a4..7bd7a981 100644--- a/film.html+++ b/film.html@@ -4,12 +4,12 @@<meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="theme-color" content="#080909" />- <meta name="description" content="CRITICAL. An original 32-second cinematic short rendered in 3D by 67.js." />- <title>CRITICAL · A 67.js short</title>+ <meta name="description" content="OPPENHEIMER. A 3D trailer study rendered live in 67.js, inspired by the Oppenheimer New Trailer." />+ <title>OPPENHEIMER · A 67.js trailer study</title><link rel="icon" href="/favicon.svg" /></head><body>- <main class="film-stage" aria-label="CRITICAL, an original 3D short film">+ <main class="film-stage" aria-label="OPPENHEIMER, a 67.js 3D trailer study"><canvas id="film-canvas" aria-label="Procedural 3D film"></canvas><div id="film-flash" class="film-flash" aria-hidden="true"></div><div id="film-title" class="film-title" aria-hidden="true">@@ -18,24 +18,24 @@</div><header class="film-header player-interface"><a class="brand" href="./">67<span>.js</span></a>- <span class="film-name">CRITICAL</span>+ <span class="film-name">OPPENHEIMER</span><nav aria-label="Explore 67.js"><a href="./nature.html">Nature</a><a href="./object.html">Object</a>- <a href="./docs.html">Docs</a><a href="./index.html#examples">Showcase</a></nav>+ <a href="./docs.html">Docs</a><a href="./downloads.html">Downloads</a></nav></header><section class="transport player-interface" aria-label="Film playback"><div class="transport-actions"><button id="film-play" class="play-button" type="button" aria-label="Play film"><span id="play-symbol" aria-hidden="true">▶</span><span id="play-label">Play film</span></button><button id="film-replay" type="button"><span aria-hidden="true">↺</span> Replay</button>- <a class="download" href="./media/critical.mp4" download="critical.mp4">Download film <span aria-hidden="true">↓</span></a>+ <a class="download" data-icon="download" href="./media/critical.mp4" download="67js-oppenheimer.mp4">Download film</a></div><div class="scrubber"><label for="film-time" class="visually-hidden">Film position in seconds</label>- <input id="film-time" type="range" min="0" max="32" step="0.01" value="0" />- <output id="film-clock" for="film-time">0:00 / 0:32</output>+ <input id="film-time" type="range" min="0" max="187" step="0.01" value="0" />+ <output id="film-clock" for="film-time">0:00 / 3:07</output></div>- <p class="film-caption">An original 3D short. Rendered live in your browser.</p>+ <p class="film-caption">A 67.js 3D study · Original synthesized score · <a href="https://www.youtube.com/watch?v=uYPbbksJxIg">Trailer reference: Universal Pictures</a></p></section><p id="film-error" class="film-error player-interface" role="alert" hidden></p></main>diff --git a/index.html b/index.htmlindex 9bbe92c4..b2766722 100644--- a/index.html+++ b/index.html@@ -38,13 +38,17 @@<div class="gallery"><a class="example" href="./object.html"><img src="./previews/wall-e.webp" alt="WALL·E model rendered in 67.js" width="1280" height="720" fetchpriority="high" /><div class="example-caption"><h3>WALL·E</h3><span>Object studio <span aria-hidden="true">↗</span></span></div><p>Explore the exterior or separate 574 parts to inspect the machinery</p></a><a class="example" href="./nature.html"><img src="./previews/nature.webp" alt="A winding stream through Silverwater valley" width="1280" height="720" /><div class="example-caption"><h3>Silverwater valley</h3><span>Nature <span aria-hidden="true">↗</span></span></div><p>Move through the landscape and change the light and wind</p></a>- <a class="example" href="./film.html"><img src="./previews/film-contact.webp" alt="Scenes from CRITICAL, a procedural 3D short film" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>CRITICAL</h3><span>Short film <span aria-hidden="true">↗</span></span></div><p>Watch a deterministic film with an original synthesized score</p></a>+ <a class="example" href="./film.html"><img src="./previews/film-contact.webp" alt="Scenes from the Oppenheimer 3D trailer study rendered in 67.js" width="1280" height="720" loading="lazy" /><div class="example-caption"><h3>Oppenheimer</h3><span>Short film <span aria-hidden="true">↗</span></span></div><p>Explore a 3D trailer study with an original synthesized score</p></a><a class="example" href="./view2d.html"><img src="./previews/view2d.webp" alt="A flat orbital poster rendered through an orthographic camera" width="960" height="540" loading="lazy" /><div class="example-caption"><h3>Orbital field</h3><span>2D and views <span aria-hidden="true">↗</span></span></div><p>Pan a vector scene or inspect a model from front, right and top</p></a><a class="example" href="./assets.html"><img src="./previews/assets.webp" alt="An imported geometric study displayed in the asset viewer" width="960" height="540" loading="lazy" /><div class="example-caption"><h3>Your models</h3><span>GLB assets <span aria-hidden="true">↗</span></span></div><p>Open a GLB, inspect its materials and sample node animation</p></a></div></section></main>- <script type="module" src="/src/home.js"></script>+ <footer class="site-footer" aria-label="Site footer">+ <div class="footer-introduction"><a class="brand" href="/" aria-label="67.js home">67<span>.js</span></a><p>Browser 3D, from scene to film.<br>Made by <a href="https://codepawl.com">CodePawl</a>.</p></div>+ <div class="footer-links"><a href="https://github.com/anxuanng/67.js" data-icon="github">GitHub</a><a href="https://www.npmjs.com/package/@codepawlhq/67js"><span class="package-logo package-logo-npm" aria-hidden="true"></span>npm</a><a href="/changelog.md">Changelog</a><a href="/license.txt">MIT license</a><a href="/logo.svg" download>Logo SVG</a></div>+ </footer>+<script type="module" src="/src/home.js"></script></body></html>diff --git a/package-lock.json b/package-lock.jsonindex 6ce249bf..dabf615b 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "@codepawlhq/67js",- "version": "0.3.1",+ "version": "0.3.2","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@codepawlhq/67js",- "version": "0.3.1",+ "version": "0.3.2","license": "MIT","devDependencies": {"gl-matrix": "3.4.4",diff --git a/package.json b/package.jsonindex 1662d25d..232b037c 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "@codepawlhq/67js",- "version": "0.3.1",+ "version": "0.3.2","private": false,"type": "module","description": "A browser graphics engine for interactive worlds, animation and cinematic media, with memory-aware CPU/GPU export",diff --git a/public/license.txt b/public/license.txtnew file mode 100644index 00000000..68dd4f77--- /dev/null+++ b/public/license.txt@@ -0,0 +1,25 @@+MIT License++Copyright (c) 2026 CodePawl+Bundled gl-matrix: Copyright (c) 2015-2025, Brandon Jones, Colin MacKenzie IV.++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.++This license covers the authored source code. WALL-E character rights belong+to Disney/Pixar. No ownership of that character is claimed.diff --git a/public/media/critical.mp4 b/public/media/critical.mp4index 0e6e74d1..c96db1bb 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 6d00f247..2d378910 100644--- a/public/media/critical.mp4.json+++ b/public/media/critical.mp4.json@@ -3,6 +3,10 @@"kind": "video","backend": "gpu","preset": "balanced",+ "aspect": "landscape",+ "start": 0,+ "encoder": "gpu",+ "assembly": null,"width": 1280,"height": 720,"actualRenderSize": {@@ -11,19 +15,35 @@"reduced": false},"fps": 24,- "duration": 32,+ "duration": 187,"memoryBudgetMiB": 384,- "peakEstimatedRenderBytes": 64853640,- "peakNodeBytes": 225230848,- "peakBrowserHeap": 7223176,+ "peakEstimatedRenderBytes": 86978764,+ "peakNodeBytes": 226672640,+ "peakBrowserHeap": 10947796,"maximumPendingFrames": 1,- "firstFrameBytes": 4250,- "elapsedSeconds": 256.6760515,+ "firstFrameBytes": 6158,+ "elapsedSeconds": 134.85767690000003,"graphics": {"gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)","samples": 4,+ "capabilities": {+ "hdr": true,+ "hdrRequested": true,+ "hdrFallbackReason": null,+ "samples": 4,+ "maximumTextureSize": 16384+ },"glError": 0},"output": "critical.mp4",- "errors": []+ "errors": [],+ "webDelivery": {+ "codec": "h264_nvenc",+ "targetVideoBitrate": 800000,+ "maxVideoBitrate": 850000,+ "audioBitrate": 128000,+ "bytes": 22757045,+ "verifiedDuration": 187,+ "verifiedFrames": 4488+ }}diff --git a/public/previews/film-contact.png b/public/previews/film-contact.pngindex 51a2334c..6f1be52f 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 b98f3d04..5925c452 100644Binary files a/public/previews/film-contact.webp and b/public/previews/film-contact.webp differdiff --git a/scripts/render-media.mjs b/scripts/render-media.mjsindex b0337a37..364c987d 100644--- a/scripts/render-media.mjs+++ b/scripts/render-media.mjs@@ -1,15 +1,15 @@import { chromium } from 'playwright';import { spawn } from 'node:child_process';-import { once } from 'node:events';import { mkdir, writeFile, stat } from 'node:fs/promises';import { existsSync } from 'node:fs';import { fileURLToPath } from 'node:url';import { resolve, dirname, basename } from 'node:path';+import { FILM_DURATION } from '../src/film.js';import { RENDER_PRESETS } from '../src/budget.js';function argumentsFrom(values) {const result = {};- const allowed = new Set(['kind', 'backend', 'scene', 'preset', 'width', 'height', 'fps', 'duration', 'time', 'memory', 'assembly', 'output', 'audio', 'encoder', 'start', 'aspect', 'asset']);+ const allowed = new Set(['kind', 'backend', 'scene', 'preset', 'width', 'height', 'fps', 'duration', 'time', 'memory', 'assembly', 'output', 'audio', 'encoder', 'start', 'aspect', 'asset', 'capture', 'jpeg-quality']);for (let index = 0; index < values.length; index += 2) {if (!values[index].startsWith('--') || values[index + 1] === undefined) throw new Error('Every option needs a value.');const name = values[index].slice(2);@@ -45,21 +45,57 @@ export function parseRenderOptions(values) {const height = Math.round(numberOption('height', defaultHeight, 64, 4096));if (kind === 'video' && (width % 2 || height % 2)) throw new Error('Video dimensions must be even for yuv420p output.');const fps = numberOption('fps', preset.fps, 1, 60);- const duration = numberOption('duration', scene === 'motion' ? 12 : 32, 0.1, 120);+ const duration = numberOption('duration', scene === 'film' ? FILM_DURATION : scene === 'motion' ? 12 : 32, 0.1, 240);const time = numberOption('time', scene === 'assets' ? 0 : 3, 0, 3600);const start = numberOption('start', 0, 0, 3600);const memory = numberOption('memory', preset.memoryBudgetMiB, 32, 1024);const assembly = numberOption('assembly', 0, 0, 1);- const output = resolve(options.output ?? `artifacts/${scene}-${backend}.${kind === 'video' ? 'mp4' : 'png'}`);- const encoderBackend = options.encoder ?? 'cpu';- if (!['cpu', 'gpu'].includes(encoderBackend)) throw new Error('Encoder must be cpu or gpu.');+ const captureFormat = options.capture ?? (kind === 'video' ? 'jpeg' : 'png');+ if (!['jpeg', 'png'].includes(captureFormat)) throw new Error('Capture must be jpeg or png.');+ const jpegQuality = numberOption('jpeg-quality', 95, 1, 100);+ if (!Number.isInteger(jpegQuality)) throw new Error('JPEG quality must be an integer.');+ const output = resolve(options.output ?? `artifacts/${scene}-${backend}.${kind === 'video' ? 'mp4' : captureFormat === 'jpeg' ? 'jpg' : 'png'}`);+ const encoderBackend = options.encoder ?? (backend === 'cpu' ? 'cpu' : 'auto');+ if (!['auto', 'cpu', 'gpu'].includes(encoderBackend)) throw new Error('Encoder must be auto, cpu or gpu.');const audio = options.audio ?? (scene === 'film' ? 'artifacts/critical-score.wav' : null);- return { options, kind, backend, scene, presetName, preset, aspect, width, height, fps, duration, time, start, memory, assembly, output, encoderBackend, audio };+ return { options, kind, backend, scene, presetName, preset, aspect, width, height, fps, duration, time, start, memory, assembly, output, encoderBackend, audio, captureFormat, jpegQuality };+}++export async function selectEncoderBackend(requested, probe) {+ if (!['auto', 'cpu', 'gpu'].includes(requested)) throw new Error('Encoder must be auto, cpu or gpu.');+ if (requested === 'cpu') return 'cpu';+ const result = await probe();+ if (result.available) return 'gpu';+ if (requested === 'gpu') throw new Error(`NVENC is unavailable: ${result.reason || 'availability probe failed'}`);+ return 'cpu';+}++function probeNvenc(ffmpeg) {+ return new Promise((resolveProbe) => {+ const probe = spawn(ffmpeg, ['-hide_banner', '-loglevel', 'error', '-f', 'lavfi', '-i', 'color=black:s=320x240:r=1', '-frames:v', '1', '-c:v', 'h264_nvenc', '-f', 'null', '-'], { windowsHide: true, stdio: ['ignore', 'ignore', 'pipe'] });+ let tail = '';+ let timedOut = false;+ const timeout = setTimeout(() => {+ timedOut = true;+ probe.kill();+ }, 5000);+ probe.stderr.on('data', data => {+ tail = (tail + data.toString()).slice(-8192);+ });+ probe.on('error', error => {+ clearTimeout(timeout);+ resolveProbe({ available: false, reason: error.message });+ });+ probe.on('close', code => {+ clearTimeout(timeout);+ resolveProbe({ available: code === 0 && !timedOut, reason: timedOut ? 'probe timed out after 5 seconds' : tail.trim() || `probe exited ${code}` });+ });+ });}export async function renderMedia(values = process.argv.slice(2)) {const plan = parseRenderOptions(values);- const { options, kind, backend, scene, presetName, preset, aspect, width, height, fps, time, start, memory, assembly, output, encoderBackend } = plan;+ const { options, kind, backend, scene, presetName, preset, aspect, width, height, fps, time, start, memory, assembly, output, captureFormat, jpegQuality } = plan;let duration = plan.duration;if (options.asset) {const details = await stat(resolve(options.asset));@@ -68,6 +104,7 @@ export async function renderMedia(values = process.argv.slice(2)) {await mkdir(dirname(output), { recursive: true });const root = fileURLToPath(new URL('..', import.meta.url));const ffmpeg = process.platform === 'win32' ? resolve(process.env.USERPROFILE, '.local/bin/ffmpeg.exe') : 'ffmpeg';+ const encoderBackend = kind === 'video' ? await selectEncoderBackend(plan.encoderBackend, () => probeNvenc(ffmpeg)) : null;const chrome = 'C:/Program Files/Google/Chrome/Application/chrome.exe';const server = spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--config', 'scripts/render-vite.config.mjs', '--host', '127.0.0.1', '--port', '5181', '--strictPort'], { cwd: root, windowsHide: true, stdio: 'pipe' });let browser;@@ -79,6 +116,8 @@ export async function renderMedia(values = process.argv.slice(2)) {let maximumPendingFrames = 0;let firstFrameBytes = 0;let actualRenderSize;+ let capturedFrames = 0;+ const stageTimings = { renderSeconds: 0, captureSeconds: 0, encoderBackpressureSeconds: 0, encoderFinishSeconds: 0 };const started = performance.now();try {await new Promise((resolveStarted, reject) => {@@ -105,10 +144,10 @@ export async function renderMedia(values = process.argv.slice(2)) {const failure = await page.locator('#notice').evaluate(element => element.hidden ? null : element.textContent);if (failure) throw new Error(`Asset import failed: ${failure}`);}- const sceneDuration = await page.evaluate(() => window.__scene?.duration ?? (window.__film ? 32 : null));+ const sceneDuration = await page.evaluate(() => window.__scene?.duration ?? window.__film?.duration);if (Number.isFinite(sceneDuration) && sceneDuration > 0) {if (start >= sceneDuration) throw new Error('Start time must precede the end of the scene.');- if (options.duration === undefined) duration = Math.min(120, sceneDuration - start);+ if (options.duration === undefined) duration = Math.min(240, sceneDuration - start);else if (kind === 'video' && start + duration > sceneDuration + 1e-8) throw new Error('The requested video extends beyond the scene duration.');if (kind === 'image' && time > sceneDuration) throw new Error('Image time exceeds the scene duration.');}@@ -136,17 +175,17 @@ export async function renderMedia(values = process.argv.slice(2)) {const session = await page.context().newCDPSession(page);const render = async (seconds) => {if (errors.length) throw new Error(`Browser render errors: ${errors.join('; ')}`);- await page.evaluate((value) => {+ const renderStarted = performance.now();+ const rendererPlan = await page.evaluate((value) => {if (window.__scene) window.__scene.renderAt(value);else if (window.renderAt) window.renderAt(value);else window.__nature.renderAt(value);- }, seconds);- const rendererPlan = await page.evaluate(() => {const renderer = window.__scene?.renderer ?? window.__film?.renderer ?? window.__nature?.renderer ?? window.__studio?.renderer;const glError = renderer.context.getError();if (glError !== 0) throw new Error(`WebGL render error ${glError}.`);return renderer.memoryPlan;- });+ }, seconds);+ stageTimings.renderSeconds += (performance.now() - renderStarted) / 1000;peakEstimatedRenderBytes = Math.max(peakEstimatedRenderBytes, rendererPlan.estimatedBytes);actualRenderSize = { width: rendererPlan.width, height: rendererPlan.height, reduced: rendererPlan.reduced };if (rendererPlan.estimatedBytes > memory * 1024 ** 2) throw new Error('Render target exceeded the configured memory budget.');@@ -156,7 +195,15 @@ export async function renderMedia(values = process.argv.slice(2)) {};async function capture(seconds) {await render(seconds);- const image = await page.screenshot({ type: 'png', animations: 'disabled' });+ const captureStarted = performance.now();+ const screenshot = await session.send('Page.captureScreenshot', {+ format: captureFormat,+ fromSurface: true,+ ...(captureFormat === 'jpeg' ? { quality: jpegQuality } : { optimizeForSpeed: true }),+ });+ const image = Buffer.from(screenshot.data, 'base64');+ stageTimings.captureSeconds += (performance.now() - captureStarted) / 1000;+ capturedFrames++;if (!firstFrameBytes) firstFrameBytes = image.byteLength;return image;}@@ -165,36 +212,71 @@ export async function renderMedia(values = process.argv.slice(2)) {if (options.audio && !existsSync(audioPath)) throw new Error('The selected audio file was not found.');const audioArguments = audioPath && existsSync(audioPath) ? ['-ss', String(start), '-i', audioPath] : [];const codecArguments = encoderBackend === 'gpu' ? ['-c:v', 'h264_nvenc', '-preset', 'p5', '-cq', '20'] : ['-c:v', 'libx264', '-preset', 'fast', '-crf', '18', '-threads', '2'];- const encodingArguments = ['-hide_banner', '-loglevel', 'error', '-y', '-f', 'image2pipe', '-framerate', String(fps), '-vcodec', 'png', '-i', 'pipe:0', ...audioArguments, ...codecArguments, '-pix_fmt', 'yuv420p', '-color_primaries', 'bt709', '-color_trc', 'bt709', '-colorspace', 'bt709', '-movflags', '+faststart', ...(audioArguments.length ? ['-c:a', 'aac', '-b:a', '192k', '-shortest'] : []), output];+ const encodingArguments = ['-hide_banner', '-loglevel', 'error', '-y', '-f', 'image2pipe', '-framerate', String(fps), '-vcodec', captureFormat === 'jpeg' ? 'mjpeg' : 'png', '-i', 'pipe:0', ...audioArguments, ...codecArguments, '-pix_fmt', 'yuv420p', '-color_primaries', 'bt709', '-color_trc', 'bt709', '-colorspace', 'bt709', '-movflags', '+faststart', ...(audioArguments.length ? ['-c:a', 'aac', '-b:a', '192k', '-shortest'] : []), output];encoder = spawn(ffmpeg, encodingArguments, { windowsHide: true, stdio: ['pipe', 'ignore', 'pipe'] });- encoder.stderr.on('data', (data) => { encoderError += data.toString(); });- encoder.on('error', (error) => { encoderError += error.message; });- encoder.stdin.on('error', (error) => { encoderError += error.message; });- const finished = once(encoder, 'close');+ const retainEncoderError = value => {+ encoderError = (encoderError + String(value)).slice(-8192);+ };+ encoder.stderr.on('data', retainEncoderError);+ encoder.on('error', error => retainEncoderError(error.message));+ encoder.stdin.on('error', error => retainEncoderError(error.message));+ const finished = new Promise(resolveFinished => {+ encoder.once('error', () => resolveFinished(-1));+ encoder.once('close', resolveFinished);+ });const frameCount = Math.ceil(duration * fps);+ const captureSequenceStarted = performance.now();for (let frame = 0; frame < frameCount; frame++) {const image = await capture(start + frame / fps);maximumPendingFrames = Math.max(maximumPendingFrames, 1);if (encoder.exitCode !== null) throw new Error(`Video encoder stopped: ${encoderError}`);- if (!encoder.stdin.write(image)) await once(encoder.stdin, 'drain');+ if (encoder.stdin.destroyed) throw new Error(`Video encoder stopped: ${encoderError}`);+ if (!encoder.stdin.write(image)) {+ const waitStarted = performance.now();+ await new Promise((resolveDrain, rejectDrain) => {+ const cleanup = () => {+ encoder.stdin.off('drain', drained);+ encoder.stdin.off('error', failed);+ encoder.off('close', closed);+ };+ const drained = () => {+ cleanup();+ resolveDrain();+ };+ const failed = error => {+ cleanup();+ rejectDrain(error);+ };+ const closed = () => failed(new Error(`Video encoder stopped before draining: ${encoderError}`));+ encoder.stdin.once('drain', drained);+ encoder.stdin.once('error', failed);+ encoder.once('close', closed);+ });+ stageTimings.encoderBackpressureSeconds += (performance.now() - waitStarted) / 1000;+ }if (frame % 48 === 0) {const { usedSize } = await session.send('Runtime.getHeapUsage');peakBrowserHeap = Math.max(peakBrowserHeap, usedSize);if (usedSize > 256 * 1024 ** 2) throw new Error('Browser JavaScript heap exceeded 256 MiB. Export stopped.');- const message = `Rendered ${frame + 1}/${frameCount} frames`;+ const elapsed = (performance.now() - captureSequenceStarted) / 1000;+ const effectiveFps = (frame + 1) / elapsed;+ const remainingSeconds = (frameCount - frame - 1) / effectiveFps;+ const message = `Rendered ${frame + 1}/${frameCount} frames | ${effectiveFps.toFixed(1)} fps | ${(effectiveFps / fps).toFixed(2)}x | ETA ${Math.ceil(remainingSeconds)}s`;console.log(message);}}encoder.stdin.end();- const [exitCode] = await finished;+ const finishStarted = performance.now();+ const exitCode = await finished;+ stageTimings.encoderFinishSeconds = (performance.now() - finishStarted) / 1000;if (exitCode !== 0) throw new Error(`Video encoding failed: ${encoderError}`);} else if (kind === 'stills') {const stillTimes = scene === 'film' && start === 0 && options.duration === undefined- ? [2.5, 7.5, 11.5, 15, 18, 22, 25, 29.5]+ ? [23, 49, 59, 101, 114, 149, 158, 182]: Array.from({ length: 8 }, (_, index) => start + duration * (index + 0.5) / 8);for (const seconds of stillTimes) {const image = await capture(seconds);- await writeFile(resolve(dirname(output), `frame-${seconds.toFixed(1)}.png`), image);+ await writeFile(resolve(dirname(output), `frame-${seconds.toFixed(1)}.${captureFormat === 'jpeg' ? 'jpg' : 'png'}`), image);}} else {await writeFile(output, await capture(time));@@ -208,7 +290,8 @@ export async function renderMedia(values = process.argv.slice(2)) {});if (graphics.glError !== 0) throw new Error(`WebGL render error ${graphics.glError}.`);if (backend === 'cpu' && !graphics.gpu.toLowerCase().includes('swiftshader')) throw new Error('CPU backend did not select SwiftShader.');- const report = { scene, kind, backend, preset: presetName, aspect, start, encoder: kind === 'video' ? encoderBackend : null, assembly: scene === 'object' ? assembly : null, width, height, actualRenderSize, fps, duration: kind === 'video' ? duration : null, memoryBudgetMiB: memory, peakEstimatedRenderBytes, peakNodeBytes, peakBrowserHeap, maximumPendingFrames, firstFrameBytes, elapsedSeconds: (performance.now() - started) / 1000, graphics, output: basename(output), errors };+ const elapsedSeconds = (performance.now() - started) / 1000;+ const report = { scene, kind, backend, preset: presetName, aspect, start, encoder: encoderBackend, requestedEncoder: kind === 'video' ? plan.encoderBackend : null, captureFormat, jpegQuality: captureFormat === 'jpeg' ? jpegQuality : null, capturedFrames, stageTimings, effectiveFPS: capturedFrames / elapsedSeconds, speedRatio: kind === 'video' ? capturedFrames / fps / elapsedSeconds : null, assembly: scene === 'object' ? assembly : null, width, height, actualRenderSize, fps, duration: kind === 'video' ? duration : null, memoryBudgetMiB: memory, peakEstimatedRenderBytes, peakNodeBytes, peakBrowserHeap, maximumPendingFrames, firstFrameBytes, elapsedSeconds, graphics, output: basename(output), errors };await writeFile(`${output}.json`, JSON.stringify(report, null, 2));console.log(JSON.stringify(report, null, 2));} finally {diff --git a/scripts/score.mjs b/scripts/score.mjsindex dbcd7ea7..11acd4a3 100644--- a/scripts/score.mjs+++ b/scripts/score.mjs@@ -1,9 +1,10 @@import { writeFile, mkdir } from 'node:fs/promises';import { resolve, dirname } from 'node:path';+import { FILM_DURATION } from '../src/film.js';const output = resolve(process.argv[2] ?? 'artifacts/critical-score.wav');const sampleRate = 48000;-const duration = 32;+const duration = FILM_DURATION;const frameCount = sampleRate * duration;const data = Buffer.alloc(44 + frameCount * 4);data.write('RIFF', 0);@@ -18,6 +19,7 @@ data.writeUInt16LE(4, 32);data.writeUInt16LE(16, 34);data.write('data', 36);data.writeUInt32LE(frameCount * 4, 40);+const sequence = [110, 130.8128, 146.8324, 164.8138];let seed = 67;let filteredNoise = 0;let peak = 0;@@ -28,20 +30,25 @@ for (let index = 0; index < frameCount; index++) {const noise = seed / 4294967296 * 2 - 1;filteredNoise += (noise - filteredNoise) * 0.03;const fade = Math.min(1, time / 1.5) * Math.min(1, (duration - time) / 2);- const tension = Math.min(1, time / 19);+ const tension = Math.min(1, time / 180);let value = Math.sin(time * Math.PI * 2 * 55) * 0.05;value += Math.sin(time * Math.PI * 2 * 82.4069 + Math.sin(time * 0.6) * 0.1) * 0.035;value += Math.sin(time * Math.PI * 2 * 110) * 0.024;value += Math.sin(time * Math.PI * 2 * 164.8138) * 0.012;- const beatInterval = time < 13.5 ? 1 : 0.5;+ const beatInterval = time < 85 ? 1.2 : time < 145 ? 0.6 : time < 165 ? 0.4 : 0.25;const beatAge = time % beatInterval;const pulse = Math.sin(beatAge * Math.PI * 2 * (48 + tension * 6)) * Math.exp(-beatAge * 13);- if (time < 19) value += pulse * (0.025 + tension * 0.11);- const ignitionAge = time - 19;+ if (time < 180) value += pulse * (0.025 + tension * 0.11);+ const ignitionAge = time - 180;if (ignitionAge >= 0) {value += Math.sin(ignitionAge * Math.PI * 2 * (30 + 20 * Math.exp(-ignitionAge * 2))) * Math.exp(-ignitionAge * 0.9) * 0.32;value += filteredNoise * Math.exp(-ignitionAge * 0.4) * 0.65;}+ const note = sequence[Math.floor(time / (time < 145 ? 4 : 1)) % sequence.length];+ const shimmer = 0.6 + 0.4 * Math.sin(time * Math.PI * 2 * 5);+ if (time < 180) value += Math.sin(time * Math.PI * 2 * note) * (0.006 + tension * 0.025) * shimmer;+ const countdownAge = time - Math.floor(time);+ if (time >= 165 && time < 180) value += Math.sin(countdownAge * Math.PI * 2 * 1800) * Math.exp(-countdownAge * 90) * 0.035;value += filteredNoise * 0.03 * tension;value = Math.tanh(value * 1.9) * fade * 0.85;const right = value + Math.sin(time * Math.PI * 2 * 110.14) * 0.012 * fade;diff --git a/scripts/smoke-scenes.mjs b/scripts/smoke-scenes.mjsindex 55020216..4d9d54d8 100644--- a/scripts/smoke-scenes.mjs+++ b/scripts/smoke-scenes.mjs@@ -60,11 +60,11 @@ try {return { checksum: checksum >>> 0, error: context.getError() };}, time);}- const ignition = await filmPixels(22);+ const ignition = await filmPixels(183.5);await page.screenshot({ path: 'artifacts/film-wide.png' });await filmPixels(5.5);- await filmPixels(29.5);- assert.deepEqual(await filmPixels(22), ignition);+ await filmPixels(101);+ assert.deepEqual(await filmPixels(183.5), ignition);assert.equal(ignition.error, 0);await page.locator('#film-time').fill('1');await page.getByRole('button', { name: 'Play film', exact: true }).click();@@ -72,7 +72,7 @@ try {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 });- await page.locator('#film-time').fill('29');+ await page.locator('#film-time').fill('183.5');await page.screenshot({ path: 'artifacts/film-narrow.png' });assert.equal(await page.evaluate(() => document.documentElement.scrollWidth), 320);const controls = await page.locator('.transport button, .transport a').evaluateAll((elements) => elements.map((element) => {diff --git a/scripts/smoke-site.mjs b/scripts/smoke-site.mjsindex e8f423e6..aab3ea47 100644--- a/scripts/smoke-site.mjs+++ b/scripts/smoke-site.mjs@@ -113,7 +113,7 @@ try {}if (route === '/downloads.html') {await page.waitForFunction(() => window.__home.state.status === 'ready');- assert.equal(await page.locator('.package-logo').count(), 4);+ assert.equal(await page.locator('.package-managers .package-logo').count(), 4);assert.equal(await page.locator('[data-package-manager]').count(), 4);assert.equal(await page.locator('[data-release-tarball], [data-release-module]').count(), 0);for (const [manager, prefix] of [['npm', 'npm install'], ['pnpm', 'pnpm add'], ['yarn', 'yarn add'], ['bun', 'bun add']]) {diff --git a/src/documentation.css b/src/documentation.cssindex 1a31266b..8ede2d5b 100644--- a/src/documentation.css+++ b/src/documentation.css@@ -1,4 +1,5 @@.documentation { --syntax-string:#9dd1b6; --syntax-keyword:#c8b1ed; --syntax-number:#e8bd88; --syntax-comment:#a0a0a0; --syntax-name:#acc7ed; }+.doc-install-link { display:inline-flex; align-items:center; gap:8px; }.documentation .docs-page { display:grid; grid-template-columns:244px minmax(0,780px); justify-content:center; gap:52px; max-width:1440px; margin-inline:auto; padding:36px 40px 64px; }.docs-sidebar { position:sticky; top:calc(var(--navigation-height,80px) + 24px); align-self:start; max-height:calc(100vh - var(--navigation-height,80px) - 48px); overflow-y:auto; padding:0 5px 12px; }.docs-title { display:block; font-size:21px; font-weight:600; letter-spacing:-.5px; margin:5px 0 25px; }diff --git a/src/documentation.js b/src/documentation.jsindex 904f5c14..0939b9b5 100644--- a/src/documentation.js+++ b/src/documentation.js@@ -195,7 +195,7 @@ function openTopic(focus = false) {article.replaceChildren(section);if (currentTopic.id === 'install') {const managerLink = document.createElement('p');- managerLink.innerHTML = `<a href="/downloads.html">Choose a package manager and get the current release ${icon('arrow')}</a>`;+ managerLink.innerHTML = `<a class="doc-install-link" href="/downloads.html">Download 67.js ${icon('arrow')}</a>`;section.append(managerLink);}const index = topics.indexOf(currentTopic);diff --git a/src/film-player.js b/src/film-player.jsindex 02b29a5d..df2d3b03 100644--- a/src/film-player.js+++ b/src/film-player.js@@ -26,6 +26,7 @@ const titleText = document.querySelector('#title-text');const subtitleText = document.querySelector('#subtitle-text');const flash = document.querySelector('#film-flash');const scenes = createFilmScenes();+slider.max = String(FILM_DURATION);const score = exporting ? null : new Audio('./media/critical.mp4');if (score) score.preload = 'none';let renderer = null;@@ -60,10 +61,13 @@ function renderAt(time) {shadowBounds: scene.shadowBounds,pixelRatio: 1,samples,+ hdr: true,memoryBudgetMiB,});activeScene = sample.scene;}+ scene.animate?.(sample.sceneTime);+ if (scene.animate) renderer.updateParts(scene.parts);renderer.render({...sample.camera,time: sample.sceneTime,@@ -71,6 +75,7 @@ function renderAt(time) {monochrome: sample.monochrome,fade: sample.fade,cinematic: true,+ effects: sample.effects,explosionProgress: sample.explosionProgress,volumeExplosion: sample.scene === 'ignition',environment: scene.environment,diff --git a/src/film-style.css b/src/film-style.cssindex 988b253a..40066e90 100644--- a/src/film-style.css+++ b/src/film-style.css@@ -66,3 +66,6 @@ button:hover { background: #ffffff1c; }.film-error { left: 20px; right: 20px; }}@media (max-width:600px) { .film-header nav { flex-basis:100%; margin-left:0; gap:6px 18px; } }++.film-caption a { text-decoration:underline; }+@media (max-width:600px) { .film-title h1 { font-size:clamp(22px,6vw,36px); letter-spacing:.12em; } }diff --git a/src/film.js b/src/film.jsindex ee968712..6ebd1d78 100644--- a/src/film.js+++ b/src/film.js@@ -1,7 +1,7 @@import { mat4, quat, vec3 } from 'gl-matrix';import { box, cylinder, sphere, torus } from './geometry.js';-export const FILM_DURATION = 32;+export const FILM_DURATION = 187;const FULL_TURN = Math.PI * 2;const HALF_PI = Math.PI / 2;@@ -14,11 +14,17 @@ const materials = {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 },rock: { tag: 'terrain', color: [0.24, 0.19, 0.14], metallic: 0, roughness: 0.95, emission: 0 },- ash: { tag: 'terrain', color: [0.055, 0.046, 0.042], metallic: 0, roughness: 0.96, 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 },+ 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 },+ olive: { tag: 'paint', color: [0.13, 0.16, 0.08], metallic: 0.2, roughness: 0.65, emission: 0 },};function createBuilder(meshes) {@@ -122,18 +128,18 @@ function createWaveChamber(meshes) {return parts;}-function addDesert(builder, aftermath = false) {+function addDesert(builder) {const { add } = builder;- add('Desert floor', 'box', [0, -0.65, 0], [260, 1, 260], aftermath ? 'ash' : 'terrain');+ add('Desert floor', 'box', [0, -0.65, 0], [260, 1, 260], 'terrain');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], aftermath ? 'ash' : 'rock', [0.12, angle, 0.1]);+ 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], aftermath ? 'ash' : 'rock', [0, angle, 0]);+ 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]);}}@@ -191,26 +197,219 @@ function createIgnition(meshes) {return builder.parts;}-function createAftermath(meshes) {+function addScientist(builder, position = [0, 0, 0], hat = true, rotation = 0) {+ const { add, beam } = 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]]);+ 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');+ 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');+ }+}++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');+ 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');+ }+ 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');+ }+ add('Window mullion', 'box', [horizontal, 2.75, -4.6], [0.055, 2.4, 0.1], '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('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');+ }+ 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 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');+ }+ }+}++function createOffice(meshes, laboratory = false) {const builder = createBuilder(meshes);+ addRoom(builder, laboratory);+ addScientist(builder, [0, 0, -1.7], !laboratory);+ 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');+ }+ } 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');+ }+ return builder.parts;+}++function addVehicle(builder, position) {const { add, beam } = builder;- addDesert(builder, true);- add('Scorched impact basin', 'cylinder', [0, -0.02, 0], [12, 0.16, 12], 'graphite');- for (let index = 0; index < 18; index++) {- const angle = index * 2.399963;- const radius = 1 + index % 6;- beam('Collapsed tower strut', [Math.cos(angle) * radius, 0.1, Math.sin(angle) * radius], [Math.cos(angle + 0.5) * (radius + 3), 0.22, Math.sin(angle + 0.5) * (radius + 3)], 0.06, 'graphite');+ 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');+ add('Flat hood', 'box', place([0, 0.95, 0.9]), [1.55, 0.42, 1.2], 'olive');+ add('Rear tub', 'box', place([0, 0.87, -1.1]), [1.5, 0.48, 0.5], 'olive');+ 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]);+ }+ 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');}- for (let index = 0; index < 55; index++) {- const angle = index * 2.399963;- const radius = 1 + index % 7 * 0.8;- add('Low ember', 'sphere', [Math.cos(angle) * radius, 0.16, Math.sin(angle) * radius], [0.12, 0.025, 0.12], 'particle');+ beam('Windshield top rail', place([-0.7, 1.9, 0.15]), place([0.7, 1.9, 0.15]), 0.035, 'olive');+ 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');}- for (let index = 0; index < 34; index++) {+ add('Spare wheel', 'cylinder', place([0, 0.95, -1.54]), [0.42, 0.24, 0.42], 'graphite', [HALF_PI, 0, 0]);+ add('Driver seat', 'box', place([-0.38, 0.98, -0.55]), [0.55, 0.14, 0.65], 'cloth');+}++function createSettlement(meshes) {+ const builder = createBuilder(meshes);+ const { add, beam } = builder;+ addDesert(builder);+ add('Unpaved main street', 'box', [0, -0.12, 0], [8, 0.045, 90], 'rock');+ for (const side of [-1, 1]) {+ for (let index = 0; index < 7; index++) {+ const horizontal = side * (12 + index % 2 * 4);+ const depth = -32 + index * 11;+ add('Research hut walls', 'box', [horizontal, 1.4, depth], [7, 2.8, 5.6], index % 3 ? 'wood' : 'plaster');+ for (const pitch of [-1, 1]) {+ 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('Window divider', 'box', [horizontal + offset, 1.6, depth + 2.87], [0.06, 0.95, 0.06], 'wood');+ }+ 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) {+ beam('Telephone wire', [side * 5.1, 5.6, depth], [side * 5.1, 5.6, depth + 11], 0.012, 'graphite');+ }+ }+ }+ addVehicle(builder, [1, 0, 8]);+ addVehicle(builder, [-2, 0, -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 place = point => point.map((value, axis) => value + center[axis]);+ add('Gadget explosive vessel', 'sphere', center, [1, 1, 1], 'graphite');+ for (let latitude = 0; latitude < 5; latitude++) {+ const elevation = -0.8 + latitude * 0.4;+ 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('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');+}++function createGadget(meshes) {+ const builder = createBuilder(meshes);+ addRoom(builder, true);+ addGadget(builder, [0, 2.25, -1.3]);+ for (const horizontal of [-2, 2]) {+ builder.beam('Assembly gantry upright', [horizontal, 0, -1.3], [horizontal, 5.7, -1.3], 0.095);+ }+ builder.beam('Assembly gantry lintel', [-2, 5.7, -1.3], [2, 5.7, -1.3], 0.095);+ return builder.parts;+}++function createControl(meshes) {+ const builder = createBuilder(meshes);+ const { add, beam } = builder;+ addRoom(builder, true);+ add('Detonator console', 'box', [0, 1.06, 0], [2.8, 0.38, 1.35], 'olive');+ for (let index = 0; index < 5; index++) {+ const horizontal = -1 + index * 0.5;+ add('Analog voltmeter bezel', 'ring', [horizontal, 1.266, -0.12], [0.19, 0.19, 0.19], 'steel', [HALF_PI, 0, 0]);+ 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('Red firing button', 'cylinder', [0.9, 1.31, 0.38], [0.12, 0.065, 0.12], 'copper');+ addScientist(builder, [0, 0, -1.5], false);+ 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');+ }+ return builder.parts;+}++function createSparks(meshes) {+ const builder = createBuilder(meshes);+ for (let index = 0; index < 360; index++) {const angle = index * 2.399963;- const height = 1.6 + index * 0.33;- const size = 0.8 + index / 34 * 1.1;- add('Residual smoke plume', 'sphere', [Math.cos(angle) * 1.4 + height * 0.14, height, Math.sin(angle) * 1.4], [size, size * 1.2, size], 'smoke');+ 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');}return builder.parts;}@@ -227,45 +426,87 @@ export function createFilmScenes() {gasRing: torus(0.045, 96, 8),};const studio = {- fogColor: [0.007, 0.009, 0.012], fogDensity: 0.028,- skyTop: [0.009, 0.013, 0.02], skyBottom: [0.025, 0.032, 0.04],- lightDirection: [-0.4, 0.8, 0.5], daylight: 0.65,+ fogColor: [0.014, 0.018, 0.018], fogDensity: 0.018,+ skyTop: [0.024, 0.035, 0.035], skyBottom: [0.1, 0.12, 0.11],+ lightDirection: [-0.4, 0.8, 0.5], daylight: 0.85,+ };+ const interior = {+ ...studio, fogDensity: 0.008, daylight: 1.05,+ skyTop: [0.12, 0.17, 0.18], skyBottom: [0.22, 0.23, 0.18],+ lightDirection: [-0.45, 0.65, 0.8],};const desert = {- fogColor: [0.14, 0.105, 0.075], fogDensity: 0.007,- skyTop: [0.075, 0.11, 0.15], skyBottom: [0.5, 0.33, 0.21],- lightDirection: [-0.65, 0.22, -0.5], daylight: 0.7,+ 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,};- const desertShadows = { extent: 55, target: [0, 6, 0], eye: [-35, 45, -35], near: 1, far: 140 };+ 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,+ };+ 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 towerParts = createDesert(meshes);+ const towerBuilder = createBuilder(meshes);+ addGadget(towerBuilder, [0, 11.3, 0]);+ towerParts.push(...towerBuilder.parts);return {- apparatus: { parts: createApparatus(meshes), environment: studio, ground: false },- atom: {- parts: createAtom(meshes), ground: false,- environment: { ...studio, fogDensity: 0.06, skyTop: [0.002, 0.004, 0.009], skyBottom: [0.008, 0.012, 0.02], daylight: 0.2 },- },- waves: { parts: createWaveChamber(meshes), environment: studio, ground: false },- desert: { parts: createDesert(meshes), environment: desert, ground: false, shadowBounds: desertShadows },- ignition: { parts: createIgnition(meshes), environment: desert, ground: false, shadowBounds: desertShadows },- aftermath: {- parts: createAftermath(meshes), ground: false, shadowBounds: desertShadows,- environment: {- fogColor: [0.023, 0.018, 0.015], fogDensity: 0.016,- skyTop: [0.013, 0.022, 0.032], skyBottom: [0.13, 0.075, 0.042],- lightDirection: [-0.6, 0.3, -0.4], daylight: 0.3,- },- },+ 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),+ ignition: set(createIgnition(meshes), night, desertShadows),};}-// Each shot owns its camera endpoints. Cuts are deliberate; motion within a shot is continuous.-const shots = [- { start: 0, end: 5, scene: 'apparatus', eye: [[0.37, 0.73, 2.12], [1.65, 1.02, 3.65]], target: [[0, 0.5, 1.28], [0, 0.48, 0.4]], fov: [34, 39], exposure: 0.95, monochrome: 0.25 },- { start: 5, end: 10, scene: 'atom', eye: [[0.5, 0.3, 6.8], [4.8, 2.5, 5.1]], target: [[0, 0, 0], [0, 0, 0]], fov: [48, 43], exposure: 0.82, monochrome: 0 },- { start: 10, end: 13.5, scene: 'waves', eye: [[-3.8, 3.4, 5.3], [0.5, 2.2, 4.4]], target: [[-0.8, 0, 0], [0.8, 0.05, 0]], fov: [49, 42], exposure: 0.85, monochrome: 1 },- { start: 13.5, end: 17, scene: 'desert', eye: [[29, 6, 37], [21, 5, 29]], target: [[0, 6, 0], [0, 7.5, 0]], fov: [44, 40], exposure: 0.8, monochrome: 0.12 },- { start: 17, end: 19, scene: 'desert', eye: [[4.7, 9.1, 6.2], [3.8, 10, 4.8]], target: [[0, 10.7, 0], [0, 11, 0]], fov: [36, 31], exposure: 0.68, monochrome: 0.25 },- { start: 19, end: 26, scene: 'ignition', eye: [[28, 7, 39], [37, 11, 49]], target: [[0, 7, 0], [0, 11, 0]], fov: [48, 53], exposure: 0.66, monochrome: 0 },- { start: 26, end: 32, scene: 'aftermath', eye: [[18, 3.2, 24], [22, 5, 30]], target: [[0, 2.5, 0], [0, 3.7, 0]], fov: [45, 46], exposure: 0.72, monochrome: 0.35 },+// Camera endpoints belong to shots; reused sets never carry playback state.+function shot(start, end, scene, eye, nextEye, target, nextTarget = target, fov = [40, 38], monochrome = 0, exposure = 0.95) {+ return { start, end, scene, eye: [eye, nextEye], target: [target, nextTarget], fov, monochrome, exposure };+}++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(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(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(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(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(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(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),];function smoothstep(value) {@@ -280,38 +521,39 @@ function interpolate(first, second, fraction) {export function sampleFilm(time) {if (!Number.isFinite(time)) throw new TypeError('Film time must be finite.');const boundedTime = Math.max(0, Math.min(FILM_DURATION, time));- const shotIndex = shots.findIndex(shot => boundedTime < shot.end);- const shot = shots[shotIndex < 0 ? shots.length - 1 : shotIndex];- const progress = (boundedTime - shot.start) / (shot.end - shot.start);- const eased = smoothstep(progress);- const sceneStart = shots.find(candidate => candidate.scene === shot.scene).start;- const sceneTime = boundedTime - sceneStart;- const explosionProgress = shot.scene === 'ignition' ? smoothstep(sceneTime / 5.5) : shot.scene === 'aftermath' ? 1 : 0;+ const shotIndex = FILM_SHOTS.findIndex(candidate => boundedTime < candidate.end);+ const selected = FILM_SHOTS[shotIndex < 0 ? FILM_SHOTS.length - 1 : shotIndex];+ const eased = smoothstep((boundedTime - selected.start) / (selected.end - selected.start));const camera = {- eye: shot.eye[0].map((value, axis) => interpolate(value, shot.eye[1][axis], eased)),- target: shot.target[0].map((value, axis) => interpolate(value, shot.target[1][axis], eased)),- fov: interpolate(...shot.fov, eased),+ eye: selected.eye[0].map((value, axis) => interpolate(value, selected.eye[1][axis], eased)),+ target: selected.target[0].map((value, axis) => interpolate(value, selected.target[1][axis], eased)),+ fov: interpolate(...selected.fov, eased),};- let title = '';- let subtitle = '';- if (boundedTime >= 28) {- title = 'CRITICAL';- subtitle = 'A 67.js short';- }- const visibility = smoothstep(boundedTime / 0.8) * (1 - smoothstep((boundedTime - 31) / 1));- const flash = boundedTime >= 19 && boundedTime < 19.65 ? Math.exp(-(boundedTime - 19) * 7) : 0;+ 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;return {- scene: shot.scene,+ scene: selected.scene,+ shotIndex: shotIndex < 0 ? FILM_SHOTS.length - 1 : shotIndex,camera,- exposure: shot.exposure + flash * 1.5,- monochrome: shot.monochrome,+ exposure: selected.exposure + flash * 1.5,+ monochrome: selected.monochrome,fade: 1 - visibility,- title,- subtitle,+ title: titleVisible ? 'OPPENHEIMER' : '',+ subtitle: titleVisible ? 'A 67.js trailer study' : '',time: boundedTime,- sceneTime,- explosionProgress,+ sceneTime: boundedTime - FILM_SHOTS.find(candidate => candidate.scene === selected.scene).start,+ explosionProgress: selected.scene === 'ignition' ? smoothstep(ignitionTime / 3.6) : 0,flash,- titleOpacity: boundedTime >= 28 ? smoothstep((boundedTime - 28) / 1.2) * visibility : 0,+ titleOpacity: titleVisible ? smoothstep((boundedTime - 181.65) / 1.15) * visibility : 0,+ effects: {+ bloom: { strength: selected.scene === 'sparks' || selected.scene === 'atom' ? 0.3 : 0.12 },+ saturation: 0.82,+ contrast: 1.08,+ temperature: selected.scene === 'night' ? -0.08 : 0.035,+ vignette: 0.22,+ grain: 0.035,+ },};}diff --git a/src/home.css b/src/home.cssindex 343e0295..fbbf9c9e 100644--- a/src/home.css+++ b/src/home.css@@ -199,3 +199,16 @@ td, th { text-align:left; padding:12px; border-bottom:0; vertical-align:top; }.preview-assembly-label output { color:var(--muted); font-size:12px; }.preview-assembly input { display:block; width:100%; min-height:44px; margin:6px 0; cursor:ew-resize; }.preview-assembly p { font-size:12px; text-align:center; margin:0; }++body:has(.navigation) { display:flex; flex-direction:column; min-height:100vh; }+body:has(.navigation) > main { flex:1; width:100%; }+.package-links { margin-top:20px; }+.site-footer { display:flex; align-items:center; justify-content:space-between; gap:28px; width:calc(100% - 48px); max-width:1352px; margin:24px auto; padding:28px; border-radius:var(--panel-radius); background-color:var(--bg); background-image:var(--dither); }+.footer-introduction .brand { font-size:24px; }+.footer-introduction .brand-mark { width:26px; height:26px; }+.footer-introduction p { margin:10px 0 0; font-size:13px; line-height:1.7; }+.footer-introduction p a { color:var(--text); }+.footer-links { display:flex; flex-wrap:wrap; align-items:center; gap:4px 18px; }+.footer-links a { display:inline-flex; align-items:center; gap:8px; min-height:44px; font-size:13px; }+.footer-links .icon { margin:0; }+@media (max-width:760px) { .site-footer { align-items:flex-start; flex-direction:column; width:calc(100% - 32px); padding:22px; gap:16px; } }diff --git a/src/home.js b/src/home.jsindex d8863b47..52c21292 100644--- a/src/home.js+++ b/src/home.js@@ -56,9 +56,8 @@ function renderRelease() {document.querySelectorAll('[data-package-manager]').forEach(button => {button.setAttribute('aria-pressed', String(button.dataset.packageManager === state.packageManager));});- setText('[data-release-status]', release- ? release.registryPublished ? '✓ Install the current published release' : '✓ Install this release from the package archive'- : state.status === 'error' ? '⚠ Release information could not load. Retry to get the current files' : '◷ Loading release information');+ document.querySelectorAll('.release-feedback').forEach(element => { element.hidden = state.status !== 'error'; });+ setText('[data-release-status]', state.status === 'error' ? 'Release information could not load. Retry to get the current files.' : '');setLink('[data-release-tarball]', release ? releaseURL(release.tarball) : null, true);setLink('[data-release-module]', release ? releaseURL(release.module) : null, true);setLink('[data-release-api]', release ? releaseURL(release.api) : null);@@ -95,10 +94,12 @@ document.querySelectorAll('[data-copy-install]').forEach(button => {if (!state.release) return;try {await navigator.clipboard.writeText(installCommand());- setText('[data-release-status]', '✓ Install command copied');+ button.textContent = 'Copied';+ setTimeout(() => { button.textContent = 'Copy command'; }, 2000);} catch {selectCommand();- setText('[data-release-status]', '⚠ Clipboard unavailable. Copy the selected command');+ document.querySelectorAll('.release-feedback').forEach(element => { element.hidden = false; });+ setText('[data-release-status]', 'Clipboard unavailable. Copy the selected command.');}});});diff --git a/tests/export-options.test.js b/tests/export-options.test.jsindex e9fd5b96..7243712f 100644--- a/tests/export-options.test.js+++ b/tests/export-options.test.js@@ -1,6 +1,7 @@import assert from 'node:assert/strict';import test from 'node:test';-import { parseRenderOptions } from '../scripts/render-media.mjs';+import { FILM_DURATION } from '../src/film.js';+import { parseRenderOptions, selectEncoderBackend } from '../scripts/render-media.mjs';test('motion portrait exports derive dimensions and duration without launching a browser', () => {const options = parseRenderOptions(['--scene', 'motion', '--kind', 'video', '--aspect', 'portrait', '--backend', 'cpu']);@@ -9,6 +10,7 @@ test('motion portrait exports derive dimensions and duration without launching aassert.equal(options.duration, 12);assert.equal(options.start, 0);assert.equal(options.audio, null);+ assert.equal(options.encoderBackend, 'cpu');});test('square and explicit dimensions preserve their selected compositions', () => {@@ -39,7 +41,7 @@ test('new options retain start offsets and legacy renderer presets', () => {assert.equal(options.start, 2.5);const film = parseRenderOptions([]);assert.equal(film.scene, 'film');- assert.equal(film.duration, 32);+ assert.equal(film.duration, FILM_DURATION);assert.equal(film.width, 1280);assert.equal(film.height, 720);});@@ -47,11 +49,53 @@ test('new options retain start offsets and legacy renderer presets', () => {test('invalid export options fail before starting resources', () => {for (const args of [['--aspect', 'diagonal'], ['--start', '-1'], ['--start', 'NaN'], ['--duration', '0'],- ['--width', '0'], ['--backend', 'unknown'], ['--scene', 'unknown'], ['--encoder', 'unknown'],+ ['--width', '0'], ['--backend', 'unknown'], ['--scene', 'unknown'], ['--encoder', 'unknown'], ['--duration', '241'],['--unknown', 'value'], ['--aspect'], ['--kind', 'video', '--width', '101', '--height', '100'],+ ['--capture', 'webp'], ['--jpeg-quality', '0'], ['--jpeg-quality', '101'], ['--jpeg-quality', '94.5'], ['--jpeg-quality', 'NaN'],]) assert.throws(() => parseRenderOptions(args));});+test('video defaults to JPEG 95 and auto encoding while stills retain lossless PNG', () => {+ const video = parseRenderOptions(['--kind', 'video']);+ assert.equal(video.captureFormat, 'jpeg');+ assert.equal(video.jpegQuality, 95);+ assert.equal(video.encoderBackend, 'auto');+ assert.equal(parseRenderOptions([]).captureFormat, 'png');+ assert.equal(parseRenderOptions(['--kind', 'stills']).captureFormat, 'png');+ const losslessVideo = parseRenderOptions(['--kind', 'video', '--capture', 'png', '--encoder', 'cpu']);+ assert.equal(losslessVideo.captureFormat, 'png');+ assert.equal(losslessVideo.encoderBackend, 'cpu');+ const jpegImage = parseRenderOptions(['--capture', 'jpeg', '--jpeg-quality', '88']);+ assert.equal(jpegImage.jpegQuality, 88);+ assert.ok(jpegImage.output.endsWith('.jpg'));+});++test('encoder preflight probes hardware only when required and falls back only in auto mode', async () => {+ let probeCalls = 0;+ const available = async () => {+ probeCalls++;+ return { available: true };+ };+ const unavailable = async () => {+ probeCalls++;+ return { available: false, reason: 'driver unavailable' };+ };+ assert.equal(await selectEncoderBackend('cpu', unavailable), 'cpu');+ assert.equal(probeCalls, 0);+ assert.equal(await selectEncoderBackend('auto', available), 'gpu');+ assert.equal(await selectEncoderBackend('gpu', available), 'gpu');+ assert.equal(await selectEncoderBackend('auto', unavailable), 'cpu');+ await assert.rejects(selectEncoderBackend('gpu', unavailable), /NVENC is unavailable: driver unavailable/);+ assert.equal(probeCalls, 4);+ await assert.rejects(selectEncoderBackend('unknown', available), /Encoder must be/);+ assert.equal(probeCalls, 4);+});++test('full trailer exports accept the authored duration within the four-minute cap', () => {+ assert.equal(parseRenderOptions(['--kind', 'video', '--duration', '187']).duration, FILM_DURATION);+ assert.equal(parseRenderOptions(['--kind', 'video', '--duration', '240']).duration, 240);+});+test('asset captures select a supplied file and avoid an automatic soundtrack', () => {const plan = parseRenderOptions(['--scene', 'assets', '--asset', 'model.glb']);assert.equal(plan.options.asset, 'model.glb');diff --git a/tests/film.test.js b/tests/film.test.jsindex 1b7642ba..8be78a00 100644--- a/tests/film.test.js+++ b/tests/film.test.js@@ -1,34 +1,45 @@import assert from 'node:assert/strict';import test from 'node:test';-import { createFilmScenes, FILM_DURATION, sampleFilm } from '../src/film.js';+import { createFilmScenes, FILM_DURATION, FILM_SHOTS, sampleFilm } from '../src/film.js';+import { resolveEffects } from '../src/effects.js';+import { planRenderSize } from '../src/budget.js';-test('film timeline includes every set with exact cut boundaries and terminal black', () => {- const cuts = [[0, 'apparatus'], [5, 'atom'], [10, 'waves'], [13.5, 'desert'], [19, 'ignition'], [26, 'aftermath']];- assert.equal(FILM_DURATION, 32);- for (const [time, scene] of cuts) {- const sample = sampleFilm(time);- assert.equal(sample.scene, scene);- assert.equal(sample.sceneTime, 0);+const distance = (first, second) => Math.hypot(...first.map((value, axis) => value - second[axis]));++test('187-second study has contiguous authored cuts, a late detonation and terminal black', () => {+ assert.equal(FILM_DURATION, 187);+ assert.ok(FILM_SHOTS.length >= 24 && FILM_SHOTS.length <= 35);+ assert.equal(FILM_SHOTS[0].start, 0);+ assert.equal(FILM_SHOTS.at(-1).end, FILM_DURATION);+ for (const [index, shot] of FILM_SHOTS.entries()) {+ assert.ok(shot.end > shot.start);+ if (index) assert.equal(shot.start, FILM_SHOTS[index - 1].end);+ assert.equal(sampleFilm(shot.start).shotIndex, index);+ assert.equal(sampleFilm(shot.start).scene, shot.scene);+ assert.equal(sampleFilm(shot.end - 0.00001).shotIndex, index);}assert.deepEqual(sampleFilm(-10), sampleFilm(0));- assert.deepEqual(sampleFilm(100), sampleFilm(32));+ assert.deepEqual(sampleFilm(1000), sampleFilm(FILM_DURATION));assert.equal(sampleFilm(0).fade, 1);assert.equal(sampleFilm(2).fade, 0);- assert.equal(sampleFilm(32).fade, 1);- assert.equal(sampleFilm(29.5).title, 'CRITICAL');- assert.equal(sampleFilm(29.5).titleOpacity, 1);- assert.equal(sampleFilm(18.9).explosionProgress, 0);- assert.equal(sampleFilm(19).flash, 1);- assert.equal(sampleFilm(25.9).explosionProgress, 1);- assert.equal(sampleFilm(27).explosionProgress, 1);+ 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(180.9).explosionProgress, 0);+ assert.equal(sampleFilm(181).sceneTime, 0);+ assert.equal(sampleFilm(181).flash, 1);+ assert.equal(sampleFilm(185).explosionProgress, 1);});-test('all frame samples are deterministic, finite, bounded and have usable cameras', () => {+test('random-access frame samples are finite and independent of playback order', () => {const scenes = createFilmScenes();- for (let frame = 0; frame <= FILM_DURATION * 60; frame++) {- const time = frame / 60;- const sample = sampleFilm(time);- assert.deepEqual(sample, sampleFilm(time));+ const times = Array.from({ length: FILM_DURATION * 24 + 1 }, (_, index) => index / 24);+ const samples = times.map(sampleFilm);+ for (let index = samples.length - 1; index >= 0; index--) {+ const sample = sampleFilm(times[index]);+ assert.deepEqual(sample, samples[index]);assert.ok(scenes[sample.scene]);for (const value of [...sample.camera.eye, ...sample.camera.target, sample.camera.fov, sample.exposure, sample.time, sample.sceneTime]) {assert.ok(Number.isFinite(value));@@ -37,58 +48,76 @@ test('all frame samples are deterministic, finite, bounded and have usable camerassert.ok(value >= 0 && value <= 1);}assert.ok(sample.camera.fov >= 20 && sample.camera.fov <= 65);- assert.ok(Math.hypot(...sample.camera.eye.map((value, axis) => value - sample.camera.target[axis])) > 0.5);+ assert.ok(distance(sample.camera.eye, sample.camera.target) > 0.5);+ assert.doesNotThrow(() => resolveEffects(sample.effects));}- for (const invalid of [NaN, Infinity, -Infinity, undefined, '1']) {+ for (const invalid of [NaN, Infinity, -Infinity, undefined, null, '1', {}]) {assert.throws(() => sampleFilm(invalid), TypeError);}});-test('camera motion stays continuous and eases to rest within each authored shot', () => {- const boundaries = [0, 5, 10, 13.5, 17, 19, 26, 32];- const distance = (first, second) => Math.hypot(...first.map((value, axis) => value - second[axis]));- for (let index = 0; index < boundaries.length - 1; index++) {- const start = boundaries[index];- const end = boundaries[index + 1];- assert.ok(distance(sampleFilm(start).camera.eye, sampleFilm(end - 0.001).camera.eye) > 0.1);- assert.ok(distance(sampleFilm(start).camera.eye, sampleFilm(start + 0.001).camera.eye) < 0.001);- assert.ok(distance(sampleFilm(end - 0.002).camera.eye, sampleFilm(end - 0.001).camera.eye) < 0.001);- for (let time = start; time + 0.01 < end; time += 0.01) {- assert.ok(distance(sampleFilm(time).camera.eye, sampleFilm(time + 0.01).camera.eye) < 0.1);- assert.ok(distance(sampleFilm(time).camera.target, sampleFilm(time + 0.01).camera.target) < 0.04);+test('camera motion is continuous and eases to rest within each shot', () => {+ for (const shot of FILM_SHOTS) {+ assert.ok(distance(sampleFilm(shot.start).camera.eye, sampleFilm(shot.end - 0.001).camera.eye) > 0.1);+ assert.ok(distance(sampleFilm(shot.start).camera.eye, sampleFilm(shot.start + 0.001).camera.eye) < 0.001);+ assert.ok(distance(sampleFilm(shot.end - 0.002).camera.eye, sampleFilm(shot.end - 0.001).camera.eye) < 0.001);+ for (let time = shot.start; time + 0.01 < shot.end; time += 0.01) {+ assert.ok(distance(sampleFilm(time).camera.eye, sampleFilm(time + 0.01).camera.eye) < 0.12);+ assert.ok(distance(sampleFilm(time).camera.target, sampleFilm(time + 0.01).camera.target) < 0.05);}}});-test('six 3D sets respect instancing, material, geometry and scene budgets', () => {+test('sets keep shared static geometry, valid surfaces and the 384 MiB target budget', () => {const scenes = createFilmScenes();- assert.equal(Object.keys(scenes).length, 6);+ assert.ok(Object.keys(scenes).length >= 8);+ const referencedSets = new Set(FILM_SHOTS.map(shot => shot.scene));+ assert.deepEqual([...referencedSets].sort(), Object.keys(scenes).sort());const budgets = {};+ const checkedGeometries = new Set();for (const [name, scene] of Object.entries(scenes)) {assert.equal(scene.ground, false);assert.ok(scene.environment.fogDensity >= 0);assert.equal(scene.environment.lightDirection.length, 3);- assert.ok(scene.parts.length > 100 && scene.parts.length < 1000);+ assert.ok(scene.parts.length > 100 && scene.parts.length <= 1500);const triangleCount = scene.parts.reduce((total, part) => total + part.geometry.indices.length / 3, 0);- assert.ok(triangleCount < 600000, name);- assert.ok(new Set(scene.parts.map(part => part.geometry)).size <= 8);+ assert.ok(triangleCount <= 700000, name);+ const geometries = new Set(scene.parts.map(part => part.geometry));+ assert.ok(geometries.size <= 12);+ let geometryBytes = scene.parts.length * 41 * 4;+ for (const geometry of geometries) {+ geometryBytes += geometry.positions.byteLength + geometry.normals.byteLength + geometry.indices.byteLength;+ if (checkedGeometries.has(geometry)) continue;+ checkedGeometries.add(geometry);+ assert.ok(geometry.positions instanceof Float32Array);+ assert.ok(geometry.normals instanceof Float32Array);+ assert.ok(geometry.indices instanceof Uint32Array);+ assert.equal(geometry.positions.length, geometry.normals.length);+ assert.ok(Array.from(geometry.positions).every(Number.isFinite));+ for (let vertex = 0; vertex < geometry.normals.length; vertex += 3) {+ assert.ok(Math.abs(Math.hypot(...geometry.normals.slice(vertex, vertex + 3)) - 1) < 0.00001);+ }+ for (const index of geometry.indices) assert.ok(index < geometry.positions.length / 3);+ }for (const part of scene.parts) {assert.ok(part.name);assert.ok(part.matrix instanceof Float32Array);assert.equal(part.matrix.length, 16);assert.equal(part.matrix[15], 1);assert.ok(Array.from(part.matrix).every(Number.isFinite));- assert.ok(part.geometry.positions instanceof Float32Array);- assert.ok(part.geometry.normals instanceof Float32Array);- assert.ok(part.geometry.indices instanceof Uint32Array);assert.ok(part.material.color.every(value => value >= 0 && value <= 1));assert.ok(part.material.roughness > 0 && part.material.roughness <= 1);assert.ok(part.material.metallic >= 0 && part.material.metallic <= 1);assert.ok(part.material.emission >= 0);}- budgets[name] = { parts: scene.parts.length, triangles: triangleCount };+ const plan = planRenderSize({ width: 1280, height: 720, samples: 4, memoryBudgetMiB: 384, hdr: true, bloom: true, geometryBytes });+ assert.equal(plan.reduced, false);+ assert.ok(plan.estimatedBytes < 384 * 1024 * 1024);+ budgets[name] = { parts: scene.parts.length, triangles: triangleCount, geometries: geometries.size, estimatedMiB: Math.round(plan.estimatedBytes / 1024 / 1024) };}assert.ok(scenes.ignition.parts.some(part => part.material.tag === 'fire'));assert.ok(scenes.ignition.parts.some(part => part.material.tag === 'smoke'));+ assert.ok(scenes.portrait.parts.some(part => part.name === 'Fedora sweeping brim'));+ assert.ok(scenes.settlement.parts.some(part => part.name === 'Army jeep chassis'));console.log(JSON.stringify(budgets));});