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
feat: implement zen mode to hide UI overlays for a clean world view; add screen texture utility functions for consistent canvas rendering
nirholas1fcee34ab73d
diff --git a/src/game/agent-desk.js b/src/game/agent-desk.jsindex 946938f8f..b2712fc85 100644--- a/src/game/agent-desk.js+++ b/src/game/agent-desk.js@@ -31,11 +31,12 @@// desk.dispose();import {- Group, Mesh, MeshBasicMaterial, MeshStandardMaterial,+ Group, Mesh, MeshStandardMaterial,PlaneGeometry, BoxGeometry, CylinderGeometry,- CanvasTexture, SRGBColorSpace, DoubleSide, Vector3,+ Vector3,} from 'three';import { createAgentScreenClient } from '../shared/agent-screen-client.js';+import { makeScreenTexture, screenMaterial } from './screen-texture.js';const NEAR_DIST = 8; // units — player proximity to activateconst REDRAW_MS = 100; // ~10fps canvas repaint@@ -271,11 +272,9 @@ export function createAgentDesk(scene, agent, opts = {}) {const canvas = document.createElement('canvas');canvas.width = CW; canvas.height = CH;const ctx = canvas.getContext('2d');- const tex = new CanvasTexture(canvas);- tex.colorSpace = SRGBColorSpace;- tex.anisotropy = 8;+ const tex = makeScreenTexture(canvas);- const screenMat = new MeshBasicMaterial({ map: tex, toneMapped: false });+ const screenMat = screenMaterial(tex);const screen = new Mesh(new PlaneGeometry(MON_W, MON_H), screenMat);screen.position.set(0, monCY, -0.35 + 0.07);screen.userData.agentDesk = true;diff --git a/src/game/chart-screen.js b/src/game/chart-screen.jsindex 44b111c11..98bb9a802 100644--- a/src/game/chart-screen.js+++ b/src/game/chart-screen.js@@ -14,10 +14,11 @@// error states are all painted on the screen itself.import {- Group, Mesh, MeshBasicMaterial, MeshStandardMaterial,+ Group, Mesh, MeshStandardMaterial,PlaneGeometry, CylinderGeometry, BoxGeometry,- CanvasTexture, SRGBColorSpace, DoubleSide,+ DoubleSide,} from 'three';+import { makeScreenCanvas, makeScreenTexture, screenMaterial } from './screen-texture.js';// An EVM 0x-address identifies a Robinhood Chain coin (NOXA/Odyssey), routed// to the robinhood-feed-backed endpoint; everything else is a pump.fun Solana@@ -31,7 +32,8 @@ const TRADES_URL = (mint, limit = 100) => {const POLL_MS = 5000;const REDRAW_MS = 100; // ~10fps: enough for a smooth ticker, cheap on the GPUconst MAX_POINTS = 220; // rolling price history kept across the session-const CW = 1280, CH = 720; // 16:9 canvas backing the screen+const CW = 1280, CH = 720; // 16:9 logical layout grid for the draw code+const SS = 1.5; // supersample: 1920x1080 backing store, crisp text// Restrained palette — the /play client is monochrome, but a trading terminal// earns a single directional accent (up green / down red) the way a real screen@@ -147,15 +149,11 @@ export function createChartScreen(scene, coin, opts = {}) {// The live face: an HTML canvas → CanvasTexture → unlit plane (so it glows// like a screen rather than catching world light).- const canvas = document.createElement('canvas');- canvas.width = CW; canvas.height = CH;- const ctx = canvas.getContext('2d');- const tex = new CanvasTexture(canvas);- tex.colorSpace = SRGBColorSpace;- tex.anisotropy = 4;+ const { canvas, ctx } = makeScreenCanvas(CW, CH, SS);+ const tex = makeScreenTexture(canvas);const panel = new Mesh(new PlaneGeometry(width, height),- new MeshBasicMaterial({ map: tex, side: DoubleSide, toneMapped: false }),+ screenMaterial(tex, { side: DoubleSide }),);panel.position.set(0, cy, 0.01);panel.userData.chartScreen = true; // raycast tagdiff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.jsindex 611f824cf..319be9aeb 100644--- a/src/game/coincommunities-ui.js+++ b/src/game/coincommunities-ui.js@@ -1320,6 +1320,30 @@ export class CommunityUI {]);onPowerSaverChange((on) => this.powerBtn.setAttribute('aria-pressed', on ? 'true' : 'false'));+ // Zen mode — hide every overlay so the world renders clean. Same+ // body.is-zen contract as /walk; Z is the hotkey (wired by the host) and+ // the floating exit pill below is the only control left on screen.+ this.zenBtn = el('button', {+ class: 'cc-zen-btn', type: 'button', 'aria-pressed': 'false',+ 'aria-label': 'Zen mode', title: 'Zen mode — hide every panel, just the world (Z)',+ onclick: () => this.h.onZen?.(),+ }, [+ el('span', { class: 'cc-zen-ico', 'aria-hidden': 'true', text: '🧘' }),+ el('span', { class: 'cc-zen-label', text: 'Zen' }),+ ]);+ this.zenExit = el('button', {+ id: 'cc-zen-exit', type: 'button',+ 'aria-label': 'Show controls', title: 'Show controls (Z)',+ onclick: () => this.h.onZen?.(),+ }, [+ el('span', { 'aria-hidden': 'true', html:+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" focusable="false">'+ + '<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12z"/><circle cx="12" cy="12" r="3"/>'+ + '</svg>' }),+ document.createTextNode('Show UI'),+ ]);+ document.body.appendChild(this.zenExit);+// Dance floor button — hidden until the player steps onto the pad.this.danceBtnLabel = el('span', { class: 'cc-dance-label', text: 'Dance' });this.danceBtn = el('button', {@@ -1332,13 +1356,13 @@ export class CommunityUI {]);const hint = el('div', { id: 'cc-hint', html:- '<kbd>W A S D</kbd> / drag-joystick to move · <kbd>drag</kbd> to look · scroll zoom · <kbd>Enter</kbd> chat · <kbd>Q</kbd> emotes · <kbd>I</kbd> inspect' });+ '<kbd>W A S D</kbd> / drag-joystick to move · <kbd>drag</kbd> to look · scroll zoom · <kbd>Enter</kbd> chat · <kbd>Q</kbd> emotes · <kbd>I</kbd> inspect · <kbd>Z</kbd> zen' });this.joystick = el('div', { id: 'cc-joystick' });this._buildTagHud();this._buildKingHud();- this.hud = el('div', { id: 'cc-hud', hidden: true }, [banner, leave, this.statusPill, this.voiceBtn, this.powerBtn, this.danceBtn, chat, this.emoteTray, this.reactionBar, hint, this.joystick]);+ this.hud = el('div', { id: 'cc-hud', hidden: true }, [banner, leave, this.statusPill, this.voiceBtn, this.powerBtn, this.zenBtn, this.danceBtn, chat, this.emoteTray, this.reactionBar, hint, this.joystick]);document.body.appendChild(this.hud);}@@ -2003,6 +2027,11 @@ export class CommunityUI {if (!on) this.setDancing(false);}+ // Mirror the zen state on both toggles (the HUD button and the exit pill).+ setZen(on) {+ this.zenBtn?.setAttribute('aria-pressed', on ? 'true' : 'false');+ }+// Toggle the button's armed state (lit = will dance on next beat).setDancing(on) {if (!this.danceBtn) return;diff --git a/src/game/coincommunities.css b/src/game/coincommunities.cssindex d61b3d9b6..39420cceb 100644--- a/src/game/coincommunities.css+++ b/src/game/coincommunities.css@@ -2923,3 +2923,75 @@ select.npc-svc-input { cursor: pointer; appearance: none; -webkit-appearance: no.cc-king-timer.cc-king-low { animation: none; }}/* ── end King of the Totem ──────────────────────────────────────────────────── */++/* ── Zen mode (hide all UI) ──────────────────────────────────────────────────+ Z, the HUD button, or a ?ui=hidden link strips every overlay — banner, chat,+ world HUD, hotbar, prompts, name tags — so the world renders clean for+ screenshots and ambient play. Movement affordances survive (the joystick and+ the driving pedal cluster), and panels the player opens on purpose (build+ palettes, shops, boards, the emote wheel) still show. Same body.is-zen+ contract as /walk and the marketplace gallery. */+body.is-zen #cc-hud > :not(#cc-joystick),+body.is-zen .cc-nav-toggle,+body.is-zen .cc-nav-drawer,+body.is-zen #cc-tag-hud,+body.is-zen #cc-tag-alert,+body.is-zen #cc-king-hud,+body.is-zen #cc-king-banner,+body.is-zen #cc-toast,+body.is-zen .cc-label,+body.is-zen .cc-bubble,+body.is-zen #wh-hud,+body.is-zen .wh-minimap,+body.is-zen .wh-feel-money,+body.is-zen .wh-feel-flourish,+body.is-zen #ps-hud,+body.is-zen .ps-action,+body.is-zen .ps-xp-float,+body.is-zen .ps-levelup,+body.is-zen .veh-prompt,+body.is-zen .combat-prompt,+body.is-zen .combat-attack-btn,+body.is-zen .combat-mob-label,+body.is-zen .combat-zone-label,+body.is-zen .tik-prompt,+body.is-zen .ac-prompt {+ display: none !important;+}++/* zen toggle — under the power saver, same visual family */+.cc-zen-btn {+ position: fixed; top: 184px; right: 14px; z-index: 22;+ display: inline-flex; align-items: center; gap: 8px;+ background: var(--cc-panel); border: 1px solid var(--cc-edge); border-radius: var(--cc-radius);+ padding: 8px 13px 8px 11px; color: var(--cc-dim); cursor: pointer;+ font-weight: 600; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;+ box-shadow: var(--cc-shadow); backdrop-filter: blur(10px);+ transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;+}+.cc-zen-btn:hover { border-color: var(--cc-edge-hi); color: var(--cc-text); background: rgba(255, 255, 255, 0.05); }+.cc-zen-btn:focus-visible { outline: none; border-color: var(--cc-edge-hi); box-shadow: 0 0 0 1px var(--cc-edge-hi); }+.cc-zen-ico { line-height: 1; filter: grayscale(1); }+.cc-zen-label { line-height: 1; }++/* zen exit pill — the one control left on screen, faded in a frame after entry */+#cc-zen-exit {+ position: fixed; z-index: 30;+ top: calc(env(safe-area-inset-top, 0px) + 14px); right: 14px;+ display: none; align-items: center; gap: 7px;+ appearance: none; border: 1px solid var(--cc-edge);+ background: var(--cc-panel); color: var(--cc-dim);+ font: inherit; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;+ padding: 8px 13px; border-radius: 999px; cursor: pointer;+ backdrop-filter: blur(10px); box-shadow: var(--cc-shadow);+ opacity: 0;+ transition: opacity 0.3s ease, color 0.12s ease, border-color 0.12s ease, background 0.12s ease;+}+body.is-zen #cc-zen-exit { display: inline-flex; }+body.is-zen.zen-revealed #cc-zen-exit { opacity: 0.85; }+#cc-zen-exit:hover { color: var(--cc-text); border-color: var(--cc-edge-hi); background: rgba(255, 255, 255, 0.05); opacity: 1; }+#cc-zen-exit:focus-visible { outline: none; border-color: var(--cc-edge-hi); box-shadow: 0 0 0 1px var(--cc-edge-hi); opacity: 1; }+#cc-zen-exit svg { width: 14px; height: 14px; display: block; }+@media (prefers-reduced-motion: reduce) {+ #cc-zen-exit { transition: none; }+}diff --git a/src/game/coincommunities.js b/src/game/coincommunities.jsindex 3377c2054..439019a15 100644--- a/src/game/coincommunities.js+++ b/src/game/coincommunities.js@@ -15,7 +15,7 @@ import {ACESFilmicToneMapping,Mesh, MeshStandardMaterial, MeshBasicMaterial, CircleGeometry, RingGeometry,CylinderGeometry, PlaneGeometry,- CanvasTexture, TextureLoader, DoubleSide,+ TextureLoader, DoubleSide,PointLight,Raycaster, Vector2, WebGLRenderTarget,} from 'three';@@ -36,6 +36,7 @@ import { createDayNightCycle } from './day-night.js';import { worldClock } from '../shared/world-clock.js';import { createCameraModeController, CAMERA_MODE_LABELS, CAMERA_MODE_FOV } from './camera-modes.js';import { createChartScreen } from './chart-screen.js';+import { makeScreenCanvas, makeScreenTexture, screenMaterial, screenAnisotropy } from './screen-texture.js';import { mountOracleRibbon } from './oracle-ribbon.js';import { MarketReactor } from './market-reactor.js';import {@@ -380,6 +381,7 @@ export class CoinCommunities {constructor(canvas) {this.canvas = canvas;this.phase = 'lobby';+ this._zen = false;this.remotes = new Map();this.keys = new Set();this.input = new Vector3(); // joystick/keys movement intent (x,z in [-1,1])@@ -506,6 +508,8 @@ export class CoinCommunities {onOpenFeatured: () => this._openFeatured(),onPublishBuild: (meta) => this._publishBuild(meta),onDance: () => this._triggerDance(),+ // Zen mode — strip every overlay for a clean view of the world.+ onZen: () => this._setZen(!this._zen),onFeaturedClosed: () => { this._featuredOpen = false; },});@@ -803,16 +807,15 @@ export class CoinCommunities {}_textBanner(name, sym) {- const c = document.createElement('canvas'); c.width = 512; c.height = 128;- const x = c.getContext('2d');+ const { canvas, ctx: x } = makeScreenCanvas(512, 128, 2);x.fillStyle = 'rgba(11,16,32,0.0)'; x.fillRect(0, 0, 512, 128);x.textAlign = 'center'; x.fillStyle = '#fff';x.font = '800 50px Inter, system-ui, sans-serif';x.fillText(name.slice(0, 18).toUpperCase(), 256, 56);x.font = 'bold 32px Inter, system-ui, sans-serif'; x.fillStyle = '#5fc8ff';x.fillText(sym, 256, 100);- const tex = new CanvasTexture(c); tex.colorSpace = SRGBColorSpace;- const m = new Mesh(new PlaneGeometry(6, 1.5), new MeshBasicMaterial({ map: tex, transparent: true, side: DoubleSide }));+ const tex = makeScreenTexture(canvas);+ const m = new Mesh(new PlaneGeometry(6, 1.5), screenMaterial(tex, { transparent: true, side: DoubleSide }));m.position.y = 10.2;return m;}@@ -833,10 +836,11 @@ export class CoinCommunities {// The lit panel: a canvas texture (name / market cap / live count) drawn by// _drawScreen. Unlit material so it glows like an LED wall at any distance.- const canvas = document.createElement('canvas');- canvas.width = 1600; canvas.height = 900;- const tex = new CanvasTexture(canvas); tex.colorSpace = SRGBColorSpace;- const panel = new Mesh(new PlaneGeometry(W, H), new MeshBasicMaterial({ map: tex }));+ // Backed at 1.5x the 1600x900 layout grid and exempt from fog/tone mapping+ // (screen-texture.js) so the biggest screen in the town reads crisp, not hazed.+ const { canvas } = makeScreenCanvas(1600, 900, 1.5);+ const tex = makeScreenTexture(canvas);+ const panel = new Mesh(new PlaneGeometry(W, H), screenMaterial(tex));panel.position.set(0, 11, 0); g.add(panel);this._screenCanvas = canvas; this._screenTex = tex;@@ -846,7 +850,8 @@ export class CoinCommunities {if (coin.image) {new TextureLoader().load(coin.image, (imgTex) => {imgTex.colorSpace = SRGBColorSpace;- const art = new Mesh(new PlaneGeometry(8.4, 8.4), new MeshBasicMaterial({ map: imgTex }));+ imgTex.anisotropy = screenAnisotropy();+ const art = new Mesh(new PlaneGeometry(8.4, 8.4), screenMaterial(imgTex));art.position.set(-6.7, 11, 0.04); g.add(art);this._screenArt = art;}, undefined, () => { /* image blocked — panel still shows text */ });@@ -1314,6 +1319,7 @@ export class CoinCommunities {this._initVoice();this.phase = 'world';this._initJoystick();+ this._restoreZen();this._onboardBuild();// W02: drivable vehicles — the parked fleet the server seeds every world// with (multiplayer/src/vehicles.js VEHICLE_SPAWNS, mirrored from this@@ -1639,6 +1645,8 @@ export class CoinCommunities {// Invalidate any in-flight enter() so a connect/avatar continuation that// resolves after this teardown bails instead of rebuilding the world.this._enterEpoch = (this._enterEpoch || 0) + 1;+ // The lobby always shows its UI; zen re-applies on the next world entry.+ this._suspendZen();// Tear voice down before the socket so our final "left voice" flag still// sends, and peers' connections close cleanly.clearTimeout(this._passRefreshTimer);@@ -2512,6 +2520,46 @@ export class CoinCommunities {}}+ // ---------------------------------------------------------------- zen mode+ // Hides every overlay (HUD, chat, prompts, name tags) so the world renders+ // clean — the same body.is-zen contract /walk uses. Movement affordances+ // stay (joystick, driving pedals), and panels the player opens on purpose+ // (build palettes, shops, the emote wheel) still show. The preference+ // persists across sessions, and a shared ?ui=hidden link starts in zen.+ _setZen(on) {+ this._zen = !!on;+ document.body.classList.toggle('is-zen', this._zen);+ if (this._zen) {+ // Defer the reveal class one frame so the exit pill fades in.+ requestAnimationFrame(() => document.body.classList.add('zen-revealed'));+ // Close the drawers/wheels so they don't linger over the clean scene.+ if (this._friendsOpen) this._closeFriends();+ this.ui.closeEmoteWheel(false);+ } else {+ document.body.classList.remove('zen-revealed');+ }+ this.ui.setZen(this._zen);+ try { localStorage.setItem('play:zen', this._zen ? '1' : '0'); } catch {}+ }++ // Restore the zen preference on world entry: URL param wins (?ui=hidden for+ // shared links, ?ui=on to force chrome back), then the stored choice.+ _restoreZen() {+ let param = null;+ try { param = new URLSearchParams(location.search).get('ui'); } catch {}+ if (param === 'hidden' || param === 'off') { this._setZen(true); return; }+ if (param === 'on' || param === 'shown') return;+ try { if (localStorage.getItem('play:zen') === '1') this._setZen(true); } catch {}+ }++ // Drop the zen body classes without touching the stored preference — the+ // lobby always shows its UI; _restoreZen() re-applies zen next world entry.+ _suspendZen() {+ this._zen = false;+ document.body.classList.remove('is-zen', 'zen-revealed');+ this.ui.setZen(false);+ }+_sayLocal(text) {if (this._localBubble) this._localBubble.remove();this._localBubble = document.createElement('div');@@ -2604,6 +2652,13 @@ export class CoinCommunities {this._toggleFriends();return;}+ // Z toggles zen mode — every overlay hidden, just the world. Plain Z+ // only: Ctrl/Cmd+Z stays the build-mode undo above.+ if (k === 'z' && !this.buildHud.active && !e.ctrlKey && !e.metaKey && !e.repeat) {+ e.preventDefault();+ this._setZen(!this._zen);+ return;+ }// C cycles the camera: follow → cinematic → first person → top down.if (k === 'c' && !this.buildHud.active && !e.repeat) {e.preventDefault();diff --git a/src/game/intel-kiosk.js b/src/game/intel-kiosk.jsindex 311a4b7be..5e60dbb3d 100644--- a/src/game/intel-kiosk.js+++ b/src/game/intel-kiosk.js@@ -19,15 +19,17 @@import {Group, Mesh, MeshBasicMaterial, MeshStandardMaterial, RingGeometry,- PlaneGeometry, BoxGeometry, CylinderGeometry, CanvasTexture, SRGBColorSpace,+ PlaneGeometry, BoxGeometry, CylinderGeometry,DoubleSide, Vector3,} from 'three';+import { makeScreenCanvas, makeScreenTexture, screenMaterial } from './screen-texture.js';import { isHomeTown } from './home-town.js';import { log } from '../shared/log.js';import { ensureX402 } from '../shared/x402-loader.js';const KIOSK_POS = new Vector3(-8, 0, -7);const INTERACT_RANGE = 5.5;+const SCREEN_W = 512, SCREEN_H = 320; // logical layout grid; backed at 2xconst ACCENT = '#9945ff';const ACCENT_LT = '#b88aff';@@ -94,14 +96,13 @@ export class IntelKiosk {pedestal.castShadow = true;this.group.add(pedestal);- this.canvas = document.createElement('canvas');- this.canvas.width = 512; this.canvas.height = 320;- this.ctx = this.canvas.getContext('2d');- this.tex = new CanvasTexture(this.canvas);- this.tex.colorSpace = SRGBColorSpace;+ const { canvas, ctx } = makeScreenCanvas(SCREEN_W, SCREEN_H, 2);+ this.canvas = canvas;+ this.ctx = ctx;+ this.tex = makeScreenTexture(this.canvas);const screen = new Mesh(new PlaneGeometry(1.5, 0.94),- new MeshBasicMaterial({ map: this.tex, toneMapped: false }),+ screenMaterial(this.tex),);screen.position.set(0, 1.85, 0.08);screen.rotation.x = -0.14;@@ -141,8 +142,7 @@ export class IntelKiosk {}_signMesh(title, sub) {- const c = document.createElement('canvas'); c.width = 512; c.height = 160;- const x = c.getContext('2d');+ const { canvas, ctx: x } = makeScreenCanvas(512, 160, 2);x.textAlign = 'center';x.fillStyle = ACCENT_LT;fitFont(x, title, 480, 54);@@ -150,10 +150,10 @@ export class IntelKiosk {x.fillStyle = 'rgba(255,255,255,0.62)';x.font = '600 26px Inter, system-ui, sans-serif';x.fillText(sub, 256, 104);- const tex = new CanvasTexture(c); tex.colorSpace = SRGBColorSpace;+ const tex = makeScreenTexture(canvas);return new Mesh(new PlaneGeometry(4.2, 1.32),- new MeshBasicMaterial({ map: tex, transparent: true, side: DoubleSide }),+ screenMaterial(tex, { transparent: true, side: DoubleSide }),);}@@ -189,7 +189,7 @@ export class IntelKiosk {// ── kiosk screen states: offer → paying → intel ────────────────────────────_drawScreen() {- const c = this.ctx, W = this.canvas.width, H = this.canvas.height;+ const c = this.ctx, W = SCREEN_W, H = SCREEN_H;const g = c.createLinearGradient(0, 0, 0, H);g.addColorStop(0, '#15151a'); g.addColorStop(1, '#0a0a0c');c.fillStyle = g; c.fillRect(0, 0, W, H);diff --git a/src/game/screen-texture.js b/src/game/screen-texture.jsnew file mode 100644index 000000000..f1e2ce714--- /dev/null+++ b/src/game/screen-texture.js@@ -0,0 +1,69 @@+// Screen Texture - shared quality settings for every in-world canvas screen.+//+// All the /play "physical screens" (brand jumbotron, x402 board, chart screen,+// intel kiosk, agent desks) are HTML canvases wrapped in CanvasTexture. Built+// naively they look terrible in-world for three stacked reasons:+// 1. Default anisotropy (1) mip-blurs any screen viewed at an angle, which+// is how screens are almost always seen from the plaza.+// 2. MeshBasicMaterial participates in scene fog and ACES tone mapping by+// default, so an "emissive" screen face gets hazed toward the fog color+// and its whites graded down to gray.+// 3. 1:1 canvas backing resolution leaves text soft the moment the player+// walks up close.+// This module centralizes the fixes so every screen gets them consistently.++import { CanvasTexture, SRGBColorSpace, MeshBasicMaterial } from 'three';++let _maxAniso = null;++// Highest anisotropic filtering level the GPU supports (capped at 16), probed+// once from a throwaway context so screen modules that only receive a Scene+// can still use it. Falls back to 4 when the probe fails.+export function screenAnisotropy() {+ if (_maxAniso != null) return _maxAniso;+ _maxAniso = 4;+ try {+ const probe = document.createElement('canvas');+ const gl = probe.getContext('webgl2') || probe.getContext('webgl');+ const ext = gl && (+ gl.getExtension('EXT_texture_filter_anisotropic') ||+ gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') ||+ gl.getExtension('MOZ_EXT_texture_filter_anisotropic')+ );+ if (ext) {+ const max = gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT);+ if (isFinite(max) && max > 1) _maxAniso = Math.min(16, max);+ }+ gl?.getExtension('WEBGL_lose_context')?.loseContext();+ } catch { /* keep the fallback */ }+ return _maxAniso;+}++// A canvas whose backing store is `ss` times its logical size, with the 2D+// context pre-scaled so existing draw code keeps using logical coordinates.+// Text and strokes render at the higher density and come out crisp up close.+// The scale transform survives save()/restore() pairs; callers must not use+// setTransform()/resetTransform(), which none of the screen modules do.+export function makeScreenCanvas(width, height, ss = 2) {+ const canvas = document.createElement('canvas');+ canvas.width = Math.round(width * ss);+ canvas.height = Math.round(height * ss);+ const ctx = canvas.getContext('2d');+ ctx.scale(ss, ss);+ return { canvas, ctx };+}++// CanvasTexture with the correct color space and full anisotropic filtering.+export function makeScreenTexture(canvas) {+ const tex = new CanvasTexture(canvas);+ tex.colorSpace = SRGBColorSpace;+ tex.anisotropy = screenAnisotropy();+ return tex;+}++// The face material for a lit screen: unlit, exempt from tone mapping (whites+// stay white) and from scene fog (a glowing LED wall does not haze out with+// the atmosphere the way diffuse surfaces do).+export function screenMaterial(tex, extra = {}) {+ return new MeshBasicMaterial({ map: tex, toneMapped: false, fog: false, ...extra });+}diff --git a/src/game/x402-jumbotron.js b/src/game/x402-jumbotron.jsindex 641517593..a5c6b38a8 100644--- a/src/game/x402-jumbotron.js+++ b/src/game/x402-jumbotron.js@@ -17,15 +17,17 @@// empty, and error states are painted on the screen itself.import {- Group, Mesh, MeshBasicMaterial, MeshStandardMaterial,+ Group, Mesh, MeshStandardMaterial,PlaneGeometry, CylinderGeometry, BoxGeometry,- CanvasTexture, SRGBColorSpace, DoubleSide,+ DoubleSide,} from 'three';+import { makeScreenCanvas, makeScreenTexture, screenMaterial } from './screen-texture.js';const FEED_URL = (limit = 12) => `/api/x402-pay?feed=1&limit=${limit}`;const POLL_MS = 8000;const REDRAW_MS = 100; // ~10fps — smooth pulse/scroll, cheap on the GPU-const CW = 1280, CH = 720; // 16:9 canvas backing the screen+const CW = 1280, CH = 720; // 16:9 logical layout grid for the draw code+const SS = 1.5; // supersample: 1920x1080 backing store, crisp textconst MAX_ROWS = 6; // recent payments shown on the board// Stage stepper, keyed to the SSE events /api/x402-pay emits — matches the order@@ -51,7 +53,11 @@ const COL = {function fmtUsdc(micro) {const n = Number(micro);if (!isFinite(n) || n <= 0) return '$0.01';- return '$' + (n / 1e6).toFixed(2);+ const usd = n / 1e6;+ // Sub-cent micropayments (a 1000-micro dance tip is $0.001) must not floor+ // to "$0.00" on a board whose whole point is showing money move.+ if (usd >= 0.01) return '$' + usd.toFixed(2);+ return '$' + usd.toFixed(4).replace(/0+$/, '').replace(/\.$/, '.00');}function shortAddr(a) {@@ -127,15 +133,13 @@ export function createX402Jumbotron(scene, opts = {}) {group.add(bezel);// The live face: canvas → CanvasTexture → unlit plane (glows like a screen).- const canvas = document.createElement('canvas');- canvas.width = CW; canvas.height = CH;- const ctx = canvas.getContext('2d');- const tex = new CanvasTexture(canvas);- tex.colorSpace = SRGBColorSpace;- tex.anisotropy = 4;+ // Supersampled backing store + max anisotropy + fog/tone-mapping exemption+ // via screen-texture.js so the board stays crisp and punchy at any angle.+ const { canvas, ctx } = makeScreenCanvas(CW, CH, SS);+ const tex = makeScreenTexture(canvas);const panel = new Mesh(new PlaneGeometry(width, height),- new MeshBasicMaterial({ map: tex, side: DoubleSide, toneMapped: false }),+ screenMaterial(tex, { side: DoubleSide }),);panel.position.set(0, cy, 0.01);panel.userData.x402Jumbotron = true;