Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ public/favicon.svg
# The site build output and its cached copy of a release web build.
site/_build
site/.cache
site/reel/guests
1 change: 1 addition & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_build/
.cache/
media/stills/
reel/guests/
2 changes: 2 additions & 0 deletions site/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const MEDIA = [
'arcane-table.jpg',
'radial-atlas.jpg',
'dial-demo.jpg',
'riftfall.jpg',
'air-hockey.jpg',
'app-inspector.jpg',
'hyperquake-logotype-black.png',
]
Expand Down
11 changes: 11 additions & 0 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ <h2>Designers build it themselves</h2>
won't tolerate. It knows the rules of the surface from the first prompt.
</p>
</div>
<div class="cards two">
<figure>
<img src="media/riftfall.jpg" alt="Riftfall: three pucks near the table's edges acting as laser turrets, firing at warheads streaming out of a purple rift in the centre" loading="lazy">
<figcaption><strong>Riftfall.</strong> Co-op missile defence. Every puck is a laser turret: turn it to aim, tap its button to fire, and keep the cities at the edges alive.</figcaption>
</figure>
<figure>
<img src="media/air-hockey.jpg" alt="Air hockey: a blue and an orange puck acting as mallets on either side of a rink, with a white puck between them" loading="lazy">
<figcaption><strong>Air hockey.</strong> Any puck or finger on your half is a mallet, so it plays one on one or two on two.</figcaption>
</figure>
</div>
<p class="cards-note">Two games our designers made on a testing day, just for fun.</p>
</section>

<section id="examples" class="examples wrap">
Expand Down
Binary file added site/media/air-hockey.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified site/media/arcane-table.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified site/media/loop-poster.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified site/media/loop.mp4
Binary file not shown.
Binary file modified site/media/loop.webm
Binary file not shown.
Binary file modified site/media/reel.mp4
Binary file not shown.
Binary file added site/media/riftfall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 37 additions & 7 deletions site/reel/record.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
* 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.
*
* Designers' own interfaces can join the reel from site/reel/guests/<id>/, which
* is not in git: their authors decide what is published as code. Riftfall and
* air hockey came from a designers' testing day (Slack, 2026-11-19); without
* them, those two scenes cannot be re-recorded and should be removed from scenes.mjs.
*
* Needs Google Chrome and ffmpeg. Scenes, and their choreography in millimetres
* and degrees through window.sim, are in scenes.mjs.
*/
Expand All @@ -32,13 +37,20 @@ 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 guests = path.join(here, 'guests')

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'

/** 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}`
}

/* ---------------- static server for dist/ and the title cards ---------------- */

