Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: shared corner-stack for floating widgets + Walk Playground polish

nirholasa0ef7ff876a4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1977038e5..ed3d654fa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,7 +16,9 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **AR & half-body avatar export fixed for compressed models** — View-in-AR (USDZ for iOS Quick Look) and the half-body VR-seat export now work for avatars that ship with meshopt or Draco geometry compression. Previously these exports silently failed on compressed GLBs because the loader had no decoder registered; the pipeline now loads the meshopt and Draco decoders before parsing, so every avatar — including the compressed ones produced by the server-side bake — converts cleanly. (`/gallery`) `[fix]`
- **AR agents hold their place and size when you rotate your phone** — Camera AR used to assume you were holding your phone upright. Rotate to landscape — or just have the browser's toolbar slide away as you scroll — and a pinned agent could quietly change size or drift off the real-world spot you placed it on. IRL now re-reads your camera's lens and your screen's orientation the instant either changes, so the agent keeps its true scale and stays locked to its spot whether you hold the phone portrait or sideways. The motion-sensor lock that rotates the view as you turn now understands landscape too, so panning around the agent stays smooth and accurate, and the rapid resizing iPhone Safari does while scrolling no longer makes the scene stutter. (`/irl`) `[improvement, fix]`
- **Brain Studio — build your agent’s mind as a visual circuit** — The Brain tab in Agent Studio is now a visual node editor: wire Persona, Model, Memory, Skills, and trading-reasoning nodes into a living graph that IS your agent’s personality. Pick from real LLMs (Claude, GPT, Granite and more) per branch, connect a memory port that recalls and writes real memories, and watch the active path light up as your agent thinks — tokens streaming, memory firing, the avatar reacting live. A built-in test chat runs your graph against the real models with real latency and token stats, and forkable templates (Sniper, Scalper, Researcher, Companion) get you started in one click. Your graph compiles straight to your agent’s persona so every existing chat surface picks up the change. (`/agent-studio`) `[feature]`
+- **Cleaner Pole Club bass — no more speaker distortion** — Fixed the buzzy bass distortion some listeners heard at the Pole Club, especially on laptop and phone speakers. The club's low-end was being boosted hard enough to clip the audio output when several tracks overlapped; we've added a brick-wall limiter on the final mix, evened out the reverb so it adds a predictable amount of space, and dialed the bass boost back to a level that still hits hard without overdriving. The room now sounds full and clean at any volume. (`/club`) `[fix]`
- **Clearer IRL onboarding and copy** — Opening IRL for the first time now spells out the core loop in plain words: turn on Camera AR, aim at the spot you want, then tap Pin here to anchor your agent in real space. The on-screen guidance updates as you go — it points you to the next step before you've pinned, and confirms when your agent is anchored. We rewrote the status messages around pinning to be calm and literal instead of technical or alarming: waiting on a GPS fix now tells you it's quicker outdoors, pinning without location explains your agent is saved on this device until you turn location on, and a missing compass reads as a gentle note rather than a warning. The caption keyboard now opens reliably when the panel slides up on iPhone. (`/irl`) `[improvement]`
+- **Corner helper cards no longer pile up and hide page content** — The small helper cards that live in the bottom-right corner — the "Getting started" guide, the "have you tried…" feature tips, and the "Your agent is ready" welcome card — each positioned themselves independently, so on many pages they stacked on the exact same spot and covered each other and the content behind them (most visibly the Deploy page's Live Preview). They now share a single tidy stack that flows them vertically, so they never overlap one another or the page. The welcome card also no longer follows you onto the Deploy and Explore pages, where it had nothing to do. (`/deploy`) `[fix, improvement]`
- **Creator royalty payouts protected against double-settlement** — Royalty payouts to skill authors now claim each pending amount atomically before sending funds on-chain, so two overlapping settlement runs can never pay the same balance twice. Creators are paid exactly once for what they've earned. `[fix]`
- **Discovery now shows only real creator avatars** — The Explore / discovery feed previously padded itself with a set of built-in sample avatars and counted them in the totals. The feed and its counts now reflect only real avatars created by the community — no filler. (`/explore`) `[improvement]`
- **Drop agents on your real floor with AR precision** — On Android phones that support AR, placing an agent in your room is now pinpoint: point at the floor, a reticle locks onto the real ground, and you tap to drop the agent exactly where you're looking — feet on the actual floor, not floating at a guess. It anchors into the same shared room as the rest of your agents, so everyone who opens IRL at that spot — including iPhones — sees it in the same place, and you can re-tap “Refine on floor” on one of your agents to sharpen just its spot without nudging the others. iPhones and phones without AR keep the aim-and-distance flow they already had, with no extra buttons and nothing that doesn't work — every device gets the best placement it can do. (`/irl`) `[feature]`
@@ -42,7 +44,6 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Live x402 payment challenges on the IBM partnership page** — The “Accelerating outcomes” section on the IBM × three.ws page had two empty gradient boxes under its AI agents and Crypto tabs. They're now live: each reads a real three.ws endpoint's HTTP 402 response on the spot and shows the exact terms the server is quoting — price in USDC, settlement network, and recipient. The AI agents tab shows what an autonomous agent reads before paying for live market data; the Crypto tab shows how any endpoint becomes pay-per-call. No wallet needed to watch it. (`/ibm/x402-demo`) `[improvement]`
- **Memory Studio — watch your agent’s memory form, curate it, and trust it** — The Memory tab in Agent Studio turns your agent’s memory into something you can see and shape. A live Timeline streams every memory as it forms — chats, lessons, rules, trades — each tagged by tier (working, recall, archival) and salience, with one-click pin, edit, merge, forget, and a slider to dial importance. A knowledge Graph maps the coins, wallets, people, and strategies your agent has learned, linked by what shows up together; click any coin to replay how your agent’s understanding of it evolved over time. Recall runs real semantic search over real embeddings, so asking “lessons from losing trades” or “rules my agent follows” returns what it actually knows — and an In-Context view shows exactly what the agent carries into every reply, with a live token budget so the core stays sharp. Seed it in seconds from your GitHub, X, and Farcaster, and the Brain’s Memory node recalls all of it for real. (`/agent-studio`) `[feature]`
- **Mobile menu plays nicely with screen readers and keyboards** — The mobile navigation drawer now fully hides itself from assistive tech and the keyboard tab order when it's closed, instead of leaving its links reachable but invisible. Screen-reader and keyboard users can no longer land focus on a link inside a collapsed menu, and the browser's accessibility warning about hidden-but-focused links is gone. `[fix]`
-- **Onboarding card no longer covers the Deploy page preview** — The "Your agent is ready" pop-up — the welcome card that helps you find your way around the 3D viewer — was following you onto the Deploy on-chain page and floating over the Live Preview panel, hiding your agent's avatar, name, and cost summary right when you needed to check them before minting. The card now knows it belongs to the 3D viewer and stays out of the Deploy and Explore pages, so the preview is fully visible again. (`/deploy`) `[fix]`
- **One API, many services: the three.ws API gateway** — We bundled a stack of popular third-party APIs behind a single three.ws API so you can reach them all with one integration, one key, and one bill. The first providers are live at /api/v1/x — CoinGecko (live prices and ranked market data), DefiLlama (protocol TVL across all of DeFi), and any OpenAI-compatible LLM — with more landing over the coming releases. Discover everything with one call to GET /api/v1, which returns the full catalog: every provider, endpoint, parameter, and price. You can pay three ways, your choice per call: bring your own upstream key (we just route it, no markup), use a three.ws API key on your plan, or pay-per-call in USDC with no account at all. Every response uses one consistent shape with standard rate-limit headers, and the platform's own capabilities — text sentiment, market and narrative intelligence, and verified agent-card lookups — live under the same /api/v1 surface. `[feature, sdk]`
- **Paid doors stay open when one payment network is down** — Every pay-per-call endpoint — the Pole Club cover charge, agent-to-agent calls, asset downloads — now offers each payment network independently. If Base is fully wired but Solana is missing a setting (or vice versa), you still get a working payment prompt on the network that's ready, instead of the whole door hard-failing. A network is advertised only when every piece it needs is in place, so a checkout can no longer be offered and then rejected mid-payment. The endpoint only declines outright when no network at all can take the payment. `[fix]`
- **Paid market-intel never charges you for unavailable data** — The pay-per-call market-intel endpoints (the $THREE Town Oracle and the crypto-intel kiosk) used to hand back an estimated "neutral" reading — and still take the payment — when their live price feed was rate-limited. They now return a clean "temporarily unavailable, retry shortly" instead, and crucially the payment is never settled when live data is missing. You only pay when you get a real, live signal. `[fix]`
@@ -64,7 +65,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Unity & Unreal avatar loading documented with code that actually works** — The developer hub's Unity and Unreal cards used to show sample code for an SDK that doesn't exist yet. They now show the real, working way to load a three.ws avatar today — your avatar's GLB endpoint loaded at runtime with glTFast (Unity) or glTFRuntime (Unreal), both standard glTF importers — alongside an honest note that a native package is still on the roadmap. (`/dashboard/developers`) `[docs, improvement]`
- **Vanity wallets for every agent — opt-in, owned per user** — Every agent and avatar has its own custodial Solana wallet, and you own it per creation: make an avatar and its agent wallet is yours; if someone forks or saves that avatar, they get a brand-new wallet they alone control — yours is never shared or copied. A new Vanity tab in the agent wallet hub lets you grind a custom address (your own prefix and/or suffix) on demand. If the wallet already holds funds, they're automatically and safely swept to the new address before the switch completes, so funds are never stranded. The wallet now appears everywhere an agent or avatar shows up — profiles, avatar pages, your Agents and Avatars dashboards, the Characters feed and Trending — each with one-tap copy, an explorer link, and a vanity badge. (`/vanity-wallet`) `[feature]`
- **Walk Playground no longer loses your character when it falls** — When you walked the little robot off a ledge it could plummet faster than the page could keep up and slip off the bottom of the screen, leaving you unable to find it. The camera now tracks falls tightly and keeps the character in view, and on pages that can't scroll it catches the character and drops it right back into view. (`/features/walk`) `[fix]`
-- **Walk the whole page — the site is now a platformer** — The corner walking companion can now step out of its spot. Click it and the character detaches and drops onto the page itself: headings, cards, buttons and images become solid ground you can walk and jump across with the arrow keys or WASD (on-screen buttons on phones). Stand on any link and it lights up like a trapdoor — pause on it, or press down, and the character dives through and you fall into the next page, landing back in from the top when it loads. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play. `[feature]`
+- **Walk the whole page — the site is now a playground** — The corner walking companion can now step out of its spot. Click it and the character detaches into a gentle bird's-eye view of the page, and you steer him anywhere across it with the arrow keys or WASD (an on-screen d-pad on phones) — no falling, just free roaming over the whole page. Step onto any link and it lights up like a doorway; pause on it or press the dive key and the character drops through, and you fall into the next page, arriving on the other side. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play. `[feature]`
## 2026-06-18
diff --git a/data/changelog.json b/data/changelog.json
index b49b387b2..fa9a7b063 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -3,10 +3,11 @@
"entries": [
{
"date": "2026-06-19",
- "title": "Onboarding card no longer covers the Deploy page preview",
- "summary": "The \"Your agent is ready\" pop-up — the welcome card that helps you find your way around the 3D viewer — was following you onto the Deploy on-chain page and floating over the Live Preview panel, hiding your agent's avatar, name, and cost summary right when you needed to check them before minting. The card now knows it belongs to the 3D viewer and stays out of the Deploy and Explore pages, so the preview is fully visible again.",
+ "title": "Corner helper cards no longer pile up and hide page content",
+ "summary": "The small helper cards that live in the bottom-right corner — the \"Getting started\" guide, the \"have you tried…\" feature tips, and the \"Your agent is ready\" welcome card — each positioned themselves independently, so on many pages they stacked on the exact same spot and covered each other and the content behind them (most visibly the Deploy page's Live Preview). They now share a single tidy stack that flows them vertically, so they never overlap one another or the page. The welcome card also no longer follows you onto the Deploy and Explore pages, where it had nothing to do.",
"tags": [
- "fix"
+ "fix",
+ "improvement"
],
"link": "/deploy"
},
@@ -80,8 +81,8 @@
},
{
"date": "2026-06-19",
- "title": "Walk the whole page — the site is now a platformer",
- "summary": "The corner walking companion can now step out of its spot. Click it and the character detaches and drops onto the page itself: headings, cards, buttons and images become solid ground you can walk and jump across with the arrow keys or WASD (on-screen buttons on phones). Stand on any link and it lights up like a trapdoor — pause on it, or press down, and the character dives through and you fall into the next page, landing back in from the top when it loads. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play.",
+ "title": "Walk the whole page — the site is now a playground",
+ "summary": "The corner walking companion can now step out of its spot. Click it and the character detaches into a gentle bird's-eye view of the page, and you steer him anywhere across it with the arrow keys or WASD (an on-screen d-pad on phones) — no falling, just free roaming over the whole page. Step onto any link and it lights up like a doorway; pause on it or press the dive key and the character drops through, and you fall into the next page, arriving on the other side. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play.",
"tags": [
"feature"
]
@@ -4844,6 +4845,15 @@
"feature"
],
"link": "/play"
+ },
+ {
+ "date": "2026-06-19",
+ "title": "Cleaner Pole Club bass — no more speaker distortion",
+ "summary": "Fixed the buzzy bass distortion some listeners heard at the Pole Club, especially on laptop and phone speakers. The club's low-end was being boosted hard enough to clip the audio output when several tracks overlapped; we've added a brick-wall limiter on the final mix, evened out the reverb so it adds a predictable amount of space, and dialed the bass boost back to a level that still hits hard without overdriving. The room now sounds full and clean at any volume.",
+ "tags": [
+ "fix"
+ ],
+ "link": "/club"
}
]
}
diff --git a/public/changelog.json b/public/changelog.json
index 85740c948..cb4bac9ab 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-19T18:41:44.795Z",
+ "generated_at": "2026-06-19T19:07:20.492Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -107,6 +107,16 @@
"feature"
]
},
+ {
+ "date": "2026-06-19",
+ "type": "update",
+ "title": "Cleaner Pole Club bass — no more speaker distortion",
+ "summary": "Fixed the buzzy bass distortion some listeners heard at the Pole Club, especially on laptop and phone speakers. The club's low-end was being boosted hard enough to clip the audio output when several tracks overlapped; we've added a brick-wall limiter on the final mix, evened out the reverb so it adds a predictable amount of space, and dialed the bass boost back to a level that still hits hard without overdriving. The room now sounds full and clean at any volume.",
+ "link": "/club",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-19",
"type": "update",
@@ -117,6 +127,17 @@
"improvement"
]
},
+ {
+ "date": "2026-06-19",
+ "type": "update",
+ "title": "Corner helper cards no longer pile up and hide page content",
+ "summary": "The small helper cards that live in the bottom-right corner — the \"Getting started\" guide, the \"have you tried…\" feature tips, and the \"Your agent is ready\" welcome card — each positioned themselves independently, so on many pages they stacked on the exact same spot and covered each other and the content behind them (most visibly the Deploy page's Live Preview). They now share a single tidy stack that flows them vertically, so they never overlap one another or the page. The welcome card also no longer follows you onto the Deploy and Explore pages, where it had nothing to do.",
+ "link": "/deploy",
+ "tags": [
+ "fix",
+ "improvement"
+ ]
+ },
{
"date": "2026-06-19",
"type": "update",
@@ -372,16 +393,6 @@
"fix"
]
},
- {
- "date": "2026-06-19",
- "type": "update",
- "title": "Onboarding card no longer covers the Deploy page preview",
- "summary": "The \"Your agent is ready\" pop-up — the welcome card that helps you find your way around the 3D viewer — was following you onto the Deploy on-chain page and floating over the Live Preview panel, hiding your agent's avatar, name, and cost summary right when you needed to check them before minting. The card now knows it belongs to the 3D viewer and stays out of the Deploy and Explore pages, so the preview is fully visible again.",
- "link": "/deploy",
- "tags": [
- "fix"
- ]
- },
{
"date": "2026-06-19",
"type": "update",
@@ -601,8 +612,8 @@
{
"date": "2026-06-19",
"type": "update",
- "title": "Walk the whole page — the site is now a platformer",
- "summary": "The corner walking companion can now step out of its spot. Click it and the character detaches and drops onto the page itself: headings, cards, buttons and images become solid ground you can walk and jump across with the arrow keys or WASD (on-screen buttons on phones). Stand on any link and it lights up like a trapdoor — pause on it, or press down, and the character dives through and you fall into the next page, landing back in from the top when it loads. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play.",
+ "title": "Walk the whole page — the site is now a playground",
+ "summary": "The corner walking companion can now step out of its spot. Click it and the character detaches into a gentle bird's-eye view of the page, and you steer him anywhere across it with the arrow keys or WASD (an on-screen d-pad on phones) — no falling, just free roaming over the whole page. Step onto any link and it lights up like a doorway; pause on it or press the dive key and the character drops through, and you fall into the next page, arriving on the other side. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play.",
"link": null,
"tags": [
"feature"
diff --git a/public/changelog.xml b/public/changelog.xml
index 78e047027..11a531bbb 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -86,6 +86,14 @@
<category>feature</category>
<description>The Brain tab in Agent Studio is now a visual node editor: wire Persona, Model, Memory, Skills, and trading-reasoning nodes into a living graph that IS your agent’s personality. Pick from real LLMs (Claude, GPT, Granite and more) per branch, connect a memory port that recalls and writes real memories, and watch the active path light up as your agent thinks — tokens streaming, memory firing, the avatar reacting live. A built-in test chat runs your graph against the real models with real latency and token stats, and forkable templates (Sniper, Scalper, Researcher, Companion) get you started in one click. Your graph compiles straight to your agent’s persona so every existing chat surface picks up the change.</description>
</item>
+ <item>
+ <title>Cleaner Pole Club bass — no more speaker distortion</title>
+ <link>https://three.ws/club</link>
+ <guid isPermaLink="false">2026-06-19:Cleaner Pole Club bass — no more speaker distortion</guid>
+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Fixed the buzzy bass distortion some listeners heard at the Pole Club, especially on laptop and phone speakers. The club's low-end was being boosted hard enough to clip the audio output when several tracks overlapped; we've added a brick-wall limiter on the final mix, evened out the reverb so it adds a predictable amount of space, and dialed the bass boost back to a level that still hits hard without overdriving. The room now sounds full and clean at any volume.</description>
+ </item>
<item>
<title>Clearer IRL onboarding and copy</title>
<link>https://three.ws/irl</link>
@@ -94,6 +102,14 @@
<category>improvement</category>
<description>Opening IRL for the first time now spells out the core loop in plain words: turn on Camera AR, aim at the spot you want, then tap Pin here to anchor your agent in real space. The on-screen guidance updates as you go — it points you to the next step before you've pinned, and confirms when your agent is anchored. We rewrote the status messages around pinning to be calm and literal instead of technical or alarming: waiting on a GPS fix now tells you it's quicker outdoors, pinning without location explains your agent is saved on this device until you turn location on, and a missing compass reads as a gentle note rather than a warning. The caption keyboard now opens reliably when the panel slides up on iPhone.</description>
</item>
+ <item>
+ <title>Corner helper cards no longer pile up and hide page content</title>
+ <link>https://three.ws/deploy</link>
+ <guid isPermaLink="false">2026-06-19:Corner helper cards no longer pile up and hide page content</guid>
+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The small helper cards that live in the bottom-right corner — the &quot;Getting started&quot; guide, the &quot;have you tried…&quot; feature tips, and the &quot;Your agent is ready&quot; welcome card — each positioned themselves independently, so on many pages they stacked on the exact same spot and covered each other and the content behind them (most visibly the Deploy page's Live Preview). They now share a single tidy stack that flows them vertically, so they never overlap one another or the page. The welcome card also no longer follows you onto the Deploy and Explore pages, where it had nothing to do.</description>
+ </item>
<item>
<title>Creator royalty payouts protected against double-settlement</title>
<link>https://three.ws/changelog</link>
@@ -294,14 +310,6 @@
<category>fix</category>
<description>The mobile navigation drawer now fully hides itself from assistive tech and the keyboard tab order when it's closed, instead of leaving its links reachable but invisible. Screen-reader and keyboard users can no longer land focus on a link inside a collapsed menu, and the browser's accessibility warning about hidden-but-focused links is gone.</description>
</item>
- <item>
- <title>Onboarding card no longer covers the Deploy page preview</title>
- <link>https://three.ws/deploy</link>
- <guid isPermaLink="false">2026-06-19:Onboarding card no longer covers the Deploy page preview</guid>
- <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>
- <category>fix</category>
- <description>The &quot;Your agent is ready&quot; pop-up — the welcome card that helps you find your way around the 3D viewer — was following you onto the Deploy on-chain page and floating over the Live Preview panel, hiding your agent's avatar, name, and cost summary right when you needed to check them before minting. The card now knows it belongs to the 3D viewer and stays out of the Deploy and Explore pages, so the preview is fully visible again.</description>
- </item>
<item>
<title>One API, many services: the three.ws API gateway</title>
<link>https://three.ws/changelog</link>
@@ -471,12 +479,12 @@
<description>When you walked the little robot off a ledge it could plummet faster than the page could keep up and slip off the bottom of the screen, leaving you unable to find it. The camera now tracks falls tightly and keeps the character in view, and on pages that can't scroll it catches the character and drops it right back into view.</description>
</item>
<item>
- <title>Walk the whole page — the site is now a platformer</title>
+ <title>Walk the whole page — the site is now a playground</title>
<link>https://three.ws/changelog</link>
- <guid isPermaLink="false">2026-06-19:Walk the whole page — the site is now a platformer</guid>
+ <guid isPermaLink="false">2026-06-19:Walk the whole page — the site is now a playground</guid>
<pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>
<category>feature</category>
- <description>The corner walking companion can now step out of its spot. Click it and the character detaches and drops onto the page itself: headings, cards, buttons and images become solid ground you can walk and jump across with the arrow keys or WASD (on-screen buttons on phones). Stand on any link and it lights up like a trapdoor — pause on it, or press down, and the character dives through and you fall into the next page, landing back in from the top when it loads. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play.</description>
+ <description>The corner walking companion can now step out of its spot. Click it and the character detaches into a gentle bird's-eye view of the page, and you steer him anywhere across it with the arrow keys or WASD (an on-screen d-pad on phones) — no falling, just free roaming over the whole page. Step onto any link and it lights up like a doorway; pause on it or press the dive key and the character drops through, and you fall into the next page, arriving on the other side. It loads nothing extra until you click in, so normal browsing pays no cost. Jump straight in from any page with ?walk=play.</description>
</item>
<item>
<title>Agent economy demos now show honest run status</title>
diff --git a/public/corner-stack.js b/public/corner-stack.js
new file mode 100644
index 000000000..56af4c315
--- /dev/null
+++ b/public/corner-stack.js
@@ -0,0 +1,129 @@
+/* three.ws corner-stack — one shared home for persistent bottom-right widgets.
+ *
+ * The platform grew a handful of independent floating cards — the "Getting
+ * started" pill, the feature-discovery prompt, the "Your agent is ready"
+ * onboarding banner — and each one hard-coded its own `position: fixed;
+ * right; bottom` plus a magic z-index. With no awareness of one another they
+ * piled onto the same pixel and covered page content (e.g. the Deploy page's
+ * Live Preview). The +80px nudge on the onboarding card was an ad-hoc patch
+ * for exactly that collision.
+ *
+ * This module replaces those one-off hacks with a single container that flows
+ * its members vertically — newest/most-important nearest the corner — so they
+ * never overlap each other or the underlying page. It is framework-free,
+ * idempotent, dependency-free, and order-independent: a widget that mounts
+ * before this script runs tags itself with `data-corner-priority` and appends
+ * to <body>; this module adopts those orphans on init.
+ *
+ * Priority: HIGHER number = closer to the corner (bottom). Members are ordered
+ * ascending top→bottom, so the highest-priority member is the bottom-most.
+ *
+ * API (window.twsCornerStack):
+ * mount(el, { priority }) — move `el` into the stack (sets priority if given)
+ * unmount(el) — remove `el` from the stack
+ * ensure() — create/return the container element
+ */
+(function () {
+ 'use strict';
+ if (window.twsCornerStack) return;
+
+ var STACK_ID = 'tws-corner-stack';
+ var STYLE_ID = 'tws-corner-stack-css';
+ var ITEM_CLASS = 'tws-corner-item';
+ var DEFAULT_PRIORITY = 50;
+ var stack = null;
+
+ var CSS = [
+ /* Global stacking ladder — promotes the old comment-only convention to
+ real, referenceable tokens. Wide gaps leave room for future layers. */
+ ':root{',
+ '--z-corner-feed:2147482000;',
+ '--z-corner-stack:2147482500;',
+ '--z-walk-companion:2147483000;',
+ '--z-overlay-modal:2147483600;',
+ '}',
+ '#' + STACK_ID + '{',
+ 'position:fixed;right:18px;bottom:18px;',
+ 'z-index:var(--z-corner-stack,2147482500);',
+ 'display:flex;flex-direction:column;align-items:flex-end;',
+ 'gap:12px;max-width:min(380px,calc(100vw - 24px));',
+ 'max-height:calc(100dvh - 36px);overflow:visible;',
+ /* Clicks fall through the gaps; members re-enable pointer events. */
+ 'pointer-events:none;',
+ '}',
+ '#' + STACK_ID + ':empty{display:none;}',
+ /* relative (not static) keeps members in the flex flow while preserving a
+ containing block for their position:absolute children (e.g. the
+ getting-started panel, card close buttons). */
+ '#' + STACK_ID + '>.' + ITEM_CLASS + '{',
+ 'position:relative;inset:auto;margin:0;pointer-events:auto;',
+ '}',
+ '@media (max-width:640px){',
+ '#' + STACK_ID + '{right:12px;bottom:12px;left:12px;align-items:stretch;gap:10px;max-width:none;}',
+ '}'
+ ].join('');
+
+ function ensureCss() {
+ if (document.getElementById(STYLE_ID)) return;
+ var style = document.createElement('style');
+ style.id = STYLE_ID;
+ style.textContent = CSS;
+ (document.head || document.documentElement).appendChild(style);
+ }
+
+ function ensureStack() {
+ ensureCss();
+ if (stack && document.body && document.body.contains(stack)) return stack;
+ var existing = document.getElementById(STACK_ID);
+ if (existing) { stack = existing; return stack; }
+ stack = document.createElement('div');
+ stack.id = STACK_ID;
+ stack.setAttribute('role', 'region');
+ stack.setAttribute('aria-label', 'Helper widgets');
+ (document.body || document.documentElement).appendChild(stack);
+ return stack;
+ }
+
+ function priorityOf(el) {
+ var p = Number(el.getAttribute('data-corner-priority'));
+ return Number.isFinite(p) ? p : DEFAULT_PRIORITY;
+ }
+
+ function place(el) {
+ var s = ensureStack();
+ el.classList.add(ITEM_CLASS);
+ var p = priorityOf(el);
+ var siblings = Array.prototype.slice.call(s.children);
+ var before = null;
+ for (var i = 0; i < siblings.length; i++) {
+ if (siblings[i] === el) continue;
+ if (priorityOf(siblings[i]) > p) { before = siblings[i]; break; }
+ }
+ s.insertBefore(el, before);
+ return el;
+ }
+
+ function mount(el, opts) {
+ if (!el) return el;
+ if (opts && opts.priority != null) {
+ el.setAttribute('data-corner-priority', String(opts.priority));
+ }
+ return place(el);
+ }
+
+ function unmount(el) {
+ if (el && stack && el.parentNode === stack) stack.removeChild(el);
+ }
+
+ /* Adopt widgets that mounted to <body> before this script executed. */
+ function adoptOrphans() {
+ if (!document.body) return;
+ var orphans = document.body.querySelectorAll(':scope > [data-corner-priority]');
+ for (var i = 0; i < orphans.length; i++) place(orphans[i]);
+ }
+
+ window.twsCornerStack = { mount: mount, unmount: unmount, ensure: ensureStack };
+
+ if (document.body) adoptOrphans();
+ else document.addEventListener('DOMContentLoaded', adoptOrphans);
+})();
diff --git a/public/feature-discovery.js b/public/feature-discovery.js
index 4ffb72c6f..e3b317fc0 100644
--- a/public/feature-discovery.js
+++ b/public/feature-discovery.js
@@ -29,6 +29,18 @@
if (typeof document === 'undefined') return;
if (document.documentElement.getAttribute('data-discovery') === 'off') return;
+ // Pull in the shared corner-stack so the card flows with the other
+ // bottom-right widgets instead of overlapping them. Idempotent; the stack
+ // adopts our tagged orphan if it loads after us.
+ function ensureCornerStack() {
+ if (window.twsCornerStack) return;
+ if (document.querySelector('script[src="/corner-stack.js"]')) return;
+ var s = document.createElement('script');
+ s.src = '/corner-stack.js';
+ s.defer = true;
+ (document.head || document.documentElement).appendChild(s);
+ }
+
// ── localStorage keys (threews:fd:* namespace) ─────────────────────────────
var K_VISITED = 'threews:fd:visited'; // routes the user has opened (array)
var K_TRIED = 'threews:fd:tried'; // dismissed "have you tried" prompts (map)
@@ -288,7 +300,13 @@
_escHandler = function (e) { if (e.key === 'Escape') dismiss(); };
document.addEventListener('keydown', _escHandler);
- document.body.appendChild(card);
+ // Flow into the shared corner-stack so the prompt stacks above the other
+ // bottom-right cards instead of landing on the same pixel. Falls back to a
+ // plain body mount; the data-corner-priority tag lets it be adopted later.
+ ensureCornerStack();
+ card.setAttribute('data-corner-priority', '10');
+ if (window.twsCornerStack) window.twsCornerStack.mount(card);
+ else document.body.appendChild(card);
_card = card;
// Reveal on next frame so the CSS transition runs.
requestAnimationFrame(function () { requestAnimationFrame(function () { card.classList.add('is-in'); }); });
diff --git a/public/features.json b/public/features.json
index 4ec1dbe41..9a763bb6c 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-19T18:41:44.783Z",
+ "generated_at": "2026-06-19T19:07:20.478Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/public/getting-started.js b/public/getting-started.js
index ff8923d08..336470597 100644
--- a/public/getting-started.js
+++ b/public/getting-started.js
@@ -418,13 +418,32 @@
overlay.addEventListener('click', function (e) { if (e.target === overlay) close(); });
}
+ // Pull in the shared corner-stack wherever this widget runs — some pages
+ // include us directly without nav.js (which normally loads it). The stack
+ // adopts our tagged orphan when it initialises, so order doesn't matter.
+ function ensureCornerStack() {
+ if (window.twsCornerStack) return;
+ if (document.querySelector('script[src="/corner-stack.js"]')) return;
+ var s = document.createElement('script');
+ s.src = '/corner-stack.js';
+ s.defer = true;
+ (document.head || document.documentElement).appendChild(s);
+ }
+
// ── Mount ─────────────────────────────────────────────────────────────────────
function mount() {
ensureCss();
+ ensureCornerStack();
root = el('div', 'twg-root');
root.appendChild(buildPanel());
root.appendChild(buildPill());
- document.body.appendChild(root);
+ // Flow into the shared corner-stack so it never overlaps the other
+ // bottom-right cards. The launcher pill owns the corner itself (highest
+ // priority). Falls back to a plain body mount if the stack isn't ready;
+ // the data-corner-priority tag lets it be adopted once the stack arrives.
+ root.setAttribute('data-corner-priority', '30');
+ if (window.twsCornerStack) window.twsCornerStack.mount(root);
+ else document.body.appendChild(root);
updatePill();
if (open) expand();
diff --git a/public/nav.js b/public/nav.js
index 65364cac5..0fe49c0ec 100644
--- a/public/nav.js
+++ b/public/nav.js
@@ -31,6 +31,19 @@ function loadSearch() {
document.head.appendChild(s);
}
+// Load the shared corner-stack (public/corner-stack.js) BEFORE any widget that
+// uses it, so window.twsCornerStack exists when they mount. It is also
+// order-independent (adopts orphans), but loading it first avoids the adopt
+// round-trip. Self-mounting + idempotent.
+function loadCornerStack() {
+ if (window.twsCornerStack) return;
+ if (document.querySelector('script[src="/corner-stack.js"]')) return;
+ const s = document.createElement('script');
+ s.src = '/corner-stack.js';
+ s.defer = true;
+ document.head.appendChild(s);
+}
+
// Load the site-wide "Getting started" first-run guide (public/getting-started.js):
// a one-time welcome for new visitors plus a resumable progress checklist. Self-
// mounting + idempotent; honours <html data-getting-started="off">.
@@ -90,6 +103,7 @@ function loadThemeSwitcher() {
}
function boot() {
+ loadCornerStack();
loadGlossary();
loadSearch();
loadDiscovery();
diff --git a/public/style.css b/public/style.css
index af41d7910..4bb66c93b 100644
--- a/public/style.css
+++ b/public/style.css
@@ -6636,11 +6636,14 @@ body[data-viewer-mode='main'][data-authed='false'] .auth-gate {
/* ── First-time onboarding banner ─────────────────────────────────────────── */
.agent-onboarding {
+ /* Fallback positioning for when the shared corner-stack isn't present; when
+ it is, #tws-corner-stack > .tws-corner-item takes over and flows this card
+ above the getting-started pill instead of overlapping it. */
position: fixed;
right: var(--space-md);
- bottom: calc(var(--space-md) + 80px);
+ bottom: var(--space-md);
width: min(360px, calc(100vw - var(--space-md) * 2));
- z-index: 60;
+ z-index: var(--z-corner-stack, 60);
animation: agent-onboarding-rise 0.32s ease-out;
}
diff --git a/src/app.js b/src/app.js
index 153103a4f..37fe35041 100644
--- a/src/app.js
+++ b/src/app.js
@@ -22,6 +22,18 @@ const TRUSTED_ASSET_HOST_RE = /(^|\.)(three\.ws|r2\.dev|mypinata\.cloud|pinata\.
// Solana. The "Deploy on Solana" CTA in /app always routes here.
const ONCHAIN_DEPLOY_AGENT_ID = '67bf6e67-93bb-40c6-9a6b-91e921696248';
const ONCHAIN_DEPLOY_AGENT_URL = `/app?agent=${ONCHAIN_DEPLOY_AGENT_ID}`;
+// Pull in the shared corner-stack (public/corner-stack.js) so the onboarding
+// card flows with the other bottom-right widgets instead of overlapping them.
+// Idempotent; the stack adopts the tagged card once it initialises.
+function ensureCornerStack() {
+ if (typeof document === 'undefined' || window.twsCornerStack) return;
+ if (document.querySelector('script[src="/corner-stack.js"]')) return;
+ const s = document.createElement('script');
+ s.src = '/corner-stack.js';
+ s.defer = true;
+ (document.head || document.documentElement).appendChild(s);
+}
+
function isSafeQueryModelUrl(raw) {
if (!raw || typeof raw !== 'string') return false;
if (raw.startsWith('/') && !raw.startsWith('//')) return true; // same-origin relative
@@ -1211,6 +1223,17 @@ class App {
if (el) el.addEventListener('click', () => dismiss());
});
+ // Flow into the shared corner-stack so the card sits above the
+ // getting-started pill instead of overlapping it. If the stack isn't ready
+ // yet, anchor the card to <body> and tag it so the stack adopts it on
+ // load; ensureCornerStack() pulls the module in if nothing else has.
+ banner.setAttribute('data-corner-priority', '20');
+ if (window.twsCornerStack) {
+ window.twsCornerStack.mount(banner);
+ } else {
+ document.body.appendChild(banner);
+ ensureCornerStack();
+ }
banner.hidden = false;
// Move focus into the dialog so keyboard/screen-reader users are taken
// to the freshly-revealed orientation message.
diff --git a/src/club-audio.js b/src/club-audio.js
index 98663480a..1b07ec885 100644
--- a/src/club-audio.js
+++ b/src/club-audio.js
@@ -41,6 +41,7 @@ export class ClubAudio {
constructor() {
this.ctx = null;
this.master = null;
+ this.limiter = null; // brick-wall limiter on the final output (anti-clip)
this.ambience = null; // { source, gain }
this.music = null; // { el, source, gain, index } — looping full-track bed
this.style = null; // { name, source, gain }
@@ -84,7 +85,22 @@ export class ClubAudio {
this.ctx = new Ctor();
this.master = this.ctx.createGain();
this.master.gain.value = this.muted ? 0 : MASTER_GAIN;
- this.master.connect(this.ctx.destination);
+
+ // Brick-wall limiter on the final output. The summed layers (music +
+ // ambience + a tipped style loop or the walk-in anthem) feeding through
+ // the +bass shelf can momentarily push the bus past 0 dBFS; without this
+ // the AudioContext destination hard-clips, which reads as buzzy bass
+ // distortion. A fast attack catches transient kick/sub peaks; the master
+ // gain still rides above it so nothing is audibly squashed under normal
+ // levels — it only engages on the overshoots.
+ this.limiter = this.ctx.createDynamicsCompressor();
+ this.limiter.threshold.value = -1.5;
+ this.limiter.knee.value = 0;
+ this.limiter.ratio.value = 20;
+ this.limiter.attack.value = 0.003;
+ this.limiter.release.value = 0.25;
+ this.master.connect(this.limiter);
+ this.limiter.connect(this.ctx.destination);
this.analyser = this.ctx.createAnalyser();
this.analyser.fftSize = 256;
@@ -105,7 +121,9 @@ export class ClubAudio {
this._fx.bass = this.ctx.createBiquadFilter();
this._fx.bass.type = 'lowshelf';
this._fx.bass.frequency.value = 90;
- this._fx.bass.gain.value = 18;
+ // +10 dB gives the bass real body without slamming the bus into the
+ // limiter on every kick. (Was +18 dB — ~8× linear — which clipped.)
+ this._fx.bass.gain.value = 10;
this._fx.lowpass = this.ctx.createBiquadFilter();
this._fx.lowpass.type = 'lowpass';
@@ -416,6 +434,7 @@ export class ClubAudio {
const buf = this.ctx.createBuffer(2, len, rate);
for (let c = 0; c < 2; c++) {
const ch = buf.getChannelData(c);
+ let sumSq = 0;
for (let i = 0; i < len; i++) {
const r =
density >= 1
@@ -423,8 +442,18 @@ export class ClubAudio {
: Math.random() < density
? Math.random() * 2 - 1
: 0;
- ch[i] = r * Math.pow(1 - i / len, decay);
+ const v = r * Math.pow(1 - i / len, decay);
+ ch[i] = v;
+ sumSq += v * v;
}
+ // Normalise each channel to unit energy (L2 norm). A raw noise IR's
+ // total energy scales with its length and density, so a 5 s sparse
+ // IR and a 1.5 s dense one would convolve at wildly different loudness
+ // and stack uncontrolled level onto the dry path. Unit-energy IRs give
+ // the convolver ~unity power gain, so the wet gains alone set how loud
+ // the reverb sits — no runaway convolution gain feeding the clip.
+ const norm = sumSq > 0 ? 1 / Math.sqrt(sumSq) : 1;
+ for (let i = 0; i < len; i++) ch[i] *= norm;
}
return buf;
}
@@ -448,8 +477,8 @@ export class ClubAudio {
const lerp = (a, b) => a + (b - a) * f;
// Outdoor (f=0) → indoor (f=1) endpoints for every node in the chain.
- const OUT = { freq: 420, q: 1.0, bass: 18, dry: 0.22, outWet: 0.85, inWet: 0.0 };
- const IN = { freq: 17000, q: 0.5, bass: 9, dry: 0.65, outWet: 0.0, inWet: 0.28 };
+ const OUT = { freq: 420, q: 1.0, bass: 10, dry: 0.22, outWet: 0.85, inWet: 0.0 };
+ const IN = { freq: 17000, q: 0.5, bass: 5, dry: 0.65, outWet: 0.0, inWet: 0.28 };
// Cutoff perceived logarithmically — interpolate as a geometric sweep.
const freq = OUT.freq * Math.pow(IN.freq / OUT.freq, f);
diff --git a/src/club-entrance.js b/src/club-entrance.js
index 31d3ca80a..05a9fe0b8 100644
--- a/src/club-entrance.js
+++ b/src/club-entrance.js
@@ -54,7 +54,7 @@ import {
import { gltfLoader } from './loaders/gltf.js';
import { AnimationManager } from './animation-manager.js';
import { ClubCrowd } from './club-crowd.js';
-import { detectProfile, PROFILES } from './club-perf.js';
+import { detectProfile, PROFILES, createFrameWatchdog } from './club-perf.js';
import { log } from './shared/log.js';
const TOUR_URL = '/club/venue/tour.glb';
@@ -63,6 +63,10 @@ const CLUBHOUSE_URL = '/club/venue/space-smugglers-clubhouse.glb';
const AVATAR_URL = '/avatars/default.glb';
const MANIFEST_URL = '/animations/manifest.json';
const PASS_KEY = 'club:pass:v1';
+
+// Hard cap on background crowd bodies per room. Each member is a full skinned
+// GLB rig (not an instanced mesh), so we keep the floor light for load + perf.
+const MAX_CROWD_PER_SCENE = 5;
const MOVE_CLIPS = new Set(['idle', 'walk']);
// The dance the avatar breaks into the instant the cover charge settles — a
// twerk on the spot before it walks past the velvet rope. Lazy-loaded from the
@@ -161,8 +165,14 @@ async function start(canvasEl) {
// antialias off + tone mapping deferred — SMAA + ACES run in the composer
// below, exactly like the pole stage (src/club.js), so the two halves of the
// journey share one cinematic look.
- const renderer = new WebGLRenderer({ canvas: canvasEl, antialias: false, alpha: false });
- renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
+ const renderer = new WebGLRenderer({ canvas: canvasEl, antialias: false, alpha: false, powerPreference: 'high-performance' });
+ // One capability profile drives the whole render budget. Pixel ratio is the
+ // single biggest heat lever — a 2× retina panel renders 4× the fragments of
+ // 1×, so we cap it per tier (high 2 / medium 1.5 / low 1) instead of always
+ // honouring the display's native ratio. The watchdog (see the frame loop)
+ // can drop this further mid-session if frames stay slow.
+ const profile = PROFILES[detectProfile()] || PROFILES.medium;
+ renderer.setPixelRatio(profile.pixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = SRGBColorSpace;
renderer.toneMapping = NoToneMapping;
@@ -219,7 +229,11 @@ async function start(canvasEl) {
new ToneMappingEffect({ mode: ToneMappingMode.ACES_FILMIC }),
new VignetteEffect({ darkness: 0.5, offset: 0.3 }),
));
- composer.addPass(new EffectPass(camera, new SMAAEffect()));
+ // SMAA is a full-screen edge pass — the first thing the watchdog drops when
+ // frames stay slow, so we keep a handle on it. Off by default on the low tier.
+ const smaaPass = new EffectPass(camera, new SMAAEffect());
+ smaaPass.enabled = profile.tier !== 'low';
+ composer.addPass(smaaPass);
const loader = gltfLoader(renderer);
@@ -304,12 +318,14 @@ async function start(canvasEl) {
// (bundled rigs + public gallery), grounded and dancing/idling clear of your
// path. Sized to the device's crowd budget; degrades to nothing if it can't
// load. Re-populated on every venue swap via refreshCrowd().
- const crowdProfile = PROFILES[detectProfile()] || PROFILES.medium;
+ const crowdProfile = profile;
const crowd = new ClubCrowd({
renderer,
scene,
manifest,
- max: crowdProfile.crowdInstances,
+ // Each crowd member is a full skinned GLB rig, so keep the floor light:
+ // at most MAX_CROWD_PER_SCENE bodies per room, regardless of device budget.
+ max: Math.min(MAX_CROWD_PER_SCENE, crowdProfile.crowdInstances),
bundled: BUNDLED_AGENTS,
});
crowd.load(); // background fetch of roster + clip data; mount() awaits it
diff --git a/src/walk-playground.js b/src/walk-playground.js
index cc64d806c..ae3e61b2d 100644
--- a/src/walk-playground.js
+++ b/src/walk-playground.js
@@ -1,15 +1,16 @@
-// Walk Playground — the page becomes a platformer level
-// =====================================================
+// Walk Playground — the page becomes a top-down playground
+// ========================================================
// Hands off from the corner Walk Companion (src/walk-companion.js): click the
-// companion and it "detaches" from its spot into a full-viewport character you
-// can actually walk around the page with. The page's real DOM — headings,
-// cards, buttons, images, links — becomes solid ground. Walk and jump across it
-// with the arrow keys / WASD (on-screen buttons on touch). Stand on a hyperlink
-// and it opens like a trapdoor beneath you: the character dives through and you
-// "fall into" the next page, dropping back in from the top on arrival.
+// companion and it "detaches" from its spot into a free-roaming character you
+// steer around the page from a gentle aerial view. The page is treated as a
+// floor seen from slightly above — walk anywhere across it with the arrow keys
+// / WASD (an on-screen d-pad on touch). There is no gravity and nothing to fall
+// off: the little guy strolls all over the page. Walk onto a hyperlink and it
+// lights up like a doorway; pause on it or press the dive key and the character
+// drops through and you "fall into" the next page, arriving on the other side.
//
// Why this lives in its own module: it is loaded with a dynamic import() the
-// first time you detach, so a normal page never pays for the platformer's code
+// first time you detach, so a normal page never pays for the playground's code
// or a second WebGL context — exactly the zero-footprint contract the companion
// already honors. It reuses the companion's shared building blocks: the same
// RobotExpressive rig + embedded clips, the same meshopt-only GLTFLoader, and
@@ -20,11 +21,15 @@ import {
AmbientLight,
AnimationMixer,
Box3,
+ CircleGeometry,
DirectionalLight,
+ DoubleSide,
Group,
HemisphereLight,
LoopOnce,
LoopRepeat,
+ Mesh,
+ MeshBasicMaterial,
OrthographicCamera,
Scene,
Timer,
@@ -39,35 +44,17 @@ import { log } from './shared/log.js';
const ROBOT_URL = '/animations/robotexpressive.glb';
const RESUME_KEY = 'walk:playground:resume'; // sessionStorage flag: drop in on arrival
-// ── Physics (CSS-pixel units, seconds) ───────────────────────────────────────
-const CHAR_PX = 138; // rendered feet-to-head height
-const GRAVITY = 2600;
-const TERMINAL = 2400;
-const MOVE_SPEED = 330;
-const RUN_SPEED = 250; // |vx| above this plays the run clip
-const JUMP_V = 1000; // ≈184px apex
-const GROUND_ACCEL = 2600;
-const AIR_ACCEL = 1400;
-const FRICTION = 2400;
-const FOOT_PAD = 26; // horizontal grace so you don't slip off pixel-exact edges
-const LAND_TOL = 14; // vertical tolerance when snapping onto a surface
-const LINK_ARM_MS = 850; // stand still on a link this long → trapdoor opens
-
-// DOM elements that count as solid ground. Filtered further by size/visibility.
-const SOLID_SELECTOR = [
- 'a[href]',
- 'button',
- 'h1',
- 'h2',
- 'h3',
- 'h4',
- 'p',
- 'li',
- 'img',
- 'figure',
- '.card',
- '[data-platform]',
-].join(',');
+// ── Tuning (CSS-pixel units, seconds) ────────────────────────────────────────
+const CHAR_PX = 150; // rendered feet-to-head height (pre-foreshorten)
+const MOVE_ACCEL = 3600;
+const MAX_SPEED = 360;
+const RUN_SPEED = 250; // speed above this plays the run clip
+const FRICTION = 3200;
+const EDGE_PAD = 30; // keep the character this far from the page edges
+const CAM_PITCH = 0.5; // radians (~28°) — gentle aerial, "not too dramatic"
+const LINK_DWELL_MS = 700; // stand on a link this long → the doorway opens
+const SPAWN_GUARD_MS = 1100; // no auto-dive until the user has had a beat of control
+const ELEM_PROBE_MS = 90; // throttle for elementFromPoint link hit-testing
function prefersReducedMotion() {
try {
@@ -112,9 +99,29 @@ function maxScroll() {
return Math.max(0, docHeight() - window.innerHeight);
}
+// Resolve the same-origin link (if any) sitting under a viewport point, walking
+// up from the topmost element there. Returns its absolute href or null.
+function linkHrefAtPoint(sx, sy) {
+ let el = document.elementFromPoint(sx, sy);
+ if (!el) return null;
+ const a = el.closest?.('a[href]');
+ if (!a) return null;
+ if (a.target && a.target !== '_self') return null;
+ const raw = a.getAttribute('href') || '';
+ if (!raw || raw.startsWith('#') || raw.startsWith('javascript:')) return null;
+ try {
+ const u = new URL(raw, location.href);
+ if (u.origin !== location.origin) return null;
+ return { href: u.href, el: a };
+ } catch {
+ return null;
+ }
+}
+
// ── Animation controller (RobotExpressive clips) ─────────────────────────────
-// States: idle / walk / run / jump. The platformer logic never branches on clip
-// names — it just calls setState(); missing clips degrade gracefully to idle.
+// States: idle / walk / run / jump (jump is the dive-through flourish). The
+// playground logic never branches on clip names — it calls setState(); missing
+// clips degrade gracefully to idle.
function makeController(root, clips) {
const mixer = new AnimationMixer(root);
const byName = (name) => clips.find((c) => c.name.toLowerCase() === name.toLowerCase());
@@ -180,28 +187,25 @@ class WalkPlayground {
this._onKeyDown = this._onKeyDown.bind(this);
this._onKeyUp = this._onKeyUp.bind(this);
this._onResize = this._onResize.bind(this);
- this._scheduleRescan = this._scheduleRescan.bind(this);
- // Character state, in document coordinates (feet position).
- this.char = { x: 0, y: 0, vx: 0, vy: 0, grounded: false, facing: 1 };
- this.platform = null; // platform currently stood on
- this.platforms = [];
- this._lastScan = 0;
- this._scrollY = 0;
+ // Character state, in document coordinates (feet position on the page).
+ this.char = { x: 0, y: 0, vx: 0, vy: 0, facing: 0 };
+ this._yaw = 0;
- // Input flags.
- this.input = { left: false, right: false, jump: false, down: false };
- this._jumpEdge = false; // jump consumed until released (no auto-bunnyhop)
+ // Input flags (held).
+ this.input = { up: false, down: false, left: false, right: false, dive: false };
- // Link-trapdoor arming.
+ // Link doorway arming.
this._armEl = null;
this._armAt = 0;
+ this._armHref = null;
+ this._lastProbe = 0;
this._diving = false;
+ this._spawnGuardUntil = 0;
- // Fall-recovery: timestamp the character first dropped below the visible
- // viewport while the page could no longer scroll to follow. If it lingers
- // there he's truly lost off-screen, so we re-drop him back into view.
- this._airborneSince = 0;
+ // Scratch vectors reused each frame (no per-frame allocation).
+ this._v0 = new Vector3();
+ this._v1 = new Vector3();
}
async mount({ avatarId = null, startScreen = null, dropIn = false } = {}) {
@@ -222,12 +226,8 @@ class WalkPlayground {
return;
}
- this._scrollY = window.scrollY || 0;
- this._scan(true);
this._placeStart(startScreen, dropIn);
- // Grace period so the character can't auto-dive through a link it happens
- // to land on during the initial settle, before the user has any control.
- this._spawnGuardUntil = performance.now() + 1500;
+ this._spawnGuardUntil = performance.now() + SPAWN_GUARD_MS;
this._bindEvents();
this._hintFor(dropIn);
@@ -243,27 +243,29 @@ class WalkPlayground {
window.removeEventListener('keydown', this._onKeyDown, true);
window.removeEventListener('keyup', this._onKeyUp, true);
window.removeEventListener('resize', this._onResize);
- window.removeEventListener('scroll', this._scheduleRescan, true);
this._clearArm();
this._teardown();
}
- // ── DOM scaffold (canvas + controls + hint) ──────────────────────────────
+ // ── DOM scaffold (canvas + d-pad + hint) ──────────────────────────────────
_buildDom() {
ensureStyles();
const host = document.createElement('div');
host.className = 'walk-pg';
host.setAttribute('role', 'application');
- host.setAttribute('aria-label', 'Page playground — walk the character with arrow keys');
+ host.setAttribute('aria-label', 'Page playground — walk the character with the arrow keys');
host.innerHTML = `
<canvas class="walk-pg-canvas"></canvas>
<div class="walk-pg-hint" aria-live="polite"></div>
<button type="button" class="walk-pg-exit" aria-label="Exit playground" title="Exit (Esc)">Exit ✕</button>
<div class="walk-pg-pad" aria-hidden="true">
- <button type="button" class="walk-pg-btn" data-act="left" aria-label="Walk left">◀</button>
- <button type="button" class="walk-pg-btn" data-act="right" aria-label="Walk right">▶</button>
- <button type="button" class="walk-pg-btn walk-pg-jump" data-act="jump" aria-label="Jump">⤒</button>
- <button type="button" class="walk-pg-btn" data-act="down" aria-label="Dive into link">⤓</button>
+ <button type="button" class="walk-pg-btn" data-act="up" aria-label="Walk up">▲</button>
+ <div class="walk-pg-pad-row">
+ <button type="button" class="walk-pg-btn" data-act="left" aria-label="Walk left">◀</button>
+ <button type="button" class="walk-pg-btn walk-pg-dive" data-act="dive" aria-label="Dive into link">⬇</button>
+ <button type="button" class="walk-pg-btn" data-act="right" aria-label="Walk right">▶</button>
+ </div>
+ <button type="button" class="walk-pg-btn" data-act="down" aria-label="Walk down">▼</button>
</div>
<div class="walk-pg-flash" aria-hidden="true"></div>
`;
@@ -274,7 +276,7 @@ class WalkPlayground {
this.flashEl = host.querySelector('.walk-pg-flash');
host.querySelector('.walk-pg-exit').addEventListener('click', () => exitPlayground());
- // Touch / pointer controls — held while pressed.
+ // Touch / pointer d-pad — held while pressed.
host.querySelectorAll('.walk-pg-btn').forEach((btn) => {
const act = btn.getAttribute('data-act');
const on = (e) => {
@@ -294,15 +296,10 @@ class WalkPlayground {
}
_setAct(act, val) {
- if (act === 'left') this.input.left = val;
- else if (act === 'right') this.input.right = val;
- else if (act === 'jump') {
- this.input.jump = val;
- if (!val) this._jumpEdge = false;
- } else if (act === 'down') this.input.down = val;
+ if (act in this.input) this.input[act] = val;
}
- // ── Three.js scene: orthographic, 1 unit = 1 CSS pixel ────────────────────
+ // ── Three.js scene: orthographic, pitched down for a gentle aerial view ────
async _buildScene() {
const renderer = new WebGLRenderer({ canvas: this.canvas, alpha: true, antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
@@ -314,20 +311,28 @@ class WalkPlayground {
this.scene = scene;
scene.add(new AmbientLight(0xffffff, 0.9));
const hemi = new HemisphereLight(0xbcd6ff, 0x1a2230, 0.75);
- hemi.position.set(0, 200, 0);
+ hemi.position.set(0, 300, 0);
scene.add(hemi);
const sun = new DirectionalLight(0xffffff, 1.7);
- sun.position.set(120, 260, 220);
+ sun.position.set(80, 320, 260);
scene.add(sun);
- // Camera maps screen pixel (px, py) → world (px, -py); +Z toward viewer.
- this.camera = new OrthographicCamera(0, window.innerWidth, 0, -window.innerHeight, -1000, 2000);
- this.camera.position.z = 600;
+ this._setupCamera();
const rig = new Group();
scene.add(rig);
this.rig = rig;
+ // Soft contact shadow on the page plane (z=0), so the character reads as
+ // standing on the page when seen from above.
+ const shadow = new Mesh(
+ new CircleGeometry(1, 28),
+ new MeshBasicMaterial({ color: 0x05070c, transparent: true, opacity: 0.32, side: DoubleSide, depthWrite: false }),
+ );
+ shadow.renderOrder = -1;
+ scene.add(shadow);
+ this.shadow = shadow;
+
const loader = new GLTFLoader();
loader.setMeshoptDecoder(await getMeshoptDecoder());
// Detaching from the corner companion means the same default rig walks
@@ -359,95 +364,59 @@ class WalkPlayground {
model.position.z -= center.z;
model.position.y -= box2.min.y;
this.modelHalfW = (size.x * scale) / 2;
+ this._shadowR = Math.max(22, this.modelHalfW * 1.15);
rig.add(model);
this.controller = makeController(model, gltf.animations || []);
}
- _placeStart(startScreen, dropIn) {
- const sy = window.scrollY || 0;
- if (dropIn) {
- // Arrived by diving through a link on the previous page — fall in from
- // the top, centered, so navigation reads as continuous descent.
- this.char.x = clamp(docWidth() * 0.5, 40, docWidth() - 40);
- this.char.y = sy - CHAR_PX;
- this.char.vy = 60;
- this.char.grounded = false;
- } else if (startScreen) {
- // Detached from the companion's corner — step out from that exact spot.
- this.char.x = clamp(startScreen.x, 40, docWidth() - 40);
- this.char.y = startScreen.y + sy;
- this.char.vy = 40;
- this.char.grounded = false;
- } else {
- this.char.x = clamp(docWidth() * 0.5, 40, docWidth() - 40);
- this.char.y = sy + window.innerHeight * 0.3;
- this.char.vy = 0;
- }
+ // Orthographic camera looking at the page plane (z=0) from slightly above, so
+ // the world maps to screen pixels at a constant scale while we view upright
+ // characters from a gentle downward angle. Feet are glued to exact page
+ // points each frame via unproject (see _pagePointAtScreen), which stays exact
+ // under any camera tilt because orthographic projection has no perspective.
+ _setupCamera() {
+ const W = window.innerWidth;
+ const H = window.innerHeight;
+ const cam = new OrthographicCamera(-W / 2, W / 2, H / 2, -H / 2, -4000, 8000);
+ const D = 3000;
+ cam.position.set(0, Math.sin(CAM_PITCH) * D, Math.cos(CAM_PITCH) * D);
+ cam.up.set(0, 1, 0);
+ cam.lookAt(0, 0, 0);
+ cam.updateProjectionMatrix();
+ cam.updateMatrixWorld(true);
+ this.camera = cam;
+ }
+
+ // World point on the page plane (z=0) that projects to a given viewport pixel.
+ _pagePointAtScreen(sx, sy, out) {
+ const W = window.innerWidth;
+ const H = window.innerHeight;
+ const ndcX = (sx / W) * 2 - 1;
+ const ndcY = -((sy / H) * 2 - 1);
+ const p0 = this._v0.set(ndcX, ndcY, -1).unproject(this.camera);
+ const p1 = this._v1.set(ndcX, ndcY, 1).unproject(this.camera);
+ const dz = p1.z - p0.z;
+ const t = Math.abs(dz) < 1e-6 ? 0 : -p0.z / dz;
+ return out.set(p0.x + (p1.x - p0.x) * t, p0.y + (p1.y - p0.y) * t, 0);
}
- // ── Platform scan from the live DOM ───────────────────────────────────────
- // Only elements within an expanded band around the viewport are considered,
- // so the platform set stays small and follows the user as they descend.
- _scan(force = false) {
- const now = performance.now();
- if (!force && now - this._lastScan < 180) return;
- this._lastScan = now;
-
+ _placeStart(startScreen, dropIn) {
const sx = window.scrollX || 0;
const sy = window.scrollY || 0;
- const bandTop = sy - 1100;
- const bandBottom = sy + window.innerHeight + 1100;
- const out = [];
- const seen = new Set();
-
- const els = document.querySelectorAll(SOLID_SELECTOR);
- for (const el of els) {
- if (out.length >= 360) break;
- if (this.host.contains(el)) continue;
- const r = el.getBoundingClientRect();
- if (r.width < 38 || r.height < 14 || r.height > 520) continue;
- const top = r.top + sy;
- const bottom = r.bottom + sy;
- if (bottom < bandTop || top > bandBottom) continue;
- const style = el.ownerDocument.defaultView.getComputedStyle(el);
- if (style.visibility === 'hidden' || style.display === 'none' || +style.opacity === 0) continue;
- const left = r.left + sx;
- const right = r.right + sx;
- const key = `${Math.round(left)},${Math.round(top)},${Math.round(right)}`;
- if (seen.has(key)) continue;
- seen.add(key);
-
- const link = el.closest('a[href]');
- let href = null;
- if (link) {
- const raw = link.getAttribute('href') || '';
- if (raw && !raw.startsWith('#') && (!link.target || link.target === '_self')) {
- try {
- const u = new URL(raw, location.href);
- if (u.origin === location.origin) href = u.href;
- } catch {
- /* unparseable href — treat as plain platform */
- }
- }
- }
- out.push({ left, right, top, bottom, href, el });
- }
-
- // Always-present floor and ceiling so the character can never escape.
const w = docWidth();
- out.push({ left: -40, right: w + 40, top: docHeight() - 3, bottom: docHeight(), href: null, el: null });
- this.platforms = out;
-
- // Keep standing on a platform that scrolled out of the rescan band.
- if (this.platform && !out.includes(this.platform)) {
- out.push(this.platform);
+ if (startScreen) {
+ // Detached from the companion's corner — start from that exact spot.
+ this.char.x = clamp(startScreen.x + sx, EDGE_PAD, w - EDGE_PAD);
+ this.char.y = clamp(startScreen.y + sy, EDGE_PAD, docHeight() - EDGE_PAD);
+ } else {
+ // Deep-link or drop-in — start near the middle of the current view.
+ this.char.x = clamp(w * 0.5, EDGE_PAD, w - EDGE_PAD);
+ this.char.y = clamp(sy + window.innerHeight * (dropIn ? 0.32 : 0.4), EDGE_PAD, docHeight() - EDGE_PAD);
}
- }
-
- _scheduleRescan() {
- this._scrollY = window.scrollY || 0;
- this._scan();
+ this.char.vx = 0;
+ this.char.vy = 0;
+ this._dropIn = dropIn;
}
// ── Events ────────────────────────────────────────────────────────────────
@@ -455,7 +424,6 @@ class WalkPlayground {
window.addEventListener('keydown', this._onKeyDown, true);
window.addEventListener('keyup', this._onKeyUp, true);
window.addEventListener('resize', this._onResize);
- window.addEventListener('scroll', this._scheduleRescan, true);
}
_onKeyDown(e) {
@@ -467,8 +435,9 @@ class WalkPlayground {
let handled = true;
if (k === 'ArrowLeft' || k === 'a' || k === 'A') this.input.left = true;
else if (k === 'ArrowRight' || k === 'd' || k === 'D') this.input.right = true;
- else if (k === ' ' || k === 'ArrowUp' || k === 'w' || k === 'W' || k === 'Spacebar') this.input.jump = true;
+ else if (k === 'ArrowUp' || k === 'w' || k === 'W') this.input.up = true;
else if (k === 'ArrowDown' || k === 's' || k === 'S') this.input.down = true;
+ else if (k === ' ' || k === 'Spacebar' || k === 'Enter' || k === 'e' || k === 'E') this.input.dive = true;
else handled = false;
if (handled) e.preventDefault();
}
@@ -477,20 +446,16 @@ class WalkPlayground {
const k = e.key;
if (k === 'ArrowLeft' || k === 'a' || k === 'A') this.input.left = false;
else if (k === 'ArrowRight' || k === 'd' || k === 'D') this.input.right = false;
- else if (k === ' ' || k === 'ArrowUp' || k === 'w' || k === 'W' || k === 'Spacebar') {
- this.input.jump = false;
- this._jumpEdge = false;
- } else if (k === 'ArrowDown' || k === 's' || k === 'S') this.input.down = false;
+ else if (k === 'ArrowUp' || k === 'w' || k === 'W') this.input.up = false;
+ else if (k === 'ArrowDown' || k === 's' || k === 'S') this.input.down = false;
+ else if (k === ' ' || k === 'Spacebar' || k === 'Enter' || k === 'e' || k === 'E') this.input.dive = false;
}
_onResize() {
this._resizeRenderer();
- if (this.camera) {
- this.camera.right = window.innerWidth;
- this.camera.bottom = -window.innerHeight;
- this.camera.updateProjectionMatrix();
- }
- this._scan(true);
+ this._setupCamera();
+ this.char.x = clamp(this.char.x, EDGE_PAD, docWidth() - EDGE_PAD);
+ this.char.y = clamp(this.char.y, EDGE_PAD, docHeight() - EDGE_PAD);
}
_resizeRenderer() {
@@ -500,8 +465,8 @@ class WalkPlayground {
// ── Hints ─────────────────────────────────────────────────────────────────
_hintFor(dropIn) {
const touch = matchMedia('(pointer: coarse)').matches;
- const move = touch ? 'Use the buttons' : 'Arrow keys / WASD to move, Space to jump';
- this._say(dropIn ? `You fell in! ${move}. Land on a link to dive deeper.` : `${move}. Land on a link to dive in.`, 5200);
+ const move = touch ? 'Use the d-pad to walk' : 'Arrow keys / WASD to walk anywhere';
+ this._say(dropIn ? `You're in! ${move}. Step on a link to dive deeper.` : `${move}. Step on a link to dive in.`, 5200);
}
_say(text, ms = 3200) {
@@ -512,15 +477,15 @@ class WalkPlayground {
this._hintTimer = setTimeout(() => this.hintEl?.classList.remove('is-in'), ms);
}
- // ── Link-trapdoor arming ──────────────────────────────────────────────────
- _armLink(p) {
- if (this._armEl === p.el) return;
+ // ── Link doorway arming ───────────────────────────────────────────────────
+ _armLink(el, href) {
+ if (this._armEl === el) return;
this._clearArm();
- this._armEl = p.el;
+ this._armEl = el;
+ this._armHref = href;
this._armAt = performance.now();
- this._armHref = p.href;
- p.el.classList.add('walk-pg-portal');
- this._say('↓ to dive in', 2200);
+ el.classList.add('walk-pg-portal');
+ this._say('Pause here or press Space to dive in', 2400);
}
_clearArm() {
@@ -535,8 +500,8 @@ class WalkPlayground {
this._diving = true;
this.controller?.setState('jump');
if (this._armEl) this._armEl.classList.add('is-open');
- // Flag so the destination relaunches the playground and drops the
- // character in from the top — the "fall into the next page" payoff.
+ // Flag so the destination relaunches the playground on arrival — the
+ // "fall into the next page" payoff.
ssSet(RESUME_KEY, '1');
this.flashEl?.classList.add('is-on');
const go = () => {
@@ -546,20 +511,18 @@ class WalkPlayground {
go();
return;
}
- // Plummet the character, then navigate once the screen has faded.
this.char.vx = 0;
- this.char.vy = TERMINAL;
- this.char.grounded = false;
- setTimeout(go, 620);
+ this.char.vy = 0;
+ setTimeout(go, 560);
}
- // ── Main loop ───────────────────────────────────────────────────────────────
+ // ── Main loop ─────────────────────────────────────────────────────────────
_tick() {
if (!this.mounted) return;
this.clock.update();
const dt = Math.min(this.clock.getDelta(), 0.033);
if (!this._diving) this._step(dt);
- this._follow(dt);
+ this._follow();
this._render(dt);
this._raf = requestAnimationFrame(this._tick);
}
@@ -567,183 +530,116 @@ class WalkPlayground {
_step(dt) {
const c = this.char;
- // Horizontal input → acceleration with friction when idle.
- const dir = (this.input.right ? 1 : 0) - (this.input.left ? 1 : 0);
- const accel = c.grounded ? GROUND_ACCEL : AIR_ACCEL;
- if (dir !== 0) {
- c.vx += dir * accel * dt;
- c.vx = clamp(c.vx, -MOVE_SPEED, MOVE_SPEED);
- c.facing = dir;
- } else if (c.grounded) {
- const f = FRICTION * dt;
- if (Math.abs(c.vx) <= f) c.vx = 0;
- else c.vx -= Math.sign(c.vx) * f;
- }
-
- // Jump (rising edge only).
- if (this.input.jump && c.grounded && !this._jumpEdge) {
- c.vy = -JUMP_V;
- c.grounded = false;
- this.platform = null;
- this._jumpEdge = true;
- this._clearArm();
+ // Build a normalized input vector (so diagonals aren't faster).
+ let ix = (this.input.right ? 1 : 0) - (this.input.left ? 1 : 0);
+ let iy = (this.input.down ? 1 : 0) - (this.input.up ? 1 : 0);
+ if (ix !== 0 && iy !== 0) {
+ const inv = 1 / Math.SQRT2;
+ ix *= inv;
+ iy *= inv;
}
- // Drop / dive request.
- if (this.input.down && c.grounded) {
- if (this.platform?.href) {
- this._dive(this.platform.href);
- return;
- }
- // Drop through a normal platform to whatever is below.
- c.y += 4;
- c.grounded = false;
- const dropped = this.platform;
- this.platform = null;
- this._dropIgnore = dropped;
- }
-
- // Gravity.
- c.vy = Math.min(c.vy + GRAVITY * dt, TERMINAL);
-
- const prevY = c.y;
- c.x = clamp(c.x + c.vx * dt, this.modelHalfW, docWidth() - this.modelHalfW);
- c.y = c.y + c.vy * dt;
-
- // Land on the highest platform crossed from above this frame.
- if (c.vy >= 0) {
- let best = null;
- for (const p of this.platforms) {
- if (p === this._dropIgnore) continue;
- if (c.x < p.left - FOOT_PAD || c.x > p.right + FOOT_PAD) continue;
- if (prevY <= p.top + LAND_TOL && c.y >= p.top) {
- if (!best || p.top < best.top) best = p;
- }
+ if (ix !== 0 || iy !== 0) {
+ c.vx += ix * MOVE_ACCEL * dt;
+ c.vy += iy * MOVE_ACCEL * dt;
+ const sp = Math.hypot(c.vx, c.vy);
+ if (sp > MAX_SPEED) {
+ const k = MAX_SPEED / sp;
+ c.vx *= k;
+ c.vy *= k;
}
- if (best) {
- c.y = best.top;
+ } else {
+ // Friction to a stop.
+ const f = FRICTION * dt;
+ const sp = Math.hypot(c.vx, c.vy);
+ if (sp <= f) {
+ c.vx = 0;
c.vy = 0;
- c.grounded = true;
- this.platform = best;
- this._dropIgnore = null;
- } else if (c.grounded && this.platform) {
- // Walked off the edge of the current platform?
- const p = this.platform;
- if (c.x < p.left - FOOT_PAD || c.x > p.right + FOOT_PAD) {
- c.grounded = false;
- this.platform = null;
- } else {
- c.y = p.top; // stay snapped
- }
} else {
- c.grounded = false;
+ const k = (sp - f) / sp;
+ c.vx *= k;
+ c.vy *= k;
}
}
- // Fell off the bottom of the world on a page the camera can't scroll to
- // follow — give it a beat to confirm, then re-drop him into view so he's
- // never lost off-screen.
- const sy = window.scrollY || 0;
- if (!c.grounded && c.vy > 0 && c.y - sy > window.innerHeight * 1.25) {
- if (!this._airborneSince) this._airborneSince = performance.now();
- else if (performance.now() - this._airborneSince > 200) {
- this._recall();
- return;
- }
- } else {
- this._airborneSince = 0;
+ c.x = clamp(c.x + c.vx * dt, EDGE_PAD, docWidth() - EDGE_PAD);
+ c.y = clamp(c.y + c.vy * dt, EDGE_PAD, docHeight() - EDGE_PAD);
+
+ // Facing: turn toward travel direction (model faces +Z at yaw 0).
+ const speed = Math.hypot(c.vx, c.vy);
+ if (speed > 12) this.char.facing = Math.atan2(c.vx, c.vy);
+
+ // Link hit-test under the feet (throttled), then arm / dive.
+ const now = performance.now();
+ if (now - this._lastProbe > ELEM_PROBE_MS) {
+ this._lastProbe = now;
+ const feetX = c.x - (window.scrollX || 0);
+ const feetY = c.y - (window.scrollY || 0);
+ const hit = linkHrefAtPoint(feetX, feetY);
+ if (hit) this._armLink(hit.el, hit.href);
+ else if (this._armEl) this._clearArm();
}
- // Trapdoor arming: standing fairly still on a link opens it. Suppressed
- // during the spawn grace period so detaching onto a link isn't an instant
- // teleport — the user gets to take control first.
- const pastGuard = performance.now() > this._spawnGuardUntil;
- if (pastGuard && c.grounded && this.platform?.href && Math.abs(c.vx) < 30 && dir === 0) {
- this._armLink(this.platform);
- if (performance.now() - this._armAt > LINK_ARM_MS) {
- this._dive(this.platform.href);
+ // Dive: explicit key, or dwelling still on the doorway past the guard.
+ if (this._armHref) {
+ if (this.input.dive) {
+ this._dive(this._armHref);
+ return;
+ }
+ const pastGuard = now > this._spawnGuardUntil;
+ if (pastGuard && speed < 24 && now - this._armAt > LINK_DWELL_MS) {
+ this._dive(this._armHref);
return;
}
- } else if (this._armEl && (!c.grounded || this.platform?.el !== this._armEl || dir !== 0)) {
- this._clearArm();
}
// Animation state.
let state = 'idle';
- if (!c.grounded) state = 'jump';
- else if (Math.abs(c.vx) > RUN_SPEED) state = 'run';
- else if (Math.abs(c.vx) > 6) state = 'walk';
+ if (speed > RUN_SPEED) state = 'run';
+ else if (speed > 12) state = 'walk';
this.controller?.setState(state);
}
- // Scroll the page so the character stays comfortably in view.
- _follow(dt) {
- const c = this.char;
+ // Scroll the page so the character stays in a comfortable central band,
+ // letting him reach the whole document by walking up or down.
+ _follow() {
const vh = window.innerHeight;
const cur = window.scrollY || 0;
- // Keep him ~55% down the viewport, easing smoothly — but track a fall
- // tighter (gravity reaches 2400px/s), or the lag slides him off the
- // bottom edge mid-plummet and the user loses sight of him.
- const target = c.y - vh * 0.55;
- const ease = c.grounded ? dt * 6 : dt * 12;
- let next = this._reduced ? target : cur + (target - cur) * Math.min(1, ease);
- // Hard visibility guarantee: never let his feet drop below 85% of the
- // viewport while the page can still scroll, so he's always findable.
- next = Math.max(next, c.y - vh * 0.85);
+ const screenY = this.char.y - cur;
+ const top = vh * 0.3;
+ const bottom = vh * 0.7;
+ let next = cur;
+ if (screenY < top) next = this.char.y - top;
+ else if (screenY > bottom) next = this.char.y - bottom;
next = clamp(next, 0, maxScroll());
if (Math.abs(next - cur) > 0.5) window.scrollTo(0, next);
- this._scrollY = window.scrollY || 0;
- this._scan();
- }
-
- // Re-drop the character into the current view when a fall has carried him
- // off-screen on a page the camera can't scroll to follow (e.g. a non-
- // scrollable layout, where the document-bottom floor sits below the fold).
- // He lands on the highest platform under him that's on screen, or onto a
- // transient full-width ledge so he stops in view rather than vanishing.
- _recall() {
- this._scan(true);
- const sy = window.scrollY || 0;
- const vh = window.innerHeight;
- const x = clamp(this.char.x, this.modelHalfW, docWidth() - this.modelHalfW);
- let best = null;
- for (const p of this.platforms) {
- if (p.top < sy + 20 || p.top > sy + vh - 20) continue; // must be on screen
- if (x < p.left - FOOT_PAD || x > p.right + FOOT_PAD) continue; // under him
- if (!best || p.top < best.top) best = p;
- }
- if (!best) {
- best = { left: -40, right: docWidth() + 40, top: sy + vh * 0.35, bottom: sy + vh * 0.35 + 3, href: null, el: null };
- this.platforms.push(best);
- }
- this.char.x = x;
- this.char.y = best.top;
- this.char.vx = 0;
- this.char.vy = 0;
- this.char.grounded = true;
- this.platform = best;
- this._dropIgnore = null;
- this._airborneSince = 0;
- this.controller?.setState('idle');
- this._say('Caught you — back in view.', 2200);
}
_render(dt) {
const c = this.char;
- const sx = window.scrollX || 0;
- const sy = window.scrollY || 0;
- const screenX = c.x - sx;
- const screenY = c.y - sy;
- this.rig.position.set(screenX, -screenY, 0);
+ const feetX = c.x - (window.scrollX || 0);
+ const feetY = c.y - (window.scrollY || 0);
+
+ // Glue the feet to the exact page point beneath them.
+ this._pagePointAtScreen(feetX, feetY, this._v0);
+ this.rig.position.copy(this._v0);
+ if (this.shadow) {
+ this.shadow.position.set(this._v0.x, this._v0.y, this._v0.z + 0.5);
+ this.shadow.scale.set(this._shadowR, this._shadowR * 0.5, 1);
+ }
- // 3/4 hero turn toward travel direction; spin while diving.
if (this._diving) {
- this.rig.rotation.y += dt * 9;
- const s = Math.max(0.05, this.rig.scale.x - dt * 1.4);
+ this.rig.rotation.y += dt * 10;
+ const s = Math.max(0.04, this.rig.scale.x - dt * 1.6);
this.rig.scale.setScalar(s);
+ if (this.shadow) this.shadow.material.opacity = Math.max(0, this.shadow.material.opacity - dt * 0.8);
} else {
- const targetYaw = c.facing >= 0 ? 0.6 : -0.6;
- this.rig.rotation.y += (targetYaw - this.rig.rotation.y) * Math.min(1, dt * 10);
+ // Smoothly turn toward the travel direction (shortest way around).
+ let d = this.char.facing - this._yaw;
+ while (d > Math.PI) d -= Math.PI * 2;
+ while (d < -Math.PI) d += Math.PI * 2;
+ this._yaw += d * Math.min(1, dt * 11);
+ this.rig.rotation.y = this._yaw;
}
this.controller?.update(dt);
@@ -803,20 +699,21 @@ function ensureStyles() {
style.textContent = `
.walk-pg{position:fixed;inset:0;z-index:2147483100;pointer-events:none;opacity:0;transition:opacity .3s ease}
.walk-pg.is-in{opacity:1}
-.walk-pg-canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;filter:drop-shadow(0 22px 26px rgba(0,0,0,.34))}
+.walk-pg-canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;filter:drop-shadow(0 16px 20px rgba(0,0,0,.28))}
.walk-pg-exit{position:fixed;top:14px;right:14px;z-index:3;pointer-events:auto;border:1px solid rgba(255,255,255,.16);background:rgba(14,16,22,.72);color:#f2f4f8;font:600 12.5px/1 system-ui,sans-serif;padding:9px 13px;border-radius:999px;cursor:pointer;backdrop-filter:blur(6px);transition:background .2s ease,transform .15s ease}
.walk-pg-exit:hover{background:rgba(220,60,60,.85)}
.walk-pg-exit:active{transform:scale(.96)}
.walk-pg-exit:focus-visible{outline:2px solid #7aa2ff;outline-offset:2px}
.walk-pg-hint{position:fixed;left:50%;bottom:22px;transform:translateX(-50%) translateY(8px);z-index:3;pointer-events:none;max-width:88vw;width:max-content;background:rgba(18,20,28,.92);color:#f2f4f8;font:500 13px/1.4 system-ui,sans-serif;padding:9px 14px;border-radius:12px;border:1px solid rgba(255,255,255,.1);box-shadow:0 10px 28px rgba(0,0,0,.35);opacity:0;transition:opacity .3s ease,transform .3s ease;text-align:center}
.walk-pg-hint.is-in{opacity:1;transform:translateX(-50%) translateY(0)}
-.walk-pg-pad{position:fixed;left:0;right:0;bottom:18px;z-index:3;display:none;justify-content:center;gap:12px;pointer-events:none}
-.walk-pg-btn{pointer-events:auto;width:60px;height:60px;border-radius:50%;border:1px solid rgba(255,255,255,.18);background:rgba(16,18,26,.78);color:#fff;font-size:22px;display:grid;place-items:center;backdrop-filter:blur(6px);-webkit-user-select:none;user-select:none;touch-action:none}
+.walk-pg-pad{position:fixed;left:18px;bottom:18px;z-index:3;display:none;flex-direction:column;align-items:center;gap:8px;pointer-events:none}
+.walk-pg-pad-row{display:flex;gap:8px;align-items:center}
+.walk-pg-btn{pointer-events:auto;width:54px;height:54px;border-radius:14px;border:1px solid rgba(255,255,255,.18);background:rgba(16,18,26,.78);color:#fff;font-size:20px;display:grid;place-items:center;backdrop-filter:blur(6px);-webkit-user-select:none;user-select:none;touch-action:none}
.walk-pg-btn:active{background:rgba(122,162,255,.5)}
-.walk-pg-jump{background:rgba(122,162,255,.32)}
-.walk-pg-flash{position:fixed;inset:0;z-index:2;pointer-events:none;background:radial-gradient(circle at 50% 50%,rgba(122,162,255,0) 0%,rgba(8,10,16,0) 60%);opacity:0;transition:opacity .55s ease}
+.walk-pg-dive{border-radius:50%;background:rgba(122,162,255,.32)}
+.walk-pg-flash{position:fixed;inset:0;z-index:2;pointer-events:none;background:radial-gradient(circle at 50% 50%,rgba(122,162,255,0) 0%,rgba(8,10,16,0) 60%);opacity:0;transition:opacity .5s ease}
.walk-pg-flash.is-on{background:radial-gradient(circle at 50% 50%,rgba(122,162,255,.25) 0%,rgba(6,8,14,.96) 70%);opacity:1}
-@media (pointer: coarse){.walk-pg-pad{display:flex}.walk-pg-hint{bottom:96px}}
+@media (pointer: coarse){.walk-pg-pad{display:flex}.walk-pg-hint{bottom:200px}}
.walk-pg-portal{outline:2px solid rgba(122,162,255,.9)!important;outline-offset:3px;border-radius:6px;box-shadow:0 0 0 4px rgba(122,162,255,.18),0 0 28px rgba(122,162,255,.45)!important;transition:box-shadow .2s ease,transform .25s ease;animation:walk-pg-pulse 1.1s ease-in-out infinite}
.walk-pg-portal.is-open{transform:scale(.94);box-shadow:0 0 0 6px rgba(122,162,255,.3),0 0 48px rgba(122,162,255,.7)!important}
@keyframes walk-pg-pulse{0%,100%{box-shadow:0 0 0 4px rgba(122,162,255,.16),0 0 22px rgba(122,162,255,.35)}50%{box-shadow:0 0 0 6px rgba(122,162,255,.3),0 0 36px rgba(122,162,255,.6)}}
@@ -857,8 +754,8 @@ export function consumeDropIn() {
return v;
}
-// Read-only snapshot of the live character + world — handy for debugging the
-// physics from the console (e.g. `__walkPlayground.state()`).
+// Read-only snapshot of the live character — handy for debugging from the
+// console (e.g. `__walkPlayground.state()`).
export function playgroundState() {
if (!_instance || !_instance.mounted) return null;
const c = _instance.char;
@@ -867,10 +764,8 @@ export function playgroundState() {
y: Math.round(c.y),
vx: Math.round(c.vx),
vy: Math.round(c.vy),
- grounded: c.grounded,
- facing: c.facing,
- platforms: _instance.platforms.length,
- onLink: !!_instance.platform?.href,
+ speed: Math.round(Math.hypot(c.vx, c.vy)),
+ onLink: !!_instance._armHref,
diving: _instance._diving,
};
}
diff --git a/tests/club-audio.test.js b/tests/club-audio.test.js
index 7dde0125a..16920caa9 100644
--- a/tests/club-audio.test.js
+++ b/tests/club-audio.test.js
@@ -140,6 +140,24 @@ class FakeConvolverNode {
}
}
+class FakeDynamicsCompressorNode {
+ constructor() {
+ this.threshold = new FakeAudioParam(-24);
+ this.knee = new FakeAudioParam(30);
+ this.ratio = new FakeAudioParam(12);
+ this.attack = new FakeAudioParam(0.003);
+ this.release = new FakeAudioParam(0.25);
+ this._connections = [];
+ }
+ connect(dest) {
+ this._connections.push(dest);
+ return dest;
+ }
+ disconnect() {
+ this._connections = [];
+ }
+}
+
class FakePannerNode {
constructor() {
this.panningModel = '';
@@ -237,6 +255,7 @@ class FakeAudioContext {
this.createdMediaSources = [];
this.createdFilters = [];
this.createdConvolvers = [];
+ this.createdCompressors = [];
this.createdPanners = [];
this.decodedBuffers = [];
this.listener = new FakeAudioListener();
@@ -266,6 +285,11 @@ class FakeAudioContext {
this.createdConvolvers.push(c);
return c;
}
+ createDynamicsCompressor() {
+ const c = new FakeDynamicsCompressorNode();
+ this.createdCompressors.push(c);
+ return c;
+ }
createBuffer(channels, length, rate) {
const data = Array.from({ length: channels }, () => new Float32Array(length));
return {
@@ -355,6 +379,22 @@ describe('ClubAudio.ensureContext', () => {
expect(audio.master.gain.value).toBeCloseTo(0.75, 3);
});
+ it('routes the master through a brick-wall limiter before the destination', async () => {
+ const audio = new ClubAudio();
+ await audio.ensureContext();
+ expect(audio.ctx.createdCompressors).toHaveLength(1);
+ expect(audio.limiter).toBeInstanceOf(FakeDynamicsCompressorNode);
+ // Master feeds the limiter, limiter feeds the destination — nothing
+ // reaches the output un-limited.
+ expect(audio.master._connections).toContain(audio.limiter);
+ expect(audio.limiter._connections).toContain(audio.ctx.destination);
+ expect(audio.master._connections).not.toContain(audio.ctx.destination);
+ // Hard-knee, high-ratio limiting with a fast attack.
+ expect(audio.limiter.knee.value).toBe(0);
+ expect(audio.limiter.ratio.value).toBeGreaterThanOrEqual(20);
+ expect(audio.limiter.attack.value).toBeLessThanOrEqual(0.005);
+ });
+
it('is idempotent — re-calling does not allocate a new context', async () => {
const audio = new ClubAudio();
await audio.ensureContext();
@@ -580,7 +620,7 @@ describe('ClubAudio.setClarity', () => {
await audio.ensureContext();
audio.setClarity(0);
expect(audio._fx.lowpass.frequency.value).toBeCloseTo(420, 0);
- expect(audio._fx.bass.gain.value).toBeCloseTo(18, 3);
+ expect(audio._fx.bass.gain.value).toBeCloseTo(10, 3);
expect(audio._fx.dry.gain.value).toBeCloseTo(0.22, 3);
expect(audio._fx.outdoorWet.gain.value).toBeCloseTo(0.85, 3);
expect(audio._fx.indoorWet.gain.value).toBeCloseTo(0.0, 3);
@@ -591,7 +631,7 @@ describe('ClubAudio.setClarity', () => {
await audio.ensureContext();
audio.setClarity(1);
expect(audio._fx.lowpass.frequency.value).toBeCloseTo(17000, 0);
- expect(audio._fx.bass.gain.value).toBeCloseTo(9, 3);
+ expect(audio._fx.bass.gain.value).toBeCloseTo(5, 3);
expect(audio._fx.dry.gain.value).toBeCloseTo(0.65, 3);
expect(audio._fx.outdoorWet.gain.value).toBeCloseTo(0.0, 3);
expect(audio._fx.indoorWet.gain.value).toBeCloseTo(0.28, 3);
@@ -602,7 +642,7 @@ describe('ClubAudio.setClarity', () => {
await audio.ensureContext();
audio.setClarity(0.5);
// Linearly-interpolated params sit between the two endpoints.
- expect(audio._fx.bass.gain.value).toBeCloseTo(13.5, 3);
+ expect(audio._fx.bass.gain.value).toBeCloseTo(7.5, 3);
expect(audio._fx.dry.gain.value).toBeCloseTo(0.435, 3);
expect(audio._fx.outdoorWet.gain.value).toBeCloseTo(0.425, 3);
expect(audio._fx.indoorWet.gain.value).toBeCloseTo(0.14, 3);