diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml
new file mode 100644
index 0000000..888ff8d
--- /dev/null
+++ b/.github/workflows/deploy-site.yml
@@ -0,0 +1,41 @@
+# Builds site/ and deploys it to the Cloudflare Pages project `planchette` in the
+# Hyperquake account. See site/build.mjs for what the build does.
+#
+# Runs when the site changes on main, and whenever a release is published, because
+# the page always offers the newest release and its live demo is that release's
+# web build. Never on pull requests: the deploy token must not be reachable from
+# a fork, so there is deliberately no pull_request or pull_request_target trigger.
+name: deploy site
+
+on:
+ push:
+ branches: [main]
+ paths: ['site/**', 'brand/**', '.github/workflows/deploy-site.yml']
+ release:
+ types: [published]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: deploy-site
+ cancel-in-progress: true
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v5
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 24
+ - name: Build
+ run: node site/build.mjs
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Deploy to Cloudflare Pages
+ run: npx --yes wrangler@4.166.0 pages deploy site/_build --project-name planchette --branch main --commit-dirty=true
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: 94101aa2f0abc6010708f574836bfdf5
diff --git a/.prettierignore b/.prettierignore
index facfd6d..130981e 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -18,3 +18,7 @@ package-lock.json
# Generated from geometry by brand/tools/make-icons.py rather than hand-edited.
brand/*.svg
public/favicon.svg
+
+# The site build output and its cached copy of a release web build.
+site/_build
+site/.cache
diff --git a/site/.gitignore b/site/.gitignore
new file mode 100644
index 0000000..ca8b0a7
--- /dev/null
+++ b/site/.gitignore
@@ -0,0 +1,3 @@
+_build/
+.cache/
+media/stills/
diff --git a/site/build.mjs b/site/build.mjs
new file mode 100644
index 0000000..83a97ea
--- /dev/null
+++ b/site/build.mjs
@@ -0,0 +1,95 @@
+#!/usr/bin/env node
+/**
+ * Builds the public site into site/_build, ready to upload as-is.
+ *
+ * node site/build.mjs # then serve site/_build, e.g. npx serve site/_build
+ *
+ * The page always offers the newest published release, pre-releases included,
+ * that has a web build attached. The live demo is that release's planchette-web
+ * zip rather than this checkout, because docs/EMBED.md is right that a site must
+ * match what people download. deploy-site.yml rebuilds whenever a release is
+ * published, so nothing needs editing here when a version ships.
+ *
+ * PLANCHETTE_VERSION=0.1.1 pins a version instead. GITHUB_TOKEN, if set, avoids
+ * the API's anonymous rate limit.
+ *
+ * Needs `unzip`, which macOS and the Ubuntu runners both have.
+ */
+import { execFileSync } from 'node:child_process'
+import fs from 'node:fs/promises'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const here = path.dirname(fileURLToPath(import.meta.url))
+const root = path.resolve(here, '..')
+const out = path.join(here, '_build')
+const cache = path.join(here, '.cache')
+const REPO = 'hyperquake/planchette'
+
+/** Newest published release with a web build, or the pinned one. */
+async function pickRelease() {
+ const headers = { accept: 'application/vnd.github+json' }
+ if (process.env.GITHUB_TOKEN) headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`
+ const res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=20`, { headers })
+ if (!res.ok) throw new Error(`GitHub releases: ${res.status}`)
+ const releases = (await res.json()).filter((r) => !r.draft)
+ const pinned = process.env.PLANCHETTE_VERSION
+ const pick = releases.find((r) => {
+ const v = r.tag_name.replace(/^v/, '')
+ return (!pinned || v === pinned) && r.assets.some((a) => a.name === `planchette-web-${v}.zip`)
+ })
+ if (!pick) throw new Error(pinned ? `no release v${pinned} with a web build` : 'no published release has a web build')
+ return { version: pick.tag_name.replace(/^v/, ''), prerelease: pick.prerelease }
+}
+const { version, prerelease } = await pickRelease()
+
+await fs.rm(out, { recursive: true, force: true })
+await fs.mkdir(path.join(out, 'brand'), { recursive: true })
+await fs.mkdir(path.join(out, 'media'), { recursive: true })
+
+const html = await fs.readFile(path.join(here, 'index.html'), 'utf8')
+await fs.writeFile(
+ path.join(out, 'index.html'),
+ html.replaceAll('{{VERSION}}', version).replaceAll('{{CHANNEL}}', prerelease ? ' (beta)' : ''),
+)
+await fs.copyFile(path.join(here, 'style.css'), path.join(out, 'style.css'))
+
+const MEDIA = [
+ 'loop.mp4',
+ 'loop.webm',
+ 'loop-poster.jpg',
+ 'reel.mp4',
+ 'arcane-table.jpg',
+ 'radial-atlas.jpg',
+ 'dial-demo.jpg',
+ 'app-inspector.jpg',
+ 'hyperquake-logotype-black.png',
+]
+for (const f of MEDIA) await fs.copyFile(path.join(here, 'media', f), path.join(out, 'media', f))
+await fs.copyFile(
+ path.join(root, 'brand', 'lockup-horizontal-black.svg'),
+ path.join(out, 'brand', 'lockup-horizontal-black.svg'),
+)
+for (const f of ['favicon.svg', 'favicon.ico']) await fs.copyFile(path.join(root, 'public', f), path.join(out, f))
+
+// The pinned web build, downloaded once and cached.
+const zipName = `planchette-web-${version}.zip`
+const zip = path.join(cache, zipName)
+try {
+ await fs.access(zip)
+} catch {
+ const url = `https://github.com/hyperquake/planchette/releases/download/v${version}/${zipName}`
+ const res = await fetch(url)
+ if (!res.ok) throw new Error(`${url}: ${res.status}. Does release v${version} have a web build attached?`)
+ await fs.mkdir(cache, { recursive: true })
+ await fs.writeFile(zip, Buffer.from(await res.arrayBuffer()))
+}
+const unpacked = path.join(cache, `web-${version}`)
+await fs.rm(unpacked, { recursive: true, force: true })
+execFileSync('unzip', ['-q', zip, '-d', unpacked])
+// The zip may or may not wrap its files in a folder; find the one with index.html.
+const entries = await fs.readdir(unpacked)
+const inner = entries.includes('index.html') ? unpacked : path.join(unpacked, entries[0])
+await fs.cp(inner, path.join(out, 'embed'), { recursive: true })
+
+console.log(`site built for v${version}${prerelease ? ' (pre-release)' : ''} in ${path.relative(root, out)}`)
diff --git a/site/index.html b/site/index.html
new file mode 100644
index 0000000..8921519
--- /dev/null
+++ b/site/index.html
@@ -0,0 +1,199 @@
+
+
+
+
+
+ Planchette: design for the table, without the table
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Design for the table, without the table.
+
+ Planchette is a free simulator for multitouch tables: the big interactive surfaces
+ in museums, showrooms and exhibits, where people gather round and use their hands
+ and real objects at once. Put pucks on it, touch it, turn things, and see exactly
+ what the table will show. Then take the same interface to the real thing.
+
+ A touch table is a metre and a quarter wide. Planchette lays every interface out
+ at the table's real resolution and measures it in real millimetres, so a button
+ that looks right here is the right size under someone's finger.
+
+
+
+
Objects, not just fingers
+
+ The table recognises physical pucks: where each one is, which way it faces and
+ which one it is. Place them, slide them and spin them, alongside as many fingers
+ as you like, the way a group of people really would.
+
+
+
+
Then run it on the table
+
+ An interface is a plain web page. When it's ready, the same files run on the real
+ table, with no rebuild and no translation. Planchette is the place you get it
+ right before you get there.
+
+
+
+
+
+
+
Try it right here
+
+ This is the real simulator, running one of the examples. Drag the puck to move it.
+ Scroll over it to turn it, then click a ring to open what it's pointing at.
+
+
+
+
+
+
The live demo needs a bigger screen. The reel above shows it in motion.
+
+
+
+
+
The whole table, on your laptop
+
+ Pick an interface, drop pucks on it and try it with several hands at once. The
+ panel on the right shows everything the interface is told, as it happens, so
+ when something looks wrong you can see why.
+
+
+
+
+
+
+
Designers build it themselves
+
+
+ At Hyperquake, designers have been making table interfaces on their own. They
+ describe what they want to an AI coding agent, watch it appear in Planchette, play
+ with it, change their minds, and carry the result to the real table to test. No
+ waiting for a developer to turn a sketch into something you can touch.
+
+
+ That works because every Planchette workspace comes with guidance written for the
+ agent: how big things should be, what a puck can do, what the table will and
+ won't tolerate. It knows the rules of the surface from the first prompt.
+
+
+
+
+
+
What's in the box
+
+
+
+ Arcane table. Runes bloom around every puck, and lightning arcs between pucks that come near each other.
+
+
+
+ Radial atlas. Turn a puck to browse a collection, tap its ring to go deeper and open a plate.
+
+
+
+ Dial demo. Every puck becomes a dial. The simplest complete example, and the place to start.
+
+
+
+
+
+
+
Get Planchette
+
Free, for macOS and Windows. Version {{VERSION}}{{CHANNEL}}.
+ Opening it the first time. Planchette isn't notarized by Apple yet,
+ so macOS will hesitate. Right-click the app and choose Open. On macOS 15 and
+ later, try to open it once, then go to System Settings, Privacy & Security,
+ and click Open Anyway. Once per machine.
+
+ Opening it the first time. The app isn't code signed yet, so
+ Windows may say it protected your PC. Click More info, then Run anyway. Once
+ per machine.
+
+
+
+
+ New to it? The getting started guide
+ takes you from install to your first interface. Older versions and release notes are on
+ GitHub.
+
+
+
+
+
Why it's free
+
+ Hyperquake designs and builds interactive installations, touch tables included. We
+ made Planchette to design our own, and we're giving it away because the work gets
+ better when more people can design for these surfaces. It's open source under the
+ MIT license. Found a bug? Tell us on GitHub.
+
+
+
+
+
+
+
+
+
diff --git a/site/media/app-inspector.jpg b/site/media/app-inspector.jpg
new file mode 100644
index 0000000..613453b
Binary files /dev/null and b/site/media/app-inspector.jpg differ
diff --git a/site/media/arcane-table.jpg b/site/media/arcane-table.jpg
new file mode 100644
index 0000000..15d59c2
Binary files /dev/null and b/site/media/arcane-table.jpg differ
diff --git a/site/media/dial-demo.jpg b/site/media/dial-demo.jpg
new file mode 100644
index 0000000..68096de
Binary files /dev/null and b/site/media/dial-demo.jpg differ
diff --git a/site/media/hyperquake-logotype-black.png b/site/media/hyperquake-logotype-black.png
new file mode 100644
index 0000000..c5b595f
Binary files /dev/null and b/site/media/hyperquake-logotype-black.png differ
diff --git a/site/media/loop-poster.jpg b/site/media/loop-poster.jpg
new file mode 100644
index 0000000..58b3e3a
Binary files /dev/null and b/site/media/loop-poster.jpg differ
diff --git a/site/media/loop.mp4 b/site/media/loop.mp4
new file mode 100644
index 0000000..6c79d94
Binary files /dev/null and b/site/media/loop.mp4 differ
diff --git a/site/media/loop.webm b/site/media/loop.webm
new file mode 100644
index 0000000..029528c
Binary files /dev/null and b/site/media/loop.webm differ
diff --git a/site/media/radial-atlas.jpg b/site/media/radial-atlas.jpg
new file mode 100644
index 0000000..2dce5aa
Binary files /dev/null and b/site/media/radial-atlas.jpg differ
diff --git a/site/media/reel.mp4 b/site/media/reel.mp4
new file mode 100644
index 0000000..cab643f
Binary files /dev/null and b/site/media/reel.mp4 differ
diff --git a/site/reel/card.css b/site/reel/card.css
new file mode 100644
index 0000000..6a49041
--- /dev/null
+++ b/site/reel/card.css
@@ -0,0 +1,13 @@
+/* Title cards for the reel. Rendered at 1920x1080 by record.mjs. */
+html, body { margin: 0; height: 100%; background: #fff; color: #000; }
+body {
+ font-family: "Untitled Sans", Helvetica, Arial, sans-serif;
+ display: grid; place-items: center; overflow: hidden;
+}
+.card { display: grid; justify-items: center; gap: 56px; text-align: center; }
+.mark { width: 168px; height: auto; }
+.lockup { width: 760px; height: auto; }
+h1 { font-weight: 400; font-size: 92px; line-height: 1.1; margin: 0; }
+p { font-size: 40px; line-height: 1.2; color: #808080; margin: 0; }
+.by { display: flex; align-items: center; gap: 28px; font-size: 36px; color: #808080; margin-top: 40px; }
+.by img { height: 40px; }
diff --git a/site/reel/end.html b/site/reel/end.html
new file mode 100644
index 0000000..6a32fda
--- /dev/null
+++ b/site/reel/end.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
Free for Mac and Windows
+
Made by
+
diff --git a/site/reel/record.mjs b/site/reel/record.mjs
new file mode 100644
index 0000000..e2ec436
--- /dev/null
+++ b/site/reel/record.mjs
@@ -0,0 +1,366 @@
+#!/usr/bin/env node
+/**
+ * Records the site's reel from the real simulator, frame by frame.
+ *
+ * npm run build # the reel records whatever is in dist/
+ * node site/reel/record.mjs # writes site/media/reel.mp4 and a poster
+ * node site/reel/record.mjs --stills # one still per scene per second, for framing
+ * node site/reel/record.mjs --scene radial-atlas
+ * node site/reel/record.mjs --shots # screenshots of the whole app, from SHOTS
+ *
+ * Why not a screen recording: the interfaces run a requestAnimationFrame loop at
+ * the table's full 3840x2160, and a laptop drops frames doing that while also
+ * encoding video. Here the page's clock is replaced, and each video frame is one
+ * exact step of it, so the result is smooth whatever the machine. Chrome's own
+ * virtual time was tried first and hangs once screenshots are taken.
+ *
+ * The one thing the shim cannot slow down is CSS transitions, which run on the
+ * real clock. The examples only use short fades, so they read slightly quicker.
+ *
+ * Needs Google Chrome and ffmpeg. Scenes, and their choreography in millimetres
+ * and degrees through window.sim, are in scenes.mjs.
+ */
+import { spawn } from 'node:child_process'
+import fs from 'node:fs/promises'
+import http from 'node:http'
+import os from 'node:os'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { SCENES, SHOTS, FPS, WIDTH, HEIGHT } from './scenes.mjs'
+
+const here = path.dirname(fileURLToPath(import.meta.url))
+const root = path.resolve(here, '../..')
+const dist = path.join(root, 'dist')
+const media = path.join(root, 'site', 'media')
+
+const args = process.argv.slice(2)
+const stills = args.includes('--stills')
+const shots = args.includes('--shots')
+const only = args.includes('--scene') ? args[args.indexOf('--scene') + 1] : null
+const CHROME = process.env.CHROME ?? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
+
+/* ---------------- static server for dist/ and the title cards ---------------- */
+
+const MIME = {
+ '.html': 'text/html',
+ '.js': 'text/javascript',
+ '.css': 'text/css',
+ '.json': 'application/json',
+ '.svg': 'image/svg+xml',
+ '.png': 'image/png',
+ '.jpg': 'image/jpeg',
+ '.ico': 'image/x-icon',
+ '.woff2': 'font/woff2',
+}
+const server = http.createServer(async (req, res) => {
+ const url = new URL(req.url, 'http://x')
+ // /cards/ serves this folder, /brand/ the repo's marks, everything else dist/.
+ let base = dist
+ let rel = decodeURIComponent(url.pathname)
+ if (rel.startsWith('/cards/')) [base, rel] = [here, rel.slice('/cards'.length)]
+ else if (rel.startsWith('/media/')) [base, rel] = [media, rel.slice('/media'.length)]
+ else if (rel.startsWith('/brand/')) [base, rel] = [path.join(root, 'brand'), rel.slice('/brand'.length)]
+ const file = path.join(base, path.normalize(rel))
+ if (!file.startsWith(base)) return res.writeHead(403).end()
+ try {
+ const body = await fs.readFile(file)
+ res.writeHead(200, { 'content-type': MIME[path.extname(file)] ?? 'application/octet-stream' }).end(body)
+ } catch {
+ res.writeHead(404).end()
+ }
+})
+await new Promise((r) => server.listen(0, '127.0.0.1', r))
+const ORIGIN = `http://127.0.0.1:${server.address().port}`
+
+/* ---------------- the clock every frame of the page runs on ---------------- */
+
+// Installed in every frame, the app iframe included. The top window drives its
+// children, so host and interface always agree on the time.
+const CLOCK = `(() => {
+ const realRaf = window.requestAnimationFrame.bind(window)
+ let now = 0
+ let queue = new Map()
+ let next = 1
+ const base = Date.now()
+ performance.now = () => now
+ Date.now = () => base + now
+ window.requestAnimationFrame = (cb) => { const id = next++; queue.set(id, cb); return id }
+ window.cancelAnimationFrame = (id) => { queue.delete(id) }
+ window.__step = (dt) => {
+ now += dt
+ const due = [...queue.values()]
+ queue = new Map()
+ for (const cb of due) { try { cb(now) } catch (e) { console.error(e) } }
+ for (const f of document.querySelectorAll('iframe')) { try { f.contentWindow.__step?.(dt) } catch {} }
+ }
+ // Until the recorder takes over, run in real time so the page can load.
+ if (window.top === window) {
+ window.__frozen = false
+ let last = 0
+ const tick = (t) => { if (window.__frozen) return; window.__step(last ? t - last : 16); last = t; realRaf(tick) }
+ realRaf(tick)
+ }
+})()`
+
+/* ---------------- Chrome over CDP ---------------- */
+
+const profile = await fs.mkdtemp(path.join(os.tmpdir(), 'planchette-reel-'))
+const chrome = spawn(
+ CHROME,
+ [
+ '--headless=new',
+ '--remote-debugging-port=0',
+ `--user-data-dir=${profile}`,
+ `--window-size=${WIDTH},${HEIGHT}`,
+ '--hide-scrollbars',
+ '--mute-audio',
+ '--force-device-scale-factor=1',
+ 'about:blank',
+ ],
+ { stdio: ['ignore', 'ignore', 'pipe'] },
+)
+const wsUrl = await new Promise((resolve, reject) => {
+ let buf = ''
+ chrome.stderr.on('data', (d) => {
+ buf += d
+ const m = buf.match(/DevTools listening on (ws:\/\/\S+)/)
+ if (m) resolve(m[1])
+ })
+ chrome.on('exit', () => reject(new Error('Chrome exited before DevTools came up')))
+})
+const port = new URL(wsUrl).port
+const targets = await (await fetch(`http://127.0.0.1:${port}/json`)).json()
+const ws = new WebSocket(targets.find((t) => t.type === 'page').webSocketDebuggerUrl)
+await new Promise((r) => (ws.onopen = r))
+let seq = 0
+const pending = new Map()
+const listeners = new Set()
+ws.onmessage = (m) => {
+ const d = JSON.parse(m.data)
+ if (d.id) pending.get(d.id)?.(d)
+ else for (const l of listeners) l(d)
+}
+const send = (method, params = {}) =>
+ new Promise((resolve, reject) => {
+ const id = ++seq
+ pending.set(id, (d) => (d.error ? reject(new Error(`${method}: ${d.error.message}`)) : resolve(d.result)))
+ ws.send(JSON.stringify({ id, method, params }))
+ })
+const once = (method) =>
+ new Promise((r) => {
+ const l = (d) => d.method === method && (listeners.delete(l), r(d))
+ listeners.add(l)
+ })
+const evaluate = async (expression) => {
+ const r = await send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true })
+ if (r.exceptionDetails) throw new Error(r.exceptionDetails.exception?.description ?? r.exceptionDetails.text)
+ return r.result.value
+}
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
+
+await send('Page.enable')
+await send('Runtime.enable')
+listeners.add(
+ (d) =>
+ d.method === 'Runtime.exceptionThrown' &&
+ console.error(' page error:', d.params.exceptionDetails.exception?.description ?? d.params.exceptionDetails.text),
+)
+await send('Emulation.setDeviceMetricsOverride', { width: WIDTH, height: HEIGHT, deviceScaleFactor: 1, mobile: false })
+await send('Page.addScriptToEvaluateOnNewDocument', { source: CLOCK })
+
+/* ---------------- record ---------------- */
+
+/** A method's source ("frame(t, s) {...}") is not an expression; make it one. */
+const source = (fn) => {
+ const src = fn.toString()
+ return /^(async\s+)?(function\b|\()/.test(src) ? src : `function ${src}`
+}
+
+async function record(scene, dir) {
+ const loaded = once('Page.loadEventFired')
+ await send('Page.navigate', { url: ORIGIN + scene.url })
+ await loaded
+ // Real time until the interface has loaded its content and said hello.
+ await sleep(scene.settleMs ?? 2500)
+ // The full app opens whatever it last showed; ?app= only applies to embeds.
+ if (scene.app) {
+ await evaluate(`sim.loadApp(${JSON.stringify(scene.app)})`)
+ await sleep(2500)
+ }
+ await evaluate('window.__frozen = true')
+ if (scene.setup) await evaluate(`(${source(scene.setup)})()`)
+ // The inspector's state persists in the profile, so set it every time.
+ if (scene.shot) await evaluate(`sim.showInspector(${Boolean(scene.inspector)})`)
+
+ const frames = Math.round(scene.seconds * FPS)
+ const every = stills ? FPS : 1
+ let written = 0
+ for (let i = 0; i < frames; i++) {
+ const t = i / FPS
+ if (scene.frame) await evaluate(`(${source(scene.frame)})(${t}, window.__reel ??= {})`)
+ await evaluate(`window.__step(${1000 / FPS})`)
+ // A shot is a scene played through and captured once, on its last frame.
+ if (scene.shot) {
+ if (i < frames - 1) continue
+ await sleep(300) // let DOM-only panels like the inspector paint
+ const shot = await send('Page.captureScreenshot', { format: 'jpeg', quality: 88 })
+ await fs.writeFile(path.join(dir, `${scene.id}.jpg`), Buffer.from(shot.data, 'base64'))
+ return 1
+ }
+ if (i % every) continue
+ const shot = await send('Page.captureScreenshot', { format: stills ? 'jpeg' : 'png', quality: 85 })
+ const name = stills
+ ? `${scene.id}-${String(t.toFixed(0)).padStart(2, '0')}s.jpg`
+ : `${String(written).padStart(5, '0')}.png`
+ await fs.writeFile(path.join(dir, name), Buffer.from(shot.data, 'base64'))
+ written++
+ }
+ return written
+}
+
+const ffmpeg = (argv) =>
+ new Promise((resolve, reject) => {
+ const p = spawn('ffmpeg', ['-y', '-loglevel', 'error', ...argv], { stdio: 'inherit' })
+ p.on('exit', (code) => (code ? reject(new Error(`ffmpeg exited ${code}`)) : resolve()))
+ })
+
+/** Joins clips with short crossfades into one web-sized mp4. */
+const FADE = 0.5
+async function join(clips, out) {
+ const inputs = clips.flatMap((c) => ['-i', c.clip])
+ let filter = ''
+ let prev = '[0:v]'
+ let offset = 0
+ for (let i = 1; i < clips.length; i++) {
+ offset += clips[i - 1].seconds - FADE
+ const label = i === clips.length - 1 ? '[v]' : `[x${i}]`
+ filter += `${prev}[${i}:v]xfade=transition=fade:duration=${FADE}:offset=${offset.toFixed(3)}${label};`
+ prev = label
+ }
+ const map = clips.length > 1 ? ['-filter_complex', filter.slice(0, -1), '-map', '[v]'] : []
+ await ffmpeg([
+ ...inputs,
+ ...map,
+ '-c:v',
+ 'libx264',
+ '-preset',
+ 'slow',
+ '-crf',
+ '23',
+ '-pix_fmt',
+ 'yuv420p',
+ '-movflags',
+ '+faststart',
+ '-an',
+ out,
+ ])
+}
+
+const work = await fs.mkdtemp(path.join(os.tmpdir(), 'planchette-reel-frames-'))
+try {
+ if (shots) {
+ // Screenshots of the whole app, toolbar and inspector included, at 2x for retina.
+ await fs.mkdir(media, { recursive: true })
+ for (const shot of SHOTS.filter((s) => !only || s.id === only)) {
+ await send('Emulation.setDeviceMetricsOverride', {
+ width: shot.width,
+ height: shot.height,
+ deviceScaleFactor: 2,
+ mobile: false,
+ })
+ await record({ ...shot, shot: true }, media)
+ console.log(`wrote site/media/${shot.id}.jpg`)
+ }
+ }
+ const chosen = shots ? [] : SCENES.filter((s) => !only || s.id === only)
+ if (shots) {
+ // done above
+ } else if (stills) {
+ const out = path.join(media, 'stills')
+ await fs.mkdir(out, { recursive: true })
+ for (const scene of chosen) console.log(`${scene.id}: ${await record(scene, out)} stills`)
+ console.log(`stills in ${out}`)
+ } else {
+ const clips = []
+ for (const scene of chosen) {
+ const dir = path.join(work, scene.id)
+ await fs.mkdir(dir)
+ const n = await record(scene, dir)
+ const clip = path.join(work, `${scene.id}.mp4`)
+ await ffmpeg([
+ '-framerate',
+ String(FPS),
+ '-i',
+ path.join(dir, '%05d.png'),
+ '-c:v',
+ 'libx264',
+ '-pix_fmt',
+ 'yuv420p',
+ '-crf',
+ '16',
+ clip,
+ ])
+ clips.push({ clip, seconds: n / FPS, scene })
+ // One still per demo, for the examples gallery on the page.
+ if (scene.still !== undefined) {
+ const frame = path.join(dir, `${String(Math.round(scene.still * FPS)).padStart(5, '0')}.png`)
+ await ffmpeg(['-i', frame, '-vf', 'scale=1280:-1', '-q:v', '3', path.join(media, `${scene.id}.jpg`)])
+ }
+ console.log(`${scene.id}: ${n} frames`)
+ }
+
+ // Two cuts from the same clips. The reel has the title cards and is for sharing;
+ // the loop is demos only and plays on the page, under a headline that already
+ // says what the title card would.
+ await fs.mkdir(media, { recursive: true })
+ if (only) {
+ await join(clips, path.join(media, `reel-${only}.mp4`))
+ } else {
+ await join(clips, path.join(media, 'reel.mp4'))
+ const demos = clips.filter((c) => !c.scene.card)
+ const loop = path.join(media, 'loop.mp4')
+ await join(demos, loop)
+ await ffmpeg([
+ '-i',
+ loop,
+ '-c:v',
+ 'libvpx-vp9',
+ '-b:v',
+ '0',
+ '-crf',
+ '36',
+ '-row-mt',
+ '1',
+ '-an',
+ path.join(media, 'loop.webm'),
+ ])
+ // The poster is the first demo that names a posterAt, at that moment of the loop.
+ let at = 1
+ let elapsed = 0
+ for (const c of demos) {
+ if (c.scene.posterAt !== undefined) {
+ at = elapsed + c.scene.posterAt
+ break
+ }
+ elapsed += c.seconds - FADE
+ }
+ await ffmpeg([
+ '-ss',
+ at.toFixed(2),
+ '-i',
+ loop,
+ '-frames:v',
+ '1',
+ '-q:v',
+ '3',
+ path.join(media, 'loop-poster.jpg'),
+ ])
+ }
+ console.log(`wrote ${path.relative(root, media)}`)
+ }
+} finally {
+ chrome.kill()
+ server.close()
+ await fs.rm(work, { recursive: true, force: true })
+ await fs.rm(profile, { recursive: true, force: true }).catch(() => {})
+}
diff --git a/site/reel/scenes.mjs b/site/reel/scenes.mjs
new file mode 100644
index 0000000..4c77d2b
--- /dev/null
+++ b/site/reel/scenes.mjs
@@ -0,0 +1,216 @@
+/**
+ * The reel, scene by scene. Each scene is a page and a choreography.
+ *
+ * `setup` and `frame` are serialized and run inside the page, so they must be
+ * self-contained: no closures over this module. `frame(t, s)` runs once per video
+ * frame with the scene time in seconds and a scratch object that persists across
+ * frames. Positions are millimetres on the 55" table (1218 x 685), angles are
+ * degrees with 0 up and clockwise positive, all through window.sim.
+ *
+ * `card: true` marks a title card: in reel.mp4, which is for sharing, and left out
+ * of loop.mp4, which plays on the page under a headline that already says it.
+ *
+ * `posterAt` (first scene that has one) picks the page's poster frame, and `still`
+ * writes media/.jpg for the examples gallery. Both are seconds into the scene.
+ *
+ * `setup` installs window.__k, a small keyframe helper:
+ * __k(t, [[t0, v0], [t1, v1], ...]) eased value at time t
+ */
+export const FPS = 30
+export const WIDTH = 1920
+export const HEIGHT = 1080
+
+const embed = (app, extra = '') => `/index.html?embed=1&puck=none&app=${app}${extra}`
+
+function prelude() {
+ sim.clear()
+ const ease = (x) => (x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2)
+ window.__k = (t, keys) => {
+ if (t <= keys[0][0]) return keys[0][1]
+ for (let i = 1; i < keys.length; i++) {
+ const [t1, v1] = keys[i]
+ const [t0, v0] = keys[i - 1]
+ if (t <= t1) return v0 + (v1 - v0) * ease((t - t0) / (t1 - t0))
+ }
+ return keys[keys.length - 1][1]
+ }
+ /** A touch that exists between t0 and t1, following a path of [t, x, y] keys. */
+ window.__touch = (s, key, t, t0, t1, keys) => {
+ const live = t >= t0 && t < t1
+ if (live && !s[key]) s[key] = sim.touch({ mmX: keys[0][1], mmY: keys[0][2] })
+ if (live && keys.length > 1) {
+ sim.moveTouch(s[key], {
+ mmX: __k(
+ t,
+ keys.map(([kt, x]) => [kt, x]),
+ ),
+ mmY: __k(
+ t,
+ keys.map(([kt, , y]) => [kt, y]),
+ ),
+ })
+ }
+ if (!live && s[key]) {
+ sim.endTouch(s[key])
+ s[key] = 0
+ }
+ }
+}
+
+export const SCENES = [
+ {
+ id: 'title',
+ card: true,
+ url: '/cards/title.html',
+ seconds: 3,
+ settleMs: 800,
+ },
+ {
+ id: 'arcane-table',
+ url: embed('arcane-table', '&zoom=0.72¢er=0.41,0.6'),
+ seconds: 9,
+ posterAt: 6,
+ still: 6.5,
+ setup: prelude,
+ frame(t, s) {
+ if (!s.a) s.a = sim.addPuck({ markerId: 1, mmX: 330, mmY: 360, angleDeg: 0 })
+ sim.movePuck(s.a, { mmX: 330 + 40 * Math.sin(t * 0.5), mmY: 360 + 20 * Math.sin(t * 0.7), angleDeg: t * 22 })
+
+ if (t >= 1.2 && !s.b) s.b = sim.addPuck({ markerId: 2, mmX: 1000, mmY: 190, angleDeg: 40 })
+ if (s.b)
+ sim.movePuck(s.b, {
+ mmX: __k(t, [
+ [1.2, 1000],
+ [4.2, 650],
+ ]),
+ mmY: __k(t, [
+ [1.2, 190],
+ [4.2, 290],
+ ]),
+ angleDeg: __k(t, [
+ [1.2, 40],
+ [9, -90],
+ ]),
+ })
+
+ if (t >= 3.6 && !s.c) s.c = sim.addPuck({ markerId: 3, mmX: 620, mmY: 590, angleDeg: 0 })
+ if (s.c)
+ sim.movePuck(s.c, {
+ mmX: __k(t, [
+ [3.6, 620],
+ [7, 520],
+ ]),
+ mmY: __k(t, [
+ [3.6, 590],
+ [7, 520],
+ ]),
+ angleDeg: __k(t, [
+ [3.6, 0],
+ [9, 140],
+ ]),
+ })
+
+ __touch(
+ s,
+ 'f',
+ t,
+ 5.2,
+ 8.2,
+ [
+ [5.2, 900],
+ [8.2, 760],
+ ].map(([kt, x]) => [kt, x, 480 - (x - 760) * 0.4]),
+ )
+ },
+ },
+ {
+ id: 'radial-atlas',
+ url: embed('radial-atlas', '&zoom=1.05¢er=0.43,0.47'),
+ seconds: 11,
+ still: 8,
+ setup: prelude,
+ frame(t, s) {
+ const X = 380
+ const Y = 340
+ if (!s.p) s.p = sim.addPuck({ markerId: 1, mmX: X, mmY: Y, angleDeg: 0 })
+ const angle = __k(t, [
+ [0.5, 0],
+ [2.6, 100],
+ [3.9, 100],
+ [5.6, 165],
+ [11, 175],
+ ])
+ sim.movePuck(s.p, { angleDeg: angle })
+ // Touch the inner ring to drill in, then the outer ring to open a plate.
+ const at = (r, deg) => [X + r * Math.sin((deg * Math.PI) / 180), Y - r * Math.cos((deg * Math.PI) / 180)]
+ const [ix, iy] = at(64, 230)
+ __touch(s, 'in', t, 3.0, 3.35, [[3.0, ix, iy]])
+ const [ox, oy] = at(118, 250)
+ __touch(s, 'out', t, 6.2, 6.55, [[6.2, ox, oy]])
+ },
+ },
+ {
+ id: 'dial-demo',
+ url: embed('dial-demo', '&zoom=0.95¢er=0.505,0.56'),
+ seconds: 7,
+ still: 4.5,
+ setup: prelude,
+ frame(t, s) {
+ if (!s.a) s.a = sim.addPuck({ markerId: 1, mmX: 430, mmY: 360, angleDeg: 0 })
+ if (!s.b) s.b = sim.addPuck({ markerId: 2, mmX: 800, mmY: 330, angleDeg: 90 })
+ sim.movePuck(s.a, {
+ angleDeg: __k(t, [
+ [0.3, 0],
+ [2.2, 135],
+ [4.6, 135],
+ [6.2, 225],
+ ]),
+ })
+ sim.movePuck(s.b, {
+ angleDeg: __k(t, [
+ [0.8, 90],
+ [3.0, -45],
+ ]),
+ })
+ const at = (x, y, deg) => [x + 62 * Math.sin((deg * Math.PI) / 180), y - 62 * Math.cos((deg * Math.PI) / 180)]
+ const [ax, ay] = at(430, 360, 135)
+ __touch(s, 'a', t, 2.7, 3.05, [[2.7, ax, ay]])
+ const [bx, by] = at(800, 330, -45)
+ __touch(s, 'b', t, 3.6, 3.95, [[3.6, bx, by]])
+ },
+ },
+ {
+ id: 'end',
+ card: true,
+ url: '/cards/end.html',
+ seconds: 3.5,
+ settleMs: 800,
+ },
+]
+
+/**
+ * Screenshots of the whole app, written to media/.jpg by `record.mjs --shots`.
+ * Same shape as a scene, played for `seconds` and captured on the last frame, in
+ * the full authoring UI rather than embed mode.
+ */
+export const SHOTS = [
+ {
+ id: 'app-inspector',
+ url: '/index.html',
+ app: 'arcane-table',
+ width: 1440,
+ height: 860,
+ seconds: 3,
+ setup: prelude,
+ inspector: true,
+ frame(t, s) {
+ if (s.done) return
+ s.done = true
+ sim.addPuck({ markerId: 3, mmX: 430, mmY: 330, angleDeg: 25 })
+ sim.addPuck({ markerId: 7, mmX: 655, mmY: 430, angleDeg: 200 })
+ sim.addPuck({ markerId: 12, mmX: 830, mmY: 275, angleDeg: 310 })
+ sim.addPuck({ markerId: 5, mmX: 560, mmY: 180, angleDeg: 95 })
+ sim.touch({ mmX: 655, mmY: 358 })
+ },
+ },
+]
diff --git a/site/reel/title.html b/site/reel/title.html
new file mode 100644
index 0000000..b4a028e
--- /dev/null
+++ b/site/reel/title.html
@@ -0,0 +1,7 @@
+
+
+
+