Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: enhance avatar customization and rendering

udvkb61115e231bc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0710f5f10..8c4bc3c9d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Avatar Studio avatars come alive — pick from 16 motions** — Your avatar no longer stands frozen in a stiff T-pose while you dress it. Avatar Studio now plays a natural looping idle the moment it loads — proof the avatar is fully rigged — and a new Animate tab lets you drive the rig live: 16 curated motions including Idle, Wave, Cheer, Celebrate, Flex, Dance, Shuffle, Rumba, Thriller, Capoeira and more. Looping motions become your avatar's resting idle, so when you Save, your avatar is captured in the relaxed stance you chose rather than a rigid pose. One-shot moves like Wave and Celebrate play once and settle back to idle automatically. (`/avatar-studio`) `[feature, improvement]`
- **Default avatars render again everywhere** — Avatars stopped appearing across the site — the homepage hero, guest avatars, and any embed that falls back to the default character all showed an empty frame. The default avatar was being loaded from an asset host that had gone offline. It now loads from three.ws itself, so default avatars render again on every page and in every embed. `[fix]`
- **Embeddable avatars get tap-to-walk, gestures, and a lighter footprint** — The walking-avatar embed you drop onto any site is now friendlier and lighter. Visitors can tap or click the ground to send the avatar walking there — no joystick required — and a one-time on-screen hint appears so first-timers actually discover the controls. Turn on a Gestures option and they get wave and jump buttons too. On desktop the avatar gently turns to face your cursor when it's standing still, so a hovered embed feels alive. While the 3D model loads, a soft silhouette stands in instead of a blank gap. The embed now pauses itself the moment it scrolls out of view or its tab is hidden, so it never drains a laptop battery in the background, and it respects your system 'reduce motion' setting. Every embed carries a small, tasteful three.ws badge that links home — removable with one toggle. The embed editor adds matching controls: walk speed, ground on/off, gestures, the badge toggle, and a Responsive option that emits a fluid snippet that fills its container on any screen. (`/embed`) `[feature, improvement]`
+- **Fixed: the Animation Gallery footer no longer covers the page** — The /animations page had a layout bug where the site footer was being pulled up and painted on top of the gallery — the hero, search bar, and animation cards ended up hidden behind it. The footer now sits where it belongs, at the bottom of the page, so the full motion library is visible and browsable again. (`/animations`) `[fix]`
- **Living Worlds video generator is back online** — The Cosmos text-to-world lane — describe a scene and get a short cinematic video that plays as a living backdrop behind your avatar — had stopped generating: NVIDIA moved the hosted Cosmos model to a new address, so every request came back as an error. We've pointed the lane at the new endpoint and it generates worlds again. (`/cosmos`) `[fix]`
- **Mission Control's live launch feed never goes dark** — The terminal's Live feed streams brand-new pump.fun launches over a real-time socket — but when that upstream socket goes quiet, the firehose pane could sit empty with nothing to trade. The feed now has a live safety net: it also reads pump.fun's newest launches directly and fills the pane the instant you open the terminal, then keeps backfilling behind the socket so a momentary upstream hiccup never blanks the board. Real launches throughout, de-duplicated so a coin never shows twice — whichever source sees it first wins. (`/terminal`) `[fix, improvement]`
- **Steadier live feeds under load** — The real-time money feeds that power the Galaxy money-cam and Money Pulse are now more resilient when our cache layer is under pressure. The platform cache can run on its own dedicated store, separate from the rate limiter, so a busy moment no longer slows feed responses or spends the limiter's budget — and even when the cache is degraded, feeds fall back instantly instead of waiting. You'll see the live maps stay smooth during traffic spikes. `[infra, improvement]`
diff --git a/api/_lib/avaturn-seed.js b/api/_lib/avaturn-seed.js
new file mode 100644
index 000000000..e6d4dcb6d
--- /dev/null
+++ b/api/_lib/avaturn-seed.js
@@ -0,0 +1,181 @@
+// @ts-check
+// Pure helpers for the avaturn-seed cron — no I/O, fully unit-testable.
+//
+// The cron drives Avaturn's editor headlessly and randomizes a "look" from the
+// account's own catalog (bodies + assets + colors) rather than from AI photos,
+// so every export is an on-model, fully-rigged Avaturn avatar. The randomization
+// is seeded (mulberry32) so a given seed reproduces a look exactly — handy for
+// debugging a bad export and for deterministic tests.
+
+/** @typedef {{ id: string, name?: string, category?: string, type?: string, slot?: string }} CatalogItem */
+/** @typedef {{ id: string, name?: string, gender?: string, body_type?: string }} BodyItem */
+
+// ── Seeded RNG ─────────────────────────────────────────────────────────────────
+
+/**
+ * Hash an arbitrary string into a 32-bit unsigned int seed.
+ * @param {string} str
+ * @returns {number}
+ */
+export function hashSeed(str) {
+ let h = 2166136261 >>> 0;
+ for (let i = 0; i < str.length; i++) {
+ h ^= str.charCodeAt(i);
+ h = Math.imul(h, 16777619);
+ }
+ return h >>> 0;
+}
+
+/**
+ * mulberry32 — tiny, fast, well-distributed seeded PRNG. Returns a function that
+ * yields floats in [0, 1).
+ * @param {number} seed
+ * @returns {() => number}
+ */
+export function mulberry32(seed) {
+ let a = seed >>> 0;
+ return function () {
+ a |= 0;
+ a = (a + 0x6d2b79f5) | 0;
+ let t = Math.imul(a ^ (a >>> 15), 1 | a);
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ };
+}
+
+/**
+ * Pick one element of `arr` using `rng`. Returns undefined for an empty array.
+ * @template T
+ * @param {T[]} arr
+ * @param {() => number} rng
+ * @returns {T | undefined}
+ */
+export function pickOne(arr, rng) {
+ if (!Array.isArray(arr) || arr.length === 0) return undefined;
+ return arr[Math.floor(rng() * arr.length)];
+}
+
+// ── Catalog grouping ───────────────────────────────────────────────────────────
+
+// Wearable asset slots we randomize. One asset is chosen per slot the catalog
+// actually offers — missing slots are simply skipped, never faked. The Avaturn
+// catalog tags each asset with a category/type; we normalize a few common
+// spellings so grouping is stable across catalog revisions.
+export const WEARABLE_SLOTS = ['outfit', 'top', 'bottom', 'shoes', 'hair', 'headwear', 'glasses', 'outerwear'];
+
+const SLOT_ALIASES = {
+ clothing: 'outfit',
+ costume: 'outfit',
+ footwear: 'shoes',
+ shoe: 'shoes',
+ hairstyle: 'hair',
+ hat: 'headwear',
+ headgear: 'headwear',
+ eyewear: 'glasses',
+ jacket: 'outerwear',
+ coat: 'outerwear',
+};
+
+/**
+ * Normalize a raw catalog category/type string to one of WEARABLE_SLOTS, or
+ * return the lowercased original when it isn't a slot we randomize.
+ * @param {string} [raw]
+ * @returns {string}
+ */
+export function normalizeSlot(raw) {
+ const k = String(raw || '').trim().toLowerCase();
+ return SLOT_ALIASES[k] || k;
+}
+
+/**
+ * Group a flat asset list into { slot: CatalogItem[] }, keeping only slots we
+ * randomize.
+ * @param {CatalogItem[]} assets
+ * @returns {Record<string, CatalogItem[]>}
+ */
+export function groupAssetsBySlot(assets) {
+ /** @type {Record<string, CatalogItem[]>} */
+ const grouped = {};
+ for (const asset of Array.isArray(assets) ? assets : []) {
+ if (!asset || !asset.id) continue;
+ const slot = normalizeSlot(asset.category ?? asset.type ?? asset.slot);
+ if (!WEARABLE_SLOTS.includes(slot)) continue;
+ (grouped[slot] ||= []).push(asset);
+ }
+ return grouped;
+}
+
+// ── Color randomization ─────────────────────────────────────────────────────────
+
+// Natural hair shades — kept realistic so results stay on-model rather than
+// cartoonish. setHairColor takes a `#rrggbb` string.
+export const HAIR_COLORS = [
+ '#0b0b0b', '#1c1310', '#2a1a0f', '#3b2412', '#4a2f1a',
+ '#5c3a1e', '#6b4423', '#7a5230', '#8d6239', '#a87c4f',
+ '#c69a63', '#d9b380', '#e3c79a', '#9a9a9a', '#d8d8d8',
+];
+
+// Avaturn eye colors are an enum keyed by name; these are the standard set.
+export const EYE_COLORS = ['brown', 'dark_brown', 'hazel', 'amber', 'green', 'blue', 'gray'];
+
+/**
+ * Build a fully-randomized look from the live catalog. Pure — no I/O. The caller
+ * (the headless harness) applies the returned ids/values via the Avaturn SDK.
+ *
+ * @param {string} seed - any string (we hash it); same seed → same look
+ * @param {{ bodies: BodyItem[], assets: CatalogItem[], bodyType?: 'male'|'female' }} catalog
+ * @returns {{
+ * bodyId: string | null,
+ * assetIds: string[],
+ * assetsBySlot: Record<string, string>,
+ * hairColor: string,
+ * eyeColor: string,
+ * skinToneCorrection: number,
+ * }}
+ */
+export function pickRandomLook(seed, { bodies, assets, bodyType }) {
+ const rng = mulberry32(hashSeed(String(seed)));
+
+ // Prefer a body matching the requested gender when the catalog tags it;
+ // fall back to the whole list so we always pick something real.
+ let bodyPool = Array.isArray(bodies) ? bodies.filter((b) => b && b.id) : [];
+ if (bodyType) {
+ const matched = bodyPool.filter(
+ (b) => normalizeSlot(b.gender ?? b.body_type) === bodyType,
+ );
+ if (matched.length) bodyPool = matched;
+ }
+ const body = pickOne(bodyPool, rng);
+
+ const grouped = groupAssetsBySlot(assets);
+ /** @type {Record<string, string>} */
+ const assetsBySlot = {};
+ const assetIds = [];
+ // Deterministic slot order so the seed reproduces the same look.
+ for (const slot of WEARABLE_SLOTS) {
+ const choice = pickOne(grouped[slot] || [], rng);
+ if (choice) {
+ assetsBySlot[slot] = choice.id;
+ assetIds.push(choice.id);
+ }
+ }
+
+ return {
+ bodyId: body?.id ?? null,
+ assetIds,
+ assetsBySlot,
+ hairColor: pickOne(HAIR_COLORS, rng) ?? HAIR_COLORS[0],
+ eyeColor: pickOne(EYE_COLORS, rng) ?? EYE_COLORS[0],
+ // -50..50; 0 = no correction. Keep within a gentle band so skin stays natural.
+ skinToneCorrection: Math.round((rng() - 0.5) * 30),
+ };
+}
+
+/**
+ * Pick a body type for a run. Roughly even split, seeded for reproducibility.
+ * @param {string} seed
+ * @returns {'male'|'female'}
+ */
+export function pickBodyType(seed) {
+ return mulberry32(hashSeed(seed + ':bodytype'))() < 0.5 ? 'male' : 'female';
+}
diff --git a/api/_lib/avaturn.js b/api/_lib/avaturn.js
new file mode 100644
index 000000000..5671af0f8
--- /dev/null
+++ b/api/_lib/avaturn.js
@@ -0,0 +1,71 @@
+// @ts-check
+// Server-side Avaturn helpers shared by the onboarding photo flow and the
+// avaturn-seed cron.
+//
+// The seed cron needs a *catalog* session — an editor session opened WITHOUT
+// selfie photos, so the headless driver can pick a body + assets from the
+// account's own catalog and export a fully-rigged GLB. That's a different shape
+// from the photo→avatar onboarding session, hence its own helper here.
+
+import { env } from './env.js';
+
+const SESSION_PATH = '/api/v1/sessions';
+const REQUEST_TIMEOUT_MS = 20_000;
+
+/**
+ * @typedef {{ sessionUrl: string, expiresAt: string | null, raw: any }} AvaturnSession
+ */
+
+/**
+ * Open an Avaturn editor session with no photos so the catalog (bodies + assets)
+ * can be randomized in the editor. Attributed to `externalUserId` so Avaturn
+ * tracks usage per synthetic account.
+ *
+ * @param {{ externalUserId: string, bodyType?: 'male'|'female', signal?: AbortSignal }} opts
+ * @returns {Promise<AvaturnSession>}
+ */
+export async function createCatalogSession({ externalUserId, bodyType = 'male', signal }) {
+ if (!env.AVATURN_API_KEY) {
+ throw Object.assign(new Error('AVATURN_API_KEY unset'), { code: 'not_configured', status: 501 });
+ }
+ const url = `${env.AVATURN_API_URL}${SESSION_PATH}`;
+ // session_type 'create' opens the editor's create UI on a default body; with
+ // no photos the user (here, the headless driver) builds the avatar from the
+ // catalog. export_type 'url' makes exportAvatar resolve to a fetchable GLB
+ // URL rather than a multi-MB data URI.
+ const body = {
+ external_user_id: externalUserId,
+ body_type: bodyType,
+ session_type: 'create',
+ export_type: 'url',
+ };
+
+ const upstream = await fetch(url, {
+ method: 'POST',
+ headers: {
+ authorization: `Bearer ${env.AVATURN_API_KEY}`,
+ 'content-type': 'application/json',
+ accept: 'application/json',
+ },
+ body: JSON.stringify(body),
+ signal: signal ?? AbortSignal.timeout(REQUEST_TIMEOUT_MS),
+ });
+
+ if (!upstream.ok) {
+ const text = await upstream.text().catch(() => '');
+ throw Object.assign(new Error(`avaturn session ${upstream.status}: ${text.slice(0, 200)}`), {
+ code: upstream.status === 401 ? 'upstream_auth' : 'upstream_error',
+ status: upstream.status >= 500 ? 502 : upstream.status,
+ });
+ }
+
+ const data = await upstream.json();
+ const sessionUrl = data?.session_url || data?.url || data?.iframe_url;
+ if (!sessionUrl) {
+ throw Object.assign(new Error('avaturn response missing session_url'), {
+ code: 'upstream_error',
+ status: 502,
+ });
+ }
+ return { sessionUrl, expiresAt: data?.expires_at ?? null, raw: data };
+}
diff --git a/api/_lib/env.js b/api/_lib/env.js
index 1d1497cb2..4eff732e8 100644
--- a/api/_lib/env.js
+++ b/api/_lib/env.js
@@ -296,6 +296,12 @@ export const env = {
get AVATURN_API_URL() {
return trimSlash(opt('AVATURN_API_URL', 'https://api.avaturn.me'));
},
+ // avaturn-seed cron — set to '1' to enable the per-minute headless seeder that
+ // grows the public gallery with randomized, Avaturn-rigged avatars. Off by
+ // default so the cron is a no-op until the operator opts in (and has quota).
+ get AVATURN_SEED_ENABLED() {
+ return opt('AVATURN_SEED_ENABLED', '') === '1';
+ },
// Anthropic API key — used by persona / memory-seeding endpoints and
// the we-pay LLM proxy (/api/llm/anthropic) when an agent selects a
diff --git a/api/_lib/token-market.js b/api/_lib/token-market.js
index 83b8faf7f..7cd49b118 100644
--- a/api/_lib/token-market.js
+++ b/api/_lib/token-market.js
@@ -74,6 +74,7 @@ export async function fetchTokenMarket(ca, opts = {}) {
: (quote.address || '').toLowerCase() === lc ? quote
: base;
const info = p.info || {};
+ const txns = p.txns || {};
return {
mint: tok.address || ca,
@@ -89,9 +90,128 @@ export async function fetchTokenMarket(ca, opts = {}) {
liquidity_usd: num(p.liquidity?.usd),
volume_24h_usd: num(p.volume?.h24),
pair_created_at: num(p.pairCreatedAt),
+ // Multi-timeframe price change (% per window) — the shape of the move, not
+ // just the 24 h endpoint. Lets the signal read acceleration vs. exhaustion.
+ momentum: {
+ m5: num(p.priceChange?.m5),
+ h1: num(p.priceChange?.h1),
+ h6: num(p.priceChange?.h6),
+ h24: num(p.priceChange?.h24),
+ },
+ // Buy/sell transaction counts over 24 h — real order flow, the difference
+ // between accumulation and distribution behind the same price move.
+ txns_24h: { buys: num(txns.h24?.buys), sells: num(txns.h24?.sells) },
};
}
+/** Money formatter for risk-factor copy — compact, human, no library. */
+function usd(n) {
+ if (n == null || !Number.isFinite(n)) return '$?';
+ if (n >= 1000) return `$${Math.round(n).toLocaleString('en-US')}`;
+ return `$${n.toLocaleString('en-US', { maximumFractionDigits: 2 })}`;
+}
+
+/** Human pair age from a millisecond span. */
+function fmtAge(ms) {
+ if (ms == null || !Number.isFinite(ms)) return 'unknown age';
+ const h = ms / 3_600_000;
+ if (h < 1) return `${Math.max(1, Math.round(h * 60))}m`;
+ if (h < 48) return `${Math.round(h)}h`;
+ return `${Math.round(h / 24)}d`;
+}
+
+/**
+ * Score the safety of any token from its live market shape — the due-diligence
+ * layer behind the CA → x402 oracle. Higher score = MORE risk (0 safe … 100
+ * critical). Every input is real DexScreener data; nothing is fabricated, and a
+ * missing field degrades to an honest "unknown" factor rather than a fake pass.
+ *
+ * `now` is injectable so the result is deterministic under test.
+ *
+ * @param {object} m a fetchTokenMarket() result
+ * @param {number} [now] epoch ms, defaults to wall clock
+ * @returns {{ score:number, level:'low'|'medium'|'high'|'critical',
+ * summary:string, factors:Array<{label:string,status:string,detail:string}> }}
+ */
+export function buildTokenRisk(m, now = Date.now()) {
+ const sym = (m.symbol || 'This token').toUpperCase();
+ const factors = [];
+ let risk = 0;
+
+ // 1) Liquidity depth — the single biggest exit-risk signal.
+ const liq = m.liquidity_usd;
+ if (liq == null) {
+ factors.push({ label: 'Liquidity', status: 'unknown', detail: 'Pool depth unavailable from upstream.' });
+ risk += 18;
+ } else if (liq < 5_000) {
+ factors.push({ label: 'Liquidity', status: 'critical', detail: `Only ${usd(liq)} pooled — trivially drained, severe exit risk.` });
+ risk += 40;
+ } else if (liq < 25_000) {
+ factors.push({ label: 'Liquidity', status: 'high', detail: `${usd(liq)} is thin — large orders slip hard.` });
+ risk += 26;
+ } else if (liq < 100_000) {
+ factors.push({ label: 'Liquidity', status: 'medium', detail: `${usd(liq)} pooled — moderate depth.` });
+ risk += 12;
+ } else {
+ factors.push({ label: 'Liquidity', status: 'low', detail: `${usd(liq)} pooled — healthy depth.` });
+ }
+
+ // 2) Pair age — brand-new pairs are unproven and the most rug-prone.
+ const ageMs = m.pair_created_at ? now - m.pair_created_at : null;
+ const ageDays = ageMs != null ? ageMs / 86_400_000 : null;
+ if (ageDays == null) {
+ factors.push({ label: 'Age', status: 'unknown', detail: 'Pair creation time unavailable.' });
+ } else if (ageDays < 1) {
+ factors.push({ label: 'Age', status: 'high', detail: `Pair is ${fmtAge(ageMs)} old — unproven and volatile.` });
+ risk += 22;
+ } else if (ageDays < 7) {
+ factors.push({ label: 'Age', status: 'medium', detail: `Pair is ${Math.round(ageDays)}d old — still early.` });
+ risk += 10;
+ } else {
+ factors.push({ label: 'Age', status: 'low', detail: `Pair is ${fmtAge(ageMs)} old — established.` });
+ }
+
+ // 3) Float vs. depth — a huge cap on thin liquidity is easy to swing/dump.
+ const cap = m.market_cap_usd;
+ if (cap != null && liq) {
+ const ratio = cap / liq;
+ if (ratio > 100) {
+ factors.push({ label: 'Float', status: 'high', detail: `Cap is ${Math.round(ratio)}× liquidity — thin float, easy to swing.` });
+ risk += 16;
+ } else if (ratio > 30) {
+ factors.push({ label: 'Float', status: 'medium', detail: `Cap is ${Math.round(ratio)}× liquidity.` });
+ risk += 7;
+ } else {
+ factors.push({ label: 'Float', status: 'low', detail: `Cap is ${ratio.toFixed(1)}× liquidity — well backed.` });
+ }
+ }
+
+ // 4) Order flow — are the trades net buys or net sells over 24 h?
+ const buys = m.txns_24h?.buys;
+ const sells = m.txns_24h?.sells;
+ if (buys != null && sells != null && buys + sells > 0) {
+ const sellShare = sells / (buys + sells);
+ if (sellShare > 0.62) {
+ factors.push({ label: 'Flow', status: 'high', detail: `${Math.round(sellShare * 100)}% of 24 h trades are sells — net distribution.` });
+ risk += 12;
+ } else if (sellShare < 0.4) {
+ factors.push({ label: 'Flow', status: 'low', detail: `${Math.round((1 - sellShare) * 100)}% of 24 h trades are buys — net accumulation.` });
+ } else {
+ factors.push({ label: 'Flow', status: 'medium', detail: 'Buy/sell flow is roughly balanced.' });
+ }
+ }
+
+ const score = Math.max(0, Math.min(100, Math.round(risk)));
+ const level = score >= 70 ? 'critical' : score >= 45 ? 'high' : score >= 22 ? 'medium' : 'low';
+ const summary =
+ level === 'critical' ? `${sym} carries critical risk — treat any position as speculative.`
+ : level === 'high' ? `${sym} shows elevated risk; size positions with care.`
+ : level === 'medium' ? `${sym} carries moderate risk — normal memecoin caution applies.`
+ : `${sym} clears the basic depth, age, and flow checks.`;
+
+ return { score, level, summary, factors };
+}
+
/**
* Build a bullish/bearish/neutral signal from market data, branded to the
* token's own symbol. Mirrors the $THREE oracle thresholds so the generated
@@ -116,6 +236,26 @@ export function buildTokenSignal(m) {
: turnover > 1 ? 'Volume is healthy against liquidity; participation is real.'
: 'Volume is light against liquidity; the move has limited backing so far.';
+ // Order-flow clause — buy/sell skew over 24 h, when DexScreener reports txns.
+ const buys = m.txns_24h?.buys;
+ const sells = m.txns_24h?.sells;
+ const pressureLine =
+ buys != null && sells != null && buys + sells > 0
+ ? sells / (buys + sells) > 0.6 ? ' Sellers dominate the tape.'
+ : buys / (buys + sells) > 0.6 ? ' Buyers dominate the tape.'
+ : ' Tape is two-sided.'
+ : '';
+
+ // Acceleration clause — compare the latest hour to the 24 h trend so the
+ // rationale flags a move that is fading or reversing, not just its endpoint.
+ const h1 = m.momentum?.h1;
+ const accelLine =
+ h1 == null ? ''
+ : change > 1 && h1 < -0.5 ? ' Momentum is cooling in the last hour.'
+ : change < -1 && h1 > 0.5 ? ' It is bouncing in the last hour.'
+ : change > 1 && h1 > 1 ? ' The last hour confirms the trend.'
+ : '';
+
let signal, headline;
if (change > 5) {
signal = 'bullish';
@@ -134,7 +274,7 @@ export function buildTokenSignal(m) {
headline = `${sym} flat at ${cStr} — consolidating at ${pStr}`;
}
- const rationale = `${sym} is ${change >= 0 ? 'up' : 'down'} ${cStr} over 24 h, trading at ${pStr}. ${flowLine}`;
+ const rationale = `${sym} is ${change >= 0 ? 'up' : 'down'} ${cStr} over 24 h, trading at ${pStr}. ${flowLine}${pressureLine}${accelLine}`;
const confidence = Math.min(0.93, 0.64 + Math.min(Math.abs(change) / 20, 0.29));
return { signal, headline, rationale, confidence };
}
diff --git a/api/ca2x402/resolve.js b/api/ca2x402/resolve.js
index a4aa2ea86..2774cc5cc 100644
--- a/api/ca2x402/resolve.js
+++ b/api/ca2x402/resolve.js
@@ -24,6 +24,7 @@ import { env } from '../_lib/env.js';
import {
fetchTokenMarket,
buildTokenSignal,
+ buildTokenRisk,
isResolvableAddress,
chainOf,
} from '../_lib/token-market.js';
@@ -112,6 +113,7 @@ async function handler(req, res) {
}
const signal = market.change_24h != null ? buildTokenSignal(market) : null;
+ const risk = buildTokenRisk(market);
const origin = originOf(req);
const endpointUrl = `${origin}${ENDPOINT_PATH}?mint=${encodeURIComponent(market.mint)}`;
@@ -129,10 +131,12 @@ async function handler(req, res) {
market_cap_usd: market.market_cap_usd,
liquidity_usd: market.liquidity_usd,
volume_24h_usd: market.volume_24h_usd,
+ momentum: market.momentum,
signal: signal?.signal ?? null,
headline: signal?.headline ?? null,
rationale: signal?.rationale ?? null,
confidence: signal?.confidence ?? null,
+ risk,
};
const service = {
diff --git a/api/marketplace/analytics.js b/api/marketplace/analytics.js
index eb0f22bbd..9028957df 100644
--- a/api/marketplace/analytics.js
+++ b/api/marketplace/analytics.js
@@ -89,6 +89,28 @@ export default wrap(async (req, res) => {
WHERE skill_nft_mint IS NOT NULL
`;
+ // ── Recent sales feed (latest individual purchases) ──────────────────────
+ // Powers the marketplace "live pulse" ticker — social proof that the market
+ // is liquid. No PII: we expose the agent (the seller, already public) and the
+ // skill + amount, never the buyer's identity or wallet.
+ const recentSales = await sql`
+ SELECT
+ sp.skill,
+ sp.agent_id,
+ ai.name AS agent_name,
+ ai.profile_image_url AS agent_image,
+ sp.amount,
+ sp.currency_mint,
+ sp.status,
+ sp.confirmed_at
+ FROM skill_purchases sp
+ JOIN agent_identities ai ON ai.id = sp.agent_id
+ WHERE sp.status IN ('confirmed', 'trial')
+ AND sp.confirmed_at IS NOT NULL
+ ORDER BY sp.confirmed_at DESC
+ LIMIT 16
+ `;
+
return json(res, 200, {
data: {
summary: {
@@ -121,6 +143,16 @@ export default wrap(async (req, res) => {
volumeAtomic: String(r.volume_atomic ?? 0),
currencyMint: r.currency_mint,
})),
+ recentSales: recentSales.map(r => ({
+ skill: r.skill,
+ agentId: r.agent_id,
+ agentName: r.agent_name,
+ agentImage: r.agent_image,
+ amountAtomic: String(r.amount ?? 0),
+ currencyMint: r.currency_mint,
+ trial: r.status === 'trial',
+ confirmedAt: r.confirmed_at ? new Date(r.confirmed_at).toISOString() : null,
+ })),
},
});
});
diff --git a/api/x402/token-intel.js b/api/x402/token-intel.js
index 5047d5d16..ffeb13def 100644
--- a/api/x402/token-intel.js
+++ b/api/x402/token-intel.js
@@ -19,7 +19,7 @@ import { buildBazaarSchema } from '../_lib/x402-spec.js';
import { installAccessControl } from '../_lib/x402/access-control.js';
import { withService } from '../_lib/x402/bazaar-helpers.js';
import { priceFor } from '../_lib/x402-prices.js';
-import { fetchTokenMarket, buildTokenSignal, isResolvableAddress } from '../_lib/token-market.js';
+import { fetchTokenMarket, buildTokenSignal, buildTokenRisk, isResolvableAddress } from '../_lib/token-market.js';
const ROUTE = '/api/x402/token-intel';
@@ -47,7 +47,7 @@ export const INPUT_SCHEMA = {
export const OUTPUT_SCHEMA = {
$schema: 'https://json-schema.org/draft/2020-12/schema',
type: 'object',
- required: ['mint', 'signal', 'headline', 'rationale', 'confidence', 'ts'],
+ required: ['mint', 'signal', 'headline', 'rationale', 'confidence', 'risk', 'ts'],
properties: {
mint: { type: 'string' },
symbol: { type: ['string', 'null'] },
@@ -58,10 +58,41 @@ export const OUTPUT_SCHEMA = {
market_cap_usd: { type: ['number', 'null'] },
liquidity_usd: { type: ['number', 'null'] },
volume_24h_usd: { type: ['number', 'null'] },
+ momentum: {
+ type: 'object',
+ description: 'Price change (%) per window — m5, h1, h6, h24.',
+ properties: {
+ m5: { type: ['number', 'null'] },
+ h1: { type: ['number', 'null'] },
+ h6: { type: ['number', 'null'] },
+ h24: { type: ['number', 'null'] },
+ },
+ },
signal: { type: 'string', enum: ['bullish', 'bearish', 'neutral'] },
headline: { type: 'string' },
rationale: { type: 'string' },
confidence: { type: 'number', minimum: 0, maximum: 1 },
+ risk: {
+ type: 'object',
+ description: 'Due-diligence risk score (0 safe … 100 critical) with the factors behind it.',
+ required: ['score', 'level', 'summary', 'factors'],
+ properties: {
+ score: { type: 'integer', minimum: 0, maximum: 100 },
+ level: { type: 'string', enum: ['low', 'medium', 'high', 'critical'] },
+ summary: { type: 'string' },
+ factors: {
+ type: 'array',
+ items: {
+ type: 'object',
+ properties: {
+ label: { type: 'string' },
+ status: { type: 'string', enum: ['low', 'medium', 'high', 'critical', 'unknown'] },
+ detail: { type: 'string' },
+ },
+ },
+ },
+ },
+ },
ts: { type: 'string', format: 'date-time' },
},
};
@@ -81,10 +112,22 @@ export const BAZAAR = {
symbol: 'THREE', name: 'three.ws', chain: 'solana',
price_usd: 0.003685, change_24h: 12.4, market_cap_usd: 3685000,
liquidity_usd: 412000, volume_24h_usd: 1268079,
+ momentum: { m5: 0.3, h1: 1.8, h6: 6.1, h24: 12.4 },
signal: 'bullish',
headline: 'THREE climbs +12.40% — moderate upside',
- rationale: 'THREE is up +12.40% over 24 h, trading at $0.003685. Volume is healthy against liquidity; participation is real.',
- confidence: 0.86, ts: '2026-06-12T10:00:00Z',
+ rationale: 'THREE is up +12.40% over 24 h, trading at $0.003685. Volume is healthy against liquidity; participation is real. Buyers dominate the tape. The last hour confirms the trend.',
+ confidence: 0.86,
+ risk: {
+ score: 8, level: 'low',
+ summary: 'THREE clears the basic depth, age, and flow checks.',
+ factors: [
+ { label: 'Liquidity', status: 'low', detail: '$412,000 pooled — healthy depth.' },
+ { label: 'Age', status: 'low', detail: 'Pair is 240d old — established.' },
+ { label: 'Float', status: 'low', detail: 'Cap is 8.9× liquidity — well backed.' },
+ { label: 'Flow', status: 'low', detail: '63% of 24 h trades are buys — net accumulation.' },
+ ],
+ },
+ ts: '2026-06-12T10:00:00Z',
},
},
schema: buildBazaarSchema({
@@ -129,6 +172,7 @@ export default paidEndpoint({
}
const { signal, headline, rationale, confidence } = buildTokenSignal(live);
+ const risk = buildTokenRisk(live);
return {
mint: live.mint,
symbol: live.symbol,
@@ -139,10 +183,12 @@ export default paidEndpoint({
market_cap_usd: live.market_cap_usd,
liquidity_usd: live.liquidity_usd,
volume_24h_usd: live.volume_24h_usd,
+ momentum: live.momentum,
signal,
headline,
rationale,
confidence,
+ risk,
ts: new Date().toISOString(),
};
},
diff --git a/data/changelog.json b/data/changelog.json
index e4e4cf195..e3300cda4 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-26",
+ "title": "Fixed: the Animation Gallery footer no longer covers the page",
+ "summary": "The /animations page had a layout bug where the site footer was being pulled up and painted on top of the gallery — the hero, search bar, and animation cards ended up hidden behind it. The footer now sits where it belongs, at the bottom of the page, so the full motion library is visible and browsable again.",
+ "tags": ["fix"],
+ "link": "/animations"
+ },
{
"date": "2026-06-26",
"title": "The post-create screen now greets you with a living agent",
diff --git a/pages/animations.html b/pages/animations.html
index 48c2e4bb2..75b144515 100644
--- a/pages/animations.html
+++ b/pages/animations.html
@@ -497,9 +497,7 @@
</div>
</main>
- <footer>
- <div id="footer-container"></div>
- </footer>
+ <div id="footer-container"></div>
<script src="/footer.js" defer></script>
<script type="module" src="/src/animations-gallery.js"></script>
diff --git a/pages/marketplace.html b/pages/marketplace.html
index 5b25500ab..2f08e1d97 100644
--- a/pages/marketplace.html
+++ b/pages/marketplace.html
@@ -2957,6 +2957,21 @@
<div class="market-tag-banner" id="market-tag-banner" role="status" hidden></div>
+ <aside
+ class="market-pulse"
+ id="market-pulse"
+ aria-label="Recent marketplace sales"
+ hidden
+ >
+ <div class="market-pulse-label">
+ <span class="market-pulse-dot" aria-hidden="true"></span>
+ Live sales
+ </div>
+ <div class="market-pulse-viewport">
+ <div class="market-pulse-track" id="market-pulse-track"></div>
+ </div>
+ </aside>
+
<div class="market-grid" id="market-grid"></div>
<div class="market-loadmore" id="market-loadmore-row" hidden>
<button id="market-loadmore" hidden>Load more</button>
diff --git a/public/changelog.json b/public/changelog.json
index 4b938caff..707717c58 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-26T04:31:58.208Z",
+ "generated_at": "2026-06-26T04:50:26.091Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -60,6 +60,16 @@
"improvement"
]
},
+ {
+ "date": "2026-06-26",
+ "type": "update",
+ "title": "Fixed: the Animation Gallery footer no longer covers the page",
+ "summary": "The /animations page had a layout bug where the site footer was being pulled up and painted on top of the gallery — the hero, search bar, and animation cards ended up hidden behind it. The footer now sits where it belongs, at the bottom of the page, so the full motion library is visible and browsable again.",
+ "link": "/animations",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-26",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 75bf676c1..512aa43ad 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -46,6 +46,14 @@
<category>feature</category>
<description>The walking-avatar embed you drop onto any site is now friendlier and lighter. Visitors can tap or click the ground to send the avatar walking there — no joystick required — and a one-time on-screen hint appears so first-timers actually discover the controls. Turn on a Gestures option and they get wave and jump buttons too. On desktop the avatar gently turns to face your cursor when it's standing still, so a hovered embed feels alive. While the 3D model loads, a soft silhouette stands in instead of a blank gap. The embed now pauses itself the moment it scrolls out of view or its tab is hidden, so it never drains a laptop battery in the background, and it respects your system 'reduce motion' setting. Every embed carries a small, tasteful three.ws badge that links home — removable with one toggle. The embed editor adds matching controls: walk speed, ground on/off, gestures, the badge toggle, and a Responsive option that emits a fluid snippet that fills its container on any screen.</description>
</item>
+ <item>
+ <title>Fixed: the Animation Gallery footer no longer covers the page</title>
+ <link>https://three.ws/animations</link>
+ <guid isPermaLink="false">2026-06-26:Fixed: the Animation Gallery footer no longer covers the page</guid>
+ <pubDate>Fri, 26 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The /animations page had a layout bug where the site footer was being pulled up and painted on top of the gallery — the hero, search bar, and animation cards ended up hidden behind it. The footer now sits where it belongs, at the bottom of the page, so the full motion library is visible and browsable again.</description>
+ </item>
<item>
<title>Living Worlds video generator is back online</title>
<link>https://three.ws/cosmos</link>
diff --git a/public/features.json b/public/features.json
index b47a5bfbf..d395306a2 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-26T04:31:58.191Z",
+ "generated_at": "2026-06-26T04:50:26.073Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/viewer.js b/src/viewer.js
index 2c0fb101a..188e7a629 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -22,6 +22,7 @@ import {
WebGLRenderer,
LinearToneMapping,
ACESFilmicToneMapping,
+ NeutralToneMapping,
} from 'three';
import Stats from 'three/addons/libs/stats.module.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
@@ -136,11 +137,16 @@ export class Viewer {
grid: false,
autoRotate: false,
- // Lights
+ // Lights — studio three-point rig (key + fill + rim) plus ambient
+ // base, lit by the Khronos PBR-Neutral tone mapper. Neutral keeps
+ // midtone brightness and saturation instead of crushing them the way
+ // ACES/Linear do, so auto-generated avatars read bright and true
+ // rather than dark and muddy in gallery cards. See updateLights() and
+ // viewer/lights.js for how the rig is assembled.
punctualLights: true,
exposure: 0.0,
- toneMapping: LinearToneMapping,
- ambientIntensity: 0.3,
+ toneMapping: NeutralToneMapping,
+ ambientIntensity: 0.45,
ambientColor: '#FFFFFF',
// The 0.8 * π factor compensates for three.js's historical
// `irradiance *= PI` step on punctual lights and keeps direct
@@ -149,6 +155,16 @@ export class Viewer {
// question; removing π would require a shader-side adjustment.
directIntensity: 0.8 * Math.PI,
directColor: '#FFFFFF',
+ // Fill softens the key's shadow side; rim/back light carves the
+ // silhouette out of dark backdrops so even a black-clad avatar never
+ // disappears into a black card. Ratios are relative to directIntensity.
+ fillRatio: 0.4,
+ fillColor: '#DCE6FF',
+ rimRatio: 0.65,
+ rimColor: '#FFFFFF',
+ // Image-based lighting strength (RoomEnvironment / HDRI). >1 lifts the
+ // ambient PBR response without washing out direct highlights.
+ environmentIntensity: 1.15,
bgColor: '#000000',
transparentBg: false,
@@ -225,7 +241,9 @@ export class Viewer {
this._composer = new EffectComposer(this.renderer);
this._renderPass = new RenderPass(this.scene, this.activeCamera);
this._composer.addPass(this._renderPass);
- const vignetteEffect = new VignetteEffect({ offset: 0.35, darkness: 0.4 });
+ // Gentle vignette — pulls focus to the avatar without darkening the small
+ // gallery thumbnails. Lower darkness + wider offset keeps the body lit.
+ const vignetteEffect = new VignetteEffect({ offset: 0.5, darkness: 0.22 });
const bloomEffect = new BloomEffect({
intensity: 0.6,
luminanceThreshold: 0.8,
@@ -1229,11 +1247,35 @@ export class Viewer {
this.renderer.toneMapping = Number(state.toneMapping);
this.renderer.toneMappingExposure = Math.pow(2, state.exposure);
- if (lights.length === 2) {
- lights[0].intensity = state.ambientIntensity;
- lights[0].color.set(state.ambientColor);
- lights[1].intensity = state.directIntensity;
- lights[1].color.set(state.directColor);
+ // Image-based lighting strength (RoomEnvironment / HDRI). Supported by
+ // three r163+; guarded so older peers degrade to the baseline response.
+ if (this.scene && 'environmentIntensity' in this.scene) {
+ this.scene.environmentIntensity = state.environmentIntensity ?? 1.0;
+ }
+
+ // Keep the studio rig in sync with GUI / scene-pref edits, addressing
+ // each light by name so the rig can grow without re-indexing.
+ for (const light of lights) {
+ switch (light.name) {
+ case 'ambient_light':
+ light.intensity = state.ambientIntensity;
+ light.color.set(state.ambientColor);
+ break;
+ case 'main_light':
+ light.intensity = state.directIntensity;
+ light.color.set(state.directColor);
+ break;
+ case 'fill_light':
+ light.intensity = state.directIntensity * (state.fillRatio ?? 0.4);
+ light.color.set(state.fillColor ?? '#DCE6FF');
+ break;
+ case 'rim_light':
+ light.intensity = state.directIntensity * (state.rimRatio ?? 0.65);
+ light.color.set(state.rimColor ?? '#FFFFFF');
+ break;
+ default:
+ break;
+ }
}
this.invalidate();
@@ -1541,15 +1583,21 @@ export class Viewer {
});
[
lightFolder.add(this.state, 'toneMapping', {
+ Neutral: NeutralToneMapping,
Linear: LinearToneMapping,
'ACES Filmic': ACESFilmicToneMapping,
}),
lightFolder.add(this.state, 'punctualLights').listen(),
+ lightFolder.add(this.state, 'environmentIntensity', 0, 3).name('IBL intensity'),
lightFolder.add(this.state, 'ambientIntensity', 0, 2),
lightFolder.addColor(this.state, 'ambientColor'),
// Slider range tracks the π-scaled default above (see #116 note).
lightFolder.add(this.state, 'directIntensity', 0, 4),
lightFolder.addColor(this.state, 'directColor'),
+ lightFolder.add(this.state, 'fillRatio', 0, 1).name('fill'),
+ lightFolder.addColor(this.state, 'fillColor'),
+ lightFolder.add(this.state, 'rimRatio', 0, 1.5).name('rim'),
+ lightFolder.addColor(this.state, 'rimColor'),
].forEach((ctrl) => ctrl.onChange(() => this.updateLights()));
// Light Probe Grid controls.
diff --git a/src/viewer/lights.js b/src/viewer/lights.js
index 98a32f2ef..ae8a86ac7 100644
--- a/src/viewer/lights.js
+++ b/src/viewer/lights.js
@@ -12,19 +12,39 @@ export function addLights(viewer) {
return;
}
- const light1 = new AmbientLight(state.ambientColor, state.ambientIntensity);
- light1.name = 'ambient_light';
- viewer.defaultCamera.add(light1);
+ // Studio three-point rig. Ambient, key and fill ride the camera so the
+ // avatar stays evenly lit from the viewer's angle as it orbits; the rim/back
+ // light is anchored in world space behind-and-above the subject to keep a
+ // consistent edge highlight that separates dark avatars from dark cards.
+ const ambient = new AmbientLight(state.ambientColor, state.ambientIntensity);
+ ambient.name = 'ambient_light';
+ viewer.defaultCamera.add(ambient);
- const light2 = new DirectionalLight(state.directColor, state.directIntensity);
- light2.position.set(0.5, 0, 0.866); // ~60º
- light2.name = 'main_light';
- viewer.defaultCamera.add(light2);
+ const key = new DirectionalLight(state.directColor, state.directIntensity);
+ key.position.set(0.5, 0.6, 0.866); // upper front-right, ~60º
+ key.name = 'main_light';
+ viewer.defaultCamera.add(key);
- viewer.lights.push(light1, light2);
+ const fill = new DirectionalLight(
+ state.fillColor ?? '#DCE6FF',
+ state.directIntensity * (state.fillRatio ?? 0.4),
+ );
+ fill.position.set(-0.9, 0.1, 0.6); // opposite side, near eye level
+ fill.name = 'fill_light';
+ viewer.defaultCamera.add(fill);
+
+ const rim = new DirectionalLight(
+ state.rimColor ?? '#FFFFFF',
+ state.directIntensity * (state.rimRatio ?? 0.65),
+ );
+ rim.position.set(-1.2, 2.4, -2.6); // behind-above, throws a hair/shoulder edge
+ rim.name = 'rim_light';
+ viewer.scene.add(rim);
+
+ viewer.lights.push(ambient, key, fill, rim);
}
export function removeLights(viewer) {
- viewer.lights.forEach((light) => light.parent.remove(light));
+ viewer.lights.forEach((light) => light.parent?.remove(light));
viewer.lights.length = 0;
}