The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.
Rust electron-alternativegame-engineglobal-illuminationgraphicsjavascript-runtimemetalpath-tracingray-tracingreal-time-renderingrenderingrustthreejstypescriptvoxelvulkanwebgpuwgpu
Site: Showcase / Download / Docs, the clients' downloads as the first call to action, the "Three bounces" mark
Yifeng "Evan" Wangea6e47b9700b
diff --git a/.gitignore b/.gitignoreindex ebce899..8302ae5 100644--- a/.gitignore+++ b/.gitignore@@ -11,5 +11,10 @@ target//assetsplayground/vendor/+# The site's generated directories: the client release (a closed-source binary) and the example packages, written by+# the client repository's release script (site/README.md).+/site/releases/+/site/play/+# Claude Code harness state (skills under .claude/skills are committed).claude/*.lockdiff --git a/README.md b/README.mdindex 14603ab..b63471d 100644--- a/README.md+++ b/README.md@@ -29,7 +29,7 @@ Mirror: [`doodlewind/ThreeRT`](https://github.com/doodlewind/ThreeRT).| `playground/` | ThreeRT Playground: a macOS native editor around the live viewport || `compare/` | Hello-world scenes side by side in three.js and ThreeRT || `docs/` | Roadmap, workflow and merge gate, parity, material functions, voxel engine |-| `site/` | The landing page: static, `bun site/serve.ts` (see [`site/README.md`](site/README.md)) |+| `site/` | The site (threert.dev): the landing page, Showcase, Download and Docs; static, `bun site/serve.ts` (see [`site/README.md`](site/README.md)) |## Getting starteddiff --git a/package-lock.json b/package-lock.jsonindex fae3f46..9433834 100644--- a/package-lock.json+++ b/package-lock.json@@ -16,6 +16,7 @@"playwright-core": "^1.65.0","pngjs": "^7.0.0","polygon-clipping": "^0.15.7",+ "qrcode-generator": "^2.0.4","sharp": "^0.35.5","three": "^0.187.0","typescript": "^5.9.3"@@ -1221,6 +1222,13 @@"splaytree": "^3.1.0"}},+ "node_modules/qrcode-generator": {+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-2.0.4.tgz",+ "integrity": "sha512-mZSiP6RnbHl4xL2Ap5HfkjLnmxfKcPWpWe/c+5XxCuetEenqmNFf1FH/ftXPCtFG5/TDobjsjz6sSNL0Sr8Z9g==",+ "dev": true,+ "license": "MIT"+ },"node_modules/robust-predicates": {"version": "3.0.3","resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz",diff --git a/package.json b/package.jsonindex 9d2deff..0f1dd9c 100644--- a/package.json+++ b/package.json@@ -21,6 +21,7 @@"playwright-core": "^1.65.0","pngjs": "^7.0.0","polygon-clipping": "^0.15.7",+ "qrcode-generator": "^2.0.4","sharp": "^0.35.5","three": "^0.187.0","typescript": "^5.9.3"diff --git a/site/README.md b/site/README.mdindex e6eaf38..5b86a79 100644--- a/site/README.md+++ b/site/README.md@@ -1,26 +1,55 @@-# ThreeRT landing page+# ThreeRT site-A static page, no build step. three.js comes from the repo's own devDependency; the images in `media/` are committed.+Static pages, no build step. three.js and the QR encoder come from the repo's own devDependencies; the images in+`media/` are committed.```bash-npm install # once, at the repo root (three, sharp)-bun site/serve.ts # http://localhost:4173/+npm install # once, at the repo root (three, qrcode-generator, sharp)+bun site/serve.ts # http://localhost:4173/ [port] [--lan]bun site/tools/build.ts # a static copy for any file host -> out/site/```+`--lan` listens on every interface and prints the LAN address: open that one on the Mac and a phone on the same+network can scan the QR codes on the pages (they carry `threert://<lan ip>:<port>/play/<id>`).+**Live at https://threert.dev** (www.threert.dev redirects there). Deploy after a change:```bashwrangler login # once, as a member of the Cloudflare account that holds threert.dev-bun site/tools/deploy.ts # build out/site, then wrangler deploy (site/wrangler.jsonc)+bun site/tools/deploy.ts # build out/site (strict, see below), then wrangler deploy (site/wrangler.jsonc)```It is a Cloudflare Worker, `threert-site`: static assets from `out/site` on the custom domains threert.dev and-www.threert.dev; `site/worker.ts` only redirects www to the apex and hands everything else to the assets.+www.threert.dev; `site/worker.ts` redirects www to the apex, serves the clients' disk images from R2 and hands everything else to the assets.+Workers static assets take **25 MiB a file**, and the client's disk image is about 32 MiB (it carries the `threert`+command line). So the image is not a static asset: it lives in the R2 bucket `threert-releases` under its file name,+and `worker.ts` serves it at the URL the Download page links, `/releases/<file>` (ranges, `ETag`, `HEAD`). R2 rather+than a GitHub release because the client is closed source and has no public repository to carry one. Once:++```bash+bunx wrangler@4 r2 bucket create threert-releases+```++`deploy.ts` uploads the image `releases/latest.json` names, then deploys. `build.ts` leaves the image out of+`out/site` (`--with-image` copies it, for a plain file host). Locally, `serve.ts` serves it from `site/releases/`.+To check the Worker itself without an account: `bunx wrangler@4 r2 object put threert-releases/<file> --file+site/releases/<file> --local --config site/wrangler.jsonc`, then `bunx wrangler@4 dev --config site/wrangler.jsonc`.-## What is on it+## Pages-1. **Hero:** Bistro night, three.js | ThreeRT under one draggable divider. "Every light, traced. At 60 fps."+Every page has the same nav, top right: **Showcase / Download / Docs / GitHub** (github.com/taichi-dev/ThreeRT), and+the same footer links. The markup is repeated in each page; change it in all four.++| Page | What is on it |+|---|---|+| `index.html` | The landing page (below). Its two buttons, in the hero and at the end: **Download** (to `download/`, named for the visitor's platform by `js/site.js`) and **GitHub**. |+| `showcase/` | Bistro night and Zero-Day as camera moves (the committed media), then **Open on your device**: a card for each example package in `play/` with an "Open in ThreeRT" link, the same game as three.js, and a QR code for the iPhone app. |+| `download/` | ThreeRT for macOS (the build `releases/latest.json` names) and ThreeRT for iPhone (a TestFlight or App Store link once `ios.url` is set), then how a client loads a game: `threert dev`, scan, traced and live. |+| `docs/` | Getting started: install the client, open an example, write a scene, the dev loop with the `threert` CLI, the package format, links to the reference documents in `docs/` on GitHub. |++### The landing page++1. **Hero:** Bistro night, three.js | ThreeRT under one draggable divider. "Path tracing at 60 fps."2. **ThreeRT = Three + RT:** Ray Tracing, Real Time, Runtime.3. **Hello world looks right:** an auto-advancing reel of three starter scenes, the ThreeRT source next to its output(three.js as written | ThreeRT with every setting at its default).@@ -32,18 +61,63 @@ www.threert.dev; `site/worker.ts` only redirects www to the apex and hands everyas three.js in any browser or WebView, drawn as live three.js device models at real proportions.8. **Just light.**+## The two generated directories++`site/releases/` and `site/play/` are not committed (.gitignore): the first holds a build of the closed-source+client, the second packages built with it. The client repository's release script writes both, whole. Without them+the pages still work: Download says that no build is published on this host, Showcase that there are no packages.+`serve.ts` and `build.ts` warn; `build.ts --require-release` (what `deploy.ts` runs) stops instead, so a deploy never+puts up a Download button with nothing behind it.++`releases/latest.json`, next to the file it names:++```jsonc+{+ "version": "0.1.0", "date": "2026-11-11",+ "macos": { "file": "ThreeRT-0.1.0-macos-arm64.dmg", "size": 33981234, "sha256": "…", "minOS": "14.0", "arch": "arm64",+ "url": null, // null: `releases/<file>` on this host (R2 behind the Worker; site/releases/ locally);+ // or the https URL of the image when it is hosted elsewhere (`release.ts --macos-url`)+ "signed": "adhoc", // or "developer-id"+ "notarized": false }, // unless signed with a Developer ID and notarized, the page explains the first launch+ "ios": { "url": null, // the TestFlight / App Store link; null: "TestFlight beta not open yet"+ "channel": "testflight", // or "appstore"+ "minOS": "17.0" }+}+```++`play/index.json`, next to a thumbnail and a package directory for each game:++```jsonc+{+ "client": "0.1.0",+ "games": [{ "id": "light-room", "title": "Light Room", "caption": "…", "kind": "game" /* or "scene" */, "thumb": "light-room.jpg" }]+}+```++`play/<id>/` is a ThreeRT package (the client repository's docs/CLIENT.md § 1): `threert.json` (format `threert/1`),+`game.js`, `game.mjs`, the same game as three.js (`index.html`, `web.js`), `presets/`, `assets/`. The pages derive the+links from where they are served (`js/site.js` `packageLinks`):++| | over https | over http (a dev machine) |+|---|---|---|+| Open in ThreeRT | `threerts://<host>/play/<id>` | `threert://<host>:<port>/play/<id>` |+| three.js in the browser | `https://<host>/play/<id>/` | `http://<host>:<port>/play/<id>/` |+| QR code | the plain `https://` URL: the phone's camera opens the three.js page, the app's scanner opens the package | the `threert://` link, which the camera hands to the app |+## Files| Path | What ||---|---|-| `index.html` | The page (sections, their styles and their script) |-| `css/threert.css` | The visual system: ink, bone and tungsten tokens, type, the comparison and player components |+| `index.html`, `showcase/`, `download/`, `docs/` | The pages (sections, their styles and their script) |+| `css/threert.css` | The visual system: ink, bone and tungsten tokens, type, the nav and footer, the comparison and player components, the cards, steps and QR tiles of the inner pages || `js/threert.js` | The wipe comparison, the synced camera-move player, the code highlighter |+| `js/site.js` | What the pages share: the visitor's platform, the release and the packages on this host, their links, QR codes || `js/devices.js` | The 3D device rows (three.js), with a still fallback when WebGL is off |-| `brand/` | The mark ("Orbit": a triangle and the one closed light path that bounces inside it) and its variants |+| `brand/` | The mark ("Three bounces": the three.js triangle, tilted as three.js draws it, and the closed light path inside it, which is three.js's own inner triangle) and its variants. `js/mark.js` draws it live in the lockup and on the landing page, and turns the path on hover || `media/` | The renders, WebP. Generated; never retouched |-| `serve.ts`, `tools/` | Local server, static build, deploy, media and device-still generators |-| `worker.ts`, `wrangler.jsonc` | The Cloudflare Worker and its config (threert.dev) |+| `serve.ts`, `tools/` | Local server, static build, deploy, media and device-still generators; `tools/vendor.ts` names the npm files the pages import (three.js, qrcode-generator) |+| `worker.ts`, `wrangler.jsonc` | The Cloudflare Worker (www redirect, disk images from R2, static assets) and its config (threert.dev) |+| `releases/`, `play/` | Generated, not committed (above) |## Mediadiff --git a/site/brand/app-icon.svg b/site/brand/app-icon.svgindex ec90944..4761407 100644--- a/site/brand/app-icon.svg+++ b/site/brand/app-icon.svg@@ -1,14 +1,14 @@<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="ThreeRT"><defs><radialGradient id="bg" cx="50%" cy="58%" r="70%"><stop offset="0" stop-color="#2A1A0E"/><stop offset=".55" stop-color="#0E0F13"/><stop offset="1" stop-color="#07080A"/></radialGradient>- <linearGradient id="ray" x1="10" y1="56" x2="54" y2="20" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient>- <filter id="glow" x="-25%" y="-25%" width="150%" height="150%"><feGaussianBlur stdDeviation="1.6"/></filter>+ <linearGradient id="ray" x1="11.59" y1="32" x2="32" y2="12.36" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient>+ <filter id="glow" x="-25%" y="-25%" width="150%" height="150%"><feGaussianBlur stdDeviation="1.8"/></filter></defs><rect width="512" height="512" rx="114" fill="url(#bg)"/><rect x="1.5" y="1.5" width="509" height="509" rx="112.5" fill="none" stroke="#fff" stroke-opacity=".08" stroke-width="3"/>- <g transform="translate(96 88) scale(5)">- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="#FF9A3A" stroke-width="5" stroke-linejoin="round" opacity=".5" filter="url(#glow)"/>- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="#ECE8E1" stroke-width="2.6" stroke-linejoin="round"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="url(#ray)" stroke-width="2.3" stroke-linejoin="round"/>+ <g transform="translate(96 96) scale(5)">+ <path d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="none" stroke="#FFAD4E" stroke-width="6" stroke-linejoin="round" opacity=".5" filter="url(#glow)"/>+ <path d="M18.39 59.5 L4.78 4.5 L59.22 20.21 Z" fill="none" stroke="#ECE8E1" stroke-width="3" stroke-linejoin="round"/>+ <path d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="url(#ray)" fill-opacity=".16" stroke="url(#ray)" stroke-width="3" stroke-linejoin="round"/></g></svg>diff --git a/site/brand/favicon.svg b/site/brand/favicon.svgindex 3d768ea..1e5cd63 100644--- a/site/brand/favicon.svg+++ b/site/brand/favicon.svg@@ -1,6 +1,6 @@<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="ThreeRT">- <!-- 16-32 px: heavier strokes, no glow. -->- <defs><linearGradient id="ray" x1="10" y1="56" x2="54" y2="20" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient></defs>- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="#ECE8E1" stroke-width="5.5" stroke-linejoin="round"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="url(#ray)" stroke-width="4.6" stroke-linejoin="round"/>+ <!-- 16-32 px: heavier strokes, the path filled, no glow. -->+ <defs><linearGradient id="ray" x1="12.33" y1="32" x2="32" y2="13.07" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient></defs>+ <path d="M18.89 58.5 L5.77 5.5 L58.23 20.64 Z" fill="none" stroke="#ECE8E1" stroke-width="5.2" stroke-linejoin="round"/>+ <path d="M12.33 32 L32 13.07 L38.56 39.57 Z" fill="url(#ray)" stroke="url(#ray)" stroke-width="4.4" stroke-linejoin="round"/></svg>diff --git a/site/brand/mark-light.svg b/site/brand/mark-light.svgindex 393626f..f59021d 100644--- a/site/brand/mark-light.svg+++ b/site/brand/mark-light.svg@@ -1,5 +1,6 @@<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="ThreeRT">- <defs><linearGradient id="ray" x1="10" y1="56" x2="54" y2="20" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#C2410C"/><stop offset=".55" stop-color="#EA7A0C"/><stop offset="1" stop-color="#F5A524"/></linearGradient></defs>- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="#111215" stroke-width="3" stroke-linejoin="round"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="url(#ray)" stroke-width="2.8" stroke-linejoin="round"/>+ <!-- On a light page: ink for the mesh, deeper stops for the light, no glow. -->+ <defs><linearGradient id="ray" x1="11.59" y1="32" x2="32" y2="12.36" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#C2410C"/><stop offset=".5" stop-color="#EA7A0C"/><stop offset="1" stop-color="#F5A524"/></linearGradient></defs>+ <path d="M18.39 59.5 L4.78 4.5 L59.22 20.21 Z" fill="none" stroke="#111215" stroke-width="3.2" stroke-linejoin="round"/>+ <path d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="url(#ray)" fill-opacity=".16" stroke="url(#ray)" stroke-width="3.2" stroke-linejoin="round"/></svg>diff --git a/site/brand/mark-mono.svg b/site/brand/mark-mono.svgindex 2f36986..420f3fe 100644--- a/site/brand/mark-mono.svg+++ b/site/brand/mark-mono.svg@@ -1,4 +1,4 @@<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="ThreeRT">- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="currentColor" stroke-width="3" stroke-linejoin="round"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linejoin="round" opacity=".72"/>+ <path d="M18.39 59.5 L4.78 4.5 L59.22 20.21 Z" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round"/>+ <path d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" opacity=".72"/></svg>diff --git a/site/brand/mark-small.svg b/site/brand/mark-small.svgindex 3d768ea..1e5cd63 100644--- a/site/brand/mark-small.svg+++ b/site/brand/mark-small.svg@@ -1,6 +1,6 @@<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="ThreeRT">- <!-- 16-32 px: heavier strokes, no glow. -->- <defs><linearGradient id="ray" x1="10" y1="56" x2="54" y2="20" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient></defs>- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="#ECE8E1" stroke-width="5.5" stroke-linejoin="round"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="url(#ray)" stroke-width="4.6" stroke-linejoin="round"/>+ <!-- 16-32 px: heavier strokes, the path filled, no glow. -->+ <defs><linearGradient id="ray" x1="12.33" y1="32" x2="32" y2="13.07" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient></defs>+ <path d="M18.89 58.5 L5.77 5.5 L58.23 20.64 Z" fill="none" stroke="#ECE8E1" stroke-width="5.2" stroke-linejoin="round"/>+ <path d="M12.33 32 L32 13.07 L38.56 39.57 Z" fill="url(#ray)" stroke="url(#ray)" stroke-width="4.4" stroke-linejoin="round"/></svg>diff --git a/site/brand/mark.svg b/site/brand/mark.svgindex af82f1a..04eaf79 100644--- a/site/brand/mark.svg+++ b/site/brand/mark.svg@@ -1,8 +1,10 @@<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="ThreeRT">- <!-- ThreeRT "Orbit": a triangle (three.js's primitive) and the one closed light path that bounces inside it.- The path is a period-6 billiard orbit (angle in = angle out at every edge) and draws the triangle's 3x3 grid. -->- <defs><linearGradient id="ray" x1="10" y1="56" x2="54" y2="20" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient><filter id="glow" x="-25%" y="-25%" width="150%" height="150%"><feGaussianBlur stdDeviation="1.5"/></filter></defs>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="#FF9A3A" stroke-width="5" stroke-linejoin="round" opacity=".45" filter="url(#glow)"/>- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="#ECE8E1" stroke-width="3" stroke-linejoin="round"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="url(#ray)" stroke-width="2.6" stroke-linejoin="round"/>+ <!-- ThreeRT "Three bounces": the three.js triangle (equilateral, tilted 16 degrees as three.js draws it) and the closed+ light path inside it. The path is three.js's own inner triangle, which is also the shortest billiard orbit a+ triangle has: three bounces, each leaving its edge at the angle it arrived. The mesh is bone; the path is lit.+ js/mark.js draws the same thing live (the lockup and the landing page's large mark) and spins it on hover. -->+ <defs><linearGradient id="ray" x1="11.59" y1="32" x2="32" y2="12.36" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient><filter id="glow" x="-25%" y="-25%" width="150%" height="150%"><feGaussianBlur stdDeviation="1.8"/></filter></defs>+ <path d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="none" stroke="#FFAD4E" stroke-width="6" stroke-linejoin="round" opacity=".5" filter="url(#glow)"/>+ <path d="M18.39 59.5 L4.78 4.5 L59.22 20.21 Z" fill="none" stroke="#ECE8E1" stroke-width="3.2" stroke-linejoin="round"/>+ <path d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="url(#ray)" fill-opacity=".16" stroke="url(#ray)" stroke-width="3.2" stroke-linejoin="round"/></svg>diff --git a/site/css/threert.css b/site/css/threert.cssindex 0af3bb9..3c1b313 100644--- a/site/css/threert.css+++ b/site/css/threert.css@@ -20,6 +20,10 @@--tungsten: #ffb454;--filament: #ffebc4;--ray: linear-gradient(100deg, var(--ember) 0%, var(--tungsten) 52%, var(--filament) 100%);+ /* The light where it pools on a surface (a lit card), and in code. */+ --halo: rgba(255, 140, 50, 0.13);+ --code-k: #ff9e64;+ --code-n: #ffd08a;/* three.js is neutral in comparisons (never red: it is the baseline, not the enemy). */--c-three: #8b919b;@@ -62,16 +66,21 @@ p { margin: 0; }/* ---------- Brand lockup ---------- */.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 20px; letter-spacing: -0.035em; }-.logo img { width: 28px; height: 28px; }+.logo img, .logo svg.mark { width: 28px; height: 28px; }+.logo svg.mark { display: block; overflow: visible; }.logo .rt { background: var(--ray); -webkit-background-clip: text; background-clip: text; color: transparent; }-/* ---------- Nav ---------- */+/* ---------- Nav: Showcase / Download / Docs / GitHub, the same on every page ---------- */.nav { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); background: color-mix(in srgb, var(--ink-0) 72%, transparent); border-bottom: 1px solid var(--line); }.nav .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }-.nav .links { display: flex; gap: 24px; margin-left: auto; font-size: 14px; color: var(--bone-2); }-.nav .links a { text-decoration: none; }+.nav .links { display: flex; align-items: center; gap: 28px; margin-left: auto; font-size: 14.5px; font-weight: 500; color: var(--bone-2); }+.nav .links a { text-decoration: none; display: inline-flex; align-items: center; gap: 5px; padding: 6px 0; border-bottom: 1.5px solid transparent; transition: color 0.2s; }.nav .links a:hover { color: var(--bone); }+.nav .links a[aria-current="page"] { color: var(--bone); border-bottom-color: var(--bone-2); }+.nav .links a svg { opacity: 0.6; }.nav.overlay { position: absolute; left: 0; right: 0; background: transparent; border-bottom-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }+a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--tungsten); outline-offset: 3px; border-radius: 4px; }+.btn:focus-visible { border-radius: 999px; }/* ---------- Buttons ---------- */.btn { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 20px; border-radius: 999px; font: 500 15px/1 var(--font-sans); text-decoration: none; border: 1px solid transparent; cursor: pointer; transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s; }@@ -79,6 +88,12 @@ p { margin: 0; }.btn.primary { background: var(--bone); color: var(--ink-0); }.btn.ghost { border-color: var(--line-2); color: var(--bone); background: transparent; }.btn.ghost:hover { border-color: var(--bone-2); }+.btn svg { flex: none; }+.btn.sm { height: 38px; padding: 0 16px; font-size: 14px; gap: 8px; }+.btn.off { border-color: var(--line); color: var(--mute); background: transparent; cursor: default; }+.btn.off:hover { transform: none; }+/* Under a row of buttons: what they are for (platforms, requirements). */+.plat { font: 400 12.5px/1.5 var(--font-mono); color: var(--mute); }/* ---------- Wipe comparison ---------- */.cmp { position: relative; overflow: hidden; border-radius: var(--r-2); background: #000; aspect-ratio: 16 / 9; user-select: none; -webkit-user-select: none; touch-action: pan-y; cursor: ew-resize; isolation: isolate; }@@ -86,13 +101,13 @@ p { margin: 0; }.cmp .pb { clip-path: inset(0 0 0 var(--x, 50%)); }.cmp img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }.cmp.zoom img { transform: scale(var(--z, 2)); transform-origin: var(--o, 50% 50%); }-.cmp .bar, .seqp .bar { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); width: 2px; margin-left: -1px; background: var(--filament); box-shadow: 0 0 18px 2px rgba(255, 180, 84, 0.65); z-index: 3; pointer-events: none; }-.cmp .knob { position: absolute; top: 50%; left: var(--x, 50%); width: 42px; height: 42px; margin: -21px 0 0 -21px; border-radius: 50%; background: rgba(10, 11, 14, 0.66); border: 1.5px solid #ffebc4; z-index: 4; display: grid; place-items: center; color: #ffebc4; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; }+.cmp .bar, .seqp .bar { position: absolute; top: 0; bottom: 0; left: var(--x, 50%); width: 2px; margin-left: -1px; background: var(--filament); box-shadow: 0 0 18px 2px color-mix(in srgb, var(--tungsten) 65%, transparent); z-index: 3; pointer-events: none; }+.cmp .knob { position: absolute; top: 50%; left: var(--x, 50%); width: 42px; height: 42px; margin: -21px 0 0 -21px; border-radius: 50%; background: rgba(10, 11, 14, 0.66); border: 1.5px solid var(--filament); z-index: 4; display: grid; place-items: center; color: var(--filament); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; }.lab { position: absolute; top: 14px; z-index: 5; display: inline-flex; align-items: flex-start; gap: 8px; padding: 7px 11px; border-radius: 8px; background: rgba(8, 9, 11, 0.66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font: 500 12px/1.25 var(--font-mono); color: #ece8e1; pointer-events: none; white-space: nowrap; }.lab.a { left: 14px; }.lab.b { right: 14px; text-align: right; flex-direction: row-reverse; }.lab i { flex: none; width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: #8b919b; }-.lab.b i { background: #ffb454; box-shadow: 0 0 8px #ffb454; }+.lab.b i { background: var(--tungsten); box-shadow: 0 0 8px var(--tungsten); }.lab small { display: block; opacity: 0.66; font-size: 11px; margin-top: 3px; }.cmp:focus-visible { outline: 2px solid var(--tungsten); outline-offset: 3px; }@@ -106,22 +121,59 @@ p { margin: 0; }.seqp .ctl { position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 6; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; background: rgba(8, 9, 11, 0.62); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font: 500 12px/1 var(--font-mono); color: #ece8e1; cursor: default; }.seqp .ctl button { appearance: none; border: 0; background: none; color: inherit; cursor: pointer; padding: 0; width: 18px; height: 18px; display: grid; place-items: center; }.seqp .ctl .track { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); position: relative; cursor: pointer; }-.seqp .ctl .track b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: #ffb454; }+.seqp .ctl .track b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--tungsten); }.seqp .loading { position: absolute; inset: 0; display: grid; place-items: center; font: 500 12px var(--font-mono); color: #80858e; z-index: 7; }/* ---------- Code ---------- */.code { font: 400 13.5px/1.7 var(--font-mono); color: #c9c4bb; background: #0a0b0e; border: 1px solid var(--line); border-radius: var(--r-2); padding: 20px 22px; overflow: auto; white-space: pre; tab-size: 2; }-.code .k { color: #ff9e64; }+.code .k { color: var(--code-k); }.code .s { color: #b5d77b; }-.code .n { color: #ffd08a; }+.code .n { color: var(--code-n); }.code .c { color: #5f646d; font-style: italic; }.code .f { color: #8fc1ff; }-.code .hl { background: rgba(255, 180, 84, 0.1); box-shadow: -22px 0 0 rgba(255, 180, 84, 0.1), 22px 0 0 rgba(255, 180, 84, 0.1); display: inline-block; width: 100%; }+.code .hl { background: color-mix(in srgb, var(--tungsten) 10%, transparent); box-shadow: -22px 0 0 color-mix(in srgb, var(--tungsten) 10%, transparent), 22px 0 0 color-mix(in srgb, var(--tungsten) 10%, transparent); display: inline-block; width: 100%; }/* ---------- Footer ---------- */.foot { border-top: 1px solid var(--line); padding: 48px 0 64px; font-size: 13px; color: var(--mute); line-height: 1.6; }.foot a { color: var(--bone-2); }.foot .cols { display: grid; grid-template-columns: 1.2fr 2fr; gap: 48px; }+.foot .site { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 18px; font-size: 14px; }+.foot .site a { text-decoration: none; }+.foot .site a:hover { color: var(--bone); }+.foot .note { font: 400 12px/1.6 var(--font-mono); color: var(--mute); }+.foot .note p + p { margin-top: 12px; }++/* ---------- Pages under the landing page (Showcase, Download, Docs) ---------- */+.page-head { padding: 88px 0 56px; }+.page-head .wrap { display: grid; gap: 22px; }+.eyebrow { font: 500 12.5px/1 var(--font-mono); color: var(--mute); letter-spacing: 0.02em; }+.sec { padding: 0 0 112px; }+.sec-top { display: grid; gap: 14px; margin-bottom: 36px; }+.h-2 { font-size: clamp(30px, 3.4vw, 46px); letter-spacing: -0.04em; line-height: 1.04; }+.card { border: 1px solid var(--line); border-radius: 22px; background: var(--ink-1); padding: 30px; min-width: 0; }+.card.lit { border-color: color-mix(in srgb, var(--tungsten) 45%, transparent); background: radial-gradient(70% 90% at 70% 0%, var(--halo), transparent 70%), var(--ink-1); }+.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }+.ticks li { position: relative; padding-left: 24px; color: var(--bone-2); font-size: 14.5px; line-height: 1.6; }+.ticks li::before { content: ""; position: absolute; left: 0; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--c-three); }+.card.lit .ticks li::before { background: var(--tungsten); box-shadow: 0 0 8px var(--tungsten); }+.kv { display: flex; flex-wrap: wrap; gap: 6px 20px; font: 400 12.5px/1.5 var(--font-mono); color: var(--mute); }+.kv b { color: var(--bone-2); font-weight: 500; }+.fine { font-size: 13.5px; line-height: 1.55; color: var(--mute); }+.fine a { color: var(--bone-2); }+code, kbd { font: 500 0.9em var(--font-mono); color: var(--bone); background: rgba(236, 232, 225, 0.07); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }+.code code { font: inherit; color: inherit; background: none; border: 0; padding: 0; white-space: inherit; }+/* A QR code: dark modules on a bone tile, so a phone reads it on the dark page. */+.qr { flex: none; width: 112px; height: 112px; padding: 7px; border-radius: 12px; background: var(--bone); display: grid; place-items: center; }+.qr svg { display: block; width: 100%; height: 100%; }+.qr.lg { width: 168px; height: 168px; padding: 10px; border-radius: 16px; }+.qr:empty { background: var(--ink-3); }+/* Numbered steps, three across. */+.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); counter-reset: step; }+.steps > li { counter-increment: step; padding: 26px 32px 0 0; border-top: 1px solid var(--line-2); min-width: 0; }+.steps > li + li { padding-left: 32px; border-left: 1px solid var(--line); }+.steps > li::before { content: "0" counter(step); display: block; font: 500 12.5px/1 var(--font-mono); color: var(--tungsten); margin-bottom: 16px; }+.steps h3 { font: 600 24px/1.1 var(--font-sans); letter-spacing: -0.03em; }+.steps p { margin-top: 12px; color: var(--bone-2); font-size: 15.5px; max-width: 40ch; }/* ---------- Reveal on scroll ---------- */.rv { opacity: 0; transform: translateY(18px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }@@ -130,7 +182,20 @@ p { margin: 0; }@media (max-width: 860px) {.wrap { padding: 0 20px; }- .nav .links { display: none; }+ .nav .wrap { gap: 16px; }+ .nav .links { gap: 20px; }.bars .row { grid-template-columns: 110px 1fr 48px; }.foot .cols { grid-template-columns: 1fr; }+ .page-head { padding: 56px 0 40px; }+ .sec { padding-bottom: 80px; }+ .steps { grid-template-columns: 1fr; }+ .steps > li { padding-right: 0; padding-bottom: 28px; }+ .steps > li + li { padding-left: 0; border-left: 0; }+ .card { padding: 22px; }+}+/* A phone: the mark alone stands for the lockup, so the four links fit on one line. */+@media (max-width: 520px) {+ .nav .logo > span { display: none; }+ .nav .links { gap: 16px; font-size: 14px; }+ .nav .links a svg { display: none; }}diff --git a/site/docs/index.html b/site/docs/index.htmlnew file mode 100644index 0000000..fa1e726--- /dev/null+++ b/site/docs/index.html@@ -0,0 +1,240 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>ThreeRT Docs — getting started</title>+<meta name="description" content="Install the ThreeRT client, open an example, write a scene with a three.js-style API, run it on a Mac and an iPhone with threert dev, and publish it as a package.">+<link rel="icon" href="../brand/favicon.svg" type="image/svg+xml">+<link rel="stylesheet" href="../css/threert.css">+<style>+ .doc { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 64px; align-items: start; padding-bottom: 112px; }+ .toc { position: sticky; top: 96px; display: grid; gap: 2px; font-size: 14px; }+ .toc a { text-decoration: none; color: var(--mute); padding: 6px 0 6px 14px; border-left: 1.5px solid var(--line); }+ .toc a:hover { color: var(--bone); border-left-color: var(--bone-2); }+ .toc .ext { margin-top: 14px; padding-left: 0; border-left: 0; color: var(--bone-2); }+ .prose { max-width: 820px; min-width: 0; }+ .prose section { padding: 0 0 64px; scroll-margin-top: 88px; }+ .prose section + section { padding-top: 56px; border-top: 1px solid var(--line); }+ .prose .num { display: block; font: 500 12.5px/1 var(--font-mono); color: var(--tungsten); margin-bottom: 14px; }+ .prose h2 { font: 620 clamp(28px, 3vw, 38px)/1.08 var(--font-sans); letter-spacing: -0.04em; }+ .prose h3 { font: 600 18px/1.3 var(--font-sans); letter-spacing: -0.015em; margin-top: 30px; }+ .prose p { margin-top: 16px; color: var(--bone-2); font-size: 16px; line-height: 1.62; max-width: 70ch; }+ .prose p a, .prose li a, .prose td a { color: var(--bone); }+ .prose ul { margin: 16px 0 0; padding-left: 20px; color: var(--bone-2); display: grid; gap: 8px; max-width: 70ch; }+ .prose .code { margin-top: 20px; font-size: 12.5px; line-height: 1.7; max-height: 460px; }+ .prose .code.sh { color: var(--bone); }+ .prose .code.sh .c { font-style: normal; }+ .prose .acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }+ .tbl { width: 100%; margin-top: 20px; border-collapse: collapse; font-size: 14.5px; }+ .tbl th { text-align: left; font: 500 12px/1 var(--font-mono); color: var(--mute); padding: 0 16px 10px 0; border-bottom: 1px solid var(--line-2); }+ .tbl td { padding: 11px 16px 11px 0; border-bottom: 1px solid var(--line); color: var(--bone-2); vertical-align: top; line-height: 1.5; }+ .tbl td:first-child { white-space: nowrap; color: var(--bone); }+ .tbl-wrap { overflow-x: auto; }+ .callout { margin-top: 22px; padding: 16px 18px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--ink-1); font-size: 14.5px; line-height: 1.55; color: var(--bone-2); max-width: 70ch; }+ .refs { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }+ .refs a { display: block; text-decoration: none; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink-1); transition: border-color 0.2s; }+ .refs a:hover { border-color: var(--line-2); }+ .refs b { display: block; font: 600 15px/1.3 var(--font-sans); color: var(--bone); }+ .refs span { display: block; margin-top: 5px; font-size: 13.5px; line-height: 1.5; color: var(--mute); }+ /* A phone: each table row is a block, the command above what it does. */+ @media (max-width: 700px) {+ .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; }+ .tbl thead { display: none; }+ .tbl tr { padding: 12px 0; border-bottom: 1px solid var(--line); }+ .tbl td { padding: 0; border: 0; }+ .tbl td:first-child { white-space: normal; line-height: 1.9; }+ .tbl td + td { margin-top: 6px; }+ }+ @media (max-width: 960px) { .doc { grid-template-columns: 1fr; gap: 28px; } .toc { position: static; display: flex; flex-wrap: wrap; gap: 6px 18px; } .toc a { padding: 2px 0; border-left: 0; } .toc .ext { margin-top: 0; } .refs { grid-template-columns: 1fr; } }+</style>+</head>+<body>++<nav class="nav" aria-label="Site">+ <div class="wrap">+ <a class="logo" href="../" aria-label="ThreeRT home"><img src="../brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <div class="links"><a href="../showcase/">Showcase</a><a href="../download/">Download</a><a href="../docs/" aria-current="page">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub<svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 1h6v6M9 1 1 9"/></svg></a></div>+ </div>+</nav>++<header class="page-head">+ <div class="wrap">+ <span class="eyebrow">Docs · Getting started</span>+ <h1 class="h-1">Write three.js-style code.<br><span class="mute">Get it traced.</span></h1>+ <p class="lede">A ThreeRT game is a TypeScript file. The client runs it and path-traces the scene it builds; the same file runs as three.js in a browser. This page takes you from the client to a game on your phone.</p>+ </div>+</header>++<div class="wrap doc">+ <nav class="toc" aria-label="On this page">+ <a href="#install">1 · Install the client</a>+ <a href="#open">2 · Open an example</a>+ <a href="#scene">3 · Write a scene</a>+ <a href="#dev">4 · The dev loop</a>+ <a href="#package">5 · Packages</a>+ <a href="#reference">6 · Reference</a>+ <a class="ext" href="https://github.com/taichi-dev/ThreeRT/tree/main/docs" rel="noopener">All docs on GitHub ↗</a>+ </nav>++ <main class="prose">+ <section id="install">+ <span class="num">01</span>+ <h2>Install the client</h2>+ <p>The client is the runtime: it fetches a game’s code, runs it and traces it on the device’s own GPU. There is one for macOS (macOS 14 or later, Apple silicon) and one for iPhone and iPad (iOS 17 or later). The macOS one also carries the <code>threert</code> command line you develop with (<a href="#dev">step 4</a>).</p>+ <div class="acts"><a class="btn primary sm" href="../download/" data-dl><span>Download</span></a></div>+ </section>++ <section id="open">+ <span class="num">02</span>+ <h2>Open an example</h2>+ <p>ThreeRT for macOS opens on its library: the dev servers running on your machine, the games you opened recently and a set of examples. The <a href="../showcase/#open">Showcase</a> hosts the same examples as packages: <b>Open in ThreeRT</b> hands the link to the client, and a phone scans the code next to it.</p>+ <p>A client opens three kinds of link: <code>threert://host:port/path</code> (plain HTTP, what a dev server on your network uses), <code>threerts://host/path</code> (HTTPS) and an ordinary <code>https://</code> URL of a package.</p>+ <p>In a game: drag to orbit, right-drag and <kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> to fly, scroll or pinch to zoom, click to play. On a phone, one finger orbits, two pan and a tap plays.</p>+ </section>++ <section id="scene">+ <span class="num">03</span>+ <h2>Write a scene</h2>+ <p>A scene is a module whose default export builds a <code>Scene</code> and a camera with <code>@threert/scene</code>, a three.js-style API: meshes, geometries, <code>MeshStandardMaterial</code>, lights, glTF models. Leave the settings alone. The sky, the shadows, the bounce light and the reflections come from tracing the scene, not from options.</p>+ <pre class="code" id="sceneCode" aria-label="material-grid.ts">Loading material-grid.ts…</pre>+ <p>This is the first slide of the <a href="../#hello">hello world on the front page</a>, where it runs next to the same code in three.js. Light is in physical units: the sun above is 80,000 lux, and an emissive surface is a light source.</p>++ <h3>From a scene to a game</h3>+ <p><code>@threert/gameplay</code> adds state and input. <code>defineGame</code> takes the initial state, a <code>setup</code> that builds the scene, handlers that change the state, and a <code>frame</code> script that shows the state in the scene every frame.</p>+ <pre class="code" id="gameCode" aria-label="A game">import { Mesh, MeshStandardMaterial } from "@threert/scene";+import { defineGame } from "@threert/gameplay";++export default defineGame({+ state: { lit: {}, night: false },++ setup() {+ // build the scene as above; give the objects you will change an id+ // orb.id = "orb_0";+ return { scene, camera };+ },++ // Handlers change the state, and only the state.+ handlers: {+ click(tx, ev) {+ tx.decide(ev.target.startsWith("orb_"), `nothing happens when you click ${ev.target}`);+ tx.state.lit[ev.target] = !tx.state.lit[ev.target];+ },+ night(tx) {+ tx.state.night = !tx.state.night;+ },+ },+ keys: { L: "night" },++ // The frame script derives the scene from the state, every frame.+ frame(f) {+ const orb = f.object("orb_0");+ orb.material.emissiveIntensity = f.state.lit.orb_0 ? 2500 : 0;+ orb.position.y = 1 + 0.08 * Math.sin(f.time * 2);+ },+});</pre>+ <p>A click reaches the game as a <code>click</code> event with the object under the cursor as its <code>target</code>; <code>keys</code> maps a key to a handler. Handlers are transactions: <code>tx.decide</code> refuses one, and nothing is half-written. What needs the engine’s own world (physics, a ray cast into the scene) goes in world handlers, described in <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/RUNTIME.md" rel="noopener">RUNTIME.md</a>.</p>+ </section>++ <section id="dev">+ <span class="num">04</span>+ <h2>The dev loop</h2>+ <p>The <code>threert</code> command line creates a project, serves it to every client on your network and reloads them on each save. It ships inside ThreeRT for macOS, with everything it needs: open the app and press <b>Install threert</b> under <b>Develop</b> in its library. That links the command into <code>/usr/local/bin</code> (macOS asks for your password), or into <code>~/.local/bin</code> when that is already on your PATH.</p>+ <pre class="code sh" aria-label="Terminal"><span class="c">$</span> threert create my-game+<span class="c">$</span> cd my-game+<span class="c">$</span> threert dev <span class="c"># bundles on save, serves the package, prints a QR code</span></pre>+ <ul>+ <li><b style="color:var(--bone)">On the Mac</b>, ThreeRT for macOS opens the game as the server starts.</li>+ <li><b style="color:var(--bone)">On an iPhone</b>, scan the QR code with the ThreeRT app (or the camera): it carries <code>threert://</code> and your machine’s address.</li>+ <li><b style="color:var(--bone)">In any browser</b>, the server’s address shows the same game as three.js.</li>+ </ul>+ <p>Save the file and every client reloads. A build error shows over the last good build, and the game’s <code>console.*</code> lines print in the terminal that runs the server.</p>+ <div class="tbl-wrap"><table class="tbl">+ <thead><tr><th>Command</th><th>What it does</th></tr></thead>+ <tbody>+ <tr><td><code>threert create <dir></code></td><td>A new game from the template: an interactive scene, a tsconfig, and AGENTS.md / CLAUDE.md so a coding agent can drive the same loop</td></tr>+ <tr><td><code>threert dev</code></td><td>The dev server: the package, the three.js page, live reload, the clients’ logs</td></tr>+ <tr><td><code>threert check</code></td><td>Bundles, typechecks and runs setup and three frames without a window: objects, lights, files read and missing, handlers, keys</td></tr>+ <tr><td><code>threert shot</code></td><td>The traced frame as a PNG, once it has settled</td></tr>+ <tr><td><code>threert click</code> · <code>key</code> · <code>event</code> · <code>state</code></td><td>Play the open game from the terminal and read its state</td></tr>+ <tr><td><code>threert pack</code></td><td>A static package of the game for any web host (below)</td></tr>+ </tbody>+ </table></div>+ <p class="callout">The command is a link into the app, so updating the app updates it. If you move the app, press <b>Install threert</b> again; <code>threert dev</code> and <code>threert check</code> repair a project’s <code>tsconfig.json</code> when it still names the old place.</p>+ </section>++ <section id="package">+ <span class="num">05</span>+ <h2>Packages</h2>+ <p>A game is distributed as code. A package is a directory on any static host, with a manifest, <code>threert.json</code>, at its base URL. <code>threert pack</code> writes one; the dev server serves one that changes as you save.</p>+ <pre class="code sh" aria-label="Terminal"><span class="c">$</span> threert pack <span class="c"># -> dist/: threert.json, game.js, game.mjs, index.html, assets/</span>+<span class="c"># upload dist/ to any static host, then, on any device with the client:</span>+<span class="c"># threerts://your.host/path</span></pre>+ <div class="tbl-wrap"><table class="tbl">+ <thead><tr><th>threert.json</th><th></th></tr></thead>+ <tbody>+ <tr><td><code>format</code></td><td><code>"threert/1"</code></td></tr>+ <tr><td><code>id</code> · <code>name</code> · <code>version</code></td><td>What the game is called; <code>id</code> is lowercase letters, digits and dashes</td></tr>+ <tr><td><code>hash</code></td><td>The hash of the code: it changes on every build, and a client caches the code by it</td></tr>+ <tr><td><code>entry</code></td><td>The game as one script, with the runtime it was built against (<code>game.js</code>)</td></tr>+ <tr><td><code>module</code></td><td>Optional: the game as an ES module that imports <code>@threert/scene</code> and <code>@threert/gameplay</code> from the client (<code>game.mjs</code>)</td></tr>+ <tr><td><code>assets</code></td><td>The files the game may read, each with its size and SHA-256. A client fetches the ones the scene uses, on demand, and checks them</td></tr>+ <tr><td><code>web</code></td><td>The same game as a three.js page (<code>index.html</code>), for screens the client cannot trace on</td></tr>+ <tr><td><code>minClient</code></td><td>The oldest client version that runs this package</td></tr>+ </tbody>+ </table></div>+ <p>Game code runs in the engine’s embedded JavaScript runtime with no file system, network or timers of its own, and the files it reads stay inside the package.</p>+ </section>++ <section id="reference">+ <span class="num">06</span>+ <h2>Reference</h2>+ <p>The engine is open source, and its documents live with the code.</p>+ <div class="refs">+ <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/RUNTIME.md" rel="noopener"><b>Runtime</b><span>How scene code runs in the engine: setup, handlers, world handlers, frame scripts, physics</span></a>+ <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/ARCHITECTURE.md" rel="noopener"><b>Architecture</b><span>The serverless gameplay and rendering runtime the engine was built for</span></a>+ <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/MATERIAL_FUNCTIONS.md" rel="noopener"><b>Material functions</b><span>A WGSL body on a material, run by the path tracer at every hit</span></a>+ <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/VOXEL.md" rel="noopener"><b>Voxel engine</b><span>A voxel game engine built around ThreeRT, measured on a destructible level</span></a>+ <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/COMPARE.md" rel="noopener"><b>Against three.js</b><span>three.js at its strongest against ThreeRT: frame rate and image quality</span></a>+ <a href="https://github.com/taichi-dev/ThreeRT/blob/main/docs/ROADMAP.md" rel="noopener"><b>Roadmap</b><span>The goal, the plan, and what each step measured</span></a>+ </div>+ </section>+ </main>+</div>++<footer class="foot">+ <div class="wrap cols">+ <div>+ <a class="logo" href="../" aria-label="ThreeRT home"><img src="../brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <p style="margin-top:14px">Real-time path tracing behind a three.js-style API.</p>+ <div class="site"><a href="../showcase/">Showcase</a><a href="../download/">Download</a><a href="../docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub</a></div>+ </div>+ <div class="note">+ <p>The engine, <code>@threert/scene</code> and <code>@threert/gameplay</code> are open source: <a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">taichi-dev/ThreeRT</a>. The clients are free to use.</p>+ <p>three.js is an independent open-source project; ThreeRT is not affiliated with it.</p>+ </div>+ </div>+</footer>++<script type="module">+ import { $, highlight } from "../js/threert.js";+ import { guard, downloadButtons } from "../js/site.js";++ guard("download", () => downloadButtons());++ // The scene sample is the hello world's own source (media/code); the game sample is on the page.+ guard("code", async () => {+ const game = $("#gameCode");+ game.innerHTML = highlight(game.textContent);+ const el = $("#sceneCode");+ try {+ const r = await fetch("../media/code/material-grid.threert.ts");+ if (!r.ok) throw new Error(String(r.status));+ el.innerHTML = highlight((await r.text()).trim());+ } catch {+ el.innerHTML = `The sample did not load. It is <a href="https://github.com/taichi-dev/ThreeRT/blob/main/compare/hello/threert/material-grid.ts" rel="noopener">compare/hello/threert/material-grid.ts</a> in the repository.`;+ }+ });+</script>+</body>+</html>diff --git a/site/download/index.html b/site/download/index.htmlnew file mode 100644index 0000000..0fd6b16--- /dev/null+++ b/site/download/index.html@@ -0,0 +1,189 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>Download ThreeRT — macOS and iPhone</title>+<meta name="description" content="ThreeRT for macOS and for iPhone and iPad: the clients that open ThreeRT games and path-trace them on your own GPU.">+<link rel="icon" href="../brand/favicon.svg" type="image/svg+xml">+<link rel="stylesheet" href="../css/threert.css">+<style>+ .dl { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }+ .dl .card { display: grid; grid-template-rows: auto auto 1fr auto; gap: 22px; }+ .dl .top { display: flex; align-items: center; gap: 16px; }+ .dl .glyph { flex: none; width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--line-2); display: grid; place-items: center; color: var(--bone); background: var(--ink-2); }+ .dl h2 { font: 600 28px/1.1 var(--font-sans); letter-spacing: -0.035em; }+ .dl .req { display: block; margin-top: 6px; font: 500 12px var(--font-mono); color: var(--mute); }+ .dl .act { display: grid; gap: 14px; justify-items: start; padding-top: 22px; border-top: 1px solid var(--line); }+ .dl .act .row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }+ .dl details { font: 400 12px/1.6 var(--font-mono); color: var(--mute); max-width: 100%; }+ .dl details summary { cursor: pointer; }+ .dl details p { margin-top: 6px; overflow-wrap: anywhere; color: var(--bone-2); }+ .dl .ios-get { display: flex; gap: 20px; align-items: center; }+ .how .lede { max-width: 62ch; }+ .term { margin-top: 44px; display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: stretch; }+ .term pre { margin: 0; font-size: 12.5px; line-height: 1.75; }+ .term pre .d { color: #5f646d; } .term pre .ok { color: #9ccf7a; } .term pre .t { color: var(--tungsten); } .term pre b { color: var(--bone); font-weight: 600; }+ .term .scan { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }+ .term .scan h3 { font: 600 20px/1.2 var(--font-sans); letter-spacing: -0.02em; }+ .term .scan p { margin-top: 8px; color: var(--bone-2); font-size: 14.5px; }+ .any { margin-top: 56px; padding-top: 36px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: end; }+ .any h3 { font: 620 clamp(26px, 3vw, 40px)/1.08 var(--font-sans); letter-spacing: -0.04em; }+ .any p { color: var(--bone-2); font-size: 16px; }+ @media (max-width: 1100px) { .dl, .term, .any { grid-template-columns: 1fr; } .any { gap: 18px; } }+ @media (max-width: 520px) { .term .scan { grid-template-columns: 1fr; } .dl .ios-get { flex-direction: column; align-items: flex-start; } }+</style>+</head>+<body>++<nav class="nav" aria-label="Site">+ <div class="wrap">+ <a class="logo" href="../" aria-label="ThreeRT home"><img src="../brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <div class="links"><a href="../showcase/">Showcase</a><a href="../download/" aria-current="page">Download</a><a href="../docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub<svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 1h6v6M9 1 1 9"/></svg></a></div>+ </div>+</nav>++<header class="page-head">+ <div class="wrap">+ <span class="eyebrow">Download</span>+ <h1 class="h-1">The client traces it.<br><span class="mute">On your own GPU.</span></h1>+ <p class="lede">ThreeRT games are code. The client fetches a game from a link, a dev server or a QR code and path-traces it on the device in front of you. The clients are free.</p>+ </div>+</header>++<section class="sec">+ <div class="wrap">+ <div class="dl">+ <div class="card lit" id="mac">+ <div class="top">+ <div class="glyph" aria-hidden="true"><svg width="26" height="26" viewBox="0 0 26 26" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round"><rect x="4.5" y="5" width="17" height="11.5" rx="1.6"/><path d="M2 20.5h22"/></svg></div>+ <div><h2>ThreeRT for macOS</h2><span class="req">macOS 14 or later · Apple silicon</span></div>+ </div>+ <ul class="ticks">+ <li>Opens games from <code>threert://</code> links, from dev servers on your network and from its own library of examples</li>+ <li>Hardware ray tracing on M3 and later; dynamic resolution holds the frame rate</li>+ <li>A game plays as soon as it opens: drag to orbit, click to play, <kbd>⌘R</kbd> to reload, <kbd>⌘S</kbd> for a screenshot</li>+ <li>Carries the <code>threert</code> command line: <b>Install threert</b> in its library puts it on your PATH</li>+ </ul>+ <span></span>+ <div class="act" id="macAct">+ <p class="fine">Looking for the build on this host…</p>+ <noscript><p class="fine">The download link is filled in by a script. With scripts off, the build is at <a href="../releases/latest.json">releases/latest.json</a>.</p></noscript>+ </div>+ </div>++ <div class="card" id="ios">+ <div class="top">+ <div class="glyph" aria-hidden="true"><svg width="26" height="26" viewBox="0 0 26 26" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" stroke-linecap="round"><rect x="7.5" y="2.5" width="11" height="21" rx="2.6"/><path d="M11.5 5.2h3"/></svg></div>+ <div><h2>ThreeRT for iPhone</h2><span class="req">iOS 17 or later · iPhone and iPad</span></div>+ </div>+ <ul class="ticks">+ <li>Scan the QR code that <code>threert dev</code> or ThreeRT for macOS shows, and that game opens on the phone</li>+ <li>iPhone 15 Pro and later trace with hardware ray queries; other Metal GPUs trace in compute</li>+ <li>One finger orbits, two pan, a pinch zooms, a tap plays; shake to reload</li>+ </ul>+ <span></span>+ <div class="act" id="iosAct">+ <p class="fine">Looking for the build on this host…</p>+ </div>+ </div>+ </div>+ </div>+</section>++<section class="sec how">+ <div class="wrap">+ <div class="sec-top">+ <h2 class="h-2">Scan, and it runs.</h2>+ <p class="lede">The client is a runtime, not one game. Like Expo Go for an app, it loads whatever project you point it at, and it loads it again every time you save.</p>+ </div>+ <ol class="steps">+ <li><h3>Run <code>threert dev</code></h3><p>It bundles your game on every save, serves it on your network and prints a QR code.</p></li>+ <li><h3>Scan the code</h3><p>With ThreeRT on the iPhone. On the Mac that runs the dev server, ThreeRT for macOS opens the game by itself.</p></li>+ <li><h3>Traced, and live</h3><p>The same code is path-traced on the device. Save a change and every connected client reloads. The game’s logs print in your terminal.</p></li>+ </ol>+ <div class="term">+ <pre class="code" aria-label="What threert dev prints"><span class="d">$</span> <b>threert dev</b>+<span class="ok">✓</span> built <span class="d">3f2a9c1e · 412 KiB · 38 ms</span>++ <b>ThreeRT dev server</b> <span class="d">·</span> my-game+ <span class="d">Local </span> http://127.0.0.1:8790+ <span class="d">iPhone </span> <span class="t">threert://192.168.1.23:8790</span> <span class="d">(scan with the ThreeRT app)</span>+ <span class="d">Web </span> http://192.168.1.23:8790/ <span class="d">(three.js, any browser)</span>++ <span class="ok">✓</span> opened in ThreeRT for macOS+ <span class="d">editing game.ts — every save rebuilds and reloads every client</span></pre>+ <div class="card scan">+ <div class="qr" data-qr="threert://192.168.1.23:8790" data-label="An example of a dev server QR code"></div>+ <div>+ <h3>A link is all a game needs</h3>+ <p>The code carries <code>threert://</code> and the dev server’s address. This one holds the example address from the terminal output; yours has your machine’s.</p>+ </div>+ </div>+ </div>+ <div class="any">+ <h3>No ray tracing? <span class="ray-text">Still the same game.</span></h3>+ <p>A device the client cannot trace on, and every browser, opens the same game as three.js: the dev server and every published package serve that page next to the code. See it on the <a href="../showcase/">examples</a>.</p>+ </div>+ </div>+</section>++<footer class="foot">+ <div class="wrap cols">+ <div>+ <a class="logo" href="../" aria-label="ThreeRT home"><img src="../brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <p style="margin-top:14px">Real-time path tracing behind a three.js-style API.</p>+ <div class="site"><a href="../showcase/">Showcase</a><a href="../download/">Download</a><a href="../docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub</a></div>+ </div>+ <div class="note">+ <p>ThreeRT for macOS and ThreeRT for iPhone are free to use. The engine they run is open source: <a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">taichi-dev/ThreeRT</a>.</p>+ <p>Mac, macOS, iPhone, iPad and TestFlight are trademarks of Apple Inc.</p>+ </div>+ </div>+</footer>++<script type="module">+ import { guard, release, macUrl, megabytes, qrTiles, qrSvg, platform } from "../js/site.js";++ const esc = (s) => String(s).replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);+ const DL = `<svg width="15" height="15" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.5v9M4.2 7 8 10.8 11.8 7M2 14.5h12"/></svg>`;++ guard("qr", () => qrTiles());++ guard("release", async () => {+ const r = await release();+ const mac = document.querySelector("#macAct"), ios = document.querySelector("#iosAct");++ // macOS: the disk image this host carries.+ const m = r?.macos;+ if (m?.file) {+ const trusted = m.signed === "developer-id" && m.notarized === true;+ mac.innerHTML = `+ <div class="row"><a class="btn primary" href="${esc(macUrl(m))}" download>${DL}<span>Download for macOS</span></a>+ <span class="kv"><span><b>${esc(r.version)}</b></span><span>${megabytes(m.size)}</span>${r.date ? `<span>${esc(r.date)}</span>` : ""}</span></div>+ ${trusted ? "" : `<p class="fine">This build is not notarized by Apple yet, so macOS stops it the first time. Open <b>System Settings → Privacy & Security</b> and choose <b>Open Anyway</b> (on macOS 14: right-click the app, then <b>Open</b>). macOS remembers the choice.</p>`}+ <details><summary>${esc(m.file)} · SHA-256</summary><p>${esc(m.sha256 ?? "")}</p></details>`;+ } else {+ mac.innerHTML = `<div class="row"><span class="btn off" aria-disabled="true">No build on this host</span></div>+ <p class="fine">No macOS build is published on this host yet.</p>`;+ }++ // iPhone: a link once the beta is open; until then, say so.+ const i = r?.ios;+ if (i?.url) {+ const where = i.channel === "appstore" ? "the App Store" : "TestFlight";+ ios.innerHTML = `<div class="ios-get"><div class="qr" id="iosQr"></div>+ <div style="display:grid;gap:12px;justify-items:start"><a class="btn primary" href="${esc(i.url)}" rel="noopener"><span>Get it on ${where}</span></a>+ <p class="fine">On a Mac? Point the iPhone’s camera at the code.</p></div></div>`;+ document.querySelector("#iosQr").innerHTML = await qrSvg(i.url, `ThreeRT for iPhone on ${where}`);+ } else {+ ios.innerHTML = `<div class="row"><span class="btn off" aria-disabled="true">TestFlight beta not open yet</span></div>+ <p class="fine">The iPhone app has no public build yet. Its TestFlight link will be on this page when the beta opens.</p>`;+ }++ // Lead with the visitor's own platform.+ if (platform() === "ios") document.querySelector(".dl").prepend(document.querySelector("#ios"));+ });+</script>+</body>+</html>diff --git a/site/index.html b/site/index.htmlindex 7592e8d..daee66b 100644--- a/site/index.html+++ b/site/index.html@@ -3,7 +3,7 @@<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">-<title>ThreeRT — Every light, traced. At 60 fps.</title>+<title>ThreeRT — Path tracing at 60 fps.</title><meta name="description" content="ThreeRT path-traces all lighting in real time behind a three.js-style API: Amazon Lumberyard Bistro and Beeple's Zero-Day at 60 fps, and three.js everywhere else."><link rel="icon" href="brand/favicon.svg" type="image/svg+xml"><link rel="stylesheet" href="css/threert.css">@@ -21,6 +21,7 @@.hero .copy a { pointer-events: auto; }.hero h1 .l2 { display: block; }.hero .cta { display: flex; gap: 12px; margin-top: 4px; flex-wrap: wrap; }+ .hero .plat { margin-top: -10px; color: var(--bone-2); }section { padding: 128px 0; }.sec-head { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: end; margin-bottom: 48px; }@@ -80,8 +81,8 @@.tricks .no { font: 600 clamp(28px, 4vw, 56px)/1.14 var(--font-sans); letter-spacing: -.04em; color: #3a3e47; }.tricks .no s { text-decoration-thickness: 2px; text-decoration-color: var(--ember); }.tricks .yes { margin-top: 26px; font: 640 clamp(56px, 8vw, 116px)/1 var(--font-sans); letter-spacing: -.055em; }- .tricks svg.orbit { width: 150px; height: 150px; margin: 0 auto 40px; display: block; overflow: visible; }- @media (prefers-reduced-motion: reduce) { .tricks svg.orbit .pulse { display: none; } }+ .tricks svg.mark { width: 150px; height: 150px; margin: 0 auto 40px; display: block; overflow: visible; }+ @media (prefers-reduced-motion: reduce) { .tricks svg.mark .pulse { display: none; } }/* ---- Everywhere: one scene, a rail to two renderers, every screen ---- */.root { display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--ink-2); font: 500 13px var(--font-mono); color: var(--bone); position: relative; z-index: 1; }@@ -90,15 +91,16 @@.branch { position: relative; }.branch + .branch { margin-top: 18px; }.branch::before { content: ""; position: absolute; left: -45.5px; top: 50%; width: 44px; height: 1.5px; background: rgba(236, 232, 225, .3); }- .branch.rt-b::before { background: var(--tungsten); box-shadow: 0 0 10px rgba(255, 180, 84, .6); }+ .branch.rt-b::before { background: var(--tungsten); box-shadow: 0 0 10px color-mix(in srgb, var(--tungsten) 60%, transparent); }.branch:last-child::after { content: ""; position: absolute; left: -48px; top: calc(50% + 1.5px); bottom: -4px; width: 8px; background: var(--ink-0); }.tier { border: 1px solid var(--line); border-radius: 22px; padding: 24px 24px 22px 30px; background: var(--ink-1); display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: center; overflow: hidden; }- .tier.rt-tier { border-color: color-mix(in srgb, var(--tungsten) 45%, transparent); background: radial-gradient(70% 90% at 70% 0%, rgba(255, 140, 50, 0.13), transparent 70%), var(--ink-1); }+ .tier.rt-tier { border-color: color-mix(in srgb, var(--tungsten) 45%, transparent); background: radial-gradient(70% 90% at 70% 0%, var(--halo), transparent 70%), var(--ink-1); }.tier h3 { font: 600 28px var(--font-sans); letter-spacing: -.035em; }.tier .req { display: block; margin-top: 8px; font: 500 12px var(--font-mono); color: var(--mute); }.tier .sub { margin-top: 14px; color: var(--bone-2); font-size: 15px; }.tier ul { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 9px; }.tier li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; color: var(--bone-2); font-size: 14.5px; }+ .tier li a { color: var(--bone); }.tier li::before { content: ""; width: 7px; height: 7px; margin-top: 8px; border-radius: 50%; background: var(--c-three); }.rt-tier li::before { background: var(--tungsten); box-shadow: 0 0 8px var(--tungsten); }.shelf3d { position: relative; height: 300px; min-width: 0; }@@ -111,7 +113,6 @@.payoff p { color: var(--bone-2); font-size: 16px; }.tricks .cta { display: flex; justify-content: center; gap: 12px; margin-top: 44px; }- .note { font: 400 12px/1.6 var(--font-mono); color: var(--mute); }@media (max-width: 1100px) {.sec-head, .motion, .details, .tier, .payoff, .rtx ol { grid-template-columns: 1fr; } .rtx li + li { padding-left: 0; border-left: 0; } .rtx .big { flex-direction: column; align-items: flex-start; }@@ -119,15 +120,19 @@.reel { grid-template-columns: 1fr; } .reel .left { border-right: 0; border-bottom: 1px solid var(--line); min-height: 300px; } .reel .story { grid-template-columns: 1fr 1fr 1fr auto; }.shelf { flex-wrap: wrap; }}+ /* A phone: nothing wider than the screen (the wordmark scales with it; the left-side picker scrolls in place). */+ @media (max-width: 700px) {+ .rtx .big h2 { font-size: 25vw; }+ .pick { max-width: calc(100% - 28px); overflow-x: auto; scrollbar-width: none; }+ }</style></head><body>-<nav class="nav overlay">+<nav class="nav overlay" aria-label="Site"><div class="wrap">- <a class="logo" href="#"><img src="brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>- <div class="links"><a href="#hello">Hello world</a><a href="#compare">vs three.js</a><a href="#motion">Motion</a><a href="#everywhere">Everywhere</a></div>- <a class="btn ghost" href="https://github.com/taichi-dev/ThreeRT" style="height:38px;font-size:14px">GitHub</a>+ <a class="logo" href="./" aria-label="ThreeRT home"><img src="brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <div class="links"><a href="showcase/">Showcase</a><a href="download/">Download</a><a href="docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub<svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 1h6v6M9 1 1 9"/></svg></a></div></div></nav>@@ -135,9 +140,10 @@<div class="cmp" id="hero" data-a="media/bistro/tuned.webp" data-b="media/bistro/live.webp" data-la="three.js" data-lb="ThreeRT" data-x="44" data-intro></div><div class="copy"><div class="wrap">- <h1 class="h-display">Every light, traced.<span class="l2 ray-text">At 60 fps.</span></h1>- <p class="lede" style="max-width:52ch">The first three.js-style engine to fully path-trace industry-standard scenes in real time.<sup>1</sup></p>- <div class="cta"><a class="btn primary" href="#hello">See it in a hello world</a><a class="btn ghost" href="#everywhere">Runs everywhere</a></div>+ <h1 class="h-display">Path tracing<span class="l2 ray-text">at 60 fps.</span></h1>+ <p class="lede" style="max-width:52ch">ThreeRT is the first three.js-style engine to fully path-trace industry-standard scenes in real time.<sup>1</sup></p>+ <div class="cta"><a class="btn primary" href="download/" data-dl><svg width="15" height="15" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.5v9M4.2 7 8 10.8 11.8 7M2 14.5h12"/></svg><span>Download</span></a><a class="btn ghost" href="https://github.com/taichi-dev/ThreeRT" rel="noopener"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 .2a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38v-1.34c-2.23.48-2.7-1.07-2.7-1.07-.36-.93-.89-1.17-.89-1.17-.73-.5.05-.49.05-.49.8.06 1.23.83 1.23.83.72 1.22 1.88.87 2.33.66.07-.52.28-.87.5-1.07-1.77-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.03 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48v2.19c0 .21.15.46.55.38A8 8 0 0 0 8 .2Z"/></svg>GitHub</a></div>+ <p class="plat">macOS 14+ on Apple silicon · iPhone and iPad, iOS 17+</p></div></div></header>@@ -250,7 +256,7 @@<div><h3>Native client</h3><span class="req">hardware ray tracing</span><p class="sub">Every light path traced, at 60 fps.</p>- <ul><li>Dynamic resolution holds the frame rate</li><li>Installs like any game client</li></ul>+ <ul><li>Dynamic resolution holds the frame rate</li><li><span>Installs like any game client: <a href="download/">macOS and iPhone</a></span></li></ul></div><div class="shelf3d" id="shelfNative"></div></div>@@ -275,39 +281,47 @@</section><section class="tricks">- <svg class="orbit rv" viewBox="0 0 64 64" aria-hidden="true">- <defs><linearGradient id="ry" x1="10" y1="56" x2="54" y2="20" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#FF6A13"/><stop offset=".5" stop-color="#FFB454"/><stop offset="1" stop-color="#FFEBC4"/></linearGradient><filter id="gl"><feGaussianBlur stdDeviation="1.4"/></filter></defs>- <path d="M32 8.967 L58 54 L6 54 Z" fill="none" stroke="#ECE8E1" stroke-width="2" stroke-linejoin="round" opacity=".9"/>- <path d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="url(#ry)" stroke-width="1.8" stroke-linejoin="round" opacity=".35"/>- <path class="pulse" d="M23.333 54 L40.667 23.978 L23.333 23.978 L40.667 54 L49.333 38.989 L14.667 38.989 Z" fill="none" stroke="#FFEBC4" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" pathLength="100" stroke-dasharray="9 91" filter="url(#gl)"><animate attributeName="stroke-dashoffset" from="100" to="0" dur="2.4s" repeatCount="indefinite"/></path>+ <svg class="mark rv" viewBox="0 0 64 64" aria-hidden="true" data-mark>+ <defs><linearGradient id="ry" x1="11.59" y1="32" x2="32" y2="12.36" gradientUnits="userSpaceOnUse"><stop offset="0" style="stop-color:var(--ember)"/><stop offset=".5" style="stop-color:var(--tungsten)"/><stop offset="1" style="stop-color:var(--filament)"/></linearGradient><filter id="gl" x="-25%" y="-25%" width="150%" height="150%"><feGaussianBlur stdDeviation="1.4"/></filter></defs>+ <rect width="64" height="64" fill="none" pointer-events="all"/>+ <path d="M18.39 59.5 L4.78 4.5 L59.22 20.21 Z" fill="none" style="stroke:var(--bone)" stroke-width="2" stroke-linejoin="round" opacity=".9"/>+ <g class="trail"></g>+ <path data-ray="main" d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="url(#ry)" fill-opacity=".1" stroke="url(#ry)" stroke-width="1.8" stroke-linejoin="round" opacity=".45"/>+ <path data-ray class="pulse" d="M11.59 32 L32 12.36 L38.81 39.86 Z" fill="none" style="stroke:var(--filament)" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" pathLength="100" stroke-dasharray="9 91" filter="url(#gl)"><animate attributeName="stroke-dashoffset" from="100" to="0" dur="2.4s" repeatCount="indefinite"/></path></svg><div class="wrap"><div class="no rv"><s>Shadow maps.</s> <s>Light probes.</s> <s>Lightmaps.</s><br><s>Screen-space GI.</s> <s>Baking.</s></div><div class="yes rv">Just <span class="ray-text">light</span>.</div>- <div class="cta rv"><a class="btn primary" href="#hello">Start with hello world</a><a class="btn ghost" href="https://github.com/taichi-dev/ThreeRT/tree/main/docs">Read the docs</a></div>+ <div class="cta rv"><a class="btn primary" href="download/" data-dl><svg width="15" height="15" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.5v9M4.2 7 8 10.8 11.8 7M2 14.5h12"/></svg><span>Download</span></a><a class="btn ghost" href="https://github.com/taichi-dev/ThreeRT" rel="noopener"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 .2a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38v-1.34c-2.23.48-2.7-1.07-2.7-1.07-.36-.93-.89-1.17-.89-1.17-.73-.5.05-.49.05-.49.8.06 1.23.83 1.23.83.72 1.22 1.88.87 2.33.66.07-.52.28-.87.5-1.07-1.77-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.03 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.28.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48v2.19c0 .21.15.46.55.38A8 8 0 0 0 8 .2Z"/></svg>GitHub</a></div>+ <p class="plat rv" style="margin-top:16px">macOS 14+ on Apple silicon · iPhone and iPad, iOS 17+</p></div></section><footer class="foot"><div class="wrap cols"><div>- <a class="logo" href="#"><img src="brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <a class="logo" href="./" aria-label="ThreeRT home"><img src="brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a><p style="margin-top:14px">Real-time path tracing behind a three.js-style API.</p>+ <div class="site"><a href="showcase/">Showcase</a><a href="download/">Download</a><a href="docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub</a></div></div><div class="note"><p><sup>1</sup> To our knowledge. 60 fps measured on an Apple M5 MacBook at 1280 × 720 output with dynamic resolution, along each scene’s own camera path; three.js r187 in Chrome on the same machine.</p>- <p style="margin-top:12px">Amazon Lumberyard Bistro: Amazon Lumberyard (2017). Zero-Day: Mike Winkelmann (Beeple) and Kate Anderson (2019). Both from NVIDIA’s Open Research Content Archive (ORCA), CC BY 4.0, converted from FBX to glTF. Damaged Helmet: Khronos glTF sample models. three.js is an independent open-source project; ThreeRT is not affiliated with it.</p>+ <p>Amazon Lumberyard Bistro: Amazon Lumberyard (2017). Zero-Day: Mike Winkelmann (Beeple) and Kate Anderson (2019). Both from NVIDIA’s Open Research Content Archive (ORCA), CC BY 4.0, converted from FBX to glTF. Damaged Helmet: Khronos glTF sample models. three.js is an independent open-source project; ThreeRT is not affiliated with it.</p></div></div></footer><script type="module">import { $, $$, compare, sequence, seg, reveal, highlight } from "./js/threert.js";+ import { downloadButtons } from "./js/site.js";// Sections fade in first, so a part that fails below (a missing three.js, a failed fetch) never blanks the page.reveal();const guard = (name, f) => { try { const r = f(); if (r?.catch) r.catch((e) => console.error(`${name}:`, e)); } catch (e) { console.error(`${name}:`, e); } };+ // The download buttons name the visitor's platform (they link to the download page either way).+ guard("download", () => downloadButtons());+guard("comparisons", () => {compare($("#hero"));for (const el of $$(".details .cmp")) compare(el);diff --git a/site/js/mark.js b/site/js/mark.jsnew file mode 100644index 0000000..e226d85--- /dev/null+++ b/site/js/mark.js@@ -0,0 +1,107 @@+// The ThreeRT mark, live: "Three bounces" (brand/mark.svg says what it is) with one thing a file cannot do. On hover+// the light path turns inside the mesh: its three bounce points slide along the edges, out to the corners (for a+// moment the path is the mesh) and on to the next midpoints, a third of a turn, leaving afterimages that catch up+// when it stops. It ends as it began, so it can go round again for as long as the pointer stays.+//+// mark() the lockup's <img> on every page (a.logo: nav and footer) becomes this drawing; the landing page's large+// mark (svg[data-mark]) gets the same turn. Without this script both stay as they are, still.++const NS = "http://www.w3.org/2000/svg";+/** The mesh triangle (bottom, top left, right), in the 64 box: the lockup's heavier drawing and the large one. */+const SMALL = [[18.89, 58.5], [5.77, 5.5], [58.23, 20.64]];+const LARGE = [[18.39, 59.5], [4.78, 4.5], [59.22, 20.21]];++const ease = (t) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2);+const clamp = (t) => Math.max(0, Math.min(1, t));+/** The triangle inscribed in V whose corners have each gone `u` of the way along their edge (0.5: the light path at+ * rest; 1: the mesh itself; 1.5: the path again, a third of a turn on). */+function inscribed(V, u) {+ const at = (s) => {+ s %= 3;+ const i = Math.floor(s), f = s - i, a = V[i], b = V[(i + 1) % 3];+ return `${(a[0] + (b[0] - a[0]) * f).toFixed(2)} ${(a[1] + (b[1] - a[1]) * f).toFixed(2)}`;+ };+ return `M${at(u)} L${at(1 + u)} L${at(2 + u)} Z`;+}++/**+ * Turns the light path of `svg` while the pointer is over `over`.+ * [data-ray] paths drawn along the light path (they all follow it)+ * [data-ray="main"] the one the afterimages copy their stroke from+ * .trail the <g> the afterimages go in+ * opts: V (the mesh), ghosts, lag (of each afterimage behind the one before, as a share of the turn), ms (a turn),+ * lit(main, k): called with k in 0..1 (how far from rest), for what else changes while it turns.+ */+function turn(svg, over, { V, ghosts, lag, ms, lit }) {+ const rays = [...svg.querySelectorAll("[data-ray]")], main = svg.querySelector('[data-ray="main"]'), trail = svg.querySelector(".trail");+ const width = Number(main.getAttribute("stroke-width"));+ const gs = Array.from({ length: ghosts }, () => {+ const p = document.createElementNS(NS, "path");+ for (const [k, v] of Object.entries({ fill: "none", stroke: main.getAttribute("stroke"), "stroke-width": (width * 0.6).toFixed(2), "stroke-linejoin": "round", display: "none" })) p.setAttribute(k, v);+ trail.append(p);+ return p;+ });+ const rest = inscribed(V, 0.5), whole = 1 + ghosts * lag;+ let t0 = 0, raf = 0, hovering = false;+ function frame(now) {+ const tau = (now - t0) / ms;+ if (tau >= whole) {+ for (const p of rays) p.setAttribute("d", rest);+ for (const g of gs) g.setAttribute("display", "none");+ lit?.(main, 0);+ raf = 0;+ if (hovering) start();+ return;+ }+ const e = ease(clamp(tau)), d = inscribed(V, 0.5 + e);+ for (const p of rays) p.setAttribute("d", d);+ gs.forEach((g, k) => {+ const ek = ease(clamp(tau - (k + 1) * lag));+ if (e - ek < 0.003) return g.setAttribute("display", "none");+ g.removeAttribute("display");+ g.setAttribute("d", inscribed(V, 0.5 + ek));+ g.setAttribute("opacity", (0.6 * (1 - k / ghosts) ** 1.5).toFixed(3));+ });+ lit?.(main, Math.sin(Math.PI * clamp(tau)));+ raf = requestAnimationFrame(frame);+ }+ function start() {+ if (raf) return;+ t0 = performance.now();+ raf = requestAnimationFrame(frame);+ }+ over.addEventListener("pointerenter", () => { hovering = true; start(); });+ over.addEventListener("pointerleave", () => { hovering = false; }); // the turn in progress finishes+ over.addEventListener("focus", () => start());+}++let serial = 0;+/** The lockup's mark as an inline drawing (the small one: heavier strokes, the path filled). */+function lockupMark() {+ const id = `mark-ray-${serial++}`;+ const svg = document.createElementNS(NS, "svg");+ svg.setAttribute("viewBox", "0 0 64 64");+ svg.setAttribute("class", "mark");+ svg.setAttribute("aria-hidden", "true");+ svg.innerHTML =+ `<defs><linearGradient id="${id}" x1="12.33" y1="32" x2="32" y2="13.07" gradientUnits="userSpaceOnUse"><stop offset="0" style="stop-color:var(--ember)"/><stop offset=".5" style="stop-color:var(--tungsten)"/><stop offset="1" style="stop-color:var(--filament)"/></linearGradient></defs>` ++ `<path d="${inscribed(SMALL, 0)}" fill="none" style="stroke:var(--bone)" stroke-width="5.2" stroke-linejoin="round"/>` ++ `<g class="trail"></g>` ++ `<path data-ray="main" d="${inscribed(SMALL, 0.5)}" fill="url(#${id})" stroke="url(#${id})" stroke-width="4.4" stroke-linejoin="round"/>`;+ return svg;+}++export function mark(root = document) {+ const still = matchMedia("(prefers-reduced-motion: reduce)").matches;+ for (const img of root.querySelectorAll("a.logo img")) {+ const svg = lockupMark();+ img.replaceWith(svg);+ // At rest the path is a filled shape; turning, it thins to its outline so the mesh and the afterimages show.+ if (!still) turn(svg, svg.closest("a.logo"), { V: SMALL, ghosts: 5, lag: 0.055, ms: 1050, lit: (main, k) => main.setAttribute("fill-opacity", (1 - 0.88 * Math.min(1, k * 2.4)).toFixed(3)) });+ }+ for (const svg of root.querySelectorAll("svg[data-mark]")) {+ if (still) continue;+ const base = Number(svg.querySelector('[data-ray="main"]').getAttribute("opacity") ?? 1);+ turn(svg, svg, { V: LARGE, ghosts: 10, lag: 0.034, ms: 1700, lit: (main, k) => main.setAttribute("opacity", (base + (1 - base) * Math.min(1, k * 1.6)).toFixed(3)) });+ }+}diff --git a/site/js/site.js b/site/js/site.jsnew file mode 100644index 0000000..13da7d5--- /dev/null+++ b/site/js/site.js@@ -0,0 +1,109 @@+// ThreeRT site: what the pages share besides the components in threert.js. The platform a visitor is on (for the+// download buttons), the client release this host carries (releases/latest.json), the example packages it hosts+// (play/index.json), their links, and QR codes. Both JSON files are generated (site/README.md); a host without them+// gets pages that say so.++import { mark } from "./mark.js";++/** The site's root URL (this file is <root>/js/site.js), so pages one level down resolve the same paths. */+export const ROOT = new URL("..", import.meta.url);+export const GITHUB = "https://github.com/taichi-dev/ThreeRT";++/** "macos" | "ios" | "other". An iPad asks for the desktop site as a Mac with a touch screen. */+export function platform() {+ const ua = navigator.userAgent;+ if (/iPhone|iPod|iPad/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)) return "ios";+ if (/Macintosh|Mac OS X/.test(ua)) return "macos";+ return "other";+}++/** The download buttons (`a[data-dl]`, linking to the download page) name the visitor's platform. */+export function downloadButtons(root = document) {+ const text = { macos: "Download for macOS", ios: "Get ThreeRT for iPhone", other: "Download" }[platform()];+ for (const a of root.querySelectorAll("a[data-dl]")) {+ const label = a.querySelector("span") ?? a;+ label.textContent = text;+ }+}++async function json(rel) {+ try {+ const r = await fetch(new URL(rel, ROOT), { cache: "no-cache" });+ return r.ok ? await r.json() : null;+ } catch {+ return null;+ }+}++/** The client release on this host: {version, date, macos: {file, url, size, sha256, minOS, arch, signed, notarized}, ios: {url, channel, minOS}}, or null. */+export const release = () => json("releases/latest.json");+/** The example packages on this host: {client, games: [{id, title, caption, kind, thumb}]}, or null. */+export const packages = () => json("play/index.json");++export const fileUrl = (file) => new URL(`releases/${file}`, ROOT).href;+/** Where a release's macOS disk image is: `macos.url` when it is hosted elsewhere (it is over this host's size limit), else next to latest.json. */+export const macUrl = (m) => (m.url ? m.url : fileUrl(m.file));+export const megabytes = (bytes) => `${(bytes / 1e6).toFixed(bytes < 1e7 ? 1 : 0)} MB`;++/**+ * A hosted package's addresses. `url`: its base (threert.json lives under it) and, with a slash, the same game as+ * three.js. `open`: the link ThreeRT clients register (threerts:// = https, threert:// = http). `qr`: what its QR code+ * carries. Over https that is the plain URL: the phone's camera opens the three.js page, the app's scanner opens the+ * package. Over http (a dev machine) it is the threert:// link, which the camera hands to the app.+ */+export function packageLinks(id) {+ const url = new URL(`play/${id}`, ROOT).href;+ const secure = url.startsWith("https:");+ const open = url.replace(/^https:/, "threerts:").replace(/^http:/, "threert:");+ return { url, web: `${url}/`, open, qr: secure ? `${url}/` : open, thumb: (file) => new URL(`play/${file}`, ROOT).href };+}++/** Whether a phone can reach this page's host (a QR code of localhost only opens on this machine). */+export const reachable = () => !/^(localhost|127\.|\[?::1)/.test(location.hostname);++let qrcode;+/** `text` as a QR code: an SVG string, dark modules only (put it in a `.qr` tile). Loads the encoder on first use. */+export async function qrSvg(text, label = "QR code") {+ qrcode ??= (await import(new URL("vendor/qrcode.mjs", ROOT).href)).default;+ const q = qrcode(0, "M");+ q.addData(text);+ q.make();+ const n = q.getModuleCount(), m = 1;+ let d = "";+ for (let y = 0; y < n; y++) {+ for (let x = 0; x < n; x++) {+ if (!q.isDark(y, x)) continue;+ let w = 1;+ while (x + w < n && q.isDark(y, x + w)) w++; // one rectangle a run: no hairlines between modules+ d += `M${x + m} ${y + m}h${w}v1h-${w}z`;+ x += w - 1;+ }+ }+ const esc = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${n + 2 * m} ${n + 2 * m}" shape-rendering="crispEdges" role="img" aria-label="${esc(label)}"><title>${esc(text)}</title><path fill="#060709" d="${d}"/></svg>`;+}++/** Fills every `.qr[data-qr]` under `root` with its code. */+export async function qrTiles(root = document) {+ for (const el of root.querySelectorAll(".qr[data-qr]")) {+ try {+ el.innerHTML = await qrSvg(el.dataset.qr, el.dataset.label ?? "QR code");+ } catch (e) {+ console.error("qr:", e);+ el.remove();+ }+ }+}++/** Runs a part of a page; a part that fails (a missing file, a failed import) is logged and the rest of the page stands. */+export function guard(name, f) {+ try {+ const r = f();+ if (r?.catch) r.catch((e) => console.error(`${name}:`, e));+ } catch (e) {+ console.error(`${name}:`, e);+ }+}++// Every page imports this file: the lockup's mark comes alive on all of them (js/mark.js).+try { mark(); } catch (e) { console.error("mark:", e); }diff --git a/site/serve.ts b/site/serve.tsindex d1a3a98..6be1f74 100644--- a/site/serve.ts+++ b/site/serve.ts@@ -1,25 +1,69 @@-// Serves the landing page locally: bun site/serve.ts [port] -> http://localhost:4173/-// three.js comes from node_modules (npm install first); site/media is committed (rebuild: bun site/tools/media.ts).+// Serves the site locally: bun site/serve.ts [port] [--lan] -> http://localhost:4173/+// --lan listen on every interface and print the LAN address, so a phone on the same network can open the pages+// and the QR codes on them (Showcase's packages, as threert://<lan ip>:<port>/play/<id>).+// three.js and the QR encoder come from node_modules (npm install first); site/media is committed (rebuild: bun+// site/tools/media.ts). releases/ and play/ are generated by the client repository's release script (site/README.md):+// without them the Download and Showcase pages say that nothing is published on this host.import { existsSync, statSync } from "node:fs";-import { join, normalize, resolve } from "node:path";+import { networkInterfaces } from "node:os";+import { extname, join, normalize, resolve } from "node:path";import { VENDOR } from "./tools/vendor.ts";const root = resolve(import.meta.dir);-const port = Number(process.argv[2] ?? process.env.PORT ?? 4173);+const args = process.argv.slice(2);+const lan = args.includes("--lan");+const port = Number(args.find((a) => /^\d+$/.test(a)) ?? process.env.PORT ?? 4173);++// What the site is made of: the pages, their shared files, and the two generated directories. Nothing else under+// site/ (tools, the worker, this file) is served.+const PAGES = new Set(["index.html", "showcase/index.html", "download/index.html", "docs/index.html"]);+const DIRS = ["css/", "js/", "brand/", "media/", "releases/", "play/"];+const TYPES: Record<string, string> = {+ ".html": "text/html; charset=utf-8", ".css": "text/css; charset=utf-8", ".js": "text/javascript; charset=utf-8", ".mjs": "text/javascript; charset=utf-8",+ ".json": "application/json", ".ts": "text/plain; charset=utf-8", ".svg": "image/svg+xml", ".webp": "image/webp", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",+ ".glb": "model/gltf-binary", ".gltf": "model/gltf+json", ".bin": "application/octet-stream", ".hdr": "application/octet-stream", ".exr": "application/octet-stream", ".ktx2": "image/ktx2",+ ".dmg": "application/x-apple-diskimage", ".zip": "application/zip",+};for (const f of Object.values(VENDOR)) if (!existsSync(f)) console.warn(`missing ${f}: run npm install at the repo root`);+for (const [f, what] of [["releases/latest.json", "the Download page has no build to offer"], ["play/index.json", "Showcase has no packages to open"]]) {+ if (!existsSync(join(root, f))) console.warn(`no site/${f}: ${what} (site/README.md)`);+}++const isFile = (f: string) => existsSync(f) && statSync(f).isFile();Bun.serve({port,- hostname: "127.0.0.1",+ hostname: lan ? "0.0.0.0" : "127.0.0.1",fetch(req) {- let path = decodeURIComponent(new URL(req.url).pathname);- if (path.endsWith("/")) path += "index.html";- const rel = path.replace(/^\/+/, "");- const file = VENDOR[rel] ?? normalize(join(root, rel));- if (!VENDOR[rel] && (!file.startsWith(root + "/") || rel.startsWith("tools/"))) return new Response("not found", { status: 404 });- if (!existsSync(file) || !statSync(file).isFile()) return new Response("not found", { status: 404 });- return new Response(Bun.file(file), { headers: { "cache-control": "no-cache" } });+ const url = new URL(req.url);+ let path: string;+ try {+ path = decodeURIComponent(url.pathname);+ } catch {+ return new Response("bad request", { status: 400 });+ }+ let rel = path.replace(/^\/+/, "");+ if (rel === "" || rel.endsWith("/")) rel += "index.html";+ const vendored = VENDOR[rel];+ const file = vendored ?? normalize(join(root, rel));+ if (!vendored) {+ if (!file.startsWith(root + "/")) return new Response("not found", { status: 404 });+ // A directory without its slash: redirect, so the page's relative links resolve (as the deployed site does).+ if (existsSync(file) && statSync(file).isDirectory() && isFile(join(file, "index.html"))) return Response.redirect(`${url.pathname}/${url.search}`, 301);+ if (!PAGES.has(rel) && !DIRS.some((d) => rel.startsWith(d))) return new Response("not found", { status: 404 });+ }+ if (!isFile(file)) return new Response("not found", { status: 404 });+ const headers: Record<string, string> = { "cache-control": "no-cache", "content-type": TYPES[extname(file).toLowerCase()] ?? "application/octet-stream" };+ // Packages are fetched by native clients and by pages on other origins (a playground, a game's own site).+ if (rel.startsWith("play/")) headers["access-control-allow-origin"] = "*";+ return new Response(Bun.file(file), { headers });},});-console.log(`ThreeRT landing page: http://localhost:${port}/`);++console.log(`ThreeRT site: http://localhost:${port}/`);+if (lan) {+ const nets = networkInterfaces();+ const ip = ["en0", "en1", ...Object.keys(nets)].flatMap((n) => nets[n] ?? []).find((n) => n.family === "IPv4" && !n.internal)?.address;+ console.log(ip ? ` LAN: http://${ip}:${port}/ (open this one for QR codes a phone can use)` : " LAN: no network address found");+}diff --git a/site/showcase/index.html b/site/showcase/index.htmlnew file mode 100644index 0000000..5249d71--- /dev/null+++ b/site/showcase/index.html@@ -0,0 +1,149 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>ThreeRT Showcase — scenes traced in real time, and examples to open</title>+<meta name="description" content="Amazon Lumberyard Bistro and Beeple's Zero-Day path-traced at 60 fps, and example games you can open in ThreeRT for macOS and iPhone or as three.js in this browser.">+<link rel="icon" href="../brand/favicon.svg" type="image/svg+xml">+<link rel="stylesheet" href="../css/threert.css">+<style>+ .feat { display: grid; grid-template-columns: 1.55fr 1fr; gap: 36px; align-items: center; }+ .feat + .feat { margin-top: 72px; }+ .feat.flip { grid-template-columns: 1fr 1.55fr; }+ .feat.flip .txt { order: -1; }+ .feat h2 { font: 620 clamp(32px, 3.6vw, 52px)/1 var(--font-sans); letter-spacing: -0.045em; }+ .feat .by { display: block; margin-top: 10px; font: 500 12px/1.5 var(--font-mono); color: var(--mute); }+ .feat p.d { margin-top: 18px; color: var(--bone-2); font-size: 16px; max-width: 46ch; }+ .feat .ticks { margin-top: 20px; }+ .feat .ticks li::before { background: var(--tungsten); box-shadow: 0 0 8px var(--tungsten); }+ .feat .more { margin-top: 22px; font-size: 14.5px; color: var(--mute); }+ .feat .more a { color: var(--bone); }++ .pk { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }+ .pk .card { padding: 0; overflow: hidden; display: grid; grid-template-rows: auto 1fr; }+ .pk .thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #000; }+ .pk .thumb img { width: 100%; height: 100%; object-fit: cover; }+ .pk .kind { position: absolute; top: 12px; left: 12px; padding: 5px 9px; border-radius: 7px; background: rgba(8, 9, 11, 0.66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font: 500 11.5px/1 var(--font-mono); color: var(--bone); }+ .pk .body { padding: 20px 22px 22px; display: grid; grid-template-columns: 1fr auto; gap: 16px 18px; align-content: start; }+ .pk h3 { font: 600 21px/1.15 var(--font-sans); letter-spacing: -0.025em; }+ .pk .cap2 { margin-top: 7px; color: var(--bone-2); font-size: 14.5px; }+ .pk .qr { width: 92px; height: 92px; padding: 6px; border-radius: 10px; }+ .pk .acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }+ .pk .addr { grid-column: 1 / -1; font: 400 11.5px/1.5 var(--font-mono); color: var(--mute); overflow-wrap: anywhere; }+ .open-note { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px 28px; }+ .open-note[hidden] { display: none; }+ @media (max-width: 1100px) { .feat, .feat.flip { grid-template-columns: 1fr; gap: 22px; } .feat.flip .txt { order: 0; } .pk { grid-template-columns: 1fr 1fr; } }+ /* A phone cannot scan its own screen: the codes are for a second device. */+ @media (max-width: 700px) { .pk { grid-template-columns: 1fr; } .pk .qr, .open-note .scan { display: none; } .pk .body { grid-template-columns: 1fr; } }+</style>+</head>+<body>++<nav class="nav" aria-label="Site">+ <div class="wrap">+ <a class="logo" href="../" aria-label="ThreeRT home"><img src="../brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <div class="links"><a href="../showcase/" aria-current="page">Showcase</a><a href="../download/">Download</a><a href="../docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub<svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 1h6v6M9 1 1 9"/></svg></a></div>+ </div>+</nav>++<header class="page-head">+ <div class="wrap">+ <span class="eyebrow">Showcase</span>+ <h1 class="h-1">Production scenes.<br><span class="mute">Every light traced.</span></h1>+ <p class="lede">Two scenes the industry uses to test renderers, with the camera moving and all of their lighting path-traced. Then small ones you can open yourself.</p>+ </div>+</header>++<section class="sec">+ <div class="wrap">+ <div class="feat rv">+ <div class="seqp" data-scene="../media/bistro" data-la="three.js · 54 fps" data-lb="ThreeRT · 60 fps"></div>+ <div class="txt">+ <h2>Bistro night</h2>+ <span class="by">Amazon Lumberyard Bistro · ORCA</span>+ <p class="d">A street corner after dark. The string lights, the shop signs and the lamps are the light sources: each one lights the square in its own colour.</p>+ <ul class="ticks"><li>Every emitter is a light</li><li>Warm light from the shop window and the wall lamp spills across the facade and the pavement</li></ul>+ <p class="more">Drag the divider: three.js on the left, ThreeRT on the right, the same camera path.<sup>1</sup></p>+ </div>+ </div>+ <div class="feat flip rv">+ <div class="seqp" data-scene="../media/zero-day" data-la="three.js · 12 fps" data-lb="ThreeRT · 60 fps"></div>+ <div class="txt">+ <h2>Zero-Day</h2>+ <span class="by">Beeple · ORCA</span>+ <p class="d">A hall of machines lit by ten thousand small emitters. Each adds its own light, highlight and shadow, and the floor mirrors the machines and their lights.</p>+ <ul class="ticks"><li>Ten thousand small lights</li><li>Reflections of the whole scene, including the parts the camera never sees</li></ul>+ <p class="more">The stills, side by side with three.js at its strongest: <a href="../#compare">against three.js at full power</a>.</p>+ </div>+ </div>+ </div>+</section>++<section class="sec" id="open">+ <div class="wrap">+ <div class="sec-top rv">+ <h2 class="h-2">Open on your device.</h2>+ <p class="lede">Each of these is a package on this site: scene code at tutorial size and the files it reads. ThreeRT fetches it and traces it on your GPU. The same package opens as three.js in this browser.</p>+ </div>+ <div class="pk" id="pk"><p class="fine">Looking for the packages on this host…</p></div>+ <div class="open-note fine" id="openNote" hidden>+ <span><b style="color:var(--bone-2)">Open in ThreeRT</b> needs the client: <a href="../download/">download it for macOS or iPhone</a>.</span>+ <span class="scan">On a phone, scan a code with the ThreeRT app.</span>+ </div>+ </div>+</section>++<footer class="foot">+ <div class="wrap cols">+ <div>+ <a class="logo" href="../" aria-label="ThreeRT home"><img src="../brand/mark.svg" alt=""><span>Three<span class="rt">RT</span></span></a>+ <p style="margin-top:14px">Real-time path tracing behind a three.js-style API.</p>+ <div class="site"><a href="../showcase/">Showcase</a><a href="../download/">Download</a><a href="../docs/">Docs</a><a href="https://github.com/taichi-dev/ThreeRT" rel="noopener">GitHub</a></div>+ </div>+ <div class="note">+ <p><sup>1</sup> 60 fps measured on an Apple M5 MacBook at 1280 × 720 output with dynamic resolution, along each scene’s own camera path; three.js r187 in Chrome on the same machine.</p>+ <p>Amazon Lumberyard Bistro: Amazon Lumberyard (2017). Zero-Day: Mike Winkelmann (Beeple) and Kate Anderson (2019). Both from NVIDIA’s Open Research Content Archive (ORCA), CC BY 4.0, converted from FBX to glTF. Damaged Helmet: Khronos glTF sample models. three.js is an independent open-source project; ThreeRT is not affiliated with it.</p>+ </div>+ </div>+</footer>++<script type="module">+ import { $, $$, sequence, reveal } from "../js/threert.js";+ import { guard, packages, packageLinks, qrSvg, reachable } from "../js/site.js";++ reveal();+ guard("camera moves", () => { for (const el of $$(".seqp")) sequence(el); });++ const esc = (s) => String(s).replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);++ // The packages this host carries (play/index.json). A host without them gets a note, not an empty grid.+ guard("packages", async () => {+ const pk = $("#pk"), index = await packages();+ const games = index?.games ?? [];+ if (!games.length) {+ pk.outerHTML = `<p class="fine">No example packages are published on this host yet. The examples also ship inside the client: <a href="../download/">download ThreeRT</a> and open its library.</p>`;+ return;+ }+ pk.innerHTML = games.map((g) => {+ const l = packageLinks(g.id);+ return `<article class="card">+ <a class="thumb" href="${esc(l.web)}" aria-label="${esc(g.title)} as three.js in this browser">${g.thumb ? `<img src="${esc(l.thumb(g.thumb))}" alt="${esc(g.title)}, rendered by ThreeRT" loading="lazy">` : ""}<span class="kind">${g.kind === "game" ? "game" : "scene"}</span></a>+ <div class="body">+ <div><h3>${esc(g.title)}</h3><p class="cap2">${esc(g.caption ?? "")}</p></div>+ <div class="qr" data-id="${esc(g.id)}"></div>+ <div class="acts"><a class="btn primary sm" href="${esc(l.open)}">Open in ThreeRT</a><a class="btn ghost sm" href="${esc(l.web)}">three.js in the browser</a></div>+ <div class="addr">${esc(l.open)}</div>+ </div>+ </article>`;+ }).join("");+ $("#openNote").hidden = false;+ if (!reachable()) $("#openNote").insertAdjacentHTML("beforeend", `<span>This page is on ${esc(location.hostname)}, which a phone cannot reach. Serve with <code>bun site/serve.ts --lan</code> and open the LAN address.</span>`);+ for (const el of $$("#pk .qr")) {+ const g = games.find((x) => x.id === el.dataset.id), l = packageLinks(g.id);+ try { el.innerHTML = await qrSvg(l.qr, `QR code: open ${g.title} on a phone`); } catch (e) { console.error("qr:", e); el.remove(); }+ }+ });+</script>+</body>+</html>diff --git a/site/tools/build.ts b/site/tools/build.tsindex db60c8f..66e4cdd 100644--- a/site/tools/build.ts+++ b/site/tools/build.ts@@ -1,17 +1,71 @@-// A static copy of the landing page for any file host: bun site/tools/build.ts [outDir] (default out/site)-// The page plus the three.js files its import map names; no bundling, nothing rewritten.-import { cpSync, copyFileSync, mkdirSync, rmSync } from "node:fs";-import { dirname, join, resolve } from "node:path";+// A static copy of the site for any file host: bun site/tools/build.ts [outDir] [--require-release] (default out/site)+// The pages plus the npm files they import (three.js, the QR encoder); no bundling, nothing rewritten.+//+// Two directories are generated elsewhere and copied when they are there (site/README.md):+// site/releases/ latest.json and the client build it names (the Download page)+// site/play/ index.json and the example packages (Showcase's "Open on your device")+// Without them the pages say that nothing is published on this host; the build warns. --require-release makes that+// (and a file over the host's size limit) an error: what the deploy uses. The disk image itself stays out of the build+// (--with-image copies it): threert.dev serves it from R2.+import { cpSync, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";+import { dirname, join, relative, resolve } from "node:path";import { VENDOR } from "./vendor.ts";const site = resolve(import.meta.dir, "..");-const out = resolve(process.argv[2] ?? join(site, "../out/site"));+const args = process.argv.slice(2);+const strict = args.includes("--require-release");+const out = resolve(args.find((a) => !a.startsWith("--")) ?? join(site, "../out/site"));+/** Cloudflare Workers static assets: 25 MiB a file. */+const MAX_FILE = 25 * 1024 * 1024;++const problems: string[] = [];rmSync(out, { recursive: true, force: true });mkdirSync(out, { recursive: true });copyFileSync(join(site, "index.html"), join(out, "index.html"));-for (const d of ["css", "js", "brand", "media"]) cpSync(join(site, d), join(out, d), { recursive: true });+for (const d of ["showcase", "download", "docs", "css", "js", "brand", "media"]) cpSync(join(site, d), join(out, d), { recursive: true });for (const [rel, file] of Object.entries(VENDOR)) {mkdirSync(dirname(join(out, rel)), { recursive: true });copyFileSync(file, join(out, rel));}-console.log(`landing page -> ${out}`);++// The client release.+const latest = join(site, "releases/latest.json");+if (existsSync(latest)) {+ const r = JSON.parse(readFileSync(latest, "utf8"));+ const file = r.macos?.file && join(site, "releases", r.macos.file);+ // The disk image is never a static asset here: with the command line in it, it is over the 25 MiB a file the host+ // takes. On threert.dev the Worker serves /releases/<file> from R2 (worker.ts; deploy.ts uploads it), or `macos.url`+ // names another place. --with-image copies it into the build, for a plain file host without that limit.+ const withImage = args.includes("--with-image");+ if (r.macos?.url) {+ if (!/^https:\/\//.test(r.macos.url)) problems.push(`site/releases/latest.json: macos.url is not an https URL (${r.macos.url})`);+ } else if (!file || !existsSync(file)) problems.push(`site/releases/latest.json names ${r.macos?.file ?? "no macOS file"}, which is not in site/releases/`);+ else if (statSync(file).size !== r.macos.size) problems.push(`site/releases/${r.macos.file} is ${statSync(file).size} bytes, latest.json says ${r.macos.size}`);+ cpSync(join(site, "releases"), join(out, "releases"), { recursive: true, filter: (src) => withImage || !src.endsWith(".dmg") });+ console.log(`release ${r.version}: ${r.macos?.url ?? r.macos?.file ?? "no macOS build"}${r.macos?.url || withImage ? "" : " (served from R2: deploy.ts uploads it)"}; iOS ${r.ios?.url ?? "not published"}`);+} else {+ problems.push("no site/releases/latest.json: the Download page will say that no build is published on this host");+}++// The example packages.+const index = join(site, "play/index.json");+if (existsSync(index)) {+ const p = JSON.parse(readFileSync(index, "utf8"));+ for (const g of p.games ?? []) {+ if (!existsSync(join(site, "play", g.id, "threert.json"))) problems.push(`site/play/index.json lists ${g.id}, which has no site/play/${g.id}/threert.json`);+ }+ cpSync(join(site, "play"), join(out, "play"), { recursive: true });+ console.log(`packages: ${(p.games ?? []).map((g: { id: string }) => g.id).join(", ")}`);+} else {+ problems.push("no site/play/index.json: Showcase will have no packages to open");+}++const walk = (d: string): string[] => readdirSync(d, { withFileTypes: true }).flatMap((e) => (e.isDirectory() ? walk(join(d, e.name)) : [join(d, e.name)]));+for (const f of walk(out)) {+ const size = statSync(f).size;+ if (size > MAX_FILE && !f.endsWith(".dmg")) problems.push(`${relative(out, f)} is ${(size / 1048576).toFixed(1)} MiB: over the 25 MiB a file that Workers static assets take`);+}++for (const p of problems) console.warn(`${strict ? "error" : "warning"}: ${p}`);+if (strict && problems.length) process.exit(1);+console.log(`site -> ${out}`);diff --git a/site/tools/deploy.ts b/site/tools/deploy.tsindex d14af08..5d9065e 100644--- a/site/tools/deploy.ts+++ b/site/tools/deploy.ts@@ -1,8 +1,21 @@-// Builds the landing page and deploys it to threert.dev (Cloudflare Workers, static assets + custom domains).+// Builds the site and deploys it to threert.dev (Cloudflare Workers: static assets, custom domains, and the clients'+// disk images from R2).// bun site/tools/deploy.ts needs `wrangler login` as a member of the account in site/wrangler.jsonc+// The build is strict: it stops when site/releases/ or site/play/ is missing or incomplete, so a deploy never puts up+// a Download button with nothing behind it (site/README.md: where the two directories come from).+// The disk image latest.json names goes to the R2 bucket first (site/wrangler.jsonc: `threert-releases`, created once+// with `bunx wrangler@4 r2 bucket create threert-releases`), so the page never links an image that is not there yet.import { $ } from "bun";-import { resolve } from "node:path";+import { existsSync, readFileSync } from "node:fs";+import { join, resolve } from "node:path";const site = resolve(import.meta.dir, "..");-await $`bun ${resolve(site, "tools/build.ts")}`;-await $`bunx wrangler@4 deploy --config ${resolve(site, "wrangler.jsonc")}`;+const config = resolve(site, "wrangler.jsonc");+await $`bun ${resolve(site, "tools/build.ts")} --require-release`;+const latest = JSON.parse(readFileSync(join(site, "releases/latest.json"), "utf8"));+if (!latest.macos?.url) {+ const file = join(site, "releases", latest.macos.file);+ if (!existsSync(file)) throw new Error(`${file} is missing`);+ await $`bunx wrangler@4 r2 object put ${`threert-releases/${latest.macos.file}`} --file ${file} --content-type application/x-apple-diskimage --remote --config ${config}`;+}+await $`bunx wrangler@4 deploy --config ${config}`;diff --git a/site/tools/vendor.ts b/site/tools/vendor.tsindex 02b8026..49a70d1 100644--- a/site/tools/vendor.ts+++ b/site/tools/vendor.ts@@ -1,8 +1,10 @@-// The three.js files the page imports (site/index.html's import map: "three" and "three/addons/"), served from the-// repo's own three devDependency so no copy is committed. serve.ts maps these URLs; build.ts copies the files.+// The files the pages import from npm packages: three.js (site/index.html's import map: "three" and "three/addons/")+// and the QR encoder (js/site.js), served from the repo's own devDependencies so no copy is committed. serve.ts maps+// these URLs; build.ts copies the files.import { join, resolve } from "node:path";-const three = resolve(import.meta.dir, "../../node_modules/three");+const modules = resolve(import.meta.dir, "../../node_modules");+const three = join(modules, "three");export const VENDOR: Record<string, string> = {"vendor/three/three.module.js": join(three, "build/three.module.js"),@@ -10,4 +12,6 @@ export const VENDOR: Record<string, string> = {"vendor/three/addons/RoomEnvironment.js": join(three, "examples/jsm/environments/RoomEnvironment.js"),"vendor/three/addons/RoundedBoxGeometry.js": join(three, "examples/jsm/geometries/RoundedBoxGeometry.js"),"vendor/three/LICENSE": join(three, "LICENSE"),+ // qrcode-generator (Kazuhiko Arase, MIT: the licence is the file's header).+ "vendor/qrcode.mjs": join(modules, "qrcode-generator/dist/qrcode.mjs"),};diff --git a/site/worker.ts b/site/worker.tsindex 5054fe3..cde4d3a 100644--- a/site/worker.ts+++ b/site/worker.ts@@ -1,7 +1,69 @@-// The landing page on Cloudflare Workers: static assets (out/site, built by site/tools/build.ts) on threert.dev.-// www.threert.dev redirects to the apex; everything else is served from the assets as built.+// The site on Cloudflare Workers: static assets (out/site, built by site/tools/build.ts) on threert.dev, and the+// clients' disk images from R2. www.threert.dev redirects to the apex.+//+// Why R2: the disk image (releases/ThreeRT-<version>-macos-arm64.dmg, about 32 MiB with the `threert` command line in+// it) is over the 25 MiB a file that static assets take, and the client is closed source, so it has no public+// repository whose releases could carry it. The bucket holds the images under their file names; this Worker serves+// them at the same URL the Download page already links, /releases/<file>, with ranges (a resumed download).+interface R2Range {+ offset?: number;+ length?: number;+ suffix?: number;+}+interface R2Object {+ size: number;+ httpEtag: string;+ range?: R2Range;+ writeHttpMetadata(headers: Headers): void;+}+interface R2ObjectBody extends R2Object {+ body: ReadableStream;+}+interface R2Bucket {+ head(key: string): Promise<R2Object | null>;+ get(key: string, options?: { range?: Headers; onlyIf?: Headers }): Promise<R2ObjectBody | R2Object | null>;+}interface Env {ASSETS: { fetch(request: Request): Promise<Response> };+ RELEASES: R2Bucket;+}++/** /releases/<name>.dmg -> the bucket key (the file name), or null for everything else. */+export function imageKey(pathname: string): string | null {+ return /^\/releases\/([A-Za-z0-9][A-Za-z0-9._-]*\.dmg)$/.exec(pathname)?.[1] ?? null;+}++async function image(request: Request, env: Env, key: string): Promise<Response> {+ if (request.method !== "GET" && request.method !== "HEAD") return new Response("method not allowed", { status: 405, headers: { allow: "GET, HEAD" } });+ const headers = new Headers({+ "content-type": "application/x-apple-diskimage",+ "content-disposition": `attachment; filename="${key}"`,+ "accept-ranges": "bytes",+ // An hour, then revalidated by ETag: a build may be replaced under its name before its version is final.+ "cache-control": "public, max-age=3600",+ });+ if (request.method === "HEAD") {+ const head = await env.RELEASES.head(key);+ if (!head) return new Response("not found", { status: 404 });+ headers.set("etag", head.httpEtag);+ headers.set("content-length", String(head.size));+ return new Response(null, { headers });+ }+ const object = await env.RELEASES.get(key, { range: request.headers, onlyIf: request.headers });+ if (!object) return new Response("not found", { status: 404 });+ headers.set("etag", object.httpEtag);+ // A conditional request the object did not pass (If-None-Match on a cached copy): no body.+ if (!("body" in object)) return new Response(null, { status: 304, headers });+ const r = object.range;+ if (request.headers.has("range") && r) {+ const start = r.suffix !== undefined ? Math.max(0, object.size - r.suffix) : (r.offset ?? 0);+ const length = r.suffix !== undefined ? object.size - start : (r.length ?? object.size - start);+ headers.set("content-range", `bytes ${start}-${start + length - 1}/${object.size}`);+ headers.set("content-length", String(length));+ return new Response(object.body, { status: 206, headers });+ }+ headers.set("content-length", String(object.size));+ return new Response(object.body, { headers });}export default {@@ -11,6 +73,8 @@ export default {url.hostname = "threert.dev";return Response.redirect(url.toString(), 301);}+ const key = imageKey(url.pathname);+ if (key) return image(request, env, key);return env.ASSETS.fetch(request);},};diff --git a/site/wrangler.jsonc b/site/wrangler.jsoncindex 84dda05..e2e1521 100644--- a/site/wrangler.jsonc+++ b/site/wrangler.jsonc@@ -8,9 +8,13 @@"assets": {"directory": "../out/site","binding": "ASSETS",- // The worker runs first so www can redirect; it hands every other request to the assets.+ // The worker runs first: www redirects, /releases/*.dmg comes from R2, every other request goes to the assets."run_worker_first": true},+ // The clients' disk images (over the 25 MiB a file that static assets take): site/tools/deploy.ts uploads+ // site/releases/*.dmg here, worker.ts serves them at /releases/<file>. Create it once:+ // bunx wrangler@4 r2 bucket create threert-releases+ "r2_buckets": [{ "binding": "RELEASES", "bucket_name": "threert-releases" }],"routes": [{ "pattern": "threert.dev", "custom_domain": true },{ "pattern": "www.threert.dev", "custom_domain": true }