const MIME = {
Expand All @@ -55,9 +67,23 @@ const MIME = {
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/.
// Interfaces in guests/ (designers' work, not in git) are served as examples.
let base = dist
let rel = decodeURIComponent(url.pathname)
if (rel.startsWith('/cards/')) [base, rel] = [here, rel.slice('/cards'.length)]
const guest = rel.match(/^\/examples\/([^/]+)\//)
if (guest && (await fs.stat(path.join(guests, guest[1])).catch(() => null))) {
;[base, rel] = [guests, rel.slice('/examples'.length)]
// A raw interface imports bare specifiers; give it the same import map the
// desktop app injects, pointing at dist's self-contained builds.
if (rel.endsWith('/index.html')) {
const file = path.join(base, path.normalize(rel))
if (!file.startsWith(base)) return res.writeHead(403).end()
const html = await fs.readFile(file, 'utf8').catch(() => null)
if (html === null) return res.writeHead(404).end()
const map = '<script type="importmap">{"imports":{"@planchette/sdk":"/sdk.js","three":"/three.js"}}</script>'
return res.writeHead(200, { 'content-type': 'text/html' }).end(html.replace(/<head>/i, `<head>${map}`))
}
} else 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))
Expand Down Expand Up @@ -167,21 +193,25 @@ listeners.add(
)
await send('Emulation.setDeviceMetricsOverride', { width: WIDTH, height: HEIGHT, deviceScaleFactor: 1, mobile: false })
await send('Page.addScriptToEvaluateOnNewDocument', { source: CLOCK })
// Recording-only hooks a scene needs inside an interface, such as reading state
// the interface keeps private. Each one checks its own page before acting.
for (const s of SCENES)
if (s.inject) await send('Page.addScriptToEvaluateOnNewDocument', { source: `(${source(s.inject)})()` })

/* ---------------- 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)
// A guest interface is not in the build's list, so the host would fall back to
// dial-demo. Point its frame at the guest directly; the handshake does not care.
if (scene.guest) {
await evaluate(`document.getElementById('appframe').src = './examples/${scene.guest}/index.html'`)
await sleep(scene.guestSettleMs ?? 3000)
}
// The full app opens whatever it last showed; ?app= only applies to embeds.
if (scene.app) {
await evaluate(`sim.loadApp(${JSON.stringify(scene.app)})`)
Expand Down
139 changes: 139 additions & 0 deletions site/reel/scenes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* `posterAt` (first scene that has one) picks the page's poster frame, and `still`
* writes media/<id>.jpg for the examples gallery. Both are seconds into the scene.
*
* `inject`, if present, runs in every frame of every page before it loads, for
* recording-only hooks; it must check which page it is on.
*
* `setup` installs window.__k, a small keyframe helper:
* __k(t, [[t0, v0], [t1, v1], ...]) eased value at time t
*/
Expand Down Expand Up @@ -179,6 +182,142 @@ export const SCENES = [
__touch(s, 'b', t, 3.6, 3.95, [[3.6, bx, by]])
},
},
// Two games designers made on a testing day, just for fun. Their code lives in
// guests/ (not in git); see record.mjs. Both are played by a script that reads
// the game's state, so the turrets and mallets respond to what actually happens.
{
id: 'riftfall',
url: embed('dial-demo'),
guest: 'riftfall',
guestSettleMs: 4000, // waits for the pixel font
seconds: 11.5,
still: 9,
setup: prelude,
frame(t, s) {
const g = document.getElementById('appframe').contentWindow.riftfall
if (!g) return
const turrets = [
{ m: 1, x: 420, y: 585 },
{ m: 2, x: 800, y: 585 },
{ m: 3, x: 610, y: 100 },
]
if (!s.ids) {
s.ids = turrets.map((p) => sim.addPuck({ markerId: p.m, mmX: p.x, mmY: p.y, angleDeg: p.y > 300 ? 0 : 180 }))
s.aim = turrets.map((p) => (p.y > 300 ? 0 : 180))
}
// Aim each turret at the warhead nearest it, leading the shot, turning at
// a believable hand speed rather than snapping.
turrets.forEach((p, i) => {
let best = null
for (const w of g.warheads) {
if (w.dead) continue
const d = Math.hypot(w.x - p.x, w.y - p.y)
if (!best || d < best.d) best = { w, d }
}
if (!best) return
const lead = best.d / 750
const tx = best.w.x + best.w.ux * best.w.speed * lead
const ty = best.w.y + best.w.uy * best.w.speed * lead
const want = (Math.atan2(tx - p.x, -(ty - p.y)) * 180) / Math.PI
let delta = ((((want - s.aim[i]) % 360) + 540) % 360) - 180
delta = Math.max(-12, Math.min(12, delta))
s.aim[i] += delta
sim.movePuck(s.ids[i], { angleDeg: s.aim[i] })
})
// Tap power buttons where the game says they are: the first one starts
// the game, then everyone switches on as the first wave arrives.
const tap = (key, i, t0) => {
const b = g.buttonPos(turrets[i].x, turrets[i].y)
__touch(s, key, t, t0, t0 + 0.2, [[t0, b.x, b.y]])
}
tap('a1', 0, 0.6)
tap('a2', 0, 1.3)
tap('a3', 0, 3.0)
tap('b', 1, 3.1)
tap('c', 2, 3.2)
},
},
{
id: 'air-hockey',
url: embed('dial-demo'),
guest: 'air-hockey',
seconds: 9,
still: 4,
// Air hockey keeps its puck private. It draws it with a 27.5mm radius, which
// nothing else on that canvas uses, so note where that circle is drawn.
inject() {
if (!location.pathname.includes('/air-hockey/')) return
const arc = CanvasRenderingContext2D.prototype.arc
CanvasRenderingContext2D.prototype.arc = function (x, y, r, ...rest) {
if (r === 27.5) window.__hockeyPuck = { x, y, at: performance.now() }
return arc.call(this, x, y, r, ...rest)
}
},
setup: prelude,
frame(t, s) {
const W = 1218
const H = 685
const app = document.getElementById('appframe').contentWindow
const seen = app.__hockeyPuck
const P = seen && app.performance.now() - seen.at < 100 ? seen : null
if (!s.m) {
s.m = {
w: { id: sim.addPuck({ markerId: 1, mmX: 130, mmY: H / 2 }), x: 130, y: H / 2, aimY: 0 },
e: { id: sim.addPuck({ markerId: 2, mmX: W - 130, mmY: H / 2 }), x: W - 130, y: H / 2, aimY: 0 },
}
}
const R = 30 + 27.5
for (const side of ['w', 'e']) {
const m = s.m[side]
const home = side === 'w' ? 130 : W - 130
const oppX = side === 'w' ? W : 0
// The puck faces off exactly on the centre line; west takes it.
const mine = P && (side === 'w' ? P.x <= W / 2 : P.x > W / 2)
let tx = home
let ty = P ? Math.max(H / 2 - 130, Math.min(H / 2 + 130, P.y)) : H / 2
let speed = 900
if (mine) {
// Pick a spot in the far goal, aiming off the walls now and then.
if (!m.aimY || m.shotAt !== s.shots) m.aimY = H / 2 + (Math.random() - 0.5) * 260
let gx = oppX - P.x
let gy = m.aimY - P.y
const gl = Math.hypot(gx, gy)
gx /= gl
gy /= gl
const front = (m.x - P.x) * gx + (m.y - P.y) * gy > -R * 0.5
if (front) {
// In front of the puck: go round it, not through it toward our own goal.
const px = -gy
const py = gx
const sgn = (m.x - P.x) * px + (m.y - P.y) * py >= 0 ? 1 : -1
tx = P.x - gx * R + px * sgn * (R + 45)
ty = P.y - gy * R + py * sgn * (R + 45)
speed = 1500
} else if (Math.hypot(m.x - (P.x - gx * (R + 20)), m.y - (P.y - gy * (R + 20))) > 25) {
tx = P.x - gx * (R + 20)
ty = P.y - gy * (R + 20)
speed = 1600
} else {
tx = P.x + gx * 140
ty = P.y + gy * 140
speed = 2600
s.shots = (s.shots ?? 0) + 0.02
}
}
const dx = tx - m.x
const dy = ty - m.y
const d = Math.hypot(dx, dy)
const step = Math.min(d, speed / 30)
if (d > 0.5) {
m.x += (dx / d) * step
m.y += (dy / d) * step
}
m.x = side === 'w' ? Math.max(35, Math.min(W / 2 - 35, m.x)) : Math.max(W / 2 + 35, Math.min(W - 35, m.x))
m.y = Math.max(35, Math.min(H - 35, m.y))
sim.movePuck(m.id, { mmX: m.x, mmY: m.y })
}
},
},
{
id: 'end',
card: true,
Expand Down
6 changes: 5 additions & 1 deletion site/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ section h2 { font-size: clamp(30px, 4vw, 44px); line-height: 1.1; }
.shot { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--grey2); }

.story { display: grid; grid-template-columns: 1fr 1.6fr; gap: 48px; align-items: start; }
.story .cards { grid-column: 1 / -1; margin-top: 8px; }
.cards.two { grid-template-columns: repeat(2, 1fr); }
.cards-note { grid-column: 1 / -1; margin-top: -24px; font-size: 15px; color: var(--grey3); }
.story-body { display: grid; gap: 20px; font-size: 21px; line-height: 1.45; }

.examples h2 { margin-bottom: 32px; }
Expand Down Expand Up @@ -115,7 +118,8 @@ footer { margin-top: 120px; padding: 32px 0 48px; border-top: 1px solid var(--gr
/* ---------------- small screens ---------------- */

@media (max-width: 860px) {
.points, .cards, .platforms, .story, .why { grid-template-columns: 1fr; gap: 32px; }
.points, .cards, .cards.two, .platforms, .story, .why { grid-template-columns: 1fr; gap: 32px; }
.cards-note { margin-top: -8px; }
.download { padding: 32px 20px; }
section + section { margin-top: 80px; }
}
Expand Down
Loading