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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
Add avatar-actions ownership surface; club entrance venue build script
nirholas333ddbefb9db
diff --git a/.gitignore b/.gitignoreindex 6297674b3..b8d4bc740 100644--- a/.gitignore+++ b/.gitignore@@ -234,3 +234,8 @@ scripts/.corr-*space_smugglers_club_house_-_dark_version.glbim-in-love-wit-a-stripper-fast.mp3++# Raw /club entrance source exports — the compressed runtime copies under+# public/club/venue/ are the committed source of truth (rebuild with+# scripts/build-club-entrance-venue.mjs).+alleyway.glbdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex e7fe0294f..f95abfe2a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,6 +28,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Rate and vouch for Solana agents from their passport** — Every Solana agent passport already showed its on-chain reputation — now you can add to it. A new "Rate this agent" panel lets anyone with a Solana wallet (Phantom or Solflare) leave a 1–5 score, with an optional public note, written on-chain as a signed attestation — no account needed. You can also back your rating with a SOL stake (from 0.001 SOL) sent to the agent's owner for an economically-weighted vouch. Submitting is guarded the obvious ways: you can't rate your own agent, scores are limited to 1–5, the minimum stake is enforced, and re-rating asks you to confirm before it updates your previous score. The moment your transaction confirms, the passport re-reads the chain on demand instead of waiting for the next indexing pass, so your rating shows up in the reputation summary within seconds. (`/agent-passport.html`) `[feature]`- **Register an existing agent on-chain in one click** — Any agent you already built can now be given an ERC-8004 on-chain identity straight from its profile — no re-entering its name, 3D model, voice, or skills. The new "Register on-chain" control reuses everything the agent already has, automatically assembles and pins a full agent manifest (its persona, voice, installed skills, and memory mode), links that manifest to the on-chain agent card, and mints the identity on the network you pick. Re-running it on the same network is a safe no-op, and your profile shows a live on-chain badge with explorer and agent-card links the moment it's done. (`/agents`) `[feature]`- **Registered agents now carry an on-chain "Validated" badge** — When an agent is registered on-chain, three.ws now automatically runs its 3D model through the platform's glTF validator and records a signed validation attestation on the ERC-8004 ValidationRegistry — so an agent that advertises validation actually carries proof of it. A green "Validated" badge appears on the agent profile, readable by anyone without a wallet, and links straight to the full validation report and the on-chain record. The check is independent of the file's byte-identity (sha256), so both are surfaced on their own: a model that passes schema validation still shows its exact byte fingerprint. If a model has problems, the badge shows "Validation failed" with the specific reason — the agent is still registered, just unvalidated — and owners can re-validate after updating their model to refresh the badge. Validation is best-effort and never blocks or reverts a registration. (`/marketplace`) `[feature, security]`+- **Save any avatar as your own — forks with their own wallet** — Saving someone else's avatar now works like forking on GitHub: it mints a brand-new avatar in your account with its own copy of the model, linked back to the original with a "Forked from" credit and a fork counter on the source. You never share one avatar between two people — your copy is yours to edit, deploy, or launch, and the original owner's stays untouched. Every saved or forked avatar's agent also gets its own custodial wallet (EVM + Solana) the moment it lands, assigned to you alone — create it, copy the addresses, or manage it right from the avatar page, the editor, and the gallery picker. One person can hold a copy of another's avatar, but no two people ever control the same agent wallet. (`/gallery`) `[feature]`- **Sell your animations in the marketplace** — Animations you build in the Studio can now be listed for sale. Pose a figure, drop your keyframes, save the clip, then hit Sell — set a price in USDC (or list it free) and three.ws bakes a self-contained animated GLB and publishes it to a new "From creators" shelf in the animation marketplace. Buyers see a poster, the creator, length and price; free clips download in one click, and paid clips are unlocked by paying once in USDC on Base or Solana — re-download free forever from the same wallet. Earnings settle straight to your payout wallet, and your motion data stays gated behind the paywall until someone buys. (`/marketplace?tab=animations`) `[feature]`- **Sniper Arena — watch AI agents trade pump.fun live** — Agents can now trade pump.fun autonomously. A new always-on engine watches every launch in real time, scores it against an agent's strategy (market-cap band, creator track record, socials), and — when it qualifies — buys from the agent's own Solana wallet, then manages the position to a take-profit, stop-loss, trailing stop, or timeout exit. Arming an agent is opt-in and capped: you set a daily budget, a per-trade size, and a mandatory stop-loss, with a kill switch that halts new buys instantly. The new Sniper Arena at three.ws/play/arena shows it all happening live — a P&L leaderboard, a streaming trade ticker where every fill links to its on-chain transaction, and the top agent's 3D avatar reacting to its own wins. Autonomous trading is experimental and you can lose the funds you commit. (`/play/arena`) `[feature]`- **Strategy Lab now catches broken trading strategies before they run** — Validation in the Strategy Lab (three.ws/strategy-lab) went from a basic syntax check to a real soundness check, so a strategy can't quietly pass review and then misbehave with live funds. It now flags the mistakes that used to slip through: a misspelled metric that silently never matches, a threshold that can never be true (like a percentage above 100), filters that contradict each other so the strategy would never buy, a position rule placed where no position exists yet, a per-trade size larger than the session budget, and later exit rules that an earlier rule always triggers first. When you point a strategy at specific coins, it confirms each one actually exists and warns if a SOL-denominated strategy targets a USDC-paired coin. Problems are shown inline, field by field, with a plain-language reason and exactly where to fix them — and the same checks now guard Backtest and Run, so what validates is what executes. (`/strategy-lab`) `[improvement]`diff --git a/data/changelog.json b/data/changelog.jsonindex fad4cf85f..fd3719a14 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,13 @@{"$comment": "Curated changelog entries for three.ws — 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-15",+ "title": "Save any avatar as your own — forks with their own wallet",+ "summary": "Saving someone else's avatar now works like forking on GitHub: it mints a brand-new avatar in your account with its own copy of the model, linked back to the original with a \"Forked from\" credit and a fork counter on the source. You never share one avatar between two people — your copy is yours to edit, deploy, or launch, and the original owner's stays untouched. Every saved or forked avatar's agent also gets its own custodial wallet (EVM + Solana) the moment it lands, assigned to you alone — create it, copy the addresses, or manage it right from the avatar page, the editor, and the gallery picker. One person can hold a copy of another's avatar, but no two people ever control the same agent wallet.",+ "tags": ["feature"],+ "link": "/gallery"+ },{"date": "2026-06-15","title": "Sell your animations in the marketplace",diff --git a/package.json b/package.jsonindex 723b1f226..19e421973 100644--- a/package.json+++ b/package.json@@ -88,6 +88,7 @@"build:club-venue": "node scripts/build-club-venue.mjs","build:club-hdri": "node scripts/build-club-hdri.mjs","build:club-audio": "node scripts/build-club-audio.mjs",+ "build:club-entrance-venue": "node scripts/build-club-entrance-venue.mjs","build:club-assets": "(npm run build:club-props & npm run build:club-venue & npm run build:club-hdri & wait)","build:artifact-viewer": "node scripts/build-artifact-viewer.mjs","build:lib": "TARGET=lib vite build",diff --git a/pages/avatar-edit.html b/pages/avatar-edit.htmlindex 33f69a6e1..02da49581 100644--- a/pages/avatar-edit.html+++ b/pages/avatar-edit.html@@ -737,8 +737,10 @@<div class="ae-chips" id="ae-chips" aria-label="Current outfit"></div><div class="ae-panel" id="ae-panel"></div><div class="ae-status" id="ae-status">Hover any item to try it on. Click to keep.</div>+ <avatar-actions id="ae-actions" style="margin-top:14px;display:block"></avatar-actions></aside></main>+ <script src="/avatar-actions.js" type="module"></script><script src="/src/avatar-edit.js" type="module"></script><script src="/brand.js" defer></script></body>diff --git a/pages/avatar-page.html b/pages/avatar-page.htmlindex d2cb9ff83..3660382d7 100644--- a/pages/avatar-page.html+++ b/pages/avatar-page.html@@ -1565,6 +1565,7 @@</div></footer>+ <script src="/avatar-actions.js" type="module"></script><script src="/src/avatar-page.js" type="module"></script><script src="/brand.js" defer></script></body>diff --git a/pages/club.html b/pages/club.htmlindex eff06d4a9..270df1e89 100644--- a/pages/club.html+++ b/pages/club.html@@ -602,10 +602,26 @@100% { opacity: 0; visibility: hidden; }}+ /* ── Entrance journey canvas ────────────────────────── */+ /* The live first-person scene (src/club-entrance.js): the alley you+ land in, then the walk through the club house. Full-screen, behind+ the door card, above the pole stage. pointer-events:none so the+ card owns interaction; the module fades + removes it on arrival. */+ .club-door-canvas {+ position: fixed;+ inset: 0;+ width: 100%;+ height: 100%;+ display: block;+ z-index: 9400;+ pointer-events: none;+ }+/* ── Door / cover-charge gate ───────────────────────── */- /* The line outside the club. Sits above the room (which boots- behind it) but below the x402 wallet modal (z 2.1e9) so the- payment flow renders on top. */+ /* The line outside the club, in the alley. Sits above the entrance+ scene (which renders behind it) but below the x402 wallet modal+ (z 2.1e9) so the payment flow renders on top. The background is an+ accent vignette only — the live alley shows through it. */.club-door {position: fixed;inset: 0;@@ -615,9 +631,9 @@justify-content: center;padding: 24px;background:- radial-gradient(120% 90% at 50% -10%, rgba(255, 59, 214, 0.16), transparent 55%),- radial-gradient(120% 90% at 50% 110%, rgba(74, 214, 255, 0.12), transparent 55%),- #040308;+ radial-gradient(120% 90% at 50% -10%, rgba(255, 59, 214, 0.20), transparent 55%),+ radial-gradient(120% 90% at 50% 110%, rgba(74, 214, 255, 0.16), transparent 55%),+ radial-gradient(125% 125% at 50% 50%, transparent 32%, rgba(4, 3, 8, 0.74) 100%);opacity: 1;transition: opacity 0.7s ease, visibility 0.7s ease;}@@ -1266,9 +1282,15 @@<!-- Entrance overlay — fades out over 1s on load --><div id="club-entrance" class="club-entrance" aria-hidden="true"></div>- <!-- Door / cover-charge gate — the line outside the club. The 3D room- boots behind this overlay; src/club-gate.js drops the rope once the- x402 cover settles and the on-chain bouncer admits the wallet. -->+ <!-- Entrance journey — live first-person scene (src/club-entrance.js):+ the alley you land in, then the walk through the club house after+ you pay. Sits behind the door card, above the pole stage. -->+ <canvas id="club-door-canvas" class="club-door-canvas" aria-hidden="true"></canvas>++ <!-- Door / cover-charge gate — the line outside the club, in the alley.+ The 3D room boots behind this overlay; src/club-gate.js drops the+ rope once the x402 cover settles and the on-chain bouncer admits+ the wallet, handing off to the walk-through. --><divid="club-door"class="club-door"@@ -1286,12 +1308,12 @@<!-- QUEUE: pay the cover --><div class="club-door-state is-queue">- <p class="club-door-eyebrow">You're in line</p>+ <p class="club-door-eyebrow">You're in line · out in the alley</p><h1 id="club-door-title" class="club-door-title">Pole Club</h1><p class="club-door-copy">There's a cover tonight. Pay <b>$0.01 USDC</b> at the door — the- bouncer checks your wallet on-chain, and if you're not on the list,- the rope drops.+ bouncer checks your wallet on-chain, and if you're on the list, the+ rope drops and you walk inside.</p><button type="button" id="club-door-pay" class="club-door-pay">Pay cover · $0.01 to enter@@ -1447,6 +1469,8 @@<!-- x402 drop-in modal (Phantom/MetaMask wallet flow + 402 retry) --><script type="module" src="/x402.js"></script>+ <!-- Entrance journey — alley → walk-through, behind the door card. -->+ <script type="module" src="/src/club-entrance.js"></script><!-- Door gate — runs the cover-charge bouncer over the room boot. --><script type="module" src="/src/club-gate.js"></script><script type="module" src="/src/club.js"></script>diff --git a/public/avatar-actions.js b/public/avatar-actions.jsnew file mode 100644index 000000000..7e0c455bb--- /dev/null+++ b/public/avatar-actions.js@@ -0,0 +1,346 @@+// <avatar-actions> — the per-avatar ownership + wallet control surfaced on every+// place a user interacts with, saves, or edits a 3D avatar.+//+// It expresses one model consistently everywhere:+// • Saving someone else's avatar is a FORK — it mints a NEW avatar in your+// namespace (copied model, your owner_id), linked back GitHub-style with+// "Forked from <owner>". You never co-own one row.+// • Every avatar's agent has its own custodial wallet, assigned per user. The+// owner can create it (if missing) and manage it; nobody else can touch it.+//+// Usage (drop into any page):+// <script type="module" src="/avatar-actions.js"></script>+// <avatar-actions avatar-id="<uuid>"></avatar-actions>+// Optionally seed data to skip a fetch:+// el.avatar = avatarObjectFromApi; // { id, owner_id, agent_id, ... }+// Variants: variant="full" (default) | "compact" (icon-dense, for cards/toolbars)+//+// Emits bubbling CustomEvents the host can react to:+// 'avatar-forked' detail: { avatar, agent } — a new fork was created+// 'wallet-created' detail: { agentId, wallet_address, solana_address }++const API = '';+let _mePromise = null;++function me() {+ if (!_mePromise) {+ _mePromise = fetch(`${API}/api/auth/me`, { credentials: 'include' })+ .then((r) => (r.ok ? r.json() : { user: null }))+ .then((d) => d.user || null)+ .catch(() => null);+ }+ return _mePromise;+}++let _csrf = null;+async function csrfToken() {+ if (_csrf) return _csrf;+ try {+ const r = await fetch(`${API}/api/csrf-token`, { credentials: 'include' });+ if (!r.ok) return null;+ _csrf = (await r.json()).token || null;+ } catch {+ _csrf = null;+ }+ return _csrf;+}++const short = (a) => (a && a.length > 12 ? `${a.slice(0, 6)}…${a.slice(-4)}` : a || '');++const styles = `+:host { display: block; --aa-fg: var(--text, #f5f5f6); --aa-dim: var(--text-dim, #8c8c92);+ --aa-bg: var(--surface-2, rgba(255,255,255,0.04)); --aa-line: var(--border, rgba(255,255,255,0.1));+ --aa-acc: var(--accent, #9945ff); --aa-good: #5fd08a; --aa-bad: #e06c75;+ font: 13px/1.45 var(--font, ui-sans-serif, system-ui, sans-serif); color: var(--aa-fg); }+.card { border: 1px solid var(--aa-line); border-radius: 12px; background: var(--aa-bg);+ padding: 14px; display: flex; flex-direction: column; gap: 12px; }+:host([variant="compact"]) .card { padding: 10px; gap: 8px; border-radius: 10px; }+.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }+.spread { justify-content: space-between; }+.lineage { font-size: 12px; color: var(--aa-dim); display: flex; align-items: center; gap: 6px; }+.lineage a { color: var(--aa-fg); text-decoration: none; border-bottom: 1px dashed var(--aa-line); }+.lineage a:hover { border-bottom-color: var(--aa-acc); color: var(--aa-acc); }+.forks { font-size: 12px; color: var(--aa-dim); }+button { font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid var(--aa-line);+ background: rgba(255,255,255,0.04); color: var(--aa-fg); padding: 8px 12px; display: inline-flex;+ align-items: center; gap: 7px; transition: background .15s, border-color .15s, transform .05s; }+button:hover { background: rgba(255,255,255,0.08); border-color: var(--aa-acc); }+button:active { transform: translateY(1px); }+button:focus-visible { outline: 2px solid var(--aa-acc); outline-offset: 2px; }+button[disabled] { opacity: .55; cursor: progress; }+button.primary { background: var(--aa-acc); border-color: var(--aa-acc); color: #fff; font-weight: 600; }+button.primary:hover { filter: brightness(1.08); background: var(--aa-acc); }+.wallet { border: 1px solid var(--aa-line); border-radius: 10px; padding: 10px 12px; display: flex;+ flex-direction: column; gap: 8px; }+.wallet h4 { margin: 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--aa-dim); font-weight: 600; }+.addr { display: flex; align-items: center; gap: 8px; }+.addr .chain { font-size: 10px; font-weight: 700; color: var(--aa-dim); width: 26px; }+.addr code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--aa-fg); }+.copy { padding: 3px 7px; font-size: 11px; }+.copy.copied { color: var(--aa-good); border-color: var(--aa-good); }+.manage { color: var(--aa-acc); text-decoration: none; font-size: 12px; font-weight: 600; }+.manage:hover { text-decoration: underline; }+.msg { font-size: 12px; padding: 8px 10px; border-radius: 8px; }+.msg.err { color: var(--aa-bad); background: rgba(224,108,117,0.1); }+.msg.ok { color: var(--aa-good); background: rgba(95,208,138,0.1); }+.spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-top-color: transparent;+ border-radius: 50%; animation: aa-spin .7s linear infinite; }+@keyframes aa-spin { to { transform: rotate(360deg); } }+.hidden { display: none !important; }+.muted { color: var(--aa-dim); font-size: 12px; }+`;++class AvatarActions extends HTMLElement {+ static get observedAttributes() {+ return ['avatar-id'];+ }++ constructor() {+ super();+ this.attachShadow({ mode: 'open' });+ this._avatar = null;+ this._agent = null;+ this._me = null;+ this._busy = false;+ }++ set avatar(v) {+ this._avatar = v || null;+ if (this.isConnected) this._init();+ }+ get avatar() {+ return this._avatar;+ }++ connectedCallback() {+ this._init();+ }++ attributeChangedCallback(name, oldV, newV) {+ if (name === 'avatar-id' && oldV !== newV && this.isConnected) this._init();+ }++ get avatarId() {+ return this._avatar?.id || this.getAttribute('avatar-id') || null;+ }++ async _init() {+ const id = this.avatarId;+ if (!id) {+ this.shadowRoot.innerHTML = '';+ return;+ }+ this._render(); // initial skeleton+ try {+ this._me = await me();+ if (!this._avatar) {+ const r = await fetch(`${API}/api/avatars/${id}`, { credentials: 'include' });+ if (r.ok) this._avatar = (await r.json()).avatar || null;+ }+ // Resolve the avatar's agent (owner sees wallet_address; secrets stripped).+ const ar = await fetch(`${API}/api/agents?avatar_id=${encodeURIComponent(id)}`, {+ credentials: 'include',+ });+ if (ar.ok) this._agent = (await ar.json()).agents?.[0] || null;+ } catch {+ /* render whatever we have */+ }+ this._render();+ }++ get isOwner() {+ return !!(this._me && this._avatar && this._me.id === this._avatar.owner_id);+ }++ _render() {+ const a = this._avatar;+ const css = `<style>${styles}</style>`;+ if (!a) {+ this.shadowRoot.innerHTML = `${css}<div class="card"><span class="muted">Loading…</span></div>`;+ return;+ }++ const lineage = a.forked_from+ ? `<div class="lineage">⑂ Forked from+ <a href="/avatar-page.html?id=${a.forked_from.avatar_id}" title="View the original">+ ${escapeHtml(a.forked_from.owner_name || a.forked_from.name || 'original')}+ </a></div>`+ : '';+ const forks =+ a.fork_count > 0+ ? `<span class="forks">⑂ ${a.fork_count} ${a.fork_count === 1 ? 'fork' : 'forks'}</span>`+ : '';++ let body = '';+ if (this.isOwner) {+ body = this._walletBlock();+ } else if (this._me) {+ body = `<button class="primary" data-act="fork" title="Save a copy to your own avatars">+ ⑂ Save to my avatars</button>+ <div class="muted">Creates your own copy with its own agent wallet. The original stays untouched.</div>`;+ } else {+ body = `<a class="manage" href="/login.html?next=${encodeURIComponent(location.pathname + location.search)}">Sign in to save this avatar →</a>`;+ }++ this.shadowRoot.innerHTML = `${css}+ <div class="card">+ ${lineage || forks ? `<div class="row spread">${lineage}${forks}</div>` : ''}+ <div class="body">${body}</div>+ <div class="msg-slot"></div>+ </div>`;+ this._wire();+ }++ _walletBlock() {+ const ag = this._agent;+ if (!ag) {+ return `<div class="muted">Save the avatar to give its agent a wallet.</div>`;+ }+ const evm = ag.wallet_address || null;+ const sol = ag.meta?.solana_address || null;+ const manage = `<a class="manage" href="/agent-edit.html?id=${ag.id}">Manage →</a>`;++ if (!evm && !sol) {+ return `<div class="wallet">+ <div class="row spread"><h4>Agent wallet</h4>${manage}</div>+ <div class="muted">No wallet yet. Give this agent a custodial EVM + Solana wallet it can transact with.</div>+ <button class="primary" data-act="create-wallet">Create wallet</button>+ </div>`;+ }+ const addr = (chain, a) =>+ a+ ? `<div class="addr"><span class="chain">${chain}</span><code>${short(a)}</code>+ <button class="copy" data-copy="${a}" title="Copy ${chain} address">Copy</button></div>`+ : '';+ return `<div class="wallet">+ <div class="row spread"><h4>Agent wallet</h4>${manage}</div>+ ${addr('EVM', evm)}+ ${addr('SOL', sol)}+ ${evm && sol ? '' : `<button data-act="create-wallet">Provision missing chain</button>`}+ </div>`;+ }++ _wire() {+ const root = this.shadowRoot;+ root.querySelectorAll('[data-copy]').forEach((b) =>+ b.addEventListener('click', async () => {+ try {+ await navigator.clipboard.writeText(b.dataset.copy);+ b.classList.add('copied');+ const t = b.textContent;+ b.textContent = 'Copied';+ setTimeout(() => {+ b.classList.remove('copied');+ b.textContent = t;+ }, 1400);+ } catch {+ /* clipboard blocked — no-op */+ }+ }),+ );+ root.querySelector('[data-act="fork"]')?.addEventListener('click', () => this._fork());+ root+ .querySelector('[data-act="create-wallet"]')+ ?.addEventListener('click', () => this._createWallet());+ }++ _msg(kind, html) {+ const slot = this.shadowRoot.querySelector('.msg-slot');+ if (slot) slot.innerHTML = `<div class="msg ${kind}">${html}</div>`;+ }++ _setBusy(btn, label) {+ this._busy = true;+ if (btn) {+ btn.disabled = true;+ btn.dataset.label = btn.innerHTML;+ btn.innerHTML = `<span class="spinner"></span>${label}`;+ }+ }+ _clearBusy(btn) {+ this._busy = false;+ if (btn && btn.dataset.label) {+ btn.disabled = false;+ btn.innerHTML = btn.dataset.label;+ }+ }++ async _fork() {+ if (this._busy) return;+ const btn = this.shadowRoot.querySelector('[data-act="fork"]');+ this._setBusy(btn, 'Saving…');+ this._msg('', '');+ try {+ const r = await fetch(`${API}/api/avatars/fork`, {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ source_avatar_id: this.avatarId }),+ });+ const d = await r.json().catch(() => ({}));+ if (!r.ok) throw new Error(d.message || d.error || `fork failed (${r.status})`);+ const wallet = d.agent?.wallet_address ? ` Its agent wallet: <code>${short(d.agent.wallet_address)}</code>.` : '';+ this._msg(+ 'ok',+ `Saved to your avatars. <a class="manage" href="/avatar-page.html?id=${d.avatar.id}">Open →</a>${wallet}`,+ );+ this.dispatchEvent(+ new CustomEvent('avatar-forked', { detail: d, bubbles: true, composed: true }),+ );+ } catch (e) {+ this._msg('err', escapeHtml(e.message));+ } finally {+ this._clearBusy(btn);+ }+ }++ async _createWallet() {+ if (this._busy) return;+ const ag = this._agent;+ if (!ag) return;+ const btn = this.shadowRoot.querySelector('[data-act="create-wallet"]');+ this._setBusy(btn, 'Creating…');+ this._msg('', '');+ try {+ const token = await csrfToken();+ const r = await fetch(`${API}/api/agents/${ag.id}/wallet/provision`, {+ method: 'POST',+ credentials: 'include',+ headers: token ? { 'x-csrf-token': token } : {},+ });+ const d = await r.json().catch(() => ({}));+ if (!r.ok) throw new Error(d.message || d.error || `provision failed (${r.status})`);+ // Reflect the new wallet locally and re-render.+ this._agent = {+ ...ag,+ wallet_address: d.wallet_address,+ meta: { ...(ag.meta || {}), solana_address: d.solana_address },+ };+ this._render();+ this._msg('ok', 'Wallet created. Fund it from the agent page to start transacting.');+ this.dispatchEvent(+ new CustomEvent('wallet-created', {+ detail: { agentId: ag.id, ...d },+ bubbles: true,+ composed: true,+ }),+ );+ } catch (e) {+ this._clearBusy(btn);+ this._msg('err', escapeHtml(e.message));+ }+ }+}++function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+}++if (!customElements.get('avatar-actions')) {+ customElements.define('avatar-actions', AvatarActions);+}++export { AvatarActions };diff --git a/public/changelog.json b/public/changelog.jsonindex 52d4172d9..43317bd20 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-15T16:05:28.055Z",+ "generated_at": "2026-06-15T17:13:58.292Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -233,6 +233,16 @@"security"]},+ {+ "date": "2026-06-15",+ "type": "update",+ "title": "Save any avatar as your own — forks with their own wallet",+ "summary": "Saving someone else's avatar now works like forking on GitHub: it mints a brand-new avatar in your account with its own copy of the model, linked back to the original with a \"Forked from\" credit and a fork counter on the source. You never share one avatar between two people — your copy is yours to edit, deploy, or launch, and the original owner's stays untouched. Every saved or forked avatar's agent also gets its own custodial wallet (EVM + Solana) the moment it lands, assigned to you alone — create it, copy the addresses, or manage it right from the avatar page, the editor, and the gallery picker. One person can hold a copy of another's avatar, but no two people ever control the same agent wallet.",+ "link": "/gallery",+ "tags": [+ "feature"+ ]+ },{"date": "2026-06-15","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 90c81a86c..41dcb5aca 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -182,6 +182,14 @@<category>feature</category><description>When an agent is registered on-chain, three.ws now automatically runs its 3D model through the platform's glTF validator and records a signed validation attestation on the ERC-8004 ValidationRegistry — so an agent that advertises validation actually carries proof of it. A green "Validated" badge appears on the agent profile, readable by anyone without a wallet, and links straight to the full validation report and the on-chain record. The check is independent of the file's byte-identity (sha256), so both are surfaced on their own: a model that passes schema validation still shows its exact byte fingerprint. If a model has problems, the badge shows "Validation failed" with the specific reason — the agent is still registered, just unvalidated — and owners can re-validate after updating their model to refresh the badge. Validation is best-effort and never blocks or reverts a registration.</description></item>+ <item>+ <title>Save any avatar as your own — forks with their own wallet</title>+ <link>https://three.ws/gallery</link>+ <guid isPermaLink="false">2026-06-15:Save any avatar as your own — forks with their own wallet</guid>+ <pubDate>Mon, 15 Jun 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>Saving someone else's avatar now works like forking on GitHub: it mints a brand-new avatar in your account with its own copy of the model, linked back to the original with a "Forked from" credit and a fork counter on the source. You never share one avatar between two people — your copy is yours to edit, deploy, or launch, and the original owner's stays untouched. Every saved or forked avatar's agent also gets its own custodial wallet (EVM + Solana) the moment it lands, assigned to you alone — create it, copy the addresses, or manage it right from the avatar page, the editor, and the gallery picker. One person can hold a copy of another's avatar, but no two people ever control the same agent wallet.</description>+ </item><item><title>Sell your animations in the marketplace</title><link>https://three.ws/marketplace?tab=animations</link>diff --git a/public/features.json b/public/features.jsonindex 28f3f31aa..5eb43eb20 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-15T16:05:28.005Z",+ "generated_at": "2026-06-15T17:13:58.279Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/public/sitemap/index.html b/public/sitemap/index.htmlindex d86babd6b..214e6cc98 100644--- a/public/sitemap/index.html+++ b/public/sitemap/index.html@@ -56,20 +56,6 @@.sm-brand img { width: 24px; height: 24px; border-radius: 5px; }.sm-brand:hover { text-decoration: none; }</style>-- <meta property="og:type" content="website">- <meta property="og:site_name" content="three.ws">- <meta property="og:title" content="Sitemap · three.ws">- <meta property="og:description" content="Human-readable index of every page on three.ws.">- <meta property="og:url" content="https://three.ws/sitemap">- <meta property="og:image" content="https://three.ws/og-image.png">- <meta property="og:image:width" content="1200">- <meta property="og:image:height" content="630">- <meta name="twitter:card" content="summary_large_image">- <meta name="twitter:title" content="Sitemap · three.ws">- <meta name="twitter:description" content="Human-readable index of every page on three.ws.">- <meta name="twitter:image" content="https://three.ws/og-image.png">- <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Sitemap","description":"Human-readable index of every page on three.ws.","url":"https://three.ws/sitemap","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script></head><body><header class="sm-topbar">diff --git a/scripts/build-club-entrance-venue.mjs b/scripts/build-club-entrance-venue.mjsindex 19a8e6759..5778dfec0 100644--- a/scripts/build-club-entrance-venue.mjs+++ b/scripts/build-club-entrance-venue.mjs@@ -1,59 +1,52 @@#!/usr/bin/env node/**- * Compresses the authored "space smugglers club house" GLB into the runtime- * asset the /club entrance scene loads (src/club-entrance.js). The raw export- * is ~21 MB — far too heavy to stream behind the cover-charge door while a- * visitor waits in line — so we run the same GLB → Meshopt + WebP pipeline the- * rest of the venue assets use:+ * Compresses the authored entrance environments into the runtime assets the+ * /club entrance journey loads (src/club-entrance.js):+ *+ * alleyway.glb → public/club/venue/alleyway.glb+ * space_smugglers_club_house_-_dark…glb → public/club/venue/space-smugglers-clubhouse.glb+ *+ * Both raw exports are ~17–21 MB — far too heavy to stream while a visitor+ * stands at the door — so we run each through the same GLB → Meshopt + WebP+ * pipeline the rest of the venue assets use:** weld → prune → dedup → resize+WebP textures → quantize → Meshopt** The runtime GLTFLoader (src/loaders/gltf.js) already wires the Meshopt* decoder + EXT_texture_webp, so the output drops straight in with no loader- * changes. Re-run after re-exporting the source model:+ * changes. Re-run after re-exporting a source model:** npm run build:club-entrance-venue*/-import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync } from 'node:fs';+import { writeFileSync, mkdirSync, existsSync, statSync } from 'node:fs';import { fileURLToPath } from 'node:url';import { dirname, resolve } from 'node:path';import { NodeIO } from '@gltf-transform/core';import { ALL_EXTENSIONS } from '@gltf-transform/extensions';-import {- weld,- prune,- dedup,- quantize,- textureCompress,- meshopt,-} from '@gltf-transform/functions';+import { weld, prune, dedup, quantize, textureCompress, meshopt } from '@gltf-transform/functions';import { MeshoptEncoder } from 'meshoptimizer';import sharp from 'sharp';const __dirname = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(__dirname, '..');--const SRC = resolve(ROOT, 'space_smugglers_club_house_-_dark_version.glb');const OUT_DIR = resolve(ROOT, 'public/club/venue');-const OUT = resolve(OUT_DIR, 'space-smugglers-clubhouse.glb');const MAX_TEXTURE = 2048;-async function main() {- if (!existsSync(SRC)) {- throw new Error(`source GLB not found: ${SRC}`);- }+// Source export → runtime filename. The outside alley you land in, then the+// interior you walk through after paying the cover.+const TARGETS = [+ { src: 'alleyway.glb', out: 'alleyway.glb' },+ { src: 'space_smugglers_club_house_-_dark_version.glb', out: 'space-smugglers-clubhouse.glb' },+];- await MeshoptEncoder.ready;+const mb = (n) => (n / 1024 / 1024).toFixed(2);- const io = new NodeIO()- .registerExtensions(ALL_EXTENSIONS)- .registerDependencies({ 'meshopt.encoder': MeshoptEncoder });-- const before = statSync(SRC).size;- const doc = await io.read(SRC);+async function compress(io, srcPath, outPath) {+ const before = statSync(srcPath).size;+ const doc = await io.read(srcPath);await doc.transform(weld(),@@ -69,14 +62,29 @@ async function main() {meshopt({ encoder: MeshoptEncoder, level: 'high' }),);- mkdirSync(OUT_DIR, { recursive: true });const glb = await io.writeBinary(doc);- writeFileSync(OUT, glb);+ writeFileSync(outPath, glb);+ const after = statSync(outPath).size;+ console.log(`${outPath.replace(ROOT + '/', '')}: ${mb(before)} MB → ${mb(after)} MB`);+}++async function main() {+ await MeshoptEncoder.ready;- const after = statSync(OUT).size;- const mb = (n) => (n / 1024 / 1024).toFixed(2);- console.log(`club entrance venue: ${mb(before)} MB → ${mb(after)} MB`);- console.log(`wrote ${OUT}`);+ const io = new NodeIO()+ .registerExtensions(ALL_EXTENSIONS)+ .registerDependencies({ 'meshopt.encoder': MeshoptEncoder });++ mkdirSync(OUT_DIR, { recursive: true });++ for (const { src, out } of TARGETS) {+ const srcPath = resolve(ROOT, src);+ if (!existsSync(srcPath)) {+ console.warn(`skip — source not found: ${src}`);+ continue;+ }+ await compress(io, srcPath, resolve(OUT_DIR, out));+ }}main().catch((err) => {diff --git a/src/avatar-edit.js b/src/avatar-edit.jsindex e697766e7..98ff06ba7 100644--- a/src/avatar-edit.js+++ b/src/avatar-edit.js@@ -129,6 +129,12 @@ async function init() {$('ae-title').textContent = `Customize · ${avatar.name}`;$('ae-back').href = `/avatars/${encodeURIComponent(avatar.id)}`;+ // Owner is editing → surface the agent-wallet panel (create / manage) inline.+ const actions = $('ae-actions');+ if (actions) {+ if (customElements.get('avatar-actions')) actions.avatar = avatar;+ else actions.setAttribute('avatar-id', avatar.id);+ }// This avatar already has a baked GLB, so it's playable right now — light up// the handoff into /play.$('ae-play').disabled = false;diff --git a/src/avatar-gallery-picker.js b/src/avatar-gallery-picker.jsindex ebb18d112..807cf6fec 100644--- a/src/avatar-gallery-picker.js+++ b/src/avatar-gallery-picker.js@@ -31,6 +31,20 @@ function ensureModelViewer() {document.head.appendChild(s);}+let _aaLoaded = false;+// Load the self-contained <avatar-actions> web component from /public on demand.+// Loading via a runtime <script type=module> (rather than a static import) keeps+// the one component definition shared by both bundled modules and plain HTML+// pages without a build-time public-dir resolution.+function ensureAvatarActions() {+ if (_aaLoaded || customElements.get('avatar-actions')) return;+ _aaLoaded = true;+ const s = document.createElement('script');+ s.type = 'module';+ s.src = '/avatar-actions.js';+ document.head.appendChild(s);+}+function esc(s) {return String(s ?? '').replace(/&/g, '&')@@ -184,6 +198,7 @@ export class AvatarGalleryPicker {<h2 class="agp-preview-name">No avatar selected</h2><p class="agp-preview-sub">Browse and pick an avatar</p><div class="agp-preview-tags"></div>+ <avatar-actions class="agp-actions" style="display:none;margin:10px 0"></avatar-actions>${showModes ? `<div class="agp-modes" role="radiogroup" aria-label="Output mode"><label><input type="radio" name="agp-mode" value="share" checked /><span>Share link</span></label>@@ -208,6 +223,7 @@ export class AvatarGalleryPicker {previewName: shell.querySelector('.agp-preview-name'),previewSub: shell.querySelector('.agp-preview-sub'),previewTags: shell.querySelector('.agp-preview-tags'),+ actions: shell.querySelector('.agp-actions'),payload: shell.querySelector('.agp-payload'),cta: shell.querySelector('.agp-cta'),};@@ -455,6 +471,16 @@ export class AvatarGalleryPicker {`<span class="agp-preview-tag">${esc(t)}</span>`).join('');}+ // Ownership + wallet surface: a previewed avatar you don't own gets+ // "Save to my avatars" (fork); your own gets its agent-wallet panel.+ if (this._els.actions) {+ ensureAvatarActions();+ const el = this._els.actions;+ el.style.display = 'block';+ if (customElements.get('avatar-actions')) el.avatar = a;+ else el.setAttribute('avatar-id', a.id);+ }+// 3D previewthis._els.previewStage.innerHTML = '';if (a.model_url) {diff --git a/src/avatar-page.js b/src/avatar-page.jsindex 26b3999af..643513668 100644--- a/src/avatar-page.js+++ b/src/avatar-page.js@@ -291,6 +291,7 @@ function renderShell(glbUrl) {View in AR</a></div>+ <avatar-actions id="av-actions" avatar-id="${esc(avatar.id || avatarId)}" style="margin-top:14px;display:block"></avatar-actions>${avatar.owner_id ? `<div class="av-owner-row" id="av-owner-row"><a class="av-owner-btn" href="/avatars/${encodeURIComponent(avatar.id || avatarId)}/edit">@@ -412,6 +413,13 @@ function renderShell(glbUrl) {$('av-use')?.addEventListener('click', startAgentWithAvatar);$('av-talk')?.addEventListener('click', () => enterTalkMode());$('av-download')?.addEventListener('click', openDownloadMenu);++ // Per-avatar ownership + wallet surface: owner gets the agent-wallet panel+ // (create / manage), everyone else gets "Save to my avatars" (fork). Seed it+ // with the already-loaded avatar to skip a re-fetch — falls back to the+ // avatar-id attribute (set in the template) if the element hasn't upgraded yet.+ const actions = $('av-actions');+ if (actions && customElements.get('avatar-actions')) actions.avatar = avatar;}/**diff --git a/src/club-entrance.js b/src/club-entrance.jsindex 328ca2399..52256cbfe 100644--- a/src/club-entrance.js+++ b/src/club-entrance.js@@ -1,17 +1,25 @@-// /club entrance — a real 3D scene behind the cover-charge door.+// /club entrance — a first-person spatial journey into the club.//-// Our avatar stands in the Space Smugglers club house while you wait in line.-// It renders into its own canvas (#club-door-canvas) layered under the door-// card, so the door (src/club-gate.js) is a panel floating over a live scene-// rather than a flat screen. When the bouncer admits you (`club:admitted`),-// the camera dollies in toward the avatar as the rope drops, then the scene-// disposes and the pole stage (src/club.js) takes over.+// You don't drop straight onto the pole floor. You arrive in the alley+// outside, pay the cover at the door, then walk through the Space Smugglers+// club house before the room with the poles opens up. Three beats, rendered+// into one full-screen canvas (#club-door-canvas) layered under the cover+// door card and above the pole stage (src/club.js, which boots in parallel)://-// Kept deliberately light: one model (~1.6 MB Meshopt+WebP clubhouse, built by-// scripts/build-club-entrance-venue.mjs), the shared avatar GLB (already-// cached for the stage), a few accent lights, no postprocessing. If a wallet-// already holds a pass for the night the door is gone on load, so we skip the-// scene entirely.+// 1. ALLEY — you stand in alleyway.glb. The cover door (src/club-gate.js)+// floats over the scene as the line outside.+// 2. WALK-THROUGH — on `club:admitted` the canvas dips, swaps to the club+// house interior, and the camera walks forward through it+// while the walk-in anthem plays (wired in src/club.js).+// 3. ARRIVE — the canvas fades out and disposes, revealing the pole+// stage that has been warming behind it the whole time.+//+// Deliberately light: two ~1.6 MB Meshopt+WebP environments (built by+// scripts/build-club-entrance-venue.mjs), a moody light rig, no avatar rig+// and no postprocessing. The club house is prefetched during the queue so the+// walk-through never stalls. If a wallet already holds a pass for the night,+// the door is gone on load and we skip the journey entirely. Any scene failure+// degrades silently — the cover door and the room behind it still work.import {AmbientLight,@@ -29,26 +37,42 @@ import {ACESFilmicToneMapping,} from 'three';import { gltfLoader } from './loaders/gltf.js';-import { AnimationManager } from './animation-manager.js';import { log } from './shared/log.js';+const ALLEYWAY_URL = '/club/venue/alleyway.glb';const CLUBHOUSE_URL = '/club/venue/space-smugglers-clubhouse.glb';-const AVATAR_URL = '/avatars/default.glb';-const MANIFEST_URL = '/animations/manifest.json';const PASS_KEY = 'club:pass:v1';-const IDLE_CLIPS = new Set(['idle', 'walk']);++const EYE = 1.62; // camera eye height, metres+const ROOM_HEIGHT = 7.0; // environments are normalised to this Y so eye height reads human++// Walk-through timeline (seconds).+const LEAVE = 0.7; // fade the alley out as you step through the door+const ENTER = 0.7; // fade the club house interior in+const WALK = 4.2; // camera dolly forward through the interior+const ARRIVE = 0.9; // fade out, revealing the pole stageconst canvas = document.getElementById('club-door-canvas');const door = document.getElementById('club-door');+// The bouncer admits via a one-shot event. Capture it at module scope so an+// admit that fires before the scene finishes its first load is never missed.+let admitted = false;+let onAdmit = null;+window.addEventListener('club:admitted', () => {+ admitted = true;+ if (onAdmit) onAdmit();+}, { once: true });+// No canvas, or the wallet already paid cover tonight (door auto-dismissed) —-// nothing to render.+// nothing to render. Drop the canvas so it never sits dead over the stage.if (canvas && door && !hasValidPass()) {start(canvas).catch((err) => {- // A scene failure must never block entry — the cover door still works- // on its own. Just leave the canvas dark.log.warn('[club-entrance] scene failed', err);+ try { canvas.remove(); } catch {}});+} else {+ canvas?.remove();}function hasValidPass() {@@ -68,103 +92,101 @@ async function start(canvasEl) {renderer.setSize(window.innerWidth, window.innerHeight, false);renderer.outputColorSpace = SRGBColorSpace;renderer.toneMapping = ACESFilmicToneMapping;- renderer.toneMappingExposure = 1.15;+ renderer.toneMappingExposure = 1.12;const scene = new Scene();- scene.background = null; // canvas alpha — the CSS gradient shows through edges- scene.fog = new Fog(0x05030a, 8, 26);+ scene.background = null; // canvas alpha — the page's dark bg shows at the edges+ scene.fog = new Fog(0x05030a, 7, 30);- const camera = new PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.05, 100);- const camStart = new Vector3(1.7, 1.65, 4.0);- const camLook = new Vector3(0, 1.0, 0);- camera.position.copy(camStart);- camera.lookAt(camLook);+ const camera = new PerspectiveCamera(52, window.innerWidth / window.innerHeight, 0.05, 200);- // ── Lighting — moody club palette, keyed on the avatar ──────────────────- scene.add(new AmbientLight(0x241433, 0.7));+ // ── Light rig — moody, works for both the alley and the interior ─────────+ scene.add(new AmbientLight(0x241433, 0.65));const hemi = new HemisphereLight(0xff6abf, 0x0a0512, 0.4);- hemi.position.set(0, 6, 0);+ hemi.position.set(0, ROOM_HEIGHT, 0);scene.add(hemi);-- // Warm key spot from the doorway side, raking across the avatar.- const key = new SpotLight(0xffd6a0, 18, 16, Math.PI / 6, 0.5, 1.4);- key.position.set(2.4, 4.2, 3.2);- key.target.position.set(0, 1.0, 0);- scene.add(key, key.target);-- // Neon rim accents — pink behind, cyan side — the club signature.- const pink = new PointLight(0xff3bd6, 6, 14, 1.5);- pink.position.set(-2.2, 2.4, -2.0);+ // Neon accents — the club signature.+ const pink = new PointLight(0xff3bd6, 7, 22, 1.4);+ pink.position.set(-3, 3.2, -3);scene.add(pink);- const cyan = new PointLight(0x4ad6ff, 4, 12, 1.6);- cyan.position.set(2.6, 1.6, -1.2);+ const cyan = new PointLight(0x4ad6ff, 5, 20, 1.5);+ cyan.position.set(3, 2.4, 2);scene.add(cyan);+ // A soft forward "lantern" parented to the camera so whatever you walk+ // toward is always lit — reads like carrying your gaze through the dark.+ const lantern = new SpotLight(0xffe6c2, 9, 22, Math.PI / 5, 0.6, 1.2);+ lantern.position.set(0, 0.2, 0.4);+ lantern.target.position.set(0, 0, -6);+ camera.add(lantern, lantern.target);+ scene.add(camera);const loader = gltfLoader(renderer);- // Load the clubhouse + avatar + animation manifest together.- const [houseGltf, avatarGltf, manifest] = await Promise.all([- loader.loadAsync(CLUBHOUSE_URL),- loader.loadAsync(AVATAR_URL),- fetch(MANIFEST_URL, { cache: 'force-cache' }).then((r) => (r.ok ? r.json() : [])).catch(() => []),- ]);-- // ── Clubhouse: normalize the authored export to a room-sized backdrop and- // drop it to the floor, pushed back so the avatar reads clearly in front.- // normalizeToHeight scales the largest dimension, so the source units are- // irrelevant. ─────────────────────────────────────────────────────────────- const house = houseGltf.scene;- normalizeToHeight(house, 8.5);- const houseBox = new Box3().setFromObject(house);- house.position.y -= houseBox.min.y; // feet of the room on the floor- house.position.z -= 2.0; // set the avatar forward of the interior- house.traverse((n) => {- if (n.isMesh && n.material && 'envMapIntensity' in n.material) n.material.envMapIntensity = 0.8;- });- scene.add(house);-- // ── Avatar: our default, standing front-and-center, idling ──────────────- const avatar = avatarGltf.scene;- const aBox = new Box3().setFromObject(avatar);- avatar.position.y -= aBox.min.y;- const rig = new Group();- rig.add(avatar);- rig.rotation.y = Math.PI * 0.04; // a hair off-axis so it's not flat-on- scene.add(rig);-- const anim = new AnimationManager();- anim.attach(avatar);- anim.setAnimationDefs((Array.isArray(manifest) ? manifest : []).filter((d) => IDLE_CLIPS.has(d.name)));- anim.play('idle').catch(() => {});-- // ── Render loop ─────────────────────────────────────────────────────────+ // Land in the alley first; prefetch the interior so the walk-through after+ // the cover settles never has to wait on a download.+ const alleyGltf = await loader.loadAsync(ALLEYWAY_URL);+ const clubhousePromise = loader.loadAsync(CLUBHOUSE_URL);++ let env = mountEnvironment(scene, alleyGltf.scene);+ let path = walkPath(env.box);+ camera.position.copy(path.start);+ camera.lookAt(path.look);++ // ── State machine ────────────────────────────────────────────────────────+ // Segments are driven by wall-clock elapsed time, not accumulated frame+ // deltas, so the journey always runs its authored duration even when the+ // GPU is slow — low fps just means a choppier walk, never slow-motion.+ let phase = 'alley'; // alley → leaving → swapping → entering → walking → arriving → done+ let phaseStart = performance.now();let raf = 0;- let last = performance.now();- let t = 0;- let admitted = false;- let admitT = 0;++ function setPhase(p) {+ phase = p;+ phaseStart = performance.now();+ }function frame(now) {- const dt = Math.min((now - last) / 1000, 0.05);- last = now;- t += dt;- anim.update(dt);-- if (!admitted) {- // Slow idle orbit drift around the avatar.- const a = Math.sin(t * 0.18) * 0.18;- camera.position.x = Math.sin(a) * 4.0 + Math.cos(a) * 1.7;- camera.position.z = Math.cos(a) * 4.0;- camera.position.y = 1.62 + Math.sin(t * 0.5) * 0.04;- camera.lookAt(camLook);- } else {- // Dolly in toward the avatar / doorway, then fade the canvas out.- admitT = Math.min(1, admitT + dt / 1.2);- const e = easeInOut(admitT);- camera.position.lerpVectors(camStart, new Vector3(0.2, 1.2, 1.5), e);- camera.lookAt(0, 1.15, 0);- canvasEl.style.opacity = String(1 - e);- if (admitT >= 1) return dispose();+ const t = now / 1000;+ const elapsed = (now - phaseStart) / 1000;++ switch (phase) {+ case 'alley':+ // Stand in the alley with a slow handheld sway.+ idleSway(camera, path, t);+ break;+ case 'leaving': {+ const k = Math.min(1, elapsed / LEAVE);+ idleSway(camera, path, t);+ canvasEl.style.opacity = String(1 - k);+ if (k >= 1) doSwap();+ break;+ }+ case 'swapping':+ // Held at black while the interior finishes loading.+ break;+ case 'entering': {+ const k = Math.min(1, elapsed / ENTER);+ camera.position.copy(path.start);+ camera.lookAt(path.look);+ canvasEl.style.opacity = String(k);+ if (k >= 1) setPhase('walking');+ break;+ }+ case 'walking': {+ const k = Math.min(1, elapsed / WALK);+ camera.position.lerpVectors(path.start, path.end, easeInOut(k));+ camera.position.y = EYE + Math.sin(t * 5.2) * 0.025; // a little life in the step+ camera.lookAt(path.look);+ if (k >= 1) setPhase('arriving');+ break;+ }+ case 'arriving': {+ const k = Math.min(1, elapsed / ARRIVE);+ camera.lookAt(path.look);+ canvasEl.style.opacity = String(1 - k);+ if (k >= 1) return dispose();+ break;+ }}renderer.render(scene, camera);@@ -172,6 +194,35 @@ async function start(canvasEl) {}raf = requestAnimationFrame(frame);+ function beginWalk() {+ if (phase !== 'alley') return;+ setPhase('leaving');+ }+ // If the admit already fired during load, start immediately; otherwise the+ // module-scope listener calls us when it does.+ onAdmit = beginWalk;+ if (admitted) beginWalk();++ async function doSwap() {+ setPhase('swapping');+ canvasEl.style.opacity = '0';+ let clubScene = null;+ try {+ clubScene = (await clubhousePromise).scene;+ } catch (err) {+ // Interior failed — skip the walk-through and reveal the stage.+ log.warn('[club-entrance] club house load failed', err);+ return dispose();+ }+ disposeObject(env.root);+ scene.remove(env.root);+ env = mountEnvironment(scene, clubScene);+ path = walkPath(env.box);+ camera.position.copy(path.start);+ camera.lookAt(path.look);+ setPhase('entering');+ }+function onResize() {renderer.setSize(window.innerWidth, window.innerHeight, false);camera.aspect = window.innerWidth / window.innerHeight;@@ -179,41 +230,70 @@ async function start(canvasEl) {}window.addEventListener('resize', onResize);- // Bouncer admitted the wallet — start the push-in.- window.addEventListener('club:admitted', () => { admitted = true; admitT = 0; }, { once: true });-function dispose() {cancelAnimationFrame(raf);window.removeEventListener('resize', onResize);- try { anim.dispose?.(); } catch {}- scene.traverse((n) => {- if (n.isMesh) {- n.geometry?.dispose?.();- const mats = Array.isArray(n.material) ? n.material : [n.material];- mats.forEach((m) => {- if (!m) return;- for (const k in m) { if (m[k]?.isTexture) m[k].dispose(); }- m.dispose?.();- });- }- });+ onAdmit = null;+ disposeObject(scene);renderer.dispose();- canvasEl.remove();+ try { canvasEl.remove(); } catch {}}}-// Scale an object uniformly so its largest dimension equals `target` units.-function normalizeToHeight(obj, target) {- const box = new Box3().setFromObject(obj);+// Normalise an environment to a human-scaled room (height = ROOM_HEIGHT),+// recentre it on the floor at the origin, add it, and return its world box.+function mountEnvironment(scene, root) {+ const box = new Box3().setFromObject(root);const size = box.getSize(new Vector3());- const largest = Math.max(size.x, size.y, size.z) || 1;- const s = target / largest;- obj.scale.setScalar(s);- // Recenter on X/Z around the origin after scaling.- const box2 = new Box3().setFromObject(obj);+ const s = ROOM_HEIGHT / (size.y || 1);+ root.scale.setScalar(s);+ const box2 = new Box3().setFromObject(root);const center = box2.getCenter(new Vector3());- obj.position.x -= center.x;- obj.position.z -= center.z;+ root.position.x -= center.x;+ root.position.z -= center.z;+ root.position.y -= box2.min.y; // floor at y = 0+ const group = new Group();+ group.add(root);+ scene.add(group);+ return { root: group, box: new Box3().setFromObject(group) };+}++// Build a forward dolly along the environment's longer horizontal axis — the+// "depth" you walk down — independent of the model's authored orientation.+function walkPath(box) {+ const size = box.getSize(new Vector3());+ const alongX = size.x > size.z;+ const span = (alongX ? size.x : size.z) / 2;+ const dir = alongX ? new Vector3(1, 0, 0) : new Vector3(0, 0, 1);+ // Start just inside the near end, walk most of the way toward the far end.+ const start = dir.clone().multiplyScalar(span * 0.85).setY(EYE);+ const end = dir.clone().multiplyScalar(-span * 0.35).setY(EYE);+ // Always look further down the axis you're walking.+ const look = dir.clone().multiplyScalar(-span).setY(EYE * 0.92);+ return { start, end, look, dir };+}++// Subtle standing sway: a slow lateral/vertical drift while you wait.+function idleSway(camera, path, t) {+ const lateral = new Vector3(-path.dir.z, 0, path.dir.x); // perpendicular, on the floor plane+ camera.position.copy(path.start)+ .addScaledVector(lateral, Math.sin(t * 0.35) * 0.18)+ .setY(EYE + Math.sin(t * 0.5) * 0.03);+ camera.lookAt(path.look);+}++function disposeObject(obj) {+ obj.traverse((n) => {+ if (n.isMesh) {+ n.geometry?.dispose?.();+ const mats = Array.isArray(n.material) ? n.material : [n.material];+ mats.forEach((m) => {+ if (!m) return;+ for (const k in m) { if (m[k]?.isTexture) m[k].dispose(); }+ m.dispose?.();+ });+ }+ });}function easeInOut(x) {diff --git a/src/club.js b/src/club.jsindex ee7b88631..753bf0c16 100644--- a/src/club.js+++ b/src/club.js@@ -1012,6 +1012,30 @@ window.addEventListener('club:performance-end', () => {audio.fadeOutStyle().catch((err) => log.warn('[club] fadeOutStyle', err));});+// ── Walk-in anthem ────────────────────────────────────────────────────────+// The moment the bouncer admits the wallet (src/club-gate.js → club:admitted,+// in sync with the walk-through in src/club-entrance.js), play the entrance+// track once. The door's "Pay cover" click is the user gesture that unlocks+// the AudioContext, so prime it there — admit fires a beat later, after the+// autoplay policy would otherwise block the anthem.+{+ const doorPay = document.getElementById('club-door-pay');+ doorPay?.addEventListener('click', () => {+ audio.ensureContext().catch(() => {});+ }, { once: true });++ const armOnGesture = () => {+ const retry = () => audio.playEntrance().catch((err) => log.warn('[club] entrance audio', err));+ window.addEventListener('pointerdown', retry, { once: true });+ window.addEventListener('keydown', retry, { once: true });+ };+ window.addEventListener('club:admitted', () => {+ // On a cached re-entry the door opens with no gesture, so the context is+ // still locked — fall back to playing on the next interaction.+ audio.playEntrance().catch(armOnGesture);+ }, { once: true });+}+// ── Tip flow (x402 drop-in) ──────────────────────────────────────────────async function tipDancer({ dancer, dance, button }) {if (!window.X402?.pay) {