diff --git a/.prettierignore b/.prettierignore index 130981e..84021d3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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 diff --git a/site/.gitignore b/site/.gitignore index ca8b0a7..3fbc0d1 100644 --- a/site/.gitignore +++ b/site/.gitignore @@ -1,3 +1,4 @@ _build/ .cache/ media/stills/ +reel/guests/ diff --git a/site/build.mjs b/site/build.mjs index 83a97ea..220b239 100644 --- a/site/build.mjs +++ b/site/build.mjs @@ -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', ] diff --git a/site/index.html b/site/index.html index 8921519..dba82bf 100644 --- a/site/index.html +++ b/site/index.html @@ -115,6 +115,17 @@

Designers build it themselves

won't tolerate. It knows the rules of the surface from the first prompt.

+
+
+ Riftfall: three pucks near the table's edges acting as laser turrets, firing at warheads streaming out of a purple rift in the centre +
Riftfall. 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.
+
+
+ Air hockey: a blue and an orange puck acting as mallets on either side of a rink, with a white puck between them +
Air hockey. Any puck or finger on your half is a mallet, so it plays one on one or two on two.
+
+
+

Two games our designers made on a testing day, just for fun.

diff --git a/site/media/air-hockey.jpg b/site/media/air-hockey.jpg new file mode 100644 index 0000000..18c8e06 Binary files /dev/null and b/site/media/air-hockey.jpg differ diff --git a/site/media/arcane-table.jpg b/site/media/arcane-table.jpg index 15d59c2..220d55f 100644 Binary files a/site/media/arcane-table.jpg and b/site/media/arcane-table.jpg differ diff --git a/site/media/loop-poster.jpg b/site/media/loop-poster.jpg index 58b3e3a..ff8b48c 100644 Binary files a/site/media/loop-poster.jpg and b/site/media/loop-poster.jpg differ diff --git a/site/media/loop.mp4 b/site/media/loop.mp4 index 6c79d94..df0e9dc 100644 Binary files a/site/media/loop.mp4 and b/site/media/loop.mp4 differ diff --git a/site/media/loop.webm b/site/media/loop.webm index 029528c..087b23b 100644 Binary files a/site/media/loop.webm and b/site/media/loop.webm differ diff --git a/site/media/reel.mp4 b/site/media/reel.mp4 index cab643f..cceb1fe 100644 Binary files a/site/media/reel.mp4 and b/site/media/reel.mp4 differ diff --git a/site/media/riftfall.jpg b/site/media/riftfall.jpg new file mode 100644 index 0000000..40c1f32 Binary files /dev/null and b/site/media/riftfall.jpg differ diff --git a/site/reel/record.mjs b/site/reel/record.mjs index e2ec436..2281931 100644 --- a/site/reel/record.mjs +++ b/site/reel/record.mjs @@ -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//, 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. */ @@ -32,6 +37,7 @@ 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') @@ -39,6 +45,12 @@ 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 = { @@ -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 = '' + return res.writeHead(200, { 'content-type': 'text/html' }).end(html.replace(//i, `${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)) @@ -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)})`) diff --git a/site/reel/scenes.mjs b/site/reel/scenes.mjs index 4c77d2b..6b35cb2 100644 --- a/site/reel/scenes.mjs +++ b/site/reel/scenes.mjs @@ -13,6 +13,9 @@ * `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. * + * `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 */ @@ -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, diff --git a/site/style.css b/site/style.css index 195a28b..429db68 100644 --- a/site/style.css +++ b/site/style.css @@ -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; } @@ -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; } }