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.

Colyseus connect, avatar rig/thumb/boot, coincommunities, walk/IRL net, and changelog updates

nirholasda8ef2b76554
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0827a4a19..d576bdaad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,10 +6,12 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-06-18
+- **Coin community worlds no longer get stuck on “Connecting…”** — Opening a coin community world could occasionally hang on “Connecting…” forever — you'd see only yourself, with chat, voice, and shared building all stalled and no way to recover short of a reload. It happened when the game server accepted the connection but never finished the join handshake, for instance while a server instance was waking from idle. The connection now has a firm time limit: if the handshake doesn't complete in time it retries on its own, and if the server stays unreachable it drops you cleanly into single-player so you can still explore and build locally — with the status pill tappable to reconnect. The same safeguard covers the open /walk world and the IRL map. `[fix]`
- **Connect a wallet and your $THREE tier is recognized — no account needed** — You no longer need a three.ws account to be seen as a $THREE holder. Connect your Solana wallet and the site reads your tier straight from your on-chain holdings: the holder chip in the top bar shows your live tier (◆ Bronze, Silver, Gold…) and holder features like High-quality generation on Forge unlock from the connected wallet alone. When a feature needs proof the wallet is yours, you approve a single free signature that moves no funds. Switch or disconnect a wallet and your tier updates instantly, no reload. Signed-in accounts keep working exactly as before. (`/forge`) `[improvement]`
- **Forge checkout no longer dead-ends when generation is briefly busy** — When the 3D generator was momentarily rate-limited mid-checkout, Forge could show a raw technical error and look like the payment had failed for good. Now a brief upstream slowdown shows a clear message — your payment was not taken, and the generation retries in a few seconds — and the checkout auto-retries on its own before ever asking you to try again. Your payment only settles once the model is actually produced, so a busy moment never costs you anything. (`/forge`) `[fix]`
- **Holding $THREE now unlocks a premium feature** — $THREE gets its first hard utility: High-quality 3D generation on Forge — the 200k-polygon, PBR-textured tier — is now reserved for $THREE holders. Reach the Bronze holder tier (the entry tier) by holding $THREE and the High tier unlocks automatically, with no payment step. Draft and Standard generation stay free forever, and bring-your-own-key generation is unaffected. Sign in, link your Solana wallet, and the economy page shows your live holder tier and exactly what it unlocks. (`/three`) `[feature]`
- **Pay $THREE per High generation — no holding required** — Don't hold $THREE yet but want a High-quality model? You can now pay in $THREE for a single High generation instead. Pick High in Forge, choose "Pay" on the holder panel, and a clean payment flow prices it in $THREE, takes one wallet approval, verifies it on-chain, and runs your generation automatically. The platform now genuinely accepts $THREE for compute. One payment buys exactly one High generation, and if a generation fails before it runs your payment stays usable — you're never charged for a model you didn't get. Draft and Standard remain free, and holders still generate High straight away. (`/forge`) `[feature]`
+- **The 3D agent on the homepage moves again instead of standing frozen** — The live avatar in the homepage hero had stopped animating — it loaded but stood in a stiff arms-out pose, and the Wave, Dance, and Pray buttons did nothing. The viewer only renders frames while something is moving to save your battery, and a recent change meant that starting an animation no longer woke the renderer back up once it had gone idle, so the avatar was stuck on its first frame. The renderer is now nudged awake the instant any animation starts, so the homepage agent idles, walks, and responds to the move buttons as intended. `[fix]`
- **The animated 3D bot in the site footer renders again** — The little animated 3D robot that sits in the footer across the site — and on the sign-in page — had gone missing, leaving an empty space. The model files it loads are compressed, but the footer loader wasn't set up to unpack that format, so it failed before the bot could appear. The decoder is now wired in, so the bot loads and spins as intended everywhere the footer shows. `[fix]`
- **The disco dance floor in coin worlds works again** — Every coin world has a disco pad beside the totem that pulses to a shared beat and crossfades dancers in lockstep. A wiring gap meant the world tried to listen for a beat the connection didn't know about, which threw an error the moment you entered and left the pad dark. The beat is now delivered properly: step onto the pad, hit Dance, and you and everyone else standing on it move to the same animation on the same beat, with the floor and lights pulsing in time. (`/play`) `[fix]`
- **Your $THREE holder tier now shows across the site** — Holding $THREE is now visible everywhere you are. A holder chip in the top bar shows your live tier (◆ Bronze, Silver, Gold…) on every page and links to the full tier breakdown. On Forge, choosing the High quality tier now shows a clear, designed panel instead of a silent block: holders see an "Unlocked" badge and generate straight away, while everyone else gets a "Get $THREE" path, the exact reason (sign in, link a wallet, or hold more), and a one-tap switch back to free Draft or Standard — no dead ends and no raw errors. (`/forge`) `[feature, improvement]`
diff --git a/data/changelog.json b/data/changelog.json
index d5651e930..8b198eb95 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,22 @@
{
"$comment": "Curated changelog entries for three.ws \u2014 the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-18",
+ "title": "Coin community worlds no longer get stuck on “Connecting…”",
+ "summary": "Opening a coin community world could occasionally hang on “Connecting…” forever — you'd see only yourself, with chat, voice, and shared building all stalled and no way to recover short of a reload. It happened when the game server accepted the connection but never finished the join handshake, for instance while a server instance was waking from idle. The connection now has a firm time limit: if the handshake doesn't complete in time it retries on its own, and if the server stays unreachable it drops you cleanly into single-player so you can still explore and build locally — with the status pill tappable to reconnect. The same safeguard covers the open /walk world and the IRL map.",
+ "tags": [
+ "fix"
+ ]
+ },
+ {
+ "date": "2026-06-18",
+ "title": "The 3D agent on the homepage moves again instead of standing frozen",
+ "summary": "The live avatar in the homepage hero had stopped animating — it loaded but stood in a stiff arms-out pose, and the Wave, Dance, and Pray buttons did nothing. The viewer only renders frames while something is moving to save your battery, and a recent change meant that starting an animation no longer woke the renderer back up once it had gone idle, so the avatar was stuck on its first frame. The renderer is now nudged awake the instant any animation starts, so the homepage agent idles, walks, and responds to the move buttons as intended.",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-18",
"title": "Forge checkout no longer dead-ends when generation is briefly busy",
diff --git a/public/changelog.json b/public/changelog.json
index 2b39c5a40..a6e480092 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,11 +1,21 @@
{
- "generated_at": "2026-06-18T01:41:59.073Z",
+ "generated_at": "2026-06-18T01:57:16.378Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
"entries": [
+ {
+ "date": "2026-06-18",
+ "type": "update",
+ "title": "Coin community worlds no longer get stuck on “Connecting…”",
+ "summary": "Opening a coin community world could occasionally hang on “Connecting…” forever — you'd see only yourself, with chat, voice, and shared building all stalled and no way to recover short of a reload. It happened when the game server accepted the connection but never finished the join handshake, for instance while a server instance was waking from idle. The connection now has a firm time limit: if the handshake doesn't complete in time it retries on its own, and if the server stays unreachable it drops you cleanly into single-player so you can still explore and build locally — with the status pill tappable to reconnect. The same safeguard covers the open /walk world and the IRL map.",
+ "link": null,
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-18",
"type": "update",
@@ -46,6 +56,16 @@
"feature"
]
},
+ {
+ "date": "2026-06-18",
+ "type": "update",
+ "title": "The 3D agent on the homepage moves again instead of standing frozen",
+ "summary": "The live avatar in the homepage hero had stopped animating — it loaded but stood in a stiff arms-out pose, and the Wave, Dance, and Pray buttons did nothing. The viewer only renders frames while something is moving to save your battery, and a recent change meant that starting an animation no longer woke the renderer back up once it had gone idle, so the avatar was stuck on its first frame. The renderer is now nudged awake the instant any animation starts, so the homepage agent idles, walks, and responds to the move buttons as intended.",
+ "link": null,
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-18",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index a3db9e9f5..a9c2435e7 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -6,6 +6,14 @@
<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/>
<description>What's new on three.ws — features, improvements, and releases, newest first.</description>
<language>en</language>
+ <item>
+ <title>Coin community worlds no longer get stuck on “Connecting…”</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-18:Coin community worlds no longer get stuck on “Connecting…”</guid>
+ <pubDate>Thu, 18 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Opening a coin community world could occasionally hang on “Connecting…” forever — you'd see only yourself, with chat, voice, and shared building all stalled and no way to recover short of a reload. It happened when the game server accepted the connection but never finished the join handshake, for instance while a server instance was waking from idle. The connection now has a firm time limit: if the handshake doesn't complete in time it retries on its own, and if the server stays unreachable it drops you cleanly into single-player so you can still explore and build locally — with the status pill tappable to reconnect. The same safeguard covers the open /walk world and the IRL map.</description>
+ </item>
<item>
<title>Connect a wallet and your $THREE tier is recognized — no account needed</title>
<link>https://three.ws/forge</link>
@@ -38,6 +46,14 @@
<category>feature</category>
<description>Don't hold $THREE yet but want a High-quality model? You can now pay in $THREE for a single High generation instead. Pick High in Forge, choose &quot;Pay&quot; on the holder panel, and a clean payment flow prices it in $THREE, takes one wallet approval, verifies it on-chain, and runs your generation automatically. The platform now genuinely accepts $THREE for compute. One payment buys exactly one High generation, and if a generation fails before it runs your payment stays usable — you're never charged for a model you didn't get. Draft and Standard remain free, and holders still generate High straight away.</description>
</item>
+ <item>
+ <title>The 3D agent on the homepage moves again instead of standing frozen</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-18:The 3D agent on the homepage moves again instead of standing frozen</guid>
+ <pubDate>Thu, 18 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The live avatar in the homepage hero had stopped animating — it loaded but stood in a stiff arms-out pose, and the Wave, Dance, and Pray buttons did nothing. The viewer only renders frames while something is moving to save your battery, and a recent change meant that starting an animation no longer woke the renderer back up once it had gone idle, so the avatar was stuck on its first frame. The renderer is now nudged awake the instant any animation starts, so the homepage agent idles, walks, and responds to the move buttons as intended.</description>
+ </item>
<item>
<title>The animated 3D bot in the site footer renders again</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index 1f1611fc6..c568a7f06 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-18T01:41:59.046Z",
+ "generated_at": "2026-06-18T01:57:16.360Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/game/avatar-rig.js b/src/game/avatar-rig.js
index d503aab14..2545093f4 100644
--- a/src/game/avatar-rig.js
+++ b/src/game/avatar-rig.js
@@ -14,6 +14,7 @@ import {
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
import { AnimationManager } from '../animation-manager.js';
+import { getMeshoptDecoder } from '../viewer/internal.js';
import { GUEST_SENTINEL, resolveGuestAvatar } from './play-handoff.js';
import { log } from '../shared/log.js';
@@ -30,8 +31,20 @@ const _draco = new DRACOLoader();
_draco.setDecoderPath('/three/draco/gltf/');
const _gltf = new GLTFLoader();
_gltf.setDRACOLoader(_draco);
-// Exported so other loaders (avatar-thumb) share one decoder module + cache.
+// Many avatar GLBs — including the platform's own /avatars/default.glb — ship
+// with EXT_meshopt_compression. Without the meshopt decoder, GLTFLoader throws
+// "setMeshoptDecoder must be called before loading compressed files" on the very
+// first bufferView and every avatar silently falls back to a capsule stand-in.
+// Wire the shared, memoized decoder once and gate loads on it (see meshoptReady)
+// so the first avatar parses too. getMeshoptDecoder lazy-imports the small
+// meshopt module and is shared with the rest of the app (footer-bot, viewer).
+const meshoptReady = getMeshoptDecoder()
+ .then((decoder) => { _gltf.setMeshoptDecoder(decoder); return decoder; })
+ .catch((e) => { log.warn('[avatar-rig] meshopt decoder unavailable:', e?.message); return null; });
+// Exported so other loaders (avatar-thumb, boot-avatar) share one decoder module
+// + cache and can wire it onto their own GLTFLoader instances.
export const dracoLoader = _draco;
+export { meshoptReady };
let _animDefs = null; // cached manifest defs (locomotion + emotes)
let _emoteDefs = null;
let _allEmoteDefs = null; // all non-locomotion emotes for the wheel
@@ -113,6 +126,7 @@ function headAnchorHeight(box) {
// user their model didn't load instead of silently swapping it.
export async function buildAvatar(rig, url, anim) {
try {
+ await meshoptReady; // ensure meshopt-compressed GLBs (incl. the default) parse
const gltf = await _gltf.loadAsync(url);
const model = gltf.scene;
model.traverse((n) => { if (n.isMesh) { n.castShadow = true; n.receiveShadow = false; } });
diff --git a/src/game/avatar-thumb.js b/src/game/avatar-thumb.js
index 2c9bc2dc6..6640644bc 100644
--- a/src/game/avatar-thumb.js
+++ b/src/game/avatar-thumb.js
@@ -12,14 +12,17 @@ import {
} from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { AnimationManager } from '../animation-manager.js';
-import { loadManifest, getLocomotionDefs, CLIP_IDLE, dracoLoader } from './avatar-rig.js';
+import { loadManifest, getLocomotionDefs, CLIP_IDLE, dracoLoader, meshoptReady } from './avatar-rig.js';
import { log } from '../shared/log.js';
const SIZE = 160; // square render target, downscaled by the chip's CSS box
-// Share the rig's Draco-enabled loader so compressed avatar GLBs preview too.
+// Share the rig's Draco-enabled loader so compressed avatar GLBs preview too,
+// plus the shared meshopt decoder so EXT_meshopt_compression GLBs (incl. the
+// default avatar) preview instead of throwing.
const _loader = new GLTFLoader();
_loader.setDRACOLoader(dracoLoader);
+meshoptReady.then((decoder) => { if (decoder) _loader.setMeshoptDecoder(decoder); });
const _cache = new Map(); // url -> Promise<string|null> (PNG data URL)
let _renderer = null;
let _scene = null;
@@ -64,6 +67,7 @@ export function renderAvatarThumb(url) {
async function _snapshot(url) {
if (!ensureRenderer()) return null;
+ await meshoptReady; // ensure the decoder is wired before the first parse
const gltf = await _loader.loadAsync(url);
const model = gltf.scene;
model.traverse((n) => { if (n.isMesh) n.frustumCulled = false; });
diff --git a/src/game/boot-avatar.js b/src/game/boot-avatar.js
index f6fa08dc3..c769e6a5a 100644
--- a/src/game/boot-avatar.js
+++ b/src/game/boot-avatar.js
@@ -23,7 +23,7 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { AnimationManager } from '../animation-manager.js';
import {
AVATAR_DEFAULT, loadManifest, getLocomotionDefs, CLIP_IDLE,
- resolveAvatarUrl, dracoLoader,
+ resolveAvatarUrl, dracoLoader, meshoptReady,
} from './avatar-rig.js';
import { getRequestedAvatar } from './play-handoff.js';
import { log } from '../shared/log.js';
@@ -69,12 +69,14 @@ function boot() {
// agent's GLB via a "See in 3D" link) if present, otherwise the one the player
// chose (persisted in cc-avatar by the lobby / a create→play handoff) — not a
// generic default, so the first character they see while the scene loads is the
- // right one. DRACO is wired in
- // because most avatar GLBs are compressed. Falls back to the default on any
- // resolve/load failure so a broken pick never wedges the loader.
+ // right one. DRACO and meshopt are both wired in because most avatar GLBs are
+ // compressed (the default avatar uses EXT_meshopt_compression). Falls back to
+ // the default on any resolve/load failure so a broken pick never wedges the loader.
const loader = new GLTFLoader();
loader.setDRACOLoader(dracoLoader);
- resolveAvatarUrl(getRequestedAvatar())
+ meshoptReady
+ .then((decoder) => { if (decoder) loader.setMeshoptDecoder(decoder); })
+ .then(() => resolveAvatarUrl(getRequestedAvatar()))
.then((chosen) => loader.loadAsync(chosen).catch(() => loader.loadAsync(AVATAR_DEFAULT)))
.then(async (gltf) => {
if (!alive) return;
diff --git a/src/game/coincommunities.css b/src/game/coincommunities.css
index ab8a9e224..5b6dfc360 100644
--- a/src/game/coincommunities.css
+++ b/src/game/coincommunities.css
@@ -130,6 +130,32 @@ html[data-bg="transparent"] #cc-lobby {
.kx-boot-bar span { animation: none; width: 100%; transform: none; opacity: 0.5; }
.kx-boot-stage.kx-boot-noavatar .kx-boot-fallback { animation: none; }
}
+/* Boot failure (most often no WebGL): the spinner is swapped for this card so a
+ player never gets stranded on a loader that can't resolve. */
+.kx-boot-error { max-width: 360px; gap: 14px; padding: 0 24px; }
+.kx-boot-error .kx-loading-mark { color: var(--cc-text); animation: none; opacity: 1; }
+.kx-boot-error-msg {
+ margin: 0; color: var(--cc-dim); font-size: 13px; line-height: 1.55;
+ letter-spacing: 0.01em; text-wrap: balance;
+}
+.kx-boot-error-actions { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
+.kx-boot-error-btn {
+ appearance: none; cursor: pointer; font: inherit;
+ background: var(--cc-accent); color: var(--cc-ink);
+ border: 0; border-radius: var(--cc-radius);
+ padding: 9px 18px; font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
+ transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
+}
+.kx-boot-error-btn:hover { box-shadow: var(--cc-glow); transform: translateY(-1px); }
+.kx-boot-error-btn:active { transform: translateY(0); opacity: 0.9; }
+.kx-boot-error-btn:focus-visible { outline: 2px solid var(--cc-edge-hi); outline-offset: 2px; }
+.kx-boot-error-link {
+ color: var(--cc-dim); font-size: 13px; text-decoration: none;
+ border-bottom: 1px solid var(--cc-edge-soft); padding-bottom: 1px;
+ transition: color 0.12s ease, border-color 0.12s ease;
+}
+.kx-boot-error-link:hover { color: var(--cc-text); border-color: var(--cc-edge-hi); }
+.kx-boot-error-link:focus-visible { outline: 2px solid var(--cc-edge-hi); outline-offset: 2px; border-radius: 1px; }
/* ---------------- lobby ---------------- */
#cc-lobby {
diff --git a/src/game/coincommunities.js b/src/game/coincommunities.js
index 9fe726b81..584058031 100644
--- a/src/game/coincommunities.js
+++ b/src/game/coincommunities.js
@@ -451,7 +451,19 @@ export class CoinCommunities {
// ---------------------------------------------------------------- render
_initRenderer() {
- const r = new WebGLRenderer({ canvas: this.canvas, antialias: true, alpha: this._transparentBg });
+ let r;
+ try {
+ r = new WebGLRenderer({ canvas: this.canvas, antialias: true, alpha: this._transparentBg });
+ } catch (err) {
+ // WebGL context creation fails on blocklisted GPUs, machines with
+ // hardware acceleration disabled, and some in-app/embedded browsers.
+ // Tag the failure so the boot guard can show a recovery message instead
+ // of leaving the player on a dead loader — boot-avatar.js already
+ // degrades gracefully, and the main scene must too.
+ const e = new Error('WebGL unavailable: ' + (err?.message || err));
+ e.code = 'NO_WEBGL';
+ throw e;
+ }
r.setPixelRatio(Math.min(window.devicePixelRatio, 2));
r.setSize(window.innerWidth, window.innerHeight);
if (this._transparentBg) r.setClearColor(0x000000, 0);
@@ -2697,8 +2709,71 @@ export class CoinCommunities {
}
}
+// Swap the boot loader for an actionable error state. The scene constructor
+// builds the renderer, scene, and HUD synchronously, so any failure there (most
+// often WebGL being unavailable) would otherwise leave the player staring at a
+// loader that never resolves. This replaces the spinner with a clear message and
+// a recovery path instead of a dead screen.
+function renderBootError(err) {
+ log.error('[coincommunities] boot failed:', err);
+ const noWebGL = err?.code === 'NO_WEBGL' || /webgl|context/i.test(err?.message || '');
+
+ let overlay = document.getElementById('kx-loading');
+ if (!overlay) {
+ overlay = document.createElement('div');
+ overlay.id = 'kx-loading';
+ document.body.appendChild(overlay);
+ }
+ overlay.classList.remove('kx-hidden');
+ overlay.replaceChildren();
+
+ // The boot avatar's render loop targets a canvas we're about to remove — stop
+ // it so it doesn't tick against a detached element.
+ try { window.__ccBootAvatar?.dispose?.(); } catch { /* best-effort teardown */ }
+
+ const card = document.createElement('div');
+ card.className = 'kx-loading-card kx-boot-error';
+ card.setAttribute('role', 'alert');
+
+ const mark = document.createElement('div');
+ mark.className = 'kx-loading-mark';
+ mark.textContent = noWebGL ? 'WebGL unavailable' : 'Couldn’t load the world';
+ card.appendChild(mark);
+
+ const msg = document.createElement('p');
+ msg.className = 'kx-boot-error-msg';
+ msg.textContent = noWebGL
+ ? 'Your browser couldn’t start 3D graphics. Turn on hardware acceleration (or WebGL) and reload — on most browsers it’s under Settings › System.'
+ : 'Something went wrong starting Coin Communities. Reload to try again — if it keeps happening, your browser may be out of date.';
+ card.appendChild(msg);
+
+ const actions = document.createElement('div');
+ actions.className = 'kx-boot-error-actions';
+
+ const retry = document.createElement('button');
+ retry.type = 'button';
+ retry.className = 'kx-boot-error-btn';
+ retry.textContent = 'Try again';
+ retry.addEventListener('click', () => location.reload());
+ actions.appendChild(retry);
+
+ const home = document.createElement('a');
+ home.className = 'kx-boot-error-link';
+ home.href = '/';
+ home.textContent = 'Back to three.ws';
+ actions.appendChild(home);
+
+ card.appendChild(actions);
+ overlay.appendChild(card);
+ retry.focus();
+}
+
const canvas = document.getElementById('kx-canvas') || document.getElementById('cc-canvas');
if (canvas) {
- const game = new CoinCommunities(canvas);
- if (typeof window !== 'undefined') window.__CC__ = game;
+ try {
+ const game = new CoinCommunities(canvas);
+ if (typeof window !== 'undefined') window.__CC__ = game;
+ } catch (err) {
+ renderBootError(err);
+ }
}
diff --git a/src/game/community-net.js b/src/game/community-net.js
index 9577127a7..d9057e8e5 100644
--- a/src/game/community-net.js
+++ b/src/game/community-net.js
@@ -12,6 +12,7 @@
import { Client, getStateCallbacks } from 'colyseus.js';
import { WalkState } from '../../multiplayer/src/schemas.js';
import { log } from '../shared/log.js';
+import { joinRoomWithTimeout } from '../shared/colyseus-connect.js';
const ROOM_NAME = 'walk_world';
const RECONNECT_BASE_MS = 3000;
@@ -250,7 +251,11 @@ export class CommunityNet {
options.holderPass = this.holderPass;
options.holderMinUsd = this.holderMinUsd;
}
- const room = await this.client.joinOrCreate(ROOM_NAME, options, WalkState);
+ // Hard timeout on the join: a hung handshake (Cloud Run cold start, wedged
+ // room, proxy holding the upgrade) would otherwise strand us in 'connecting'
+ // forever — joinOrCreate has no timeout of its own. On timeout this throws
+ // 'connect_timeout', falling through to the catch → reconnect with backoff.
+ const room = await joinRoomWithTimeout(this.client, ROOM_NAME, options, WalkState);
if (this._destroyed || gen !== this._connectGen) {
try { room.leave(); } catch {}
return;
diff --git a/src/game/play-systems.css b/src/game/play-systems.css
index 622b46698..1abc488b9 100644
--- a/src/game/play-systems.css
+++ b/src/game/play-systems.css
@@ -440,9 +440,25 @@
/* ---- Responsive: tuck the HUD in on small screens ---- */
@media (max-width: 560px) {
.ps-gold { top: 70px; left: 10px; }
- .ps-rail { top: auto; bottom: 150px; transform: none; right: 10px; }
- .ps-hotbar { bottom: 70px; gap: 4px; padding: 5px; }
- .ps-slot { width: 40px; height: 40px; }
- .ps-action { bottom: 126px; }
+ /* The bottom-left corner belongs to the movement joystick (#cc-joystick:
+ left 16px, bottom 20px, 104px tall → occupies up to ~124px from the bottom).
+ The hotbar is centred and wide, so at phone widths its left slots used to sit
+ on top of the joystick — and because #ps-hud (z 23) paints above #cc-hud
+ (z 20, the joystick's stacking context), those slots won the touch hit-test
+ and swallowed every drag. The avatar couldn't be moved at all. Lift the hotbar
+ into a clear band above the joystick and the bottom-right emote/reaction stack
+ (which tops out at ~138px), and let it scroll horizontally so it never
+ overflows a narrow screen. */
+ .ps-hotbar {
+ bottom: 150px; gap: 4px; padding: 5px;
+ left: 50%; transform: translateX(-50%);
+ max-width: calc(100vw - 20px); overflow-x: auto; scrollbar-width: none;
+ }
+ .ps-hotbar::-webkit-scrollbar { display: none; }
+ .ps-slot { width: 40px; height: 40px; flex: 0 0 auto; }
+ /* Contextual action button and tool rail ride above the lifted hotbar so the
+ bottom-left joystick zone stays completely clear. */
+ .ps-action { bottom: 208px; }
+ .ps-rail { top: auto; bottom: 232px; transform: none; right: 10px; }
.ps-panel { right: 10px; left: 10px; width: auto; max-width: none; }
}
diff --git a/src/irl-net.js b/src/irl-net.js
index 47410ea9c..1152de435 100644
--- a/src/irl-net.js
+++ b/src/irl-net.js
@@ -18,6 +18,7 @@
import { Client, getStateCallbacks } from 'colyseus.js';
import { IrlState } from '../multiplayer/src/irl-schemas.js';
+import { joinRoomWithTimeout } from './shared/colyseus-connect.js';
import { encodeGeohash } from '../multiplayer/src/geohash.js';
import { log } from './shared/log.js';
@@ -154,7 +155,11 @@ export class IrlNet {
this.client = new Client(this.url);
// `geocell` is the server's filterBy key (matchmaking): every viewer in the
// same precision-6 cell joins one room instance.
- const room = await this.client.joinOrCreate(ROOM_NAME, {
+ // Hard timeout on the join: a hung handshake would otherwise strand us in
+ // 'connecting' forever — joinOrCreate has no timeout. On timeout this throws
+ // and the catch below schedules a reconnect (then settles into 'unavailable',
+ // where irl.js falls back to the proximity poll).
+ const room = await joinRoomWithTimeout(this.client, ROOM_NAME, {
geocell: this.geocell,
deviceToken: this.deviceToken,
agent: this.agent,
diff --git a/src/shared/colyseus-connect.js b/src/shared/colyseus-connect.js
new file mode 100644
index 000000000..590c4b324
--- /dev/null
+++ b/src/shared/colyseus-connect.js
@@ -0,0 +1,63 @@
+// ── colyseus-connect.js — bounded room join for every multiplayer client ────
+//
+// Colyseus's `joinOrCreate` resolves only after the server completes the
+// JOIN_ROOM handshake that follows the WebSocket open — and it gives that wait
+// no timeout. A socket that opens but never finishes the handshake leaves the
+// promise pending *forever*: it neither resolves nor rejects. That happens in
+// the wild more than the happy path suggests —
+// • a Cloud Run instance scaled to zero accepts the upgrade while still
+// cold-booting the room process,
+// • a wedged or GC-paused room never sends JOIN_ROOM,
+// • a proxy / load balancer holds the upgrade open without forwarding it.
+//
+// With no rejection there is no `catch`, so the client is stranded in a
+// terminal 'connecting' state: the status pill reads "Connecting…" indefinitely
+// and the reconnect/offline fallback (which only fires on an error) never runs.
+// That is the stuck-on-connecting bug this guard removes.
+//
+// We race the join against a hard timeout. If the join wins, its room is
+// returned unchanged. If the timeout wins we throw a tagged
+// `Error('connect_timeout')` so the caller's existing catch reconnects with
+// backoff (and, after its attempts are spent, falls back to single-player).
+//
+// A join that resolves *after* the timeout fired is abandoned and its room is
+// left — a zombie handshake must never orphan a second live socket, which would
+// double-deliver every broadcast (the duplicate-chat leak the callers' own
+// generation guards also defend against).
+
+// Generous enough to clear a Cloud Run cold start (instance boot + room spawn +
+// handshake), tight enough that a genuinely dead endpoint surfaces an error and
+// reconnects rather than hanging. Reconnect backoff handles the retry cadence.
+export const CONNECT_TIMEOUT_MS = 15_000;
+
+/**
+ * Join (or create) a Colyseus room with a hard client-side timeout.
+ *
+ * @template T
+ * @param {import('colyseus.js').Client} client a live Colyseus client
+ * @param {string} roomName matchmaking room name
+ * @param {Record<string, unknown>} options join options (filterBy keys, identity…)
+ * @param {T} schema the room state schema class
+ * @param {number} [timeoutMs] join deadline; defaults to CONNECT_TIMEOUT_MS
+ * @returns {Promise<import('colyseus.js').Room>} the joined room
+ * @throws {Error} `connect_timeout` if the handshake doesn't complete in time
+ */
+export async function joinRoomWithTimeout(client, roomName, options, schema, timeoutMs = CONNECT_TIMEOUT_MS) {
+ const joinPromise = client.joinOrCreate(roomName, options, schema);
+ let timer = null;
+ let timedOut = false;
+ try {
+ return await Promise.race([
+ joinPromise,
+ new Promise((_, reject) => {
+ timer = setTimeout(() => { timedOut = true; reject(new Error('connect_timeout')); }, timeoutMs);
+ }),
+ ]);
+ } finally {
+ clearTimeout(timer);
+ // If the timeout won the race, the join may still be in flight. Attach
+ // handlers now (the second `() => {}` swallows a late rejection so it never
+ // surfaces as an unhandled promise) and leave any room it eventually yields.
+ if (timedOut) joinPromise.then((room) => { try { room.leave(); } catch {} }, () => {});
+ }
+}
diff --git a/src/viewer.js b/src/viewer.js
index 782909d9d..919fdb435 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -82,6 +82,17 @@ export class Viewer {
// External animation system (Mixamo-style)
this.animationManager = new AnimationManager();
this._animPanelEl = null;
+ // Restart the on-demand render loop whenever an external clip starts.
+ // crossfadeTo/play set currentAction asynchronously and hold no viewer
+ // reference, so onChange is the only signal that a new action is live —
+ // without invalidating here, a clip started after the load-reveal frames
+ // settle would never tick the mixer and the avatar would freeze in its
+ // bind pose (T-pose). Wired at construction so it survives kiosk mode,
+ // where _setupAnimationPanel (and its own onChange) is skipped.
+ this.animationManager.onChange = () => {
+ if (this._animPanelEl) this._renderAnimButtons();
+ this.invalidate();
+ };
this.state = {
environment:
@@ -1752,10 +1763,9 @@ export class Viewer {
this.invalidate();
});
- // Listen for changes from AnimationManager
- this.animationManager.onChange = () => {
- this._renderAnimButtons();
- };
+ // onChange (render panel buttons + invalidate the render loop) is wired
+ // once in the constructor so it also runs in kiosk mode, where this panel
+ // setup is skipped entirely.
}
/**
diff --git a/src/walk-net.js b/src/walk-net.js
index 22a27a28f..a3e9e03be 100644
--- a/src/walk-net.js
+++ b/src/walk-net.js
@@ -15,6 +15,7 @@
import { Client, getStateCallbacks } from 'colyseus.js';
import { WalkState } from '../multiplayer/src/schemas.js';
import { log } from './shared/log.js';
+import { joinRoomWithTimeout } from './shared/colyseus-connect.js';
const ROOM_NAME = 'walk_world';
const SEND_HZ = 15;
@@ -172,7 +173,11 @@ export class WalkNet {
// same coin mint join one room instance. `coin`/`coinName`/… seed that
// room's identity the first time it's created. Empty coin → mainland.
const presence = this.getPresence ? await this.getPresence().catch(() => null) : null;
- const room = await this.client.joinOrCreate(ROOM_NAME, {
+ // Hard timeout on the join: a hung handshake (cold-start server, proxy
+ // holding the WS upgrade) would otherwise strand us in 'connecting'
+ // forever — joinOrCreate has no timeout. On timeout this throws and the
+ // catch below schedules a reconnect.
+ const room = await joinRoomWithTimeout(this.client, ROOM_NAME, {
name: this.name,
avatar: this.avatar,
agent: this.agent,
diff --git a/tests/colyseus-connect.test.js b/tests/colyseus-connect.test.js
new file mode 100644
index 000000000..d96800d3b
--- /dev/null
+++ b/tests/colyseus-connect.test.js
@@ -0,0 +1,71 @@
+// joinRoomWithTimeout — the bounded room join shared by every multiplayer client
+// (community-net, walk-net, irl-net). Colyseus's joinOrCreate never times out the
+// post-open JOIN_ROOM handshake, so a hung handshake would strand a client in a
+// terminal 'connecting' state forever. These lock in that the helper either
+// returns the room in time, or throws 'connect_timeout' AND leaves a room that
+// resolves too late (so a zombie handshake can't orphan a second live socket).
+
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+
+import { joinRoomWithTimeout, CONNECT_TIMEOUT_MS } from '../src/shared/colyseus-connect.js';
+
+// A fake Colyseus client whose joinOrCreate resolves/rejects/hangs on command.
+function clientThatJoins(behaviour) {
+ return { joinOrCreate: vi.fn(() => behaviour()) };
+}
+
+describe('joinRoomWithTimeout', () => {
+ beforeEach(() => vi.useFakeTimers());
+ afterEach(() => vi.useRealTimers());
+
+ it('returns the room when the join resolves before the deadline', async () => {
+ const room = { id: 'r1', leave: vi.fn() };
+ const client = clientThatJoins(() => Promise.resolve(room));
+
+ const p = joinRoomWithTimeout(client, 'walk_world', { coin: '' }, {});
+ await expect(p).resolves.toBe(room);
+ expect(client.joinOrCreate).toHaveBeenCalledWith('walk_world', { coin: '' }, {});
+ expect(room.leave).not.toHaveBeenCalled();
+ });
+
+ it('throws connect_timeout when the handshake never completes', async () => {
+ // A join that never settles — the exact stuck-on-connecting case.
+ const client = clientThatJoins(() => new Promise(() => {}));
+
+ const p = joinRoomWithTimeout(client, 'walk_world', {}, {}, 15_000);
+ const assertion = expect(p).rejects.toThrow('connect_timeout');
+ await vi.advanceTimersByTimeAsync(15_000);
+ await assertion;
+ });
+
+ it('leaves a room that resolves AFTER the timeout fired (no orphaned socket)', async () => {
+ const room = { id: 'late', leave: vi.fn() };
+ let resolveJoin;
+ const client = clientThatJoins(() => new Promise((res) => { resolveJoin = res; }));
+
+ const p = joinRoomWithTimeout(client, 'walk_world', {}, {}, 5_000);
+ const assertion = expect(p).rejects.toThrow('connect_timeout');
+ await vi.advanceTimersByTimeAsync(5_000);
+ await assertion;
+
+ // The zombie handshake completes late — its room must be left, not leaked.
+ resolveJoin(room);
+ await vi.advanceTimersByTimeAsync(0);
+ expect(room.leave).toHaveBeenCalledTimes(1);
+ });
+
+ it('propagates a real join rejection unchanged (not masked as a timeout)', async () => {
+ const client = clientThatJoins(() => Promise.reject(new Error('4215: room locked')));
+
+ await expect(joinRoomWithTimeout(client, 'walk_world', {}, {})).rejects.toThrow('4215: room locked');
+ });
+
+ it('defaults to the shared CONNECT_TIMEOUT_MS deadline', async () => {
+ const client = clientThatJoins(() => new Promise(() => {}));
+
+ const p = joinRoomWithTimeout(client, 'walk_world', {}, {});
+ const assertion = expect(p).rejects.toThrow('connect_timeout');
+ await vi.advanceTimersByTimeAsync(CONNECT_TIMEOUT_MS);
+ await assertion;
+ });
+});