Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Add WebGL2 studio, GLB export and equivalent-render benchmark

Nguyen Xuan Anb0b07cbfaf4c
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..744e59a6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 67.js contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..a845292c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,82 @@
+# 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.
+
+![The mechanical specimen rendered by 67.js](docs/specimen.png)
+
+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 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.
+
+## Run
+
+1. Install Node.js 22.12 or newer.
+2. Run `npm ci`.
+3. Run `npm run dev`.
+4. Open the URL printed by Vite.
+
+## Checks
+
+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.
+
+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.
+
+## Performance
+
+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 local Chrome run on an RTX 3060 measured these medians.
+
+| 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 |
+
+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.
+
+## Renderer shape
+
+`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.
+
+```js
+import { 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.
+```
+
+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.
+
+## References
+
+- [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.
+
+The geometry and model in this repository are original. No Blender source or external model assets are included.
diff --git a/docs/benchmark.json b/docs/benchmark.json
new file mode 100644
index 00000000..9e9ea192
--- /dev/null
+++ b/docs/benchmark.json
@@ -0,0 +1,45 @@
+{
+ "graphics": {
+ "parts": 252,
+ "triangles": 206432,
+ "calls": 9,
+ "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,
+ "pixelAgreement": 1
+ },
+ {
+ "name": "67.js individual",
+ "milliseconds": 0.0318750012665987,
+ "calls": 253,
+ "pixelAgreement": 0.9999951171875
+ },
+ {
+ "name": "Three.js instanced",
+ "milliseconds": 0.016875000670552254,
+ "calls": 9,
+ "pixelAgreement": 0.999990234375
+ },
+ {
+ "name": "Three.js individual",
+ "milliseconds": 0.4237500000745058,
+ "calls": 253,
+ "pixelAgreement": 0.9999951171875
+ }
+ ],
+ "resolution": [
+ 640,
+ 480
+ ],
+ "samples": 120,
+ "submissionsPerSample": 8,
+ "isolated": true,
+ "metric": "CPU draw submission median milliseconds, GPU synchronization outside timed region",
+ "browser": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/154.0.0.0 Safari/537.36",
+ "errors": []
+}
\ No newline at end of file
diff --git a/docs/specimen.png b/docs/specimen.png
new file mode 100644
index 00000000..f279f7bb
Binary files /dev/null and b/docs/specimen.png differ
diff --git a/docs/verification.md b/docs/verification.md
new file mode 100644
index 00000000..1fbd42c8
--- /dev/null
+++ b/docs/verification.md
@@ -0,0 +1,25 @@
+# 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`.
+
+| 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.
diff --git a/index.html b/index.html
new file mode 100644
index 00000000..5a82565c
--- /dev/null
+++ b/index.html
@@ -0,0 +1,62 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <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." />
+ <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>
+ <body>
+ <main>
+ <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>
+ <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>
+ </section>
+ <aside class="controls" aria-label="Model appearance">
+ <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" 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>
+ </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" />
+ <div class="view-actions">
+ <button id="rotate" aria-pressed="false">↻ Auto orbit</button>
+ <button id="inspect" aria-pressed="false">Surface normals</button>
+ </div>
+ <label class="quality-label" for="quality">Resolution
+ <select id="quality"><option value="1">Performance</option><option value="1.5" selected>Balanced</option><option value="2">High</option></select>
+ </label>
+ </aside>
+ <footer>
+ <p class="hint">Drag to orbit <span>·</span> Scroll to zoom</p>
+ <div class="metrics" aria-label="Renderer statistics"><span id="parts">Loading geometry…</span><span id="calls"></span><span id="cpu"></span></div>
+ <button id="benchmark">Measure performance ↗</button>
+ </footer>
+ <section id="benchmark-result" class="benchmark-result" hidden aria-label="Performance results">
+ <h2>CPU draw submission</h2>
+ <p id="benchmark-summary" role="status"></p>
+ <p class="benchmark-note">Same geometry, camera, resolution and flat shader. Median of 120 samples, 8 submissions per sample. GPU time and visual quality are separate measurements.</p>
+ <button id="dismiss-benchmark">Back to model</button>
+ </section>
+ <p id="notice" class="notice" role="status" hidden></p>
+ </main>
+ <script type="module" src="/src/main.js"></script>
+ </body>
+</html>
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 00000000..61732370
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,875 @@
+{
+ "name": "67.js",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "67.js",
+ "version": "0.1.0",
+ "dependencies": {
+ "gl-matrix": "3.4.4"
+ },
+ "devDependencies": {
+ "playwright": "1.64.0",
+ "three": "0.186.1",
+ "vite": "8.3.4"
+ }
+ },
+ "node_modules/@oxc-project/types": {
+ "version": "0.153.0",
+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.153.0.tgz",
+ "integrity": "sha512-jSNrRIyvPVLL5E1z/tS5zLAprosGz/FuI1PWwEOz59j3E4TTTzSpqKb/RDGqJhhW0QHYISGXxq582wGx6T11Tw==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/oxc-project"
+ }
+ },
+ "node_modules/@rolldown/binding-android-arm-eabi": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.13.tgz",
+ "integrity": "sha512-Vu/NICrgdRvUOeaJZIyB2FP63s6fO/4ud5l8dXmxDx9yDyn+mN0y+gsvsVviSli+T361Aqo0h46EuMoobrwawA==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-android-arm64": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.13.tgz",
+ "integrity": "sha512-6LEoIrGy5vvCd2boNnv2soPSUZj/PRvhp8R/t9KlX+mIZxThIE/ZqxrGXxmuNX0FuvQFvLdZr7S4HrYpYBVhEQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-darwin-arm64": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.13.tgz",
+ "integrity": "sha512-CaJSRzlQ6Q+zkDMVA9OkVxBjVoPRCDEE3v0FSJ9kIQBgRjFApA3Si4ijhbNVUji7ZJt+PfO0e46qy4nPInHUPA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-darwin-x64": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.13.tgz",
+ "integrity": "sha512-e4r340I5hxSzJkD3YJBxgzq/rJ3wwxwdLLb2FPt1Zpyem20nrQPT11DDEEkazwxaHumH8wpglsp/Ozgj/wT6mw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-freebsd-x64": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.13.tgz",
+ "integrity": "sha512-hoBWDZ4/K/mJKVMbsgUd1jfpA2DiOrJ54mpegObU9TBHBBrtX4FLIXJJQRDPZ/2Dn91GvPob+Z2hwKJzf4E5SQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.13.tgz",
+ "integrity": "sha512-oF9fZu3vTWnTiVAkDFxU9PJLt1nh20K9RRpuHsR7ZnE2L7XookBbDBVLojCVSLGbvtSlxeUNnjAj6DbNsKyzbg==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm64-gnu": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.13.tgz",
+ "integrity": "sha512-DTpb/+jMiqWMPgphn4ksW1zW+XLJ6dJJ9FMvnIk9I291LhCctMPhMYJrP5t9p6C9qa3KXadDdUEZHBaPh3kNxQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-arm64-musl": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.13.tgz",
+ "integrity": "sha512-xU+Kvv9N2A3SY35zFh1FWWNjxbadE/BKeqnkXe7vScU4GZsw757BlVmDLITZEq8DPpk6m7uoDYkK7P+x/uU5Ow==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.13.tgz",
+ "integrity": "sha512-XMk/hnhh25oQ756Lclb1Q11h4ll0xC0Esa5w4Vzp+mAE2S3AGJgeM0SonrIgY8fHhjarb6hcoTuwoFG0VVP2ig==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-s390x-gnu": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.13.tgz",
+ "integrity": "sha512-U1BoTHYmlywE2n3HUWjzZ+8EQsKr+OwpxYuDWaubx42tUL8QSL7nOqRz/NVHanibbFP3M1Rxuprz/wNcbMKjqw==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-x64-gnu": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.13.tgz",
+ "integrity": "sha512-J4cm80Pc6wEwV5AZ42o62sIQgDk+Y7R2s646jIwuvO+4V46QB58N4vVuMPWCBaNgursXLpmUWJV//WQAkPvHBQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-linux-x64-musl": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.13.tgz",
+ "integrity": "sha512-W0euZS40U4V6JkmEnVCIX9mcsL6cbXQ4X8c2w+MMOIjFg68TXUW+u3RT+2e1t1pv9mg/EP3pDtK3POXdQ7Rxyw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-openharmony-arm64": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.13.tgz",
+ "integrity": "sha512-do/AF/4n9MRshia3a5aXoy8xM2c6mgfT6D7H/dY6my5z+hfCIR4ab7mk4IRj++nsEQpKy39kd0DQnDq+r692tw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-win32-arm64-msvc": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.13.tgz",
+ "integrity": "sha512-6FtUf2cJZobutJdxnGYX8z0vtbgqU0b2v8vfBhkXb9wp2MppMFtkunE+IaOntyi01rkIQoPW2GHABtfzsC0BRQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/binding-win32-x64-msvc": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.13.tgz",
+ "integrity": "sha512-UKhFaZTeTcbKrb3iU82m17jVcPEAoqDkCN5MBqgPyZSwp/cQmib21crTS0DdH7T1B7wZRWEI89YQAOJMet5yhg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ }
+ },
+ "node_modules/@rolldown/pluginutils": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/detect-libc": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/fdir": {
+ "version": "6.5.0",
+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "peerDependencies": {
+ "picomatch": "^3 || ^4"
+ },
+ "peerDependenciesMeta": {
+ "picomatch": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/gl-matrix": {
+ "version": "3.4.4",
+ "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.4.tgz",
+ "integrity": "sha512-latSnyDNt/8zYUB6VIJ6PCh2jBjJX6gnDsoCZ7LyW7GkqrD51EWwa9qCoGixj8YqBtETQK/xY7OmpTF8xz1DdQ==",
+ "license": "MIT"
+ },
+ "node_modules/lightningcss": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",
+ "dev": true,
+ "license": "MPL-2.0",
+ "dependencies": {
+ "detect-libc": "^2.0.3"
+ },
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ },
+ "optionalDependencies": {
+ "lightningcss-android-arm64": "1.33.0",
+ "lightningcss-darwin-arm64": "1.33.0",
+ "lightningcss-darwin-x64": "1.33.0",
+ "lightningcss-freebsd-x64": "1.33.0",
+ "lightningcss-linux-arm-gnueabihf": "1.33.0",
+ "lightningcss-linux-arm64-gnu": "1.33.0",
+ "lightningcss-linux-arm64-musl": "1.33.0",
+ "lightningcss-linux-x64-gnu": "1.33.0",
+ "lightningcss-linux-x64-musl": "1.33.0",
+ "lightningcss-win32-arm64-msvc": "1.33.0",
+ "lightningcss-win32-x64-msvc": "1.33.0"
+ }
+ },
+ "node_modules/lightningcss-android-arm64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",
+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-arm64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",
+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-x64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",
+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-freebsd-x64": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",
+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm-gnueabihf": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",
+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-gnu": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",
+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-musl": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",
+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-gnu": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",
+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-musl": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",
+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-arm64-msvc": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",
+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-x64-msvc": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",
+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/nanoid": {
+ "version": "3.3.20",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
+ "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
+ "node_modules/picocolors": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/picomatch": {
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
+ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/playwright": {
+ "version": "1.64.0",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.0.tgz",
+ "integrity": "sha512-kVzTnYFYEyQ9RGzBjNCd2+yEqWmVbxl3AHPynv3qQ6JTjv4a+kwRcnqQwIpuP3NnrnIrE/Q6wWAIAvMfIE2/Yg==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "playwright-core": "1.64.0"
+ },
+ "bin": {
+ "playwright": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/playwright-core": {
+ "version": "1.64.0",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.0.tgz",
+ "integrity": "sha512-T9r+MZkTECl2+oUcZ26YgZzTrYidTsIhYYkJix+6iDOymOb1FB2RLLSOxRGnZGv5DStt+aduIVbt+E8WygXYpg==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "playwright-core": "cli.js"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/postcss": {
+ "version": "8.5.29",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.29.tgz",
+ "integrity": "sha512-49cGhUbXj8Qenv0iTMxA1cFBzxXoctpC9Ujd77t1WcbJIr6nF/eI7g/8MgxrYldFRuAXvja7xQRwavoW7kgrxQ==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/postcss"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "nanoid": "^3.3.19",
+ "picocolors": "^1.1.1",
+ "source-map-js": "^1.2.2"
+ },
+ "engines": {
+ "node": "^10 || ^12 || >=14"
+ }
+ },
+ "node_modules/rolldown": {
+ "version": "1.2.13",
+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.13.tgz",
+ "integrity": "sha512-/5apOkwWxtACcQtZ5WlrAsKS4JwXVThQPJZ3RqIruRY9UG9M8e0VlXN068xum/JRKA4aIUoJ13ghe/kGCvidiQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@oxc-project/types": "=0.153.0",
+ "@rolldown/pluginutils": "^1.0.0"
+ },
+ "bin": {
+ "rolldown": "bin/cli.mjs"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "optionalDependencies": {
+ "@rolldown/binding-android-arm-eabi": "1.2.13",
+ "@rolldown/binding-android-arm64": "1.2.13",
+ "@rolldown/binding-darwin-arm64": "1.2.13",
+ "@rolldown/binding-darwin-x64": "1.2.13",
+ "@rolldown/binding-freebsd-x64": "1.2.13",
+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.13",
+ "@rolldown/binding-linux-arm64-gnu": "1.2.13",
+ "@rolldown/binding-linux-arm64-musl": "1.2.13",
+ "@rolldown/binding-linux-ppc64-gnu": "1.2.13",
+ "@rolldown/binding-linux-s390x-gnu": "1.2.13",
+ "@rolldown/binding-linux-x64-gnu": "1.2.13",
+ "@rolldown/binding-linux-x64-musl": "1.2.13",
+ "@rolldown/binding-openharmony-arm64": "1.2.13",
+ "@rolldown/binding-win32-arm64-msvc": "1.2.13",
+ "@rolldown/binding-win32-x64-msvc": "1.2.13"
+ }
+ },
+ "node_modules/source-map-js": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
+ "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/three": {
+ "version": "0.186.1",
+ "resolved": "https://registry.npmjs.org/three/-/three-0.186.1.tgz",
+ "integrity": "sha512-blFeqb49wRCSGUGj7gtpfnSGHy2lwDk94RhUmS1c/hTby70kvChbWpkJ4Pm1390LqzzvTmzgXKHPEafJwCb8jA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/tinyglobby": {
+ "version": "0.2.17",
+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fdir": "^6.5.0",
+ "picomatch": "^4.0.4"
+ },
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/SuperchupuDev"
+ }
+ },
+ "node_modules/vite": {
+ "version": "8.3.4",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.4.tgz",
+ "integrity": "sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "lightningcss": "^1.33.0",
+ "picomatch": "^4.0.7",
+ "postcss": "^8.5.29",
+ "rolldown": "~1.2.12",
+ "tinyglobby": "^0.2.17"
+ },
+ "bin": {
+ "vite": "bin/vite.js"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "funding": {
+ "url": "https://github.com/vitejs/vite?sponsor=1"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.3"
+ },
+ "peerDependencies": {
+ "@types/node": "^20.19.0 || >=22.12.0",
+ "@vitejs/devtools": "^0.7.1",
+ "esbuild": "^0.27.0 || ^0.28.0",
+ "jiti": ">=1.21.0",
+ "less": "^4.0.0",
+ "sass": "^1.70.0",
+ "sass-embedded": "^1.70.0",
+ "stylus": ">=0.54.8",
+ "sugarss": "^5.0.0",
+ "terser": "^5.16.0",
+ "tsx": "^4.8.1",
+ "yaml": "^2.4.2"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ },
+ "@vitejs/devtools": {
+ "optional": true
+ },
+ "esbuild": {
+ "optional": true
+ },
+ "jiti": {
+ "optional": true
+ },
+ "less": {
+ "optional": true
+ },
+ "sass": {
+ "optional": true
+ },
+ "sass-embedded": {
+ "optional": true
+ },
+ "stylus": {
+ "optional": true
+ },
+ "sugarss": {
+ "optional": true
+ },
+ "terser": {
+ "optional": true
+ },
+ "tsx": {
+ "optional": true
+ },
+ "yaml": {
+ "optional": true
+ }
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
index 3e2b74b6..7188ad62 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,12 @@
"test": "node --test",
"smoke": "node scripts/smoke.mjs"
},
- "dependencies": { "gl-matrix": "3.4.4" },
- "devDependencies": { "vite": "8.0.3", "playwright": "1.58.2", "three": "0.186.0" }
+ "dependencies": {
+ "gl-matrix": "3.4.4"
+ },
+ "devDependencies": {
+ "playwright": "1.64.0",
+ "three": "0.186.1",
+ "vite": "8.3.4"
+ }
}
diff --git a/public/specimen.glb b/public/specimen.glb
new file mode 100644
index 00000000..7ac437b0
Binary files /dev/null and b/public/specimen.glb differ
diff --git a/scripts/export-model.mjs b/scripts/export-model.mjs
new file mode 100644
index 00000000..5ee6260b
--- /dev/null
+++ b/scripts/export-model.mjs
@@ -0,0 +1,9 @@
+import { mkdir, writeFile } from 'node:fs/promises';
+import { createModel } from '../src/model.js';
+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`);
diff --git a/scripts/smoke.mjs b/scripts/smoke.mjs
new file mode 100644
index 00000000..acb05f30
--- /dev/null
+++ b/scripts/smoke.mjs
@@ -0,0 +1,100 @@
+import { chromium } from 'playwright';
+import { spawn } from 'node:child_process';
+import { mkdir, writeFile } from 'node:fs/promises';
+import { existsSync } from 'node:fs';
+import assert from 'node:assert/strict';
+import { fileURLToPath } from 'node:url';
+
+const artifactDirectory = new URL('../artifacts/', import.meta.url);
+await mkdir(artifactDirectory, { recursive: true });
+const server = spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1', '--port', '5178', '--strictPort'], { cwd: new URL('..', import.meta.url), windowsHide: true, stdio: 'pipe' });
+let browser;
+try {
+ await new Promise((resolve, reject) => {
+ const timeout = setTimeout(() => reject(new Error('Vite did not start.')), 15000);
+ server.stdout.on('data', (data) => {
+ if (data.toString().includes('127.0.0.1:5178')) { clearTimeout(timeout); resolve(); }
+ });
+ server.on('error', reject);
+ server.on('exit', (code) => { clearTimeout(timeout); reject(new Error(`Vite exited ${code}`)); });
+ });
+ const chromePath = 'C:/Program Files/Google/Chrome/Application/chrome.exe';
+ browser = await chromium.launch({ headless: true, ...(existsSync(chromePath) ? { executablePath: chromePath } : {}), args: ['--enable-webgl', '--ignore-gpu-blocklist'] });
+ const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 1 });
+ const errors = [];
+ page.on('pageerror', (error) => errors.push(error.message));
+ page.on('console', (message) => { if (message.type() === 'error') errors.push(message.text()); });
+ 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)) });
+ const graphics = await page.evaluate(() => {
+ const renderer = window.__studio.renderer;
+ const context = renderer.context;
+ 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, 252);
+ assert.equal(graphics.calls, 9);
+ 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.locator('#viewport').focus();
+ const initialAzimuth = await page.evaluate(() => window.__studio.state.azimuth);
+ await page.keyboard.press('ArrowRight');
+ assert.ok(await page.evaluate((initial) => window.__studio.state.azimuth > initial, initialAzimuth));
+ await page.getByRole('button', { name: 'Reset view' }).click();
+ assert.equal(await page.evaluate(() => window.__studio.state.azimuth), initialAzimuth);
+ await page.getByRole('button', { name: 'Surface normals' }).click();
+ assert.equal(await page.evaluate(() => window.__studio.state.inspection), true);
+ await page.getByRole('button', { name: 'Surface normals' }).click();
+ 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 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), [9, 253, 9, 253]);
+ 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 });
+ await page.waitForTimeout(250);
+ await page.screenshot({ path: fileURLToPath(new URL('mobile.png', artifactDirectory)) });
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth), 390);
+ await page.setViewportSize({ width: 320, height: 700 });
+ await page.waitForTimeout(100);
+ await page.screenshot({ path: fileURLToPath(new URL('narrow.png', artifactDirectory)) });
+ assert.equal(await page.evaluate(() => document.documentElement.scrollWidth), 320);
+ const visibleControls = await page.locator('button:not([hidden])').evaluateAll((buttons) => buttons.filter((button) => button.checkVisibility()).map((button) => {
+ const rectangle = button.getBoundingClientRect();
+ 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.setViewportSize({ width: 390, height: 844 });
+ await page.getByRole('button', { name: 'Graphite finish' }).click();
+ assert.equal(await page.locator('#finish-name').textContent(), 'Graphite');
+ await page.getByRole('button', { name: 'Auto orbit' }).click();
+ const orbitStart = await page.evaluate(() => window.__studio.state.azimuth);
+ await page.waitForTimeout(300);
+ assert.ok(await page.evaluate((initial) => window.__studio.state.azimuth > initial, orbitStart));
+ await page.getByRole('button', { name: 'Auto orbit' }).click();
+ await page.evaluate(() => {
+ window.__lostExtension = window.__studio.renderer.context.getExtension('WEBGL_lose_context');
+ window.__lostExtension.loseContext();
+ });
+ await page.waitForFunction(() => document.querySelector('#notice').textContent.includes('context lost'));
+ await page.waitForTimeout(250);
+ await page.evaluate(() => window.__lostExtension.restoreContext());
+ await page.waitForFunction(() => document.querySelector('#notice').textContent.includes('Graphics restored'));
+ assert.equal(await page.evaluate(() => window.__studio.renderer.context.getError()), 0);
+ 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));
+} finally {
+ await browser?.close();
+ server.kill();
+}
diff --git a/src/benchmark.js b/src/benchmark.js
new file mode 100644
index 00000000..1822e877
--- /dev/null
+++ b/src/benchmark.js
@@ -0,0 +1,104 @@
+import { Renderer67, groupParts } from './renderer.js';
+import { benchmarkVertexShader, benchmarkFragmentShader } from './shaders.js';
+
+function median(values) {
+ const sorted = [...values].sort((left, right) => left - right);
+ return sorted[Math.floor(sorted.length / 2)];
+}
+
+async function measure(render, context) {
+ const timings = [];
+ for (let index = 0; index < 150; index++) {
+ await new Promise(requestAnimationFrame);
+ context.finish();
+ const start = performance.now();
+ for (let repetition = 0; repetition < 8; repetition++) render();
+ const milliseconds = (performance.now() - start) / 8;
+ context.finish();
+ if (index >= 30) timings.push(milliseconds);
+ }
+ return median(timings);
+}
+
+export async function runBenchmark(parts, onProgress = () => {}) {
+ const THREE = await import('three');
+ const canvas = document.createElement('canvas');
+ canvas.style.cssText = 'width:640px;height:480px;position:fixed;left:-1000px;top:0';
+ document.body.appendChild(canvas);
+ const results = [];
+ let referencePixels;
+ function comparePixels(context, render) {
+ render();
+ const pixels = new Uint8Array(640 * 480 * 4);
+ context.readPixels(0, 0, 640, 480, context.RGBA, context.UNSIGNED_BYTE, pixels);
+ if (!referencePixels) referencePixels = pixels;
+ let matching = 0;
+ for (let index = 0; index < pixels.length; index++) {
+ if (Math.abs(pixels[index] - referencePixels[index]) <= 1) matching++;
+ }
+ return matching / pixels.length;
+ }
+ const camera = { eye: [4, 3.1, 5], target: [0, 1.2, 0] };
+ try {
+ for (const batching of [true, false]) {
+ onProgress(`Measuring 67.js ${batching ? 'instanced' : 'individual meshes'}…`);
+ const renderer = new Renderer67(canvas, parts, { batching, pixelRatio: 1, benchmark: true });
+ try {
+ const milliseconds = await measure(() => renderer.render(camera), renderer.context);
+ results.push({ name: `67.js ${batching ? 'instanced' : 'individual'}`, milliseconds, calls: renderer.batches.length, pixelAgreement: comparePixels(renderer.context, () => renderer.render(camera)) });
+ } finally {
+ renderer.dispose();
+ }
+ }
+ for (const batching of [true, false]) {
+ onProgress(`Measuring Three.js ${batching ? 'instanced' : 'individual meshes'}…`);
+ const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: false });
+ renderer.setPixelRatio(1);
+ renderer.setSize(640, 480, false);
+ renderer.setClearColor(0x25292d);
+ const scene = new THREE.Scene();
+ const threeCamera = new THREE.PerspectiveCamera(180 / 5.5, 640 / 480, 0.1, 100);
+ threeCamera.position.set(...camera.eye);
+ threeCamera.lookAt(...camera.target);
+ threeCamera.updateMatrixWorld();
+ const viewProjection = new THREE.Matrix4().multiplyMatrices(threeCamera.projectionMatrix, threeCamera.matrixWorldInverse);
+ const geometries = [];
+ const material = new THREE.RawShaderMaterial({
+ glslVersion: THREE.GLSL3,
+ vertexShader: benchmarkVertexShader.replace('#version 300 es', ''),
+ fragmentShader: benchmarkFragmentShader.replace('#version 300 es', ''),
+ uniforms: { viewProjection: { value: viewProjection } },
+ });
+ const floor = {
+ geometry: { positions: new Float32Array([-100, 0.019, -100, -100, 0.019, 100, 100, 0.019, 100, 100, 0.019, -100]), indices: new Uint32Array([0, 1, 2, 0, 2, 3]) },
+ matrix: new THREE.Matrix4().elements,
+ material: { color: [0.04, 0.05, 0.06] },
+ };
+ for (const group of groupParts([...parts, floor], batching)) {
+ const source = group[0].geometry;
+ const geometry = new THREE.InstancedBufferGeometry();
+ geometry.setAttribute('position', new THREE.BufferAttribute(source.positions, 3));
+ geometry.setIndex(new THREE.BufferAttribute(source.indices, 1));
+ geometry.setAttribute('instanceMatrix', new THREE.InstancedBufferAttribute(new Float32Array(group.flatMap((part) => Array.from(part.matrix))), 16));
+ geometry.setAttribute('instanceColor', new THREE.InstancedBufferAttribute(new Float32Array(group.flatMap((part) => part.material.color)), 3));
+ geometry.instanceCount = group.length;
+ const mesh = new THREE.Mesh(geometry, material);
+ mesh.frustumCulled = false;
+ mesh.matrixAutoUpdate = false;
+ scene.add(mesh);
+ geometries.push(geometry);
+ }
+ try {
+ const milliseconds = await measure(() => renderer.render(scene, threeCamera), renderer.getContext());
+ results.push({ name: `Three.js ${batching ? 'instanced' : 'individual'}`, milliseconds, calls: renderer.info.render.calls, pixelAgreement: comparePixels(renderer.getContext(), () => renderer.render(scene, threeCamera)) });
+ } finally {
+ geometries.forEach((geometry) => geometry.dispose());
+ material.dispose();
+ renderer.dispose();
+ }
+ }
+ return { results, resolution: [640, 480], samples: 120, submissionsPerSample: 8, isolated: window.crossOriginIsolated, metric: 'CPU draw submission median milliseconds, GPU synchronization outside timed region', browser: navigator.userAgent };
+ } finally {
+ canvas.remove();
+ }
+}
diff --git a/src/export.js b/src/export.js
new file mode 100644
index 00000000..07e5e832
--- /dev/null
+++ b/src/export.js
@@ -0,0 +1,91 @@
+function paddedLength(length) {
+ return Math.ceil(length / 4) * 4;
+}
+
+export function exportGlb(parts) {
+ const document = {
+ asset: { version: '2.0', generator: '67.js' },
+ scene: 0,
+ scenes: [{ nodes: parts.map((_, index) => index) }],
+ nodes: [],
+ meshes: [],
+ materials: [],
+ accessors: [],
+ bufferViews: [],
+ buffers: [],
+ };
+ const chunks = [];
+ let byteLength = 0;
+ const geometries = new Map();
+ const materials = new Map();
+ const meshes = new Map();
+ function accessor(data, type, target) {
+ const viewIndex = document.bufferViews.length;
+ document.bufferViews.push({ buffer: 0, byteOffset: byteLength, byteLength: data.byteLength, target });
+ chunks.push({ offset: byteLength, data: new Uint8Array(data.buffer, data.byteOffset, data.byteLength) });
+ byteLength += paddedLength(data.byteLength);
+ const entry = { bufferView: viewIndex, componentType: data instanceof Float32Array ? 5126 : 5125, count: type === 'VEC3' ? data.length / 3 : data.length, type };
+ if (type === 'VEC3') {
+ entry.min = [Infinity, Infinity, Infinity];
+ entry.max = [-Infinity, -Infinity, -Infinity];
+ for (let index = 0; index < data.length; index++) {
+ const component = index % 3;
+ entry.min[component] = Math.min(entry.min[component], data[index]);
+ entry.max[component] = Math.max(entry.max[component], data[index]);
+ }
+ }
+ document.accessors.push(entry);
+ return document.accessors.length - 1;
+ }
+ for (const part of parts) {
+ if (!geometries.has(part.geometry)) {
+ geometries.set(part.geometry, {
+ attributes: { POSITION: accessor(part.geometry.positions, 'VEC3', 34962), NORMAL: accessor(part.geometry.normals, 'VEC3', 34962) },
+ indices: accessor(part.geometry.indices, 'SCALAR', 34963),
+ });
+ }
+ const materialKey = JSON.stringify(part.material);
+ if (!materials.has(materialKey)) {
+ materials.set(materialKey, document.materials.length);
+ document.materials.push({
+ pbrMetallicRoughness: { baseColorFactor: [...part.material.color, 1], metallicFactor: part.material.metallic, roughnessFactor: part.material.roughness },
+ emissiveFactor: part.material.color.map((component) => Math.min(1, component * (part.material.emission ?? 0))),
+ });
+ }
+ const geometry = geometries.get(part.geometry);
+ const material = materials.get(materialKey);
+ const meshKey = `${geometry.indices}:${material}`;
+ if (!meshes.has(meshKey)) {
+ meshes.set(meshKey, document.meshes.length);
+ document.meshes.push({ primitives: [{ ...geometry, material }] });
+ }
+ document.nodes.push({ name: part.name, mesh: meshes.get(meshKey), matrix: Array.from(part.matrix) });
+ }
+ document.buffers.push({ byteLength });
+ const json = new TextEncoder().encode(JSON.stringify(document));
+ const jsonLength = paddedLength(json.length);
+ const result = new ArrayBuffer(12 + 8 + jsonLength + 8 + byteLength);
+ const header = new DataView(result);
+ header.setUint32(0, 0x46546c67, true);
+ header.setUint32(4, 2, true);
+ header.setUint32(8, result.byteLength, true);
+ header.setUint32(12, jsonLength, true);
+ header.setUint32(16, 0x4e4f534a, true);
+ const bytes = new Uint8Array(result);
+ bytes.fill(32, 20, 20 + jsonLength);
+ bytes.set(json, 20);
+ const binaryHeader = 20 + jsonLength;
+ header.setUint32(binaryHeader, byteLength, true);
+ header.setUint32(binaryHeader + 4, 0x004e4942, true);
+ for (const chunk of chunks) bytes.set(chunk.data, binaryHeader + 8 + chunk.offset);
+ return result;
+}
+
+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.click();
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
+}
diff --git a/src/main.js b/src/main.js
new file mode 100644
index 00000000..bd16fe02
--- /dev/null
+++ b/src/main.js
@@ -0,0 +1,180 @@
+import './style.css';
+import { Renderer67 } from './renderer.js';
+import { createModel } from './model.js';
+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] },
+ 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 };
+let renderer;
+let scheduledFrame = 0;
+let lastTime = 0;
+let frameCount = 0;
+let cpuTotal = 0;
+let noticeTimer;
+let dragging = null;
+
+function notify(message, failure = false) {
+ const notice = document.querySelector('#notice');
+ notice.textContent = `${failure ? '⚠' : '✓'} ${message}`;
+ notice.hidden = false;
+ clearTimeout(noticeTimer);
+ if (!failure) noticeTimer = setTimeout(() => { notice.hidden = true; }, 4000);
+}
+
+function camera() {
+ const mobile = canvas.clientWidth <= 700;
+ const distance = state.distance;
+ const target = [0, mobile ? 1.5 : 1.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],
+ armorColor: finishes[state.finish].color,
+ armorSurface: finishes[state.finish].surface,
+ exposure: state.exposure,
+ inspection: state.inspection,
+ };
+}
+
+function draw(time) {
+ scheduledFrame = 0;
+ if (!renderer || document.hidden) return;
+ if (state.rotating && !dragging) state.azimuth += Math.min((time - lastTime) / 1000, 0.05) * 0.16;
+ lastTime = time;
+ renderer.render(camera());
+ cpuTotal += renderer.cpuMilliseconds;
+ frameCount++;
+ document.querySelector('#cpu').textContent = `${(cpuTotal / frameCount).toFixed(2)} ms CPU`;
+ if (frameCount > 60) { cpuTotal = renderer.cpuMilliseconds; frameCount = 1; }
+ if (state.rotating) invalidate();
+}
+
+function invalidate() {
+ if (!scheduledFrame && renderer && !document.hidden) scheduledFrame = requestAnimationFrame(draw);
+}
+
+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`;
+ invalidate();
+ window.__studio = { parts, get renderer() { return renderer; }, state, camera, invalidate };
+}
+
+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 };
+ canvas.setPointerCapture(event.pointerId);
+});
+canvas.addEventListener('pointermove', (event) => {
+ if (!dragging || event.pointerId !== dragging.pointerId) return;
+ state.azimuth -= (event.clientX - dragging.x) * 0.007;
+ state.elevation = Math.max(-0.15, Math.min(1.1, state.elevation + (event.clientY - dragging.y) * 0.007));
+ dragging.x = event.clientX;
+ dragging.y = event.clientY;
+ invalidate();
+});
+for (const eventName of ['pointerup', 'pointercancel', 'lostpointercapture']) canvas.addEventListener(eventName, () => { dragging = null; });
+canvas.addEventListener('wheel', (event) => {
+ event.preventDefault();
+ state.distance = Math.max(3.5, Math.min(11, state.distance + event.deltaY * 0.008));
+ invalidate();
+}, { passive: false });
+canvas.addEventListener('keydown', (event) => {
+ const changes = { ArrowLeft: [-0.1, 0, 0], ArrowRight: [0.1, 0, 0], ArrowUp: [0, 0.08, 0], ArrowDown: [0, -0.08, 0], '+': [0, 0, -0.3], '=': [0, 0, -0.3], '-': [0, 0, 0.3] };
+ if (changes[event.key]) {
+ event.preventDefault();
+ const [azimuth, elevation, distance] = changes[event.key];
+ state.azimuth += azimuth;
+ state.elevation = Math.max(-0.15, Math.min(1.1, state.elevation + elevation));
+ state.distance = Math.max(3.5, Math.min(11, state.distance + distance));
+ invalidate();
+ }
+ 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 });
+ invalidate();
+});
+document.querySelectorAll('[data-finish]').forEach((button) => button.addEventListener('click', () => {
+ state.finish = button.dataset.finish;
+ document.querySelectorAll('[data-finish]').forEach((swatch) => {
+ const selected = swatch === button;
+ swatch.classList.toggle('selected', selected);
+ swatch.setAttribute('aria-pressed', String(selected));
+ });
+ document.querySelector('#finish-name').textContent = finishes[state.finish].name;
+ invalidate();
+}));
+document.querySelector('#exposure').addEventListener('input', (event) => {
+ state.exposure = Number(event.target.value);
+ document.querySelector('#exposure-value').textContent = state.exposure.toFixed(1);
+ invalidate();
+});
+document.querySelector('#rotate').addEventListener('click', (event) => {
+ state.rotating = !state.rotating;
+ event.currentTarget.setAttribute('aria-pressed', String(state.rotating));
+ lastTime = performance.now();
+ invalidate();
+});
+document.querySelector('#inspect').addEventListener('click', (event) => {
+ state.inspection = !state.inspection;
+ event.currentTarget.setAttribute('aria-pressed', String(state.inspection));
+ invalidate();
+});
+document.querySelector('#quality').addEventListener('change', (event) => {
+ if (!renderer) return;
+ renderer.pixelRatio = Number(event.target.value);
+ renderer.resize();
+ invalidate();
+});
+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);
+ downloadGlb(exported);
+ notify('GLB exported. Open it in Blender or another glTF viewer.');
+ } catch (error) { notify(`Export failed: ${error.message}`, true); }
+});
+document.querySelector('#benchmark').addEventListener('click', async (event) => {
+ const button = event.currentTarget;
+ button.disabled = true;
+ const wasRotating = state.rotating;
+ state.rotating = false;
+ document.querySelector('#rotate').setAttribute('aria-pressed', 'false');
+ const summary = document.querySelector('#benchmark-summary');
+ document.querySelector('#benchmark-result').hidden = false;
+ summary.textContent = '◷ Loading benchmark…';
+ try {
+ const { runBenchmark } = await import('./benchmark.js');
+ const report = await runBenchmark(parts, (progress) => { summary.textContent = `◷ ${progress}`; });
+ window.__benchmarkReport = report;
+ summary.textContent = `✓ Measured on this browser\n${report.results.map((result) => `${result.name}: ${result.milliseconds === 0 ? '<0.013' : result.milliseconds.toFixed(3)} ms · ${result.calls} calls`).join('\n')}`;
+ } catch (error) { summary.textContent = `⚠ Benchmark failed: ${error.message}`; }
+ finally {
+ button.disabled = false;
+ state.rotating = wasRotating;
+ document.querySelector('#rotate').setAttribute('aria-pressed', String(wasRotating));
+ invalidate();
+ }
+});
+document.querySelector('#dismiss-benchmark').addEventListener('click', () => { document.querySelector('#benchmark-result').hidden = true; });
+new ResizeObserver(() => { renderer?.resize(); invalidate(); }).observe(canvas);
+document.addEventListener('visibilitychange', () => { lastTime = performance.now(); invalidate(); });
+canvas.addEventListener('webglcontextlost', (event) => {
+ event.preventDefault();
+ cancelAnimationFrame(scheduledFrame);
+ scheduledFrame = 0;
+ renderer = null;
+ notify('Graphics context lost. Waiting for the browser to restore it.', true);
+});
+canvas.addEventListener('webglcontextrestored', () => {
+ try { initialize(); notify('Graphics restored.'); } catch (error) { notify(error.message, true); }
+});
diff --git a/src/renderer.js b/src/renderer.js
new file mode 100644
index 00000000..599667ba
--- /dev/null
+++ b/src/renderer.js
@@ -0,0 +1,206 @@
+import { mat4, mat3 } from 'gl-matrix';
+import { vertexShader, fragmentShader, depthVertexShader, depthFragmentShader, benchmarkVertexShader, benchmarkFragmentShader } from './shaders.js';
+
+function compileProgram(context, vertexSource, fragmentSource) {
+ const program = context.createProgram();
+ const shaders = [];
+ for (const [kind, source] of [[context.VERTEX_SHADER, vertexSource], [context.FRAGMENT_SHADER, fragmentSource]]) {
+ const shader = context.createShader(kind);
+ context.shaderSource(shader, source);
+ context.compileShader(shader);
+ if (!context.getShaderParameter(shader, context.COMPILE_STATUS)) {
+ const message = context.getShaderInfoLog(shader);
+ context.deleteShader(shader);
+ shaders.forEach((compiled) => context.deleteShader(compiled));
+ context.deleteProgram(program);
+ throw new Error(`Shader compilation failed: ${message}`);
+ }
+ shaders.push(shader);
+ context.attachShader(program, shader);
+ }
+ context.linkProgram(program);
+ shaders.forEach((shader) => context.deleteShader(shader));
+ if (!context.getProgramParameter(program, context.LINK_STATUS)) {
+ const message = context.getProgramInfoLog(program);
+ context.deleteProgram(program);
+ throw new Error(`Shader linking failed: ${message}`);
+ }
+ return program;
+}
+
+function groundPart() {
+ return {
+ name: 'Studio floor',
+ geometry: {
+ positions: new Float32Array([-100, 0.019, -100, -100, 0.019, 100, 100, 0.019, 100, 100, 0.019, -100]),
+ normals: new Float32Array([0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]),
+ indices: new Uint32Array([0, 1, 2, 0, 2, 3]),
+ },
+ matrix: mat4.create(),
+ material: { color: [0.04, 0.05, 0.06], metallic: 0, roughness: 1, emission: 0, tag: 'floor' },
+ };
+}
+
+export function groupParts(parts, batching = true) {
+ const groups = new Map();
+ for (const part of parts) {
+ if (part.matrix.length !== 16 || !Array.from(part.matrix).every(Number.isFinite)) {
+ throw new Error(`Invalid transform: ${part.name}`);
+ }
+ const key = batching ? part.geometry : part;
+ if (!groups.has(key)) groups.set(key, []);
+ groups.get(key).push(part);
+ }
+ return [...groups.values()];
+}
+
+export class Renderer67 {
+ constructor(canvas, parts, { batching = true, pixelRatio = 1.5, benchmark = false } = {}) {
+ this.canvas = canvas;
+ this.context = canvas.getContext('webgl2', { antialias: true, alpha: false, powerPreference: 'high-performance' });
+ if (!this.context) throw new Error('WebGL2 is unavailable. Enable hardware acceleration or use a supported browser.');
+ this.pixelRatio = pixelRatio;
+ this.benchmark = benchmark;
+ this.buffers = [];
+ this.batches = [];
+ this.view = mat4.create();
+ this.projection = mat4.create();
+ this.viewProjection = mat4.create();
+ this.lightProjection = 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'].map((name) => [name, this.context.getUniformLocation(this.program, name)]));
+ this.depthUniform = this.context.getUniformLocation(this.depthProgram, 'lightProjection');
+ this.partCount = parts.length;
+ this.triangles = parts.reduce((total, part) => total + part.geometry.indices.length / 3, 0);
+ groupParts([...parts, groundPart()], batching).forEach((group) => this.batches.push(this.uploadBatch(group)));
+ this.createShadowMap();
+ this.resize();
+ }
+
+ uploadBuffer(target, data) {
+ const buffer = this.context.createBuffer();
+ this.buffers.push(buffer);
+ this.context.bindBuffer(target, buffer);
+ this.context.bufferData(target, data, this.context.STATIC_DRAW);
+ return buffer;
+ }
+
+ uploadBatch(parts) {
+ const context = this.context;
+ const geometry = parts[0].geometry;
+ const vertexArray = context.createVertexArray();
+ context.bindVertexArray(vertexArray);
+ for (const [location, data] of [[0, geometry.positions], [1, geometry.normals]]) {
+ this.uploadBuffer(context.ARRAY_BUFFER, data);
+ context.enableVertexAttribArray(location);
+ context.vertexAttribPointer(location, 3, context.FLOAT, false, 0, 0);
+ }
+ this.uploadBuffer(context.ELEMENT_ARRAY_BUFFER, geometry.indices);
+ const stride = 32;
+ const instanceData = new Float32Array(parts.length * stride);
+ const normalMatrix = mat3.create();
+ parts.forEach((part, index) => {
+ const offset = index * stride;
+ if (!mat3.normalFromMat4(normalMatrix, part.matrix)) throw new Error(`Singular transform: ${part.name}`);
+ instanceData.set(part.matrix, offset);
+ instanceData.set(normalMatrix, offset + 16);
+ instanceData.set(part.material.color, offset + 25);
+ instanceData.set([part.material.metallic, part.material.roughness, part.material.emission ?? 0, part.material.tag === 'floor' ? 2 : part.material.tag === 'armor' ? 1 : 0], offset + 28);
+ });
+ 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);
+ context.bindVertexArray(null);
+ return { vertexArray, indexCount: geometry.indices.length, instanceCount: parts.length, floor: parts[0].material.tag === 'floor' };
+ }
+
+ attribute(location, size, stride, offset) {
+ this.context.enableVertexAttribArray(location);
+ this.context.vertexAttribPointer(location, size, this.context.FLOAT, false, stride, offset);
+ this.context.vertexAttribDivisor(location, 1);
+ }
+
+ createShadowMap() {
+ const context = this.context;
+ 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);
+ 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();
+ context.bindFramebuffer(context.FRAMEBUFFER, this.shadowFramebuffer);
+ context.framebufferTexture2D(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.TEXTURE_2D, this.shadowTexture, 0);
+ context.drawBuffers([context.NONE]);
+ context.readBuffer(context.NONE);
+ if (context.checkFramebufferStatus(context.FRAMEBUFFER) !== context.FRAMEBUFFER_COMPLETE) throw new Error('Shadow framebuffer is incomplete.');
+ const lightView = mat4.lookAt(mat4.create(), [-3, 6, 4], [0, 1, 0], [0, 1, 0]);
+ mat4.ortho(this.lightProjection, -3.5, 3.5, -3.5, 3.5, 0.1, 15);
+ mat4.multiply(this.lightProjection, this.lightProjection, lightView);
+ context.viewport(0, 0, 2048, 2048);
+ context.enable(context.DEPTH_TEST);
+ context.enable(context.CULL_FACE);
+ context.clear(context.DEPTH_BUFFER_BIT);
+ context.useProgram(this.depthProgram);
+ context.uniformMatrix4fv(this.depthUniform, false, this.lightProjection);
+ context.enable(context.POLYGON_OFFSET_FILL);
+ context.polygonOffset(1, 1);
+ for (const batch of this.batches) if (!batch.floor) this.drawBatch(batch);
+ context.disable(context.POLYGON_OFFSET_FILL);
+ context.bindFramebuffer(context.FRAMEBUFFER, null);
+ }
+
+ resize() {
+ const ratio = Math.min(window.devicePixelRatio || 1, this.pixelRatio);
+ const width = Math.max(1, Math.round(this.canvas.clientWidth * ratio));
+ const height = Math.max(1, Math.round(this.canvas.clientHeight * ratio));
+ if (this.canvas.width !== width || this.canvas.height !== height) {
+ this.canvas.width = width;
+ this.canvas.height = height;
+ }
+ mat4.perspective(this.projection, Math.PI / 5.5, width / height, 0.1, 100);
+ this.projection[8] = !this.benchmark && this.canvas.clientWidth > 700 ? -0.25 : 0;
+ }
+
+ drawBatch(batch) {
+ this.context.bindVertexArray(batch.vertexArray);
+ this.context.drawElementsInstanced(this.context.TRIANGLES, batch.indexCount, this.context.UNSIGNED_INT, 0, batch.instanceCount);
+ }
+
+ render({ eye, target = [0, 1.2, 0], armorColor = [0.53, 0.39, 0.24], armorSurface = [0.88, 0.32], exposure = 1, inspection = false }) {
+ const start = performance.now();
+ const context = this.context;
+ mat4.lookAt(this.view, eye, target, [0, 1, 0]);
+ mat4.multiply(this.viewProjection, this.projection, this.view);
+ context.viewport(0, 0, this.canvas.width, this.canvas.height);
+ context.clearColor(0.145, 0.162, 0.177, 1);
+ context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT);
+ context.useProgram(this.program);
+ context.uniformMatrix4fv(this.uniforms.viewProjection, false, this.viewProjection);
+ context.uniformMatrix4fv(this.uniforms.lightProjection, false, this.lightProjection);
+ context.uniform3fv(this.uniforms.eye, eye);
+ context.uniform3fv(this.uniforms.armorColor, armorColor);
+ context.uniform2fv(this.uniforms.armorSurface, armorSurface);
+ context.uniform1f(this.uniforms.exposure, exposure);
+ context.uniform1f(this.uniforms.inspection, inspection ? 1 : 0);
+ context.activeTexture(context.TEXTURE0);
+ context.bindTexture(context.TEXTURE_2D, this.shadowTexture);
+ context.uniform1i(this.uniforms.shadowMap, 0);
+ for (const batch of this.batches) this.drawBatch(batch);
+ context.bindVertexArray(null);
+ this.cpuMilliseconds = performance.now() - start;
+ }
+
+ dispose() {
+ this.batches.forEach((batch) => this.context.deleteVertexArray(batch.vertexArray));
+ this.buffers.forEach((buffer) => this.context.deleteBuffer(buffer));
+ this.context.deleteTexture(this.shadowTexture);
+ this.context.deleteFramebuffer(this.shadowFramebuffer);
+ this.context.deleteProgram(this.program);
+ this.context.deleteProgram(this.depthProgram);
+ }
+}
diff --git a/src/shaders.js b/src/shaders.js
new file mode 100644
index 00000000..58781a5c
--- /dev/null
+++ b/src/shaders.js
@@ -0,0 +1,156 @@
+export const vertexShader = `#version 300 es
+precision highp float;
+layout(location=0) in vec3 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in mat4 instanceMatrix;
+layout(location=6) in mat3 instanceNormal;
+layout(location=9) in vec3 instanceColor;
+layout(location=10) in vec4 instanceSurface;
+uniform mat4 viewProjection;
+uniform mat4 lightProjection;
+out vec3 worldPosition;
+out vec3 worldNormal;
+out vec3 baseColor;
+out vec4 surface;
+out vec4 shadowPosition;
+void main() {
+ vec4 world = instanceMatrix * vec4(position, 1.0);
+ worldPosition = world.xyz;
+ worldNormal = normalize(instanceNormal * normal);
+ baseColor = instanceColor;
+ surface = instanceSurface;
+ shadowPosition = lightProjection * world;
+ gl_Position = viewProjection * world;
+}`;
+
+export const depthVertexShader = `#version 300 es
+precision highp float;
+layout(location=0) in vec3 position;
+layout(location=2) in mat4 instanceMatrix;
+uniform mat4 lightProjection;
+void main() {
+ gl_Position = lightProjection * instanceMatrix * vec4(position, 1.0);
+}`;
+
+export const depthFragmentShader = `#version 300 es
+precision highp float;
+void main() {}
+`;
+
+export const benchmarkVertexShader = `#version 300 es
+precision highp float;
+layout(location=0) in vec3 position;
+layout(location=2) in mat4 instanceMatrix;
+layout(location=9) in vec3 instanceColor;
+uniform mat4 viewProjection;
+out vec3 color;
+void main() {
+ color = instanceColor;
+ gl_Position = viewProjection * instanceMatrix * vec4(position, 1.0);
+}`;
+
+export const benchmarkFragmentShader = `#version 300 es
+precision highp float;
+in vec3 color;
+out vec4 outputColor;
+void main() { outputColor = vec4(color, 1.0); }
+`;
+
+export const fragmentShader = `#version 300 es
+precision highp float;
+in vec3 worldPosition;
+in vec3 worldNormal;
+in vec3 baseColor;
+in vec4 surface;
+in vec4 shadowPosition;
+uniform vec3 eye;
+uniform vec3 armorColor;
+uniform vec2 armorSurface;
+uniform float exposure;
+uniform float inspection;
+uniform sampler2D shadowMap;
+out vec4 outputColor;
+const float PI = 3.14159265359;
+
+vec3 fresnel(float cosine, vec3 reflectance) {
+ return reflectance + (1.0 - reflectance) * pow(1.0 - cosine, 5.0);
+}
+
+float shadowVisibility(vec3 normal) {
+ vec3 projected = shadowPosition.xyz / shadowPosition.w * 0.5 + 0.5;
+ if (projected.z > 1.0 || projected.z < 0.0 || any(lessThan(projected.xy, vec2(0.0))) || any(greaterThan(projected.xy, vec2(1.0)))) return 1.0;
+ float bias = max(0.0006, 0.002 * (1.0 - dot(normal, normalize(vec3(-3.0, 6.0, 4.0)))));
+ float visibility = 0.0;
+ vec2 texel = 1.0 / vec2(textureSize(shadowMap, 0));
+ for (int row = -1; row <= 1; row++) {
+ for (int column = -1; column <= 1; column++) {
+ float depth = texture(shadowMap, projected.xy + vec2(column, row) * texel * 2.5).r;
+ visibility += projected.z - bias <= depth ? 1.0 : 0.18;
+ }
+ }
+ return visibility / 9.0;
+}
+
+vec3 studio(vec3 direction, float roughness) {
+ vec3 color = mix(vec3(0.025, 0.035, 0.045), vec3(0.22, 0.25, 0.27), smoothstep(-0.3, 0.8, direction.y));
+ float blur = roughness * 0.35;
+ float key = smoothstep(0.80 - blur, 0.87, dot(direction, normalize(vec3(-3.0, 5.0, 4.0))));
+ float rim = smoothstep(0.90 - blur, 0.97, dot(direction, normalize(vec3(4.0, 2.0, -3.0))));
+ float strip = exp(-pow((direction.x + 0.6) / (0.035 + blur), 2.0)) * smoothstep(-0.1, 0.6, direction.y);
+ return color + key * vec3(2.8, 2.2, 1.6) + rim * vec3(0.5, 1.6, 1.5) + strip * vec3(0.7);
+}
+
+vec3 illuminate(vec3 normal, vec3 viewDirection, vec3 lightDirection, vec3 radiance, vec3 color, float metallic, float roughness) {
+ vec3 halfway = normalize(viewDirection + lightDirection);
+ float normalLight = max(dot(normal, lightDirection), 0.0);
+ float normalView = max(dot(normal, viewDirection), 0.001);
+ float normalHalf = max(dot(normal, halfway), 0.0);
+ float alpha = roughness * roughness;
+ float denominator = normalHalf * normalHalf * (alpha * alpha - 1.0) + 1.0;
+ float distribution = alpha * alpha / max(PI * denominator * denominator, 0.00001);
+ float masking = pow(roughness + 1.0, 2.0) / 8.0;
+ float geometry = normalView / (normalView * (1.0 - masking) + masking);
+ geometry *= normalLight / (normalLight * (1.0 - masking) + masking);
+ vec3 reflectance = fresnel(max(dot(halfway, viewDirection), 0.0), mix(vec3(0.04), color, metallic));
+ vec3 specular = distribution * geometry * reflectance / max(4.0 * normalView * normalLight, 0.001);
+ vec3 diffuse = (1.0 - reflectance) * (1.0 - metallic) * color / PI;
+ return (diffuse + specular) * radiance * normalLight;
+}
+
+vec3 toneMap(vec3 color) {
+ return clamp((color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14), 0.0, 1.0);
+}
+
+void main() {
+ vec3 normal = normalize(worldNormal);
+ vec3 viewDirection = normalize(eye - worldPosition);
+ vec3 color = mix(baseColor, armorColor, step(0.5, surface.w) * (1.0 - step(1.5, surface.w)));
+ float metallic = surface.x;
+ float roughness = clamp(surface.y, 0.075, 1.0);
+ if (surface.w > 0.5 && surface.w < 1.5) {
+ metallic = armorSurface.x;
+ roughness = armorSurface.y;
+ }
+ float visibility = shadowVisibility(normal);
+ vec3 radiance = illuminate(normal, viewDirection, normalize(vec3(-3.0, 6.0, 4.0)), vec3(6.5, 5.7, 4.7) * visibility, color, metallic, roughness);
+ radiance += illuminate(normal, viewDirection, normalize(vec3(4.0, 2.0, -3.0)), vec3(1.4, 3.4, 3.2), color, metallic, roughness);
+ radiance += illuminate(normal, viewDirection, normalize(vec3(1.0, 2.0, 5.0)), vec3(0.8, 0.9, 1.1), color, metallic, roughness);
+ vec3 reflectance = fresnel(max(dot(normal, viewDirection), 0.0), mix(vec3(0.04), color, metallic));
+ radiance += studio(reflect(-viewDirection, normal), roughness) * reflectance * (1.0 - roughness * 0.55);
+ radiance += color * (1.0 - metallic) * vec3(0.16, 0.20, 0.22) * (0.45 + 0.55 * max(normal.y, 0.0));
+ radiance += color * surface.z;
+ if (surface.w > 1.5) {
+ 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;
+ float fog = 1.0 - exp(-length(worldPosition.xz) * 0.05);
+ radiance = mix(radiance, vec3(0.018, 0.022, 0.026), fog);
+ }
+ if (inspection > 0.5) radiance = normal * 0.5 + 0.5;
+ outputColor = vec4(pow(toneMap(radiance * exposure), vec3(1.0 / 2.2)), 1.0);
+ if (surface.w > 1.5 && inspection < 0.5) {
+ float distanceFade = exp(-length(worldPosition.xz) * 0.08);
+ float contact = 1.0 - 0.1 * exp(-dot(worldPosition.xz, worldPosition.xz) * 1.4);
+ vec3 floorColor = mix(vec3(0.145, 0.162, 0.177), vec3(0.17, 0.19, 0.205), distanceFade);
+ outputColor = vec4(floorColor * (0.72 + 0.28 * visibility) * contact, 1.0);
+ }
+}`;
diff --git a/src/style.css b/src/style.css
new file mode 100644
index 00000000..eb2b1c93
--- /dev/null
+++ b/src/style.css
@@ -0,0 +1,89 @@
+:root { font-family: 'DM Sans', system-ui, sans-serif; color: #edf0ef; background: #25292d; font-synthesis: none; color-scheme: dark; }
+* { box-sizing: border-box; }
+body { margin: 0; }
+main { width: 100%; height: 100svh; min-height: 600px; position: relative; overflow: hidden; }
+#viewport { display: block; width: 100%; height: 100%; touch-action: none; outline-offset: -5px; cursor: grab; }
+#viewport:active { cursor: grabbing; }
+button, select, a, fieldset, label, footer { user-select: none; }
+button, select { font: inherit; }
+button { color: inherit; background: #ffffff09; padding: 11px 16px; border: 0; border-radius: 8px; cursor: pointer; transition: background 150ms; }
+button:hover { background: #ffffff17; }
+button[aria-pressed=true] { background: #b7eddf19; color: #b7eddf; }
+button:disabled { opacity: 0.6; cursor: wait; }
+:focus-visible { outline: 2px solid #b7eddf; outline-offset: 4px; }
+.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; }
+.toolbar-actions { margin-left: auto; display: flex; gap: 10px; }
+.primary { background: #b7eddf; color: #19312c; font-weight: 600; }
+.primary:hover { background: #cdf7ec; }
+.primary span { margin-left: 14px; }
+.object-info { position: absolute; left: 5%; top: 27%; pointer-events: none; max-width: 340px; }
+h1 { font-weight: 450; font-size: clamp(32px, 3.4vw, 55px); line-height: 1.1; letter-spacing: -2px; margin: 0 0 22px; }
+.object-info p { color: #aab5bc; font-size: 14px; line-height: 1.8; margin: 0; }
+.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; }
+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; }
+.swatch { width: 27px; height: 27px; padding: 0; background: var(--swatch); border-radius: 50%; box-shadow: inset 0 0 0 1px #ffffff35; }
+.swatch:hover { background: var(--swatch); transform: scale(1.08); }
+.swatch.selected { outline: 1px solid #d6e6e0; outline-offset: 4px; }
+.swatch[aria-pressed=true] { background: var(--swatch); }
+#finish-name { color: #93a4ac; }
+.exposure-label { display: flex; justify-content: space-between; }
+output { color: #98aaa9; font-variant-numeric: tabular-nums; }
+input[type=range] { width: 100%; margin: 14px 0 25px; accent-color: #b7eddf; cursor: pointer; }
+.view-actions { display: grid; gap: 8px; }
+.view-actions button { padding: 10px 7px; text-align: left; font-size: 12px; }
+.quality-label { display: grid; gap: 10px; margin-top: 22px; color: #b8c3c6; }
+select { width: 100%; border: 0; background: #ffffff09; border-radius: 6px; padding: 8px; font-size: 12px; color: #d2dcdd; }
+footer { position: absolute; inset: auto 40px 26px; display: flex; align-items: center; gap: 25px; font-size: 12px; color: #a2afb5; }
+.hint { margin: 0; }
+.hint span { padding: 0 10px; }
+.metrics { display: flex; gap: 20px; margin-left: auto; font-variant-numeric: tabular-nums; }
+footer button { font-size: 12px; }
+.notice { position: absolute; left: 50%; bottom: 85px; transform: translateX(-50%); background: #20262b; padding: 14px 20px; border-radius: 9px; max-width: min(90vw, 600px); font-size: 13px; }
+.benchmark-result { position: absolute; left: 40px; bottom: 90px; background: #20262bf5; border-radius: 15px; padding: 24px; max-width: min(520px, calc(100% - 80px)); }
+h2 { font-weight: 500; font-size: 20px; margin: 0 0 15px; }
+#benchmark-summary { white-space: pre-line; line-height: 1.9; font-size: 14px; font-variant-numeric: tabular-nums; }
+.benchmark-note { font-size: 12px; line-height: 1.7; color: #a2afb5; }
+@media (max-width: 1100px) {
+ .object-info { top: 19%; max-width: 250px; }
+ h1 { font-size: 35px; }
+ .object-info p { font-size: 12px; }
+ .metrics { gap: 10px; }
+ .hint { display: none; }
+}
+@media (max-width: 700px) {
+ main { min-height: 700px; }
+ #viewport { position: absolute; top: 220px; height: calc(100% - 465px); }
+ .toolbar { inset: 18px 20px auto; gap: 15px; }
+ .brand { font-size: 27px; }
+ .studio-name { display: none; }
+ .toolbar-actions { gap: 5px; }
+ .toolbar-actions button { padding: 10px 12px; font-size: 12px; }
+ .object-info { top: 94px; 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; }
+ fieldset { margin: 0; grid-row: span 2; }
+ legend { margin-bottom: 12px; }
+ .finishes { margin-bottom: 10px; }
+ .exposure-label { align-self: end; }
+ input[type=range] { margin: 0; }
+ .view-actions { grid-column: span 2; display: flex; gap: 12px; }
+ .quality-label { display: none; }
+ 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; }
+ .benchmark-result { left: 20px; bottom: 85px; max-width: calc(100% - 40px); }
+}
+@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
diff --git a/tests/export.test.js b/tests/export.test.js
new file mode 100644
index 00000000..a10a57ad
--- /dev/null
+++ b/tests/export.test.js
@@ -0,0 +1,18 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { createModel } from '../src/model.js';
+import { exportGlb } from '../src/export.js';
+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+
+test('exported GLB loads with an independent glTF loader and preserves every part', async () => {
+ const parts = createModel();
+ const binary = exportGlb(parts);
+ const header = new DataView(binary);
+ assert.equal(header.getUint32(0, true), 0x46546c67);
+ assert.equal(header.getUint32(8, true), binary.byteLength);
+ const gltf = await new GLTFLoader().parseAsync(binary, '');
+ let meshCount = 0;
+ gltf.scene.traverse((node) => { if (node.isMesh) meshCount++; });
+ assert.equal(meshCount, parts.length);
+ assert.ok(binary.byteLength < 500000);
+});
diff --git a/vite.config.js b/vite.config.js
new file mode 100644
index 00000000..4dbc448a
--- /dev/null
+++ b/vite.config.js
@@ -0,0 +1,11 @@
+import { defineConfig } from 'vite';
+
+const headers = {
+ 'Cross-Origin-Opener-Policy': 'same-origin',
+ 'Cross-Origin-Embedder-Policy': 'require-corp',
+};
+
+export default defineConfig({
+ server: { headers },
+ preview: { headers },
+});