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(home): put the live event countdown on the front page, and unify the mark
nirholas3cac7f226470
diff --git a/pages/home.html b/pages/home.htmlindex 94ff14a04..9c23f5f1c 100644--- a/pages/home.html+++ b/pages/home.html@@ -72,6 +72,12 @@<!-- Seasonal decorations (date-gated no-op outside its window) --><script src="/seasonal.js" defer></script>+<!-- Live-event strip, inserted between the nav and the hero at runtime. Reads+ the ONE event window in the repo (public/event.json) through+ src/shared/event-config.js, the same reader the /play countdown uses, and+ mounts nothing when there is no event or the event has ended. -->+<script type="module" src="/src/home-event-banner.js"></script>+<!-- ── HERO ─────────────────────────────────────────────────────── --><main id="main-content" tabindex="-1"><section class="hero">diff --git a/src/home-event-banner.js b/src/home-event-banner.jsnew file mode 100644index 000000000..ed327d37a--- /dev/null+++ b/src/home-event-banner.js@@ -0,0 +1,185 @@+// Home-page event strip.+//+// The countdown used to live only on /play, which meant the event was invisible+// to anyone who never opened the world. This mounts a compact announcement bar+// between the nav and the hero on `/`, reading the SAME window as the /play+// surfaces through src/shared/event-config.js. There is exactly one copy of the+// event times in this repo (public/event.json); this file adds a view, never a+// second source.+//+// Self-attaching and self-removing: it fetches once at boot, mounts nothing when+// there is no event (or the event has ended), ticks once a second while an event+// is upcoming, flips to LIVE without a reload the moment the start time passes,+// and unmounts itself when the end time passes.+//+// Dismissal is shared with the /play in-world pill (the same+// `cc-event-dismissed:<startsAt>` key), so a visitor who waves the reminder away+// on the home page does not meet it again in the world. The /play lobby banner+// is deliberately NOT dismissible: it is lobby content, not an overlay.++import {+ loadEventConfig, eventState, clockString, formatStart, alreadyAtEvent,+} from './shared/event-config.js';++const STYLE = `+.tws-eventbar {+ border-bottom: 1px solid var(--hairline, rgba(255,255,255,0.08));+ background: var(--surface-0, #0e0e0f);+ color: var(--text, #f6f6f6);+ font-family: var(--font-body, 'Inter', system-ui, sans-serif);+}+.tws-eventbar-in {+ max-width: 1400px; margin: 0 auto; padding: 10px 24px;+ display: flex; align-items: center; gap: 14px; flex-wrap: wrap;+}+.tws-eventbar-dot {+ flex: none; width: 6px; height: 6px; border-radius: 50%;+ background: var(--text-3, #8a8a8a);+}+.tws-eventbar[data-state="live"] .tws-eventbar-dot {+ background: var(--accent, #fff); box-shadow: 0 0 6px var(--accent, #fff);+ animation: tws-eventbar-pulse 2.4s ease-in-out infinite;+}+@keyframes tws-eventbar-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }+@media (prefers-reduced-motion: reduce) {+ .tws-eventbar[data-state="live"] .tws-eventbar-dot { animation: none; }+ .tws-eventbar-cta, .tws-eventbar-x { transition: none; }+}+.tws-eventbar-kicker {+ font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px;+ letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-3, #8a8a8a);+ white-space: nowrap;+}+.tws-eventbar-name { font-weight: 600; font-size: 14px; }+.tws-eventbar-when { font-size: 13px; color: var(--text-2, #a8a8a8); }+.tws-eventbar-clock {+ font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px;+ font-variant-numeric: tabular-nums; color: var(--text, #f6f6f6);+ padding: 3px 9px; border: 1px solid var(--hairline, rgba(255,255,255,0.08));+ border-radius: 999px; white-space: nowrap;+}+.tws-eventbar-cta {+ margin-left: auto;+ display: inline-flex; align-items: center; gap: 7px;+ padding: 7px 14px; border-radius: 999px;+ border: 1px solid var(--hairline-strong, rgba(255,255,255,0.14));+ color: var(--text, #f6f6f6); text-decoration: none;+ font-size: 13px; font-weight: 500; white-space: nowrap;+ transition: color 0.15s, border-color 0.15s, background 0.15s;+}+.tws-eventbar-cta .tws-eventbar-arrow { display: inline-block; transition: transform 0.15s; }+.tws-eventbar-cta:hover, .tws-eventbar-cta:focus-visible {+ background: rgba(255, 255, 255, 0.05);+ border-color: var(--accent, #fff);+}+.tws-eventbar-cta:hover .tws-eventbar-arrow,+.tws-eventbar-cta:focus-visible .tws-eventbar-arrow { transform: translateX(3px); }+.tws-eventbar-cta:active { transform: translateY(1px); }+.tws-eventbar-cta:focus-visible { outline: 2px solid var(--accent, #fff); outline-offset: 2px; }+.tws-eventbar-x {+ flex: none; display: grid; place-items: center; width: 26px; height: 26px;+ border: 0; border-radius: 50%; background: transparent;+ color: var(--text-3, #8a8a8a); font: inherit; font-size: 15px; line-height: 1;+ transition: background 0.15s, color 0.15s;+}+/* With no CTA the close button takes the right edge itself. */+.tws-eventbar-x { margin-left: auto; }+.tws-eventbar-cta ~ .tws-eventbar-x { margin-left: 0; }+.tws-eventbar-x:hover { background: rgba(255, 255, 255, 0.08); color: var(--text, #f6f6f6); }+.tws-eventbar-x:active { transform: scale(0.94); }+.tws-eventbar-x:focus-visible { outline: 2px solid var(--accent, #fff); outline-offset: 1px; }+[data-theme='light'] .tws-eventbar-cta:hover,+[data-theme='light'] .tws-eventbar-cta:focus-visible { background: rgba(0, 0, 0, 0.05); }+[data-theme='light'] .tws-eventbar-x:hover { background: rgba(0, 0, 0, 0.06); }+@media (max-width: 720px) {+ .tws-eventbar-in { padding: 9px 16px; gap: 8px 10px; }+ .tws-eventbar-when { flex-basis: 100%; order: 4; font-size: 12px; }+ .tws-eventbar-cta { margin-left: 0; order: 5; }+ .tws-eventbar-x { order: 6; margin-left: auto; }+}+`;++function el(tag, attrs = {}, children = []) {+ const n = document.createElement(tag);+ for (const [k, v] of Object.entries(attrs)) {+ if (v == null) continue;+ if (k === 'text') n.textContent = v;+ else if (k.startsWith('on') && typeof v === 'function') n.addEventListener(k.slice(2), v);+ else n.setAttribute(k, v);+ }+ for (const c of children) if (c) n.appendChild(c);+ return n;+}++class HomeEventBar {+ constructor(cfg, main) {+ this.cfg = cfg;+ this.timer = 0;+ document.head.appendChild(el('style', { text: STYLE }));++ this.kicker = el('span', { class: 'tws-eventbar-kicker', text: 'Upcoming' });+ this.clock = el('span', { class: 'tws-eventbar-clock', role: 'timer' });+ const cta = cfg.link && !alreadyAtEvent(cfg)+ ? el('a', { class: 'tws-eventbar-cta', href: cfg.link, 'data-cta': 'event_join', 'data-cta-loc': 'home_eventbar' }, [+ el('span', { text: cfg.linkLabel }),+ el('span', { class: 'tws-eventbar-arrow', 'aria-hidden': 'true', text: '→' }),+ ])+ : null;++ this.bar = el('aside', { class: 'tws-eventbar', 'aria-label': `Event: ${cfg.name}` }, [+ el('div', { class: 'tws-eventbar-in' }, [+ el('span', { class: 'tws-eventbar-dot', 'aria-hidden': 'true' }),+ this.kicker,+ el('span', { class: 'tws-eventbar-name', text: cfg.name }),+ el('span', { class: 'tws-eventbar-when', text: formatStart(cfg.startsAt) }),+ this.clock,+ cta,+ el('button', {+ type: 'button', class: 'tws-eventbar-x', title: 'Dismiss',+ 'aria-label': 'Dismiss the event announcement',+ onclick: () => {+ try { localStorage.setItem('cc-event-dismissed:' + cfg.startsAt, '1'); } catch { /* private mode: dismiss for this page view only */ }+ this.destroy();+ },+ }, [el('span', { 'aria-hidden': 'true', text: '×' })]),+ ]),+ ]);++ main.parentNode.insertBefore(this.bar, main);+ this._tick();+ this.timer = setInterval(() => this._tick(), 1000);+ }++ _tick() {+ const now = Date.now();+ const state = eventState(this.cfg, now);+ if (state === 'over') return this.destroy();+ this.bar.setAttribute('data-state', state);+ if (state === 'live') {+ this.kicker.textContent = 'Live now';+ this.clock.textContent = 'LIVE';+ } else {+ this.kicker.textContent = 'Upcoming';+ this.clock.textContent = clockString(this.cfg.startsAt - now);+ }+ }++ destroy() {+ clearInterval(this.timer);+ this.bar?.remove();+ this.bar = null;+ }+}++async function boot() {+ const cfg = await loadEventConfig();+ if (!cfg) return;+ let dismissed = false;+ try { dismissed = !!localStorage.getItem('cc-event-dismissed:' + cfg.startsAt); } catch { dismissed = false; }+ if (dismissed) return;+ const main = document.getElementById('main-content');+ if (!main || !main.parentNode) return;+ new HomeEventBar(cfg, main);+}++boot();diff --git a/src/shared/brand-mark.js b/src/shared/brand-mark.jsnew file mode 100644index 000000000..836a16d36--- /dev/null+++ b/src/shared/brand-mark.js@@ -0,0 +1,54 @@+// The three.ws mark, in one place.+//+// The glyph was copy-pasted as an inline <svg> string in every surface that+// needed it, which is how a logo ends up subtly different on three pages. It+// lives here now as raw path data plus two renderers:+//+// threeMarkSvg() — an inline <svg> string for DOM chrome (nav, HUD, footers)+// threeMarkPath2D() — a Path2D for <canvas> compositing (share cards, exports)+//+// Both draw the SAME path in the SAME 32x32 viewBox, so a mark stamped onto a+// downloaded PNG is pixel-for-pixel the mark in the page header.++/** The mark's `d` attribute, authored in a 0 0 32 32 viewBox. */+export const THREE_MARK_PATH = 'M11.013 1.011a16 16 0 0 0-3.96 1.39C2.79 4.531.213 8.757.012 13.564c-.16 3.933 1.31 7.62 4.117 10.357l.736.715-.16.46c-.084.249-.13.504-.138.761 0 1.358 1.448 2.218 2.638 1.567.535-.292.879-.748 1.043-1.384.084-.331.092-.462.07-.882-.02-.43-.04-.535-.18-.83-.246-.52-.567-.86-1.087-1.153l-.297-.167.106-.32c.18-.543.79-1.717 1.181-2.276 1.91-2.729 5.066-4.395 8.4-4.434l.43-.005.012-1.19c.006-.654.024-1.19.04-1.19s.252.197.526.438c.71.624 2.296 1.95 2.785 2.328.23.178.41.34.4.36-.01.02-.214.156-.453.303-.926.57-2.265 1.65-3.13 2.524l-.27.273.012 1.064.013 1.064.32.027c1.327.114 2.598.685 3.578 1.607.21.198.39.343.4.323.04-.073.276-1.327.346-1.84.296-2.169-.094-4.317-1.129-6.16l-.19-.34.246-.45c.811-1.485 1.291-3.063 1.456-4.776.04-.42.046-.488.111-.488.111 0 1.327.715 1.94 1.143 2.953 2.057 4.96 5.241 5.579 8.856.21 1.22.234 1.585.234 3.063 0 1.485-.024 1.844-.234 3.064-.811 4.736-4.06 8.732-8.51 10.474-1.04.407-2.504.78-3.578.91l-.32.04v2.395l.41-.046c2.014-.226 4.222-.93 5.98-1.91 4.84-2.688 8.058-7.464 8.696-12.897.105-.892.105-3.063 0-3.956-.638-5.433-3.856-10.21-8.697-12.898C24.083.99 21.875.285 19.86.06 19.322 0 19.27 0 15.752.006c-3.346.006-4.234.02-4.74.105Z';++/** The mark's authoring viewBox size, so callers can scale without guessing. */+export const THREE_MARK_VIEWBOX = 32;++/**+ * Inline SVG string for the mark. Fills with `currentColor`, so the surrounding+ * element's `color` drives it. Decorative by default (`aria-hidden`); pass a+ * label when the mark is the only content of a link or button.+ *+ * @param {{ label?: string, className?: string }} [opts]+ */+export function threeMarkSvg({ label = '', className = '' } = {}) {+ const a11y = label+ ? `role="img" aria-label="${label.replace(/"/g, '"')}"`+ : 'aria-hidden="true"';+ const cls = className ? ` class="${className}"` : '';+ return `<svg${cls} viewBox="0 0 ${THREE_MARK_VIEWBOX} ${THREE_MARK_VIEWBOX}" fill="currentColor" xmlns="http://www.w3.org/2000/svg" ${a11y} focusable="false"><path d="${THREE_MARK_PATH}"/></svg>`;+}++/**+ * The mark as a Path2D for canvas compositing. Coordinates stay in the 32x32+ * authoring space; scale and translate with the context transform:+ *+ * ctx.save();+ * ctx.translate(x, y);+ * ctx.scale(size / THREE_MARK_VIEWBOX, size / THREE_MARK_VIEWBOX);+ * ctx.fill(threeMarkPath2D());+ * ctx.restore();+ *+ * Returns null where Path2D is unavailable, so callers can skip the mark+ * instead of throwing mid-render.+ */+export function threeMarkPath2D() {+ if (typeof Path2D === 'undefined') return null;+ try {+ return new Path2D(THREE_MARK_PATH);+ } catch {+ return null;+ }+}