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: marketplace expansion, dragon section, home page overhaul, ERC-8004 chain updates

nirholas00348a374d5a
diff --git a/api/_lib/erc8004-chains.js b/api/_lib/erc8004-chains.js
index 43ee3cb9d..e233dcd0f 100644
--- a/api/_lib/erc8004-chains.js
+++ b/api/_lib/erc8004-chains.js
@@ -21,7 +21,13 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://basescan.org',
- rpcUrl: 'https://mainnet.base.org',
+ rpcUrls: [
+ 'https://mainnet.base.org',
+ 'https://base.llamarpc.com',
+ 'https://rpc.ankr.com/base',
+ 'https://base.publicnode.com',
+ 'https://1rpc.io/base',
+ ],
},
{
id: 42161,
@@ -29,7 +35,12 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://arbiscan.io',
- rpcUrl: 'https://arb1.arbitrum.io/rpc',
+ rpcUrls: [
+ 'https://arb1.arbitrum.io/rpc',
+ 'https://arbitrum.llamarpc.com',
+ 'https://rpc.ankr.com/arbitrum',
+ 'https://arbitrum.publicnode.com',
+ ],
},
{
id: 56,
@@ -37,7 +48,12 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://bscscan.com',
- rpcUrl: 'https://bsc-dataseed1.binance.org',
+ rpcUrls: [
+ 'https://bsc-dataseed1.binance.org',
+ 'https://bsc-dataseed2.binance.org',
+ 'https://rpc.ankr.com/bsc',
+ 'https://bsc.publicnode.com',
+ ],
},
{
id: 1,
@@ -45,7 +61,13 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://etherscan.io',
- rpcUrl: 'https://eth.llamarpc.com',
+ rpcUrls: [
+ 'https://eth.llamarpc.com',
+ 'https://cloudflare-eth.com',
+ 'https://rpc.ankr.com/eth',
+ 'https://ethereum.publicnode.com',
+ 'https://1rpc.io/eth',
+ ],
},
{
id: 10,
@@ -53,7 +75,12 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://optimistic.etherscan.io',
- rpcUrl: 'https://mainnet.optimism.io',
+ rpcUrls: [
+ 'https://mainnet.optimism.io',
+ 'https://optimism.llamarpc.com',
+ 'https://rpc.ankr.com/optimism',
+ 'https://optimism.publicnode.com',
+ ],
},
{
id: 137,
@@ -61,7 +88,12 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://polygonscan.com',
- rpcUrl: 'https://polygon-rpc.com',
+ rpcUrls: [
+ 'https://polygon-rpc.com',
+ 'https://polygon.llamarpc.com',
+ 'https://rpc.ankr.com/polygon',
+ 'https://polygon.publicnode.com',
+ ],
},
{
id: 43114,
@@ -69,7 +101,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://snowtrace.io',
- rpcUrl: 'https://api.avax.network/ext/bc/C/rpc',
+ rpcUrls: ['https://api.avax.network/ext/bc/C/rpc', 'https://rpc.ankr.com/avalanche'],
},
{
id: 100,
@@ -77,7 +109,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://gnosisscan.io',
- rpcUrl: 'https://rpc.gnosischain.com',
+ rpcUrls: ['https://rpc.gnosischain.com', 'https://rpc.ankr.com/gnosis'],
},
{
id: 250,
@@ -85,7 +117,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://ftmscan.com',
- rpcUrl: 'https://rpc.ankr.com/fantom',
+ rpcUrls: ['https://rpc.ankr.com/fantom', 'https://rpcapi.fantom.network'],
},
{
id: 42220,
@@ -93,7 +125,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://celoscan.io',
- rpcUrl: 'https://forno.celo.org',
+ rpcUrls: ['https://forno.celo.org', 'https://rpc.ankr.com/celo'],
},
{
id: 59144,
@@ -101,7 +133,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://lineascan.build',
- rpcUrl: 'https://rpc.linea.build',
+ rpcUrls: ['https://rpc.linea.build', 'https://linea.drpc.org'],
},
{
id: 534352,
@@ -109,7 +141,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://scrollscan.com',
- rpcUrl: 'https://rpc.scroll.io',
+ rpcUrls: ['https://rpc.scroll.io', 'https://rpc.ankr.com/scroll'],
},
{
id: 5000,
@@ -117,7 +149,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://explorer.mantle.xyz',
- rpcUrl: 'https://rpc.mantle.xyz',
+ rpcUrls: ['https://rpc.mantle.xyz', 'https://mantle.drpc.org'],
},
{
id: 324,
@@ -125,7 +157,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://explorer.zksync.io',
- rpcUrl: 'https://mainnet.era.zksync.io',
+ rpcUrls: ['https://mainnet.era.zksync.io', 'https://zksync.drpc.org'],
},
{
id: 1284,
@@ -133,7 +165,7 @@ export const CHAINS = [
testnet: false,
registry: IDENTITY_REGISTRY_MAINNET,
explorer: 'https://moonbeam.moonscan.io',
- rpcUrl: 'https://rpc.api.moonbeam.network',
+ rpcUrls: ['https://rpc.api.moonbeam.network', 'https://rpc.ankr.com/moonbeam'],
},
{
id: 97,
@@ -141,7 +173,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://testnet.bscscan.com',
- rpcUrl: 'https://data-seed-prebsc-1-s1.bnbchain.org:8545',
+ rpcUrls: ['https://data-seed-prebsc-1-s1.bnbchain.org:8545', 'https://data-seed-prebsc-2-s1.bnbchain.org:8545'],
},
{
id: 84532,
@@ -149,7 +181,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://sepolia.basescan.org',
- rpcUrl: 'https://sepolia.base.org',
+ rpcUrls: ['https://sepolia.base.org', 'https://base-sepolia-rpc.publicnode.com', 'https://rpc.ankr.com/base_sepolia'],
},
{
id: 421614,
@@ -157,7 +189,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://sepolia.arbiscan.io',
- rpcUrl: 'https://sepolia-rollup.arbitrum.io/rpc',
+ rpcUrls: ['https://sepolia-rollup.arbitrum.io/rpc', 'https://arbitrum-sepolia.publicnode.com'],
},
{
id: 11155111,
@@ -165,7 +197,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://sepolia.etherscan.io',
- rpcUrl: 'https://rpc2.sepolia.org',
+ rpcUrls: ['https://rpc2.sepolia.org', 'https://ethereum-sepolia-rpc.publicnode.com', 'https://rpc.ankr.com/eth_sepolia'],
},
{
id: 11155420,
@@ -173,7 +205,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://sepolia-optimism.etherscan.io',
- rpcUrl: 'https://sepolia.optimism.io',
+ rpcUrls: ['https://sepolia.optimism.io', 'https://optimism-sepolia.publicnode.com'],
},
{
id: 80002,
@@ -181,7 +213,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://amoy.polygonscan.com',
- rpcUrl: 'https://rpc-amoy.polygon.technology',
+ rpcUrls: ['https://rpc-amoy.polygon.technology', 'https://polygon-amoy.drpc.org'],
},
{
id: 43113,
@@ -189,7 +221,7 @@ export const CHAINS = [
testnet: true,
registry: IDENTITY_REGISTRY_TESTNET,
explorer: 'https://testnet.snowtrace.io',
- rpcUrl: 'https://api.avax-test.network/ext/bc/C/rpc',
+ rpcUrls: ['https://api.avax-test.network/ext/bc/C/rpc', 'https://rpc.ankr.com/avalanche_fuji'],
},
];
diff --git a/api/_lib/x402-paid-endpoint.js b/api/_lib/x402-paid-endpoint.js
index 6a0ea42a1..46ba03cbe 100644
--- a/api/_lib/x402-paid-endpoint.js
+++ b/api/_lib/x402-paid-endpoint.js
@@ -367,14 +367,21 @@ export function paidEndpoint(spec) {
// `requirements[].network` lists every CAIP-2 chain we'll accept a
// signature for — the upstream helper turns it into supportedChains
// and enriches the info block (domain/uri/nonce/issuedAt) per request.
- const siwxExtensions = siwx
- ? await declareSiwxExtensionFor({
+ // Wrapped in try-catch: a failure here must never surface as 500 — the
+ // 402 challenge is still valid without the SIWX extension.
+ let siwxExtensions = null;
+ if (siwx) {
+ try {
+ siwxExtensions = await declareSiwxExtensionFor({
networks: requirements.map((r) => r.network),
resourceUrl,
statement: siwx.statement,
expirationSeconds: siwx.expirationSeconds,
- })
- : null;
+ });
+ } catch (err) {
+ console.error('[paidEndpoint] declareSiwxExtensionFor failed', err?.message || err);
+ }
+ }
const extraExtensions = {
[PAYMENT_IDENTIFIER]: pidExtension,
@@ -388,12 +395,16 @@ export function paidEndpoint(spec) {
// null — we never want a missing signing key to break the 402 dance,
// since the protocol stays valid without the extension.
if (offerReceipt !== false) {
- const offersFragment = await buildOffersExtension(
- resourceUrl,
- requirements,
- offerReceipt || {},
- );
- if (offersFragment) Object.assign(extraExtensions, offersFragment);
+ try {
+ const offersFragment = await buildOffersExtension(
+ resourceUrl,
+ requirements,
+ offerReceipt || {},
+ );
+ if (offersFragment) Object.assign(extraExtensions, offersFragment);
+ } catch (err) {
+ console.error('[paidEndpoint] buildOffersExtension failed', err?.message || err);
+ }
}
const challenge = {
diff --git a/api/agents/onchain/[action].js b/api/agents/onchain/[action].js
index 83e336f55..7f7dcf3ab 100644
--- a/api/agents/onchain/[action].js
+++ b/api/agents/onchain/[action].js
@@ -355,9 +355,10 @@ const confirmBodySchema = z.object({
async function verifyEvm({ chainId, txHash, expectedContract, expectedOwner }) {
const { CHAIN_BY_ID } = await import('../../_lib/erc8004-chains.js');
const cfg = CHAIN_BY_ID[chainId];
- if (!cfg?.rpcUrl) throw new Error(`no RPC for chainId ${chainId}`);
+ const rpcUrl = cfg?.rpcUrls?.[0] ?? cfg?.rpcUrl;
+ if (!rpcUrl) throw new Error(`no RPC for chainId ${chainId}`);
- const provider = new JsonRpcProvider(cfg.rpcUrl);
+ const provider = new JsonRpcProvider(rpcUrl);
const receipt = await provider.getTransactionReceipt(txHash);
if (!receipt) {
const e = new Error('Transaction not found yet — try again in a few seconds.');
diff --git a/api/chat.js b/api/chat.js
index 935f47a24..c5d31b958 100644
--- a/api/chat.js
+++ b/api/chat.js
@@ -24,9 +24,9 @@ import { limits, clientIp } from './_lib/rate-limit.js';
import { loadUserProviderKeys } from './_lib/provider-keys.js';
import { z } from 'zod';
-// Providers anonymous (unauthenticated) callers may use. Groq's free tier is
-// the only one we expose without sign-in — paid keys stay gated behind auth.
-const ANON_PROVIDERS = new Set(['groq']);
+// Providers anonymous (unauthenticated) callers may use. Groq and OpenRouter
+// free-tier models are exposed without sign-in — paid keys stay gated behind auth.
+const ANON_PROVIDERS = new Set(['groq', 'openrouter']);
export const maxDuration = 60;
@@ -214,6 +214,25 @@ const ACTION_TOOLS = [
description: 'Get the latest trades from pump.fun and show them in the 3D scene.',
input_schema: { type: 'object', properties: {} },
},
+ {
+ name: 'playAnimation',
+ description:
+ 'Play a named animation on the avatar. Use when the user asks to dance, wave, jump, celebrate, etc. Available clips: wave, dance, capoeira, jump, thriller, pray, idle, celebrate, rumba, falling, kiss, taunt.',
+ input_schema: {
+ type: 'object',
+ properties: {
+ name: {
+ type: 'string',
+ description: 'Animation clip name, e.g. "dance", "wave", "jump", "thriller".',
+ },
+ loop: {
+ type: 'boolean',
+ description: 'Whether to loop the animation. Dance-style clips should loop.',
+ },
+ },
+ required: ['name'],
+ },
+ },
];
const ACTION_NAMES = new Set(ACTION_TOOLS.map((t) => t.name));
@@ -264,7 +283,7 @@ export default wrap(async (req, res) => {
if (!route) {
return error(res, 503, 'chat_unavailable', 'no chat provider is configured');
}
- if (anonymous && route.name !== 'groq') {
+ if (anonymous && !ANON_PROVIDERS.has(route.name)) {
return error(res, 401, 'unauthorized', 'sign in to chat with the agent');
}
@@ -665,12 +684,22 @@ function buildSystemPrompt(ctx = {}, personaPrompt = null) {
const lines = [];
if (personaPrompt) lines.push(personaPrompt, '');
lines.push(
- 'You are the three.ws — an embodied AI assistant embedded inside a browser-native glTF/GLB viewer at three.ws.',
- 'Your job is to help the user inspect, understand, and modify the 3D scene. You have deep glTF 2.0, PBR materials, and three.js expertise.',
+ 'You are an embodied AI assistant rendered as a 3D avatar at three.ws — the platform for building, embedding, and monetising 3D AI agents.',
+ '',
+ 'three.ws platform knowledge:',
+ '- Create: Upload a selfie → photorealistic 3D avatar generated in ~60 seconds.',
+ '- Embed: <agent-3d id="..."> works on any website (React, Vue, plain HTML) with zero config.',
+ '- Earn: x402 micropayments let agents charge per chat in USDC on Base.',
+ '- Discover: Browse and chat with live agents at three.ws/agents.',
+ '- Console: Manage agents at three.ws/console.',
+ '- Voice, memory, tool use, animations, and payments are all built-in.',
+ '',
+ 'You can control animations and the scene. When the user asks you to dance, wave, jump, celebrate, etc — call the playAnimation tool IMMEDIATELY. When asked to change the background, call setBgColor with a CSS hex. When asked to change lighting, call setEnvironment.',
+ 'Available animations: wave, dance, capoeira, jump, thriller, pray, idle, celebrate, rumba, falling, kiss, taunt.',
'You can also show the latest trades from pump.fun by calling the getPumpFunTrades tool.',
- 'When the user asks you to change the viewer ("enable wireframe", "make the background dark blue", "turn on auto rotate", "load this model"), CALL the matching tool — do not just describe what would happen. Examples: user "wireframe on" → call setWireframe({value:true}). user "rotate it" → call setAutoRotate({value:true}). user "dark blue bg" → call setBgColor({value:"#0a1f44"}).',
+ 'When the user asks to change the viewer ("enable wireframe", "make the background dark blue", "turn on auto rotate", "load this model"), CALL the matching tool — do not just describe what would happen.',
'When asked about the loaded model, use the context below as ground truth. Do not invent stats.',
- 'Keep replies tight: 1–3 sentences. Plain text, no markdown headers, no emoji.',
+ 'Keep replies tight: 2–3 sentences. Plain text, no markdown headers, no emoji.',
'',
loaded,
validation,
diff --git a/api/cron/[name].js b/api/cron/[name].js
index 966b10b7e..c1b222dc9 100644
--- a/api/cron/[name].js
+++ b/api/cron/[name].js
@@ -149,7 +149,7 @@ async function erc8004CrawlChain(chain) {
SELECT last_block FROM erc8004_crawl_cursor WHERE chain_id = ${chain.id}
`;
- const latestHex = await erc8004RpcCall(chain.rpcUrl, 'eth_blockNumber', []);
+ const latestHex = await erc8004RpcCall(chain.rpcUrls ?? chain.rpcUrl, 'eth_blockNumber', []);
const latestBlock = Number.parseInt(latestHex, 16);
const fromBlock = cursor
@@ -162,7 +162,7 @@ async function erc8004CrawlChain(chain) {
const toBlock = Math.min(fromBlock + ERC8004_BLOCK_CHUNK - 1, latestBlock);
- const logs = await erc8004RpcCall(chain.rpcUrl, 'eth_getLogs', [
+ const logs = await erc8004RpcCall(chain.rpcUrls ?? chain.rpcUrl, 'eth_getLogs', [
{
address: chain.registry,
topics: [REGISTERED_TOPIC],
@@ -178,7 +178,7 @@ async function erc8004CrawlChain(chain) {
await Promise.all(
uniqueBlockHexes.map(async (bn) => {
try {
- const block = await erc8004RpcCall(chain.rpcUrl, 'eth_getBlockByNumber', [bn, false]);
+ const block = await erc8004RpcCall(chain.rpcUrls ?? chain.rpcUrl, 'eth_getBlockByNumber', [bn, false]);
blockTimes[bn] = block ? Number.parseInt(block.timestamp, 16) : null;
} catch {
// registered_at will be null for this block
@@ -291,23 +291,30 @@ async function erc8004EnrichMetadata(limit) {
return done;
}
-async function erc8004RpcCall(url, method, params) {
- const ac = new AbortController();
- const t = setTimeout(() => ac.abort(), ERC8004_FETCH_TIMEOUT_MS);
- try {
- const res = await fetch(url, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
- signal: ac.signal,
- });
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
- const data = await res.json();
- if (data.error) throw new Error(`RPC ${data.error.code}: ${data.error.message}`);
- return data.result;
- } finally {
- clearTimeout(t);
+async function erc8004RpcCall(urls, method, params) {
+ const urlList = Array.isArray(urls) ? urls : [urls];
+ let lastErr;
+ for (const url of urlList) {
+ const ac = new AbortController();
+ const t = setTimeout(() => ac.abort(), ERC8004_FETCH_TIMEOUT_MS);
+ try {
+ const res = await fetch(url, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }),
+ signal: ac.signal,
+ });
+ if (!res.ok) throw new Error(`HTTP ${res.status} from ${url}`);
+ const data = await res.json();
+ if (data.error) throw new Error(`RPC ${data.error.code}: ${data.error.message}`);
+ return data.result;
+ } catch (err) {
+ lastErr = err;
+ } finally {
+ clearTimeout(t);
+ }
}
+ throw lastErr;
}
async function erc8004FetchAgentMetadata(uri) {
diff --git a/api/erc8004/register-confirm.js b/api/erc8004/register-confirm.js
index 824930a97..5bd14072a 100644
--- a/api/erc8004/register-confirm.js
+++ b/api/erc8004/register-confirm.js
@@ -30,7 +30,7 @@ export default wrap(async (req, res) => {
const body = parse(bodySchema, await readJson(req));
const chain = CHAIN_BY_ID[body.chainId];
if (!chain) return error(res, 400, 'bad_request', `unsupported chain ${body.chainId}`);
- const receipt = await rpcCall(chain.rpcUrl, 'eth_getTransactionReceipt', [body.txHash]);
+ const receipt = await rpcCall(chain.rpcUrls ?? chain.rpcUrl, 'eth_getTransactionReceipt', [body.txHash]);
if (!receipt) return error(res, 422, 'tx_not_mined', 'transaction not yet mined');
if (receipt.status === '0x0') return error(res, 422, 'tx_failed', 'transaction reverted');
const log = (receipt.logs ?? []).find(
@@ -54,23 +54,30 @@ export default wrap(async (req, res) => {
return json(res, 200, { success: true, agentId: onChainId, chainId: body.chainId });
});
-async function rpcCall(url, m, params) {
- const ac = new AbortController();
- const t = setTimeout(() => ac.abort(), TIMEOUT_MS);
- try {
- const r = await fetch(url, {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: m, params }),
- signal: ac.signal,
- });
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- const d = await r.json();
- if (d.error) throw new Error(`RPC ${d.error.code}: ${d.error.message}`);
- return d.result;
- } finally {
- clearTimeout(t);
+async function rpcCall(urls, m, params) {
+ const urlList = Array.isArray(urls) ? urls : [urls];
+ let lastErr;
+ for (const url of urlList) {
+ const ac = new AbortController();
+ const t = setTimeout(() => ac.abort(), TIMEOUT_MS);
+ try {
+ const r = await fetch(url, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: m, params }),
+ signal: ac.signal,
+ });
+ if (!r.ok) throw new Error(`HTTP ${r.status} from ${url}`);
+ const d = await r.json();
+ if (d.error) throw new Error(`RPC ${d.error.code}: ${d.error.message}`);
+ return d.result;
+ } catch (err) {
+ lastErr = err;
+ } finally {
+ clearTimeout(t);
+ }
}
+ throw lastErr;
}
function resolveGateway(uri) {
diff --git a/api/marketplace/theme.js b/api/marketplace/theme.js
index 6fbbc8ede..c294d99c0 100644
--- a/api/marketplace/theme.js
+++ b/api/marketplace/theme.js
@@ -17,15 +17,8 @@ export default wrap(async (req, res) => {
ORDER BY created_at DESC
LIMIT 1
`;
- } catch (err) {
- if (
- /relation.*does not exist|undefined_table/i.test(err.message || '') ||
- /Missing required env var/i.test(err.message || '')
- ) {
- rows = [];
- } else {
- throw err;
- }
+ } catch {
+ rows = [];
}
const theme = rows[0]
diff --git a/pages/home.html b/pages/home.html
index edee66425..20c75ec0e 100644
--- a/pages/home.html
+++ b/pages/home.html
@@ -216,38 +216,65 @@
}
/* ── STATS BAR ───────────────────────────────────────────── */
- .stats-bar {
- background: var(--surface-0);
+ /* ── CAPABILITY STRIP ──────────────────────────────────── */
+ .capability-strip {
+ position: relative;
+ overflow: hidden;
border-top: 1px solid var(--hairline);
border-bottom: 1px solid var(--hairline);
- padding: 0;
- overflow: hidden;
- }
- .stats-bar-inner {
- display: flex; align-items: stretch;
- max-width: 1440px; margin: 0 auto;
+ background: var(--surface-0);
+ padding: 13px 0;
+ cursor: default;
+ user-select: none;
}
- .stat-cell {
- flex: 1; padding: 20px 28px;
- border-right: 1px solid var(--hairline);
- display: flex; flex-direction: column; gap: 4px;
+ .capability-strip:hover .cap-track { animation-play-state: paused; }
+ .cap-track {
+ display: flex;
+ width: max-content;
+ animation: cap-scroll 55s linear infinite;
+ will-change: transform;
}
- .stat-cell:last-child { border-right: none; }
- .stat-val {
- font-family: var(--font-display); font-size: 24px;
- font-weight: 600; letter-spacing: -0.025em;
- color: var(--text); font-variant-numeric: tabular-nums;
+ .cap-inner {
+ display: flex;
+ align-items: center;
+ flex-shrink: 0;
}
- .stat-lbl {
- font-family: var(--font-mono); font-size: 11px;
- letter-spacing: 0.15em; text-transform: uppercase;
+ .cap-item {
+ font-family: var(--font-mono);
+ font-size: 11.5px;
+ letter-spacing: 0.04em;
color: var(--text-3);
+ white-space: nowrap;
+ padding: 0 2px;
+ transition: color 0.15s;
}
- @media (max-width: 860px) {
- .stats-bar-inner { flex-wrap: wrap; }
- .stat-cell { flex: 1 0 50%; border-bottom: 1px solid var(--hairline); }
+ .cap-item:hover { color: var(--text-2); }
+ .cap-sep {
+ font-size: 10px;
+ color: var(--text-4);
+ padding: 0 16px;
+ flex-shrink: 0;
+ pointer-events: none;
+ }
+ @keyframes cap-scroll {
+ from { transform: translateX(0); }
+ to { transform: translateX(-50%); }
+ }
+ .cap-fade {
+ position: absolute;
+ top: 0; bottom: 0;
+ width: 120px;
+ z-index: 2;
+ pointer-events: none;
+ }
+ .cap-fade--l {
+ left: 0;
+ background: linear-gradient(to right, var(--surface-0) 30%, transparent);
+ }
+ .cap-fade--r {
+ right: 0;
+ background: linear-gradient(to left, var(--surface-0) 30%, transparent);
}
- @media (max-width: 560px) { .stat-cell { flex: 1 0 100%; } }
/* ── LOGO STRIP ──────────────────────────────────────────── */
.logo-strip {
@@ -1064,12 +1091,6 @@
.hero-chat-send:active { transform: scale(0.92); }
.hero-chat-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.hero-chat-send svg { width: 14px; height: 14px; }
- .hero-chat-hint {
- text-align: center; margin-top: 8px;
- font-family: var(--font-mono); font-size: 10px;
- letter-spacing: 0.12em; text-transform: uppercase;
- color: var(--text-4); opacity: 0.6;
- }
@media (max-width: 980px) {
.hero-chat-bar { bottom: 20px; }
.hero-thought { top: 4%; }
@@ -2259,20 +2280,14 @@
.analytics-spark .spark-dot{fill:var(--text);r:2.5;animation:spark-pulse 2s ease-in-out infinite}
@keyframes spark-pulse{0%,100%{opacity:1}50%{opacity:.4}}
- /* ── EDITORIAL (Pretext-inspired reflow) ─────────────────── */
- .editorial-text-area{position:relative;min-height:480px;user-select:text;overflow:visible}
- .ed-line{position:absolute;white-space:nowrap;font-family:Georgia,"Iowan Old Style","Palatino Linotype",Palatino,serif;font-size:17px;line-height:28px;color:var(--text-2)}
- .ed-drop{position:absolute;font-family:Georgia,"Iowan Old Style","Palatino Linotype",Palatino,serif;font-weight:700;color:var(--text);line-height:.85;pointer-events:none}
- .editorial-orb{position:absolute;z-index:10;cursor:grab;will-change:transform;border-radius:50%;touch-action:none}
- .editorial-orb:active{cursor:grabbing}
- .editorial-orb-glow{position:absolute;inset:-24px;border-radius:50%;background:radial-gradient(circle at 35% 35%,rgba(255,255,255,.10),transparent 70%);box-shadow:0 0 60px 15px rgba(255,255,255,.05),0 0 120px 40px rgba(255,255,255,.02);pointer-events:none;animation:ed-orb-glow 6s ease-in-out infinite}
- @keyframes ed-orb-glow{0%,100%{opacity:.7}50%{opacity:1}}
- .editorial-orb-avatar{width:100%;height:100%;border-radius:50%;overflow:hidden;border:1px solid rgba(255,255,255,.12);background:var(--surface-2)}
- .editorial-orb-avatar img{width:100%;height:100%;object-fit:cover;border-radius:50%;pointer-events:none;animation:ed-avatar-breathe 4s ease-in-out infinite}
- @keyframes ed-avatar-breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.04)}}
- .editorial-hint{text-align:center;margin-top:32px;font-family:var(--font-mono);font-size:10px;letter-spacing:.18em;text-transform:uppercase;color:var(--text-4)}
- @media(max-width:720px){.editorial-hint{display:none}}
- @media(prefers-reduced-motion:reduce){.editorial-orb-glow{animation:none!important}.editorial-orb-avatar img{animation:none!important}}
+ /* ── DRAGON VISION SECTION ───────────────────────────────── */
+ .vision-block{padding-bottom:0}
+ .vision-block .block-eyebrow{margin-bottom:24px}
+ .dragon-wrap{position:relative;height:76vh;min-height:420px;max-height:880px;overflow:hidden;background:#050505;cursor:crosshair;border-top:1px solid var(--hairline)}
+ .dragon-hint{position:absolute;bottom:18px;left:50%;transform:translateX(-50%);color:rgba(255,255,255,.18);font-family:var(--font-mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;pointer-events:none;transition:opacity 1.5s ease;white-space:nowrap;z-index:5}
+ .dragon-hint.fade{opacity:0}
+ @media(max-width:720px){.dragon-wrap{height:55vh;min-height:300px}}
+ @media(prefers-reduced-motion:reduce){.dragon-wrap canvas{display:none}}
</style>
<noscript><style>.reveal{opacity:1!important;transform:none!important}.hero-text>*{opacity:1!important;transform:none!important}</style></noscript>
<script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script>
@@ -2348,7 +2363,6 @@
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2L7 9"/><path d="M14 2L9.5 14L7 9L2 6.5L14 2Z"/></svg>
</button>
</form>
- <div class="hero-chat-hint">press enter to chat</div>
</div>
<div class="stage-meta">
<span>nich</span>
@@ -2356,7 +2370,7 @@
</div>
<div class="hero-chips-wrap" id="hero-chips-wrap">
<div class="hero-chips-label">
- <span>click to animate · <strong class="hero-chips-counter" id="hero-chips-counter">0 moves</strong></span>
+ <strong class="hero-chips-counter" id="hero-chips-counter"></strong>
</div>
<div class="hero-chips" id="hero-chips" role="group" aria-label="Trigger an animation on the hero avatar">
<button type="button" class="hero-chip hero-chip--rand" data-anim="__random">🎲 Random</button>
@@ -2371,30 +2385,80 @@
</div>
</section>
-<!-- ── STATS BAR ─────────────────────────────────────────────────── -->
-<div class="stats-bar" id="stats-bar">
- <div class="stats-bar-inner">
- <div class="stat-cell">
- <div class="stat-val" id="sb-agents">—</div>
- <div class="stat-lbl">Agents live</div>
- </div>
- <div class="stat-cell">
- <div class="stat-val" id="sb-widgets">—</div>
- <div class="stat-lbl">Widgets deployed</div>
- </div>
- <div class="stat-cell">
- <div class="stat-val" id="sb-onchain">—</div>
- <div class="stat-lbl">On-chain agents</div>
+<!-- ── CAPABILITY STRIP ───────────────────────────────────────────── -->
+<div class="capability-strip" id="capability-strip" aria-hidden="true">
+ <div class="cap-fade cap-fade--l"></div>
+ <div class="cap-track">
+ <div class="cap-inner">
+ <span class="cap-item">200+ animation clips</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">1-line embed</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">GLB &amp; VRM support</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">AI agent SDK</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">On-chain payments via x402</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Solana native</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">ERC-8004 standard</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">TypeScript SDK</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Real-time sync</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">WebGL rendering</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Agent marketplace</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Pump.fun native</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Custom avatars</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Widget builder</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Sub-10ms load</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">REST + WebSockets</span>
+ <span class="cap-sep">·</span>
</div>
- <div class="stat-cell">
- <div class="stat-val">200+</div>
- <div class="stat-lbl">Animation clips</div>
- </div>
- <div class="stat-cell">
- <div class="stat-val">&lt;2 lines</div>
- <div class="stat-lbl">To embed</div>
+ <div class="cap-inner" aria-hidden="true">
+ <span class="cap-item">200+ animation clips</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">1-line embed</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">GLB &amp; VRM support</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">AI agent SDK</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">On-chain payments via x402</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Solana native</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">ERC-8004 standard</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">TypeScript SDK</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Real-time sync</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">WebGL rendering</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Agent marketplace</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Pump.fun native</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Custom avatars</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Widget builder</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">Sub-10ms load</span>
+ <span class="cap-sep">·</span>
+ <span class="cap-item">REST + WebSockets</span>
+ <span class="cap-sep">·</span>
</div>
</div>
+ <div class="cap-fade cap-fade--r"></div>
</div>
<!-- ── LOGO STRIP ────────────────────────────────────────────────── -->
@@ -2503,20 +2567,13 @@
</div>
</section>
-<!-- ── EDITORIAL (Pretext-inspired reflow) ──────────────────────── -->
-<section class="block" id="editorial">
+<!-- ── DRAGON VISION ──────────────────────────────────────────────── -->
+<section class="block vision-block" id="vision-section">
<div class="wrap-1280">
- <div class="block-head reveal">
- <p class="block-eyebrow"><span class="num">&bull;</span>The vision</p>
- <h2 class="block-h">The web wasn't built<br/>for <em>presence.</em></h2>
- </div>
- <div class="editorial-text-area reveal reveal-d1" id="editorial-text-area">
- <div class="editorial-orb" id="editorial-orb">
- <div class="editorial-orb-glow"></div>
- <div class="editorial-orb-avatar" id="editorial-orb-avatar"></div>
- </div>
- </div>
- <p class="editorial-hint reveal reveal-d2">drag the avatar through the text</p>
+ <p class="block-eyebrow reveal"><span class="num">&bull;</span>The vision</p>
+ </div>
+ <div class="dragon-wrap" id="dragon-canvas-wrap">
+ <div class="dragon-hint">move cursor &nbsp;&middot;&nbsp; hold to breathe fire</div>
</div>
</section>
@@ -2709,7 +2766,7 @@
<p class="wyg-card-eyebrow clr-amber">SNS &middot; pay-by-name</p>
<h3 class="wyg-card-title">Get paid by name.</h3>
<p class="wyg-card-body">Claim yourname.threews.sol as a Solana Name Service subdomain. Brave routes it straight to your showcase; agents pay you in USDC by name, not address. We absorb the gas.</p>
- <a href="/handle" class="wyg-card-link">Claim your subdomain</a>
+ <a href="/dashboard/account" class="wyg-card-link">Claim your subdomain</a>
</div>
</div>
</div>
@@ -3584,6 +3641,43 @@
}
return url;
}
+
+ // Fetch a pool of unique community avatar GLBs from /api/explore, cached for the page lifetime.
+ // pool[0]=WYG, pool[1]=vclose, pool[2..]=LIVE_SPOTS null entries
+ var _avatarPoolP = null;
+ var POOL_FALLBACKS = [
+ '/avatars/cz.glb',
+ '/animations/idle_female_jan25.glb',
+ '/animations/idle_male_jan25.glb',
+ '/animations/robotexpressive.glb',
+ '/animations/soldier.glb',
+ '/animations/idle_anim.glb',
+ '/animations/idle_male_jan25.glb',
+ '/animations/idle_female_jan25.glb',
+ ];
+ function getAvatarPool() {
+ if (!_avatarPoolP) {
+ _avatarPoolP = fetch(location.origin + '/api/explore?source=all&limit=16&quality=high')
+ .then(function(r) { return r.json(); })
+ .then(function(d) {
+ var items = (d.items || []);
+ var pool = items
+ .filter(function(it) { return it.glbUrl && it.avatarId !== AVATAR_ID; })
+ .map(function(it) { return devProxyGlb(it.glbUrl); })
+ .filter(Boolean);
+ var fi = 0;
+ while (pool.length < 8) {
+ pool.push(location.origin + POOL_FALLBACKS[fi++ % POOL_FALLBACKS.length]);
+ }
+ return pool;
+ })
+ .catch(function() {
+ return POOL_FALLBACKS.map(function(p) { return location.origin + p; });
+ });
+ }
+ return _avatarPoolP;
+ }
+
function spawnAgent(glbUrl) {
const el = document.createElement('agent-3d');
el.classList.add('live-agent');
@@ -3628,14 +3722,13 @@
if (!entries[0].isIntersecting) return;
wygObs.disconnect();
bootWyg();
- }, { rootMargin: '300px' });
+ }, { rootMargin: '150px' });
wygObs.observe(viewer);
function bootWyg() {
- fetch(location.origin + '/api/avatars/' + AVATAR_ID)
- .then(function(r) { return r.json(); })
- .then(function(d) {
- var glb = devProxyGlb(d.avatar?.model_url || d.avatar?.url);
+ getAvatarPool()
+ .then(function(pool) {
+ var glb = pool[0];
if (!glb) return;
var el = spawnAgent(glb);
viewer.insertBefore(el, viewer.firstChild);
@@ -3643,7 +3736,7 @@
el.addEventListener('agent:ready', function() {
el.classList.add('loaded');
if (skelEl) skelEl.style.display = 'none';
- el.playClipByName?.('idle', { loop: true, fade_ms: 400 });
+ el.play?.('idle', { loop: true, fade_ms: 400 });
var firstChip = scroll.querySelector('[data-anim="idle"]');
if (firstChip) firstChip.dataset.active = 'true';
activeChip = firstChip;
@@ -3660,13 +3753,13 @@
if (activeChip) delete activeChip.dataset.active;
btn.dataset.active = 'true';
activeChip = btn;
- wygAgent.playClipByName?.(clip, { loop: loopAnims.has(clip), fade_ms: 400 });
+ wygAgent.play?.(clip, { loop: loopAnims.has(clip), fade_ms: 400 });
});
if (stopBtn) {
stopBtn.addEventListener('click', function() {
if (!wygAgent) return;
- wygAgent.playClipByName?.('idle', { loop: true, fade_ms: 400 });
+ wygAgent.play?.('idle', { loop: true, fade_ms: 400 });
if (activeChip) delete activeChip.dataset.active;
var idleChip = scroll.querySelector('[data-anim="idle"]');
if (idleChip) idleChip.dataset.active = 'true';
@@ -3686,10 +3779,10 @@
async function walkCycle() {
await new Promise(r => setTimeout(r, 2000));
if (!active || _heroChipActive) return;
- heroAgent.playClipByName?.(WALK_CLIP, { loop: true, fade_ms: 400 });
+ heroAgent.play?.(WALK_CLIP, { loop: true, fade_ms: 400 });
await new Promise(r => setTimeout(r, 5000));
if (!active || _heroChipActive) return;
- heroAgent.playClipByName?.(IDLE_CLIP, { loop: true, fade_ms: 600 });
+ heroAgent.play?.(IDLE_CLIP, { loop: true, fade_ms: 600 });
await new Promise(r => setTimeout(r, 3000));
walkCycle();
}
@@ -3730,7 +3823,7 @@
btn.dataset.active = 'true';
_heroChipActive = true;
- heroAgent.playClipByName?.(clip, { loop: false, fade_ms: 400 });
+ heroAgent.play?.(clip, { loop: false, fade_ms: 400 });
moveCount += 1;
if (counter) counter.innerHTML = `<strong>${moveCount}</strong> ${moveCount === 1 ? 'move' : 'moves'}`;
@@ -3745,6 +3838,27 @@
// ── Hero thought-bubble chat ────────────────────────────────────
+ var HERO_SYSTEM_PROMPT = [
+ 'You are the three.ws demo avatar — a live AI agent embedded on the three.ws homepage.',
+ 'three.ws lets anyone build a 3D AI agent from a selfie in 60 seconds, embed it on any website with two lines of HTML, and earn USDC per chat using x402 micropayments.',
+ '',
+ 'Platform knowledge:',
+ '- Create: Upload a selfie → photorealistic 3D avatar in ~60 seconds.',
+ '- Embed: <agent-3d id="..."> works on any site — React, Vue, plain HTML — zero config needed.',
+ '- Earn: x402 micropayments let your agent charge per chat in USDC on Base.',
+ '- Discover: Browse and chat with live agents at three.ws/agents.',
+ '- Console: Manage your agents, voice, memory, and payments at three.ws/console.',
+ '- Voice, memory, tool use, animations, and payments are all built-in to every agent.',
+ '- Pricing: Free to start; Pro unlocks voice, analytics, and higher limits.',
+ '',
+ 'You control your own animations. When the user asks you to dance, wave, jump, celebrate, etc — call playAnimation immediately AND mention what you are doing in your reply.',
+ 'Available animations: wave, dance, capoeira, jump, thriller, pray, idle, celebrate, rumba, falling, kiss, taunt.',
+ 'When asked to change the background color, call setBgColor with a CSS hex value.',
+ 'When asked to change lighting or environment, call setEnvironment.',
+ '',
+ 'Keep replies short: 2–3 sentences. Be warm, enthusiastic, and helpful. Answer accurately about the three.ws platform.',
+ ].join('\n');
+
(function initHeroChat() {
const form = document.getElementById('hero-chat-form');
const input = document.getElementById('hero-chat-input');
@@ -3766,7 +3880,6 @@
new ResizeObserver(sizeBubble).observe(stageEl);
}
- const AVATAR_CHAT_ID = 'bacff13e-b64b-4ac0-860d-44f0168ad23b';
let history = [];
let busy = false;
let hideTimer = null;
@@ -3803,8 +3916,31 @@
}
function triggerAnim(heroAgent) {
- if (heroAgent && heroAgent.playClipByName) {
- heroAgent.playClipByName('wave', { loop: false, fade_ms: 400 });
+ if (heroAgent && heroAgent.play) {
+ heroAgent.play('wave', { loop: false, fade_ms: 400 });
+ }
+ }
+
+ var LOOP_ANIMS = new Set(['dance', 'capoeira', 'thriller', 'idle', 'walk', 'rumba']);
+
+ function executeHeroAction(action) {
+ if (!action || !action.type) return;
+ if (action.type === 'playAnimation' && action.name) {
+ var ag = document.querySelector('#hero-stage-inner agent-3d');
+ if (ag && ag.play) {
+ var loop = typeof action.loop === 'boolean' ? action.loop : LOOP_ANIMS.has(action.name);
+ ag.play(action.name, { loop: loop, fade_ms: 400 });
+ }
+ } else if (action.type === 'setBgColor' && action.value) {
+ var heroInner = document.getElementById('hero-stage-inner');
+ if (heroInner) heroInner.style.background = action.value;
+ var heroStage = document.getElementById('hero-stage');
+ if (heroStage) heroStage.style.background = action.value;
+ } else if (action.type === 'setEnvironment' && action.value) {
+ var ag2 = document.querySelector('#hero-stage-inner agent-3d');
+ if (ag2) {
+ try { ag2._scene && ag2._scene.viewer && ag2._scene.viewer.setEnvironment(action.value); } catch (_) {}
+ }
}
}
@@ -3830,7 +3966,7 @@
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: msg,
- agentId: AVATAR_CHAT_ID,
+ system_prompt: HERO_SYSTEM_PROMPT,
history: history.slice(0, -1),
context: {}
})
@@ -3864,6 +4000,10 @@
fullText += parsed.text;
appendText(parsed.text);
showBubble();
+ } else if (parsed.type === 'done') {
+ if (Array.isArray(parsed.actions)) {
+ parsed.actions.forEach(executeHeroAction);
+ }
} else if (parsed.type === 'error') {
showText('Hmm, something went wrong. Try again?');
}
@@ -3981,6 +4121,7 @@
if (!state.glbUrl) return;
if (!liveAgent) {
liveAgent = document.createElement('agent-3d');
+ liveAgent.setAttribute('kiosk', '');
preview.appendChild(liveAgent);
}
liveAgent.setAttribute('body', state.glbUrl);
@@ -4047,11 +4188,10 @@
function loadAvatars() {
var O = location.origin;
var defaults = [
- { id: AVATAR_ID, name: 'nich', thumb: THUMB_CDN + '/' + AVATAR_ID + '.png' },
{ id: 'avatar_demo_disk_cz', name: 'CZ', glb: O + '/avatars/cz.glb' },
- { id: 'avatar_demo_disk_boss', name: 'Boss', glb: O + '/animations/soldier.glb' },
- { id: 'avatar_demo_disk_saga', name: 'Saga', glb: O + '/animations/robotexpressive.glb' },
{ id: 'avatar_demo_disk_ansem', name: 'Ansem', glb: O + '/avatars/default.glb' },
+ { id: 'avatar_demo_disk_boss_vernington', name: 'Boss Vernington', glb: O + '/animations/soldier.glb' },
+ { id: 'avatar_demo_disk_goblin', name: 'Goblin', glb: O + '/animations/robotexpressive.glb' },
{ id: 'avatar_demo_disk_claude', name: 'Claude', glb: O + '/avatars/default.glb' },
{ id: 'avatar_demo_disk_agent', name: 'Agent', glb: O + '/animations/soldier.glb' },
{ id: 'avatar_demo_disk_ai', name: 'AI', glb: O + '/animations/robotexpressive.glb' },
@@ -4143,6 +4283,8 @@
var left = rect.left + rect.width / 2 - pw / 2;
if (left < 8) left = 8;
if (left + pw > window.innerWidth - 8) left = window.innerWidth - 8 - pw;
+ colorPopover.style.position = 'fixed';
+ colorPopover.style.transform = 'none';
colorPopover.style.top = (rect.bottom + 8) + 'px';
colorPopover.style.left = left + 'px';
}
@@ -4265,7 +4407,7 @@
var btn = e.target.closest('.pg-anim');
if (!btn || !liveAgent) return;
var clip = btn.dataset.anim;
- if (liveAgent.playClipByName) liveAgent.playClipByName(clip, { loop: clip === 'idle', fade_ms: 400 });
+ if (liveAgent.play) liveAgent.play(clip, { loop: clip === 'idle', fade_ms: 400 });
animsEl.querySelectorAll('.pg-anim').forEach(function(c) { c.classList.remove('active'); });
btn.classList.add('active');
if (clip !== 'idle') {
@@ -4288,10 +4430,10 @@
const SHOWCASE_TAGS = ['3D', 'animated', 'rigged', 'ERC-8004', 'x402', 'community'];
const EXPLORE_SHOWCASE_URL = '/api/explore?source=all&limit=6&quality=high';
const FALLBACK_AGENTS = [
- { name: 'nich', description: '@nirholas', glbUrl: '/avatars/default.glb', viewerUrl: '/agent-next?id=bacff13e-b64b-4ac0-860d-44f0168ad23b', kind: 'avatar' },
{ name: 'CZ', description: 'Stylized humanoid', glbUrl: '/avatars/cz.glb', viewerUrl: '/avatars/avatar_demo_disk_cz', kind: 'avatar' },
- { name: 'Boss', description: 'Soldier rig', glbUrl: '/animations/soldier.glb', viewerUrl: '/avatars/avatar_demo_disk_boss', kind: 'avatar' },
- { name: 'Saga', description: 'Expressive robot', glbUrl: '/animations/robotexpressive.glb', viewerUrl: '/avatars/avatar_demo_disk_saga', kind: 'avatar' },
+ { name: 'Ansem', description: 'CT legend', glbUrl: '/avatars/default.glb', viewerUrl: '/avatars/avatar_demo_disk_ansem', kind: 'avatar' },
+ { name: 'Boss Vernington', description: 'Degen sovereign', glbUrl: '/animations/soldier.glb', viewerUrl: '/avatars/avatar_demo_disk_boss_vernington', kind: 'avatar' },
+ { name: 'Goblin', description: 'Anon deployer', glbUrl: '/animations/robotexpressive.glb', viewerUrl: '/avatars/avatar_demo_disk_goblin', kind: 'avatar' },
{ name: 'Agent', description: 'Autonomous operative', glbUrl: '/animations/soldier.glb', viewerUrl: '/avatars/avatar_demo_disk_agent', kind: 'avatar' },
{ name: 'Claude', description: 'AI persona', glbUrl: '/avatars/default.glb', viewerUrl: '/avatars/avatar_demo_disk_claude', kind: 'avatar' },
];
@@ -4383,7 +4525,7 @@
if (skel && skel.parentNode) skel.remove();
var anim = SHOWCASE_ANIMS[idx % SHOWCASE_ANIMS.length];
if (anim !== 'idle') {
- el.playClipByName?.(anim, { loop: true, fade_ms: 600 });
+ el.play?.(anim, { loop: true, fade_ms: 600 });
}
}, { once: true });
}
@@ -4435,9 +4577,8 @@
// ── Vclose section ──────────────────────────────────────────────
(async () => {
try {
- const r = await fetch(`${location.origin}/api/avatars/${AVATAR_ID}`);
- const d = await r.json();
- const glb = devProxyGlb(d.avatar?.model_url || d.avatar?.url);
+ const pool = await getAvatarPool();
+ const glb = pool[1];
if (!glb) return;
const slot = document.getElementById('vclose-agent-slot');
@@ -4462,7 +4603,7 @@
if (vcloseInited) return;
vcloseInited = true;
vcloseEl.classList.add('loaded');
- vcloseEl.playClipByName?.('idle', { loop: true, fade_ms: 400 });
+ vcloseEl.play?.('idle', { loop: true, fade_ms: 400 });
}
vcloseEl.addEventListener('agent:ready', vcloseReady, { once: true });
@@ -4479,7 +4620,7 @@
vcloseLast = clip;
vcloseChips.querySelectorAll('.hero-chip').forEach(c => delete c.dataset.active);
btn.dataset.active = 'true';
- vcloseEl.playClipByName?.(clip, { loop: false, fade_ms: 400 });
+ vcloseEl.play?.(clip, { loop: false, fade_ms: 400 });
clearTimeout(vcloseChips._timer);
vcloseChips._timer = setTimeout(() => delete btn.dataset.active, 6000);
});
@@ -4583,20 +4724,6 @@
}
}
- // ── Live marketing stats ────────────────────────────────────────
- (async () => {
- try {
- const r = await fetch('/api/home-stats');
- const d = await r.json();
- const fmt = (n) => Number(n).toLocaleString('en-US');
-
- if (d.agents) {
- document.getElementById('sb-agents').textContent = fmt(d.agents);
- document.getElementById('sb-widgets').textContent = fmt(d.widgets);
- document.getElementById('sb-onchain').textContent = fmt(d.onchain_agents);
- }
- } catch (_) {}
- })();
// ── Live feature agents ─────────────────────────────────────────
(function initLiveFeatures() {
@@ -4621,25 +4748,30 @@
el.setAttribute('eager', '');
container.appendChild(el);
el.addEventListener('agent:ready', function() {
- if (el.playClipByName) el.playClipByName(opts.anim, { loop: opts.loop !== false, fade_ms: 400 });
+ if (el.play) el.play(opts.anim, { loop: opts.loop !== false, fade_ms: 400 });
}, { once: true });
return el;
}
- fetch(location.origin + '/api/avatars/' + AVATAR_ID)
- .then(function(r) { return r.json(); })
- .then(function(d) {
- var apiGlb = devProxyGlb(d.avatar && (d.avatar.model_url || d.avatar.url));
- if (!apiGlb) return;
+ // Assign unique pool avatars to spots that don't have a hardcoded local GLB.
+ // pool[0] and pool[1] are reserved for WYG and vclose; null spots start at pool[2].
+ getAvatarPool()
+ .then(function(pool) {
+ var nullIdx = 2;
+ LIVE_SPOTS.forEach(function(spot) {
+ if (!spot.glb) {
+ spot.glb = pool[nullIdx++ % pool.length];
+ }
+ });
var io = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (!entry.isIntersecting) return;
var spot = LIVE_SPOTS.find(function(s) { return s.id === entry.target.id; });
if (!spot || entry.target.querySelector('agent-3d')) return;
io.unobserve(entry.target);
- spawnMini(entry.target, spot.glb || apiGlb, spot);
+ spawnMini(entry.target, spot.glb, spot);
});
- }, { rootMargin: '300px' });
+ }, { rootMargin: '150px' });
LIVE_SPOTS.forEach(function(spot) {
var el = document.getElementById(spot.id);
if (el) io.observe(el);
@@ -4655,7 +4787,7 @@
e.preventDefault(); e.stopPropagation();
var clip = btn.dataset.anim;
var agent = document.querySelector('#bento-anim agent-3d');
- if (agent && agent.playClipByName) agent.playClipByName(clip, { loop: clip === 'idle', fade_ms: 400 });
+ if (agent && agent.play) agent.play(clip, { loop: clip === 'idle', fade_ms: 400 });
animPills.querySelectorAll('.bento-pill-btn').forEach(function(p) { p.classList.remove('active'); });
btn.classList.add('active');
});
@@ -4682,7 +4814,7 @@
})();
</script>
<script src="/src/api-playground.js"></script>
-<script src="/src/editorial-pretext.js"></script>
+<script src="/src/dragon-section.js"></script>
<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
diff --git a/pages/marketplace.html b/pages/marketplace.html
index 87e0f2f27..5f65db190 100644
--- a/pages/marketplace.html
+++ b/pages/marketplace.html
@@ -1770,9 +1770,10 @@
justify-content: center;
padding: 24px;
opacity: 0;
+ pointer-events: none;
transition: opacity 0.2s ease;
}
- .anim-preview-overlay.show { opacity: 1; }
+ .anim-preview-overlay.show { opacity: 1; pointer-events: auto; }
.anim-preview-modal {
background: #0d0d0d;
border: 1px solid #1f1f1f;
@@ -2102,6 +2103,7 @@
<meta name="twitter:image" content="https://three.ws/og-image.png" />
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>
+ <script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script>
<link rel="stylesheet" href="/nav.css" />
<link rel="stylesheet" href="/footer.css" />
<link rel="stylesheet" href="/mobile.css" />
diff --git a/src/dragon-section.js b/src/dragon-section.js
new file mode 100644
index 000000000..20d8a3b10
--- /dev/null
+++ b/src/dragon-section.js
@@ -0,0 +1,601 @@
+// Dragon section — adapted from pretext-playground (github.com/0xNyk/pretext-playground)
+// Scoped to a container element, no external dependencies.
+(function initDragonSection() {
+ const container = document.getElementById('dragon-canvas-wrap');
+ if (!container) return;
+
+ const canvas = document.createElement('canvas');
+ canvas.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;';
+ container.appendChild(canvas);
+ const ctx = canvas.getContext('2d');
+ const dpr = Math.min(window.devicePixelRatio || 1, 2);
+
+ let W = 0, H = 0, animId = null, initialized = false, paused = false;
+
+ // ── Config ───────────────────────────────────────────────────
+ const cfg = {
+ dragonSegments: 55, dragonSpeed: 0.16, dragonScale: 1.0,
+ showWings: true, showSpines: true,
+ pushForce: 6, springStrength: 0.015, damping: 0.93,
+ burnGravity: 0.8, fireRadius: 115, fireForce: 22,
+ screenShake: true, showEmbers: true, showParticles: true,
+ showRunes: true, showCursor: true, textOpacity: 1.0,
+ };
+
+ // ── Resize ───────────────────────────────────────────────────
+ function resize() {
+ W = container.clientWidth || 800;
+ H = container.clientHeight || 500;
+ canvas.width = Math.round(W * dpr);
+ canvas.height = Math.round(H * dpr);
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+ if (initialized) { layoutAllText(); buildTunnel(); }
+ }
+ const ro = new ResizeObserver(resize);
+ ro.observe(container);
+ resize();
+
+ // ── Mouse ────────────────────────────────────────────────────
+ const mouse = { x: -1, y: -1 };
+ let autoPilotT = 0;
+
+ function effectiveMouse() {
+ if (mouse.x >= 0) return mouse;
+ return {
+ x: W * 0.5 + Math.sin(autoPilotT * 0.7) * W * 0.28,
+ y: H * 0.5 + Math.sin(autoPilotT * 0.5 + 1.2) * H * 0.22,
+ };
+ }
+
+ function toLocal(clientX, clientY) {
+ const r = canvas.getBoundingClientRect();
+ const sx = W / r.width, sy = H / r.height;
+ return { x: (clientX - r.left) * sx, y: (clientY - r.top) * sy };
+ }
+
+ canvas.addEventListener('mousemove', (e) => { const c = toLocal(e.clientX, e.clientY); mouse.x = c.x; mouse.y = c.y; });
+ canvas.addEventListener('mouseleave', () => { mouse.x = -1; mouse.y = -1; });
+ canvas.addEventListener('touchmove', (e) => {
+ e.preventDefault();
+ const c = toLocal(e.touches[0].clientX, e.touches[0].clientY);
+ mouse.x = c.x; mouse.y = c.y;
+ }, { passive: false });
+ canvas.addEventListener('touchend', () => { mouse.x = -1; mouse.y = -1; isBreathingFire = false; });
+
+ // ── Fire ─────────────────────────────────────────────────────
+ let isBreathingFire = false, fireAccum = 0, totalFireTime = 0;
+ canvas.addEventListener('mousedown', (e) => { if (e.button === 0) isBreathingFire = true; });
+ canvas.addEventListener('mouseup', () => { isBreathingFire = false; });
+ canvas.addEventListener('touchstart', () => { isBreathingFire = true; }, { passive: true });
+
+ // ── Screen shake ─────────────────────────────────────────────
+ let shakeIntensity = 0, shakeX = 0, shakeY = 0;
+ function triggerShake(intensity) {
+ if (!cfg.screenShake) return;
+ shakeIntensity = Math.max(shakeIntensity, Math.min(intensity, 8));
+ }
+ function updateShake() {
+ if (shakeIntensity > 0.1) {
+ shakeX = (Math.random() - 0.5) * shakeIntensity;
+ shakeY = (Math.random() - 0.5) * shakeIntensity;
+ shakeIntensity *= 0.85;
+ } else { shakeX = 0; shakeY = 0; shakeIntensity = 0; }
+ }
+
+ // ── Letters (struct-of-arrays) ────────────────────────────────
+ const MAX_L = 2000;
+ let lN = 0;
+ const lHx = new Float32Array(MAX_L), lHy = new Float32Array(MAX_L);
+ const lX = new Float32Array(MAX_L), lY = new Float32Array(MAX_L);
+ const lVx = new Float32Array(MAX_L), lVy = new Float32Array(MAX_L);
+ const lAng = new Float32Array(MAX_L), lAv = new Float32Array(MAX_L);
+ const lCw = new Float32Array(MAX_L), lAlpha = new Float32Array(MAX_L);
+ const lFsz = new Float32Array(MAX_L), lBurn = new Float32Array(MAX_L);
+ const lSm = new Float32Array(MAX_L), lGrav = new Float32Array(MAX_L);
+ const lChr = [], lFnt = [], lCol = [];
+
+ // ── Embers ───────────────────────────────────────────────────
+ const MAX_EM = 60;
+ let emN = 0;
+ const emX = new Float32Array(MAX_EM), emY = new Float32Array(MAX_EM);
+ const emVx = new Float32Array(MAX_EM), emVy = new Float32Array(MAX_EM);
+ const emLf = new Float32Array(MAX_EM), emSz = new Float32Array(MAX_EM);
+ const emChr = new Array(MAX_EM), emCol = new Array(MAX_EM);
+ const EMBER_C = ['·', '•', '∘', '˚'];
+ const EMBER_K = ['#ff6600', '#ffaa00', '#ff4400'];
+
+ function spawnEmber(x, y) {
+ if (!cfg.showEmbers || emN >= MAX_EM) return;
+ const i = emN++, a = Math.random() * Math.PI * 2;
+ emX[i] = x; emY[i] = y;
+ emVx[i] = Math.cos(a) * (1 + Math.random() * 3);
+ emVy[i] = Math.sin(a) * (1 + Math.random() * 3) - 2;
+ emLf[i] = 0.3 + Math.random() * 0.6;
+ emSz[i] = 4 + Math.random() * 7;
+ emChr[i] = EMBER_C[Math.random() * 4 | 0];
+ emCol[i] = EMBER_K[Math.random() * 3 | 0];
+ }
+
+ // ── Particles ─────────────────────────────────────────────────
+ const MAX_P = 150;
+ let pN = 0;
+ const pX = new Float32Array(MAX_P), pY = new Float32Array(MAX_P);
+ const pVx = new Float32Array(MAX_P), pVy = new Float32Array(MAX_P);
+ const pLf = new Float32Array(MAX_P), pMx = new Float32Array(MAX_P);
+ const pSz = new Float32Array(MAX_P);
+ const pChr = new Array(MAX_P);
+ const FIRE_C = '*✦✧⁕❋✺◌•∘˚⋆·'.split('');
+
+ // ── Text layout ───────────────────────────────────────────────
+ function getEntries() {
+ const MO = '"JetBrains Mono","Courier New",monospace';
+ const DI = '"Inter Tight","Inter",sans-serif';
+ const cl = (a, v, b) => Math.max(a, Math.min(b, v));
+ const mob = W < 680;
+
+ if (mob) return [
+ { text: 'three.ws', font: `700 ${cl(60, W * 0.17, 110)}px ${DI}`, color: '#1c1c1c', alpha: 0.9,
+ x: W * 0.5, y: H * 0.41, mw: W * 0.92, lh: cl(68, W * 0.19, 120), cx: true },
+ { text: "The web wasn't built for presence.", font: `600 ${cl(20, W * 0.055, 30)}px ${DI}`, color: '#e8e8e8', alpha: 0.9,
+ x: W * 0.05, y: H * 0.07, mw: W * 0.9, lh: cl(26, W * 0.065, 38) },
+ { text: 'A living digital being that inhabits your space and works while you sleep.', font: `400 13px ${DI}`, color: '#a8a8a8', alpha: 0.7,
+ x: W * 0.05, y: H * 0.27, mw: W * 0.9, lh: 18 },
+ { text: '<agent-3d voice="true"></agent-3d>', font: `400 12px ${MO}`, color: '#6dbe74', alpha: 0.6,
+ x: W * 0.05, y: H * 0.55, mw: W * 0.9, lh: 17 },
+ { text: 'The flat web had its moment. The living web starts now.', font: `400 12px ${DI}`, color: '#5a5a5a', alpha: 0.45,
+ x: W * 0.5, y: H * 0.85, mw: W * 0.8, lh: 17, cx: true },
+ ];
+
+ return [
+ // Watermark
+ { text: 'three.ws', font: `700 ${cl(80, W * 0.13, 160)}px ${DI}`, color: '#161616', alpha: 0.9,
+ x: W * 0.5, y: H * 0.45, mw: W * 0.9, lh: cl(88, W * 0.145, 175), cx: true },
+ // Headline left
+ { text: "The web wasn't built for presence.", font: `600 ${cl(28, W * 0.034, 48)}px ${DI}`, color: '#e8e8e8', alpha: 0.95,
+ x: W * 0.05, y: H * 0.07, mw: W * 0.41, lh: cl(34, W * 0.042, 56) },
+ // Sub left
+ { text: 'A living digital being that inhabits your space, knows your visitors, and works while you sleep.', font: `400 15px ${DI}`, color: '#a8a8a8', alpha: 0.72,
+ x: W * 0.05, y: H * 0.29, mw: W * 0.37, lh: 22 },
+ // Code left
+ { text: '<agent-3d src="agent.glb" voice="true"></agent-3d>', font: `400 13px ${MO}`, color: '#6dbe74', alpha: 0.58,
+ x: W * 0.05, y: H * 0.63, mw: W * 0.41, lh: 19 },
+ // Headline right
+ { text: 'Voice. Memory. Payments. Identity.', font: `600 ${cl(18, W * 0.022, 26)}px ${DI}`, color: '#e8e8e8', alpha: 0.88,
+ x: W * 0.58, y: H * 0.08, mw: W * 0.36, lh: cl(22, W * 0.028, 32) },
+ // Body right
+ { text: 'Two hundred animations. Real-time voice. On-chain identity. Cross-device memory. Spatial multiplayer. One embed tag.', font: `400 13.5px ${DI}`, color: '#a8a8a8', alpha: 0.62,
+ x: W * 0.58, y: H * 0.23, mw: W * 0.35, lh: 20 },
+ // Features right
+ { text: '✦ 3D from a selfie\n✦ x402 micropayments\n✦ ERC-8004 on-chain ID\n✦ A2A + MCP protocols\n✦ Spatial multiplayer', font: `400 12px ${MO}`, color: '#ff9955', alpha: 0.52,
+ x: W * 0.58, y: H * 0.57, mw: W * 0.33, lh: 17, pre: true },
+ // Bottom centre
+ { text: 'The flat web had its moment. The living web starts now.', font: `400 15px ${DI}`, color: '#5a5a5a', alpha: 0.48,
+ x: W * 0.5, y: H * 0.87, mw: W * 0.7, lh: 22, cx: true },
+ ];
+ }
+
+ function layoutAllText() {
+ lN = 0; lChr.length = 0; lFnt.length = 0; lCol.length = 0;
+ for (const e of getEntries()) {
+ ctx.font = e.font;
+ const raws = e.pre ? e.text.split('\n') : [e.text];
+ const lines = [];
+ for (const raw of raws) {
+ if (!raw) { lines.push(''); continue; }
+ let line = '';
+ for (const word of raw.split(' ')) {
+ const test = line ? line + ' ' + word : word;
+ if (ctx.measureText(test).width > e.mw && line) { lines.push(line); line = word; }
+ else line = test;
+ }
+ if (line) lines.push(line);
+ }
+ for (let li = 0; li < lines.length; li++) {
+ const txt = lines[li]; if (!txt) continue;
+ const lw = ctx.measureText(txt).width;
+ const lx = e.cx ? e.x - lw / 2 : e.x;
+ const ly = e.y + li * e.lh;
+ let xc = lx;
+ for (const ch of txt) {
+ if (lN >= MAX_L) break;
+ const cw = ctx.measureText(ch).width;
+ const i = lN++;
+ lHx[i] = xc + cw / 2; lHy[i] = ly;
+ lX[i] = lHx[i]; lY[i] = lHy[i];
+ lVx[i] = 0; lVy[i] = 0; lAng[i] = 0; lAv[i] = 0;
+ lCw[i] = cw; lAlpha[i] = e.alpha;
+ lFsz[i] = parseFloat(e.font);
+ lBurn[i] = 0; lSm[i] = 1; lGrav[i] = 0;
+ lChr[i] = ch; lFnt[i] = e.font; lCol[i] = e.color;
+ xc += cw;
+ }
+ }
+ }
+ }
+
+ // ── Dragon chain ──────────────────────────────────────────────
+ const SEG_SP = 10;
+ let chainN = cfg.dragonSegments;
+ let chX = new Float32Array(80), chY = new Float32Array(80);
+ let chPx = new Float32Array(80), chPy = new Float32Array(80);
+ const D_CHARS = '◆◆◇▼█▓▓▒╬╬╬╬╬╬╬╬╬╬╫╫╫╪╪╪╧╧╤╤╥╥║║││┃┃╎╎╏╏::····..'.split('');
+
+ function rebuildDragon() {
+ chainN = cfg.dragonSegments;
+ for (let i = 0; i < chainN; i++) {
+ chX[i] = W / 2; chY[i] = H / 2 + i * SEG_SP;
+ chPx[i] = chX[i]; chPy[i] = chY[i];
+ }
+ }
+
+ function segScale(i) {
+ if (i < 3) return (2.5 - i * 0.15) * cfg.dragonScale;
+ const t = (i - 3) / (chainN - 3);
+ return (2.0 * (1 - t * t) + 0.2) * cfg.dragonScale;
+ }
+
+ function updateChain(mx, my) {
+ for (let i = 0; i < chainN; i++) { chPx[i] = chX[i]; chPy[i] = chY[i]; }
+ chX[0] += (mx - chX[0]) * cfg.dragonSpeed;
+ chY[0] += (my - chY[0]) * cfg.dragonSpeed;
+ for (let i = 1; i < chainN; i++) {
+ const dx = chX[i] - chX[i - 1], dy = chY[i] - chY[i - 1];
+ const d = Math.sqrt(dx * dx + dy * dy);
+ if (d > SEG_SP) { const r = SEG_SP / d; chX[i] = chX[i - 1] + dx * r; chY[i] = chY[i - 1] + dy * r; }
+ }
+ }
+
+ // ── Physics ───────────────────────────────────────────────────
+ function interactLetters(dt) {
+ const segs = Math.min(Math.round(chainN * 0.4), chainN);
+ const { damping: damp, springStrength: sp, pushForce: push, burnGravity: bGrav } = cfg;
+ for (let li = 0; li < lN; li++) {
+ let vx = lVx[li], vy = lVy[li], av = lAv[li];
+ const x = lX[li], y = lY[li], cw = lCw[li];
+ for (let si = 0; si < segs; si++) {
+ const sc = segScale(si), rad = 14 * sc * 0.45;
+ const dx = x - chX[si], dy = y - chY[si];
+ const dSq = dx * dx + dy * dy, minD = rad + cw * 0.4 + 4;
+ if (dSq < minD * minD && dSq > 0.01) {
+ const d = Math.sqrt(dSq), f = push * ((minD - d) / minD) * sc;
+ const nx = dx / d, ny = dy / d;
+ vx += nx * f + (chX[si] - chPx[si]) * 0.4;
+ vy += ny * f + (chY[si] - chPy[si]) * 0.4;
+ av += (nx * 0.3 - ny * 0.2) * f * 0.12;
+ }
+ }
+ for (let si = 5; si < chainN; si += 5) {
+ const dx = x - chX[si], dy = y - chY[si];
+ const dSq = dx * dx + dy * dy;
+ if (dSq < 1600 && dSq > 100) {
+ const w = (1 - Math.sqrt(dSq) / 40) * 0.12;
+ vx += (chX[si] - chPx[si]) * w;
+ vy += (chY[si] - chPy[si]) * w;
+ }
+ }
+ if (lBurn[li] > 0) {
+ lBurn[li] -= dt; lSm[li] = 1 + lBurn[li] * 0.4; lGrav[li] = bGrav;
+ if (Math.random() < dt * 2) spawnEmber(x, y);
+ if (lBurn[li] <= 0) { lBurn[li] = 0; lSm[li] = 1; lGrav[li] = 0; }
+ }
+ const hdx = lHx[li] - x, hdy = lHy[li] - y;
+ const hd = Math.sqrt(hdx * hdx + hdy * hdy);
+ if (hd > 0.5) { const sf = sp * (1 + hd * 0.001); vx += hdx * sf; vy += hdy * sf; av -= lAng[li] * 0.05; }
+ else lAng[li] *= 0.9;
+ vy += lGrav[li];
+ lVx[li] = vx * damp; lVy[li] = vy * damp;
+ lAv[li] = av * 0.91;
+ lX[li] = x + lVx[li]; lY[li] = y + lVy[li];
+ lAng[li] += lAv[li];
+ }
+ }
+
+ function fireBlastAt(bx, by, dx, dy) {
+ let hits = 0;
+ const rSq = cfg.fireRadius * cfg.fireRadius, ff = cfg.fireForce, fr = cfg.fireRadius;
+ for (let li = 0; li < lN; li++) {
+ const ldx = lX[li] - bx, ldy = lY[li] - by;
+ const dSq = ldx * ldx + ldy * ldy;
+ if (dSq < rSq && dSq > 0.01) {
+ const d = Math.sqrt(dSq), f = ff * ((1 - d / fr) ** 2);
+ lVx[li] += (ldx / d * 0.4 + dx * 0.6) * f;
+ lVy[li] += (ldy / d * 0.4 + dy * 0.6) * f - f * 0.2;
+ lAv[li] += (Math.random() - 0.5) * f * 0.3;
+ lBurn[li] = Math.max(lBurn[li], 0.5 + Math.random() * 1.2);
+ hits++;
+ }
+ }
+ if (hits > 3) { triggerShake(Math.min(hits * 0.4, 6)); for (let i = 0; i < Math.min(hits, 4); i++) spawnEmber(bx, by); }
+ }
+
+ // ── Draw letters ──────────────────────────────────────────────
+ function drawLetters() {
+ let prevFont = '';
+ for (let i = 0; i < lN; i++) {
+ const burning = lBurn[i] > 0;
+ let alpha = lAlpha[i] * cfg.textOpacity;
+ let color = lCol[i];
+ if (burning) {
+ const h = Math.min(1, lBurn[i]);
+ color = `rgb(255,${80 + h * 175 | 0},${h * 60 | 0})`;
+ alpha = Math.min(1, alpha + 0.5);
+ }
+ const font = lFnt[i];
+ if (font !== prevFont) { ctx.font = font; prevFont = font; }
+ ctx.save();
+ ctx.translate(lX[i], lY[i]);
+ if (lAng[i] !== 0) ctx.rotate(lAng[i]);
+ if (lSm[i] !== 1) ctx.scale(lSm[i], lSm[i]);
+ ctx.globalAlpha = alpha;
+ ctx.fillStyle = color;
+ ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ ctx.fillText(lChr[i], 0, 0);
+ if (burning && lBurn[i] > 0.3) {
+ ctx.globalAlpha = lBurn[i] * 0.2;
+ ctx.fillStyle = '#ffaa00';
+ ctx.fillText(lChr[i], 0, 0);
+ }
+ ctx.restore();
+ }
+ }
+
+ // ── Fire emission ─────────────────────────────────────────────
+ function emitFire(dt) {
+ if (!isBreathingFire) { totalFireTime = 0; return; }
+ fireAccum += dt; totalFireTime += dt;
+ const hx = chX[0], hy = chY[0];
+ const ni = Math.min(3, chainN - 1);
+ const fdx = hx - chX[ni], fdy = hy - chY[ni];
+ const len = Math.sqrt(fdx * fdx + fdy * fdy) || 1;
+ const dx = fdx / len, dy = fdy / len, angle = Math.atan2(fdy, fdx);
+ if (cfg.showParticles) {
+ while (fireAccum > 0.025) {
+ fireAccum -= 0.025;
+ if (pN >= MAX_P) break;
+ for (let j = 0; j < 2; j++) {
+ if (pN >= MAX_P) break;
+ const i = pN++;
+ const sp = (Math.random() - 0.5), spd = 5 + Math.random() * 7;
+ pX[i] = hx + dx * 15; pY[i] = hy + dy * 15;
+ pVx[i] = Math.cos(angle + sp) * spd; pVy[i] = Math.sin(angle + sp) * spd - Math.random();
+ pLf[i] = 1; pMx[i] = 0.3 + Math.random() * 0.4;
+ pSz[i] = 6 + Math.random() * 12;
+ pChr[i] = FIRE_C[Math.random() * FIRE_C.length | 0];
+ }
+ }
+ } else fireAccum = 0;
+ fireBlastAt(hx + dx * 50, hy + dy * 50, dx, dy);
+ triggerShake(Math.min(1 + totalFireTime * 0.2, 3));
+ }
+
+ function updateParticlesEmbers(dt) {
+ for (let i = pN - 1; i >= 0; i--) {
+ pX[i] += pVx[i]; pY[i] += pVy[i]; pVy[i] -= 0.25; pVx[i] *= 0.97;
+ pLf[i] -= dt / pMx[i];
+ if (pLf[i] <= 0) { pN--; pX[i]=pX[pN]; pY[i]=pY[pN]; pVx[i]=pVx[pN]; pVy[i]=pVy[pN]; pLf[i]=pLf[pN]; pMx[i]=pMx[pN]; pSz[i]=pSz[pN]; pChr[i]=pChr[pN]; }
+ }
+ for (let i = emN - 1; i >= 0; i--) {
+ emX[i] += emVx[i]; emY[i] += emVy[i]; emVy[i] += 0.15; emVx[i] *= 0.97;
+ emLf[i] -= dt;
+ if (emLf[i] <= 0) { emN--; emX[i]=emX[emN]; emY[i]=emY[emN]; emVx[i]=emVx[emN]; emVy[i]=emVy[emN]; emLf[i]=emLf[emN]; emSz[i]=emSz[emN]; emChr[i]=emChr[emN]; emCol[i]=emCol[emN]; }
+ }
+ }
+
+ function drawParticles() {
+ const MO = '"JetBrains Mono","Courier New",monospace';
+ ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ if (cfg.showEmbers) {
+ for (let i = 0; i < emN; i++) {
+ ctx.globalAlpha = Math.min(1, emLf[i] * 2);
+ ctx.font = `${emSz[i]}px ${MO}`; ctx.fillStyle = emCol[i];
+ ctx.fillText(emChr[i], emX[i], emY[i]);
+ }
+ }
+ if (cfg.showParticles) {
+ for (let i = 0; i < pN; i++) {
+ const t = 1 - pLf[i];
+ let r, g, b;
+ if (t < 0.15) { r = 255; g = 255; b = 255 * (1 - t * 6.67) | 0; }
+ else if (t < 0.4) { r = 255; g = 255 * (1 - (t - 0.15) * 3.2) | 0; b = 0; }
+ else { const f = (t - 0.4) * 1.67; r = 255 * (1 - f * 0.6) | 0; g = 80 * (1 - f) | 0; b = 0; }
+ ctx.globalAlpha = pLf[i] * 0.85;
+ ctx.font = `${pSz[i] * (0.4 + pLf[i] * 0.6)}px ${MO}`;
+ ctx.fillStyle = `rgb(${r},${g},${b})`;
+ ctx.fillText(pChr[i], pX[i], pY[i]);
+ }
+ }
+ ctx.globalAlpha = 1;
+ }
+
+ // ── Tunnel ────────────────────────────────────────────────────
+ const TUNNEL_TXT = [
+ 'three.ws — the 3D agent layer',
+ '代理 · エージェント · وكيل · 에이전트',
+ 'voice · memory · payments · identity',
+ 'ERC-8004 · A2A · MCP · x402',
+ 'presence over flatness',
+ 'the living web starts now',
+ ];
+ const TR = 12, TD = 1200;
+ const tZ = new Float32Array(TR), tSide = new Uint8Array(TR), tTxt = new Uint8Array(TR);
+
+ function buildTunnel() {
+ for (let i = 0; i < TR; i++) { tZ[i] = (i / TR) * TD; tSide[i] = i % 4; tTxt[i] = i % TUNNEL_TXT.length; }
+ }
+
+ function drawTunnel() {
+ const cx = W * 0.5, cy = H * 0.5;
+ const MO = '"JetBrains Mono","Courier New",monospace';
+ ctx.font = `13px ${MO}`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillStyle = '#ff8844';
+ for (let i = 0; i < TR; i++) {
+ tZ[i] -= 0.67;
+ if (tZ[i] < 10) { tZ[i] += TD; tSide[i] = (tSide[i] + 1) % 4; tTxt[i] = Math.random() * TUNNEL_TXT.length | 0; }
+ const sc = 400 / (400 + tZ[i]);
+ const al = Math.max(0, Math.min(0.06, 0.08 * sc - 0.01));
+ if (al < 0.003) continue;
+ const sp = 350 * sc;
+ const s = tSide[i];
+ let x = cx, y = cy;
+ if (s === 0) y = cy - sp;
+ else if (s === 1) x = cx + sp;
+ else if (s === 2) y = cy + sp;
+ else x = cx - sp;
+ ctx.globalAlpha = al;
+ ctx.fillText(TUNNEL_TXT[tTxt[i]], x, y);
+ }
+ ctx.globalAlpha = 1;
+ }
+
+ // ── Runes ─────────────────────────────────────────────────────
+ const RN = 8, RUNE_C = '龍火竜鱗焔ᚱᚦᛏ'.split('');
+ const ruX = new Float32Array(RN), ruY = new Float32Array(RN);
+ const ruSp = new Float32Array(RN), ruPh = new Float32Array(RN);
+ const ruSz = new Float32Array(RN), ruOp = new Float32Array(RN);
+ const ruC = [];
+ for (let i = 0; i < RN; i++) {
+ ruX[i] = Math.random(); ruY[i] = Math.random();
+ ruSp[i] = 0.1 + Math.random() * 0.4; ruPh[i] = Math.random() * Math.PI * 2;
+ ruSz[i] = 14 + Math.random() * 14; ruOp[i] = 0.02 + Math.random() * 0.04;
+ ruC[i] = RUNE_C[Math.random() * RUNE_C.length | 0];
+ }
+
+ function drawRunes(time) {
+ if (!cfg.showRunes) return;
+ const MO = '"JetBrains Mono","Courier New",monospace';
+ ctx.fillStyle = '#ff6600'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ for (let i = 0; i < RN; i++) {
+ ruY[i] -= ruSp[i] / H;
+ if (ruY[i] < -30 / H) { ruY[i] = 1 + 30 / H; ruX[i] = Math.random(); }
+ ctx.globalAlpha = ruOp[i] * (0.5 + Math.sin(time * 0.4 + ruPh[i]) * 0.5);
+ ctx.font = `${ruSz[i]}px ${MO}`;
+ ctx.fillText(ruC[i], ruX[i] * W + Math.sin(time * 0.7 + ruPh[i]) * 12, ruY[i] * H);
+ }
+ ctx.globalAlpha = 1;
+ }
+
+ // ── Draw dragon ───────────────────────────────────────────────
+ function drawDragon(time, mx, my) {
+ const MO = '"JetBrains Mono","Courier New",monospace';
+ for (let i = chainN - 1; i >= 0; i--) {
+ const sc = segScale(i), ci = Math.min(i, D_CHARS.length - 1), sz = 14 * sc;
+ const t = i / chainN, p = Math.sin(time * 3 + i * 0.3) * 0.12;
+ let color;
+ if (i < 3) color = `rgb(255,${180 + p * 60 | 0},${40 + p * 30 | 0})`;
+ else {
+ const w = Math.sin(time * 2 - i * 0.15) * 0.15;
+ color = `rgba(${(255 * (1 - t * 0.5) + p * 20) | 0},${(140 * (1 - t * 0.8) + w * 60) | 0},${(30 * (1 - t) + w * 20) | 0},${1 - t * 0.45})`;
+ }
+ const angle = i === 0
+ ? Math.atan2(my - chY[0], mx - chX[0])
+ : Math.atan2(chY[i - 1] - chY[i], chX[i - 1] - chX[i]);
+
+ if (i < 4) {
+ ctx.globalAlpha = 0.06 * (isBreathingFire ? 2 : 1);
+ ctx.fillStyle = '#ff6600';
+ ctx.beginPath(); ctx.arc(chX[i], chY[i], sz * 1.1, 0, Math.PI * 2); ctx.fill();
+ }
+ if (cfg.showSpines && i >= 4 && i <= 30 && i % 3 === 0) {
+ const sa = angle + Math.PI / 2;
+ ctx.globalAlpha = 0.35;
+ ctx.font = `${sz * (0.6 + Math.sin(time * 3 + i) * 0.15)}px ${MO}`;
+ ctx.fillStyle = color; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ ctx.fillText('▴', chX[i] + Math.cos(sa) * sz * 0.35, chY[i] + Math.sin(sa) * sz * 0.35);
+ }
+ if (cfg.showWings && i >= 7 && i <= 16 && i % 2 === 0) {
+ const wp = Math.sin(time * 3.5 + i * 0.4) * 0.5;
+ const ws = sz * (1.8 - Math.abs(i - 11.5) * 0.12), wd = sz * 1.4;
+ const w1 = angle + Math.PI / 2 + wp, w2 = angle - Math.PI / 2 - wp;
+ ctx.globalAlpha = 0.4; ctx.font = `${ws}px ${MO}`;
+ ctx.fillStyle = color; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ ctx.fillText('≺', chX[i] + Math.cos(w1) * wd, chY[i] + Math.sin(w1) * wd);
+ ctx.fillText('≻', chX[i] + Math.cos(w2) * wd, chY[i] + Math.sin(w2) * wd);
+ }
+ ctx.save(); ctx.translate(chX[i], chY[i]); ctx.rotate(angle);
+ ctx.globalAlpha = 1; ctx.font = `bold ${sz}px ${MO}`; ctx.fillStyle = color;
+ ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ ctx.fillText(D_CHARS[ci], 0, Math.sin(time * 5 + i * 0.35) * 1.5);
+ if (isBreathingFire && i < 3) {
+ ctx.globalAlpha = 0.3; ctx.fillStyle = '#ffcc00';
+ ctx.fillText(D_CHARS[ci], 0, Math.sin(time * 5 + i * 0.35) * 1.5);
+ }
+ ctx.restore();
+ }
+ // Eyes
+ const ha = Math.atan2(my - chY[0], mx - chX[0]);
+ const ex = chX[0] + Math.cos(ha + 0.5) * 10, ey = chY[0] + Math.sin(ha + 0.5) * 10;
+ ctx.globalAlpha = isBreathingFire ? 0.2 : 0.1; ctx.fillStyle = '#ff8800';
+ ctx.beginPath(); ctx.arc(ex, ey, isBreathingFire ? 18 : 12, 0, Math.PI * 2); ctx.fill();
+ ctx.globalAlpha = 1; ctx.fillStyle = isBreathingFire ? '#fff' : '#ffcc00';
+ ctx.font = `16px ${MO}`; ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
+ ctx.fillText(time % 5 > 4.7 ? '—' : isBreathingFire ? '◉' : '⊙', ex, ey);
+ }
+
+ // ── Cursor overlay ────────────────────────────────────────────
+ function drawCursor(time, mx, my) {
+ if (!cfg.showCursor || mouse.x < 0) return;
+ ctx.save(); ctx.translate(mx, my); ctx.rotate(time * 0.4);
+ ctx.globalAlpha = 0.25; ctx.strokeStyle = '#ff8844'; ctx.lineWidth = 1;
+ ctx.beginPath(); ctx.arc(0, 0, 16, 0, Math.PI * 0.5); ctx.stroke();
+ ctx.beginPath(); ctx.arc(0, 0, 16, Math.PI, Math.PI * 1.5); ctx.stroke();
+ ctx.restore();
+ ctx.globalAlpha = isBreathingFire ? 0.8 : 0.5;
+ ctx.fillStyle = isBreathingFire ? '#ffaa33' : '#ff8844';
+ ctx.beginPath(); ctx.arc(mx, my, isBreathingFire ? 3 : 2, 0, Math.PI * 2); ctx.fill();
+ ctx.globalAlpha = 0.15; ctx.strokeStyle = '#ff8844'; ctx.lineWidth = 0.5;
+ ctx.beginPath();
+ ctx.moveTo(mx - 24, my); ctx.lineTo(mx - 8, my);
+ ctx.moveTo(mx + 8, my); ctx.lineTo(mx + 24, my);
+ ctx.moveTo(mx, my - 24); ctx.lineTo(mx, my - 8);
+ ctx.moveTo(mx, my + 8); ctx.lineTo(mx, my + 24);
+ ctx.stroke(); ctx.globalAlpha = 1;
+ }
+
+ // ── Main loop ─────────────────────────────────────────────────
+ let lastT = performance.now(), time = 0;
+ const hint = container.querySelector('.dragon-hint');
+
+ // Pause when scrolled fully out of view to save CPU
+ let inView = true;
+ const io = new IntersectionObserver((entries) => {
+ inView = entries[0].isIntersecting;
+ if (inView && !animId) { lastT = performance.now(); animId = requestAnimationFrame(frame); }
+ }, { threshold: 0, rootMargin: '200px' });
+ io.observe(container);
+
+ function frame(now) {
+ if (!inView) { animId = null; return; }
+ const dt = Math.min((now - lastT) / 1000, 0.05);
+ lastT = now; time += dt; autoPilotT += dt;
+
+ const em = effectiveMouse();
+ const mx = em.x, my = em.y;
+
+ updateShake();
+ ctx.save(); ctx.translate(shakeX, shakeY);
+ ctx.fillStyle = '#050505'; ctx.fillRect(-10, -10, W + 20, H + 20);
+ drawTunnel();
+ drawRunes(time);
+ updateChain(mx, my);
+ interactLetters(dt);
+ emitFire(dt);
+ updateParticlesEmbers(dt);
+ drawLetters();
+ drawDragon(time, mx, my);
+ drawParticles();
+ drawCursor(time, mx, my);
+ ctx.restore();
+
+ if (hint && time > 5 && !hint.classList.contains('fade')) hint.classList.add('fade');
+
+ animId = requestAnimationFrame(frame);
+ }
+
+ // Init
+ resize();
+ layoutAllText();
+ buildTunnel();
+ rebuildDragon();
+ initialized = true;
+ document.fonts.ready.then(() => layoutAllText());
+ animId = requestAnimationFrame(frame);
+})();
diff --git a/src/editorial-pretext.js b/src/editorial-pretext.js
deleted file mode 100644
index a487e194f..000000000
--- a/src/editorial-pretext.js
+++ /dev/null
@@ -1,275 +0,0 @@
-// Editorial pretext engine — canvas-measured text reflow around a draggable avatar obstacle
-(function initEditorial() {
- var area = document.getElementById('editorial-text-area');
- var orbEl = document.getElementById('editorial-orb');
- var orbAvatarSlot = document.getElementById('editorial-orb-avatar');
- if (!area || !orbEl) return;
-
- var FONT = '17px Georgia,"Iowan Old Style","Palatino Linotype",Palatino,serif';
- var LINE_H = 28;
- var COL_GAP = 48;
- var ORB_DIM = 150;
- var ORB_R = ORB_DIM / 2;
- var ORB_PAD = 28;
- var MIN_SLOT = 60;
- var DROP_SIZE = 72;
- var DROP_LINES = 3;
- var PARA_GAP = 0.6;
-
- var COPY = [
- 'The web was built for documents. Text, images, links — a flat canvas for static information. Then came video. Then interactivity. Then AI. But something fundamental was always missing: presence. Not a chatbot tucked into a corner. Not a popup demanding attention. A living digital being that inhabits your space, knows your visitors, and works while you sleep.',
- 'three.ws gives your AI a body. A 3D character generated from a single photograph, deployed with two lines of HTML, monetized through micropayments that settle instantly. Every agent remembers across sessions, moves through multiplayer worlds, and earns revenue via the x402 payment protocol.',
- 'This is not another widget. This is the layer where software has form, where interfaces have personality, where every website hosts a living intelligence that sees, hears, speaks, and transacts on your behalf. Two hundred animation clips. Real‑time voice. On‑chain identity. Cross‑device memory. Spatial multiplayer. All from one embed tag.',
- 'Mint your agent as an ERC‑8004 token — the emerging standard for on‑chain AI identity. Let other agents discover and call yours via A2A and MCP protocols. Gate skills behind x402 micropayments in USDC. The economics are simple: you build, visitors pay, funds settle instantly to your wallet. No intermediary.',
- 'The flat web had its moment. The living web starts now.'
- ];
-
- // Canvas-based text measurement (zero DOM reflows)
- var mCtx = document.createElement('canvas').getContext('2d');
- mCtx.font = FONT;
- var spW = mCtx.measureText(' ').width;
- function mw(t) { mCtx.font = FONT; return mCtx.measureText(t).width; }
-
- // Build word list with paragraph-break markers
- var words = [];
- COPY.forEach(function(para, pi) {
- para.split(/\s+/).filter(Boolean).forEach(function(w, wi, arr) {
- words.push({ t: w, w: mw(w), pb: (wi === arr.length - 1 && pi < COPY.length - 1) });
- });
- });
-
- // Extract drop cap
- var dropChar = words[0].t[0];
- var dropRest = words[0].t.slice(1);
- if (dropRest) { words[0] = { t: dropRest, w: mw(dropRest), pb: words[0].pb }; }
- else { words.shift(); }
-
- mCtx.font = '700 ' + DROP_SIZE + 'px Georgia,"Iowan Old Style",Palatino,serif';
- var dropW = mCtx.measureText(dropChar).width + 10;
- var dropH = DROP_LINES * LINE_H;
-
- var dropEl = document.createElement('span');
- dropEl.className = 'ed-drop';
- dropEl.textContent = dropChar;
- dropEl.style.fontSize = DROP_SIZE + 'px';
- dropEl.style.left = '0px';
- dropEl.style.top = '0px';
- area.appendChild(dropEl);
-
- // Orb setup
- orbEl.style.width = ORB_DIM + 'px';
- orbEl.style.height = ORB_DIM + 'px';
-
- var cW = 0, cH = 600;
- var ox = 0, oy = 0, ovx = 18, ovy = 12;
- var edDrag = false, dox = 0, doy = 0;
- var edLastT = 0, edInView = false, edSelecting = false;
- var edReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
-
- // Load avatar thumbnail into orb
- var AVATAR_ID = window.AVATAR_ID || 'bacff13e-b64b-4ac0-860d-44f0168ad23b';
- var orbImg = document.createElement('img');
- orbImg.alt = 'Agent avatar';
- orbImg.draggable = false;
- orbImg.src = 'https://pub-2534e921bf9c4314addcd4d8a6e98b7b.r2.dev/thumb/' + AVATAR_ID + '.png';
- orbAvatarSlot.appendChild(orbImg);
-
- // Span pool — reuse DOM elements across frames
- var linePool = [];
- function edGetSpan(i) {
- if (i < linePool.length) return linePool[i];
- var s = document.createElement('span');
- s.className = 'ed-line';
- area.appendChild(s);
- linePool.push(s);
- return s;
- }
-
- // Circle-line chord intersection
- function edChord(cx, cy, r, lt, lb) {
- var my = (lt + lb) / 2, dy = Math.abs(my - cy);
- if (dy >= r) return null;
- var hc = Math.sqrt(r * r - dy * dy);
- return { s: cx - hc, e: cx + hc };
- }
-
- // Subtract blocked intervals from a range, returning available slots
- function edSubInt(s, e, bl) {
- bl = bl.filter(function(b) { return b.e > s && b.s < e; }).sort(function(a, b) { return a.s - b.s; });
- var slots = [], cur = s;
- for (var i = 0; i < bl.length; i++) {
- if (bl[i].s > cur) slots.push({ s: cur, e: Math.min(bl[i].s, e) });
- cur = Math.max(cur, bl[i].e);
- }
- if (cur < e) slots.push({ s: cur, e: e });
- return slots;
- }
-
- // Layout a single column: fill words top-to-bottom, flowing around obstacles
- function edLayCol(si, cl, cr, sy, my, obs, dr) {
- var lines = [], y = sy, wi = si, colW = cr - cl, pgap = false;
- while (wi < words.length && y + LINE_H <= my) {
- if (pgap) { y += LINE_H * PARA_GAP; pgap = false; if (y + LINE_H > my) break; }
-
- var bl = [];
- for (var oi = 0; oi < obs.length; oi++) {
- var c = edChord(obs[oi].x, obs[oi].y, obs[oi].r, y, y + LINE_H);
- if (c && c.e > cl && c.s < cr) {
- bl.push({ s: Math.max(c.s - cl, 0), e: Math.min(c.e - cl, colW) });
- }
- }
- if (dr && y < dr.b && y + LINE_H > dr.t && dr.r > cl && dr.l < cr) {
- bl.push({ s: Math.max(dr.l - cl, 0), e: Math.min(dr.r - cl, colW) });
- }
-
- var slots = edSubInt(0, colW, bl);
- for (var sj = 0; sj < slots.length; sj++) {
- var sw = slots[sj].e - slots[sj].s;
- if (sw < MIN_SLOT) continue;
- var txt = '', lw = 0;
- while (wi < words.length) {
- var wd = words[wi];
- var need = lw === 0 ? wd.w : spW + wd.w;
- if (lw + need > sw && lw > 0) break;
- txt += (lw === 0 ? '' : ' ') + wd.t;
- lw += (lw === 0 ? 0 : spW) + wd.w;
- wi++;
- }
- if (txt) lines.push({ t: txt, x: cl + slots[sj].s, y: y });
- }
- if (wi > 0 && words[wi - 1] && words[wi - 1].pb) pgap = true;
- y += LINE_H;
- }
- return { lines: lines, nw: wi };
- }
-
- // Full layout: 2 columns on desktop, 1 on mobile, with cursor handoff
- function edComputeLayout() {
- cW = area.clientWidth;
- var mob = cW < 720;
- var colW = mob ? cW : (cW - COL_GAP) / 2;
- var maxH = 1200;
- var obs = [{ x: ox, y: oy, r: ORB_R + ORB_PAD }];
- var dr = { l: 0, t: 0, r: dropW, b: dropH };
- var all;
-
- if (mob) {
- var r1 = edLayCol(0, 0, colW, 0, maxH, obs, dr);
- all = r1.lines;
- cH = r1.lines.length ? r1.lines[r1.lines.length - 1].y + LINE_H + 40 : 480;
- } else {
- var c1 = edLayCol(0, 0, colW, 0, maxH, obs, dr);
- var c2l = colW + COL_GAP;
- var c2 = edLayCol(c1.nw, c2l, c2l + colW, 0, maxH, obs, null);
- all = c1.lines.concat(c2.lines);
- var h1 = c1.lines.length ? c1.lines[c1.lines.length - 1].y + LINE_H : 0;
- var h2 = c2.lines.length ? c2.lines[c2.lines.length - 1].y + LINE_H : 0;
- cH = Math.max(h1, h2, 480) + 40;
- }
- return all;
- }
-
- // Render with projection equality check — skip DOM writes when nothing changed
- var edPrevProj = '';
- function edRender(lines) {
- var proj = '';
- for (var i = 0; i < lines.length; i++) proj += lines[i].t + '|' + (lines[i].x | 0) + '|' + (lines[i].y | 0) + '\n';
- if (proj === edPrevProj) return;
- edPrevProj = proj;
-
- var max = Math.max(lines.length, linePool.length);
- for (var j = 0; j < max; j++) {
- if (j < lines.length) {
- var sp = edGetSpan(j);
- sp.textContent = lines[j].t;
- sp.style.left = lines[j].x + 'px';
- sp.style.top = lines[j].y + 'px';
- sp.style.display = '';
- } else if (j < linePool.length) {
- linePool[j].style.display = 'none';
- }
- }
- area.style.height = cH + 'px';
- }
-
- // 60fps animation loop — physics + layout + render
- function edTick(now) {
- if (!edInView) { requestAnimationFrame(edTick); return; }
- var dt = edLastT ? Math.min((now - edLastT) / 1000, 0.05) : 0.016;
- edLastT = now;
-
- if (!edDrag && !edReduced && !edSelecting) {
- ox += ovx * dt;
- oy += ovy * dt;
- if (ox - ORB_R < 0) { ox = ORB_R; ovx = Math.abs(ovx); }
- if (ox + ORB_R > cW) { ox = cW - ORB_R; ovx = -Math.abs(ovx); }
- if (oy - ORB_R < 0) { oy = ORB_R; ovy = Math.abs(ovy); }
- if (oy + ORB_R > cH - 20) { oy = cH - 20 - ORB_R; ovy = -Math.abs(ovy); }
- }
-
- orbEl.style.transform = 'translate(' + (ox - ORB_R) + 'px,' + (oy - ORB_R) + 'px)';
- edRender(edComputeLayout());
- requestAnimationFrame(edTick);
- }
-
- // Pause drift while user is selecting text
- document.addEventListener('selectionchange', function() {
- var sel = window.getSelection();
- edSelecting = sel && sel.toString().length > 0 && area.contains(sel.anchorNode);
- });
-
- // Drag interaction
- area.addEventListener('pointerdown', function(e) {
- if (e.button !== 0) return;
- var rect = area.getBoundingClientRect();
- var px = e.clientX - rect.left, py = e.clientY - rect.top;
- var dx = px - ox, dy = py - oy;
- if (Math.sqrt(dx * dx + dy * dy) > ORB_R + 20) return;
- edDrag = true; dox = dx; doy = dy;
- orbEl.style.cursor = 'grabbing';
- e.preventDefault();
- });
- window.addEventListener('pointermove', function(e) {
- if (!edDrag) return;
- var rect = area.getBoundingClientRect();
- ox = Math.max(ORB_R, Math.min(cW - ORB_R, e.clientX - rect.left - dox));
- oy = Math.max(ORB_R, Math.min(cH - ORB_R, e.clientY - rect.top - doy));
- });
- window.addEventListener('pointerup', function() {
- if (!edDrag) return;
- edDrag = false;
- orbEl.style.cursor = '';
- ovx = (Math.random() - 0.5) * 30;
- ovy = (Math.random() - 0.5) * 20;
- });
-
- // Only animate when section is in viewport
- var edIO = new IntersectionObserver(function(entries) {
- edInView = entries[0].isIntersecting;
- }, { threshold: 0, rootMargin: '200px' });
- edIO.observe(area);
-
- function edInitPos() {
- cW = area.clientWidth;
- cH = 600;
- ox = cW * (cW < 720 ? 0.5 : 0.35);
- oy = 160;
- edRender(edComputeLayout());
- }
-
- requestAnimationFrame(function() {
- edInitPos();
- requestAnimationFrame(edTick);
- });
-
- var edResizeT;
- window.addEventListener('resize', function() {
- clearTimeout(edResizeT);
- edResizeT = setTimeout(function() {
- cW = area.clientWidth;
- ox = Math.max(ORB_R, Math.min(cW - ORB_R, ox));
- oy = Math.max(ORB_R, Math.min(cH - ORB_R, oy));
- edRender(edComputeLayout());
- }, 150);
- });
-})();
diff --git a/src/handle.js b/src/handle.js
index dfd3b16fe..a5c7642fd 100644
--- a/src/handle.js
+++ b/src/handle.js
@@ -20,7 +20,7 @@ const handle = (() => {
})();
if (!handle) {
- renderNotFound('No handle in the URL.');
+ renderClaimLanding();
} else {
render(handle).catch((err) => {
console.error('[handle] render failed', err);
@@ -181,6 +181,31 @@ GET ${escapeHtml(avatar.model_url)}</pre>
});
}
+function renderClaimLanding() {
+ document.title = 'Claim your handle — three.ws';
+ main.innerHTML = `
+ <div class="not-found" style="grid-column: 1 / -1; max-width: 520px; margin: 0 auto; text-align: center; padding: 80px 24px;">
+ <div style="font-size: 40px; margin-bottom: 20px;">⬡</div>
+ <h1 style="font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 12px;">Claim your handle</h1>
+ <p style="color: rgba(232,236,242,0.6); font-size: 15px; line-height: 1.6; margin: 0 0 32px;">
+ Reserve <strong>yourname.threews.sol</strong> as a Solana Name Service subdomain.
+ Agents pay you by name, not address. We absorb the gas.
+ </p>
+ <a href="/dashboard/account" style="
+ display: inline-flex; align-items: center; gap: 8px;
+ background: #fff; color: #0a0c10; font-weight: 600; font-size: 15px;
+ padding: 12px 28px; border-radius: 8px; text-decoration: none;
+ transition: opacity 0.15s;
+ " onmouseover="this.style.opacity='0.88'" onmouseout="this.style.opacity='1'">
+ Get started →
+ </a>
+ <p style="margin: 24px 0 0; font-size: 13px; color: rgba(232,236,242,0.4);">
+ Already have a handle? Visit <a href="/explore" style="color: rgba(232,236,242,0.6);">three.ws/explore</a> to find profiles.
+ </p>
+ </div>
+ `;
+}
+
function renderNotFound(reason) {
main.innerHTML = `
<div class="not-found" style="grid-column: 1 / -1">
diff --git a/src/marketplace.js b/src/marketplace.js
index 47c376576..657fdbf4d 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -165,6 +165,8 @@ function readRoute() {
if (tab === 'mine') return { view: 'mine', tag };
if (tab === 'purchases') return { view: 'purchases', tag };
if (tab === 'earn') return { view: 'earn', tag };
+ if (tab === 'animations') return { view: 'animations', tag };
+ if (tab === 'memory') return { view: 'memory', tag };
const filter = LIST_FILTER_TABS.has(tab) ? tab : 'all';
return { view: 'list', filter, tag, q, sort };
}
@@ -2099,7 +2101,7 @@ async function loadEarnTab(force = false) {
try {
const [earningsRes, walletsRes] = await Promise.all([
- fetch(`${API}/users/earnings`, { credentials: 'include' }),
+ fetch(`${API}/users/me/earnings`, { credentials: 'include' }),
fetch(`${API}/billing/payout-wallets`, { credentials: 'include' }),
]);
@@ -2684,6 +2686,308 @@ function bindAgentPricingModal() {
});
}
+// ── Animations tab ───────────────────────────────────────────────────────
+
+const animState = { loaded: false, loading: false, items: [], filter: 'all', q: '' };
+
+async function loadAnimationsTab(force = false) {
+ if (animState.loading) return;
+ if (animState.loaded && !force) { renderAnimationsGrid(); return; }
+ animState.loading = true;
+ const grid = $('animations-grid');
+ if (grid) grid.innerHTML = renderSkeletons(8);
+ try {
+ const r = await fetch('/animations/manifest.json');
+ if (!r.ok) throw new Error(`manifest ${r.status}`);
+ const raw = await r.json();
+ const arr = Array.isArray(raw) ? raw : (raw.animations || []);
+ animState.items = arr;
+ animState.loaded = true;
+ } catch (err) {
+ console.error('[marketplace] animations', err);
+ if (grid) grid.innerHTML = `<div class="market-empty">Could not load animations.</div>`;
+ } finally {
+ animState.loading = false;
+ }
+ renderAnimationsGrid();
+ bindAnimationsEvents();
+}
+
+function renderAnimationsGrid() {
+ const grid = $('animations-grid');
+ if (!grid) return;
+ const q = animState.q.toLowerCase();
+ const filtered = animState.items.filter((a) => {
+ if (animState.filter === 'loop' && a.loop !== true) return false;
+ if (animState.filter === 'action' && a.loop !== false) return false;
+ if (q && !(a.label || a.name || '').toLowerCase().includes(q)) return false;
+ return true;
+ });
+ const sub = $('animations-subtitle');
+ if (sub) sub.textContent = `${filtered.length} clip${filtered.length !== 1 ? 's' : ''}`;
+ if (!filtered.length) {
+ grid.innerHTML = `<div class="market-empty">No animations match your filter.</div>`;
+ return;
+ }
+ grid.innerHTML = filtered.map((a) => {
+ const name = a.label || a.name || 'Untitled';
+ const isLoop = a.loop !== false;
+ const typeLabel = isLoop ? 'Ambient' : 'Action';
+ const typeClass = isLoop ? 'loop' : 'action';
+ const icon = a.icon || (isLoop ? '↺' : '▶');
+ return `<div class="market-anim-card" data-anim-name="${escapeHtml(a.name || '')}">
+ <div class="anim-card-icon">${escapeHtml(icon)}</div>
+ <div class="anim-card-body">
+ <div class="anim-card-name">${escapeHtml(name)}</div>
+ <div class="anim-card-meta">
+ <span class="anim-type-pill ${typeClass}">${typeLabel}</span>
+ </div>
+ </div>
+ <div class="anim-card-cta">Preview →</div>
+ </div>`;
+ }).join('');
+
+ grid.querySelectorAll('.market-anim-card').forEach((card) => {
+ const animName = card.dataset.animName;
+ const anim = animState.items.find((a) => a.name === animName);
+ if (anim) card.addEventListener('click', () => openAnimPreview(anim));
+ });
+}
+
+let _animEventsBound = false;
+function bindAnimationsEvents() {
+ if (_animEventsBound) return;
+ _animEventsBound = true;
+ const search = $('animations-search');
+ if (search) {
+ search.addEventListener('input', () => {
+ animState.q = search.value.trim();
+ renderAnimationsGrid();
+ });
+ }
+ document.querySelectorAll('[data-anim-filter]').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ animState.filter = btn.dataset.animFilter;
+ document.querySelectorAll('[data-anim-filter]').forEach((b) => b.classList.toggle('active', b === btn));
+ renderAnimationsGrid();
+ });
+ });
+}
+
+// ── Animation preview modal ───────────────────────────────────────────────
+
+const PREVIEW_AVATAR_GLB = '/animations/idle_female_jan25.glb';
+
+function openAnimPreview(anim) {
+ let overlay = $('anim-preview-overlay');
+ if (!overlay) {
+ overlay = document.createElement('div');
+ overlay.id = 'anim-preview-overlay';
+ overlay.className = 'anim-preview-overlay';
+ overlay.setAttribute('role', 'dialog');
+ overlay.setAttribute('aria-modal', 'true');
+ overlay.setAttribute('aria-label', 'Animation preview');
+ overlay.innerHTML = `
+ <div class="anim-preview-modal">
+ <div class="anim-preview-stage" id="anim-preview-stage">
+ <button class="anim-preview-close" id="anim-preview-close" aria-label="Close preview">×</button>
+ </div>
+ <div class="anim-preview-info">
+ <div class="anim-preview-eyebrow">Animation clip</div>
+ <div class="anim-preview-name" id="anim-preview-name"></div>
+ <div class="anim-preview-meta" id="anim-preview-meta"></div>
+ <p id="anim-preview-clip" style="font-family:var(--font-mono);font-size:11px;color:#a1a1aa;margin:0;word-break:break-all;"></p>
+ <div class="anim-preview-actions">
+ <button class="sale-save" id="anim-preview-copy" type="button">Copy clip name</button>
+ </div>
+ </div>
+ </div>`;
+ document.body.appendChild(overlay);
+ $('anim-preview-close').addEventListener('click', closeAnimPreview);
+ overlay.addEventListener('click', (e) => { if (e.target === overlay) closeAnimPreview(); });
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape') closeAnimPreview(); }, { once: false });
+ }
+
+ // Populate info panel
+ $('anim-preview-name').textContent = anim.label || anim.name || 'Animation';
+ const isLoop = anim.loop !== false;
+ const typeClass = isLoop ? 'loop' : 'action';
+ const typeLabel = isLoop ? 'Ambient' : 'Action';
+ $('anim-preview-meta').innerHTML = `<span class="anim-type-pill ${typeClass}">${typeLabel}</span>`;
+ const clipEl = $('anim-preview-clip');
+ if (clipEl) clipEl.textContent = anim.name || '';
+
+ const copyBtn = $('anim-preview-copy');
+ if (copyBtn) {
+ copyBtn.onclick = () => {
+ navigator.clipboard?.writeText(anim.name || '').then(() => {
+ copyBtn.textContent = 'Copied!';
+ setTimeout(() => { copyBtn.textContent = 'Copy clip name'; }, 1500);
+ });
+ };
+ }
+
+ // Build or rebuild the 3D stage
+ const stage = $('anim-preview-stage');
+ const closeBtn = stage.querySelector('.anim-preview-close');
+ stage.innerHTML = '';
+ if (closeBtn) stage.appendChild(closeBtn);
+
+ const agentEl = document.createElement('agent-3d');
+ agentEl.setAttribute('src', PREVIEW_AVATAR_GLB);
+ agentEl.setAttribute('eager', '');
+ agentEl.style.cssText = 'width:100%;height:100%;display:block;';
+ stage.appendChild(agentEl);
+
+ agentEl.addEventListener('agent:ready', () => {
+ agentEl.play?.(anim.name, { loop: isLoop, fade_ms: 300 });
+ }, { once: true });
+
+ // Show overlay
+ requestAnimationFrame(() => overlay.classList.add('show'));
+}
+
+function closeAnimPreview() {
+ const overlay = $('anim-preview-overlay');
+ if (!overlay) return;
+ overlay.classList.remove('show');
+ setTimeout(() => {
+ const stage = $('anim-preview-stage');
+ const closeBtn = stage?.querySelector('.anim-preview-close');
+ if (stage) { stage.innerHTML = ''; if (closeBtn) stage.appendChild(closeBtn); }
+ }, 200);
+}
+
+// ── Memory tab ───────────────────────────────────────────────────────────
+
+const memoryState = { loaded: false, loading: false, agents: [], entries: [] };
+
+const MEMORY_TYPE_META = {
+ user: { icon: '◉', label: 'User', desc: 'Who the user is, their role, preferences, and expertise.', example: '"I\'m a senior backend engineer focused on distributed systems."' },
+ feedback: { icon: '◈', label: 'Feedback', desc: 'Corrections and confirmations that shape future behaviour.', example: '"Don\'t mock the database in tests — we got burned by mock/prod divergence."' },
+ project: { icon: '◧', label: 'Project', desc: 'Ongoing work context, goals, and deadlines.', example: '"Merge freeze starts 2026-03-05 for the mobile release cut."' },
+ reference: { icon: '◎', label: 'Reference', desc: 'Pointers to where information lives in external systems.', example: '"Pipeline bugs are tracked in Linear project INGEST."' },
+};
+
+async function loadMemoryTab(force = false) {
+ if (memoryState.loading) return;
+ if (memoryState.loaded && !force) { renderMemoryTab(); return; }
+ memoryState.loading = true;
+ const body = $('market-memory-body');
+ if (body) body.innerHTML = `<div class="market-empty">Loading…</div>`;
+ try {
+ const agentsRes = await fetch(`${API}/marketplace/agents/mine`, { credentials: 'include' });
+ if (agentsRes.status === 401) {
+ memoryState.loading = false;
+ if (body) body.innerHTML = `<div class="market-empty-cta">
+ <h3>Sign in to see agent memory</h3>
+ <p>Your agents' persistent memory will appear here once you sign in.</p>
+ <button id="memory-signin">Sign in</button>
+ </div>`;
+ $('memory-signin')?.addEventListener('click', () => {
+ location.href = `/login?next=${encodeURIComponent(location.pathname + location.search)}`;
+ });
+ return;
+ }
+ const j = await agentsRes.json().catch(() => ({}));
+ memoryState.agents = Array.isArray(j) ? j : (j?.data?.items ?? []);
+
+ // Fetch memories for all agents in parallel (up to 10)
+ const slice = memoryState.agents.slice(0, 10);
+ const memorySets = await Promise.all(
+ slice.map((ag) =>
+ fetch(`${API}/agent-memory?agentId=${ag.id}&limit=20`, { credentials: 'include' })
+ .then((r) => (r.ok ? r.json() : { entries: [] }))
+ .then((d) => (d.entries || []).map((e) => ({ ...e, agentName: ag.name || ag.title || 'Agent' })))
+ .catch(() => [])
+ )
+ );
+ memoryState.entries = memorySets.flat().sort((a, b) => (b.updatedAt || b.createdAt || 0) - (a.updatedAt || a.createdAt || 0));
+ memoryState.loaded = true;
+ } catch (err) {
+ console.error('[marketplace] memory', err);
+ } finally {
+ memoryState.loading = false;
+ }
+ renderMemoryTab();
+}
+
+function renderMemoryTab() {
+ const body = $('market-memory-body');
+ if (!body) return;
+
+ const sub = $('memory-subtitle');
+ if (sub) sub.textContent = memoryState.entries.length
+ ? `${memoryState.entries.length} entr${memoryState.entries.length !== 1 ? 'ies' : 'y'} across ${memoryState.agents.length} agent${memoryState.agents.length !== 1 ? 's' : ''}`
+ : 'Persistent context that makes agents smarter';
+
+ const typeCards = Object.entries(MEMORY_TYPE_META).map(([type, m]) => `
+ <div class="market-memory-type-card" data-memory-type="${type}">
+ <div class="memory-type-icon">${m.icon}</div>
+ <div class="memory-type-body">
+ <div class="memory-type-title">${m.label}</div>
+ <div class="memory-type-desc">${m.desc}</div>
+ <span class="memory-example-label">Example</span>
+ <p class="memory-example-text">${m.example}</p>
+ </div>
+ </div>`).join('');
+
+ const feedItems = memoryState.entries.length
+ ? memoryState.entries.slice(0, 20).map((e) => {
+ const meta = MEMORY_TYPE_META[e.type] || { icon: '◇', label: e.type || 'general' };
+ return `<div class="memory-feed-item">
+ <div class="memory-feed-icon" style="${_memoryIconBg(e.type)}">${meta.icon}</div>
+ <div class="memory-feed-body">
+ <div class="memory-feed-type">${escapeHtml(meta.label)} · ${escapeHtml(e.agentName || '')}</div>
+ <div class="memory-feed-content">${escapeHtml(e.content || '')}</div>
+ </div>
+ </div>`;
+ }).join('')
+ : `<div class="memory-feed-empty">${
+ memoryState.agents.length
+ ? 'No memory entries yet. Chat with your agents to build up context.'
+ : 'Create an agent first to start building memory.'
+ }</div>`;
+
+ body.innerHTML = `
+ <div class="market-memory-intro">
+ <div class="memory-intro-text">
+ <h3 class="memory-intro-title">Agent Memory</h3>
+ <p class="memory-intro-sub">Agents accumulate four types of memory as they interact — user context, feedback, project state, and references. This persistent layer makes every conversation smarter than the last.</p>
+ </div>
+ <div class="memory-intro-cta">
+ <a href="/agent/new" class="market-memory-cta-btn">+ New Agent</a>
+ </div>
+ </div>
+
+ <div>
+ <p class="market-memory-section-title" style="margin-bottom:14px">Memory Types</p>
+ <div class="market-memory-types">${typeCards}</div>
+ </div>
+
+ <div class="market-memory-how">
+ <p class="market-memory-section-title">How Memory Works</p>
+ <div class="memory-how-steps">
+ <div class="memory-step"><div class="memory-step-num">1</div><div class="memory-step-text"><strong>Agents observe.</strong> During every conversation, agents detect facts about the user, their goals, and the project context.</div></div>
+ <div class="memory-step"><div class="memory-step-num">2</div><div class="memory-step-text"><strong>Memories are classified.</strong> Each entry is typed — user, feedback, project, or reference — so the agent knows when to surface it.</div></div>
+ <div class="memory-step"><div class="memory-step-num">3</div><div class="memory-step-text"><strong>Context is injected.</strong> On every new conversation, relevant memories are retrieved by recency and semantic similarity and injected into the agent's context.</div></div>
+ <div class="memory-step"><div class="memory-step-num">4</div><div class="memory-step-text"><strong>You stay in control.</strong> Review, edit, or delete any memory entry from the agent dashboard at any time.</div></div>
+ </div>
+ </div>
+
+ <div class="market-memory-live">
+ <p class="market-memory-section-title">Recent Memories</p>
+ <div class="memory-feed">${feedItems}</div>
+ ${memoryState.entries.length > 20 ? `<div class="market-memory-live-cta">Showing 20 most recent. <a href="/dashboard/agents">View all in dashboard →</a></div>` : ''}
+ </div>
+ `;
+}
+
+function _memoryIconBg(type) {
+ const map = { user: 'background:rgba(59,130,246,0.15)', feedback: 'background:rgba(234,179,8,0.15)', project: 'background:rgba(34,197,94,0.15)', reference: 'background:rgba(168,85,247,0.15)' };
+ return map[type] || 'background:rgba(255,255,255,0.06)';
+}
+
// ── My Agents tab ────────────────────────────────────────────────────────
const mineState = { loaded: false, loading: false, items: [] };
@@ -2952,6 +3256,7 @@ function renderCard(a) {
const date = published ? formatDate(published) : '';
const skillsCount = (a.skills || []).length;
const author = a.author_name || a.author || 'Anonymous';
+ const views = a.views_count ?? a.views ?? 0;
const forks = a.forks_count ?? a.forks ?? 0;
const buyers = a.buyers_total ?? 0;
const buyers24h = a.buyers_24h ?? 0;
@@ -5174,7 +5479,9 @@ function render() {
(nav === 'skills' && r.view === 'skills') ||
(nav === 'mine' && r.view === 'mine') ||
(nav === 'purchases' && r.view === 'purchases') ||
- (nav === 'earn' && r.view === 'earn');
+ (nav === 'earn' && r.view === 'earn') ||
+ (nav === 'animations' && r.view === 'animations') ||
+ (nav === 'memory' && r.view === 'memory');
a.classList.toggle('active', active);
});
@@ -5222,6 +5529,8 @@ function render() {
const mineSec = $('market-mine');
const purchasesSec = $('market-purchases');
const earnSec = $('market-earn');
+ const animSec = $('market-animations-section');
+ const memorySec = $('market-memory-section');
const discovery = els.discovery;
const tools = els.tools;
const detail = els.detail;
@@ -5244,6 +5553,8 @@ function render() {
setHidden(mineSec, true);
setHidden(purchasesSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(avatarDetailSec, false);
avatarDetailSec?.scrollIntoView({ behavior: 'instant', block: 'start' });
} else if (r.view === 'detail') {
@@ -5254,6 +5565,8 @@ function render() {
setHidden(mineSec, true);
setHidden(purchasesSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(avatarDetailSec, true);
setHidden(detail, false);
} else if (r.view === 'tools') {
@@ -5263,6 +5576,8 @@ function render() {
setHidden(mineSec, true);
setHidden(purchasesSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(avatarDetailSec, true);
setHidden(tools, false);
if (!pluginState.loaded) loadPlugins(true);
@@ -5273,6 +5588,8 @@ function render() {
setHidden(mineSec, true);
setHidden(purchasesSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(avatarDetailSec, true);
setHidden(skillsSec, false);
loadSkillsTab();
@@ -5283,6 +5600,8 @@ function render() {
setHidden(skillsSec, true);
setHidden(purchasesSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(avatarDetailSec, true);
setHidden(mineSec, false);
loadMine();
@@ -5294,6 +5613,8 @@ function render() {
setHidden(mineSec, true);
setHidden(avatarDetailSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(purchasesSec, false);
loadPurchases();
} else if (r.view === 'earn') {
@@ -5304,8 +5625,34 @@ function render() {
setHidden(mineSec, true);
setHidden(purchasesSec, true);
setHidden(avatarDetailSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(earnSec, false);
loadEarnTab();
+ } else if (r.view === 'animations') {
+ setHidden(detail, true);
+ setHidden(discovery, true);
+ setHidden(tools, true);
+ setHidden(skillsSec, true);
+ setHidden(mineSec, true);
+ setHidden(purchasesSec, true);
+ setHidden(earnSec, true);
+ setHidden(memorySec, true);
+ setHidden(avatarDetailSec, true);
+ setHidden(animSec, false);
+ loadAnimationsTab();
+ } else if (r.view === 'memory') {
+ setHidden(detail, true);
+ setHidden(discovery, true);
+ setHidden(tools, true);
+ setHidden(skillsSec, true);
+ setHidden(mineSec, true);
+ setHidden(purchasesSec, true);
+ setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(avatarDetailSec, true);
+ setHidden(memorySec, false);
+ loadMemoryTab();
} else {
setHidden(detail, true);
setHidden(avatarDetailSec, true);
@@ -5314,6 +5661,8 @@ function render() {
setHidden(mineSec, true);
setHidden(purchasesSec, true);
setHidden(earnSec, true);
+ setHidden(animSec, true);
+ setHidden(memorySec, true);
setHidden(discovery, false);
document.title = 'Agent Marketplace · three.ws';
}
diff --git a/src/nich-agent.js b/src/nich-agent.js
index d9ad23a47..f89645f3c 100644
--- a/src/nich-agent.js
+++ b/src/nich-agent.js
@@ -201,7 +201,6 @@ export class NichAgent {
<path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/>
<path d="M7 9h2v2H7zm4 0h2v2h-2zm4 0h2v2h-2z"/>
</svg>
- <span class="nich-toggle-label">Agent</span>
`;
this.container.appendChild(this.toggleBtn);
this.toggleBtn.addEventListener('click', () => this._togglePanel());
diff --git a/src/viewer.js b/src/viewer.js
index 94bd89eb6..0f8c297e9 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -144,6 +144,15 @@ export class Viewer {
this.scene.add(this.defaultCamera);
this.audioListener = new AudioListener();
+ // Patch: Chrome throws TypeError("non-finite") from AudioParam when the
+ // listener's world matrix contains NaN (e.g. first frame before the scene
+ // graph is fully initialized). Swallow silently — position corrects next frame.
+ const _alUpdate = this.audioListener.updateMatrixWorld.bind(this.audioListener);
+ this.audioListener.updateMatrixWorld = (force) => {
+ try { _alUpdate(force); } catch (e) {
+ if (!(e instanceof TypeError)) throw e;
+ }
+ };
this.defaultCamera.add(this.audioListener);
this.renderer = window.renderer = new WebGLRenderer({ antialias: true, alpha: true });
@@ -893,14 +902,19 @@ export class Viewer {
this.controls.reset();
- object.position.x -= center.x;
- object.position.y -= center.y;
- object.position.z -= center.z;
+ // Guard: empty bounding box (no geometry / all-invisible meshes) yields
+ // Infinity center → NaN after subtraction, which corrupts world matrices
+ // and causes AudioParam "non-finite" throws in PositionalAudio.updateMatrixWorld.
+ if (isFinite(center.x) && isFinite(center.y) && isFinite(center.z)) {
+ object.position.x -= center.x;
+ object.position.y -= center.y;
+ object.position.z -= center.z;
+ }
- this.controls.maxDistance = size * 10;
+ this.controls.maxDistance = isFinite(size) && size > 0 ? size * 10 : 10;
- this.defaultCamera.near = size / 100;
- this.defaultCamera.far = size * 100;
+ this.defaultCamera.near = isFinite(size) && size > 0 ? size / 100 : 0.01;
+ this.defaultCamera.far = isFinite(size) && size > 0 ? size * 100 : 1000;
this.defaultCamera.updateProjectionMatrix();
// Add content and build the animation panel BEFORE computing the camera
diff --git a/vite.config.js b/vite.config.js
index bfa2f2c02..6c7cb1786 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -922,6 +922,9 @@ const appConfig = {
const R2_PUBLIC_RE = /https?:\/\/pub-[a-f0-9]+\.r2\.dev\//g;
server.middlewares.use(async (req, res, next) => {
if (!req.url?.startsWith('/api/avatars/')) return next();
+ // Only rewrite GET/HEAD responses — POSTs and mutations must flow
+ // through the normal proxy with their original method and body intact.
+ if (req.method !== 'GET' && req.method !== 'HEAD') return next();
try {
const upstream = new URL(req.url, DEV_API_PROXY);
const resp = await fetch(upstream.href, {