3D engine that AI agents drive
Add explodable WALL-E studio, bounded media exports and scene skills
Nguyen Xuan An32aa19cc3448
diff --git a/README.md b/README.mdindex a845292c..1993a356 100644--- a/README.md+++ b/README.md@@ -1,16 +1,18 @@# 67.js-67.js is an experimental WebGL2 renderer with an original procedural 3D model and an interactive object studio.-The demo runs without Three.js. The performance comparison loads Three.js only when requested.+67.js is an experimental WebGL2 renderer with an explodable WALL·E study, an interactive nature world and a deterministic 3D short film.+The viewers run without Three.js. The optional benchmark loads Three.js separately.-+-The specimen contains 252 parts and 206,432 triangles across eight shared geometries.-The renderer submits nine draw calls, including the studio floor.-Its materials use a GGX lighting model, analytical studio reflections, a static shadow map and ACES tone mapping.+The WALL·E study contains 574 parts, 860,380 triangles and seven shared geometries.+The studio submits eight geometry draws, including the floor.+Its slider separates 20 assemblies to expose batteries, circuit boards, motors, gears and optical mechanisms.+The layer controls show the shell, the interior or both. GLB export preserves the selected layers, finish and explosion amount.-The studio supports orbiting, zooming, three finishes, exposure adjustment, surface inspection and GLB export.-The exported model opens in glTF viewers. Blender supports importing this GLB format.+The renderer uses sampled fillets, GGX lighting, shadows, explicit MSAA, FXAA, specular filtering and ACES tone mapping.+It reuses geometry buffers during explosion and refreshes shadows without allocating another shadow texture.+The studio renders on demand. Continuous animation pauses in hidden tabs.## Run@@ -19,64 +21,95 @@ The exported model opens in glTF viewers. Blender supports importing this GLB fo3. Run `npm run dev`.4. Open the URL printed by Vite.-## Checks+| Page | Experience |+| --- | --- |+| `/` | 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. |-1. Run `npm test` to check geometry and GLB export with an independent glTF loader.-2. Run `npm run build` to create the production site in `dist/`.-3. Run `npm run smoke` to exercise the studio in headless Chrome.+CRITICAL combines mechanical details, atomic orbits, waves, a desert test tower and a volumetric ignition sequence.+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.++## Render images and video++1. Run `npm run score` to generate the original soundtrack.+2. Choose a command below for the required scene and backend.+3. Inspect the output and its JSON report.++```powershell+npm run render -- --kind image --scene object --backend gpu --preset high --output artifacts/wall-e.png+npm run render -- --kind image --scene nature --backend gpu --preset high --output artifacts/nature.png+npm run render -- --kind image --scene object --backend cpu --preset cpu --output artifacts/wall-e-cpu.png+npm run render -- --kind video --scene film --backend gpu --preset balanced --encoder gpu --output public/media/critical.mp4+```-The smoke script uses installed Chrome on Windows, or Playwright Chromium on other platforms.-If Chromium is missing, run `npx playwright install chromium`.-The smoke saves screenshots, a GLB and benchmark results under the ignored `artifacts/` directory.+| Preset | Dimensions | MSAA samples | FPS | Target budget |+| --- | --- | ---: | ---: | ---: |+| `preview` | 960 × 540 | 2 | 24 | 256 MiB |+| `balanced` | 1280 × 720 | 4 | 24 | 384 MiB |+| `high` | 1920 × 1080 | 4 | 24 | 512 MiB |+| `cpu` | 640 × 360 | 1 | 12 | 192 MiB |-## Performance+GPU rendering uses hardware WebGL. CPU rendering explicitly requests and verifies ANGLE SwiftShader.+The encoder independently supports two-thread libx264 or NVIDIA NVENC.+The exporter streams one frame at a time and waits for encoder backpressure.+It keeps one live scene renderer and disables development reloads during capture.-The benchmark compares 67.js and Three.js with identical geometry, camera, resolution and flat shaders.-Each renderer runs with instancing and with individual meshes.-It measures CPU draw submission, with GPU synchronization outside the timed region.-The reported value is the median of 120 samples after 30 warmup samples.-Each sample averages eight submissions to reduce clock rounding.+The planner reduces render dimensions before targets exceed their estimated budget.+The estimate includes geometry, shadows, targets and frame staging. It excludes some browser and driver allocations.+The report records actual dimensions, estimated render memory, Node RSS and sampled browser JavaScript heap.+Node and JavaScript heap guards stop capture above 512 MiB and 256 MiB respectively.+These guards cannot guarantee that every driver or system allocation succeeds.-The local Chrome run on an RTX 3060 measured these medians.+## Skills++The repository includes two reusable Codex skills.++- [build-67js-scene](skills/build-67js-scene/SKILL.md) covers geometry, materials, cameras, interaction and anti-aliasing.+- [render-67js-media](skills/render-67js-media/SKILL.md) covers CPU/GPU presets, streaming exports and memory measurements.++## Checks and performance++1. Run `npm test` to validate geometry, scene budgets, the timeline and independent GLB loading.+2. Run `npm run build` to create all three production pages in `dist/`.+3. Run `npm run smoke` to exercise the studio in headless Chrome.-| Renderer | CPU milliseconds | Draw calls |-| --- | ---: | ---: |-| 67.js, instanced | 0.0056 | 9 |-| Three.js, instanced | 0.0169 | 9 |-| 67.js, individual | 0.0319 | 253 |-| Three.js, individual | 0.4238 | 253 |+The smoke saves rendered screenshots, a GLB and benchmark results under the ignored `artifacts/` directory.+The benchmark compares identical geometry, camera, resolution and flat shaders with both instanced and individual draws.+It measures CPU submission over 120 samples after warmup, with GPU synchronization outside the timed region.-These results apply to this static scene and CPU submission only.-The benchmark images agreed on more than 99.99% of color channels within one byte of tolerance.-They do not establish a general speed advantage, GPU performance or matching image quality against Three.js or Blender.-Vite serves isolation headers for finer browser timers. Other hosts need equivalent COOP and COEP headers for comparable measurements.+The results establish no general speed advantage or visual parity with Three.js or Blender.+Vite serves COOP and COEP headers for fine browser timers. Other hosts need equivalent headers for comparable timing.+Detailed measured results and limits are in [verification.md](docs/verification.md).-## Renderer shape+## API-`createModel()` returns a flat array of parts.-Each part has a shared geometry, a column-major transform, a name and a metallic/roughness material.-`Renderer67` groups parts by geometry identity and uploads transforms, normal matrices and materials as instance attributes.-The studio renders on demand, with continuous rendering enabled only for auto orbit.-Hidden tabs stop rendering. Static shadows do not rerender during camera movement.+`createModel()` returns shared geometries, column-major matrices, linear RGB materials and optional assembly offsets.+`Renderer67` groups geometry identities into instanced batches.```jsimport { Renderer67 } from './src/renderer.js';import { createModel } from './src/model.js';-const renderer = new Renderer67(canvas, createModel());-renderer.render({ eye: [4, 3, 5], target: [0, 1.35, 0] });-// Call resize() after changing the canvas dimensions.-// Call dispose() when the viewer is removed.+const renderer = new Renderer67(canvas, createModel(), {+ samples: 4,+ memoryBudgetMiB: 256,+});+renderer.render({ eye: [4, 3, 7], target: [0, 1.5, 0], assemblyAmount: 0.5 });+// Call resize() after CSS dimensions change.+// Call dispose() before replacing the renderer.```-This prototype focuses on static procedural objects.-It does not yet support animation, texture maps, asset loading, ray tracing or a general scene graph.-Blender-level realism remains a visual target, rather than a verified equivalence claim.+This prototype supports procedural scenes and authored animation. It lacks texture loading, ray tracing and a general scene graph.+Blender-level realism remains a visual target.-## References+## Credits-- [Three.js](https://threejs.org/) and its [source repository](https://github.com/mrdoob/three.js/).-- [Blender source](https://projects.blender.org/blender/blender).-- [gl-matrix](https://github.com/toji/gl-matrix) supplies the matrix operations.+WALL·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).+It includes no film footage, dialogue or soundtrack samples.-The geometry and model in this repository are original. No Blender source or external model assets are included.+- [Three.js](https://threejs.org/) and its [source](https://github.com/mrdoob/three.js/) provide the benchmark reference.+- [Blender](https://projects.blender.org/blender/blender) provides the visual quality target.+- [gl-matrix](https://github.com/toji/gl-matrix) supplies matrix operations.diff --git a/docs/benchmark.json b/docs/benchmark.jsonindex 9e9ea192..2e4c3fa7 100644--- a/docs/benchmark.json+++ b/docs/benchmark.json@@ -1,35 +1,35 @@{"graphics": {- "parts": 252,- "triangles": 206432,- "calls": 9,+ "parts": 574,+ "triangles": 860380,+ "calls": 8,"glError": 0,"gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)"},"results": [{"name": "67.js instanced",- "milliseconds": 0.005625000223517418,- "calls": 9,+ "milliseconds": 0.015000000596046448,+ "calls": 8,"pixelAgreement": 1},{"name": "67.js individual",- "milliseconds": 0.0318750012665987,- "calls": 253,- "pixelAgreement": 0.9999951171875+ "milliseconds": 1.8168749995529652,+ "calls": 575,+ "pixelAgreement": 0.99999755859375},{"name": "Three.js instanced",- "milliseconds": 0.016875000670552254,- "calls": 9,- "pixelAgreement": 0.999990234375+ "milliseconds": 0.030000001192092896,+ "calls": 8,+ "pixelAgreement": 0.9999674479166667},{"name": "Three.js individual",- "milliseconds": 0.4237500000745058,- "calls": 253,- "pixelAgreement": 0.9999951171875+ "milliseconds": 1.9962499998509884,+ "calls": 575,+ "pixelAgreement": 0.9999698893229166}],"resolution": [diff --git a/docs/film-contact.png b/docs/film-contact.pngnew file mode 100644index 00000000..51a2334cBinary files /dev/null and b/docs/film-contact.png differdiff --git a/docs/film-cpu-trial.json b/docs/film-cpu-trial.jsonnew file mode 100644index 00000000..a2a48365--- /dev/null+++ b/docs/film-cpu-trial.json@@ -0,0 +1,29 @@+{+ "scene": "film",+ "kind": "video",+ "backend": "cpu",+ "preset": "cpu",+ "width": 640,+ "height": 360,+ "actualRenderSize": {+ "width": 640,+ "height": 360,+ "reduced": false+ },+ "fps": 12,+ "duration": 2,+ "memoryBudgetMiB": 192,+ "peakEstimatedRenderBytes": 23381640,+ "peakNodeBytes": 165179392,+ "peakBrowserHeap": 5058368,+ "maximumPendingFrames": 1,+ "firstFrameBytes": 1449,+ "elapsedSeconds": 7.3255598,+ "graphics": {+ "gpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)",+ "samples": 1,+ "glError": 0+ },+ "output": "film-cpu-trial.mp4",+ "errors": []+}\ No newline at end of filediff --git a/docs/nature.png b/docs/nature.pngnew file mode 100644index 00000000..905741c7Binary files /dev/null and b/docs/nature.png differdiff --git a/docs/specimen.png b/docs/specimen.pngdeleted file mode 100644index f279f7bb..00000000Binary files a/docs/specimen.png and /dev/null differdiff --git a/docs/verification.md b/docs/verification.mdindex 1fbd42c8..72d7fd81 100644--- a/docs/verification.md+++ b/docs/verification.md@@ -1,25 +1,65 @@# Verification-The local run used Chrome 154 through Playwright and an NVIDIA RTX 3060 through ANGLE D3D11.-The raw benchmark results are in `benchmark.json`.+The checks used Windows Chrome 154 through Playwright, an RTX 3060 through ANGLE D3D11 and CPU rendering through SwiftShader.| Check | Result || --- | --- |-| Geometry winding, unit normals, indices and model bounds | Four Node tests passed, including export validation. |-| GLB export | The independent Three.js GLTFLoader loaded all 252 model nodes. |-| WebGL | No GL errors or browser console errors during the smoke. |-| Desktop | The rendered 1440 × 900 studio was inspected. |-| Mobile | The rendered 390 × 844 and 320 × 700 studio was inspected. |-| Controls | Finish, reset, keyboard orbit, normals, auto orbit and GLB download passed. |-| Recovery | Context loss and restoration passed. |-| Benchmark output | All four renderers matched the reference image above 99.99% of channels. |-| Production build | Vite built successfully. |--The interface review covered the new studio and its controls.-The first mobile render overlapped the model and controls. A separate mobile canvas region fixed the overlap.-The selected finish swatch initially lost its fill. A specific selected-swatch rule fixed that state.-Both repaired states were checked in the subsequent rendered smoke.--Keyboard controls use native elements, visible focus styles and explicit labels.-Screen-reader behavior, 200% browser zoom and a formal contrast audit were not verified.-The benchmark measures CPU submission only. GPU timing and visual parity with Blender remain unverified.+| Node tests | All 19 tests passed for geometry, bounds, scene budgets, timeline sampling and GLB loading. |+| GLB | The independent Three.js GLTFLoader loaded all 574 WALL·E nodes. The assembled file contains 635,752 bytes. |+| Explosion | The GPU pixel checksum returned to its original value after a 0 → 50 → 100 → 0 slider round trip. |+| Allocation reuse | The shadow texture remained identical while the slider moved. |+| Layers and export | Shell, interior and combined views worked. Exploded GLB translations matched the authored offsets. |+| Studio controls | Finishes, keyboard orbit, reset, normals, auto orbit and downloads passed. |+| Recovery | WebGL context loss and restoration passed without graphics errors. |+| Nature | Daylight, wind, viewpoints, detail, water ripples, keyboard orbit and PNG download passed. |+| Film | Out-of-order seeks reproduced ignition pixels. Playback, score loading, pause and mobile controls passed. |+| Layout | Rendered studio, nature and film views were inspected at desktop and 320-pixel widths. |+| Reduced motion | Nature starts paused. Film playback waits for a click. |+| Production | Vite built all three pages. Its large-chunk warning applies to the optional Three.js benchmark. |+| Skills | Both entrypoints passed frontmatter, length and route validation. GPU and CPU export commands produced usable files. |++The studio review found panels covering the model and missing spaces around mobile line breaks.+Camera framing and HTML whitespace fixed those problems. The subsequent screenshots show the repaired views.+Material tags use flat shader varyings because interpolated tags previously produced stripes on the floor.+The current studio enables four MSAA samples, FXAA and specular filtering.++## Offline exports++| Export | Output | Elapsed time | Estimated render memory | Observed Node RSS |+| --- | --- | ---: | ---: | ---: |+| GPU WALL·E image | 1920 × 1080 PNG | 1.68 s | 119.4 MiB | 124.0 MiB |+| CPU WALL·E image | 640 × 360 PNG | 4.02 s | 22.7 MiB | 124.5 MiB |+| GPU film, NVENC | 1280 × 720, 32 s, 24 FPS | 256.68 s | 61.9 MiB | 214.8 MiB |+| CPU film trial, libx264 | 640 × 360, 2 s, 12 FPS | 7.33 s | 22.3 MiB | 157.5 MiB |++The image runs use different resolutions. Their times do not establish a direct CPU/GPU speed comparison.+Elapsed export time includes browser startup, PNG capture and encoding.+All four runs reported zero WebGL errors.+Both video runs held a maximum of one pending frame.+The full GPU film sampled a maximum JavaScript heap of 6.9 MiB.++FFprobe verified 768 H.264 frames, 32.000 seconds, 24 FPS, BT.709 metadata and 48 kHz stereo AAC.+The MP4 contains 13,759,581 bytes. Representative encoded frames were inspected in `film-contact.png`.++FFmpeg measured the encoded score at -21.0 dB mean volume and -4.5 dB peak volume.+The score uses original synthesized tones and seeded noise. No human listening check was performed.++The JSON reports contain the exact measurements.++- `wall-e-gpu.json` and `wall-e-cpu.json` record the image runs.+- `film-cpu-trial.json` records the software rendering and encoding trial.+- `../public/media/critical.mp4.json` records the full hardware export.+- `benchmark.json` records the comparison with Three.js.++The memory estimate covers authored targets, geometry and staging. It does not measure total driver VRAM or browser RSS.+The sampled JavaScript heap can miss intermediate peaks.+The guards reduce allocation risk without guaranteeing that every system allocation succeeds.++## Limits++The benchmark measures CPU draw submission with identical flat shaders. Every result agreed on more than 99.99% of image channels.+It does not measure GPU frame time or establish general Three.js superiority.++The film and nature world use stylized procedural assets. Blender-level realism remains unverified.+Screen-reader behavior, 200% browser zoom and formal contrast compliance were not verified.+The skills passed structural checks and real pipeline exercises. Automatic skill selection was not evaluated.diff --git a/docs/wall-e-cpu.json b/docs/wall-e-cpu.jsonnew file mode 100644index 00000000..e7cc5a2f--- /dev/null+++ b/docs/wall-e-cpu.json@@ -0,0 +1,30 @@+{+ "scene": "object",+ "kind": "image",+ "backend": "cpu",+ "preset": "cpu",+ "assembly": 0,+ "width": 640,+ "height": 360,+ "actualRenderSize": {+ "width": 640,+ "height": 360,+ "reduced": false+ },+ "fps": 12,+ "duration": null,+ "memoryBudgetMiB": 192,+ "peakEstimatedRenderBytes": 23808212,+ "peakNodeBytes": 130510848,+ "peakBrowserHeap": 0,+ "maximumPendingFrames": 0,+ "firstFrameBytes": 85627,+ "elapsedSeconds": 4.0178842,+ "graphics": {+ "gpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)",+ "samples": 1,+ "glError": 0+ },+ "output": "wall-e-cpu.png",+ "errors": []+}\ No newline at end of filediff --git a/docs/wall-e-exploded.png b/docs/wall-e-exploded.pngnew file mode 100644index 00000000..54e70882Binary files /dev/null and b/docs/wall-e-exploded.png differdiff --git a/docs/wall-e-gpu.json b/docs/wall-e-gpu.jsonnew file mode 100644index 00000000..e530afbf--- /dev/null+++ b/docs/wall-e-gpu.json@@ -0,0 +1,30 @@+{+ "scene": "object",+ "kind": "image",+ "backend": "gpu",+ "preset": "high",+ "assembly": 0,+ "width": 1920,+ "height": 1080,+ "actualRenderSize": {+ "width": 1920,+ "height": 1080,+ "reduced": false+ },+ "fps": 24,+ "duration": null,+ "memoryBudgetMiB": 512,+ "peakEstimatedRenderBytes": 125184212,+ "peakNodeBytes": 130011136,+ "peakBrowserHeap": 0,+ "maximumPendingFrames": 0,+ "firstFrameBytes": 316128,+ "elapsedSeconds": 1.6807979,+ "graphics": {+ "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)",+ "samples": 4,+ "glError": 0+ },+ "output": "wall-e.png",+ "errors": []+}\ No newline at end of filediff --git a/docs/wall-e.png b/docs/wall-e.pngnew file mode 100644index 00000000..a25831f6Binary files /dev/null and b/docs/wall-e.png differdiff --git a/index.html b/index.htmlindex 5a82565c..ce3280ef 100644--- a/index.html+++ b/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="theme-color" content="#25292d" />- <meta name="description" content="67.js. A small WebGL2 engine, a detailed procedural object, and a browser 3D studio." />+ <meta name="description" content="Explore WALL·E inside and out. An explodable procedural 3D study rendered with 67.js." /><title>67.js · Object studio</title><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='15' fill='%2325292d'/%3E%3Ctext x='7' y='45' font-family='sans-serif' font-weight='bold' font-size='38' fill='%23b7eddf'%3E67%3C/text%3E%3C/svg%3E" /></head>@@ -13,26 +13,32 @@<canvas id="viewport" tabindex="0" aria-label="3D model. Drag or use arrow keys to orbit. Scroll or use plus and minus to zoom."></canvas><header class="toolbar"><a class="brand" href="./" aria-label="67.js home">67<span>.js</span></a>- <span class="studio-name">Object studio</span>+ <nav class="studio-nav" aria-label="Scenes"><a href="./" aria-current="page">Object</a><a href="./nature.html">Nature</a><a href="./film.html">Film</a></nav><div class="toolbar-actions"><button id="reset" title="Reset camera (R)">Reset view</button><button id="export" class="primary">Export GLB <span aria-hidden="true">↗</span></button></div></header><section class="object-info" aria-labelledby="object-title">- <h1 id="object-title">A little machine. <br />A lot of detail.</h1>- <p id="model-description">An original mechanical specimen. <br />Built from geometry. Rendered in your browser.</p>- <div class="object-caption"><span class="status-dot" aria-hidden="true">●</span> <span id="model-name">Specimen 01</span><span class="caption-separator">/</span><span>Procedural model</span></div>+ <h1 id="object-title">WALL·E, <br />inside out.</h1>+ <p id="model-description">Pull apart the shell. Explore the machinery. <br />Slide back to bring him together.</p>+ <div class="object-caption"><span class="status-dot" aria-hidden="true">●</span> <span id="model-name">WALL·E study</span><span class="caption-separator">/</span><span>Procedural geometry</span></div></section><aside class="controls" aria-label="Model appearance">+ <div class="assembly-control">+ <label for="assembly">Explode model <output id="assembly-value">0%</output></label>+ <input id="assembly" type="range" min="0" max="100" step="1" value="0" aria-valuetext="Assembled" />+ <div class="assembly-endpoints"><span>Assembled</span><span>Exploded</span></div>+ <div class="layer-actions" role="group" aria-label="Model layers"><button data-layer="all" aria-pressed="true">All</button><button data-layer="exterior" aria-pressed="false">Shell</button><button data-layer="interior" aria-pressed="false">Inside</button></div>+ </div><fieldset><legend>Finish</legend><div class="finishes">- <button class="swatch selected" data-finish="titanium" aria-label="Titanium finish" aria-pressed="true" style="--swatch:#c29a62"></button>+ <button class="swatch selected" data-finish="yellow" aria-label="Yellow finish" aria-pressed="true" style="--swatch:#d8a33c"></button><button class="swatch" data-finish="ceramic" aria-label="Ceramic finish" aria-pressed="false" style="--swatch:#d7e0de"></button><button class="swatch" data-finish="graphite" aria-label="Graphite finish" aria-pressed="false" style="--swatch:#59666e"></button></div>- <span id="finish-name">Titanium</span>+ <span id="finish-name">Factory yellow</span></fieldset><label class="exposure-label" for="exposure">Exposure <output id="exposure-value">1.0</output></label><input id="exposure" type="range" min="0.5" max="1.8" step="0.1" value="1" />diff --git a/package.json b/package.jsonindex 7188ad62..47583940 100644--- a/package.json+++ b/package.json@@ -9,7 +9,11 @@"build": "vite build","preview": "vite preview --host 127.0.0.1","test": "node --test",- "smoke": "node scripts/smoke.mjs"+ "smoke": "node scripts/smoke.mjs",+ "smoke:scenes": "node scripts/smoke-scenes.mjs",+ "render": "node scripts/render-media.mjs",+ "score": "node scripts/score.mjs",+ "export:model": "node scripts/export-model.mjs"},"dependencies": {"gl-matrix": "3.4.4"diff --git a/public/media/critical.mp4 b/public/media/critical.mp4new file mode 100644index 00000000..0e6e74d1Binary files /dev/null and b/public/media/critical.mp4 differdiff --git a/public/media/critical.mp4.json b/public/media/critical.mp4.jsonnew file mode 100644index 00000000..6d00f247--- /dev/null+++ b/public/media/critical.mp4.json@@ -0,0 +1,29 @@+{+ "scene": "film",+ "kind": "video",+ "backend": "gpu",+ "preset": "balanced",+ "width": 1280,+ "height": 720,+ "actualRenderSize": {+ "width": 1280,+ "height": 720,+ "reduced": false+ },+ "fps": 24,+ "duration": 32,+ "memoryBudgetMiB": 384,+ "peakEstimatedRenderBytes": 64853640,+ "peakNodeBytes": 225230848,+ "peakBrowserHeap": 7223176,+ "maximumPendingFrames": 1,+ "firstFrameBytes": 4250,+ "elapsedSeconds": 256.6760515,+ "graphics": {+ "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)",+ "samples": 4,+ "glError": 0+ },+ "output": "critical.mp4",+ "errors": []+}diff --git a/public/specimen.glb b/public/specimen.glbdeleted file mode 100644index 7ac437b0..00000000Binary files a/public/specimen.glb and /dev/null differdiff --git a/public/wall-e.glb b/public/wall-e.glbnew file mode 100644index 00000000..99e5e940Binary files /dev/null and b/public/wall-e.glb differdiff --git a/scripts/export-model.mjs b/scripts/export-model.mjsindex 5ee6260b..0c573e9b 100644--- a/scripts/export-model.mjs+++ b/scripts/export-model.mjs@@ -5,5 +5,5 @@ import { exportGlb } from '../src/export.js';const directory = new URL('../public/', import.meta.url);await mkdir(directory, { recursive: true });const binary = exportGlb(createModel());-await writeFile(new URL('specimen.glb', directory), new Uint8Array(binary));-console.log(`Exported original model: ${binary.byteLength} bytes`);+await writeFile(new URL('wall-e.glb', directory), new Uint8Array(binary));+console.log(`Exported procedural WALL-E: ${binary.byteLength} bytes`);diff --git a/scripts/render-media.mjs b/scripts/render-media.mjsnew file mode 100644index 00000000..a8883ef7--- /dev/null+++ b/scripts/render-media.mjs@@ -0,0 +1,170 @@+import { chromium } from 'playwright';+import { spawn, execFile } from 'node:child_process';+import { once } from 'node:events';+import { mkdir, writeFile } from 'node:fs/promises';+import { existsSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { resolve, dirname, basename } from 'node:path';+import { RENDER_PRESETS } from '../src/budget.js';++function argumentsFrom(values) {+ const result = {};+ 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.');+ result[values[index].slice(2)] = values[index + 1];+ }+ return result;+}++const options = argumentsFrom(process.argv.slice(2));+const kind = options.kind ?? 'image';+const backend = options.backend ?? 'gpu';+const scene = options.scene ?? 'film';+const presetName = options.preset ?? (backend === 'cpu' ? 'cpu' : 'balanced');+const preset = RENDER_PRESETS[presetName];+if (!preset || !['image', 'video', 'stills'].includes(kind) || !['gpu', 'cpu'].includes(backend) || !['film', 'nature', 'object'].includes(scene)) throw new Error('Unknown render kind, backend, scene or preset.');+const numberOption = (name, fallback, minimum, maximum) => {+ const value = Number(options[name] ?? fallback);+ if (!Number.isFinite(value) || value < minimum || value > maximum) throw new Error(`${name} must be between ${minimum} and ${maximum}.`);+ return value;+};+const width = Math.round(numberOption('width', preset.width, 64, 4096));+const height = Math.round(numberOption('height', preset.height, 64, 4096));+const fps = numberOption('fps', preset.fps, 1, 60);+const duration = numberOption('duration', 32, 0.1, 120);+const time = numberOption('time', 3, 0, 32);+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'}`);+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 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;+let encoder;+let encoderError = '';+let peakNodeBytes = 0;+let peakBrowserHeap = 0;+let peakEstimatedRenderBytes = 0;+let maximumPendingFrames = 0;+let firstFrameBytes = 0;+let actualRenderSize;+const started = performance.now();+const progress = [];+try {+ await new Promise((resolveStarted, reject) => {+ const timeout = setTimeout(() => reject(new Error('Render server did not start.')), 15000);+ server.stdout.on('data', (data) => {+ if (data.toString().includes('127.0.0.1:5181')) { clearTimeout(timeout); resolveStarted(); }+ });+ server.on('error', reject);+ server.on('exit', (code) => { clearTimeout(timeout); reject(new Error(`Render server exited ${code}.`)); });+ });+ const args = ['--enable-webgl', '--ignore-gpu-blocklist'];+ if (backend === 'cpu') args.push('--use-angle=swiftshader', '--enable-unsafe-swiftshader');+ browser = await chromium.launch({ headless: true, ...(existsSync(chrome) ? { executablePath: chrome } : {}), args });+ const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: 1 });+ const errors = [];+ page.on('pageerror', (error) => errors.push(error.message));+ const route = scene === 'object' ? 'index.html' : `${scene}.html`;+ const query = new URLSearchParams({ export: '1', width: String(width), height: String(height), memory: String(memory), samples: String(backend === 'cpu' ? 1 : preset.samples) });+ await page.goto(`http://127.0.0.1:5181/${route}?${query}`);+ await page.waitForFunction((mode) => mode === 'film' ? window.__filmReady : mode === 'nature' ? window.__nature : window.__studio, scene, { timeout: 60000 });+ if (scene !== 'film') await page.evaluate(({ memory, width, height, samples, scene, assembly }) => {+ const canvas = document.querySelector('canvas');+ canvas.style.cssText = `position:fixed;inset:0;width:${width}px;height:${height}px`;+ document.querySelectorAll('main > :not(canvas)').forEach((element) => {+ element.hidden = true;+ element.style.setProperty('display', 'none', 'important');+ });+ const renderer = scene === 'object' ? window.__studio.renderer : window.__nature.renderer;+ renderer.memoryBudgetMiB = memory;+ renderer.pixelRatio = 1;+ renderer.samples = samples;+ renderer.resize();+ if (scene === 'object') {+ window.__studio.state.exporting = true;+ window.__studio.state.assembly = assembly;+ renderer.projection[8] = 0;+ window.renderAt = () => renderer.render(window.__studio.camera());+ } else window.renderAt = (time) => window.__nature.renderAt(time);+ }, { memory, width, height, samples: backend === 'cpu' ? 1 : preset.samples, scene, assembly });+ const session = await page.context().newCDPSession(page);+ const render = async (seconds) => {+ await page.evaluate((value) => {+ if (window.renderAt) window.renderAt(value);+ else window.__nature.renderAt(value);+ }, seconds);+ const rendererPlan = await page.evaluate(() => {+ const renderer = window.__film?.renderer ?? window.__nature?.renderer ?? window.__studio?.renderer;+ return renderer.memoryPlan;+ });+ 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.');+ const nodeBytes = process.memoryUsage().rss;+ peakNodeBytes = Math.max(peakNodeBytes, nodeBytes);+ if (nodeBytes > 512 * 1024 ** 2) throw new Error('Capture process exceeded 512 MiB. Export stopped before buffering more frames.');+ };+ async function capture(seconds) {+ await render(seconds);+ const image = await page.screenshot({ type: 'png', animations: 'disabled' });+ if (!firstFrameBytes) firstFrameBytes = image.byteLength;+ return image;+ }+ if (kind === 'video') {+ const codec = options.encoder ?? 'cpu';+ if (!['cpu', 'gpu'].includes(codec)) throw new Error('Encoder must be cpu or gpu.');+ const audioPath = resolve(options.audio ?? 'artifacts/critical-score.wav');+ const audioArguments = existsSync(audioPath) ? ['-i', audioPath] : [];+ const codecArguments = codec === '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];+ 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 frameCount = Math.ceil(duration * fps);+ for (let frame = 0; frame < frameCount; frame++) {+ const image = await capture(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 (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`;+ progress.push(message);+ console.log(message);+ }+ }+ encoder.stdin.end();+ const [exitCode] = await finished;+ if (exitCode !== 0) throw new Error(`Video encoding failed: ${encoderError}`);+ } else if (kind === 'stills') {+ for (const seconds of [2.5, 7.5, 11.5, 15, 18, 22, 25, 29.5]) {+ const image = await capture(seconds);+ await writeFile(resolve(dirname(output), `frame-${seconds.toFixed(1)}.png`), image);+ }+ } else {+ await writeFile(output, await capture(time));+ }+ if (errors.length) throw new Error(`Browser render errors: ${errors.join('; ')}`);+ const graphics = await page.evaluate(() => {+ const renderer = window.__film?.renderer ?? window.__nature?.renderer ?? window.__studio?.renderer;+ const context = renderer.context;+ const extension = context.getExtension('WEBGL_debug_renderer_info');+ return { gpu: extension ? context.getParameter(extension.UNMASKED_RENDERER_WEBGL) : 'unavailable', samples: renderer.samples, glError: context.getError() };+ });+ 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, 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 };+ await writeFile(`${output}.json`, JSON.stringify(report, null, 2));+ console.log(JSON.stringify(report, null, 2));+} finally {+ if (encoder && encoder.exitCode === null) encoder.kill();+ await browser?.close();+ server.kill();+}diff --git a/scripts/render-vite.config.mjs b/scripts/render-vite.config.mjsnew file mode 100644index 00000000..c45bf0c5--- /dev/null+++ b/scripts/render-vite.config.mjs@@ -0,0 +1,13 @@+import { defineConfig } from 'vite';++// Editing another scene must not reload an offline render halfway through a film.+export default defineConfig({+ server: {+ hmr: false,+ watch: { ignored: ['**/*'] },+ headers: {+ 'Cross-Origin-Opener-Policy': 'same-origin',+ 'Cross-Origin-Embedder-Policy': 'require-corp',+ },+ },+});diff --git a/scripts/score.mjs b/scripts/score.mjsnew file mode 100644index 00000000..dbcd7ea7--- /dev/null+++ b/scripts/score.mjs@@ -0,0 +1,55 @@+import { writeFile, mkdir } from 'node:fs/promises';+import { resolve, dirname } from 'node:path';++const output = resolve(process.argv[2] ?? 'artifacts/critical-score.wav');+const sampleRate = 48000;+const duration = 32;+const frameCount = sampleRate * duration;+const data = Buffer.alloc(44 + frameCount * 4);+data.write('RIFF', 0);+data.writeUInt32LE(data.length - 8, 4);+data.write('WAVEfmt ', 8);+data.writeUInt32LE(16, 16);+data.writeUInt16LE(1, 20);+data.writeUInt16LE(2, 22);+data.writeUInt32LE(sampleRate, 24);+data.writeUInt32LE(sampleRate * 4, 28);+data.writeUInt16LE(4, 32);+data.writeUInt16LE(16, 34);+data.write('data', 36);+data.writeUInt32LE(frameCount * 4, 40);+let seed = 67;+let filteredNoise = 0;+let peak = 0;+let energy = 0;+for (let index = 0; index < frameCount; index++) {+ const time = index / sampleRate;+ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;+ 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);+ 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 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 (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;+ }+ 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;+ peak = Math.max(peak, Math.abs(value), Math.abs(right));+ energy += value * value + right * right;+ data.writeInt16LE(Math.round(Math.max(-1, Math.min(1, value)) * 32767), 44 + index * 4);+ data.writeInt16LE(Math.round(Math.max(-1, Math.min(1, right)) * 32767), 46 + index * 4);+}+await mkdir(dirname(output), { recursive: true });+await writeFile(output, data);+console.log(JSON.stringify({ duration, sampleRate, channels: 2, peakDbfs: 20 * Math.log10(peak), rmsDbfs: 20 * Math.log10(Math.sqrt(energy / (frameCount * 2))), provenance: 'Original deterministic synthesized score. No samples or movie audio.' }, null, 2));diff --git a/scripts/smoke-scenes.mjs b/scripts/smoke-scenes.mjsnew file mode 100644index 00000000..11284ee0--- /dev/null+++ b/scripts/smoke-scenes.mjs@@ -0,0 +1,90 @@+import { chromium } from 'playwright';+import { spawn } from 'node:child_process';+import { existsSync } from 'node:fs';+import { writeFile } from 'node:fs/promises';+import assert from 'node:assert/strict';++const server = spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1', '--port', '5179', '--strictPort'], { windowsHide: true, stdio: 'pipe' });+let browser;+try {+ await new Promise((resolve, reject) => {+ const timeout = setTimeout(() => reject(new Error('Scene smoke server did not start.')), 15000);+ server.stdout.on('data', (data) => {+ if (data.toString().includes('127.0.0.1:5179')) { clearTimeout(timeout); resolve(); }+ });+ server.on('error', reject);+ server.on('exit', (code) => { clearTimeout(timeout); reject(new Error(`Scene server exited ${code}.`)); });+ });+ const chrome = 'C:/Program Files/Google/Chrome/Application/chrome.exe';+ browser = await chromium.launch({ headless: true, ...(existsSync(chrome) ? { executablePath: chrome } : {}), args: ['--enable-webgl', '--ignore-gpu-blocklist'] });+ const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, reducedMotion: 'reduce' });+ const errors = [];+ page.on('pageerror', (error) => errors.push(error.message));+ await page.goto('http://127.0.0.1:5179/nature.html');+ await page.waitForFunction(() => window.__nature?.renderer);+ assert.equal(await page.evaluate(() => window.__nature.state.paused), true);+ await page.screenshot({ path: 'artifacts/nature-wide.png' });+ await page.locator('#daylight').fill('0.25');+ await page.locator('#wind').fill('0.75');+ assert.equal(await page.evaluate(() => window.__nature.state.daylight), 0.25);+ assert.equal(await page.evaluate(() => window.__nature.state.wind), 0.75);+ await page.locator('#viewpoint').selectOption('1');+ await page.locator('#detail').selectOption('low');+ await page.waitForFunction(() => window.__nature.world.parts.length === 1526);+ await page.locator('#viewpoint').selectOption('0');+ await page.locator('#viewport').click({ position: { x: 720, y: 630 } });+ assert.ok(await page.evaluate(() => window.__nature.state.rippleTime >= 0));+ await page.locator('#viewport').focus();+ const natureAzimuth = await page.evaluate(() => window.__nature.state.azimuth);+ await page.keyboard.press('ArrowRight');+ assert.notEqual(await page.evaluate(() => window.__nature.state.azimuth), natureAzimuth);+ const downloadReady = page.waitForEvent('download');+ await page.locator('#save-image').click();+ await (await downloadReady).saveAs('artifacts/nature-download.png');+ await page.setViewportSize({ width: 320, height: 700 });+ await page.screenshot({ path: 'artifacts/nature-narrow.png' });+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth), 320);++ await page.setViewportSize({ width: 1440, height: 900 });+ await page.goto('http://127.0.0.1:5179/film.html');+ await page.waitForFunction(() => window.__filmReady);+ async function filmPixels(time) {+ return page.evaluate((seconds) => {+ window.renderAt(seconds);+ const renderer = window.__film.renderer;+ const context = renderer.context;+ const pixels = new Uint8Array(renderer.canvas.width * renderer.canvas.height * 4);+ context.readPixels(0, 0, renderer.canvas.width, renderer.canvas.height, context.RGBA, context.UNSIGNED_BYTE, pixels);+ let checksum = 2166136261;+ for (const byte of pixels) checksum = Math.imul(checksum ^ byte, 16777619);+ return { checksum: checksum >>> 0, error: context.getError() };+ }, time);+ }+ const ignition = await filmPixels(22);+ await page.screenshot({ path: 'artifacts/film-wide.png' });+ await filmPixels(5.5);+ await filmPixels(29.5);+ assert.deepEqual(await filmPixels(22), ignition);+ assert.equal(ignition.error, 0);+ await page.locator('#film-time').fill('1');+ await page.getByRole('button', { name: 'Play film', exact: true }).click();+ await page.waitForFunction(() => window.__film.score.readyState >= 2 && window.__film.score.currentTime > 1.1);+ 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.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) => {+ const rectangle = element.getBoundingClientRect();+ return { left: rectangle.left, right: rectangle.right, bottom: rectangle.bottom };+ }));+ assert.ok(controls.every((control) => control.left >= 0 && control.right <= 320 && control.bottom <= 700));+ assert.deepEqual(errors, []);+ const result = { checks: 'Nature daylight, wind, viewpoints, detail, ripple, keyboard and PNG; deterministic film seeks, audio playback, mobile layout and reduced motion', errors };+ await writeFile('artifacts/scenes-verification.json', JSON.stringify(result, null, 2));+ console.log(JSON.stringify(result));+} finally {+ await browser?.close();+ server.kill();+}diff --git a/scripts/smoke.mjs b/scripts/smoke.mjsindex 49d324aa..69315606 100644--- a/scripts/smoke.mjs+++ b/scripts/smoke.mjs@@ -1,6 +1,6 @@import { chromium } from 'playwright';import { spawn } from 'node:child_process';-import { mkdir, writeFile } from 'node:fs/promises';+import { mkdir, readFile, writeFile } from 'node:fs/promises';import { existsSync } from 'node:fs';import assert from 'node:assert/strict';import { fileURLToPath } from 'node:url';@@ -24,6 +24,18 @@ try {const errors = [];page.on('pageerror', (error) => errors.push(error.message));page.on('console', (message) => { if (message.type() === 'error') errors.push(message.text()); });+ async function modelPixels() {+ return page.evaluate(() => {+ const renderer = window.__studio.renderer;+ renderer.render(window.__studio.camera());+ const context = renderer.context;+ const pixels = new Uint8Array(renderer.canvas.width * renderer.canvas.height * 4);+ context.readPixels(0, 0, renderer.canvas.width, renderer.canvas.height, context.RGBA, context.UNSIGNED_BYTE, pixels);+ let checksum = 2166136261;+ for (const byte of pixels) checksum = Math.imul(checksum ^ byte, 16777619);+ return checksum >>> 0;+ });+ }await page.goto('http://127.0.0.1:5178');await page.waitForFunction(() => window.__studio?.renderer && document.querySelector('#cpu').textContent.includes('ms CPU'));await page.screenshot({ path: fileURLToPath(new URL('desktop.png', artifactDirectory)) });@@ -33,13 +45,42 @@ try {const extension = context.getExtension('WEBGL_debug_renderer_info');return { parts: renderer.partCount, triangles: renderer.triangles, calls: renderer.batches.length, glError: context.getError(), gpu: extension ? context.getParameter(extension.UNMASKED_RENDERER_WEBGL) : 'unavailable' };});- assert.equal(graphics.parts, 325);- assert.equal(graphics.calls, 10);+ assert.equal(graphics.parts, 574);+ assert.equal(graphics.calls, 8);assert.equal(graphics.glError, 0);await page.getByRole('button', { name: 'Ceramic finish' }).click();assert.equal(await page.locator('#finish-name').textContent(), 'Ceramic');await page.screenshot({ path: fileURLToPath(new URL('ceramic.png', artifactDirectory)) });- await page.getByRole('button', { name: 'Titanium finish' }).click();+ await page.getByRole('button', { name: 'Yellow finish' }).click();+ const assembled = await modelPixels();+ await page.evaluate(() => { window.__shadowBefore = window.__studio.renderer.shadowTexture; });+ for (const value of ['50', '100']) {+ await page.locator('#assembly').fill(value);+ await page.waitForFunction((amount) => window.__studio.renderer.assemblyAmount === amount, Number(value) / 100);+ }+ assert.equal(await page.locator('#assembly').getAttribute('aria-valuetext'), 'Fully exploded');+ assert.notEqual(await modelPixels(), assembled);+ await page.screenshot({ path: fileURLToPath(new URL('exploded.png', artifactDirectory)) });+ assert.ok(await page.evaluate(() => window.__studio.renderer.shadowTexture === window.__shadowBefore));+ const explodedDownloadReady = page.waitForEvent('download');+ await page.getByRole('button', { name: 'Export GLB' }).click();+ await (await explodedDownloadReady).saveAs(fileURLToPath(new URL('wall-e-exploded.glb', artifactDirectory)));+ const exportedBinary = await readFile(new URL('wall-e-exploded.glb', artifactDirectory));+ const exportedScene = JSON.parse(exportedBinary.subarray(20, 20 + exportedBinary.readUInt32LE(12)).toString());+ const expectedPanel = await page.evaluate(() => {+ const part = window.__studio.parts.find((part) => Math.abs(part.assembly.offset[2]) > 1);+ return { name: part.name, translation: part.matrix[14] + part.assembly.offset[2] };+ });+ assert.ok(Math.abs(exportedScene.nodes.find((node) => node.name === expectedPanel.name).matrix[14] - expectedPanel.translation) < 0.000001);+ await page.locator('#assembly').fill('0');+ await page.waitForFunction(() => window.__studio.renderer.assemblyAmount === 0);+ assert.equal(await modelPixels(), assembled);+ await page.getByRole('button', { name: 'Inside', exact: true }).click();+ assert.ok(await page.evaluate(() => window.__studio.renderer.partCount < window.__studio.parts.length));+ await page.screenshot({ path: fileURLToPath(new URL('interior.png', artifactDirectory)) });+ await page.getByRole('button', { name: 'Shell', exact: true }).click();+ assert.equal(await page.evaluate(() => window.__studio.state.layer), 'exterior');+ await page.getByRole('button', { name: 'All', exact: true }).click();await page.locator('#viewport').focus();const initialAzimuth = await page.evaluate(() => window.__studio.state.azimuth);await page.keyboard.press('ArrowRight');@@ -52,12 +93,12 @@ try {const downloadPromise = page.waitForEvent('download');await page.getByRole('button', { name: 'Export GLB' }).click();const download = await downloadPromise;- await download.saveAs(fileURLToPath(new URL('specimen.glb', artifactDirectory)));+ await download.saveAs(fileURLToPath(new URL('wall-e.glb', artifactDirectory)));await page.getByRole('button', { name: 'Measure performance' }).click();await page.waitForFunction(() => window.__benchmarkReport, null, { timeout: 90000 });const report = await page.evaluate(() => window.__benchmarkReport);assert.equal(report.results.length, 4);- assert.deepEqual(report.results.map((result) => result.calls), [10, 326, 10, 326]);+ assert.deepEqual(report.results.map((result) => result.calls), [8, 575, 8, 575]);assert.ok(report.results.every((result) => result.pixelAgreement > 0.999), JSON.stringify(report.results));await page.getByRole('button', { name: 'Back to model' }).click();await page.setViewportSize({ width: 390, height: 844 });@@ -73,6 +114,9 @@ try {return { name: button.getAttribute('aria-label') || button.textContent, left: rectangle.left, right: rectangle.right, width: rectangle.width, height: rectangle.height };}));assert.ok(visibleControls.every((button) => button.left >= 0 && button.right <= 320 && button.width >= 24 && button.height >= 24), JSON.stringify(visibleControls));+ await page.locator('#assembly').fill('100');+ await page.waitForFunction(() => window.__studio.renderer.assemblyAmount === 1);+ await page.screenshot({ path: fileURLToPath(new URL('narrow-exploded.png', artifactDirectory)) });await page.setViewportSize({ width: 390, height: 844 });await page.getByRole('button', { name: 'Graphite finish' }).click();assert.equal(await page.locator('#finish-name').textContent(), 'Graphite');@@ -93,7 +137,7 @@ try {const lostContextErrors = errors.filter((message) => !message.includes('CONTEXT_LOST_WEBGL'));assert.deepEqual(lostContextErrors, []);await writeFile(new URL('benchmark.json', artifactDirectory), JSON.stringify({ graphics, ...report, errors: lostContextErrors }, null, 2));- console.log(JSON.stringify({ graphics, benchmark: report.results, checks: 'Desktop, mobile, finishes, keyboard orbit, reset, normals, GLB download, auto orbit, context loss passed' }, null, 2));+ console.log(JSON.stringify({ graphics, benchmark: report.results, checks: 'Assemble/explode round trip, stable shadow allocation, layers, desktop/mobile, finishes, keyboard orbit, reset, normals, GLB, auto orbit, context restoration passed' }, null, 2));} finally {await browser?.close();server.kill();diff --git a/skills/build-67js-scene/SKILL.md b/skills/build-67js-scene/SKILL.mdnew file mode 100644index 00000000..885b132a--- /dev/null+++ b/skills/build-67js-scene/SKILL.md@@ -0,0 +1,41 @@+---+name: build-67js-scene+description: Build or refine interactive 3D scenes with 67.js. Use for 67.js models, nature worlds, cinematic scenes, camera controls, materials and anti-aliasing, including "làm cảnh 67.js" and "model bị răng cưa".+license: MIT+---++# Dựng cảnh 3D bằng 67.js++Use the actual 67.js checkout. Locate it from the active workspace or Git remote before writing files.+Read its `README.md`, `src/renderer.js` and the closest existing scene module.+Use `simplify-code` and `engineering-workflows` for implementation.++## Choose the surface++- An object studio uses `src/model.js` and `src/main.js`.+- An outdoor world uses `src/nature.js` and `src/nature-viewer.js`.+- A deterministic film uses `src/film.js` and `src/film-player.js`.+- An image or video export uses `render-67js-media`.++Read [scene-contract.md](references/scene-contract.md) before creating parts or changing materials.++## Build and inspect++1. State the focal point, camera, scale and intended lighting.+2. Reuse geometry identities across repeated parts. Keep transforms and materials in instance attributes.+3. Use curved surfaces and sampled fillets for close objects. Keep coarse geometry for distant objects.+4. Enable explicit MSAA, FXAA and specular filtering through `Renderer67`.+5. Set the render memory budget before allocating a target.+6. Keep per-frame animation deterministic. Pause continuous rendering when the document is hidden.+7. Validate geometry, bounds and scene budgets with the existing Node tests.+8. Capture actual rendered wide and narrow views. Inspect edges, highlights, overlap and the focal point.+9. Exercise orbit, zoom, camera selection and the requested interaction through project dev tooling.++Do not treat an `antialias: true` context as proof that the final image looks smooth.+Report measured geometry, draw counts and render size separately from visual judgments.+Do not claim Blender parity or general Three.js speed superiority from one scene.++## Finish++Deliver the scene link, a rendered image, relevant checks and known limits.+Keep this skill aligned with the checked-out renderer API when changing that API.diff --git a/skills/build-67js-scene/agents/openai.yaml b/skills/build-67js-scene/agents/openai.yamlnew file mode 100644index 00000000..d6357284--- /dev/null+++ b/skills/build-67js-scene/agents/openai.yaml@@ -0,0 +1,4 @@+interface:+ display_name: "Dựng cảnh 3D bằng 67.js"+ short_description: "Dựng model, cảnh thiên nhiên và phim bằng 67.js"+ default_prompt: "Use $build-67js-scene to implement and inspect this 67.js scene."diff --git a/skills/build-67js-scene/references/scene-contract.md b/skills/build-67js-scene/references/scene-contract.mdnew file mode 100644index 00000000..6dbe9a18--- /dev/null+++ b/skills/build-67js-scene/references/scene-contract.md@@ -0,0 +1,73 @@+# Scene contract++Each part has these fields.++```js+{+ name: 'Birch canopy',+ geometry: {+ positions: new Float32Array(),+ normals: new Float32Array(),+ indices: new Uint32Array(),+ },+ matrix: new Float32Array(16),+ material: {+ color: [0.16, 0.30, 0.08],+ metallic: 0,+ roughness: 0.8,+ emission: 0,+ tag: 'foliage',+ },+}+```++The transform is a column-major matrix. Colors are linear RGB.+Normals are unit vectors. Triangle winding faces outward.+Each geometry identity becomes one instanced batch.++Explodable parts also provide `assembly: { layer: 'exterior' | 'interior', section: 'front-panel', offset: [0, 0, 1.7] }`.+The offset is a world-space translation at full explosion. `render({ assemblyAmount: 0.5, ...camera })` applies half the offset in the vertex shader.+Keep each section's offsets consistent so fasteners follow their panel. Base matrices remain assembled.++Changing assembly amount refreshes shadows while reusing the same shadow texture and geometry buffers.+For an exploded GLB, add the current offset to matrix translation entries 12, 13 and 14 before export.++The material tags select renderer behavior.++| Tag | Behavior |+| --- | --- |+| `armor` | Studio finish color and surface overrides. |+| `floor` | Studio floor shading. |+| `water` | Animated surface normals and interaction ripples. |+| `foliage`, `grass` | Wind movement and backlighting. |+| `terrain` | Subtle natural surface variation. |+| `fire`, `smoke` | Film ignition expansion and procedural shading. |+| Other tags | Standard metallic/roughness shading. |++Material tags and colors use flat varyings.+Interpolated numeric tags can change by tiny amounts and select the wrong shading branch.++An outdoor renderer receives `world: true`, `ground: false` and the scene environment.+The environment provides `fogColor`, `fogDensity`, `skyTop`, `skyBottom`, `lightDirection` and optional `daylight`.+The sky colors are display RGB. Fog colors are linear RGB.++```js+const renderer = new Renderer67(canvas, world.parts, {+ world: true,+ ground: false,+ environment: world.environment,+ samples: 4,+ pixelRatio: 1.25,+ memoryBudgetMiB: 256,+});+renderer.render({ ...world.camera, time: 0, wind: 0.3 });+```++The renderer owns its GPU buffers and targets. Call `dispose()` before replacing it.+Call `resize()` when CSS dimensions change.+Check `memoryPlan` for the actual render size and estimated allocation.+The planner can reduce resolution to stay within its target budget.++Films sample their timeline through `sampleFilm(time)`.+Camera FOV uses degrees. Film time must be finite and independent of the wall clock.+`renderAt(time)` must produce the same frame when called in a different order.diff --git a/skills/render-67js-media/SKILL.md b/skills/render-67js-media/SKILL.mdnew file mode 100644index 00000000..eb884904--- /dev/null+++ b/skills/render-67js-media/SKILL.md@@ -0,0 +1,41 @@+---+name: render-67js-media+description: Export 67.js scenes to PNG or MP4 on GPU or CPU. Use for render ảnh/video 3D, export presets, MSAA quality, performance measurements and bounded RAM/VRAM capture without buffering full frame sequences.+license: MIT+---++# Xuất ảnh và video 67.js++Locate the 67.js checkout and read its `scripts/render-media.mjs` and `src/budget.js`.+Read [rendering.md](references/rendering.md) for commands, backends and measurement limits.+Use the repository pipeline rather than constructing a parallel exporter.++## Choose and render++1. Check the available GPU memory before a GPU job on a shared machine.+2. Choose GPU rendering for speed. Choose the CPU preset when hardware WebGL is unavailable.+3. Choose the smallest preset that meets the output requirement.+4. Set width, height, samples and memory before rendering.+5. Keep one browser, one live scene renderer and one pending capture frame.+6. Stream frames to FFmpeg. Await encoder backpressure before capturing the next frame.+7. Stop on browser errors, graphics errors or a memory guard failure.+8. Inspect representative stills before the full film export.+9. Verify duration, frame count, dimensions, color metadata, audio and file size with FFprobe.+10. Inspect the output report and close the browser and encoder after the job.++Use below-normal priority for heavy local exports. Do not stop another session's process.+Use deterministic scene time. Do not use a real-time screen recording for offline export.++CPU encoding and CPU rendering are separate choices.+GPU encoding uses NVENC when supported. CPU encoding uses two threads by default.++## Report the limits++The framebuffer estimate is an allocation model, not a measured total VRAM figure.+Node RSS and the sampled browser JavaScript heap do not cover every browser allocation.+Report the actual renderer backend, estimated target memory, observed process metrics and elapsed export time.+Do not promise that a budget prevents every driver or system allocation failure.+When resolution is reduced, state the actual render dimensions.++Deliver the PNG or MP4, its JSON report and the reproduction command.+For a score, record provenance and measured loudness. Say whether anyone listened to it.diff --git a/skills/render-67js-media/agents/openai.yaml b/skills/render-67js-media/agents/openai.yamlnew file mode 100644index 00000000..b9089f32--- /dev/null+++ b/skills/render-67js-media/agents/openai.yaml@@ -0,0 +1,4 @@+interface:+ display_name: "Xuất ảnh và video 67.js"+ short_description: "Render ảnh, video bằng GPU hoặc CPU có giới hạn nhớ"+ default_prompt: "Use $render-67js-media to export this scene and verify its quality and memory report."diff --git a/skills/render-67js-media/references/rendering.md b/skills/render-67js-media/references/rendering.mdnew file mode 100644index 00000000..e6f336fa--- /dev/null+++ b/skills/render-67js-media/references/rendering.md@@ -0,0 +1,49 @@+# Rendering commands++Run these commands from the repository root.++```powershell+node scripts/render-media.mjs --kind image --scene nature --backend gpu --preset high --output artifacts/nature.png+node scripts/render-media.mjs --kind image --scene object --backend cpu --preset cpu --output artifacts/object-cpu.png+node scripts/render-media.mjs --kind stills --scene film --backend gpu --preset balanced --output artifacts/stills/frame.png+node scripts/score.mjs+node scripts/render-media.mjs --kind video --scene film --backend gpu --preset balanced --encoder gpu --output artifacts/critical.mp4+```++The available scenes are `object`, `nature` and `film`.+GPU rendering selects hardware WebGL through Chrome. CPU rendering requests ANGLE SwiftShader.+The CPU exporter verifies that the selected backend reports SwiftShader.++| Preset | Dimensions | Samples | FPS | Target budget |+| --- | --- | ---: | ---: | ---: |+| `preview` | 960 × 540 | 2 | 24 | 256 MiB |+| `balanced` | 1280 × 720 | 4 | 24 | 384 MiB |+| `high` | 1920 × 1080 | 4 | 24 | 512 MiB |+| `cpu` | 640 × 360 | 1 | 12 | 192 MiB |++The memory planner includes color/depth targets, resolve storage, staging frames, shadows and uploaded geometry.+The browser context remains an additional allocation outside that estimate.+The offline exporter uses one capture frame at a time.+It disposes the previous scene before uploading the next scene.++`--memory` controls the target budget. `--width`, `--height`, `--fps` and `--duration` override preset values.+For object images, `--assembly 1` explodes the model. The default value `0` assembles it.++Each option requires a value. Dimensions range from 64 to 4096 pixels.+Memory ranges from 32 to 1024 MiB. Duration ranges from 0.1 to 120 seconds.++The video encoder can use `--encoder cpu` or `--encoder gpu` independently of the renderer backend.+The hardware encoder requires NVENC. A failed encoder stops the export and reports its error.+The renderer does not silently replace a failed hardware export with a lower-quality output.++`scripts/score.mjs` generates the original film score.+The `--audio <path>` option selects an existing score.+Do not use movie dialogue, footage or music without authorization.++```powershell+ffprobe -v error -count_frames -show_entries stream=codec_name,width,height,r_frame_rate,nb_read_frames,color_space:format=duration,size -of json artifacts/critical.mp4+```++Inspect the sidecar `<output>.json` for backend, estimated allocation, process memory, frame queue and graphics errors.+The process guard stops Node above 512 MiB and sampled browser JavaScript heap above 256 MiB.+Heap samples do not establish peak browser RSS or total VRAM use.diff --git a/src/export.js b/src/export.jsindex 07e5e832..dd644616 100644--- a/src/export.js+++ b/src/export.js@@ -85,7 +85,7 @@ export function downloadGlb(parts) {const url = URL.createObjectURL(new Blob([exportGlb(parts)], { type: 'model/gltf-binary' }));const link = document.createElement('a');link.href = url;- link.download = '67js-specimen.glb';+ link.download = '67js-wall-e.glb';link.click();setTimeout(() => URL.revokeObjectURL(url), 1000);}diff --git a/src/film-player.js b/src/film-player.jsindex 9bdb4eaf..8b7c19d2 100644--- a/src/film-player.js+++ b/src/film-player.js@@ -25,6 +25,8 @@ const titleText = document.querySelector('#title-text');const subtitleText = document.querySelector('#subtitle-text');const flash = document.querySelector('#film-flash');const scenes = createFilmScenes();+const score = exporting ? null : new Audio('./media/critical.mp4');+if (score) score.preload = 'none';let renderer = null;let activeScene = null;let currentTime = 0;@@ -49,7 +51,8 @@ function renderAt(time) {renderer?.dispose();renderer = null;activeScene = null;- renderer = new Renderer67(canvas, scene.parts, {+ const parts = sample.scene === 'ignition' ? scene.parts.filter(part => !['fire', 'smoke'].includes(part.material.tag)) : scene.parts;+ renderer = new Renderer67(canvas, parts, {world: true,ground: scene.ground,environment: scene.environment,@@ -68,6 +71,7 @@ function renderAt(time) {fade: sample.fade,cinematic: true,explosionProgress: sample.explosionProgress,+ volumeExplosion: sample.scene === 'ignition',environment: scene.environment,});currentTime = sample.time;@@ -90,9 +94,15 @@ function setPlaying(value) {animationFrame = 0;if (playing) {if (currentTime >= FILM_DURATION) renderAt(0);+ if (score) {+ score.currentTime = currentTime;+ score.play().catch(() => {+ document.querySelector('.film-caption').textContent = '⚠ Score unavailable. The 3D film continues.';+ });+ }playbackOrigin = performance.now() - currentTime * 1000;animationFrame = requestAnimationFrame(advance);- }+ } else score?.pause();}function showError(error) {@@ -106,7 +116,8 @@ function showError(error) {function advance(timestamp) {if (!playing) return;try {- renderAt((timestamp - playbackOrigin) / 1000);+ const seconds = score && !score.paused && score.readyState >= 2 ? score.currentTime : (timestamp - playbackOrigin) / 1000;+ renderAt(seconds);if (currentTime >= FILM_DURATION) setPlaying(false);else animationFrame = requestAnimationFrame(advance);} catch (error) {@@ -152,6 +163,7 @@ window.__film = {sampleFilm,renderAt,duration: FILM_DURATION,+ score,exporting,options: { width, height, samples, memoryBudgetMiB },};diff --git a/src/film.js b/src/film.jsindex 36335c51..ee968712 100644--- a/src/film.js+++ b/src/film.js@@ -181,7 +181,7 @@ function createIgnition(meshes) {add('Rolling smoke crown', 'sphere', [Math.cos(angle) * radius, height, Math.sin(angle) * radius], [size * 1.3, size, size * 1.3], 'smoke');}for (let index = 0; index < 6; index++) {- add('Dust shock ring', 'gasRing', [0, 0.2 + index * 0.14, 0], [10 + index * 2.3, 10 + index * 2.3, 2.5], 'smoke', [HALF_PI, 0, index * 0.07]);+ add('Dust shock ring', 'gasRing', [0, 0.12 + index * 0.03, 0], [10 + index * 2.3, 10 + index * 2.3, 0.12], 'smoke', [HALF_PI, 0, 0]);}for (let index = 0; index < 130; index++) {const angle = index * 2.399963;diff --git a/src/main.js b/src/main.jsindex bd16fe02..30af209d 100644--- a/src/main.js+++ b/src/main.js@@ -6,11 +6,11 @@ import { downloadGlb } from './export.js';const canvas = document.querySelector('#viewport');const parts = createModel();const finishes = {- titanium: { name: 'Titanium', color: [0.53, 0.39, 0.24], surface: [0.88, 0.32] },+ yellow: { name: 'Factory yellow', color: [0.62, 0.34, 0.035], surface: [0.48, 0.43] },ceramic: { name: 'Ceramic', color: [0.7, 0.77, 0.74], surface: [0.05, 0.24] },graphite: { name: 'Graphite', color: [0.10, 0.14, 0.17], surface: [0.65, 0.4] },};-const state = { azimuth: 0.48, elevation: 0.18, distance: 6.4, finish: 'titanium', exposure: 1, inspection: false, rotating: false };+const state = { azimuth: 0.48, elevation: 0.18, distance: 7.8, finish: 'yellow', exposure: 1, inspection: false, rotating: false, assembly: 0, layer: 'all' };let renderer;let scheduledFrame = 0;let lastTime = 0;@@ -29,8 +29,9 @@ function notify(message, failure = false) {function camera() {const mobile = canvas.clientWidth <= 700;- const distance = state.distance;- const target = [0, mobile ? 1.5 : 1.35, 0];+ if (renderer) renderer.projection[8] = mobile || state.exporting ? 0 : -0.25 + state.assembly * 0.15;+ const distance = state.distance * (mobile ? 0.78 : 1) + state.assembly * (mobile ? 4.5 : 6);+ const target = [0, (mobile ? 1.5 : 1.35) + state.assembly * 0.35, 0];return {target,eye: [Math.sin(state.azimuth) * Math.cos(state.elevation) * distance, target[1] + Math.sin(state.elevation) * distance, Math.cos(state.azimuth) * Math.cos(state.elevation) * distance],@@ -38,6 +39,7 @@ function camera() {armorSurface: finishes[state.finish].surface,exposure: state.exposure,inspection: state.inspection,+ assemblyAmount: state.assembly,};}@@ -59,15 +61,29 @@ function invalidate() {}function initialize() {- renderer = new Renderer67(canvas, parts);- document.querySelector('#parts').textContent = `${parts.length} parts · ${Math.round(renderer.triangles / 1000)}k triangles`;- document.querySelector('#calls').textContent = `${renderer.batches.length} draw calls`;+ const visibleParts = state.layer === 'all' ? parts : parts.filter((part) => part.assembly?.layer === state.layer);+ renderer = new Renderer67(canvas, visibleParts, { shadowBounds: { extent: 5, eye: [-3, 7, 4], target: [0, 1.5, 0] } });+ document.querySelector('#parts').textContent = `${visibleParts.length} parts · ${Math.round(renderer.triangles / 1000)}k triangles`;+ document.querySelector('#calls').textContent = `${renderer.batches.length} geometry draws`;invalidate();window.__studio = { parts, get renderer() { return renderer; }, state, camera, invalidate };}try { initialize(); } catch (error) { notify(error.message, true); }+document.querySelector('#assembly').addEventListener('input', (event) => {+ state.assembly = Number(event.target.value) / 100;+ document.querySelector('#assembly-value').textContent = `${event.target.value}%`;+ event.target.setAttribute('aria-valuetext', state.assembly === 0 ? 'Assembled' : state.assembly === 1 ? 'Fully exploded' : `${event.target.value}% exploded`);+ invalidate();+});+document.querySelectorAll('[data-layer]').forEach((button) => button.addEventListener('click', () => {+ state.layer = button.dataset.layer;+ document.querySelectorAll('[data-layer]').forEach((control) => control.setAttribute('aria-pressed', String(control === button)));+ renderer?.dispose();+ try { initialize(); } catch (error) { notify(error.message, true); }+}));+canvas.addEventListener('pointerdown', (event) => {if (event.button !== 0) return;dragging = { pointerId: event.pointerId, x: event.clientX, y: event.clientY };@@ -100,7 +116,7 @@ canvas.addEventListener('keydown', (event) => {if (event.key.toLowerCase() === 'r') document.querySelector('#reset').click();});document.querySelector('#reset').addEventListener('click', () => {- Object.assign(state, { azimuth: 0.48, elevation: 0.18, distance: 6.4 });+ Object.assign(state, { azimuth: 0.48, elevation: 0.18, distance: 7.8 });invalidate();});document.querySelectorAll('[data-finish]').forEach((button) => button.addEventListener('click', () => {@@ -138,7 +154,12 @@ document.querySelector('#quality').addEventListener('change', (event) => {document.querySelector('#export').addEventListener('click', () => {try {const finish = finishes[state.finish];- const exported = parts.map((part) => part.material.tag === 'armor' ? { ...part, material: { ...part.material, color: finish.color, metallic: finish.surface[0], roughness: finish.surface[1] } } : part);+ const exported = parts.filter((part) => state.layer === 'all' || part.assembly?.layer === state.layer).map((part) => {+ const matrix = new Float32Array(part.matrix);+ for (let axis = 0; axis < 3; axis++) matrix[12 + axis] += (part.assembly?.offset[axis] ?? 0) * state.assembly;+ const material = part.material.tag === 'armor' ? { ...part.material, color: finish.color, metallic: finish.surface[0], roughness: finish.surface[1] } : part.material;+ return { ...part, matrix, material };+ });downloadGlb(exported);notify('GLB exported. Open it in Blender or another glTF viewer.');} catch (error) { notify(`Export failed: ${error.message}`, true); }@@ -172,6 +193,7 @@ canvas.addEventListener('webglcontextlost', (event) => {event.preventDefault();cancelAnimationFrame(scheduledFrame);scheduledFrame = 0;+ renderer?.dispose();renderer = null;notify('Graphics context lost. Waiting for the browser to restore it.', true);});diff --git a/src/nature.js b/src/nature.jsindex e0c61d31..25c019ce 100644--- a/src/nature.js+++ b/src/nature.js@@ -368,8 +368,8 @@ export function createNatureWorld({ seed = 67, detail = 'balanced' } = {}) {camera,bounds: worldBounds(parts),environment: {- fogColor: [0.43, 0.58, 0.62],- fogDensity: 0.0065,+ fogColor: [0.16, 0.23, 0.26],+ fogDensity: 0.0045,skyTop: [0.24, 0.48, 0.7],skyBottom: [0.78, 0.86, 0.87],lightDirection: [-0.46, 0.77, 0.44],diff --git a/src/post.js b/src/post.jsindex e075f811..590eaf9f 100644--- a/src/post.js+++ b/src/post.js@@ -16,8 +16,61 @@ uniform float monochrome;uniform float fade;uniform float cinematic;uniform float time;+uniform float volumeExplosion;+uniform float explosionProgress;+uniform mat4 inverseViewProjection;+uniform vec3 eye;out vec4 outputColor;float luminance(vec3 color) { return dot(color, vec3(0.299, 0.587, 0.114)); }+float hash(vec3 position) { return fract(sin(dot(position, vec3(127.1, 311.7, 74.7))) * 43758.5453); }+float cloudNoise(vec3 position) {+ vec3 cell = floor(position);+ vec3 fraction = fract(position);+ fraction = fraction * fraction * (3.0 - 2.0 * fraction);+ float lower = mix(mix(hash(cell), hash(cell + vec3(1,0,0)), fraction.x), mix(hash(cell + vec3(0,1,0)), hash(cell + vec3(1,1,0)), fraction.x), fraction.y);+ float upper = mix(mix(hash(cell + vec3(0,0,1)), hash(cell + vec3(1,0,1)), fraction.x), mix(hash(cell + vec3(0,1,1)), hash(cell + vec3(1,1,1)), fraction.x), fraction.y);+ return mix(lower, upper, fraction.z);+}+vec3 explosion(vec3 background) {+ vec4 endpoint = inverseViewProjection * vec4(textureCoordinate * 2.0 - 1.0, 1.0, 1.0);+ vec3 direction = normalize(endpoint.xyz / endpoint.w - eye);+ float scale = 0.03 + explosionProgress * 0.97;+ vec3 center = vec3(0,12,0) * scale;+ float radius = 15.0 * scale;+ vec3 relative = eye - center;+ float projected = dot(relative, direction);+ float discriminant = projected * projected - dot(relative, relative) + radius * radius;+ if (discriminant <= 0.0) return background;+ float entry = max(0.0, -projected - sqrt(discriminant));+ float exitDistance = -projected + sqrt(discriminant);+ float stepSize = (exitDistance - entry) / 36.0;+ vec3 accumulated = vec3(0);+ float transmittance = 1.0;+ for (int stepIndex = 0; stepIndex < 36; stepIndex++) {+ vec3 position = (eye + direction * (entry + (float(stepIndex) + 0.5) * stepSize)) / scale;+ if (position.y < 0.0) continue;+ vec3 flow = position * 0.56 - vec3(0, time * 0.55, 0);+ float noise = cloudNoise(flow) * 0.68 + cloudNoise(flow * 2.1 + vec3(5.4,1.7,9.1)) * 0.32;+ float fireShape = 1.0 - length((position - vec3(0,7,0)) / vec3(7.0,7.6,7.0));+ float capShape = 1.0 - length((position - vec3(0,18,0)) / vec3(9.4,5.7,9.4));+ float stemShape = min(1.0 - length(position.xz) / 3.5, min((position.y - 8.0) / 3.0, (19.0 - position.y) / 3.0));+ float fireDensity = smoothstep(0.0, 0.32, fireShape + (noise - 0.5) * 0.6);+ float smokeDensity = smoothstep(0.0, 0.3, max(capShape, stemShape) + (noise - 0.5) * 0.45);+ float density = max(fireDensity * 0.7, smokeDensity * 1.2);+ float opacity = 1.0 - exp(-density * stepSize / scale * 0.30);+ float temperature = clamp(fireShape * 0.9 + noise * 0.65, 0.0, 1.0);+ vec3 fireColor = mix(vec3(0.45,0.018,0.001), vec3(2.5,0.9,0.09), smoothstep(0.25,0.95,temperature));+ fireColor = mix(fireColor, vec3(4.0,2.8,1.5), smoothstep(0.92,1.0,temperature));+ vec3 smokeColor = vec3(0.11,0.085,0.062) * (0.4 + noise * 0.8);+ smokeColor += vec3(0.18,0.028,0.002) * max(0.0,1.0 - abs(position.y - 11.0) / 7.0);+ vec3 color = mix(smokeColor, fireColor, fireDensity / max(0.001,fireDensity + smokeDensity));+ accumulated += color * opacity * transmittance;+ transmittance *= 1.0 - opacity;+ if (transmittance < 0.02) break;+ }+ accumulated = accumulated / (accumulated + 0.5);+ return accumulated + background * transmittance;+}void main() {vec2 texel = 1.0 / resolution;vec3 center = texture(frameTexture, textureCoordinate).rgb;@@ -40,6 +93,7 @@ void main() {float secondLuma = luminance(second);vec3 color = secondLuma < minimumLuma || secondLuma > maximumLuma ? first : second;if (maximumLuma - minimumLuma < max(0.03, maximumLuma * 0.125)) color = center;+ if (volumeExplosion > 0.5) color = explosion(color);color = mix(color, vec3(luminance(color)), monochrome);vec2 centered = textureCoordinate * 2.0 - 1.0;color *= 1.0 - cinematic * 0.20 * dot(centered, centered);diff --git a/src/renderer.js b/src/renderer.jsindex 6d9c1225..f3b297bf 100644--- a/src/renderer.js+++ b/src/renderer.js@@ -80,14 +80,15 @@ export class Renderer67 {this.inverseViewProjection = mat4.create();this.program = compileProgram(this.context, benchmark ? benchmarkVertexShader : vertexShader, benchmark ? benchmarkFragmentShader : fragmentShader);this.depthProgram = compileProgram(this.context, depthVertexShader, depthFragmentShader);- this.uniforms = Object.fromEntries(['viewProjection', 'lightProjection', 'eye', 'armorColor', 'armorSurface', 'exposure', 'inspection', 'shadowMap', 'time', 'wind', 'worldMode', 'daylight', 'lightDirection', 'fogColor', 'fogDensity', 'waterRipple', 'rippleTime', 'explosionProgress', 'explosionCenter'].map((name) => [name, this.context.getUniformLocation(this.program, name)]));+ this.uniforms = Object.fromEntries(['viewProjection', 'lightProjection', 'eye', 'armorColor', 'armorSurface', 'exposure', 'inspection', 'shadowMap', 'time', 'wind', 'worldMode', 'daylight', 'lightDirection', 'fogColor', 'fogDensity', 'waterRipple', 'rippleTime', 'explosionProgress', 'explosionCenter', 'assemblyAmount'].map((name) => [name, this.context.getUniformLocation(this.program, name)]));if (!benchmark) {this.postProgram = compileProgram(this.context, fullscreenVertex, postFragment);this.skyProgram = compileProgram(this.context, fullscreenVertex, skyFragment);- this.postUniforms = Object.fromEntries(['frameTexture', 'resolution', 'monochrome', 'fade', 'cinematic', 'time'].map((name) => [name, this.context.getUniformLocation(this.postProgram, name)]));+ this.postUniforms = Object.fromEntries(['frameTexture', 'resolution', 'monochrome', 'fade', 'cinematic', 'time', 'volumeExplosion', 'explosionProgress', 'inverseViewProjection', 'eye'].map((name) => [name, this.context.getUniformLocation(this.postProgram, name)]));this.skyUniforms = Object.fromEntries(['skyTop', 'skyBottom', 'sunDirection', 'inverseViewProjection', 'eye', 'time', 'daylight'].map((name) => [name, this.context.getUniformLocation(this.skyProgram, name)]));}this.depthUniform = this.context.getUniformLocation(this.depthProgram, 'lightProjection');+ this.depthAssemblyUniform = this.context.getUniformLocation(this.depthProgram, 'assemblyAmount');this.partCount = parts.length;this.triangles = parts.reduce((total, part) => total + part.geometry.indices.length / 3, 0);groupParts(ground ? [...parts, groundPart()] : parts, batching).forEach((group) => this.batches.push(this.uploadBatch(group)));@@ -116,7 +117,7 @@ export class Renderer67 {context.vertexAttribPointer(location, 3, context.FLOAT, false, 0, 0);}this.uploadBuffer(context.ELEMENT_ARRAY_BUFFER, geometry.indices);- const stride = 32;+ const stride = 35;const instanceData = new Float32Array(parts.length * stride);const normalMatrix = mat3.create();parts.forEach((part, index) => {@@ -126,12 +127,14 @@ export class Renderer67 {instanceData.set(normalMatrix, offset + 16);instanceData.set(part.material.color, offset + 25);instanceData.set([part.material.metallic, part.material.roughness, part.material.emission ?? 0, MATERIAL_TAGS[part.material.tag] ?? 0], offset + 28);+ instanceData.set(part.assembly?.offset ?? [0, 0, 0], offset + 32);});this.uploadBuffer(context.ARRAY_BUFFER, instanceData);for (let column = 0; column < 4; column++) this.attribute(2 + column, 4, stride * 4, column * 16);for (let column = 0; column < 3; column++) this.attribute(6 + column, 3, stride * 4, 64 + column * 12);this.attribute(9, 3, stride * 4, 100);this.attribute(10, 4, stride * 4, 112);+ this.attribute(11, 3, stride * 4, 128);context.bindVertexArray(null);return { vertexArray, indexCount: geometry.indices.length, instanceCount: parts.length, floor: parts[0].material.tag === 'floor' };}@@ -144,14 +147,15 @@ export class Renderer67 {createShadowMap() {const context = this.context;- this.shadowTexture = context.createTexture();+ const allocateShadow = !this.shadowTexture;+ if (allocateShadow) this.shadowTexture = context.createTexture();context.bindTexture(context.TEXTURE_2D, this.shadowTexture);- context.texImage2D(context.TEXTURE_2D, 0, context.DEPTH_COMPONENT24, 2048, 2048, 0, context.DEPTH_COMPONENT, context.UNSIGNED_INT, null);+ if (allocateShadow) context.texImage2D(context.TEXTURE_2D, 0, context.DEPTH_COMPONENT24, 2048, 2048, 0, context.DEPTH_COMPONENT, context.UNSIGNED_INT, null);context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.NEAREST);context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.NEAREST);context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_S, context.CLAMP_TO_EDGE);context.texParameteri(context.TEXTURE_2D, context.TEXTURE_WRAP_T, context.CLAMP_TO_EDGE);- this.shadowFramebuffer = context.createFramebuffer();+ if (!this.shadowFramebuffer) this.shadowFramebuffer = context.createFramebuffer();context.bindFramebuffer(context.FRAMEBUFFER, this.shadowFramebuffer);context.framebufferTexture2D(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.TEXTURE_2D, this.shadowTexture, 0);context.drawBuffers([context.NONE]);@@ -168,6 +172,7 @@ export class Renderer67 {context.clear(context.DEPTH_BUFFER_BIT);context.useProgram(this.depthProgram);context.uniformMatrix4fv(this.depthUniform, false, this.lightProjection);+ context.uniform1f(this.depthAssemblyUniform, this.assemblyAmount ?? 0);context.enable(context.POLYGON_OFFSET_FILL);context.polygonOffset(1, 1);for (const batch of this.batches) if (!batch.floor) this.drawBatch(batch);@@ -260,6 +265,10 @@ export class Renderer67 {context.uniform1f(this.postUniforms.fade, frame.fade ?? 0);context.uniform1f(this.postUniforms.cinematic, frame.cinematic ? 1 : 0);context.uniform1f(this.postUniforms.time, frame.time ?? 0);+ context.uniform1f(this.postUniforms.volumeExplosion, frame.volumeExplosion ? 1 : 0);+ context.uniform1f(this.postUniforms.explosionProgress, frame.explosionProgress ?? 1);+ context.uniformMatrix4fv(this.postUniforms.inverseViewProjection, false, this.inverseViewProjection);+ context.uniform3fv(this.postUniforms.eye, frame.eye);context.drawArrays(context.TRIANGLES, 0, 3);}@@ -272,6 +281,11 @@ export class Renderer67 {const { eye, target = [0, 1.2, 0], armorColor = [0.53, 0.39, 0.24], armorSurface = [0.88, 0.32], exposure = 1, inspection = false } = frame;const start = performance.now();const context = this.context;+ const assemblyAmount = Math.max(0, Math.min(1, frame.assemblyAmount ?? 0));+ if (this.assemblyAmount !== assemblyAmount) {+ this.assemblyAmount = assemblyAmount;+ this.createShadowMap();+ }if (frame.fov) mat4.perspective(this.projection, frame.fov * Math.PI / 180, this.canvas.width / this.canvas.height, 0.1, this.world ? 600 : 100);mat4.lookAt(this.view, eye, target, [0, 1, 0]);mat4.multiply(this.viewProjection, this.projection, this.view);@@ -303,6 +317,7 @@ export class Renderer67 {context.uniform1f(this.uniforms.rippleTime, frame.rippleTime ?? -1000);context.uniform1f(this.uniforms.explosionProgress, frame.explosionProgress ?? 1);context.uniform3fv(this.uniforms.explosionCenter, environment.explosionCenter);+ context.uniform1f(this.uniforms.assemblyAmount, assemblyAmount);context.activeTexture(context.TEXTURE0);context.bindTexture(context.TEXTURE_2D, this.shadowTexture);context.uniform1i(this.uniforms.shadowMap, 0);diff --git a/src/shaders.js b/src/shaders.jsindex c4889a5d..f679391f 100644--- a/src/shaders.js+++ b/src/shaders.js@@ -6,12 +6,14 @@ layout(location=2) in mat4 instanceMatrix;layout(location=6) in mat3 instanceNormal;layout(location=9) in vec3 instanceColor;layout(location=10) in vec4 instanceSurface;+layout(location=11) in vec3 assemblyOffset;uniform mat4 viewProjection;uniform mat4 lightProjection;uniform float time;uniform float wind;uniform float explosionProgress;uniform vec3 explosionCenter;+uniform float assemblyAmount;out vec3 worldPosition;out vec3 worldNormal;flat out vec3 baseColor;@@ -19,6 +21,7 @@ flat out vec4 surface;out vec4 shadowPosition;void main() {vec4 world = instanceMatrix * vec4(position, 1.0);+ world.xyz += assemblyOffset * assemblyAmount;if (instanceSurface.w == 4.0 || instanceSurface.w == 7.0) {world.x += sin(time * 1.2 + world.z * 0.31 + world.x * 0.17) * wind * 0.10 * max(position.y + 0.5, 0.0);}@@ -40,9 +43,13 @@ export const depthVertexShader = `#version 300 esprecision highp float;layout(location=0) in vec3 position;layout(location=2) in mat4 instanceMatrix;+layout(location=11) in vec3 assemblyOffset;uniform mat4 lightProjection;+uniform float assemblyAmount;void main() {- gl_Position = lightProjection * instanceMatrix * vec4(position, 1.0);+ vec4 world = instanceMatrix * vec4(position, 1.0);+ world.xyz += assemblyOffset * assemblyAmount;+ gl_Position = lightProjection * world;}`;export const depthFragmentShader = `#version 300 es@@ -165,6 +172,11 @@ void main() {color = mix(color, vec3(0.10, 0.23, 0.25), pow(1.0 - max(dot(normal, viewDirection), 0.0), 4.0));roughness = 0.16;}+ if (surface.w == 4.0 || surface.w == 7.0) {+ float leaves = sin(worldPosition.x * 13.0 + sin(worldPosition.y * 9.0)) * sin(worldPosition.z * 11.0 - worldPosition.y * 5.0);+ color *= 0.78 + leaves * 0.16;+ normal = normalize(normal + vec3(sin(worldPosition.z * 12.0), sin(worldPosition.x * 9.0), cos(worldPosition.y * 11.0)) * 0.06);+ }if (surface.w == 5.0) {float mottling = sin(worldPosition.x * 3.3) * sin(worldPosition.z * 4.1) * 0.5 + sin(worldPosition.x * 0.9 + worldPosition.z * 1.7) * 0.5;color *= 0.94 + mottling * 0.06;@@ -179,6 +191,12 @@ void main() {radiance += color * (1.0 - metallic) * mix(vec3(0.16, 0.20, 0.22), vec3(0.19, 0.25, 0.30) * max(daylight, 0.08), worldMode) * (0.45 + 0.55 * max(normal.y, 0.0));if (surface.w == 4.0 || surface.w == 7.0) radiance += color * max(dot(-normal, normalize(lightDirection)), 0.0) * 0.3 * daylight;radiance += color * surface.z;+ if (surface.w == 3.0) {+ float reflectivity = 0.20 + 0.65 * pow(1.0 - max(dot(normal, viewDirection), 0.0), 3.0);+ vec3 reflection = mix(vec3(0.12, 0.24, 0.28), vec3(0.40, 0.63, 0.78), clamp(reflect(-viewDirection, normal).y, 0.0, 1.0));+ radiance = mix(radiance * 0.6, reflection * daylight, reflectivity);+ radiance += vec3(1.0, 0.85, 0.55) * pow(max(dot(reflect(-normalize(lightDirection), normal), viewDirection), 0.0), 220.0) * 2.0 * daylight;+ }if (surface.w == 2.0) {float contact = 1.0 - 0.45 * exp(-dot(worldPosition.xz, worldPosition.xz) * 1.4);radiance = vec3(0.034, 0.041, 0.046) * (0.4 + visibility * 0.6) * contact;@@ -187,12 +205,12 @@ void main() {}if (surface.w == 8.0) {float turbulence = sin(worldPosition.x * 3.0 + time * 4.0) * sin(worldPosition.y * 4.2 - time * 3.0) * sin(worldPosition.z * 3.7);- float heat = clamp(0.65 + turbulence * 0.3 - explosionProgress * 0.25, 0.0, 1.0);- radiance = mix(vec3(3.0, 0.12, 0.01), vec3(18.0, 9.0, 1.0), heat) * max(0.15, surface.z);+ float heat = pow(clamp(0.55 + turbulence * 0.5 - explosionProgress * 0.12, 0.0, 1.0), 3.0);+ radiance = mix(vec3(0.22, 0.003, 0.0002), vec3(8.0, 2.8, 0.15), heat) * max(0.2, surface.z * 0.10);}if (surface.w == 9.0) {float turbulence = sin(worldPosition.x * 2.0 + time) * sin(worldPosition.y * 3.3 - time * 0.6);- radiance = color * (0.5 + turbulence * 0.15) + vec3(0.8, 0.10, 0.015) * max(0.0, 1.0 - explosionProgress) * max(0.0, -normal.y);+ radiance = color * (0.22 + turbulence * 0.12) + vec3(0.35, 0.05, 0.005) * max(0.0, 1.0 - explosionProgress) * max(0.0, -normal.y);}float fog = 1.0 - exp(-length(worldPosition - eye) * fogDensity);radiance = mix(radiance, fogColor, fog * worldMode);diff --git a/src/style.css b/src/style.cssindex eb2b1c93..5ebab8d2 100644--- a/src/style.css+++ b/src/style.css@@ -14,7 +14,9 @@ button:disabled { opacity: 0.6; cursor: wait; }.toolbar { position: absolute; inset: 30px 40px auto; display: flex; align-items: center; gap: 26px; }.brand { color: #f5f6f5; text-decoration: none; font-weight: 700; font-size: 31px; letter-spacing: -2px; }.brand span { font-weight: 450; color: #a4b0b6; }-.studio-name { color: #a6b1b6; font-size: 14px; }+.studio-nav { display: flex; gap: 6px; }+.studio-nav a { text-decoration: none; color: #a6b1b6; font-size: 13px; padding: 9px 12px; border-radius: 7px; }+.studio-nav a[aria-current] { color: #edf0ef; background: #ffffff09; }.toolbar-actions { margin-left: auto; display: flex; gap: 10px; }.primary { background: #b7eddf; color: #19312c; font-weight: 600; }.primary:hover { background: #cdf7ec; }@@ -25,7 +27,13 @@ h1 { font-weight: 450; font-size: clamp(32px, 3.4vw, 55px); line-height: 1.1; le.object-caption { display: flex; align-items: center; gap: 10px; margin-top: 30px; font-size: 12px; color: #c4cfce; }.status-dot { color: #b7eddf; font-size: 8px; }.caption-separator { color: #69757d; margin: 0 2px; }-.controls { position: absolute; right: 36px; top: 29%; width: 178px; padding: 18px; background: #20262bc9; border-radius: 16px; backdrop-filter: blur(15px); font-size: 12px; }+.controls { position: absolute; right: 36px; top: 20%; width: 202px; padding: 18px; background: #20262bc9; border-radius: 16px; backdrop-filter: blur(15px); font-size: 12px; }+.assembly-control { margin-bottom: 25px; }+.assembly-control label { display: flex; justify-content: space-between; }+.assembly-control input { margin: 14px 0 8px; }+.assembly-endpoints { display: flex; justify-content: space-between; color: #aab5bc; font-size: 10px; }+.layer-actions { display: flex; gap: 4px; margin-top: 14px; }+.layer-actions button { padding: 8px 10px; font-size: 11px; flex: 1; }fieldset { padding: 0; margin: 0 0 28px; border: 0; }legend { color: #c5cecf; padding: 0; margin-bottom: 13px; }.finishes { display: flex; gap: 14px; margin-bottom: 12px; }@@ -59,20 +67,22 @@ h2 { font-weight: 500; font-size: 20px; margin: 0 0 15px; }.hint { display: none; }}@media (max-width: 700px) {- main { min-height: 700px; }- #viewport { position: absolute; top: 220px; height: calc(100% - 465px); }+ main { min-height: 800px; }+ #viewport { position: absolute; top: 200px; height: calc(100% - 570px); }.toolbar { inset: 18px 20px auto; gap: 15px; }.brand { font-size: 27px; }- .studio-name { display: none; }+ .studio-nav { position: absolute; top: 50px; left: 0; }+ .studio-nav a { padding: 7px 12px; }.toolbar-actions { gap: 5px; }.toolbar-actions button { padding: 10px 12px; font-size: 12px; }- .object-info { top: 94px; left: 24px; max-width: 100%; }+ .object-info { top: 120px; left: 24px; max-width: 100%; }h1 { font-size: 29px; letter-spacing: -1px; margin-bottom: 10px; }h1 br { display: none; }.object-info p { line-height: 1.5; }.object-info p br { display: none; }.object-caption { margin-top: 10px; font-size: 11px; }.controls { inset: auto 20px 84px; width: auto; padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }+ .assembly-control { grid-column: span 2; margin: 0 0 10px; }fieldset { margin: 0; grid-row: span 2; }legend { margin-bottom: 12px; }.finishes { margin-bottom: 10px; }@@ -83,7 +93,7 @@ h2 { font-weight: 500; font-size: 20px; margin: 0 0 15px; }footer { inset: auto 20px 20px; display: grid; gap: 8px; }.metrics { margin: 0; font-size: 10px; justify-content: space-between; }footer button { padding: 5px 0; text-align: left; font-size: 11px; background: transparent; }- .notice { bottom: 270px; }+ .notice { bottom: 360px; }.benchmark-result { left: 20px; bottom: 85px; max-width: calc(100% - 40px); }}@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }diff --git a/vite.config.js b/vite.config.jsindex 4dbc448a..ca93f3f6 100644--- a/vite.config.js+++ b/vite.config.js@@ -8,4 +8,5 @@ const headers = {export default defineConfig({server: { headers },preview: { headers },+ build: { rolldownOptions: { input: { object: 'index.html', nature: 'nature.html', film: 'film.html' } } },});