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(game): add isometric /game world; extract shared avatar-rig module

nirholas6c2d5f34ca34
diff --git a/pages/game.html b/pages/game.html
new file mode 100644
index 000000000..b39bf4d21
--- /dev/null
+++ b/pages/game.html
@@ -0,0 +1,85 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Adventure · three.ws</title>
+ <meta
+ name="viewport"
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
+ />
+ <meta
+ name="description"
+ content="Adventure mode on three.ws — an isometric MMO. Gather wood and ore, fight, level up your skills, bank your loot, and explore a shared world with players worldwide."
+ />
+ <meta name="theme-color" content="#0d1420" />
+
+ <!--
+ Multiplayer server URL — the deployed Colyseus host (Cloud Run).
+ Local dev ignores this and uses ws://localhost:2567 automatically
+ (see defaultServerUrl in src/game/game-net.js), so
+ `npm run dev:walk-all` works out of the box.
+ -->
+ <meta name="game-server" content="wss://three-ws-multiplayer-93741856042.us-central1.run.app" />
+
+ <link rel="shortcut icon" href="/favicon.ico" />
+
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:title" content="Adventure · three.ws" />
+ <meta property="og:description" content="An isometric MMO on three.ws — gather, fight, level up, and explore a shared world." />
+ <meta property="og:url" content="https://three.ws/game" />
+
+ <link rel="stylesheet" href="/src/game/iso-game.css" />
+ </head>
+ <body>
+ <canvas id="kg-canvas"></canvas>
+
+ <!-- Projected nameplates layer -->
+ <div id="kg-labels"></div>
+
+ <!-- In-world HUD -->
+ <header id="kg-topbar" hidden>
+ <span id="kg-realm">Mainland</span>
+ <span class="kg-stat">online <b id="kg-online">0</b></span>
+ <span id="kg-status" data-status="connecting">connecting</span>
+ </header>
+
+ <div id="kg-toasts"></div>
+ <div id="kg-joystick"></div>
+
+ <div id="kg-hint" hidden>
+ <kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> move · drag to rotate · scroll to zoom
+ </div>
+
+ <!-- Start overlay -->
+ <div id="kg-start" class="kg-overlay" hidden>
+ <div class="kg-card">
+ <div class="kg-eyebrow">three.ws · adventure</div>
+ <h1 class="kg-title">Enter the world</h1>
+ <p class="kg-sub">Gather, fight, and level up across a shared isometric realm. Pick a name and drop in.</p>
+ <label class="kg-field">
+ <input id="kg-name" type="text" maxlength="24" autocomplete="off" aria-label="Display name" placeholder="guest" />
+ </label>
+ <button id="kg-start-btn" class="kg-btn" type="button">Enter world</button>
+ <div class="kg-feats">
+ <span class="kg-feat">Woodcutting</span>
+ <span class="kg-feat">Mining</span>
+ <span class="kg-feat">Combat</span>
+ <span class="kg-feat">Banking</span>
+ </div>
+ </div>
+ </div>
+
+ <!-- Offline overlay -->
+ <div id="kg-offline" class="kg-overlay" hidden>
+ <div class="kg-card">
+ <div class="kg-eyebrow">three.ws · adventure</div>
+ <h1 class="kg-title">Disconnected</h1>
+ <p class="kg-sub" id="kg-offline-msg">Couldn’t reach the game server.</p>
+ <button id="kg-retry" class="kg-btn" type="button">Reconnect</button>
+ </div>
+ </div>
+
+ <script type="module" src="/src/game/iso-game.js"></script>
+ </body>
+</html>
diff --git a/public/features.json b/public/features.json
index 41e1a71a2..0004190b1 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-05-30T10:28:41.252Z",
+ "generated_at": "2026-05-30T12:28:40.975Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/scripts/test-joystick.mjs b/scripts/test-joystick.mjs
new file mode 100644
index 000000000..8ad96c6fd
--- /dev/null
+++ b/scripts/test-joystick.mjs
@@ -0,0 +1,67 @@
+// Headless proof that the /play joystick actually drives the avatar.
+// Loads the real page, enters world phase, then performs a REAL mouse-drag on
+// the joystick (the exact path the bug lived in: nipplejs v1 event parsing) and
+// asserts the local avatar position changes. Fails loudly on any console error.
+import { chromium } from 'playwright';
+
+const BASE = process.env.BASE || 'http://localhost:3000';
+const errors = [];
+
+const browser = await chromium.launch();
+const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
+page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
+page.on('pageerror', (e) => errors.push('pageerror: ' + e.message));
+
+await page.goto(`${BASE}/pages/play.html`, { waitUntil: 'load' });
+await page.waitForFunction(() => !!window.__CC__, { timeout: 10000 });
+
+// Put the scene into world phase (bypassing the multiplayer server — we are
+// testing input→movement, not netcode) and mount the joystick.
+const setup = await page.evaluate(() => {
+ const cc = window.__CC__;
+ cc.phase = 'world';
+ document.getElementById('cc-lobby').hidden = true; // clear the overlay off the stick
+ document.getElementById('cc-hud').hidden = false;
+ cc._initJoystick();
+ const z = document.getElementById('cc-joystick').getBoundingClientRect();
+ return {
+ nippleReady: !!cc._nipple,
+ center: { x: z.x + z.width / 2, y: z.y + z.height / 2 },
+ before: { x: cc.localPos.x, z: cc.localPos.z },
+ };
+});
+if (!setup.nippleReady) { console.error('❌ nipplejs did not initialise'); await browser.close(); process.exit(1); }
+
+// Real mouse drag: press on the stick, push UP (forward), hold.
+await page.mouse.move(setup.center.x, setup.center.y);
+await page.mouse.down();
+await page.mouse.move(setup.center.x, setup.center.y - 46, { steps: 6 });
+
+// Let the running rAF loop integrate the movement intent for a few frames.
+await page.waitForTimeout(350);
+const mid = await page.evaluate(() => ({
+ joy: window.__CC__._joy ? { ...window.__CC__._joy } : null,
+ pos: { x: window.__CC__.localPos.x, z: window.__CC__.localPos.z },
+}));
+
+await page.mouse.up();
+await page.waitForTimeout(50);
+const after = await page.evaluate(() => ({ joy: window.__CC__._joy }));
+
+await browser.close();
+
+const moved = Math.hypot(mid.pos.x - setup.before.x, mid.pos.z - setup.before.z);
+console.log('console errors :', errors.length ? errors : 'none');
+console.log('_joy on drag :', mid.joy);
+console.log('pos before :', setup.before);
+console.log('pos after drag :', mid.pos);
+console.log('distance moved :', moved.toFixed(3), 'm');
+console.log('_joy on release:', after.joy);
+
+let pass = true;
+if (errors.length) { console.error('❌ console errors present'); pass = false; }
+if (!mid.joy) { console.error('❌ joystick drag did not set _joy (handler threw or no payload)'); pass = false; }
+if (moved < 0.05) { console.error('❌ avatar did not move on joystick drag'); pass = false; }
+if (after.joy !== null && after.joy !== undefined) { console.error('❌ _joy not cleared on release'); pass = false; }
+console.log(pass ? '\n✅ JOYSTICK WORKS — a real drag moves the avatar' : '\n❌ JOYSTICK TEST FAILED');
+process.exit(pass ? 0 : 1);
diff --git a/src/game/avatar-rig.js b/src/game/avatar-rig.js
new file mode 100644
index 000000000..22c22c01d
--- /dev/null
+++ b/src/game/avatar-rig.js
@@ -0,0 +1,101 @@
+// Shared avatar rig helpers — the single path for loading a GLB/VRM avatar into
+// a Three.js rig, wiring its AnimationManager (idle/walk + emotes), and playing
+// one-shot emotes. Used by every multiplayer 3D scene (the social walkaround in
+// coincommunities.js, the isometric RPG in iso-game.js) so avatar loading,
+// fallbacks, and the animation clip set never drift between experiences.
+//
+// Scene-specific concerns (chat bubbles, nameplates, position interpolation,
+// HP bars) live in each scene's own player class — this module only owns the
+// model + animation rig.
+
+import {
+ Group, Box3, Mesh, MeshStandardMaterial, CapsuleGeometry, SphereGeometry,
+} from 'three';
+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+import { AnimationManager } from '../animation-manager.js';
+
+export const AVATAR_DEFAULT = '/avatars/default.glb';
+export const MANIFEST_URL = '/animations/manifest.json';
+export const CLIP_IDLE = 'idle';
+export const CLIP_WALK = 'av-walk-feminine';
+
+const _gltf = new GLTFLoader();
+let _animDefs = null; // cached manifest defs (locomotion + emotes)
+let _emoteDefs = null;
+
+// Fetch the animation manifest once and cache the locomotion + emote clip defs.
+// Idempotent: safe to await from multiple scenes.
+export async function loadManifest() {
+ if (_animDefs) return;
+ let manifest = [];
+ try {
+ const r = await fetch(MANIFEST_URL, { cache: 'force-cache' });
+ if (r.ok) manifest = await r.json();
+ } catch { /* fall through to locomotion-only */ }
+ const byName = (n) => manifest.find((d) => d.name === n);
+ const loco = [byName(CLIP_IDLE), byName(CLIP_WALK)].filter(Boolean);
+ const emotes = manifest.filter((d) => d.name !== CLIP_IDLE && d.name !== CLIP_WALK).slice(0, 6);
+ _emoteDefs = emotes;
+ _animDefs = [...loco, ...emotes];
+}
+
+// The emote clip defs loaded by loadManifest() (empty until it resolves).
+export function getEmoteDefs() {
+ return _emoteDefs || [];
+}
+
+// Resolve an avatar input (GLB/VRM URL, site path, or three.ws avatar id) to a
+// loadable model URL. Falls back to the default avatar on anything unresolved.
+export async function resolveAvatarUrl(input) {
+ const v = (input || '').trim();
+ if (!v) return AVATAR_DEFAULT;
+ if (/^https?:\/\//i.test(v) || v.startsWith('/')) return v;
+ try {
+ const r = await fetch(`/api/avatars/${encodeURIComponent(v)}`, { headers: { accept: 'application/json' } });
+ if (r.ok) { const { avatar } = await r.json(); if (avatar?.url) return avatar.url; }
+ } catch { /* ignore */ }
+ return AVATAR_DEFAULT;
+}
+
+// Load a GLB avatar into a rig + wire an AnimationManager (idle/walk/emotes).
+// Returns { height }. On failure, drops in a capsule stand-in so the player is
+// never invisible.
+export async function buildAvatar(rig, url, anim) {
+ try {
+ const gltf = await _gltf.loadAsync(url);
+ const model = gltf.scene;
+ model.traverse((n) => { if (n.isMesh) { n.castShadow = true; n.receiveShadow = false; } });
+ const box = new Box3().setFromObject(model);
+ model.position.y -= box.min.y;
+ rig.add(model);
+ anim.attach(model);
+ if (_animDefs?.length) { anim.setAnimationDefs(_animDefs); await anim.loadAll(); await anim.crossfadeTo(CLIP_IDLE, 0); }
+ return { height: Math.max(0.5, box.max.y - box.min.y) };
+ } catch (err) {
+ console.warn('[avatar-rig] avatar load failed, using stand-in:', url, err?.message);
+ const body = new Mesh(new CapsuleGeometry(0.32, 0.7, 4, 10), new MeshStandardMaterial({ color: 0x8aa6d8 }));
+ body.position.y = 0.85; body.castShadow = true;
+ const head = new Mesh(new SphereGeometry(0.28, 14, 10), new MeshStandardMaterial({ color: 0xf1c9a5 }));
+ head.position.y = 1.55; head.castShadow = true;
+ rig.add(body, head);
+ return { height: 1.7 };
+ }
+}
+
+// Play a one-shot emote clip on a rig's AnimationManager, then return to the
+// locomotion clip. No-op if the emote isn't in the loaded manifest.
+export async function playEmoteClip(anim, name, motion) {
+ const def = getEmoteDefs().find((d) => d.name === name);
+ if (!def) return;
+ try {
+ if (!anim.clips?.has?.(name)) await anim.loadAnimation(name, def.url, { loop: false });
+ await anim.crossfadeTo(name, 0.15);
+ setTimeout(() => anim.crossfadeTo(motion === 'walk' || motion === 'run' ? CLIP_WALK : CLIP_IDLE, 0.2), 2400);
+ } catch { /* clip missing — ignore */ }
+}
+
+// Convenience: a fresh AnimationManager (re-exported so scenes don't need a
+// separate import just to spin up a rig).
+export function newAnim() {
+ return new AnimationManager();
+}
diff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.js
index 3f7c7479a..98ca92260 100644
--- a/src/game/coincommunities-ui.js
+++ b/src/game/coincommunities-ui.js
@@ -68,6 +68,10 @@ export class CommunityUI {
]),
]),
el('div', { class: 'cc-search' }, [el('span', { text: '🔎' }), this.searchInput]),
+ el('a', { class: 'cc-adventure', href: '/game', title: 'Isometric MMO — gather, fight, level up' }, [
+ el('span', { class: 'cc-adventure-ico', text: '⚔️' }),
+ el('span', { html: 'Adventure mode<small>Gather · fight · level up</small>' }),
+ ]),
]),
el('div', { class: 'cc-avatar-bar' }, [
el('div', { class: 'cc-avatar-label', html: 'Your avatar<small>Pick one, or bring your own / your agent</small>' }),
diff --git a/src/game/coincommunities.css b/src/game/coincommunities.css
index ea647e8d0..1d9e25d5d 100644
--- a/src/game/coincommunities.css
+++ b/src/game/coincommunities.css
@@ -233,7 +233,7 @@ html, body {
/* chat sidebar — dockable, minimizable, persistent log */
#cc-chat {
- position: fixed; left: 14px; bottom: 14px; width: min(340px, 82vw);
+ position: fixed; right: 14px; bottom: 14px; width: min(340px, 82vw);
max-height: min(60vh, 520px); z-index: 21;
display: flex; flex-direction: column; overflow: hidden;
background: var(--cc-panel); border: 1px solid var(--cc-edge);
@@ -337,21 +337,61 @@ html, body {
.cc-bubble::after { width: 7px; height: 7px; bottom: -18px; transform: translateX(-45%); }
@keyframes cc-bubble-in { from { opacity: 0; } }
+/* control hint — tucked under the coin banner (top-left), clear of every corner */
#cc-hint {
- position: fixed; right: 14px; bottom: 14px; z-index: 19;
+ position: fixed; left: 14px; top: 82px; z-index: 19;
color: var(--cc-dim); font-size: 11px; line-height: 1.7; letter-spacing: 0.02em;
- background: var(--cc-panel); border: 1px solid var(--cc-edge); border-radius: var(--cc-radius); padding: 9px 12px;
- backdrop-filter: blur(10px);
+ background: var(--cc-panel); border: 1px solid var(--cc-edge); border-radius: var(--cc-radius); padding: 8px 12px;
+ backdrop-filter: blur(10px); max-width: min(420px, 60vw);
}
#cc-hint kbd {
background: rgba(255, 255, 255, 0.06); border: 1px solid var(--cc-edge); border-radius: var(--cc-radius-sm);
padding: 1px 5px; font-size: 10px; font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--cc-text);
}
-#cc-joystick { position: fixed; left: 22px; bottom: 90px; width: 120px; height: 120px; z-index: 21; touch-action: none; }
+/* movement stick — bottom-left, always on (touch + mouse). Subtle on desktop,
+ full strength on touch. Sits opposite the chat (bottom-right) so they never overlap. */
+#cc-joystick {
+ position: fixed; left: 22px; bottom: 90px; width: 120px; height: 120px; z-index: 22; touch-action: none;
+ opacity: 0.5; transition: opacity 0.2s ease;
+}
+#cc-joystick:hover { opacity: 1; }
+@media (pointer: coarse) { #cc-joystick { opacity: 1; } }
+#cc-joystick.cc-joy-active { opacity: 1; }
+.cc-joy-base {
+ position: absolute; inset: 0; border-radius: 50%;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1.5px solid rgba(255, 255, 255, 0.35);
+ box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.05);
+ display: grid; place-items: center;
+}
+.cc-joy-thumb {
+ width: 46px; height: 46px; border-radius: 50%;
+ background: rgba(255, 255, 255, 0.85);
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
+ transition: transform 0.05s linear;
+ will-change: transform; pointer-events: none;
+}
+#cc-joystick.cc-joy-active .cc-joy-thumb { transition: none; }
@media (max-width: 640px) {
#cc-hint { display: none; }
.cc-coin-banner { max-width: 60vw; }
#cc-chat { width: 72vw; }
}
+
+/* Adventure-mode link — entry from the social lobby into the isometric MMO (/game). */
+.cc-adventure {
+ display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
+ padding: 8px 14px; border-radius: 12px; color: #e8edf6;
+ background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.14);
+ transition: background 0.15s, border-color 0.15s, transform 0.08s;
+ white-space: nowrap;
+}
+.cc-adventure:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.3); }
+.cc-adventure:active { transform: translateY(1px); }
+.cc-adventure:focus-visible { outline: 2px solid #cdd6e6; outline-offset: 2px; }
+.cc-adventure-ico { font-size: 18px; line-height: 1; }
+.cc-adventure span { display: flex; flex-direction: column; font-weight: 700; font-size: 13px; line-height: 1.2; }
+.cc-adventure small { font-weight: 500; font-size: 11px; opacity: 0.6; }
+@media (max-width: 640px) { .cc-adventure small { display: none; } }
diff --git a/src/game/coincommunities.js b/src/game/coincommunities.js
index 0ebcf4d99..49a7cbd02 100644
--- a/src/game/coincommunities.js
+++ b/src/game/coincommunities.js
@@ -11,85 +11,28 @@
// Colyseus), reused here so a coin community is a first-class 3D space.
import {
- Scene, Color, Fog, WebGLRenderer, PerspectiveCamera, Group, Vector3, Box3,
+ Scene, Color, Fog, WebGLRenderer, PerspectiveCamera, Group, Vector3,
HemisphereLight, DirectionalLight, AmbientLight, PCFSoftShadowMap, SRGBColorSpace,
Mesh, MeshStandardMaterial, MeshBasicMaterial, CircleGeometry, RingGeometry,
- CylinderGeometry, CapsuleGeometry, SphereGeometry, PlaneGeometry,
+ CylinderGeometry, PlaneGeometry,
CanvasTexture, TextureLoader, DoubleSide,
} from 'three';
-import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
-import nipplejs from 'nipplejs';
import { AnimationManager } from '../animation-manager.js';
import { CommunityNet } from './community-net.js';
import { CommunityUI } from './coincommunities-ui.js';
import { normalizeGatewayURL } from '../ipfs.js';
+import {
+ loadManifest, getEmoteDefs, resolveAvatarUrl, buildAvatar, playEmoteClip,
+ CLIP_IDLE, CLIP_WALK,
+} from './avatar-rig.js';
-const AVATAR_DEFAULT = '/avatars/default.glb';
-const MANIFEST_URL = '/animations/manifest.json';
-const CLIP_IDLE = 'idle';
-const CLIP_WALK = 'av-walk-feminine';
const WORLD_RADIUS = 58; // a touch inside the server's 60m clamp
const MOVE_SPEED = 4.2;
const REMOTE_LERP = 0.18;
+const JOY_DEADZONE = 0.12; // swallow tiny stick grazes so the avatar doesn't drift
const TRENDING_URL = '/api/pump/trending?limit=30';
-const _gltf = new GLTFLoader();
-let _animDefs = null; // cached manifest defs (locomotion + emotes)
-let _emoteDefs = null;
-
-async function loadManifest() {
- if (_animDefs) return;
- let manifest = [];
- try {
- const r = await fetch(MANIFEST_URL, { cache: 'force-cache' });
- if (r.ok) manifest = await r.json();
- } catch { /* fall through to locomotion-only */ }
- const byName = (n) => manifest.find((d) => d.name === n);
- const loco = [byName(CLIP_IDLE), byName(CLIP_WALK)].filter(Boolean);
- const emotes = manifest.filter((d) => d.name !== CLIP_IDLE && d.name !== CLIP_WALK).slice(0, 6);
- _emoteDefs = emotes;
- _animDefs = [...loco, ...emotes];
-}
-
-// Resolve an avatar input (GLB/VRM URL, site path, or three.ws avatar id) to a
-// loadable model URL. Falls back to the default avatar on anything unresolved.
-async function resolveAvatarUrl(input) {
- const v = (input || '').trim();
- if (!v) return AVATAR_DEFAULT;
- if (/^https?:\/\//i.test(v) || v.startsWith('/')) return v;
- try {
- const r = await fetch(`/api/avatars/${encodeURIComponent(v)}`, { headers: { accept: 'application/json' } });
- if (r.ok) { const { avatar } = await r.json(); if (avatar?.url) return avatar.url; }
- } catch { /* ignore */ }
- return AVATAR_DEFAULT;
-}
-
-// Load a GLB avatar into a rig + wire an AnimationManager (idle/walk/emotes).
-// Returns { height }. On failure, drops in a capsule stand-in so the player is
-// never invisible.
-async function buildAvatar(rig, url, anim) {
- try {
- const gltf = await _gltf.loadAsync(url);
- const model = gltf.scene;
- model.traverse((n) => { if (n.isMesh) { n.castShadow = true; n.receiveShadow = false; } });
- const box = new Box3().setFromObject(model);
- model.position.y -= box.min.y;
- rig.add(model);
- anim.attach(model);
- if (_animDefs?.length) { anim.setAnimationDefs(_animDefs); await anim.loadAll(); await anim.crossfadeTo(CLIP_IDLE, 0); }
- return { height: Math.max(0.5, box.max.y - box.min.y) };
- } catch (err) {
- console.warn('[coincommunities] avatar load failed, using stand-in:', url, err?.message);
- const body = new Mesh(new CapsuleGeometry(0.32, 0.7, 4, 10), new MeshStandardMaterial({ color: 0x8aa6d8 }));
- body.position.y = 0.85; body.castShadow = true;
- const head = new Mesh(new SphereGeometry(0.28, 14, 10), new MeshStandardMaterial({ color: 0xf1c9a5 }));
- head.position.y = 1.55; head.castShadow = true;
- rig.add(body, head);
- return { height: 1.7 };
- }
-}
-
// A networked peer: their own avatar rig + animation + name label + chat bubble.
class RemotePlayer {
constructor(scene, player) {
@@ -164,17 +107,6 @@ class RemotePlayer {
}
}
-// Play a one-shot emote clip then return to the locomotion clip.
-async function playEmoteClip(anim, name, motion) {
- const def = _emoteDefs?.find((d) => d.name === name);
- if (!def) return;
- try {
- if (!anim.clips?.has?.(name)) await anim.loadAnimation(name, def.url, { loop: false });
- await anim.crossfadeTo(name, 0.15);
- setTimeout(() => anim.crossfadeTo(motion === 'walk' || motion === 'run' ? CLIP_WALK : CLIP_IDLE, 0.2), 2400);
- } catch { /* clip missing — ignore */ }
-}
-
export class CoinCommunities {
constructor(canvas) {
this.canvas = canvas;
@@ -358,7 +290,7 @@ export class CoinCommunities {
history.replaceState(null, '', location.pathname + '?' + q.toString());
} catch { /* non-fatal */ }
await loadManifest();
- this.ui.setEmotes((_emoteDefs || []).map((d) => ({ name: d.name, icon: d.icon || '🙂', label: d.label })));
+ this.ui.setEmotes(getEmoteDefs().map((d) => ({ name: d.name, icon: d.icon || '🙂', label: d.label })));
// Build the coin's world + local avatar.
this._buildTotem(coin);
@@ -463,15 +395,60 @@ export class CoinCommunities {
_initJoystick() {
const zone = document.getElementById('cc-joystick');
- if (!zone || this._nipple) return;
- // Touch only — keep desktop on WASD.
- if (!matchMedia('(pointer: coarse)').matches) { zone.style.display = 'none'; return; }
- this._nipple = nipplejs.create({ zone, mode: 'static', position: { left: '60px', bottom: '60px' }, color: '#ffffff', size: 110 });
- this._nipple.on('move', (_e, d) => {
- const f = Math.min(1, d.force);
- this._joy = { x: Math.cos(d.angle.radian) * f, z: -Math.sin(d.angle.radian) * f };
+ if (!zone || this._joyInit) return;
+ this._joyInit = true;
+ // Self-contained pointer-events joystick — no external lib, so the input
+ // contract can never drift. Responds to BOTH touch and mouse-drag, so the
+ // world is playable without a keyboard and verifiable on desktop. Desktop
+ // also keeps WASD; the two intents simply sum in _stepLocal.
+ const base = document.createElement('div');
+ base.className = 'cc-joy-base';
+ const thumb = document.createElement('div');
+ thumb.className = 'cc-joy-thumb';
+ base.appendChild(thumb);
+ zone.appendChild(base);
+
+ const RADIUS = 48; // px the thumb can travel from center before clamping
+ let activeId = null;
+
+ const setFromPointer = (clientX, clientY) => {
+ const r = base.getBoundingClientRect();
+ const cx = r.left + r.width / 2;
+ const cy = r.top + r.height / 2;
+ let dx = (clientX - cx) / RADIUS;
+ let dy = (clientY - cy) / RADIUS;
+ const m = Math.hypot(dx, dy);
+ if (m > 1) { dx /= m; dy /= m; } // clamp to the unit circle
+ thumb.style.transform = `translate(${dx * RADIUS}px, ${dy * RADIUS}px)`;
+ const mag = Math.min(1, m);
+ if (mag < JOY_DEADZONE) { this._joy = null; return; } // swallow drift
+ const k = (mag - JOY_DEADZONE) / (1 - JOY_DEADZONE) / mag; // remap past deadzone
+ // Screen-down (+dy) is "toward camera" = backward, so z = +dy.
+ this._joy = { x: dx * k, z: dy * k };
+ };
+ const release = () => {
+ activeId = null;
+ this._joy = null;
+ thumb.style.transform = 'translate(0px, 0px)';
+ zone.classList.remove('cc-joy-active');
+ };
+
+ zone.addEventListener('pointerdown', (e) => {
+ activeId = e.pointerId;
+ zone.setPointerCapture(e.pointerId);
+ zone.classList.add('cc-joy-active');
+ setFromPointer(e.clientX, e.clientY);
+ e.preventDefault();
+ });
+ zone.addEventListener('pointermove', (e) => {
+ if (e.pointerId !== activeId) return;
+ setFromPointer(e.clientX, e.clientY);
+ e.preventDefault();
});
- this._nipple.on('end', () => { this._joy = null; });
+ const onUp = (e) => { if (e.pointerId === activeId) release(); };
+ zone.addEventListener('pointerup', onUp);
+ zone.addEventListener('pointercancel', onUp);
+ zone.addEventListener('lostpointercapture', onUp);
}
// ---------------------------------------------------------------- loop
diff --git a/src/game/game-net.js b/src/game/game-net.js
index 3c4dbc7c4..56c09042c 100644
--- a/src/game/game-net.js
+++ b/src/game/game-net.js
@@ -11,13 +11,22 @@
import { Client, getStateCallbacks } from 'colyseus.js';
const ROOM_NAME = 'game_mainland';
+const RECONNECT_BASE_MS = 3000;
+const RECONNECT_MAX_MS = 60_000;
+const MAX_RECONNECT_ATTEMPTS = 6;
function defaultServerUrl() {
- // Resolution priority mirrors walk-net:
+ // Resolution priority mirrors community-net / walk-net:
// 1. window.GAME_SERVER_URL (test override)
- // 2. <meta name="game-server"> then <meta name="walk-server"> (shared host)
- // 3. Same host on :2567 (dev convenience)
+ // 2. local dev → ws://<host>:2567, ignoring the production <meta> baked
+ // into the static page (so `npm run dev:walk-all` works out of the box)
+ // 3. <meta name="game-server"> then <meta name="walk-server"> (prod host)
+ // 4. Same host on :2567
if (typeof window !== 'undefined' && window.GAME_SERVER_URL) return window.GAME_SERVER_URL;
+ const host = typeof location !== 'undefined' ? location.hostname : '';
+ if (host === 'localhost' || host === '127.0.0.1' || host === '0.0.0.0') {
+ return `ws://${host}:2567`;
+ }
if (typeof document !== 'undefined') {
for (const sel of ['meta[name="game-server"]', 'meta[name="walk-server"]']) {
const v = document.querySelector(sel)?.getAttribute('content')?.trim();
@@ -56,6 +65,7 @@ export class GameNet {
mobRemove: new Set(),
};
this._reconnectTimer = null;
+ this._reconnectAttempts = 0;
this._destroyed = false;
}
@@ -108,6 +118,7 @@ export class GameNet {
});
this.room.onError((code, message) => console.warn('[game-net] room.onError', code, message));
+ this._reconnectAttempts = 0;
this._setStatus('online');
} catch (err) {
console.warn('[game-net] connect failed:', err?.message ?? err);
@@ -116,9 +127,19 @@ export class GameNet {
}
}
+ // Exponential backoff with a hard ceiling. When the server is unreachable
+ // (e.g. not deployed), each attempt costs a connection timeout — retrying
+ // forever at a fixed interval floods the console. After MAX_RECONNECT_ATTEMPTS
+ // we stop and stay 'offline'; the UI offers a manual reconnect via retry().
_scheduleReconnect() {
if (this._reconnectTimer || this._destroyed) return;
- const delay = 3000 + Math.random() * 1500;
+ if (this._reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
+ this._setStatus('offline', 'game server unreachable');
+ return;
+ }
+ const attempt = this._reconnectAttempts++;
+ const backoff = Math.min(RECONNECT_BASE_MS * 2 ** attempt, RECONNECT_MAX_MS);
+ const delay = backoff + Math.random() * 1000;
this._reconnectTimer = setTimeout(() => {
this._reconnectTimer = null;
if (!this._destroyed) this.connect();
@@ -140,6 +161,7 @@ export class GameNet {
retry() {
if (this._reconnectTimer) { clearTimeout(this._reconnectTimer); this._reconnectTimer = null; }
+ this._reconnectAttempts = 0;
this.connect();
}
diff --git a/src/game/iso-game.css b/src/game/iso-game.css
new file mode 100644
index 000000000..03fe5b56e
--- /dev/null
+++ b/src/game/iso-game.css
@@ -0,0 +1,138 @@
+/* Isometric RPG (/game) — HUD, overlays, nameplates, toasts.
+ Dark, sleek, monochrome-leaning to match the /play client; avatars and world
+ provide the colour. */
+
+:root {
+ --kg-bg: #0d1420;
+ --kg-panel: rgba(16, 22, 34, 0.92);
+ --kg-line: rgba(255, 255, 255, 0.12);
+ --kg-text: #e8edf6;
+ --kg-dim: #95a1b6;
+ --kg-accent: #cdd6e6;
+}
+
+* { box-sizing: border-box; }
+html, body {
+ margin: 0; height: 100%; overflow: hidden;
+ background: var(--kg-bg); color: var(--kg-text);
+ font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
+ -webkit-font-smoothing: antialiased; overscroll-behavior: none;
+}
+#kg-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
+body.kg-loading-cursor { cursor: progress; }
+
+/* DOM layer for projected nameplates (pointer-transparent). */
+#kg-labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
+
+.kg-label {
+ position: absolute; top: 0; left: 0; will-change: transform;
+ display: flex; flex-direction: column; align-items: center; gap: 3px;
+ font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
+ text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
+}
+.kg-label-name {
+ padding: 1px 7px; border-radius: 6px;
+ background: rgba(13, 20, 32, 0.66); border: 1px solid var(--kg-line);
+ white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
+}
+.kg-label--me .kg-label-name { background: rgba(40, 52, 74, 0.82); border-color: rgba(255, 255, 255, 0.28); }
+.kg-hp {
+ width: 46px; height: 4px; border-radius: 3px; overflow: hidden;
+ background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(0, 0, 0, 0.4);
+ opacity: 0; transition: opacity 0.2s;
+}
+.kg-label.kg-hurt .kg-hp { opacity: 1; }
+.kg-hp i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #6ee787, #d7ff7a); transition: width 0.2s ease; }
+
+/* Top bar: realm + online + connection status. */
+#kg-topbar {
+ position: fixed; top: 0; left: 0; right: 0; z-index: 8;
+ display: flex; align-items: center; gap: 14px;
+ padding: 10px 16px; pointer-events: none;
+ background: linear-gradient(180deg, rgba(8, 12, 20, 0.7), transparent);
+}
+#kg-realm { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
+.kg-stat { font-size: 12px; color: var(--kg-dim); display: inline-flex; align-items: center; gap: 5px; }
+.kg-stat b { color: var(--kg-text); font-weight: 700; }
+#kg-status {
+ margin-left: auto; pointer-events: auto;
+ font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
+ padding: 4px 10px; border-radius: 999px;
+ background: rgba(255, 255, 255, 0.06); border: 1px solid var(--kg-line); color: var(--kg-dim);
+}
+#kg-status[data-status="online"] { color: #6ee787; border-color: rgba(110, 231, 135, 0.4); }
+#kg-status[data-status="connecting"] { color: #ffce5c; border-color: rgba(255, 206, 92, 0.4); }
+#kg-status[data-status="offline"], #kg-status[data-status="failed"] { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.4); }
+
+/* Controls hint (bottom). */
+#kg-hint {
+ position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 7;
+ font-size: 12px; color: var(--kg-dim); pointer-events: none; text-align: center;
+ background: rgba(13, 20, 32, 0.5); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--kg-line);
+}
+#kg-hint kbd {
+ font: inherit; font-weight: 700; color: var(--kg-text);
+ background: rgba(255, 255, 255, 0.08); border: 1px solid var(--kg-line);
+ border-radius: 4px; padding: 0 5px;
+}
+
+/* Toasts (server notices: gathered, killed, inventory full, …). */
+#kg-toasts { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 9; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
+.kg-toast {
+ padding: 8px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
+ background: var(--kg-panel); border: 1px solid var(--kg-line); color: var(--kg-text);
+ opacity: 0; transform: translateY(-8px); transition: opacity 0.3s, transform 0.3s;
+ box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
+}
+.kg-toast--in { opacity: 1; transform: translateY(0); }
+.kg-toast--kill { border-color: rgba(110, 231, 135, 0.45); }
+.kg-toast--full, .kg-toast--tool, .kg-toast--bank { border-color: rgba(255, 206, 92, 0.45); }
+
+/* Joystick zone (touch only). */
+#kg-joystick { position: fixed; left: 0; bottom: 0; width: 180px; height: 200px; z-index: 6; }
+
+/* Start + offline overlays. */
+.kg-overlay {
+ position: fixed; inset: 0; z-index: 20;
+ display: flex; align-items: center; justify-content: center; padding: 24px;
+ background: radial-gradient(120% 120% at 50% 30%, rgba(20, 28, 44, 0.55), rgba(8, 12, 20, 0.9));
+ backdrop-filter: blur(2px);
+}
+.kg-overlay[hidden] { display: none; }
+.kg-card {
+ width: 100%; max-width: 380px; text-align: center;
+ background: var(--kg-panel); border: 1px solid var(--kg-line); border-radius: 18px;
+ padding: 30px 26px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
+}
+.kg-eyebrow { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--kg-dim); }
+.kg-title { font-size: 26px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -0.01em; }
+.kg-sub { font-size: 14px; color: var(--kg-dim); line-height: 1.5; margin: 0 0 22px; }
+.kg-field { display: block; width: 100%; margin-bottom: 14px; }
+.kg-field input {
+ width: 100%; padding: 12px 14px; font-size: 15px;
+ background: rgba(0, 0, 0, 0.3); color: var(--kg-text);
+ border: 1px solid var(--kg-line); border-radius: 10px; outline: none; transition: border-color 0.15s;
+}
+.kg-field input:focus { border-color: var(--kg-accent); }
+.kg-btn {
+ width: 100%; padding: 13px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
+ background: var(--kg-text); color: #0d1420; border: 0; border-radius: 10px;
+ transition: transform 0.08s ease, opacity 0.15s;
+}
+.kg-btn:hover { opacity: 0.92; }
+.kg-btn:active { transform: translateY(1px); }
+.kg-btn:focus-visible { outline: 2px solid var(--kg-accent); outline-offset: 2px; }
+.kg-feats { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
+.kg-feat { font-size: 11px; color: var(--kg-dim); border: 1px solid var(--kg-line); border-radius: 999px; padding: 4px 10px; }
+
+.kg-spinner {
+ width: 34px; height: 34px; margin: 4px auto 18px; border-radius: 50%;
+ border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--kg-text);
+ animation: kg-spin 0.8s linear infinite;
+}
+@keyframes kg-spin { to { transform: rotate(360deg); } }
+
+@media (max-width: 480px) {
+ .kg-card { padding: 24px 20px; }
+ .kg-title { font-size: 22px; }
+}
diff --git a/src/game/iso-game.js b/src/game/iso-game.js
new file mode 100644
index 000000000..37811fca1
--- /dev/null
+++ b/src/game/iso-game.js
@@ -0,0 +1,728 @@
+// Isometric RPG client — the /game scene. The front door to the authoritative
+// MMO that already lives on the server (multiplayer/src/rooms/GameRoom.js):
+// gathering, combat, skills, inventory, banking on the Mainland realm. This
+// scene renders GameRoom's synced state through the GameNet bridge and turns
+// player intent into the server's tile-stepped protocol.
+//
+// Design mirrors coincommunities.js (renderer → scene → RAF loop → phases) but
+// the world is tile-based: a grid the server validates against, with a fixed
+// three-quarter "isometric" camera that follows the local player. Avatar/anim
+// loading is shared via avatar-rig.js so the RPG and the social walkaround
+// never drift apart.
+//
+// Extension seams for the rest of Epic A (kept intentionally small so each task
+// is a localized change):
+// • _buildNodeView(node) — T7 replaces the placeholder gather-node meshes.
+// • _buildMobView(mob) — T8 replaces the placeholder combat-mob meshes.
+// • onGatherTarget / onAttackTarget / bank/inventory hooks — T7/T8/T9.
+// The baseline here renders real, navigable placeholders so the world is alive
+// today; those tasks swap geometry without touching the networking or loop.
+
+import {
+ Scene, Color, Fog, WebGLRenderer, PerspectiveCamera, Group, Vector3,
+ HemisphereLight, DirectionalLight, AmbientLight, PCFSoftShadowMap, SRGBColorSpace,
+ Mesh, MeshStandardMaterial, MeshBasicMaterial, PlaneGeometry, BoxGeometry,
+ CylinderGeometry, ConeGeometry, DodecahedronGeometry, IcosahedronGeometry,
+ CircleGeometry, CanvasTexture, RepeatWrapping, DoubleSide,
+} from 'three';
+import nipplejs from 'nipplejs';
+
+import { GameNet } from './game-net.js';
+import {
+ loadManifest, resolveAvatarUrl, buildAvatar, newAnim, CLIP_IDLE, CLIP_WALK,
+} from './avatar-rig.js';
+
+const TILE = 1.0; // world units per tile
+const STEP_INTERVAL_MS = 165; // walk cadence — one authoritative step per tile
+const MOVE_LERP = 0.22; // position interpolation toward the server tile
+const YAW_LERP = 0.22;
+const AVATAR_DEFAULT = '/avatars/default.glb';
+
+// ---------------------------------------------------------------------------
+// GamePlayerView — a player's avatar rig in the tile world. The server owns the
+// authoritative tile; this view interpolates toward it so movement reads smooth
+// at the 15Hz patch rate. Used for both the local player and remote peers
+// (T6 polishes remote-specific touches like HP bars on top of this baseline).
+// ---------------------------------------------------------------------------
+class GamePlayerView {
+ constructor(scene, tileToWorld, player, isLocal) {
+ this.scene = scene;
+ this.tileToWorld = tileToWorld;
+ this.isLocal = isLocal;
+ this.id = player.id;
+
+ this.rig = new Group();
+ this.anim = newAnim();
+ this.height = 1.7;
+
+ // Authoritative tile + facing, and the interpolation targets derived from
+ // them. tx/ty always reflect the latest server state (used for stepping).
+ this.tx = player.tx;
+ this.ty = player.ty;
+ this.yaw = player.yaw || 0;
+ this.curYaw = this.yaw;
+ this.motion = player.motion || 'idle';
+ this.hp = player.hp; this.maxHp = player.maxHp;
+ this.dead = !!player.dead;
+
+ const w = tileToWorld(player.tx, player.ty);
+ this.rig.position.set(w.x, 0, w.z);
+ this.target = new Vector3(w.x, 0, w.z);
+ scene.add(this.rig);
+
+ // Floating nameplate (DOM, projected each frame). HP bar fills in for the
+ // local player and any damaged peer.
+ this.label = document.createElement('div');
+ this.label.className = 'kg-label' + (isLocal ? ' kg-label--me' : '');
+ this.label.innerHTML =
+ `<span class="kg-label-name"></span><span class="kg-hp"><i></i></span>`;
+ this.nameEl = this.label.querySelector('.kg-label-name');
+ this.hpFill = this.label.querySelector('.kg-hp i');
+ this.nameEl.textContent = player.name || 'guest';
+ document.getElementById('kg-labels')?.appendChild(this.label);
+ this._renderHp();
+
+ this._avatarUrl = null;
+ this.setAvatar(player.cosmetic || '');
+ }
+
+ setAvatar(url) {
+ const next = url || AVATAR_DEFAULT;
+ if (next === this._avatarUrl) return;
+ this._avatarUrl = next;
+ this.rig.clear();
+ this.anim = newAnim();
+ resolveAvatarUrl(next).then((u) => buildAvatar(this.rig, u, this.anim).then(({ height }) => {
+ this.height = height;
+ this.anim.crossfadeTo(this.motion === 'walk' ? CLIP_WALK : CLIP_IDLE, 0);
+ }));
+ }
+
+ apply(player) {
+ const moved = player.tx !== this.tx || player.ty !== this.ty;
+ this.tx = player.tx; this.ty = player.ty;
+ this.yaw = player.yaw ?? this.yaw;
+ const w = this.tileToWorld(player.tx, player.ty);
+ this.target.set(w.x, 0, w.z);
+
+ if (player.name && player.name !== this.nameEl.textContent) this.nameEl.textContent = player.name;
+ if (player.hp !== this.hp || player.maxHp !== this.maxHp) {
+ this.hp = player.hp; this.maxHp = player.maxHp; this._renderHp();
+ }
+ if (!!player.dead !== this.dead) {
+ this.dead = !!player.dead;
+ this.rig.visible = !this.dead;
+ this.label.classList.toggle('kg-dead', this.dead);
+ }
+ if (player.motion !== this.motion) {
+ this.motion = player.motion;
+ this.anim.crossfadeTo(this.motion === 'walk' ? CLIP_WALK : CLIP_IDLE, 0.16);
+ }
+ // Mark when the server says we moved so the loop can settle us to idle on
+ // arrival without waiting for a separate motion patch.
+ if (moved) this._movedAt = performance.now();
+ }
+
+ _renderHp() {
+ const pct = this.maxHp > 0 ? Math.max(0, Math.min(1, this.hp / this.maxHp)) : 0;
+ this.hpFill.style.width = (pct * 100).toFixed(0) + '%';
+ // Hide the bar at full health to keep nameplates clean; show when hurt.
+ this.label.classList.toggle('kg-hurt', pct < 1);
+ }
+
+ tick(dt) {
+ this.rig.position.x += (this.target.x - this.rig.position.x) * MOVE_LERP;
+ this.rig.position.z += (this.target.z - this.rig.position.z) * MOVE_LERP;
+ let d = this.yaw - this.curYaw;
+ while (d > Math.PI) d -= Math.PI * 2;
+ while (d < -Math.PI) d += Math.PI * 2;
+ this.curYaw += d * YAW_LERP;
+ this.rig.rotation.y = this.curYaw;
+ this.anim?.update(dt);
+ }
+
+ dispose() {
+ this.scene.remove(this.rig);
+ this.label.remove();
+ }
+}
+
+// ---------------------------------------------------------------------------
+// IsoGame — the scene controller.
+// ---------------------------------------------------------------------------
+export class IsoGame {
+ constructor(canvas) {
+ this.canvas = canvas;
+ this.phase = 'start'; // 'start' | 'connecting' | 'world' | 'offline'
+ this.players = new Map(); // sessionId -> GamePlayerView
+ this.nodeViews = new Map(); // id -> { group, node }
+ this.mobViews = new Map(); // id -> { group, mob }
+ this.keys = new Set();
+ this.realm = null;
+ this.myId = null;
+
+ // Camera: a follow rig at a fixed three-quarter angle. Drag rotates yaw,
+ // wheel/pinch zooms. Pitch is steep for the isometric read.
+ this.camYaw = 0.7; this.camPitch = 0.95; this.camDist = 16;
+ this._dragging = false; this._lastPtr = null; this._downAt = 0;
+ this._stepAccum = 0;
+ this._last = performance.now();
+ this._camTarget = new Vector3(0, 0, 0);
+
+ this._initRenderer();
+ this._initScene();
+ this._bindHud();
+ this._bindInput();
+
+ this._loop = this._loop.bind(this);
+ requestAnimationFrame(this._loop);
+ }
+
+ // ---------------------------------------------------------------- render
+ _initRenderer() {
+ const r = new WebGLRenderer({ canvas: this.canvas, antialias: true });
+ r.setPixelRatio(Math.min(window.devicePixelRatio, 2));
+ r.setSize(window.innerWidth, window.innerHeight);
+ r.shadowMap.enabled = true; r.shadowMap.type = PCFSoftShadowMap;
+ r.outputColorSpace = SRGBColorSpace;
+ this.renderer = r;
+ window.addEventListener('resize', () => this._onResize());
+ }
+
+ _initScene() {
+ const scene = new Scene();
+ scene.background = new Color(0x223a55);
+ scene.fog = new Fog(0x223a55, 48, 120);
+ this.scene = scene;
+
+ this.camera = new PerspectiveCamera(48, window.innerWidth / window.innerHeight, 0.1, 400);
+ this.camera.position.set(12, 16, 12);
+
+ scene.add(new HemisphereLight(0xdcebff, 0x49603a, 1.0));
+ scene.add(new AmbientLight(0xffffff, 0.28));
+ const sun = new DirectionalLight(0xfff0d4, 1.25);
+ sun.position.set(24, 40, 18); sun.castShadow = true;
+ sun.shadow.mapSize.set(2048, 2048);
+ const s = sun.shadow.camera; s.left = -40; s.right = 40; s.top = 40; s.bottom = -40; s.near = 1; s.far = 140;
+ sun.shadow.bias = -0.0004;
+ scene.add(sun, sun.target);
+ this._sun = sun;
+
+ // Static realm geometry (ground, buildings, fountain, tile paint) lives in
+ // its own group so a realm (re)build is a single clear + rebuild WITHOUT
+ // touching dynamic objects — gather nodes and mobs sync via schema patches
+ // whose arrival order vs. the 'realm' message isn't guaranteed, so they
+ // must survive a realm rebuild.
+ this.staticGroup = new Group();
+ this.objectGroup = new Group();
+ scene.add(this.staticGroup, this.objectGroup);
+ }
+
+ // ---------------------------------------------------------------- coords
+ // Tile (tx,ty) → world (x,z), centred on the realm so the camera orbits the
+ // middle of the map and shadows stay inside the shadow-camera frustum.
+ _tileToWorld(tx, ty) {
+ const c = (this.realm?.grid ?? 48) / 2;
+ return { x: (tx - c + 0.5) * TILE, z: (ty - c + 0.5) * TILE };
+ }
+
+ // ---------------------------------------------------------------- realm
+ _buildRealm(layout) {
+ this.realm = layout;
+ // Clear only the static realm geometry; dynamic nodes/mobs (objectGroup)
+ // and players (added straight to the scene) survive a realm rebuild.
+ this.staticGroup.clear();
+
+ const grid = layout.grid || 48;
+ const size = grid * TILE;
+
+ // Ground plane with a subtle tile grid so movement is legible.
+ const ground = new Mesh(
+ new PlaneGeometry(size, size),
+ new MeshStandardMaterial({ map: this._gridTexture(grid), color: 0x6b9a52, roughness: 1 }),
+ );
+ ground.rotation.x = -Math.PI / 2;
+ ground.receiveShadow = true;
+ this.staticGroup.add(ground);
+
+ // Solid blocks (bank building, pond water, etc.) — render each blocked
+ // rect as a low box so the no-go zones are visually obvious and match the
+ // server's walkability exactly.
+ for (const b of layout.blocked || []) {
+ const w = (b.x1 - b.x0 + 1) * TILE;
+ const d = (b.y1 - b.y0 + 1) * TILE;
+ const isWater = layout.name === 'pond';
+ const h = isWater ? 0.25 : 2.4;
+ const box = new Mesh(
+ new BoxGeometry(w, h, d),
+ new MeshStandardMaterial({
+ color: isWater ? 0x2c5a86 : 0x4a4f5e,
+ roughness: isWater ? 0.3 : 0.85,
+ metalness: isWater ? 0.1 : 0,
+ transparent: isWater, opacity: isWater ? 0.85 : 1,
+ }),
+ );
+ const cx = (b.x0 + b.x1) / 2, cy = (b.y0 + b.y1) / 2;
+ const w0 = this._tileToWorld(cx, cy);
+ box.position.set(w0.x, h / 2, w0.z);
+ box.castShadow = !isWater; box.receiveShadow = true;
+ this.staticGroup.add(box);
+ }
+
+ // Fountain landmark.
+ if (layout.fountain) {
+ const f = new Group();
+ const base = new Mesh(new CylinderGeometry(1.6, 1.8, 0.5, 24),
+ new MeshStandardMaterial({ color: 0x6b7280, roughness: 0.9 }));
+ base.position.y = 0.25; base.castShadow = true; base.receiveShadow = true;
+ const water = new Mesh(new CylinderGeometry(1.3, 1.3, 0.12, 24),
+ new MeshStandardMaterial({ color: 0x3aa0d0, roughness: 0.2, emissive: 0x0a2a3a, emissiveIntensity: 0.4 }));
+ water.position.y = 0.5;
+ f.add(base, water);
+ const w0 = this._tileToWorld(layout.fountain.tx, layout.fountain.ty);
+ f.position.set(w0.x, 0, w0.z);
+ this.staticGroup.add(f);
+ }
+
+ // Bank counter tiles — a warm highlight so players know where to bank.
+ this._paintTiles(layout.bankZone, 0xffce5c, 0.85);
+ // Fishing + cooking spots, if the realm has them.
+ this._paintTiles(layout.fishing, 0x3aa0d0, 0.6);
+ this._paintTiles(layout.cooking, 0xff7a3a, 0.6);
+ // Portals.
+ for (const p of layout.portals || []) {
+ this._paintTiles(this._rectTiles(p), 0xae7bff, 0.7);
+ }
+
+ // Frame the camera on the spawn before the local player exists.
+ const sp = this._tileToWorld(layout.spawn?.tx ?? grid / 2, layout.spawn?.ty ?? grid / 2);
+ this._camTarget.set(sp.x, 0, sp.z);
+
+ this.hud.realm.textContent = (layout.name || 'realm').replace(/^\w/, (m) => m.toUpperCase());
+ }
+
+ _rectTiles(r) {
+ const out = [];
+ for (let tx = r.x0; tx <= r.x1; tx++) for (let ty = r.y0; ty <= r.y1; ty++) out.push({ tx, ty });
+ return out;
+ }
+
+ _paintTiles(tiles, color, opacity) {
+ if (!tiles?.length) return;
+ const mat = new MeshBasicMaterial({ color, transparent: true, opacity, side: DoubleSide });
+ const geo = new PlaneGeometry(TILE * 0.92, TILE * 0.92);
+ for (const t of tiles) {
+ const m = new Mesh(geo, mat);
+ m.rotation.x = -Math.PI / 2;
+ const w = this._tileToWorld(t.tx, t.ty);
+ m.position.set(w.x, 0.04, w.z);
+ this.staticGroup.add(m);
+ }
+ }
+
+ // A faint white tile grid drawn once into a tiling canvas texture.
+ _gridTexture(grid) {
+ const px = 64;
+ const c = document.createElement('canvas'); c.width = c.height = px;
+ const x = c.getContext('2d');
+ x.fillStyle = '#5c8a44'; x.fillRect(0, 0, px, px);
+ x.strokeStyle = 'rgba(255,255,255,0.10)'; x.lineWidth = 2;
+ x.strokeRect(0, 0, px, px);
+ const tex = new CanvasTexture(c);
+ tex.wrapS = tex.wrapT = RepeatWrapping;
+ tex.repeat.set(grid, grid);
+ tex.colorSpace = SRGBColorSpace;
+ return tex;
+ }
+
+ // ---------------------------------------------------------------- connect
+ async start(name) {
+ if (this.phase === 'world' || this.phase === 'connecting') return;
+ this.phase = 'connecting';
+ this._setHudPhase('connecting');
+ // Reuse the avatar the player already picked on /play (persisted there).
+ // Cross-player avatar sync needs a networked field on GamePlayer; until
+ // then this at least keeps your own look consistent across both scenes.
+ this.avatarPref = localStorage.getItem('cc-avatar') || '';
+ await loadManifest();
+
+ this.net = new GameNet({ name });
+ this.net.on('status', ({ status, error }) => this._onStatus(status, error));
+ this.net.on('realm', (layout) => this._buildRealm(layout));
+ this.net.on('notice', (n) => this._toast(n));
+ this.net.on('bank', (b) => this._onBank(b));
+ this.net.on('playerAdd', (p, id) => this._playerAdd(p, id));
+ this.net.on('playerChange', (p, id) => this._playerChange(p, id));
+ this.net.on('playerRemove', (id) => this._playerRemove(id));
+ this.net.on('nodeAdd', (n, id) => this._nodeAdd(n, id));
+ this.net.on('nodeChange', (n, id) => this._nodeChange(n, id));
+ this.net.on('nodeRemove', (id) => this._nodeRemove(id));
+ this.net.on('mobAdd', (m, id) => this._mobAdd(m, id));
+ this.net.on('mobChange', (m, id) => this._mobChange(m, id));
+ this.net.on('mobRemove', (id) => this._mobRemove(id));
+
+ await this.net.connect();
+ this.myId = this.net.sessionId;
+ this._initJoystick();
+ }
+
+ _onStatus(status, error) {
+ this.hud.status.textContent = status;
+ this.hud.status.dataset.status = status;
+ if (status === 'online') {
+ this.phase = 'world';
+ this._setHudPhase('world');
+ } else if (status === 'offline' || status === 'failed') {
+ // Keep the world visible if we were already in it (a transient drop);
+ // only fall back to the offline screen if we never connected.
+ if (this.phase !== 'world') { this.phase = 'offline'; this._setHudPhase('offline'); }
+ this.hud.offlineMsg.textContent = error || 'Disconnected from the game server.';
+ }
+ this._updateOnline();
+ }
+
+ // ---------------------------------------------------------------- players
+ _playerAdd(p, id) {
+ if (this.players.has(id)) { this.players.get(id).apply(p); return; }
+ const isLocal = id === this.myId;
+ const view = new GamePlayerView(this.scene, (tx, ty) => this._tileToWorld(tx, ty), p, isLocal);
+ if (isLocal && this.avatarPref) view.setAvatar(this.avatarPref);
+ this.players.set(id, view);
+ this._updateOnline();
+ }
+ _playerChange(p, id) { this.players.get(id)?.apply(p); }
+ _playerRemove(id) {
+ const v = this.players.get(id);
+ if (v) { v.dispose(); this.players.delete(id); this._updateOnline(); }
+ }
+ _localView() { return this.myId ? this.players.get(this.myId) : null; }
+
+ _updateOnline() {
+ if (this.hud?.online) this.hud.online.textContent = String(this.players.size || 0);
+ }
+
+ // ---------------------------------------------------------------- nodes
+ // Resource nodes (trees/rocks/coal). T7 swaps _buildNodeView for richer
+ // geometry + gather interactions; the add/change/remove plumbing stays.
+ _nodeAdd(node, id) {
+ if (this.nodeViews.has(id)) { this._nodeChange(node, id); return; }
+ const group = this._buildNodeView(node);
+ const w = this._tileToWorld(node.tx, node.ty);
+ group.position.set(w.x, 0, w.z);
+ group.visible = !node.depleted;
+ this.objectGroup.add(group);
+ this.nodeViews.set(id, { group, node });
+ }
+ _nodeChange(node, id) {
+ const v = this.nodeViews.get(id);
+ if (!v) return;
+ v.node = node;
+ v.group.visible = !node.depleted;
+ }
+ _nodeRemove(id) {
+ const v = this.nodeViews.get(id);
+ if (v) { this.objectGroup.remove(v.group); this.nodeViews.delete(id); }
+ }
+
+ // Override seam for T7. Baseline: a recognizable low-poly prop per kind.
+ _buildNodeView(node) {
+ const g = new Group();
+ if (node.kind === 'tree') {
+ const trunk = new Mesh(new CylinderGeometry(0.12, 0.16, 0.9, 8),
+ new MeshStandardMaterial({ color: 0x6b4a2b, roughness: 1 }));
+ trunk.position.y = 0.45; trunk.castShadow = true;
+ const leaves = new Mesh(new ConeGeometry(0.7, 1.4, 8),
+ new MeshStandardMaterial({ color: 0x3f7d3a, roughness: 1 }));
+ leaves.position.y = 1.5; leaves.castShadow = true;
+ g.add(trunk, leaves);
+ } else if (node.kind === 'coal') {
+ const m = new Mesh(new IcosahedronGeometry(0.55, 0),
+ new MeshStandardMaterial({ color: 0x23262e, roughness: 0.6, metalness: 0.2 }));
+ m.position.y = 0.45; m.castShadow = true; g.add(m);
+ } else { // rock
+ const m = new Mesh(new DodecahedronGeometry(0.6, 0),
+ new MeshStandardMaterial({ color: 0x8a8f9c, roughness: 0.9 }));
+ m.position.y = 0.45; m.castShadow = true; g.add(m);
+ }
+ return g;
+ }
+
+ // ---------------------------------------------------------------- mobs
+ // T8 swaps _buildMobView for proper enemies + attack interactions.
+ _mobAdd(mob, id) {
+ if (this.mobViews.has(id)) { this._mobChange(mob, id); return; }
+ const group = this._buildMobView(mob);
+ const w = this._tileToWorld(mob.tx, mob.ty);
+ group.position.set(w.x, 0, w.z);
+ group.visible = !mob.dead;
+ this.objectGroup.add(group);
+ this.mobViews.set(id, { group, mob });
+ }
+ _mobChange(mob, id) {
+ const v = this.mobViews.get(id);
+ if (!v) return;
+ v.mob = mob;
+ v.group.visible = !mob.dead;
+ const w = this._tileToWorld(mob.tx, mob.ty);
+ v.group.position.set(w.x, 0, w.z);
+ }
+ _mobRemove(id) {
+ const v = this.mobViews.get(id);
+ if (v) { this.objectGroup.remove(v.group); this.mobViews.delete(id); }
+ }
+
+ // Override seam for T8. Baseline: a colour-coded stand-in per mob kind.
+ _buildMobView(mob) {
+ const g = new Group();
+ const color = mob.kind === 'ogre' ? 0x9c5a3c : mob.kind === 'goblin' ? 0x5a8c3c : 0x9aa0ac;
+ const scale = mob.kind === 'ogre' ? 1.4 : 1;
+ const body = new Mesh(new CylinderGeometry(0.3 * scale, 0.35 * scale, 1.1 * scale, 10),
+ new MeshStandardMaterial({ color, roughness: 0.9 }));
+ body.position.y = 0.55 * scale; body.castShadow = true;
+ g.add(body);
+ return g;
+ }
+
+ // ---------------------------------------------------------------- banking / notices
+ // Bank contents arrive here (T9 renders the bank UI). Kept so the server's
+ // 'bank' message has a real consumer and the latest snapshot is available.
+ _onBank(payload) { this._bank = payload?.slots || []; }
+
+ _toast({ kind, text }) {
+ if (!text) return;
+ const el = document.createElement('div');
+ el.className = 'kg-toast kg-toast--' + (kind || 'info');
+ el.textContent = text;
+ this.hud.toasts.appendChild(el);
+ requestAnimationFrame(() => el.classList.add('kg-toast--in'));
+ setTimeout(() => { el.classList.remove('kg-toast--in'); setTimeout(() => el.remove(), 300); }, 2600);
+ }
+
+ // ---------------------------------------------------------------- input
+ _bindInput() {
+ window.addEventListener('keydown', (e) => {
+ if (this._typing()) return;
+ this.keys.add(e.key.toLowerCase());
+ });
+ window.addEventListener('keyup', (e) => this.keys.delete(e.key.toLowerCase()));
+ window.addEventListener('blur', () => this.keys.clear());
+
+ this.canvas.addEventListener('pointerdown', (e) => {
+ this._dragging = true; this._lastPtr = { x: e.clientX, y: e.clientY }; this._downAt = performance.now();
+ });
+ window.addEventListener('pointerup', () => { this._dragging = false; });
+ window.addEventListener('pointermove', (e) => {
+ if (!this._dragging) return;
+ const dx = e.clientX - this._lastPtr.x, dy = e.clientY - this._lastPtr.y;
+ this._lastPtr = { x: e.clientX, y: e.clientY };
+ this.camYaw -= dx * 0.005;
+ this.camPitch = Math.max(0.45, Math.min(1.25, this.camPitch + dy * 0.004));
+ });
+ this.canvas.addEventListener('wheel', (e) => {
+ e.preventDefault();
+ this.camDist = Math.max(7, Math.min(30, this.camDist * (e.deltaY > 0 ? 1.1 : 0.9)));
+ }, { passive: false });
+ }
+
+ _typing() {
+ const a = document.activeElement;
+ return a && (a.tagName === 'INPUT' || a.tagName === 'TEXTAREA');
+ }
+
+ _initJoystick() {
+ const zone = document.getElementById('kg-joystick');
+ if (!zone || this._nipple) return;
+ if (!matchMedia('(pointer: coarse)').matches) { zone.style.display = 'none'; return; }
+ this._nipple = nipplejs.create({ zone, mode: 'static', position: { left: '64px', bottom: '76px' }, color: '#9aa0ac', size: 110 });
+ this._nipple.on('move', (_e, d) => {
+ const f = Math.min(1, d.force);
+ this._joy = { x: Math.cos(d.angle.radian) * f, z: -Math.sin(d.angle.radian) * f };
+ });
+ this._nipple.on('end', () => { this._joy = null; });
+ }
+
+ // Movement intent (keys + joystick) → a camera-relative world direction →
+ // the nearest 8-way tile delta, sent as one authoritative step per cadence.
+ _attemptStep() {
+ const me = this._localView();
+ if (!me || me.dead || !this.realm) return;
+
+ let f = 0, r = 0;
+ if (this.keys.has('w') || this.keys.has('arrowup')) f += 1;
+ if (this.keys.has('s') || this.keys.has('arrowdown')) f -= 1;
+ if (this.keys.has('d') || this.keys.has('arrowright')) r += 1;
+ if (this.keys.has('a') || this.keys.has('arrowleft')) r -= 1;
+ if (this._joy) { f += -this._joy.z; r += this._joy.x; }
+ if (!f && !r) return;
+
+ // Camera basis on the ground plane. forward = camera→target.
+ const fwd = { x: -Math.sin(this.camYaw), z: -Math.cos(this.camYaw) };
+ const right = { x: Math.cos(this.camYaw), z: -Math.sin(this.camYaw) };
+ const wx = right.x * r + fwd.x * f;
+ const wz = right.z * r + fwd.z * f;
+ if (Math.abs(wx) < 1e-3 && Math.abs(wz) < 1e-3) return;
+
+ const dtx = wx > 0.4 ? 1 : wx < -0.4 ? -1 : 0;
+ const dty = wz > 0.4 ? 1 : wz < -0.4 ? -1 : 0;
+ if (!dtx && !dty) return;
+
+ const tx = me.tx + dtx, ty = me.ty + dty;
+ const yaw = Math.atan2(wx, wz);
+ if (!this._isWalkable(tx, ty)) {
+ // Try sliding along whichever axis is clear so we hug walls instead of
+ // sticking — server still validates the final step.
+ if (dtx && this._isWalkable(me.tx + dtx, me.ty)) return this._sendStep(me.tx + dtx, me.ty, yaw);
+ if (dty && this._isWalkable(me.tx, me.ty + dty)) return this._sendStep(me.tx, me.ty + dty, yaw);
+ me.yaw = yaw; // still face the way we're pushing
+ return;
+ }
+ this._sendStep(tx, ty, yaw);
+ }
+
+ _sendStep(tx, ty, yaw) {
+ this.net?.step(tx, ty, yaw);
+ }
+
+ // Client-side walkability mirror of the server (bounds + blocked + live node/
+ // mob occupancy) so we don't spam steps the server will reject.
+ _isWalkable(tx, ty) {
+ const grid = this.realm?.grid ?? 48;
+ if (tx < 0 || ty < 0 || tx >= grid || ty >= grid) return false;
+ for (const b of this.realm.blocked || []) {
+ if (tx >= b.x0 && tx <= b.x1 && ty >= b.y0 && ty <= b.y1) return false;
+ }
+ for (const [, v] of this.nodeViews) {
+ if (!v.node.depleted && v.node.tx === tx && v.node.ty === ty) return false;
+ }
+ for (const [, v] of this.mobViews) {
+ if (!v.mob.dead && v.mob.tx === tx && v.mob.ty === ty) return false;
+ }
+ return true;
+ }
+
+ // ---------------------------------------------------------------- HUD
+ _bindHud() {
+ this.hud = {
+ start: document.getElementById('kg-start'),
+ startBtn: document.getElementById('kg-start-btn'),
+ nameInput: document.getElementById('kg-name'),
+ offline: document.getElementById('kg-offline'),
+ offlineMsg: document.getElementById('kg-offline-msg'),
+ retryBtn: document.getElementById('kg-retry'),
+ topbar: document.getElementById('kg-topbar'),
+ realm: document.getElementById('kg-realm'),
+ online: document.getElementById('kg-online'),
+ status: document.getElementById('kg-status'),
+ toasts: document.getElementById('kg-toasts'),
+ hint: document.getElementById('kg-hint'),
+ };
+ const savedName = localStorage.getItem('cc-name') || '';
+ if (savedName) this.hud.nameInput.value = savedName;
+ this.hud.nameInput.placeholder = 'guest-' + Math.random().toString(36).slice(2, 6);
+
+ const begin = () => {
+ const name = (this.hud.nameInput.value || this.hud.nameInput.placeholder).trim().slice(0, 24);
+ localStorage.setItem('cc-name', name);
+ this.start(name);
+ };
+ this.hud.startBtn.addEventListener('click', begin);
+ this.hud.nameInput.addEventListener('keydown', (e) => { if (e.key === 'Enter') begin(); });
+ this.hud.retryBtn.addEventListener('click', () => {
+ this._setHudPhase('connecting');
+ this.phase = 'connecting';
+ this.net ? this.net.retry() : this.start(this.hud.nameInput.value || this.hud.nameInput.placeholder);
+ });
+ this._setHudPhase('start');
+ }
+
+ _setHudPhase(phase) {
+ this.hud.start.hidden = phase !== 'start';
+ this.hud.offline.hidden = phase !== 'offline';
+ this.hud.topbar.hidden = !(phase === 'world' || phase === 'connecting');
+ this.hud.hint.hidden = phase !== 'world';
+ document.body.classList.toggle('kg-loading-cursor', phase === 'connecting');
+ }
+
+ // ---------------------------------------------------------------- loop
+ _loop() {
+ requestAnimationFrame(this._loop);
+ const now = performance.now();
+ const dt = Math.min(0.05, (now - this._last) / 1000);
+ this._last = now;
+
+ if (this.phase === 'world') {
+ this._stepAccum += now - (this._stepLast || now);
+ this._stepLast = now;
+ if (this._stepAccum >= STEP_INTERVAL_MS) { this._stepAccum = 0; this._attemptStep(); }
+ for (const [, v] of this.players) v.tick(dt);
+ this._updateCamera();
+ this._updateLabels();
+ } else {
+ this._stepLast = now;
+ this._idleCamera(dt);
+ }
+ this.renderer.render(this.scene, this.camera);
+ }
+
+ _updateCamera() {
+ const me = this._localView();
+ if (me) this._camTarget.lerp(new Vector3(me.rig.position.x, 0.8, me.rig.position.z), 0.12);
+ this._placeCamera();
+ }
+
+ // Slow orbit of the spawn while on the start/offline screens for a touch of life.
+ _idleCamera(dt) {
+ this.camYaw += dt * 0.05;
+ this._placeCamera();
+ }
+
+ _placeCamera() {
+ const t = this._camTarget;
+ const x = t.x + this.camDist * Math.cos(this.camPitch) * Math.sin(this.camYaw);
+ const z = t.z + this.camDist * Math.cos(this.camPitch) * Math.cos(this.camYaw);
+ const y = t.y + this.camDist * Math.sin(this.camPitch);
+ this.camera.position.set(x, y, z);
+ this.camera.lookAt(t);
+ // Keep the sun roughly following the action so shadows stay framed.
+ if (this._sun) {
+ this._sun.position.set(t.x + 24, 40, t.z + 18);
+ this._sun.target.position.set(t.x, 0, t.z);
+ this._sun.target.updateMatrixWorld();
+ }
+ }
+
+ // Project each player's head to screen space and place its DOM nameplate.
+ _updateLabels() {
+ const w = window.innerWidth, h = window.innerHeight;
+ const v = new Vector3();
+ for (const [, pv] of this.players) {
+ if (pv.dead) { pv.label.style.display = 'none'; continue; }
+ v.set(pv.rig.position.x, pv.height + 0.35, pv.rig.position.z).project(this.camera);
+ const behind = v.z > 1;
+ if (behind) { pv.label.style.display = 'none'; continue; }
+ pv.label.style.display = '';
+ const sx = (v.x * 0.5 + 0.5) * w;
+ const sy = (-v.y * 0.5 + 0.5) * h;
+ pv.label.style.transform = `translate(-50%, -100%) translate(${sx.toFixed(1)}px, ${sy.toFixed(1)}px)`;
+ }
+ }
+
+ _onResize() {
+ this.camera.aspect = window.innerWidth / window.innerHeight;
+ this.camera.updateProjectionMatrix();
+ this.renderer.setSize(window.innerWidth, window.innerHeight);
+ }
+
+ destroy() {
+ this.net?.destroy();
+ for (const [, v] of this.players) v.dispose();
+ this.players.clear();
+ this._nipple?.destroy();
+ }
+}
+
+const canvas = document.getElementById('kg-canvas');
+if (canvas) {
+ const game = new IsoGame(canvas);
+ if (typeof window !== 'undefined') window.__ISO__ = game;
+}
diff --git a/vercel.json b/vercel.json
index de063330f..c7de44448 100644
--- a/vercel.json
+++ b/vercel.json
@@ -325,6 +325,10 @@
"src": "/play/?",
"dest": "/play.html"
},
+ {
+ "src": "/game/?",
+ "dest": "/game.html"
+ },
{
"src": "/walk/?",
"dest": "/walk.html"
diff --git a/vite.config.js b/vite.config.js
index 2b18bdafa..55362ff34 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -241,6 +241,7 @@ const appConfig = {
communities: resolve(__dirname, 'pages/communities.html'),
'walk-embed': resolve(__dirname, 'pages/walk-embed.html'),
play: resolve(__dirname, 'pages/play.html'),
+ game: resolve(__dirname, 'pages/game.html'),
pose: resolve(__dirname, 'pages/pose.html'),
club: resolve(__dirname, 'pages/club.html'),
skills: resolve(__dirname, 'pages/skills.html'),