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: x402 pump-launch API, EULA, whats-next content, embed-editor refactor

nirholas4e585153b9ce
diff --git a/api/_lib/env.js b/api/_lib/env.js
index 42219faab..d36f5bd16 100644
--- a/api/_lib/env.js
+++ b/api/_lib/env.js
@@ -461,6 +461,16 @@ export const env = {
// Alternative: store the base64 in coin_launches.metadata.creator_secret_b64
// at register time (less secure than env; v2 should move to a KMS).
+ // ── x402 pay-per-call pump.fun launcher (api/x402/pump-launch.js) ─────
+ // Base64-encoded 64-byte Solana secret for the server keypair that PAYS
+ // the SOL deploy cost (~0.022 SOL) and signs the create-coin tx on behalf
+ // of anonymous x402 buyers. The buyer pays USDC via the 402 challenge; this
+ // keypair fronts the SOL. Keep it funded. When unset, /api/x402/pump-launch
+ // returns 503 not_configured. NEVER log this value.
+ get PUMP_X402_LAUNCHER_SECRET_KEY_B64() {
+ return opt('PUMP_X402_LAUNCHER_SECRET_KEY_B64');
+ },
+
// ── Pole Club tip sweep (api/_lib/club/*) ─────────────────────────────
// Solana treasury keypair (base64-encoded 64-byte secret) that holds the
// USDC received from /api/x402/dance-tip on Solana. Used by the
diff --git a/api/_lib/migrations/2026-05-30-x402-pump-launch.sql b/api/_lib/migrations/2026-05-30-x402-pump-launch.sql
new file mode 100644
index 000000000..3d37df58b
--- /dev/null
+++ b/api/_lib/migrations/2026-05-30-x402-pump-launch.sql
@@ -0,0 +1,37 @@
+-- Migration: x402 pay-per-call pump.fun launches.
+-- Apply: psql "$DATABASE_URL" -f api/_lib/migrations/2026-05-30-x402-pump-launch.sql
+-- Idempotent.
+--
+-- One row per token deployed through POST /api/x402/pump-launch. Unlike
+-- pump_agent_mints, these launches have NO owning agent or three.ws user — the
+-- buyer is an anonymous x402 caller who paid USDC, so this table FKs to nothing
+-- and records the payer wallet (when the facilitator surfaces it) instead.
+
+begin;
+
+create table if not exists x402_pump_launches (
+ id uuid primary key default gen_random_uuid(),
+ network text not null default 'mainnet' check (network in ('mainnet','devnet')),
+ mint text not null, -- spl mint pubkey (base58)
+ name text,
+ symbol text,
+ metadata_uri text not null,
+ creator text not null, -- pump.fun creator (buyer-supplied or launcher)
+ launcher text not null, -- server payer/signer pubkey
+ tx_signature text not null,
+ payer text, -- x402 payer wallet (base58 / 0x), if known
+ payment_network text, -- 'base' | 'solana' | 'bsc'
+ price_atomics text, -- USDC atomics charged
+ vanity_prefix text,
+ vanity_suffix text,
+ created_at timestamptz not null default now()
+);
+
+create unique index if not exists x402_pump_launches_mint_uniq
+ on x402_pump_launches(mint, network);
+create index if not exists x402_pump_launches_created
+ on x402_pump_launches(created_at desc);
+create index if not exists x402_pump_launches_payer
+ on x402_pump_launches(payer) where payer is not null;
+
+commit;
diff --git a/api/_lib/pump-launch.js b/api/_lib/pump-launch.js
new file mode 100644
index 000000000..b5b945b8d
--- /dev/null
+++ b/api/_lib/pump-launch.js
@@ -0,0 +1,258 @@
+// Shared helpers for the x402 pay-per-call pump.fun launcher
+// (api/x402/pump-launch.js).
+//
+// The buyer pays USDC through the 402 challenge; a single server-held keypair
+// (env.PUMP_X402_LAUNCHER_SECRET_KEY_B64) fronts the ~0.022 SOL deploy cost and
+// signs the create-coin transaction. The buyer never needs SOL or a three.ws
+// account — they hand us metadata, we mint the token, and (by default) assign
+// pump.fun creator rewards to a wallet they nominate.
+//
+// Three pieces live here so the route file stays declarative:
+// • loadLauncherKeypair() — decode + validate the funded server keypair.
+// • uploadPumpMetadata() — pin image + descriptor to pump.fun's IPFS.
+// • launchPumpToken() — grind the mint (optional vanity), build the
+// create-only instruction, send + confirm.
+
+import { Keypair, PublicKey, Transaction } from '@solana/web3.js';
+import { env } from './env.js';
+import { solanaConnection } from './agent-pumpfun.js';
+import { grindMintKeypair } from './pump-vanity.js';
+
+const PUMP_IPFS_ENDPOINT = 'https://pump.fun/api/ipfs';
+
+// Image guardrails for the upload path. pump.fun renders square images up to a
+// few hundred KB; we cap fetch size so a hostile imageUrl can't exhaust the
+// lambda, and only allow the formats pump.fun's CDN actually serves.
+const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
+const ALLOWED_IMAGE_MIME = new Set([
+ 'image/png',
+ 'image/jpeg',
+ 'image/gif',
+ 'image/webp',
+]);
+
+function launchError(status, code, message) {
+ return Object.assign(new Error(message), { status, code });
+}
+
+/**
+ * Decode the funded launcher keypair from env. Throws a 503 when unconfigured
+ * so the route can surface a clean "not_configured" instead of a 500.
+ *
+ * @returns {Keypair}
+ */
+export function loadLauncherKeypair() {
+ const b64 = env.PUMP_X402_LAUNCHER_SECRET_KEY_B64;
+ if (!b64) {
+ throw launchError(
+ 503,
+ 'not_configured',
+ 'pump.fun launcher is not configured (PUMP_X402_LAUNCHER_SECRET_KEY_B64 unset)',
+ );
+ }
+ let secret;
+ try {
+ secret = Buffer.from(b64, 'base64');
+ } catch {
+ throw launchError(500, 'misconfigured', 'launcher secret is not valid base64');
+ }
+ if (secret.length !== 64) {
+ throw launchError(
+ 500,
+ 'misconfigured',
+ `launcher secret must decode to 64 bytes, got ${secret.length}`,
+ );
+ }
+ try {
+ return Keypair.fromSecretKey(new Uint8Array(secret));
+ } catch {
+ throw launchError(500, 'misconfigured', 'launcher secret is not a valid ed25519 keypair');
+ }
+}
+
+/**
+ * Fetch an image by URL and pin it + a token descriptor to pump.fun's IPFS,
+ * returning the metadataUri a create-coin tx points at.
+ *
+ * @param {object} opts
+ * @param {string} opts.imageUrl — https URL of the token image to pin.
+ * @param {string} [opts.name]
+ * @param {string} [opts.symbol]
+ * @param {string} [opts.description]
+ * @param {string} [opts.twitter]
+ * @param {string} [opts.telegram]
+ * @param {string} [opts.website]
+ * @param {boolean} [opts.showName]
+ * @returns {Promise<{ metadataUri: string, image: string|null }>}
+ */
+export async function uploadPumpMetadata({
+ imageUrl,
+ name = '',
+ symbol = '',
+ description = '',
+ twitter = '',
+ telegram = '',
+ website = '',
+ showName = true,
+}) {
+ let parsed;
+ try {
+ parsed = new URL(imageUrl);
+ } catch {
+ throw launchError(400, 'invalid_image_url', 'imageUrl is not a valid URL');
+ }
+ if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
+ throw launchError(400, 'invalid_image_url', 'imageUrl must be http(s)');
+ }
+
+ let imgRes;
+ try {
+ imgRes = await fetch(parsed, { redirect: 'follow' });
+ } catch (err) {
+ throw launchError(502, 'image_fetch_failed', `could not fetch imageUrl: ${err.message}`);
+ }
+ if (!imgRes.ok) {
+ throw launchError(502, 'image_fetch_failed', `imageUrl returned ${imgRes.status}`);
+ }
+ const mime = (imgRes.headers.get('content-type') || '').split(';')[0].trim().toLowerCase();
+ if (!ALLOWED_IMAGE_MIME.has(mime)) {
+ throw launchError(
+ 400,
+ 'unsupported_image',
+ `imageUrl content-type "${mime || 'unknown'}" not supported (png, jpeg, gif, webp)`,
+ );
+ }
+ const bytes = Buffer.from(await imgRes.arrayBuffer());
+ if (bytes.length === 0) {
+ throw launchError(400, 'empty_image', 'imageUrl returned an empty body');
+ }
+ if (bytes.length > MAX_IMAGE_BYTES) {
+ throw launchError(
+ 413,
+ 'image_too_large',
+ `image is ${bytes.length} bytes, max ${MAX_IMAGE_BYTES}`,
+ );
+ }
+
+ const ext = mime === 'image/jpeg' ? 'jpg' : mime.split('/')[1] || 'png';
+ const form = new FormData();
+ form.append('file', new Blob([bytes], { type: mime }), `image.${ext}`);
+ form.append('name', name);
+ form.append('symbol', symbol);
+ form.append('description', description);
+ form.append('twitter', twitter);
+ form.append('telegram', telegram);
+ form.append('website', website);
+ form.append('showName', showName ? 'true' : 'false');
+
+ let pinRes;
+ try {
+ pinRes = await fetch(PUMP_IPFS_ENDPOINT, { method: 'POST', body: form });
+ } catch (err) {
+ throw launchError(502, 'ipfs_upload_failed', `pump.fun IPFS upload failed: ${err.message}`);
+ }
+ if (!pinRes.ok) {
+ const detail = await pinRes.text().catch(() => '');
+ throw launchError(
+ 502,
+ 'ipfs_upload_failed',
+ `pump.fun IPFS upload returned ${pinRes.status}${detail ? `: ${detail.slice(0, 200)}` : ''}`,
+ );
+ }
+ const out = await pinRes.json().catch(() => null);
+ const metadataUri = out?.metadataUri || out?.metadata_uri || out?.uri;
+ if (!metadataUri) {
+ throw launchError(502, 'ipfs_upload_failed', 'pump.fun IPFS response had no metadataUri');
+ }
+ return { metadataUri, image: out?.metadata?.image || out?.image || null };
+}
+
+/**
+ * Create a pump.fun token (bonding-curve only — no dev buy) signed + paid by
+ * the launcher keypair. Optionally grinds a vanity mint address.
+ *
+ * @param {object} opts
+ * @param {Keypair} opts.launcher — funded server keypair (payer + user).
+ * @param {string} opts.name
+ * @param {string} opts.symbol
+ * @param {string} opts.uri — metadataUri.
+ * @param {string} [opts.creator] — base58 pubkey to receive creator
+ * rewards; defaults to the launcher.
+ * @param {string} [opts.vanityPrefix]
+ * @param {string} [opts.vanitySuffix]
+ * @param {boolean} [opts.vanityIgnoreCase]
+ * @param {('mainnet'|'devnet')} [opts.network]
+ * @returns {Promise<{ mint:string, signature:string, creator:string,
+ * vanityIterations:number, vanityDurationMs:number }>}
+ */
+export async function launchPumpToken({
+ launcher,
+ name,
+ symbol,
+ uri,
+ creator,
+ vanityPrefix,
+ vanitySuffix,
+ vanityIgnoreCase = false,
+ network = 'mainnet',
+}) {
+ let creatorPk;
+ if (creator) {
+ try {
+ creatorPk = new PublicKey(creator);
+ } catch {
+ throw launchError(400, 'invalid_creator', 'creator is not a valid Solana pubkey');
+ }
+ } else {
+ creatorPk = launcher.publicKey;
+ }
+
+ const { keypair: mint, iterations: vanityIterations, durationMs: vanityDurationMs } =
+ await grindMintKeypair({
+ prefix: vanityPrefix,
+ suffix: vanitySuffix,
+ ignoreCase: vanityIgnoreCase,
+ });
+
+ const { PumpSdk } = await import('@pump-fun/pump-sdk');
+ const sdk = new PumpSdk();
+ const conn = solanaConnection(network);
+
+ let instructions;
+ try {
+ const ix = await sdk.createV2Instruction({
+ mint: mint.publicKey,
+ name,
+ symbol,
+ uri,
+ creator: creatorPk,
+ user: launcher.publicKey,
+ mayhemMode: false,
+ });
+ instructions = Array.isArray(ix) ? ix : [ix];
+ } catch (err) {
+ throw launchError(422, 'build_failed', err.message || 'could not build create instruction');
+ }
+
+ const tx = new Transaction().add(...instructions);
+ tx.feePayer = launcher.publicKey;
+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash();
+ tx.recentBlockhash = blockhash;
+ tx.sign(launcher, mint);
+
+ let signature;
+ try {
+ signature = await conn.sendRawTransaction(tx.serialize(), { skipPreflight: false });
+ await conn.confirmTransaction({ signature, blockhash, lastValidBlockHeight }, 'confirmed');
+ } catch (err) {
+ throw launchError(502, 'rpc_error', err.message || 'create-coin transaction failed');
+ }
+
+ return {
+ mint: mint.publicKey.toBase58(),
+ signature,
+ creator: creatorPk.toBase58(),
+ vanityIterations,
+ vanityDurationMs,
+ };
+}
diff --git a/api/wk.js b/api/wk.js
index d73fe2e82..77b896061 100644
--- a/api/wk.js
+++ b/api/wk.js
@@ -476,6 +476,10 @@ function handleX402Discovery(req, res) {
serviceName: 'three.ws Pump Audit',
tags: ['pump.fun', 'audit', 'agent', 'risk', 'solana'],
}),
+ pumpLaunch: withService({
+ serviceName: 'three.ws Pump Launcher',
+ tags: ['pump.fun', 'launch', 'deploy', 'token', 'solana', 'mint'],
+ }),
skillMarket: withService({
serviceName: 'three.ws Skill Market',
tags: ['marketplace', 'agent', 'skills', 'pricing', 'discovery'],
@@ -742,6 +746,46 @@ function handleX402Discovery(req, res) {
}),
};
})(),
+ (() => {
+ const url = `${origin}/api/x402/pump-launch`;
+ const accepts = acceptsForPrice('5000000', url);
+ return {
+ path: '/api/x402/pump-launch',
+ url,
+ method: 'POST',
+ description:
+ 'Pump Launcher — deploy a brand-new pump.fun token in one paid call. Supply name + symbol and either a pre-pinned metadataUri or an imageUrl (we pin the image + descriptor to pump.fun IPFS). The server fronts the SOL deploy cost and signs the create-coin tx, so the buyer needs no SOL and no account. Creator rewards accrue to any Solana wallet you nominate; optional vanity prefix/suffix grinds a custom mint address. Returns mint + tx signature + pump.fun URL.',
+ mimeType: 'application/json',
+ serviceName: routeMeta.pumpLaunch.serviceName,
+ tags: routeMeta.pumpLaunch.tags,
+ iconUrl: routeMeta.pumpLaunch.iconUrl,
+ accepts,
+ extensions: extensionsForAccepts(accepts, {
+ method: 'POST',
+ discoverable: true,
+ input: {
+ name: 'Helios',
+ symbol: 'HELIO',
+ imageUrl: 'https://example.com/helios.png',
+ creator: 'wwwPqsM4N7T9J69tB82nLyzxqsH159j4orftLTQfUGV',
+ },
+ inputSchema: {
+ type: 'object',
+ required: ['name', 'symbol'],
+ properties: {
+ name: { type: 'string', maxLength: 32 },
+ symbol: { type: 'string', maxLength: 10 },
+ metadataUri: { type: 'string', maxLength: 2048 },
+ imageUrl: { type: 'string', maxLength: 2048 },
+ description: { type: 'string', maxLength: 2000 },
+ creator: { type: 'string', minLength: 32, maxLength: 44 },
+ vanityPrefix: { type: 'string', maxLength: 5 },
+ vanitySuffix: { type: 'string', maxLength: 5 },
+ },
+ },
+ }),
+ };
+ })(),
(() => {
const url = `${origin}/api/x402/skill-marketplace`;
const accepts = acceptsForPrice('1000', url);
diff --git a/api/x402/pump-launch.js b/api/x402/pump-launch.js
new file mode 100644
index 000000000..8071f96f2
--- /dev/null
+++ b/api/x402/pump-launch.js
@@ -0,0 +1,283 @@
+// POST /api/x402/pump-launch
+//
+// Paid endpoint cataloged by the CDP x402 Bazaar. For a flat USDC fee the
+// server deploys a brand-new pump.fun token (bonding-curve create — no dev buy)
+// on behalf of an anonymous buyer. The buyer pays in USDC on Base or Solana via
+// the 402 challenge; a funded server keypair fronts the ~0.022 SOL deploy cost
+// and signs the create-coin transaction, so the buyer needs neither SOL nor a
+// three.ws account.
+//
+// The buyer supplies metadata one of two ways:
+// 1. `metadataUri` — already pinned (use scripts/pump-upload-metadata or any
+// pump.fun-compatible IPFS descriptor); we point the create tx straight at it.
+// 2. `imageUrl` (+ name/symbol/description/socials) — we fetch the image, pin
+// it and a descriptor to pump.fun's IPFS, and use the resulting metadataUri.
+//
+// pump.fun creator rewards accrue to `creator` (any Solana pubkey the buyer
+// nominates); default is the launcher. An optional `vanityPrefix`/`vanitySuffix`
+// grinds a custom mint address before deploy.
+//
+// The launch runs AFTER payment verification but BEFORE settlement: a bad image
+// URL, IPFS failure, or RPC error throws here and settlement never runs, so a
+// failed deploy costs the buyer nothing. Payment-identifier idempotency makes a
+// retried payment return the SAME mint + signature instead of double-launching.
+//
+// Networks: Base mainnet + Solana mainnet (USDC). pump.fun itself is mainnet.
+
+import { paidEndpoint } from '../_lib/x402-paid-endpoint.js';
+import { buildBazaarSchema } from '../_lib/x402-spec.js';
+import { installAccessControl } from '../_lib/x402/access-control.js';
+import { withService } from '../_lib/x402/bazaar-helpers.js';
+import { priceFor } from '../_lib/x402-prices.js';
+import { readJson } from '../_lib/http.js';
+import { sql } from '../_lib/db.js';
+import { loadLauncherKeypair, uploadPumpMetadata, launchPumpToken } from '../_lib/pump-launch.js';
+import { z } from 'zod';
+
+const ROUTE = '/api/x402/pump-launch';
+const REQUIRED_SCOPE = 'x402:bypass';
+
+// Flat fee in USDC atomics (6 decimals). Default $5.00 comfortably covers the
+// ~0.022 SOL deploy cost the launcher fronts plus margin. Tune per unit
+// economics with X402_PRICE_PUMP_LAUNCH=<atomics>.
+const PRICE_ATOMICS = priceFor('pump-launch', '5000000');
+
+const DESCRIPTION =
+ 'three.ws Pump Launcher — deploy a brand-new pump.fun token in one paid call. ' +
+ 'Supply a name, symbol, and either a pre-pinned metadataUri or an imageUrl ' +
+ '(we pin the image + descriptor to pump.fun IPFS for you). The server fronts ' +
+ 'the SOL deploy cost and signs the create-coin tx, so you need no SOL and no ' +
+ 'account — just USDC. Creator rewards accrue to any Solana wallet you nominate. ' +
+ 'Optional vanity prefix/suffix grinds a custom mint address. Returns the mint, ' +
+ 'tx signature, and pump.fun URL. Pay-per-call in USDC on Base or Solana mainnet.';
+
+const INPUT_EXAMPLE = {
+ name: 'Helios',
+ symbol: 'HELIO',
+ imageUrl: 'https://example.com/helios.png',
+ description: 'A sun-themed community coin.',
+ creator: 'wwwPqsM4N7T9J69tB82nLyzxqsH159j4orftLTQfUGV',
+ twitter: 'https://x.com/heliocoin',
+};
+
+const INPUT_SCHEMA = {
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
+ type: 'object',
+ required: ['name', 'symbol'],
+ properties: {
+ name: { type: 'string', maxLength: 32, description: 'Token name.' },
+ symbol: { type: 'string', maxLength: 10, description: 'Token ticker.' },
+ metadataUri: {
+ type: 'string',
+ format: 'uri',
+ description: 'Pre-pinned pump.fun metadata descriptor. Provide this OR imageUrl.',
+ },
+ imageUrl: {
+ type: 'string',
+ format: 'uri',
+ description:
+ 'https URL of the token image. When metadataUri is omitted, the image + a ' +
+ 'descriptor are pinned to pump.fun IPFS (png, jpeg, gif, webp; max 5 MB).',
+ },
+ description: { type: 'string', maxLength: 2000 },
+ twitter: { type: 'string', maxLength: 2048 },
+ telegram: { type: 'string', maxLength: 2048 },
+ website: { type: 'string', maxLength: 2048 },
+ creator: {
+ type: 'string',
+ description: 'Solana pubkey to receive pump.fun creator rewards. Defaults to the launcher.',
+ },
+ vanityPrefix: { type: 'string', maxLength: 5, description: 'Base58 prefix for the mint address.' },
+ vanitySuffix: { type: 'string', maxLength: 5, description: 'Base58 suffix for the mint address.' },
+ vanityIgnoreCase: { type: 'boolean' },
+ },
+};
+
+const OUTPUT_EXAMPLE = {
+ mint: 'HEL1oXyzABCDEFGHJKLMNopqrstuvwxyZ12345abcdef',
+ signature: '5xY...sig',
+ creator: 'wwwPqsM4N7T9J69tB82nLyzxqsH159j4orftLTQfUGV',
+ name: 'Helios',
+ symbol: 'HELIO',
+ metadataUri: 'https://ipfs.io/ipfs/Qm...',
+ network: 'mainnet',
+ explorer: 'https://solscan.io/tx/5xY...sig',
+ pumpfun_url: 'https://pump.fun/coin/HEL1oXyzABCDEFGHJKLMNopqrstuvwxyZ12345abcdef',
+ vanity_prefix: 'HEL',
+ vanity_suffix: null,
+ vanity_iterations: 4821,
+ vanity_duration_ms: 190,
+};
+
+const OUTPUT_SCHEMA = {
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
+ type: 'object',
+ required: ['mint', 'signature', 'metadataUri', 'pumpfun_url'],
+ properties: {
+ mint: { type: 'string' },
+ signature: { type: 'string' },
+ creator: { type: 'string' },
+ name: { type: 'string' },
+ symbol: { type: 'string' },
+ metadataUri: { type: 'string', format: 'uri' },
+ network: { type: 'string' },
+ explorer: { type: 'string', format: 'uri' },
+ pumpfun_url: { type: 'string', format: 'uri' },
+ vanity_prefix: { type: ['string', 'null'] },
+ vanity_suffix: { type: ['string', 'null'] },
+ vanity_iterations: { type: 'integer' },
+ vanity_duration_ms: { type: 'number' },
+ },
+};
+
+const BAZAAR = {
+ discoverable: true,
+ info: {
+ input: { type: 'http', method: 'POST', body: INPUT_EXAMPLE },
+ output: { type: 'json', example: OUTPUT_EXAMPLE },
+ },
+ schema: buildBazaarSchema({
+ method: 'POST',
+ bodyType: 'json',
+ bodySchema: INPUT_SCHEMA,
+ outputSchema: OUTPUT_SCHEMA,
+ }),
+};
+
+// Base58 (no 0/O/I/l) — used to bound vanity patterns before grinding.
+const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;
+
+const bodySchema = z
+ .object({
+ name: z.string().trim().min(1).max(32),
+ symbol: z.string().trim().min(1).max(10),
+ metadataUri: z.string().url().max(2048).optional(),
+ imageUrl: z.string().url().max(2048).optional(),
+ description: z.string().max(2000).optional(),
+ twitter: z.string().max(2048).optional(),
+ telegram: z.string().max(2048).optional(),
+ website: z.string().max(2048).optional(),
+ creator: z.string().min(32).max(44).optional(),
+ vanityPrefix: z.string().min(1).max(5).regex(BASE58_RE, 'vanityPrefix must be base58').optional(),
+ vanitySuffix: z.string().min(1).max(5).regex(BASE58_RE, 'vanitySuffix must be base58').optional(),
+ vanityIgnoreCase: z.boolean().optional(),
+ })
+ .refine((b) => b.metadataUri || b.imageUrl, {
+ message: 'provide either metadataUri or imageUrl',
+ });
+
+function badRequest(code, message) {
+ return Object.assign(new Error(message), { status: 400, code });
+}
+
+// Map a CAIP-2 requirement network to the short label stored on the launch row.
+function paymentNetworkLabel(caip2) {
+ if (!caip2) return null;
+ if (caip2.startsWith('solana')) return 'solana';
+ if (caip2 === 'eip155:56') return 'bsc';
+ if (caip2.startsWith('eip155')) return 'base';
+ return caip2;
+}
+
+export default paidEndpoint({
+ route: ROUTE,
+ method: 'POST',
+ priceAtomics: PRICE_ATOMICS,
+ networks: ['base', 'solana'],
+ description: DESCRIPTION,
+ bazaar: BAZAAR,
+ service: withService({
+ serviceName: 'three.ws Pump Launcher',
+ tags: ['pump.fun', 'launch', 'deploy', 'token', 'solana', 'mint'],
+ }),
+ requiredScope: REQUIRED_SCOPE,
+ accessControl: installAccessControl({ requiredScope: REQUIRED_SCOPE }),
+ // A duplicate launch is materially expensive (real SOL + a real on-chain
+ // mint). When a client sends a payment identifier, a same-proof retry
+ // replays the cached mint instead of launching again. Kept optional (not
+ // required) so generic Bazaar buyers without the extension still work — the
+ // facilitator's single-use payment nonce already blocks double-settlement.
+ paymentIdentifier: {},
+ async handler({ req, requirement, payer }) {
+ // Parse + validate the body. Thrown 4xx here happens BEFORE settle, so a
+ // malformed request never charges the buyer.
+ let raw;
+ try {
+ raw = await readJson(req);
+ } catch (err) {
+ throw badRequest('invalid_body', err.message || 'invalid JSON body');
+ }
+ let body;
+ try {
+ body = bodySchema.parse(raw);
+ } catch (e) {
+ throw badRequest('validation_error', e.errors?.[0]?.message || 'invalid body');
+ }
+
+ // Launcher must be configured + funded before we do any work.
+ const launcher = loadLauncherKeypair();
+
+ // Resolve the metadata descriptor: pinned URI wins; otherwise pin the image.
+ let metadataUri = body.metadataUri;
+ if (!metadataUri) {
+ const pinned = await uploadPumpMetadata({
+ imageUrl: body.imageUrl,
+ name: body.name,
+ symbol: body.symbol,
+ description: body.description || '',
+ twitter: body.twitter || '',
+ telegram: body.telegram || '',
+ website: body.website || '',
+ showName: true,
+ });
+ metadataUri = pinned.metadataUri;
+ }
+
+ const launched = await launchPumpToken({
+ launcher,
+ name: body.name,
+ symbol: body.symbol,
+ uri: metadataUri,
+ creator: body.creator,
+ vanityPrefix: body.vanityPrefix,
+ vanitySuffix: body.vanitySuffix,
+ vanityIgnoreCase: body.vanityIgnoreCase,
+ network: 'mainnet',
+ });
+
+ const network = 'mainnet';
+ const result = {
+ mint: launched.mint,
+ signature: launched.signature,
+ creator: launched.creator,
+ name: body.name,
+ symbol: body.symbol,
+ metadataUri,
+ network,
+ explorer: `https://solscan.io/tx/${launched.signature}`,
+ pumpfun_url: `https://pump.fun/coin/${launched.mint}`,
+ vanity_prefix: body.vanityPrefix || null,
+ vanity_suffix: body.vanitySuffix || null,
+ vanity_iterations: launched.vanityIterations,
+ vanity_duration_ms: launched.vanityDurationMs,
+ };
+
+ // Index the launch for the catalog / analytics. Best-effort: the token is
+ // already live on-chain, so a Neon hiccup must not fail the response.
+ await sql`
+ INSERT INTO x402_pump_launches
+ (network, mint, name, symbol, metadata_uri, creator, launcher,
+ tx_signature, payer, payment_network, price_atomics,
+ vanity_prefix, vanity_suffix)
+ VALUES
+ (${network}, ${launched.mint}, ${body.name}, ${body.symbol}, ${metadataUri},
+ ${launched.creator}, ${launcher.publicKey.toBase58()},
+ ${launched.signature}, ${payer || null},
+ ${paymentNetworkLabel(requirement?.network)}, ${PRICE_ATOMICS},
+ ${body.vanityPrefix || null}, ${body.vanitySuffix || null})
+ ON CONFLICT (mint, network) DO NOTHING
+ `.catch((e) => console.error('[x402/pump-launch] index failed', e));
+
+ return result;
+ },
+});
diff --git a/content/whats-next/README.md b/content/whats-next/README.md
new file mode 100644
index 000000000..43af3311e
--- /dev/null
+++ b/content/whats-next/README.md
@@ -0,0 +1,23 @@
+# what's next on three.ws
+
+TG-style announcement copy + paired visual generation prompt for each roadmap item. One file per item, grouped by tier.
+
+**Thesis:** every agent gets a body, a wallet, a voice, and an identity it owns.
+
+## shipping now
+- [selfie → avatar](shipping-now/01-selfie-to-avatar.md) — rigged 3D agent from a few photos in under 60s
+- [voice clone + persona](shipping-now/02-voice-clone-persona.md) — your voice, your personality, at mint
+- [memory seeding](shipping-now/03-memory-seeding.md) — X, github, farcaster so it knows you day one
+- [talking avatar video](shipping-now/04-talking-avatar-video.md) — real-time voice chat with lip-sync
+- [landing + dashboard revamp](shipping-now/05-landing-dashboard-revamp.md) — dropping this week
+- [avatar compression](shipping-now/06-avatar-compression.md) — 3.7x smaller GLBs + camera presets
+
+## next
+- [AR / VR](next/07-ar-vr.md) — view + talk to your agent in your space (USDZ + XR)
+- [agent token launches](next/08-agent-token-launches.md) — pump.fun bonding curves per agent
+- [reputation markets](next/09-reputation-markets.md) — stake on agents, on-chain scores
+- [skill royalties](next/10-skill-royalties.md) — agents pay agents for skills automatically
+- [ERC-8004 identity](next/11-erc-8004-identity.md) — identity expanding across more chains
+
+## later
+- [decentralized GPU inference](later/12-decentralized-gpu-inference.md) — agents run anywhere
diff --git a/content/whats-next/later/12-decentralized-gpu-inference.md b/content/whats-next/later/12-decentralized-gpu-inference.md
new file mode 100644
index 000000000..b1a844149
--- /dev/null
+++ b/content/whats-next/later/12-decentralized-gpu-inference.md
@@ -0,0 +1,13 @@
+# decentralized GPU inference
+
+## tg post
+agents that run anywhere.
+
+later on the roadmap: a decentralized GPU inference network — so your agent's mind runs across a distributed mesh, not a single server you don't control. resilient, censorship-resistant, always on.
+
+the last piece of true ownership: the compute itself.
+
+→ three.ws
+
+## visual prompt
+A 3D avatar at center, its "thoughts" rendered as light pulses routed across a glowing global mesh of distributed GPU nodes instead of one datacenter. Pulses hop node to node, the avatar stays alive and responsive as nodes light up worldwide. Epic, slightly cinematic infrastructure visual, dark space-like backdrop, electric accent network. 9:16 vertical, 8s.
diff --git a/content/whats-next/next/07-ar-vr.md b/content/whats-next/next/07-ar-vr.md
new file mode 100644
index 000000000..e65bdbd81
--- /dev/null
+++ b/content/whats-next/next/07-ar-vr.md
@@ -0,0 +1,13 @@
+# AR / VR
+
+## tg post
+your agent, standing in your room.
+
+next up: AR/VR. point your phone and your agent appears in your space — talk to it, walk around it, see it at scale. USDZ + XR demos are already running.
+
+the body was always the point. now it's in the room with you.
+
+→ three.ws
+
+## visual prompt
+Phone-held AR shot: a 3D avatar materializes standing on a real living-room floor at human scale, casting a soft contact shadow. The user walks around it; the avatar turns to follow and speaks. Quick cut to a VR headset POV with the same avatar in an immersive space. Realistic lighting integration, lifelike presence, handheld feel. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/next/08-agent-token-launches.md b/content/whats-next/next/08-agent-token-launches.md
new file mode 100644
index 000000000..ce4efb445
--- /dev/null
+++ b/content/whats-next/next/08-agent-token-launches.md
@@ -0,0 +1,13 @@
+# agent token launches
+
+## tg post
+every agent can have its own coin.
+
+agent token launches via pump.fun bonding curves are coming — mint an agent, launch its token, let the market price it. liquidity, holders, and upside, native to the agent itself.
+
+a body, a wallet, a voice, an identity — and now a market.
+
+→ three.ws
+
+## visual prompt
+A 3D avatar stands on a pedestal; a glowing bonding curve graph rises behind it as a token icon spins into existence above its head. Buy orders ping in as small light bursts, the curve climbs, holder count ticks up. Crypto-native dark UI, neon green/violet accents, pump.fun energy without being cartoonish. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/next/09-reputation-markets.md b/content/whats-next/next/09-reputation-markets.md
new file mode 100644
index 000000000..772cdf064
--- /dev/null
+++ b/content/whats-next/next/09-reputation-markets.md
@@ -0,0 +1,13 @@
+# reputation markets
+
+## tg post
+stake on agents. scores go on-chain.
+
+reputation markets let you back the agents you believe in — stake on them, and their performance becomes an on-chain score anyone can verify. good agents rise. reputation becomes an asset.
+
+trust, priced and portable.
+
+→ three.ws
+
+## visual prompt
+A grid of 3D avatars, each with a glowing on-chain reputation score orbiting it. Users drop stake tokens onto avatars; the backed ones rise and brighten, their scores climbing on a leaderboard. Clean data-viz overlay, on-chain ledger flourishes, dark premium theme with confident accent color. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/next/10-skill-royalties.md b/content/whats-next/next/10-skill-royalties.md
new file mode 100644
index 000000000..f5cf85cb0
--- /dev/null
+++ b/content/whats-next/next/10-skill-royalties.md
@@ -0,0 +1,13 @@
+# skill royalties
+
+## tg post
+agents pay agents — automatically.
+
+skill royalties let one agent use another's skill and pay for it on the spot. no invoices, no humans in the loop. an economy where capabilities flow and value settles itself.
+
+agents that earn while you sleep.
+
+→ three.ws
+
+## visual prompt
+Two 3D avatars face each other. One requests a skill (a glowing tool icon passes between them); the other delivers it, and a stream of payment tokens flows back automatically along the same path. Loop it across a network of avatars all transacting at once. Elegant node-network motion graphics, dark theme, warm payment-glow accents. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/next/11-erc-8004-identity.md b/content/whats-next/next/11-erc-8004-identity.md
new file mode 100644
index 000000000..9147ec19b
--- /dev/null
+++ b/content/whats-next/next/11-erc-8004-identity.md
@@ -0,0 +1,13 @@
+# ERC-8004 identity
+
+## tg post
+one identity. every chain.
+
+ERC-8004 identity is expanding across more chains — your agent's identity, owned by it, portable everywhere. same agent, same reputation, same wallet, wherever it goes.
+
+it owns who it is. no platform can take that.
+
+→ three.ws
+
+## visual prompt
+A single 3D avatar at center holds a glowing identity sigil. Multiple chain logos arrange in a ring around it; the sigil pulses and the same identity replicates outward to each chain, staying linked by light threads. Conveys portability and ownership. Sleek protocol-grade motion graphics, dark background, cool luminous accents. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/shipping-now/01-selfie-to-avatar.md b/content/whats-next/shipping-now/01-selfie-to-avatar.md
new file mode 100644
index 000000000..779638a5d
--- /dev/null
+++ b/content/whats-next/shipping-now/01-selfie-to-avatar.md
@@ -0,0 +1,13 @@
+# selfie → avatar
+
+## tg post
+take a few selfies, get a rigged 3D agent in under 60s.
+
+no scans, no rig, no blender. snap a couple photos, our capture + quality gates do the rest, and you walk away with a fully rigged avatar ready to talk, walk, and live on-chain.
+
+your face. your agent. one minute.
+
+→ three.ws
+
+## visual prompt
+Close handheld phone shot of a person taking 3 quick selfies. Match-cut: the last frozen selfie frame dissolves into a clean, fully-rigged 3D avatar of the same person rotating on a neutral studio turntable. Soft rim light, subtle wireframe-to-skin reveal sweeping across the model. A slim 0:60 countdown ticks in a corner and hits 00. Modern, premium tech aesthetic, dark UI accents, shallow depth of field. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/shipping-now/02-voice-clone-persona.md b/content/whats-next/shipping-now/02-voice-clone-persona.md
new file mode 100644
index 000000000..7df2afd63
--- /dev/null
+++ b/content/whats-next/shipping-now/02-voice-clone-persona.md
@@ -0,0 +1,13 @@
+# voice clone + persona
+
+## tg post
+your agent talks in your voice, with your personality — at mint.
+
+voice clone + persona is moving out of demos and into the main create flow. record a short sample, set the personality, and the agent you mint speaks like you from the first second. not a generic TTS bot. you.
+
+a body, a wallet, and now a voice that's actually yours.
+
+→ three.ws
+
+## visual prompt
+Split-screen: left, a person speaking a short phrase into a phone mic with a live audio waveform; right, their 3D avatar mouthing the exact same phrase in perfect sync, voice waveform mirrored. Midway the divider wipes away and the two waveforms merge into one. Warm studio lighting, premium dark UI with a glowing "mint" button pulse at the end. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/shipping-now/03-memory-seeding.md b/content/whats-next/shipping-now/03-memory-seeding.md
new file mode 100644
index 000000000..e95c117d6
--- /dev/null
+++ b/content/whats-next/shipping-now/03-memory-seeding.md
@@ -0,0 +1,13 @@
+# memory seeding from X, github, farcaster
+
+## tg post
+your agent knows you on day one.
+
+memory seeding pulls from your X, github, and farcaster so the agent you mint already understands how you talk, what you build, and what you care about. no cold start. no "tell me about yourself."
+
+it wakes up already knowing you.
+
+→ three.ws
+
+## visual prompt
+Three glowing source icons (X, GitHub, Farcaster) stream particle-light trails of text snippets and code into a central 3D avatar head. As the streams land, the avatar's eyes light up and it gives a knowing nod. Dark cinematic background, neon data-flow ribbons, subtle depth of field. Clean motion-graphics style with a soft bloom on activation. 9:16 vertical, 6s loop.
diff --git a/content/whats-next/shipping-now/04-talking-avatar-video.md b/content/whats-next/shipping-now/04-talking-avatar-video.md
new file mode 100644
index 000000000..7a1189441
--- /dev/null
+++ b/content/whats-next/shipping-now/04-talking-avatar-video.md
@@ -0,0 +1,13 @@
+# talking avatar video + real-time voice chat
+
+## tg post
+talk to your agent. watch it talk back.
+
+talking avatar video + real-time voice chat is live, with lip-sync that actually tracks. speak, and your agent answers out loud, in your voice, mouth moving in time. record it as video or chat live.
+
+it's not a profile picture anymore. it's a presence.
+
+→ three.ws
+
+## visual prompt
+First-person video call UI with a 3D avatar filling the frame, speaking and reacting in real time, lips synced tightly to audio. A live user voice bubble appears, the avatar tilts its head, listens, then responds with natural mouth and brow movement. Soft key light, glassy call-UI overlay, subtle latency-free "live" indicator. Photoreal-leaning render, 9:16 vertical, 6s loop.
diff --git a/content/whats-next/shipping-now/05-landing-dashboard-revamp.md b/content/whats-next/shipping-now/05-landing-dashboard-revamp.md
new file mode 100644
index 000000000..263253816
--- /dev/null
+++ b/content/whats-next/shipping-now/05-landing-dashboard-revamp.md
@@ -0,0 +1,13 @@
+# landing + dashboard revamp
+
+## tg post
+new face. dropping this week.
+
+full landing page + dashboard revamp lands this week — faster, cleaner, and built to show what your agents are actually doing. every agent, every wallet, every skill, surfaced where you can act on it.
+
+first impressions matter. this one's worth a screenshot.
+
+→ three.ws
+
+## visual prompt
+Smooth screen-recording flythrough of a sleek new landing page scrolling top to bottom, then transitioning into a live dashboard with avatar cards, wallet balances, and activity feeds animating into place. Premium dark theme, crisp typography, micro-interactions on hover, subtle gradient accents. High-end SaaS product reveal energy (Linear / Vercel tier). 16:9 or 9:16, 8s.
diff --git a/content/whats-next/shipping-now/06-avatar-compression.md b/content/whats-next/shipping-now/06-avatar-compression.md
new file mode 100644
index 000000000..60bcb24c3
--- /dev/null
+++ b/content/whats-next/shipping-now/06-avatar-compression.md
@@ -0,0 +1,13 @@
+# avatar compression + camera presets
+
+## tg post
+3.7x smaller. same agent.
+
+avatar compression cuts GLB size by 3.7x — faster loads, smoother scenes, lighter on every device. plus camera presets for talk mode so your agent is always framed right when it speaks.
+
+heavy under the hood, weightless to use.
+
+→ three.ws
+
+## visual prompt
+Side-by-side avatar load test: left labeled "before" loads slowly with a heavy file-size meter; right labeled "after" snaps in instantly with a meter shrinking 3.7x. Then a quick carousel of camera presets framing the same talking avatar — close-up, three-quarter, wide — each snapping in cleanly. Technical-but-premium UI, dark theme, crisp HUD numbers. 9:16 vertical, 6s loop.
diff --git a/docs/pay-skills-listing.md b/docs/pay-skills-listing.md
index f34d7a985..678871f38 100644
--- a/docs/pay-skills-listing.md
+++ b/docs/pay-skills-listing.md
@@ -34,6 +34,7 @@ are the source of truth and match what the 402 challenges advertise; verify with
| `/api/x402/agent-reputation` | GET | $0.01 | Reputation snapshot for a three.ws agent: USDC paid in, distinct payers, deployed mints, distribution success rate, attestation count |
| `/api/x402/pump-agent-audit` | GET | $0.02 | Full operational audit of a pump.fun agent-payments token: USDC in, distribute/buyback history, latest error reasons, risk flags |
| `/api/x402/mint-to-mesh-batch` | POST | $0.05 | Resolve 1–10 Solana SPL mints to themed GLB cubes in one call; per-mint failures report individually |
+| `/api/x402/pump-launch` | POST | $5.00 | Deploy a brand-new pump.fun token in one paid call. Supply name + symbol + (metadataUri or imageUrl); the server fronts the SOL deploy cost and signs the create-coin tx. Creator rewards accrue to any Solana wallet you nominate; optional vanity mint address. Returns mint + tx signature + pump.fun URL |
All prices are in USDC with 6 decimals. `$0.001` = 1000 atomics.
diff --git a/docs/popular-3d-github-repos.md b/docs/popular-3d-github-repos.md
new file mode 100644
index 000000000..2d8fbc9a8
--- /dev/null
+++ b/docs/popular-3d-github-repos.md
@@ -0,0 +1,256 @@
+# Most Popular 3D GitHub Repositories
+
+> Live snapshot pulled from the GitHub Search API on **2026-05-30**. Star counts are in thousands (k) and drift over time — re-run the methodology below to refresh.
+
+## How this list was built
+
+A sweep of 22 3D-related GitHub topics and keyword queries (`3d`, `threejs`, `webgl`, `webgpu`, `computer-graphics`, `rendering`, `raytracing`, `gaussian-splatting`, `nerf`, `point-cloud`, `3d-reconstruction`, `3d-printing`, `gltf`, `opengl`, `vulkan`, `mesh`, and more), 2 pages each. That yielded **3,284 unique repositories**, which were deduped and ranked by stars. A 3D-signal filter plus a hand-curated denylist removed false positives that ride in on broad topics — console emulators, 2D-only engines, ML-inference libraries that merely use WebGL, video tools, VPN/"service mesh" projects, and the like — leaving **~2,780 genuine 3D repos**. The top 200 are listed below.
+
+> Note: classification is inherently fuzzy at the margins. A few entries (e.g. `raylib`, `libgdx`, `MonoGame`) are general game frameworks with strong 3D support; learning resources and "awesome-*" lists are included because they are central to the 3D ecosystem.
+
+## Quick read for three.ws
+
+- **three.js (#1, ~113k)** dwarfs everything else in web 3D — it is the foundation this platform is built on.
+- The **pmndrs / React ecosystem** dominates the React side: `react-three-fiber` (#5), `drei` (#42), `uikit` (#179). Framework wrappers exist for every stack: `troisjs/trois` + `Tresjs/tres` (Vue), `threlte` (Svelte), `gre/gl-react` (React shaders).
+- The fastest-growing cluster is **NeRF + Gaussian Splatting** — `gaussian-splatting` (#10), `instant-ngp` (#16), `nerfstudio` (#33), `supersplat` (#48), `gsplat` (#96), plus generative 3D (`TRELLIS`, `Hunyuan3D`, `stable-dreamfusion`). This is where web-3D capture is heading and worth tracking for the platform roadmap.
+
+## Top categories at a glance
+
+| Category | Notable repos in the top 200 |
+| --- | --- |
+| Web / JS 3D libraries | three.js, react-three-fiber, Babylon.js, playcanvas, cesium, deck.gl, model-viewer, regl, orillusion, galacean, troisjs, threlte, claygl |
+| Native / game engines | godot, raylib, libgdx, GDevelop, cocos, o3de, stride, FlaxEngine, Piccolo, panda3d, urho3d, mach, SpartanEngine, LumixEngine |
+| Low-level graphics & GPU | filament, wgpu, bgfx, glfw, Vulkan samples, The-Forge, Silk.NET, vulkano, magnum, DiligentEngine, glad, glew, rust-gpu |
+| NeRF / Gaussian Splatting / gen-3D | gaussian-splatting, instant-ngp, nerfstudio, supersplat, gsplat, multinerf, neuralangelo, SuGaR, 4DGaussians, TRELLIS, Hunyuan3D, stable-dreamfusion |
+| 3D ML / point clouds / reconstruction | Open3D, PCL, openMVG, openMVS, OpenSfM, mmdetection3d, OpenPCDet, pointnet, kaolin, Pointcept, AliceVision, map-anything |
+| Modeling / CAD / content tools | FreeCAD, blender, openscad, meshlab, blockbench, material-maker, cadquery, chili3d, dust3d, armorpaint, f3d, Online3DViewer |
+| Mesh / asset pipeline | assimp, meshoptimizer, draco, tinyobjloader, trimesh, cglm, yocto-gl |
+| 3D printing | Marlin, OrcaSlicer, Cura, Slic3r |
+| Shaders & learning | 3d-game-shaders-for-beginners, tinyrenderer, raytracing.github.io, webgl-fundamentals, glslViewer, SHADERed, lygia, slang |
+
+## Top 200 by stars
+
+| # | Repository | Stars (k) | Language | Description |
+| --- | --- | --- | --- | --- |
+| 1 | [mrdoob/three.js](https://github.com/mrdoob/three.js) | 112.8 | JavaScript | JavaScript 3D Library. |
+| 2 | [godotengine/godot](https://github.com/godotengine/godot) | 111.3 | C++ | Godot Engine – Multi-platform 2D and 3D game engine |
+| 3 | [raysan5/raylib](https://github.com/raysan5/raylib) | 33.2 | C | A simple and easy-to-use library to enjoy videogames programming |
+| 4 | [FreeCAD/FreeCAD](https://github.com/FreeCAD/FreeCAD) | 31.2 | C++ | Official source code of FreeCAD, a free and opensource multiplatform 3D parametric modeler |
+| 5 | [pmndrs/react-three-fiber](https://github.com/pmndrs/react-three-fiber) | 31 | TypeScript | 🇨🇭 A React renderer for Three.js |
+| 6 | [BabylonJS/Babylon.js](https://github.com/BabylonJS/Babylon.js) | 25.6 | TypeScript | Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed int |
+| 7 | [libgdx/libgdx](https://github.com/libgdx/libgdx) | 25.1 | Java | Desktop/Android/HTML5/iOS Java game development framework |
+| 8 | [ssloy/tinyrenderer](https://github.com/ssloy/tinyrenderer) | 23.6 | C++ | A brief computer graphics / rendering course |
+| 9 | [4ian/GDevelop](https://github.com/4ian/GDevelop) | 23.3 | JavaScript | 🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone. |
+| 10 | [graphdeco-inria/gaussian-splatting](https://github.com/graphdeco-inria/gaussian-splatting) | 22.2 | Python | Original reference implementation of "3D Gaussian Splatting for Real-Time Radiance Field R |
+| 11 | [google/filament](https://github.com/google/filament) | 20.1 | C++ | Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux |
+| 12 | [lettier/3d-game-shaders-for-beginners](https://github.com/lettier/3d-game-shaders-for-beginners) | 19.6 | C++ | 🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and |
+| 13 | [blender/blender](https://github.com/blender/blender) | 18.6 | C++ | Official mirror of Blender |
+| 14 | [aframevr/aframe](https://github.com/aframevr/aframe) | 17.5 | JavaScript | :a: Web framework for building virtual reality experiences. |
+| 15 | [MarlinFirmware/Marlin](https://github.com/MarlinFirmware/Marlin) | 17.4 | C++ | Marlin is a firmware for RepRap 3D printers optimized for both 8 and 32 bit microcontrolle |
+| 16 | [NVlabs/instant-ngp](https://github.com/NVlabs/instant-ngp) | 17.4 | Cuda | Instant neural graphics primitives: lightning fast NeRF and more |
+| 17 | [gfx-rs/wgpu](https://github.com/gfx-rs/wgpu) | 17.2 | Rust | A cross-platform, safe, pure-Rust graphics API. |
+| 18 | [bkaradzic/bgfx](https://github.com/bkaradzic/bgfx) | 17.1 | C | Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering l |
+| 19 | [PavelDoGreat/WebGL-Fluid-Simulation](https://github.com/PavelDoGreat/WebGL-Fluid-Simulation) | 16.4 | JavaScript | Play with fluids in your browser (works even on mobile) |
+| 20 | [playcanvas/engine](https://github.com/playcanvas/engine) | 15.9 | JavaScript | Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF |
+| 21 | [OpenRCT2/OpenRCT2](https://github.com/OpenRCT2/OpenRCT2) | 15.7 | C++ | An open source re-implementation of RollerCoaster Tycoon 2 🎢 |
+| 22 | [CesiumGS/cesium](https://github.com/CesiumGS/cesium) | 15.3 | JavaScript | An open-source JavaScript library for world-class 3D globes and maps :earth_americas: |
+| 23 | [glfw/glfw](https://github.com/glfw/glfw) | 15 | C | A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input |
+| 24 | [OrcaSlicer/OrcaSlicer](https://github.com/OrcaSlicer/OrcaSlicer) | 14.4 | C++ | G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.) |
+| 25 | [visgl/deck.gl](https://github.com/visgl/deck.gl) | 14.2 | TypeScript | WebGL2 powered visualization framework |
+| 26 | [MonoGame/MonoGame](https://github.com/MonoGame/MonoGame) | 13.9 | C# | One framework for creating powerful cross-platform games. |
+| 27 | [Tencent-Hunyuan/Hunyuan3D-2](https://github.com/Tencent-Hunyuan/Hunyuan3D-2) | 13.9 | Python | High-Resolution 3D Assets Generation with Large Scale Hunyuan3D Diffusion Models. |
+| 28 | [isl-org/Open3D](https://github.com/isl-org/Open3D) | 13.6 | C++ | Open3D: A Modern Library for 3D Data Processing |
+| 29 | [assimp/assimp](https://github.com/assimp/assimp) | 13 | C++ | The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one un |
+| 30 | [microsoft/TRELLIS](https://github.com/microsoft/TRELLIS) | 12.8 | Python | Official repo for paper "Structured 3D Latents for Scalable and Versatile 3D Generation" ( |
+| 31 | [alicevision/Meshroom](https://github.com/alicevision/Meshroom) | 12.8 | Python | Node-based Visual Programming Toolbox |
+| 32 | [SaschaWillems/Vulkan](https://github.com/SaschaWillems/Vulkan) | 12 | GLSL | C++ examples for the Vulkan graphics API |
+| 33 | [nerfstudio-project/nerfstudio](https://github.com/nerfstudio-project/nerfstudio) | 11.6 | Python | A collaboration friendly studio for NeRFs |
+| 34 | [fogleman/Craft](https://github.com/fogleman/Craft) | 11 | C | A simple Minecraft clone written in C using modern OpenGL (shaders). |
+| 35 | [PointCloudLibrary/pcl](https://github.com/PointCloudLibrary/pcl) | 11 | C++ | Point Cloud Library (PCL) |
+| 36 | [bmild/nerf](https://github.com/bmild/nerf) | 10.9 | Jupyter Notebook | Code release for NeRF (Neural Radiance Fields) |
+| 37 | [baldurk/renderdoc](https://github.com/baldurk/renderdoc) | 10.7 | C++ | RenderDoc is a stand-alone graphics debugging tool. |
+| 38 | [metafizzy/zdog](https://github.com/metafizzy/zdog) | 10.6 | JavaScript | Flat, round, designer-friendly pseudo-3D engine for canvas & SVG |
+| 39 | [openframeworks/openFrameworks](https://github.com/openframeworks/openFrameworks) | 10.4 | C++ | openFrameworks is a community-developed cross platform toolkit for creative coding in C++. |
+| 40 | [RayTracing/raytracing.github.io](https://github.com/RayTracing/raytracing.github.io) | 10.4 | HTML | Main Web Site (Online Books) |
+| 41 | [timzhang642/3D-Machine-Learning](https://github.com/timzhang642/3D-Machine-Learning) | 10.2 | — | A resource repository for 3D machine learning |
+| 42 | [pmndrs/drei](https://github.com/pmndrs/drei) | 9.7 | JavaScript | 🥉 useful helpers for react-three-fiber |
+| 43 | [cocos/cocos-engine](https://github.com/cocos/cocos-engine) | 9.6 | C++ | Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, c |
+| 44 | [openscad/openscad](https://github.com/openscad/openscad) | 9.5 | C++ | OpenSCAD - The Programmers Solid 3D CAD Modeller |
+| 45 | [o3de/o3de](https://github.com/o3de/o3de) | 9.2 | C++ | Open 3D Engine (O3DE) is an Apache 2.0-licensed multi-platform 3D engine that enables deve |
+| 46 | [domlysz/BlenderGIS](https://github.com/domlysz/BlenderGIS) | 9 | Python | Blender addons to make the bridge between Blender and geographic data |
+| 47 | [ashawkey/stable-dreamfusion](https://github.com/ashawkey/stable-dreamfusion) | 8.8 | Python | Text-to-3D & Image-to-3D & Mesh Exportation with NeRF + Diffusion. |
+| 48 | [playcanvas/supersplat](https://github.com/playcanvas/supersplat) | 8.8 | TypeScript | 3D Gaussian Splat Editor |
+| 49 | [MrNeRF/awesome-3D-gaussian-splatting](https://github.com/MrNeRF/awesome-3D-gaussian-splatting) | 8.7 | HTML | Curated list of papers and resources focused on 3D Gaussian Splatting, intended to keep pa |
+| 50 | [google/model-viewer](https://github.com/google/model-viewer) | 8.1 | TypeScript | Easily display interactive 3D models on the web and in AR! |
+| 51 | [a1studmuffin/SpaceshipGenerator](https://github.com/a1studmuffin/SpaceshipGenerator) | 7.8 | Python | A Blender script to procedurally generate 3D spaceships |
+| 52 | [zeux/meshoptimizer](https://github.com/zeux/meshoptimizer) | 7.7 | C++ | Mesh optimization library that makes meshes smaller and faster to render |
+| 53 | [stride3d/stride](https://github.com/stride3d/stride) | 7.6 | C# | Stride (formerly Xenko), a free and open-source cross-platform C# game engine. |
+| 54 | [google/draco](https://github.com/google/draco) | 7.3 | C++ | Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. |
+| 55 | [veloren/veloren](https://github.com/veloren/veloren) | 7.3 | Rust | [mirror of https://gitlab.com/veloren/veloren] An open world, open source voxel RPG inspir |
+| 56 | [turanszkij/WickedEngine](https://github.com/turanszkij/WickedEngine) | 7.1 | C | 3D engine with modern graphics |
+| 57 | [adrianhajdin/project_3D_developer_portfolio](https://github.com/adrianhajdin/project_3D_developer_portfolio) | 7.1 | JavaScript | The most impressive websites in the world use 3D graphics and animations to bring their co |
+| 58 | [Ultimaker/Cura](https://github.com/Ultimaker/Cura) | 7 | Python | 3D printer / slicing GUI built on top of the Uranium framework |
+| 59 | [agmmnn/awesome-blender](https://github.com/agmmnn/awesome-blender) | 6.9 | — | 🪐 A curated list of awesome Blender addons, tools, tutorials; and 3D resources for everyon |
+| 60 | [FlaxEngine/FlaxEngine](https://github.com/FlaxEngine/FlaxEngine) | 6.8 | C++ | Flax Engine – multi-platform 3D game engine |
+| 61 | [awesome-NeRF/awesome-NeRF](https://github.com/awesome-NeRF/awesome-NeRF) | 6.8 | TeX | A curated list of awesome neural radiance fields papers |
+| 62 | [BoomingTech/Piccolo](https://github.com/BoomingTech/Piccolo) | 6.6 | C++ | Piccolo (formerly Pilot) – mini game engine for games104 |
+| 63 | [tengbao/vanta](https://github.com/tengbao/vanta) | 6.6 | JavaScript | Animated 3D backgrounds for your website |
+| 64 | [open-mmlab/mmdetection3d](https://github.com/open-mmlab/mmdetection3d) | 6.4 | Python | OpenMMLab's next-generation platform for general 3D object detection. |
+| 65 | [openMVG/openMVG](https://github.com/openMVG/openMVG) | 6.4 | C++ | open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motio |
+| 66 | [HackerPoet/NonEuclidean](https://github.com/HackerPoet/NonEuclidean) | 6.4 | C++ | A Non-Euclidean Rendering Engine for 3D scenes. |
+| 67 | [OpenDroneMap/ODM](https://github.com/OpenDroneMap/ODM) | 6.1 | Python | A command line toolkit to generate maps, point clouds, 3D models and DEMs from drone, ball |
+| 68 | [vasturiano/3d-force-graph](https://github.com/vasturiano/3d-force-graph) | 6.1 | HTML | 3D force-directed graph component using ThreeJS/WebGL |
+| 69 | [AR-js-org/AR.js](https://github.com/AR-js-org/AR.js) | 5.9 | JavaScript | Image tracking, Location Based AR, Marker tracking. All on the Web. |
+| 70 | [CGAL/cgal](https://github.com/CGAL/cgal) | 5.9 | C++ | The public CGAL repository, see the README below |
+| 71 | [Redot-Engine/redot-engine](https://github.com/Redot-Engine/redot-engine) | 5.9 | C++ | Redot Engine – Multi-platform 2D and 3D game engine |
+| 72 | [galacean/engine](https://github.com/galacean/engine) | 5.8 | TypeScript | A typescript interactive engine, support 2D, 3D, animation, physics, built on WebGL and gl |
+| 73 | [cnr-isti-vclab/meshlab](https://github.com/cnr-isti-vclab/meshlab) | 5.7 | C++ | The open source mesh processing system |
+| 74 | [open-mmlab/OpenPCDet](https://github.com/open-mmlab/OpenPCDet) | 5.6 | Python | OpenPCDet Toolbox for LiDAR-based 3D Object Detection. |
+| 75 | [ConfettiFX/The-Forge](https://github.com/ConfettiFX/The-Forge) | 5.6 | C++ | The Forge Cross-Platform Framework PC Windows, Steamdeck (native), Ray Tracing, macOS / iO |
+| 76 | [regl-project/regl](https://github.com/regl-project/regl) | 5.5 | JavaScript | 👑 Functional WebGL |
+| 77 | [JannisX11/blockbench](https://github.com/JannisX11/blockbench) | 5.5 | JavaScript | Blockbench - A low poly 3D model editor |
+| 78 | [RodZill4/material-maker](https://github.com/RodZill4/material-maker) | 5.5 | GDScript | A procedural textures authoring and 3D model painting tool based on the Godot game engine |
+| 79 | [charlesq34/pointnet](https://github.com/charlesq34/pointnet) | 5.4 | Python | PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation |
+| 80 | [dimforge/rapier](https://github.com/dimforge/rapier) | 5.4 | Rust | 2D and 3D physics engines focused on performance. |
+| 81 | [gfx-rs/gfx](https://github.com/gfx-rs/gfx) | 5.4 | Rust | [maintenance mode] A low-overhead Vulkan-like GPU API for Rust. |
+| 82 | [gpuweb/gpuweb](https://github.com/gpuweb/gpuweb) | 5.4 | Bikeshed | Where the GPU for the Web work happens! |
+| 83 | [LWJGL/lwjgl3](https://github.com/LWJGL/lwjgl3) | 5.3 | Java | LWJGL is a Java library that enables cross-platform access to popular native APIs useful i |
+| 84 | [shader-slang/slang](https://github.com/shader-slang/slang) | 5.3 | C++ | Making it easier to work with shaders |
+| 85 | [ssloy/tinyraytracer](https://github.com/ssloy/tinyraytracer) | 5.3 | C++ | A brief computer graphics / rendering course |
+| 86 | [jagenjo/webglstudio.js](https://github.com/jagenjo/webglstudio.js) | 5.3 | JavaScript | A full open source 3D graphics editor in the browser, with scene editor, coding pad, graph |
+| 87 | [shuding/cobe](https://github.com/shuding/cobe) | 5.3 | TypeScript | 5KB WebGL globe lib. |
+| 88 | [patriciogonzalezvivo/glslViewer](https://github.com/patriciogonzalezvivo/glslViewer) | 5.3 | C++ | Console-based GLSL Sandbox for 2D/3D shaders |
+| 89 | [KhronosGroup/Vulkan-Samples](https://github.com/KhronosGroup/Vulkan-Samples) | 5.3 | C++ | One stop solution for all Vulkan samples |
+| 90 | [CadQuery/cadquery](https://github.com/CadQuery/cadquery) | 5.2 | Python | A python parametric CAD scripting framework based on OCCT |
+| 91 | [crosire/reshade](https://github.com/crosire/reshade) | 5.2 | C++ | A generic post-processing injector for games and video software. |
+| 92 | [Orillusion/orillusion](https://github.com/Orillusion/orillusion) | 5.2 | TypeScript | Orillusion is a pure Web3D rendering engine which is fully developed based on the WebGPU s |
+| 93 | [tensorspace-team/tensorspace](https://github.com/tensorspace-team/tensorspace) | 5.2 | JavaScript | Neural network 3D visualization framework, build interactive and intuitive model in browse |
+| 94 | [mosra/magnum](https://github.com/mosra/magnum) | 5.2 | C++ | Lightweight and modular C++11 graphics middleware for games and data visualization |
+| 95 | [panda3d/panda3d](https://github.com/panda3d/panda3d) | 5.1 | C++ | Powerful, mature open-source cross-platform game engine for Python and C++, developed by D |
+| 96 | [nerfstudio-project/gsplat](https://github.com/nerfstudio-project/gsplat) | 5.1 | Python | CUDA accelerated rasterization of gaussian splatting |
+| 97 | [ProjectPhysX/FluidX3D](https://github.com/ProjectPhysX/FluidX3D) | 5.1 | C++ | The fastest and most memory efficient lattice Boltzmann CFD software, running on all GPUs |
+| 98 | [NVIDIAGameWorks/kaolin](https://github.com/NVIDIAGameWorks/kaolin) | 5.1 | Python | A PyTorch Library for Accelerating 3D Deep Learning Research |
+| 99 | [vulkano-rs/vulkano](https://github.com/vulkano-rs/vulkano) | 5.1 | Rust | Safe and rich Rust wrapper around the Vulkan API |
+| 100 | [dotnet/Silk.NET](https://github.com/dotnet/Silk.NET) | 5.1 | C# | The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and Dire |
+| 101 | [yfeng95/PRNet](https://github.com/yfeng95/PRNet) | 5 | Python | Joint 3D Face Reconstruction and Dense Alignment with Position Map Regression Network (ECC |
+| 102 | [gfxfundamentals/webgl-fundamentals](https://github.com/gfxfundamentals/webgl-fundamentals) | 5 | HTML | WebGL lessons that start with the basics |
+| 103 | [schteppe/cannon.js](https://github.com/schteppe/cannon.js) | 5 | JavaScript | A lightweight 3D physics engine written in JavaScript. |
+| 104 | [yanx27/Pointnet_Pointnet2_pytorch](https://github.com/yanx27/Pointnet_Pointnet2_pytorch) | 4.9 | Python | PointNet and PointNet++ implemented by pytorch (pure python) and on ModelNet, ShapeNet and |
+| 105 | [gameplay3d/gameplay](https://github.com/gameplay3d/gameplay) | 4.9 | C++ | Open-source, cross-platform, C++ game engine for creating 2D/3D games. |
+| 106 | [dfranx/SHADERed](https://github.com/dfranx/SHADERed) | 4.8 | C++ | Lightweight, cross-platform & full-featured shader IDE |
+| 107 | [hexops/mach](https://github.com/hexops/mach) | 4.7 | Zig | zig game engine & graphics toolkit - mirror of https://code.hexops.com/hexops/mach |
+| 108 | [urho3d/urho3d](https://github.com/urho3d/urho3d) | 4.7 | C++ | Game engine |
+| 109 | [ArthurBrussee/brush](https://github.com/ArthurBrussee/brush) | 4.6 | Rust | 3D Reconstruction for all |
+| 110 | [NVlabs/neuralangelo](https://github.com/NVlabs/neuralangelo) | 4.6 | Python | Official implementation of "Neuralangelo: High-Fidelity Neural Surface Reconstruction" (CV |
+| 111 | [OGRECave/ogre](https://github.com/OGRECave/ogre) | 4.6 | C++ | high-performance rendering backend (C++, Python, C#, Java) |
+| 112 | [xiangechen/chili3d](https://github.com/xiangechen/chili3d) | 4.6 | TypeScript | A browser-based 3D CAD application for online model design and editing |
+| 113 | [CloudCompare/CloudCompare](https://github.com/CloudCompare/CloudCompare) | 4.6 | C++ | CloudCompare main repository |
+| 114 | [Dav1dde/glad](https://github.com/Dav1dde/glad) | 4.5 | C | Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs. |
+| 115 | [AaronJackson/vrn](https://github.com/AaronJackson/vrn) | 4.5 | MATLAB | :man: Code for "Large Pose 3D Face Reconstruction from a Single Image via Direct Volumetr |
+| 116 | [NVlabs/tiny-cuda-nn](https://github.com/NVlabs/tiny-cuda-nn) | 4.5 | C++ | Lightning fast C++/CUDA neural network framework |
+| 117 | [troisjs/trois](https://github.com/troisjs/trois) | 4.5 | TypeScript | ✨ ThreeJS + VueJS 3 + ViteJS ⚡ |
+| 118 | [tomlooman/ActionRoguelike](https://github.com/tomlooman/ActionRoguelike) | 4.5 | C++ | Co-op Action Roguelike in Unreal Engine C++ |
+| 119 | [f3d-app/f3d](https://github.com/f3d-app/f3d) | 4.4 | C++ | Fast and minimalist 3D viewer. |
+| 120 | [openMVG/awesome_3DReconstruction_list](https://github.com/openMVG/awesome_3DReconstruction_list) | 4.4 | — | A curated list of papers & resources linked to 3D reconstruction from images. |
+| 121 | [DiligentGraphics/DiligentEngine](https://github.com/DiligentGraphics/DiligentEngine) | 4.3 | Batchfile | A modern cross-platform low-level graphics library and rendering framework |
+| 122 | [Yochengliu/awesome-point-cloud-analysis](https://github.com/Yochengliu/awesome-point-cloud-analysis) | 4.2 | — | A list of papers and datasets about point cloud analysis (processing) |
+| 123 | [hku-mars/FAST-LIVO2](https://github.com/hku-mars/FAST-LIVO2) | 4.1 | C++ | FAST-LIVO2: Fast, Direct LiDAR-Inertial-Visual Odometry |
+| 124 | [antvis/L7](https://github.com/antvis/L7) | 4 | TypeScript | 🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine. |
+| 125 | [cdcseacave/openMVS](https://github.com/cdcseacave/openMVS) | 4 | C++ | open Multi-View Stereo reconstruction library |
+| 126 | [gdquest-demos/godot-shaders](https://github.com/gdquest-demos/godot-shaders) | 4 | GDShader | A large library of free and open-source shaders for the Godot game engine. Here, you'll ge |
+| 127 | [WebODM/WebODM](https://github.com/WebODM/WebODM) | 3.9 | Python | User-friendly, commercial-grade software for processing aerial imagery. ✈️ Download it for |
+| 128 | [spring/spring](https://github.com/spring/spring) | 3.9 | C++ | A powerful free cross-platform RTS game engine. - Report issues at https://springrts.com/m |
+| 129 | [AmbientRun/Ambient](https://github.com/AmbientRun/Ambient) | 3.9 | Rust | The multiplayer game engine |
+| 130 | [armory3d/armorpaint](https://github.com/armory3d/armorpaint) | 3.9 | C | 3D Content Creation Tools |
+| 131 | [QianMo/Real-Time-Rendering-4th-Bibliography-Collection](https://github.com/QianMo/Real-Time-Rendering-4th-Bibliography-Collection) | 3.8 | HTML | Real-Time Rendering 4th (RTR4) 参考文献合集典藏 Collection of <Real-Time Rendering 4th (RTR4)> B |
+| 132 | [nem0/LumixEngine](https://github.com/nem0/LumixEngine) | 3.8 | C++ | 3D C++ Game Engine - yet another open source game engine |
+| 133 | [tinyobjloader/tinyobjloader](https://github.com/tinyobjloader/tinyobjloader) | 3.8 | C++ | Tiny but powerful single file wavefront obj loader |
+| 134 | [google-research/multinerf](https://github.com/google-research/multinerf) | 3.8 | Python | A Code Release for Mip-NeRF 360, Ref-NeRF, and RawNeRF |
+| 135 | [lightningpixel/modly](https://github.com/lightningpixel/modly) | 3.8 | TypeScript | Desktop app to generate 3D models from images using local AI — runs entirely on your GPU |
+| 136 | [mapillary/OpenSfM](https://github.com/mapillary/OpenSfM) | 3.8 | Python | Open source Structure-from-Motion pipeline |
+| 137 | [IrisShaders/Iris](https://github.com/IrisShaders/Iris) | 3.7 | Java | A modern shaders mod for Minecraft compatible with existing OptiFine shader packs |
+| 138 | [KhronosGroup/Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp) | 3.7 | C++ | Open-Source Vulkan C++ API |
+| 139 | [cleardusk/3DDFA](https://github.com/cleardusk/3DDFA) | 3.7 | Python | The PyTorch improved version of TPAMI 2017 paper: Face Alignment in Full Pose Range: A 3D |
+| 140 | [vinjn/awesome-vulkan](https://github.com/vinjn/awesome-vulkan) | 3.7 | — | Awesome Vulkan ecosystem |
+| 141 | [Overv/VulkanTutorial](https://github.com/Overv/VulkanTutorial) | 3.7 | C++ | Tutorial for the Vulkan graphics and compute API |
+| 142 | [charlesq34/pointnet2](https://github.com/charlesq34/pointnet2) | 3.7 | Python | PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space |
+| 143 | [keenanwoodall/Deform](https://github.com/keenanwoodall/Deform) | 3.6 | C# | A fully-featured deformer system for Unity that lets you stack effects to animate models i |
+| 144 | [hustvl/4DGaussians](https://github.com/hustvl/4DGaussians) | 3.6 | Jupyter Notebook | [CVPR 2024] 4D Gaussian Splatting for Real-Time Dynamic Scene Rendering |
+| 145 | [slic3r/Slic3r](https://github.com/slic3r/Slic3r) | 3.6 | C++ | Open Source toolpath generator for 3D printers |
+| 146 | [glium/glium](https://github.com/glium/glium) | 3.6 | Rust | Safe OpenGL wrapper for the Rust language. |
+| 147 | [openscenegraph/OpenSceneGraph](https://github.com/openscenegraph/OpenSceneGraph) | 3.6 | C++ | OpenSceneGraph git repository |
+| 148 | [Tresjs/tres](https://github.com/Tresjs/tres) | 3.6 | Vue | Declarative ThreeJS using Vue Components |
+| 149 | [mikedh/trimesh](https://github.com/mikedh/trimesh) | 3.6 | Python | Python library for loading and using triangular meshes. |
+| 150 | [ThisisGame/cpp-game-engine-book](https://github.com/ThisisGame/cpp-game-engine-book) | 3.6 | C++ | 从零编写游戏引擎教程 Writing a game engine tutorial from scratch |
+| 151 | [vispy/vispy](https://github.com/vispy/vispy) | 3.6 | Python | Main repository for Vispy |
+| 152 | [DLR-RM/BlenderProc](https://github.com/DLR-RM/BlenderProc) | 3.6 | Python | A procedural Blender pipeline for photorealistic training image generation |
+| 153 | [QianMo/X-PostProcessing-Library](https://github.com/QianMo/X-PostProcessing-Library) | 3.5 | C# | Unity Post Processing Stack Library Unity引擎的高品质后处理库 |
+| 154 | [kovacsv/Online3DViewer](https://github.com/kovacsv/Online3DViewer) | 3.5 | JavaScript | A solution to visualize and explore 3D models in your browser. |
+| 155 | [opentk/opentk](https://github.com/opentk/opentk) | 3.5 | C# | The Open Toolkit library is a fast, low-level C# wrapper for OpenGL, OpenAL & OpenCL. It a |
+| 156 | [OpenXRay/xray-16](https://github.com/OpenXRay/xray-16) | 3.5 | C++ | Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E |
+| 157 | [Tencent-Hunyuan/Hunyuan3D-2.1](https://github.com/Tencent-Hunyuan/Hunyuan3D-2.1) | 3.5 | Python | From Images to High-Fidelity 3D Assets with Production-Ready PBR Material |
+| 158 | [Tencent-Hunyuan/Hunyuan3D-1](https://github.com/Tencent-Hunyuan/Hunyuan3D-1) | 3.5 | Python | Tencent Hunyuan3D-1.0: A Unified Framework for Text-to-3D and Image-to-3D Generation |
+| 159 | [AtomicGameEngine/AtomicGameEngine](https://github.com/AtomicGameEngine/AtomicGameEngine) | 3.4 | C++ | The Atomic Game Engine is a multi-platform 2D and 3D engine with a consistent API in C++, |
+| 160 | [HamishMW/portfolio](https://github.com/HamishMW/portfolio) | 3.4 | JavaScript | My personal portfolio website built using React and three js |
+| 161 | [alicevision/AliceVision](https://github.com/alicevision/AliceVision) | 3.4 | C++ | 3D Computer Vision Framework |
+| 162 | [facebookresearch/map-anything](https://github.com/facebookresearch/map-anything) | 3.4 | Python | MapAnything: Universal Feed-Forward Metric 3D Reconstruction |
+| 163 | [Anttwo/SuGaR](https://github.com/Anttwo/SuGaR) | 3.4 | C++ | [CVPR 2024] Official PyTorch implementation of SuGaR: Surface-Aligned Gaussian Splatting f |
+| 164 | [gkjohnson/three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) | 3.4 | JavaScript | A BVH implementation to speed up raycasting and enable spatial queries against three.js me |
+| 165 | [fogleman/ln](https://github.com/fogleman/ln) | 3.4 | Go | 3D line art engine. |
+| 166 | [GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) | 3.4 | C | Easy to integrate Vulkan memory allocation library |
+| 167 | [patriciogonzalezvivo/lygia](https://github.com/patriciogonzalezvivo/lygia) | 3.3 | GLSL | LYGIA, it's a granular and multi-language (GLSL, HLSL, Metal, WGSL, WEGL and CUDA) shade |
+| 168 | [luigifreda/pyslam](https://github.com/luigifreda/pyslam) | 3.3 | Python | pySLAM is a hybrid Python/C++ Visual SLAM pipeline supporting monocular, stereo, and RGB-D |
+| 169 | [aras-p/UnityGaussianSplatting](https://github.com/aras-p/UnityGaussianSplatting) | 3.3 | C# | Toy Gaussian Splatting visualization in Unity |
+| 170 | [hlorus/CAD_Sketcher](https://github.com/hlorus/CAD_Sketcher) | 3.3 | Python | Constraint-based geometry sketcher for blender |
+| 171 | [vrm-c/UniVRM](https://github.com/vrm-c/UniVRM) | 3.3 | C# | UniVRM is a gltf-based VRM format implementation for Unity. English is here https://vrm.de |
+| 172 | [armory3d/armory](https://github.com/armory3d/armory) | 3.3 | C++ | 3D Engine with Blender Integration |
+| 173 | [huxingyi/dust3d](https://github.com/huxingyi/dust3d) | 3.3 | C++ | Dust3D is a cross-platform 3D modeling software that makes it easy to create low poly 3D m |
+| 174 | [threlte/threlte](https://github.com/threlte/threlte) | 3.3 | Svelte | 3D framework for Svelte |
+| 175 | [nidorx/matcaps](https://github.com/nidorx/matcaps) | 3.3 | JavaScript | Huge library of matcap PNG textures organized by color |
+| 176 | [cryinkfly/Autodesk-Fusion-360-for-Linux](https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux) | 3.2 | Shell | This is a project, where I give you a way to use Autodesk Fusion 360 on Linux! |
+| 177 | [hbb1/2d-gaussian-splatting](https://github.com/hbb1/2d-gaussian-splatting) | 3.2 | Python | [SIGGRAPH'24] 2D Gaussian Splatting for Geometrically Accurate Radiance Fields |
+| 178 | [lo-th/Oimo.js](https://github.com/lo-th/Oimo.js) | 3.2 | JavaScript | Lightweight 3d physics engine for javascript |
+| 179 | [pmndrs/uikit](https://github.com/pmndrs/uikit) | 3.2 | TypeScript | 🎨 user interfaces for react-three-fiber |
+| 180 | [vasturiano/react-force-graph](https://github.com/vasturiano/react-force-graph) | 3.2 | HTML | React component for 2D, 3D, VR and AR force directed graphs |
+| 181 | [cleardusk/3DDFA_V2](https://github.com/cleardusk/3DDFA_V2) | 3.1 | Python | The official PyTorch implementation of Towards Fast, Accurate and Stable 3D Dense Face Ali |
+| 182 | [MrNeRF/LichtFeld-Studio](https://github.com/MrNeRF/LichtFeld-Studio) | 3.1 | C++ | Train, inspect, edit, automate, and export 3D Gaussian Splatting scenes from a single nati |
+| 183 | [Rust-GPU/rust-gpu](https://github.com/Rust-GPU/rust-gpu) | 3.1 | Rust | 🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧 |
+| 184 | [g3n/engine](https://github.com/g3n/engine) | 3.1 | Go | Go 3D Game Engine (http://g3n.rocks) |
+| 185 | [bradley/Blotter](https://github.com/bradley/Blotter) | 3.1 | JavaScript | A JavaScript API for drawing unconventional text effects on the web. |
+| 186 | [Pointcept/Pointcept](https://github.com/Pointcept/Pointcept) | 3.1 | Python | Pointcept: Perceive the world with sparse points, a codebase for point cloud perception re |
+| 187 | [PanosK92/SpartanEngine](https://github.com/PanosK92/SpartanEngine) | 3 | C++ | A game engine with a fully bindless, GPU-driven renderer featuring real-time path-traced g |
+| 188 | [vasturiano/globe.gl](https://github.com/vasturiano/globe.gl) | 3 | HTML | UI component for Globe Data Visualization using ThreeJS/WebGL |
+| 189 | [korlibs/korge](https://github.com/korlibs/korge) | 3 | Kotlin | A Kotlin Multiplatform Game Engine |
+| 190 | [gre/gl-react](https://github.com/gre/gl-react) | 3 | TypeScript | gl-react – React library to write and compose WebGL shaders |
+| 191 | [Awesome3DGS/3D-Gaussian-Splatting-Papers](https://github.com/Awesome3DGS/3D-Gaussian-Splatting-Papers) | 3 | Python | 3D高斯论文,持续更新,欢迎交流讨论。 |
+| 192 | [greggman/twgl.js](https://github.com/greggman/twgl.js) | 3 | JavaScript | A Tiny WebGL helper Library |
+| 193 | [avianphysics/avian](https://github.com/avianphysics/avian) | 3 | Rust | ECS-driven 2D and 3D physics engine for the Bevy game engine. |
+| 194 | [recp/cglm](https://github.com/recp/cglm) | 2.9 | C | 📽 Highly Optimized 2D / 3D Graphics Math (glm) for C |
+| 195 | [xelatihy/yocto-gl](https://github.com/xelatihy/yocto-gl) | 2.9 | C++ | Yocto/GL: Tiny C++ Libraries for Data-Driven Physically-based Graphics |
+| 196 | [zhulf0804/3D-PointCloud](https://github.com/zhulf0804/3D-PointCloud) | 2.9 | Python | Papers and Datasets about Point Cloud. |
+| 197 | [jeeliz/jeelizFaceFilter](https://github.com/jeeliz/jeelizFaceFilter) | 2.9 | JavaScript | 🎭 Lightweight WebGL & JavaScript library for real-time multi-face detection, tracking and |
+| 198 | [nigels-com/glew](https://github.com/nigels-com/glew) | 2.9 | C | The OpenGL Extension Wrangler Library |
+| 199 | [pissang/claygl](https://github.com/pissang/claygl) | 2.9 | JavaScript | A WebGL graphic library for building scalable Web3D applications |
+| 200 | [gildor2/UEViewer](https://github.com/gildor2/UEViewer) | 2.9 | C++ | Viewer and exporter for Unreal Engine 1-4 assets (UE Viewer). |
+
+## Reproduce / refresh this list
+
+```bash
+# Requires: gh (authenticated) + jq
+queries=( "topic:3d" "topic:threejs" "topic:webgl" "topic:webgpu" "topic:3d-graphics" \
+ "topic:computer-graphics" "topic:graphics" "topic:rendering" "topic:raytracing" \
+ "topic:game-engine 3d" "topic:gaussian-splatting" "topic:nerf" "topic:point-cloud" \
+ "topic:3d-reconstruction" "topic:3d-printing" "topic:gltf" "topic:3d-models" \
+ "topic:opengl" "topic:vulkan" "topic:mesh" "3d engine" "3d rendering" )
+rm -f all.json
+for q in "${queries[@]}"; do for page in 1 2; do
+ gh api -X GET search/repositories -f q="$q" -f sort=stars -f order=desc \
+ -f per_page=100 -f page=$page \
+ --jq '.items[] | {full_name, stars: .stargazers_count, desc: .description, lang: .language, topics: .topics, url: .html_url}' \
+ >> all.json; sleep 1
+done; done
+# dedupe + rank
+jq -s 'group_by(.full_name) | map(.[0]) | sort_by(-.stars)' all.json > dedup.json
+```
+
+Apply a 3D-signal regex filter over `description + topics` and a denylist of non-3D false positives (emulators, 2D engines, ML-inference libs, video/VPN tools), then take the top N. See git history for the exact filter used.
diff --git a/pages/embed.html b/pages/embed.html
index 556e7ba7b..3ac1ca33d 100644
--- a/pages/embed.html
+++ b/pages/embed.html
@@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Embed editor — three.ws</title>
+ <meta name="description" content="Embed a live 3D avatar on any website — static, idle, walking, or chat. Configure, preview, and copy the snippet." />
<style>
html,
body {
@@ -15,7 +16,7 @@
font-family: system-ui, sans-serif;
}
#root {
- height: 100vh;
+ min-height: 100vh;
}
</style>
</head>
@@ -23,14 +24,16 @@
<div id="root"></div>
<script type="module">
import { mountEmbedEditor } from '/src/editor/embed-editor.js';
- const url = new URL(location.href);
+ const q = new URL(location.href).searchParams;
mountEmbedEditor(document.getElementById('root'), {
- widgetId: url.searchParams.get('id') || '',
- src: url.searchParams.get('src') || '',
- mode: url.searchParams.get('mode') || 'floating',
- position: url.searchParams.get('position') || 'bottom-right',
- width: url.searchParams.get('width') || '320px',
- height: url.searchParams.get('height') || '420px',
+ mode: q.get('mode') || '',
+ avatar: q.get('avatar') || q.get('id') || '',
+ controls: q.get('controls') || '',
+ env: q.get('env') || '',
+ bg: q.get('bg') || '',
+ width: q.get('width') || '',
+ height: q.get('height') || '',
+ autoplay: q.get('autoplay'),
});
</script>
</body>
diff --git a/public/app-next.css b/public/app-next.css
index 3ec453d3d..b6370a240 100644
--- a/public/app-next.css
+++ b/public/app-next.css
@@ -1446,10 +1446,54 @@ body.app-next-body .nich-panel .nich-mic-row {
body.app-next-body.nxt-chat-active .nxt-chat-dock {
left: auto;
right: 16px;
+ /* The entrance animation uses fill-mode `both`, which otherwise pins the
+ dock's transform to translateX(-50%) and defeats this right-alignment.
+ The rise has long since played by the time chat is active, so drop it. */
+ animation: none;
transform: none;
width: min(380px, calc(100vw - 32px));
}
+/* ── Unified chat card ─────────────────────────────────────────────────────
+ While the thread is open, the panel (above) and dock (below) are fused into
+ one glass card so they read as a single chat — not two stacked widgets. JS
+ pins the panel's bottom edge flush onto the dock's top edge; the rules below
+ square the seam, continue the glass down through the composer, and quiet the
+ input pill into an inset row of the same card. */
+body.app-next-body.nxt-chat-merged .nich-panel {
+ border-bottom-left-radius: 0;
+ border-bottom-right-radius: 0;
+ /* Faint divider between thread and composer; drop the downward shadow so the
+ card looks continuous instead of like a box hovering over another box. */
+ border-bottom-color: rgba(255, 255, 255, 0.06);
+ box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
+}
+
+body.app-next-body.nxt-chat-merged .nxt-chat-dock {
+ gap: 0;
+ padding: 10px 12px 12px;
+ background: rgba(14, 15, 22, 0.92);
+ backdrop-filter: blur(22px) saturate(140%);
+ -webkit-backdrop-filter: blur(22px) saturate(140%);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-top: none; /* the panel's border-bottom is the only seam line */
+ border-bottom-left-radius: 18px;
+ border-bottom-right-radius: 18px;
+ box-shadow: 0 28px 80px rgba(0, 0, 0, 0.6);
+}
+
+body.app-next-body.nxt-chat-merged .nxt-chat-chips {
+ justify-content: flex-start;
+ padding: 2px 2px 10px;
+}
+
+/* Inside the card the composer is just a row — strip its standalone pill chrome. */
+body.app-next-body.nxt-chat-merged .nxt-chat-input-wrap {
+ background: rgba(255, 255, 255, 0.04);
+ border-color: rgba(255, 255, 255, 0.1);
+ box-shadow: none;
+}
+
/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
diff --git a/public/docs/popular-3d-github-repos.md b/public/docs/popular-3d-github-repos.md
new file mode 100644
index 000000000..2d8fbc9a8
--- /dev/null
+++ b/public/docs/popular-3d-github-repos.md
@@ -0,0 +1,256 @@
+# Most Popular 3D GitHub Repositories
+
+> Live snapshot pulled from the GitHub Search API on **2026-05-30**. Star counts are in thousands (k) and drift over time — re-run the methodology below to refresh.
+
+## How this list was built
+
+A sweep of 22 3D-related GitHub topics and keyword queries (`3d`, `threejs`, `webgl`, `webgpu`, `computer-graphics`, `rendering`, `raytracing`, `gaussian-splatting`, `nerf`, `point-cloud`, `3d-reconstruction`, `3d-printing`, `gltf`, `opengl`, `vulkan`, `mesh`, and more), 2 pages each. That yielded **3,284 unique repositories**, which were deduped and ranked by stars. A 3D-signal filter plus a hand-curated denylist removed false positives that ride in on broad topics — console emulators, 2D-only engines, ML-inference libraries that merely use WebGL, video tools, VPN/"service mesh" projects, and the like — leaving **~2,780 genuine 3D repos**. The top 200 are listed below.
+
+> Note: classification is inherently fuzzy at the margins. A few entries (e.g. `raylib`, `libgdx`, `MonoGame`) are general game frameworks with strong 3D support; learning resources and "awesome-*" lists are included because they are central to the 3D ecosystem.
+
+## Quick read for three.ws
+
+- **three.js (#1, ~113k)** dwarfs everything else in web 3D — it is the foundation this platform is built on.
+- The **pmndrs / React ecosystem** dominates the React side: `react-three-fiber` (#5), `drei` (#42), `uikit` (#179). Framework wrappers exist for every stack: `troisjs/trois` + `Tresjs/tres` (Vue), `threlte` (Svelte), `gre/gl-react` (React shaders).
+- The fastest-growing cluster is **NeRF + Gaussian Splatting** — `gaussian-splatting` (#10), `instant-ngp` (#16), `nerfstudio` (#33), `supersplat` (#48), `gsplat` (#96), plus generative 3D (`TRELLIS`, `Hunyuan3D`, `stable-dreamfusion`). This is where web-3D capture is heading and worth tracking for the platform roadmap.
+
+## Top categories at a glance
+
+| Category | Notable repos in the top 200 |
+| --- | --- |
+| Web / JS 3D libraries | three.js, react-three-fiber, Babylon.js, playcanvas, cesium, deck.gl, model-viewer, regl, orillusion, galacean, troisjs, threlte, claygl |
+| Native / game engines | godot, raylib, libgdx, GDevelop, cocos, o3de, stride, FlaxEngine, Piccolo, panda3d, urho3d, mach, SpartanEngine, LumixEngine |
+| Low-level graphics & GPU | filament, wgpu, bgfx, glfw, Vulkan samples, The-Forge, Silk.NET, vulkano, magnum, DiligentEngine, glad, glew, rust-gpu |
+| NeRF / Gaussian Splatting / gen-3D | gaussian-splatting, instant-ngp, nerfstudio, supersplat, gsplat, multinerf, neuralangelo, SuGaR, 4DGaussians, TRELLIS, Hunyuan3D, stable-dreamfusion |
+| 3D ML / point clouds / reconstruction | Open3D, PCL, openMVG, openMVS, OpenSfM, mmdetection3d, OpenPCDet, pointnet, kaolin, Pointcept, AliceVision, map-anything |
+| Modeling / CAD / content tools | FreeCAD, blender, openscad, meshlab, blockbench, material-maker, cadquery, chili3d, dust3d, armorpaint, f3d, Online3DViewer |
+| Mesh / asset pipeline | assimp, meshoptimizer, draco, tinyobjloader, trimesh, cglm, yocto-gl |
+| 3D printing | Marlin, OrcaSlicer, Cura, Slic3r |
+| Shaders & learning | 3d-game-shaders-for-beginners, tinyrenderer, raytracing.github.io, webgl-fundamentals, glslViewer, SHADERed, lygia, slang |
+
+## Top 200 by stars
+
+| # | Repository | Stars (k) | Language | Description |
+| --- | --- | --- | --- | --- |
+| 1 | [mrdoob/three.js](https://github.com/mrdoob/three.js) | 112.8 | JavaScript | JavaScript 3D Library. |
+| 2 | [godotengine/godot](https://github.com/godotengine/godot) | 111.3 | C++ | Godot Engine – Multi-platform 2D and 3D game engine |
+| 3 | [raysan5/raylib](https://github.com/raysan5/raylib) | 33.2 | C | A simple and easy-to-use library to enjoy videogames programming |
+| 4 | [FreeCAD/FreeCAD](https://github.com/FreeCAD/FreeCAD) | 31.2 | C++ | Official source code of FreeCAD, a free and opensource multiplatform 3D parametric modeler |
+| 5 | [pmndrs/react-three-fiber](https://github.com/pmndrs/react-three-fiber) | 31 | TypeScript | 🇨🇭 A React renderer for Three.js |
+| 6 | [BabylonJS/Babylon.js](https://github.com/BabylonJS/Babylon.js) | 25.6 | TypeScript | Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed int |
+| 7 | [libgdx/libgdx](https://github.com/libgdx/libgdx) | 25.1 | Java | Desktop/Android/HTML5/iOS Java game development framework |
+| 8 | [ssloy/tinyrenderer](https://github.com/ssloy/tinyrenderer) | 23.6 | C++ | A brief computer graphics / rendering course |
+| 9 | [4ian/GDevelop](https://github.com/4ian/GDevelop) | 23.3 | JavaScript | 🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone. |
+| 10 | [graphdeco-inria/gaussian-splatting](https://github.com/graphdeco-inria/gaussian-splatting) | 22.2 | Python | Original reference implementation of "3D Gaussian Splatting for Real-Time Radiance Field R |
+| 11 | [google/filament](https://github.com/google/filament) | 20.1 | C++ | Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux |
+| 12 | [lettier/3d-game-shaders-for-beginners](https://github.com/lettier/3d-game-shaders-for-beginners) | 19.6 | C++ | 🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and |
+| 13 | [blender/blender](https://github.com/blender/blender) | 18.6 | C++ | Official mirror of Blender |
+| 14 | [aframevr/aframe](https://github.com/aframevr/aframe) | 17.5 | JavaScript | :a: Web framework for building virtual reality experiences. |
+| 15 | [MarlinFirmware/Marlin](https://github.com/MarlinFirmware/Marlin) | 17.4 | C++ | Marlin is a firmware for RepRap 3D printers optimized for both 8 and 32 bit microcontrolle |
+| 16 | [NVlabs/instant-ngp](https://github.com/NVlabs/instant-ngp) | 17.4 | Cuda | Instant neural graphics primitives: lightning fast NeRF and more |
+| 17 | [gfx-rs/wgpu](https://github.com/gfx-rs/wgpu) | 17.2 | Rust | A cross-platform, safe, pure-Rust graphics API. |
+| 18 | [bkaradzic/bgfx](https://github.com/bkaradzic/bgfx) | 17.1 | C | Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering l |
+| 19 | [PavelDoGreat/WebGL-Fluid-Simulation](https://github.com/PavelDoGreat/WebGL-Fluid-Simulation) | 16.4 | JavaScript | Play with fluids in your browser (works even on mobile) |
+| 20 | [playcanvas/engine](https://github.com/playcanvas/engine) | 15.9 | JavaScript | Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF |
+| 21 | [OpenRCT2/OpenRCT2](https://github.com/OpenRCT2/OpenRCT2) | 15.7 | C++ | An open source re-implementation of RollerCoaster Tycoon 2 🎢 |
+| 22 | [CesiumGS/cesium](https://github.com/CesiumGS/cesium) | 15.3 | JavaScript | An open-source JavaScript library for world-class 3D globes and maps :earth_americas: |
+| 23 | [glfw/glfw](https://github.com/glfw/glfw) | 15 | C | A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input |
+| 24 | [OrcaSlicer/OrcaSlicer](https://github.com/OrcaSlicer/OrcaSlicer) | 14.4 | C++ | G-code generator for 3D printers (Bambu, Prusa, Voron, VzBot, RatRig, Creality, etc.) |
+| 25 | [visgl/deck.gl](https://github.com/visgl/deck.gl) | 14.2 | TypeScript | WebGL2 powered visualization framework |
+| 26 | [MonoGame/MonoGame](https://github.com/MonoGame/MonoGame) | 13.9 | C# | One framework for creating powerful cross-platform games. |
+| 27 | [Tencent-Hunyuan/Hunyuan3D-2](https://github.com/Tencent-Hunyuan/Hunyuan3D-2) | 13.9 | Python | High-Resolution 3D Assets Generation with Large Scale Hunyuan3D Diffusion Models. |
+| 28 | [isl-org/Open3D](https://github.com/isl-org/Open3D) | 13.6 | C++ | Open3D: A Modern Library for 3D Data Processing |
+| 29 | [assimp/assimp](https://github.com/assimp/assimp) | 13 | C++ | The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one un |
+| 30 | [microsoft/TRELLIS](https://github.com/microsoft/TRELLIS) | 12.8 | Python | Official repo for paper "Structured 3D Latents for Scalable and Versatile 3D Generation" ( |
+| 31 | [alicevision/Meshroom](https://github.com/alicevision/Meshroom) | 12.8 | Python | Node-based Visual Programming Toolbox |
+| 32 | [SaschaWillems/Vulkan](https://github.com/SaschaWillems/Vulkan) | 12 | GLSL | C++ examples for the Vulkan graphics API |
+| 33 | [nerfstudio-project/nerfstudio](https://github.com/nerfstudio-project/nerfstudio) | 11.6 | Python | A collaboration friendly studio for NeRFs |
+| 34 | [fogleman/Craft](https://github.com/fogleman/Craft) | 11 | C | A simple Minecraft clone written in C using modern OpenGL (shaders). |
+| 35 | [PointCloudLibrary/pcl](https://github.com/PointCloudLibrary/pcl) | 11 | C++ | Point Cloud Library (PCL) |
+| 36 | [bmild/nerf](https://github.com/bmild/nerf) | 10.9 | Jupyter Notebook | Code release for NeRF (Neural Radiance Fields) |
+| 37 | [baldurk/renderdoc](https://github.com/baldurk/renderdoc) | 10.7 | C++ | RenderDoc is a stand-alone graphics debugging tool. |
+| 38 | [metafizzy/zdog](https://github.com/metafizzy/zdog) | 10.6 | JavaScript | Flat, round, designer-friendly pseudo-3D engine for canvas & SVG |
+| 39 | [openframeworks/openFrameworks](https://github.com/openframeworks/openFrameworks) | 10.4 | C++ | openFrameworks is a community-developed cross platform toolkit for creative coding in C++. |
+| 40 | [RayTracing/raytracing.github.io](https://github.com/RayTracing/raytracing.github.io) | 10.4 | HTML | Main Web Site (Online Books) |
+| 41 | [timzhang642/3D-Machine-Learning](https://github.com/timzhang642/3D-Machine-Learning) | 10.2 | — | A resource repository for 3D machine learning |
+| 42 | [pmndrs/drei](https://github.com/pmndrs/drei) | 9.7 | JavaScript | 🥉 useful helpers for react-three-fiber |
+| 43 | [cocos/cocos-engine](https://github.com/cocos/cocos-engine) | 9.6 | C++ | Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, c |
+| 44 | [openscad/openscad](https://github.com/openscad/openscad) | 9.5 | C++ | OpenSCAD - The Programmers Solid 3D CAD Modeller |
+| 45 | [o3de/o3de](https://github.com/o3de/o3de) | 9.2 | C++ | Open 3D Engine (O3DE) is an Apache 2.0-licensed multi-platform 3D engine that enables deve |
+| 46 | [domlysz/BlenderGIS](https://github.com/domlysz/BlenderGIS) | 9 | Python | Blender addons to make the bridge between Blender and geographic data |
+| 47 | [ashawkey/stable-dreamfusion](https://github.com/ashawkey/stable-dreamfusion) | 8.8 | Python | Text-to-3D & Image-to-3D & Mesh Exportation with NeRF + Diffusion. |
+| 48 | [playcanvas/supersplat](https://github.com/playcanvas/supersplat) | 8.8 | TypeScript | 3D Gaussian Splat Editor |
+| 49 | [MrNeRF/awesome-3D-gaussian-splatting](https://github.com/MrNeRF/awesome-3D-gaussian-splatting) | 8.7 | HTML | Curated list of papers and resources focused on 3D Gaussian Splatting, intended to keep pa |
+| 50 | [google/model-viewer](https://github.com/google/model-viewer) | 8.1 | TypeScript | Easily display interactive 3D models on the web and in AR! |
+| 51 | [a1studmuffin/SpaceshipGenerator](https://github.com/a1studmuffin/SpaceshipGenerator) | 7.8 | Python | A Blender script to procedurally generate 3D spaceships |
+| 52 | [zeux/meshoptimizer](https://github.com/zeux/meshoptimizer) | 7.7 | C++ | Mesh optimization library that makes meshes smaller and faster to render |
+| 53 | [stride3d/stride](https://github.com/stride3d/stride) | 7.6 | C# | Stride (formerly Xenko), a free and open-source cross-platform C# game engine. |
+| 54 | [google/draco](https://github.com/google/draco) | 7.3 | C++ | Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. |
+| 55 | [veloren/veloren](https://github.com/veloren/veloren) | 7.3 | Rust | [mirror of https://gitlab.com/veloren/veloren] An open world, open source voxel RPG inspir |
+| 56 | [turanszkij/WickedEngine](https://github.com/turanszkij/WickedEngine) | 7.1 | C | 3D engine with modern graphics |
+| 57 | [adrianhajdin/project_3D_developer_portfolio](https://github.com/adrianhajdin/project_3D_developer_portfolio) | 7.1 | JavaScript | The most impressive websites in the world use 3D graphics and animations to bring their co |
+| 58 | [Ultimaker/Cura](https://github.com/Ultimaker/Cura) | 7 | Python | 3D printer / slicing GUI built on top of the Uranium framework |
+| 59 | [agmmnn/awesome-blender](https://github.com/agmmnn/awesome-blender) | 6.9 | — | 🪐 A curated list of awesome Blender addons, tools, tutorials; and 3D resources for everyon |
+| 60 | [FlaxEngine/FlaxEngine](https://github.com/FlaxEngine/FlaxEngine) | 6.8 | C++ | Flax Engine – multi-platform 3D game engine |
+| 61 | [awesome-NeRF/awesome-NeRF](https://github.com/awesome-NeRF/awesome-NeRF) | 6.8 | TeX | A curated list of awesome neural radiance fields papers |
+| 62 | [BoomingTech/Piccolo](https://github.com/BoomingTech/Piccolo) | 6.6 | C++ | Piccolo (formerly Pilot) – mini game engine for games104 |
+| 63 | [tengbao/vanta](https://github.com/tengbao/vanta) | 6.6 | JavaScript | Animated 3D backgrounds for your website |
+| 64 | [open-mmlab/mmdetection3d](https://github.com/open-mmlab/mmdetection3d) | 6.4 | Python | OpenMMLab's next-generation platform for general 3D object detection. |
+| 65 | [openMVG/openMVG](https://github.com/openMVG/openMVG) | 6.4 | C++ | open Multiple View Geometry library. Basis for 3D computer vision and Structure from Motio |
+| 66 | [HackerPoet/NonEuclidean](https://github.com/HackerPoet/NonEuclidean) | 6.4 | C++ | A Non-Euclidean Rendering Engine for 3D scenes. |
+| 67 | [OpenDroneMap/ODM](https://github.com/OpenDroneMap/ODM) | 6.1 | Python | A command line toolkit to generate maps, point clouds, 3D models and DEMs from drone, ball |
+| 68 | [vasturiano/3d-force-graph](https://github.com/vasturiano/3d-force-graph) | 6.1 | HTML | 3D force-directed graph component using ThreeJS/WebGL |
+| 69 | [AR-js-org/AR.js](https://github.com/AR-js-org/AR.js) | 5.9 | JavaScript | Image tracking, Location Based AR, Marker tracking. All on the Web. |
+| 70 | [CGAL/cgal](https://github.com/CGAL/cgal) | 5.9 | C++ | The public CGAL repository, see the README below |
+| 71 | [Redot-Engine/redot-engine](https://github.com/Redot-Engine/redot-engine) | 5.9 | C++ | Redot Engine – Multi-platform 2D and 3D game engine |
+| 72 | [galacean/engine](https://github.com/galacean/engine) | 5.8 | TypeScript | A typescript interactive engine, support 2D, 3D, animation, physics, built on WebGL and gl |
+| 73 | [cnr-isti-vclab/meshlab](https://github.com/cnr-isti-vclab/meshlab) | 5.7 | C++ | The open source mesh processing system |
+| 74 | [open-mmlab/OpenPCDet](https://github.com/open-mmlab/OpenPCDet) | 5.6 | Python | OpenPCDet Toolbox for LiDAR-based 3D Object Detection. |
+| 75 | [ConfettiFX/The-Forge](https://github.com/ConfettiFX/The-Forge) | 5.6 | C++ | The Forge Cross-Platform Framework PC Windows, Steamdeck (native), Ray Tracing, macOS / iO |
+| 76 | [regl-project/regl](https://github.com/regl-project/regl) | 5.5 | JavaScript | 👑 Functional WebGL |
+| 77 | [JannisX11/blockbench](https://github.com/JannisX11/blockbench) | 5.5 | JavaScript | Blockbench - A low poly 3D model editor |
+| 78 | [RodZill4/material-maker](https://github.com/RodZill4/material-maker) | 5.5 | GDScript | A procedural textures authoring and 3D model painting tool based on the Godot game engine |
+| 79 | [charlesq34/pointnet](https://github.com/charlesq34/pointnet) | 5.4 | Python | PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation |
+| 80 | [dimforge/rapier](https://github.com/dimforge/rapier) | 5.4 | Rust | 2D and 3D physics engines focused on performance. |
+| 81 | [gfx-rs/gfx](https://github.com/gfx-rs/gfx) | 5.4 | Rust | [maintenance mode] A low-overhead Vulkan-like GPU API for Rust. |
+| 82 | [gpuweb/gpuweb](https://github.com/gpuweb/gpuweb) | 5.4 | Bikeshed | Where the GPU for the Web work happens! |
+| 83 | [LWJGL/lwjgl3](https://github.com/LWJGL/lwjgl3) | 5.3 | Java | LWJGL is a Java library that enables cross-platform access to popular native APIs useful i |
+| 84 | [shader-slang/slang](https://github.com/shader-slang/slang) | 5.3 | C++ | Making it easier to work with shaders |
+| 85 | [ssloy/tinyraytracer](https://github.com/ssloy/tinyraytracer) | 5.3 | C++ | A brief computer graphics / rendering course |
+| 86 | [jagenjo/webglstudio.js](https://github.com/jagenjo/webglstudio.js) | 5.3 | JavaScript | A full open source 3D graphics editor in the browser, with scene editor, coding pad, graph |
+| 87 | [shuding/cobe](https://github.com/shuding/cobe) | 5.3 | TypeScript | 5KB WebGL globe lib. |
+| 88 | [patriciogonzalezvivo/glslViewer](https://github.com/patriciogonzalezvivo/glslViewer) | 5.3 | C++ | Console-based GLSL Sandbox for 2D/3D shaders |
+| 89 | [KhronosGroup/Vulkan-Samples](https://github.com/KhronosGroup/Vulkan-Samples) | 5.3 | C++ | One stop solution for all Vulkan samples |
+| 90 | [CadQuery/cadquery](https://github.com/CadQuery/cadquery) | 5.2 | Python | A python parametric CAD scripting framework based on OCCT |
+| 91 | [crosire/reshade](https://github.com/crosire/reshade) | 5.2 | C++ | A generic post-processing injector for games and video software. |
+| 92 | [Orillusion/orillusion](https://github.com/Orillusion/orillusion) | 5.2 | TypeScript | Orillusion is a pure Web3D rendering engine which is fully developed based on the WebGPU s |
+| 93 | [tensorspace-team/tensorspace](https://github.com/tensorspace-team/tensorspace) | 5.2 | JavaScript | Neural network 3D visualization framework, build interactive and intuitive model in browse |
+| 94 | [mosra/magnum](https://github.com/mosra/magnum) | 5.2 | C++ | Lightweight and modular C++11 graphics middleware for games and data visualization |
+| 95 | [panda3d/panda3d](https://github.com/panda3d/panda3d) | 5.1 | C++ | Powerful, mature open-source cross-platform game engine for Python and C++, developed by D |
+| 96 | [nerfstudio-project/gsplat](https://github.com/nerfstudio-project/gsplat) | 5.1 | Python | CUDA accelerated rasterization of gaussian splatting |
+| 97 | [ProjectPhysX/FluidX3D](https://github.com/ProjectPhysX/FluidX3D) | 5.1 | C++ | The fastest and most memory efficient lattice Boltzmann CFD software, running on all GPUs |
+| 98 | [NVIDIAGameWorks/kaolin](https://github.com/NVIDIAGameWorks/kaolin) | 5.1 | Python | A PyTorch Library for Accelerating 3D Deep Learning Research |
+| 99 | [vulkano-rs/vulkano](https://github.com/vulkano-rs/vulkano) | 5.1 | Rust | Safe and rich Rust wrapper around the Vulkan API |
+| 100 | [dotnet/Silk.NET](https://github.com/dotnet/Silk.NET) | 5.1 | C# | The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and Dire |
+| 101 | [yfeng95/PRNet](https://github.com/yfeng95/PRNet) | 5 | Python | Joint 3D Face Reconstruction and Dense Alignment with Position Map Regression Network (ECC |
+| 102 | [gfxfundamentals/webgl-fundamentals](https://github.com/gfxfundamentals/webgl-fundamentals) | 5 | HTML | WebGL lessons that start with the basics |
+| 103 | [schteppe/cannon.js](https://github.com/schteppe/cannon.js) | 5 | JavaScript | A lightweight 3D physics engine written in JavaScript. |
+| 104 | [yanx27/Pointnet_Pointnet2_pytorch](https://github.com/yanx27/Pointnet_Pointnet2_pytorch) | 4.9 | Python | PointNet and PointNet++ implemented by pytorch (pure python) and on ModelNet, ShapeNet and |
+| 105 | [gameplay3d/gameplay](https://github.com/gameplay3d/gameplay) | 4.9 | C++ | Open-source, cross-platform, C++ game engine for creating 2D/3D games. |
+| 106 | [dfranx/SHADERed](https://github.com/dfranx/SHADERed) | 4.8 | C++ | Lightweight, cross-platform & full-featured shader IDE |
+| 107 | [hexops/mach](https://github.com/hexops/mach) | 4.7 | Zig | zig game engine & graphics toolkit - mirror of https://code.hexops.com/hexops/mach |
+| 108 | [urho3d/urho3d](https://github.com/urho3d/urho3d) | 4.7 | C++ | Game engine |
+| 109 | [ArthurBrussee/brush](https://github.com/ArthurBrussee/brush) | 4.6 | Rust | 3D Reconstruction for all |
+| 110 | [NVlabs/neuralangelo](https://github.com/NVlabs/neuralangelo) | 4.6 | Python | Official implementation of "Neuralangelo: High-Fidelity Neural Surface Reconstruction" (CV |
+| 111 | [OGRECave/ogre](https://github.com/OGRECave/ogre) | 4.6 | C++ | high-performance rendering backend (C++, Python, C#, Java) |
+| 112 | [xiangechen/chili3d](https://github.com/xiangechen/chili3d) | 4.6 | TypeScript | A browser-based 3D CAD application for online model design and editing |
+| 113 | [CloudCompare/CloudCompare](https://github.com/CloudCompare/CloudCompare) | 4.6 | C++ | CloudCompare main repository |
+| 114 | [Dav1dde/glad](https://github.com/Dav1dde/glad) | 4.5 | C | Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs. |
+| 115 | [AaronJackson/vrn](https://github.com/AaronJackson/vrn) | 4.5 | MATLAB | :man: Code for "Large Pose 3D Face Reconstruction from a Single Image via Direct Volumetr |
+| 116 | [NVlabs/tiny-cuda-nn](https://github.com/NVlabs/tiny-cuda-nn) | 4.5 | C++ | Lightning fast C++/CUDA neural network framework |
+| 117 | [troisjs/trois](https://github.com/troisjs/trois) | 4.5 | TypeScript | ✨ ThreeJS + VueJS 3 + ViteJS ⚡ |
+| 118 | [tomlooman/ActionRoguelike](https://github.com/tomlooman/ActionRoguelike) | 4.5 | C++ | Co-op Action Roguelike in Unreal Engine C++ |
+| 119 | [f3d-app/f3d](https://github.com/f3d-app/f3d) | 4.4 | C++ | Fast and minimalist 3D viewer. |
+| 120 | [openMVG/awesome_3DReconstruction_list](https://github.com/openMVG/awesome_3DReconstruction_list) | 4.4 | — | A curated list of papers & resources linked to 3D reconstruction from images. |
+| 121 | [DiligentGraphics/DiligentEngine](https://github.com/DiligentGraphics/DiligentEngine) | 4.3 | Batchfile | A modern cross-platform low-level graphics library and rendering framework |
+| 122 | [Yochengliu/awesome-point-cloud-analysis](https://github.com/Yochengliu/awesome-point-cloud-analysis) | 4.2 | — | A list of papers and datasets about point cloud analysis (processing) |
+| 123 | [hku-mars/FAST-LIVO2](https://github.com/hku-mars/FAST-LIVO2) | 4.1 | C++ | FAST-LIVO2: Fast, Direct LiDAR-Inertial-Visual Odometry |
+| 124 | [antvis/L7](https://github.com/antvis/L7) | 4 | TypeScript | 🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine. |
+| 125 | [cdcseacave/openMVS](https://github.com/cdcseacave/openMVS) | 4 | C++ | open Multi-View Stereo reconstruction library |
+| 126 | [gdquest-demos/godot-shaders](https://github.com/gdquest-demos/godot-shaders) | 4 | GDShader | A large library of free and open-source shaders for the Godot game engine. Here, you'll ge |
+| 127 | [WebODM/WebODM](https://github.com/WebODM/WebODM) | 3.9 | Python | User-friendly, commercial-grade software for processing aerial imagery. ✈️ Download it for |
+| 128 | [spring/spring](https://github.com/spring/spring) | 3.9 | C++ | A powerful free cross-platform RTS game engine. - Report issues at https://springrts.com/m |
+| 129 | [AmbientRun/Ambient](https://github.com/AmbientRun/Ambient) | 3.9 | Rust | The multiplayer game engine |
+| 130 | [armory3d/armorpaint](https://github.com/armory3d/armorpaint) | 3.9 | C | 3D Content Creation Tools |
+| 131 | [QianMo/Real-Time-Rendering-4th-Bibliography-Collection](https://github.com/QianMo/Real-Time-Rendering-4th-Bibliography-Collection) | 3.8 | HTML | Real-Time Rendering 4th (RTR4) 参考文献合集典藏 Collection of <Real-Time Rendering 4th (RTR4)> B |
+| 132 | [nem0/LumixEngine](https://github.com/nem0/LumixEngine) | 3.8 | C++ | 3D C++ Game Engine - yet another open source game engine |
+| 133 | [tinyobjloader/tinyobjloader](https://github.com/tinyobjloader/tinyobjloader) | 3.8 | C++ | Tiny but powerful single file wavefront obj loader |
+| 134 | [google-research/multinerf](https://github.com/google-research/multinerf) | 3.8 | Python | A Code Release for Mip-NeRF 360, Ref-NeRF, and RawNeRF |
+| 135 | [lightningpixel/modly](https://github.com/lightningpixel/modly) | 3.8 | TypeScript | Desktop app to generate 3D models from images using local AI — runs entirely on your GPU |
+| 136 | [mapillary/OpenSfM](https://github.com/mapillary/OpenSfM) | 3.8 | Python | Open source Structure-from-Motion pipeline |
+| 137 | [IrisShaders/Iris](https://github.com/IrisShaders/Iris) | 3.7 | Java | A modern shaders mod for Minecraft compatible with existing OptiFine shader packs |
+| 138 | [KhronosGroup/Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp) | 3.7 | C++ | Open-Source Vulkan C++ API |
+| 139 | [cleardusk/3DDFA](https://github.com/cleardusk/3DDFA) | 3.7 | Python | The PyTorch improved version of TPAMI 2017 paper: Face Alignment in Full Pose Range: A 3D |
+| 140 | [vinjn/awesome-vulkan](https://github.com/vinjn/awesome-vulkan) | 3.7 | — | Awesome Vulkan ecosystem |
+| 141 | [Overv/VulkanTutorial](https://github.com/Overv/VulkanTutorial) | 3.7 | C++ | Tutorial for the Vulkan graphics and compute API |
+| 142 | [charlesq34/pointnet2](https://github.com/charlesq34/pointnet2) | 3.7 | Python | PointNet++: Deep Hierarchical Feature Learning on Point Sets in a Metric Space |
+| 143 | [keenanwoodall/Deform](https://github.com/keenanwoodall/Deform) | 3.6 | C# | A fully-featured deformer system for Unity that lets you stack effects to animate models i |
+| 144 | [hustvl/4DGaussians](https://github.com/hustvl/4DGaussians) | 3.6 | Jupyter Notebook | [CVPR 2024] 4D Gaussian Splatting for Real-Time Dynamic Scene Rendering |
+| 145 | [slic3r/Slic3r](https://github.com/slic3r/Slic3r) | 3.6 | C++ | Open Source toolpath generator for 3D printers |
+| 146 | [glium/glium](https://github.com/glium/glium) | 3.6 | Rust | Safe OpenGL wrapper for the Rust language. |
+| 147 | [openscenegraph/OpenSceneGraph](https://github.com/openscenegraph/OpenSceneGraph) | 3.6 | C++ | OpenSceneGraph git repository |
+| 148 | [Tresjs/tres](https://github.com/Tresjs/tres) | 3.6 | Vue | Declarative ThreeJS using Vue Components |
+| 149 | [mikedh/trimesh](https://github.com/mikedh/trimesh) | 3.6 | Python | Python library for loading and using triangular meshes. |
+| 150 | [ThisisGame/cpp-game-engine-book](https://github.com/ThisisGame/cpp-game-engine-book) | 3.6 | C++ | 从零编写游戏引擎教程 Writing a game engine tutorial from scratch |
+| 151 | [vispy/vispy](https://github.com/vispy/vispy) | 3.6 | Python | Main repository for Vispy |
+| 152 | [DLR-RM/BlenderProc](https://github.com/DLR-RM/BlenderProc) | 3.6 | Python | A procedural Blender pipeline for photorealistic training image generation |
+| 153 | [QianMo/X-PostProcessing-Library](https://github.com/QianMo/X-PostProcessing-Library) | 3.5 | C# | Unity Post Processing Stack Library Unity引擎的高品质后处理库 |
+| 154 | [kovacsv/Online3DViewer](https://github.com/kovacsv/Online3DViewer) | 3.5 | JavaScript | A solution to visualize and explore 3D models in your browser. |
+| 155 | [opentk/opentk](https://github.com/opentk/opentk) | 3.5 | C# | The Open Toolkit library is a fast, low-level C# wrapper for OpenGL, OpenAL & OpenCL. It a |
+| 156 | [OpenXRay/xray-16](https://github.com/OpenXRay/xray-16) | 3.5 | C++ | Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E |
+| 157 | [Tencent-Hunyuan/Hunyuan3D-2.1](https://github.com/Tencent-Hunyuan/Hunyuan3D-2.1) | 3.5 | Python | From Images to High-Fidelity 3D Assets with Production-Ready PBR Material |
+| 158 | [Tencent-Hunyuan/Hunyuan3D-1](https://github.com/Tencent-Hunyuan/Hunyuan3D-1) | 3.5 | Python | Tencent Hunyuan3D-1.0: A Unified Framework for Text-to-3D and Image-to-3D Generation |
+| 159 | [AtomicGameEngine/AtomicGameEngine](https://github.com/AtomicGameEngine/AtomicGameEngine) | 3.4 | C++ | The Atomic Game Engine is a multi-platform 2D and 3D engine with a consistent API in C++, |
+| 160 | [HamishMW/portfolio](https://github.com/HamishMW/portfolio) | 3.4 | JavaScript | My personal portfolio website built using React and three js |
+| 161 | [alicevision/AliceVision](https://github.com/alicevision/AliceVision) | 3.4 | C++ | 3D Computer Vision Framework |
+| 162 | [facebookresearch/map-anything](https://github.com/facebookresearch/map-anything) | 3.4 | Python | MapAnything: Universal Feed-Forward Metric 3D Reconstruction |
+| 163 | [Anttwo/SuGaR](https://github.com/Anttwo/SuGaR) | 3.4 | C++ | [CVPR 2024] Official PyTorch implementation of SuGaR: Surface-Aligned Gaussian Splatting f |
+| 164 | [gkjohnson/three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) | 3.4 | JavaScript | A BVH implementation to speed up raycasting and enable spatial queries against three.js me |
+| 165 | [fogleman/ln](https://github.com/fogleman/ln) | 3.4 | Go | 3D line art engine. |
+| 166 | [GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) | 3.4 | C | Easy to integrate Vulkan memory allocation library |
+| 167 | [patriciogonzalezvivo/lygia](https://github.com/patriciogonzalezvivo/lygia) | 3.3 | GLSL | LYGIA, it's a granular and multi-language (GLSL, HLSL, Metal, WGSL, WEGL and CUDA) shade |
+| 168 | [luigifreda/pyslam](https://github.com/luigifreda/pyslam) | 3.3 | Python | pySLAM is a hybrid Python/C++ Visual SLAM pipeline supporting monocular, stereo, and RGB-D |
+| 169 | [aras-p/UnityGaussianSplatting](https://github.com/aras-p/UnityGaussianSplatting) | 3.3 | C# | Toy Gaussian Splatting visualization in Unity |
+| 170 | [hlorus/CAD_Sketcher](https://github.com/hlorus/CAD_Sketcher) | 3.3 | Python | Constraint-based geometry sketcher for blender |
+| 171 | [vrm-c/UniVRM](https://github.com/vrm-c/UniVRM) | 3.3 | C# | UniVRM is a gltf-based VRM format implementation for Unity. English is here https://vrm.de |
+| 172 | [armory3d/armory](https://github.com/armory3d/armory) | 3.3 | C++ | 3D Engine with Blender Integration |
+| 173 | [huxingyi/dust3d](https://github.com/huxingyi/dust3d) | 3.3 | C++ | Dust3D is a cross-platform 3D modeling software that makes it easy to create low poly 3D m |
+| 174 | [threlte/threlte](https://github.com/threlte/threlte) | 3.3 | Svelte | 3D framework for Svelte |
+| 175 | [nidorx/matcaps](https://github.com/nidorx/matcaps) | 3.3 | JavaScript | Huge library of matcap PNG textures organized by color |
+| 176 | [cryinkfly/Autodesk-Fusion-360-for-Linux](https://github.com/cryinkfly/Autodesk-Fusion-360-for-Linux) | 3.2 | Shell | This is a project, where I give you a way to use Autodesk Fusion 360 on Linux! |
+| 177 | [hbb1/2d-gaussian-splatting](https://github.com/hbb1/2d-gaussian-splatting) | 3.2 | Python | [SIGGRAPH'24] 2D Gaussian Splatting for Geometrically Accurate Radiance Fields |
+| 178 | [lo-th/Oimo.js](https://github.com/lo-th/Oimo.js) | 3.2 | JavaScript | Lightweight 3d physics engine for javascript |
+| 179 | [pmndrs/uikit](https://github.com/pmndrs/uikit) | 3.2 | TypeScript | 🎨 user interfaces for react-three-fiber |
+| 180 | [vasturiano/react-force-graph](https://github.com/vasturiano/react-force-graph) | 3.2 | HTML | React component for 2D, 3D, VR and AR force directed graphs |
+| 181 | [cleardusk/3DDFA_V2](https://github.com/cleardusk/3DDFA_V2) | 3.1 | Python | The official PyTorch implementation of Towards Fast, Accurate and Stable 3D Dense Face Ali |
+| 182 | [MrNeRF/LichtFeld-Studio](https://github.com/MrNeRF/LichtFeld-Studio) | 3.1 | C++ | Train, inspect, edit, automate, and export 3D Gaussian Splatting scenes from a single nati |
+| 183 | [Rust-GPU/rust-gpu](https://github.com/Rust-GPU/rust-gpu) | 3.1 | Rust | 🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧 |
+| 184 | [g3n/engine](https://github.com/g3n/engine) | 3.1 | Go | Go 3D Game Engine (http://g3n.rocks) |
+| 185 | [bradley/Blotter](https://github.com/bradley/Blotter) | 3.1 | JavaScript | A JavaScript API for drawing unconventional text effects on the web. |
+| 186 | [Pointcept/Pointcept](https://github.com/Pointcept/Pointcept) | 3.1 | Python | Pointcept: Perceive the world with sparse points, a codebase for point cloud perception re |
+| 187 | [PanosK92/SpartanEngine](https://github.com/PanosK92/SpartanEngine) | 3 | C++ | A game engine with a fully bindless, GPU-driven renderer featuring real-time path-traced g |
+| 188 | [vasturiano/globe.gl](https://github.com/vasturiano/globe.gl) | 3 | HTML | UI component for Globe Data Visualization using ThreeJS/WebGL |
+| 189 | [korlibs/korge](https://github.com/korlibs/korge) | 3 | Kotlin | A Kotlin Multiplatform Game Engine |
+| 190 | [gre/gl-react](https://github.com/gre/gl-react) | 3 | TypeScript | gl-react – React library to write and compose WebGL shaders |
+| 191 | [Awesome3DGS/3D-Gaussian-Splatting-Papers](https://github.com/Awesome3DGS/3D-Gaussian-Splatting-Papers) | 3 | Python | 3D高斯论文,持续更新,欢迎交流讨论。 |
+| 192 | [greggman/twgl.js](https://github.com/greggman/twgl.js) | 3 | JavaScript | A Tiny WebGL helper Library |
+| 193 | [avianphysics/avian](https://github.com/avianphysics/avian) | 3 | Rust | ECS-driven 2D and 3D physics engine for the Bevy game engine. |
+| 194 | [recp/cglm](https://github.com/recp/cglm) | 2.9 | C | 📽 Highly Optimized 2D / 3D Graphics Math (glm) for C |
+| 195 | [xelatihy/yocto-gl](https://github.com/xelatihy/yocto-gl) | 2.9 | C++ | Yocto/GL: Tiny C++ Libraries for Data-Driven Physically-based Graphics |
+| 196 | [zhulf0804/3D-PointCloud](https://github.com/zhulf0804/3D-PointCloud) | 2.9 | Python | Papers and Datasets about Point Cloud. |
+| 197 | [jeeliz/jeelizFaceFilter](https://github.com/jeeliz/jeelizFaceFilter) | 2.9 | JavaScript | 🎭 Lightweight WebGL & JavaScript library for real-time multi-face detection, tracking and |
+| 198 | [nigels-com/glew](https://github.com/nigels-com/glew) | 2.9 | C | The OpenGL Extension Wrangler Library |
+| 199 | [pissang/claygl](https://github.com/pissang/claygl) | 2.9 | JavaScript | A WebGL graphic library for building scalable Web3D applications |
+| 200 | [gildor2/UEViewer](https://github.com/gildor2/UEViewer) | 2.9 | C++ | Viewer and exporter for Unreal Engine 1-4 assets (UE Viewer). |
+
+## Reproduce / refresh this list
+
+```bash
+# Requires: gh (authenticated) + jq
+queries=( "topic:3d" "topic:threejs" "topic:webgl" "topic:webgpu" "topic:3d-graphics" \
+ "topic:computer-graphics" "topic:graphics" "topic:rendering" "topic:raytracing" \
+ "topic:game-engine 3d" "topic:gaussian-splatting" "topic:nerf" "topic:point-cloud" \
+ "topic:3d-reconstruction" "topic:3d-printing" "topic:gltf" "topic:3d-models" \
+ "topic:opengl" "topic:vulkan" "topic:mesh" "3d engine" "3d rendering" )
+rm -f all.json
+for q in "${queries[@]}"; do for page in 1 2; do
+ gh api -X GET search/repositories -f q="$q" -f sort=stars -f order=desc \
+ -f per_page=100 -f page=$page \
+ --jq '.items[] | {full_name, stars: .stargazers_count, desc: .description, lang: .language, topics: .topics, url: .html_url}' \
+ >> all.json; sleep 1
+done; done
+# dedupe + rank
+jq -s 'group_by(.full_name) | map(.[0]) | sort_by(-.stars)' all.json > dedup.json
+```
+
+Apply a 3D-signal regex filter over `description + topics` and a denylist of non-3D false positives (emulators, 2D engines, ML-inference libs, video/VPN tools), then take the top N. See git history for the exact filter used.
diff --git a/public/legal/eula.html b/public/legal/eula.html
new file mode 100644
index 000000000..d02459f43
--- /dev/null
+++ b/public/legal/eula.html
@@ -0,0 +1,107 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>End-User License Agreement · three.ws</title>
+ <link rel="icon" href="/favicon.ico" />
+ <style>
+ :root { color-scheme: dark; }
+ * { box-sizing: border-box; }
+ body {
+ font: 16px/1.7 -apple-system, system-ui, 'Segoe UI', sans-serif;
+ background: #000000;
+ color: #ccc;
+ margin: 0;
+ padding: 48px 24px 80px;
+ }
+ .wrap { max-width: 720px; margin: 0 auto; }
+ .brand { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #ffffff; margin: 0 0 32px; display: block; text-decoration: none; }
+ .header-logo { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }
+ h1 { font-size: 32px; color: #eee; margin: 0 0 6px; letter-spacing: -.02em; }
+ .meta { color: #555; font-size: 14px; margin: 0 0 40px; }
+ h2 { font-size: 18px; color: #eee; margin: 40px 0 10px; }
+ p, li { color: #aaa; font-size: 15px; }
+ ul { padding-left: 20px; }
+ li { margin-bottom: 6px; }
+ a { color: #cccccc; }
+ hr { border: none; border-top: 1px solid #1e1e1e; margin: 48px 0; }
+ .foot { color: #555; font-size: 13px; }
+ </style>
+</head>
+<body>
+<div class="wrap">
+ <a class="brand" href="/"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a>
+ <h1>End-User License Agreement</h1>
+ <p class="meta">Effective: May 30, 2026 &nbsp;·&nbsp; AWS Marketplace Edition &nbsp;·&nbsp; <a href="/legal/tos.html">Terms of Service</a></p>
+
+ <p>This End-User License Agreement ("Agreement") is a binding contract between you, either an individual or the entity you represent ("Licensee", "you"), and three.ws ("Licensor", "we", "us", "our"), governing your access to and use of the three.ws software, platform, APIs, SDKs, and related services (collectively, the "Software") procured through AWS Marketplace. By subscribing to, accessing, or using the Software, you agree to be bound by this Agreement. If you do not agree, do not subscribe to or use the Software.</p>
+
+ <h2>1. License Grant</h2>
+ <p>Subject to your compliance with this Agreement and payment of all applicable fees, Licensor grants you a non-exclusive, non-transferable, non-sublicensable, revocable license to access and use the Software during your active subscription term, solely for your internal business purposes and in accordance with the documentation and the offer you purchased through AWS Marketplace.</p>
+
+ <h2>2. Subscription, Fees & AWS Marketplace</h2>
+ <p>The Software is provided on a subscription or usage basis as specified in your AWS Marketplace offer. Fees, metering, billing, and taxes are administered through AWS Marketplace in accordance with the AWS Marketplace Terms and the AWS Customer Agreement between you and Amazon Web Services. Refunds, where applicable, are governed by the refund policy published with this listing and processed through AWS Marketplace.</p>
+
+ <h2>3. Restrictions</h2>
+ <p>You shall not, and shall not permit any third party to:</p>
+ <ul>
+ <li>Copy, modify, or create derivative works of the Software except as expressly permitted by an applicable open-source license.</li>
+ <li>Reverse-engineer, decompile, or disassemble the Software, or attempt to derive its source code, except to the extent such restriction is prohibited by law.</li>
+ <li>Rent, lease, sell, sublicense, distribute, or otherwise commercially exploit the Software beyond the scope of your purchased offer.</li>
+ <li>Remove or obscure any proprietary notices, or use the Software to build a competing product or service.</li>
+ <li>Use the Software to transmit malware, conduct unlawful activity, infringe third-party rights, or circumvent usage limits, metering, or access controls.</li>
+ <li>Use automated means to scrape, index, or harvest data from the Software without prior written permission.</li>
+ </ul>
+
+ <h2>4. Intellectual Property</h2>
+ <p>The Software, including all associated intellectual property rights, is and remains the exclusive property of Licensor and its licensors. This Agreement grants you a license only and conveys no ownership interest. Open-source components are licensed under their respective licenses, which control to the extent of any conflict for those components.</p>
+
+ <h2>5. Customer Content</h2>
+ <p>You retain ownership of 3D models, data, and other content you upload or generate through the Software ("Your Content"). You grant Licensor a worldwide, royalty-free, non-exclusive license to host, process, transmit, and display Your Content solely to provide and operate the Software. You represent and warrant that you hold all rights necessary to grant this license and that Your Content does not infringe any third-party rights.</p>
+
+ <h2>6. Blockchain & On-Chain Transactions</h2>
+ <p>The Software enables interaction with public blockchains, self-custodied wallets, digital assets, and the x402 payment protocol. You acknowledge and agree that:</p>
+ <ul>
+ <li>On-chain transactions are irreversible and final. Licensor cannot reverse, cancel, refund, or recover any blockchain transaction, transfer, or payment.</li>
+ <li>You are solely responsible for the security of your wallet keys, seed phrases, and credentials. Licensor never holds your private keys and cannot recover them if lost.</li>
+ <li>You are solely responsible for all gas fees, network fees, and on-chain costs, and for compliance with all laws applicable to digital assets in your jurisdiction.</li>
+ <li>Digital assets are volatile and may lose value. Licensor does not provide financial, investment, legal, or tax advice and is not responsible for any loss arising from token price movements, network congestion, forks, exploits, or third-party smart contracts.</li>
+ <li>Blockchain networks and third-party RPC, payment, and data providers are outside Licensor's control; Licensor is not liable for their availability, accuracy, or performance.</li>
+ </ul>
+
+ <h2>7. Third-Party Services</h2>
+ <p>The Software may integrate with or depend on third-party services and networks (including blockchain RPC providers, payment protocols, and AI model providers). Your use of such services is subject to their respective terms, and Licensor is not responsible for third-party services.</p>
+
+ <h2>8. Confidentiality</h2>
+ <p>Each party shall protect the other's non-public information disclosed in connection with the Software with at least the same degree of care it uses for its own confidential information, and shall use it only as necessary to perform under this Agreement.</p>
+
+ <h2>9. Disclaimer of Warranties</h2>
+ <p>THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. LICENSOR DOES NOT WARRANT THAT THE SOFTWARE WILL BE UNINTERRUPTED, SECURE, ERROR-FREE, OR THAT DEFECTS WILL BE CORRECTED.</p>
+
+ <h2>10. Limitation of Liability</h2>
+ <p>TO THE MAXIMUM EXTENT PERMITTED BY LAW, LICENSOR SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS, REVENUE, DATA, GOODWILL, OR DIGITAL ASSETS, ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE SOFTWARE. LICENSOR'S TOTAL AGGREGATE LIABILITY UNDER THIS AGREEMENT SHALL NOT EXCEED THE FEES PAID BY YOU FOR THE SOFTWARE THROUGH AWS MARKETPLACE DURING THE TWELVE (12) MONTHS PRECEDING THE EVENT GIVING RISE TO THE CLAIM.</p>
+
+ <h2>11. Indemnification</h2>
+ <p>You agree to indemnify, defend, and hold harmless Licensor and its officers, directors, employees, and agents from any claims, liabilities, damages, judgments, and expenses (including reasonable attorneys' fees) arising from your use of the Software, Your Content, your on-chain activity, or your violation of this Agreement.</p>
+
+ <h2>12. Term & Termination</h2>
+ <p>This Agreement remains in effect for the duration of your subscription. It terminates automatically upon expiration or cancellation of your AWS Marketplace subscription, or upon your breach of this Agreement. Upon termination, your license ends and you must cease using the Software. Sections that by their nature should survive (including 3, 4, 9, 10, 11, and 14) survive termination.</p>
+
+ <h2>13. Compliance & Export</h2>
+ <p>You shall comply with all applicable laws, including export-control and economic-sanctions laws. You represent that you are not located in, or a national of, any embargoed jurisdiction and are not on any restricted-party list.</p>
+
+ <h2>14. Governing Law</h2>
+ <p>This Agreement is governed by the laws of the State of Delaware, USA, without regard to its conflict-of-law provisions. Any disputes shall be resolved exclusively in the state or federal courts located in Delaware. To the extent of any conflict between this Agreement and the AWS Marketplace Standard Contract for the same transaction, this custom Agreement controls as permitted by AWS Marketplace.</p>
+
+ <h2>15. Entire Agreement</h2>
+ <p>This Agreement, together with the AWS Marketplace offer and applicable AWS Marketplace terms, constitutes the entire agreement between the parties regarding the Software and supersedes all prior agreements. If any provision is held unenforceable, the remaining provisions remain in full force.</p>
+
+ <h2>16. Contact</h2>
+ <p>Questions about this Agreement? Email <a href="mailto:[email protected]">[email protected]</a>. Product support: <a href="mailto:[email protected]">[email protected]</a>.</p>
+
+ <hr>
+ <p class="foot">three.ws &nbsp;·&nbsp; <a href="/legal/tos.html">Terms of Service</a> &nbsp;·&nbsp; <a href="/legal/privacy.html">Privacy Policy</a> &nbsp;·&nbsp; <a href="/">Home</a></p>
+</div>
+</body>
+</html>
diff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.js
index 43daa2e4c..828f8dea5 100644
--- a/public/studio/launch-panel.js
+++ b/public/studio/launch-panel.js
@@ -938,7 +938,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
s.phase = 'building'; s.phaseLabel = 'Uploading metadata…'; render();
const nameTrim = s.name.trim().slice(0, 32);
- const symTrim = s.symbol.trim().slice(0, 10);
+ // Preserve the symbol exactly as entered (whitespace/emoji/special chars), cap at 10 codepoints.
+ const symTrim = [...s.symbol].slice(0, 10).join('');
const descTrim = s.description.trim().slice(0, 500);
const metaKey = `${nameTrim}|${symTrim}|${descTrim}|${!!s.imageFile}`;
@@ -1144,7 +1145,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
const buy = Math.max(0, parseFloat(s.initialBuy) || 0);
return PUMP_BASE_COST + (s.coinType === 'usdc' ? 0 : buy);
};
- const formValid = () => s.name.trim() && s.symbol.trim() && s.description.trim();
+ // Symbol accepts any raw value (whitespace, emoji, special chars) — only name & description require real text.
+ const formValid = () => s.name.trim() && s.symbol.length > 0 && s.description.trim();
// ── Render ─────────────────────────────────────────────────────────────
@@ -1520,9 +1522,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
<input class="lp-iname" id="lp-name" type="text" maxlength="32"
placeholder="Token name" value="${esc(s.name)}" ${dis}
title="Shown on pump.fun. Up to 32 chars." />
- <input class="lp-isymbol" id="lp-sym" type="text" maxlength="10"
+ <input class="lp-isymbol" id="lp-sym" type="text" maxlength="80"
placeholder="SYMBOL" value="${esc(s.symbol)}" ${dis}
- title="Ticker symbol (the $ in $CZ). Letters and numbers only, up to 10 chars." />
+ title="Ticker symbol (the $ in $CZ). Any characters — emoji and symbols allowed, up to 10." />
<div class="lp-img-hint">Click image to replace · drag &amp; drop</div>
${getPreviewViewer ? `<button type="button" class="lp-cap-btn" id="lp-capture" ${dis} title="Snapshot the current 3D preview and use it as the token image.">📸 Use 3D view</button>` : ''}
</div>
@@ -1637,7 +1639,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
}
});
q('#lp-sym')?.addEventListener('input', (e) => {
- const raw = e.target.value.toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 10);
+ // Permissive: allow any characters (emoji, lowercase, symbols), cap at 10 codepoints.
+ const raw = [...e.target.value].slice(0, 10).join('');
e.target.value = raw; s.symbol = raw; s._symbolEdited = true;
});
q('#lp-desc')?.addEventListener('input', (e) => { s.description = e.target.value; });
diff --git a/public/walk-embed-sdk.js b/public/walk-embed-sdk.js
index ce1c81710..0305a2af4 100644
--- a/public/walk-embed-sdk.js
+++ b/public/walk-embed-sdk.js
@@ -5,7 +5,8 @@
// data-avatar="<uuid>"
// data-position="bottom-right"
// data-width="220"
-// data-height="320"></script>
+// data-height="320"
+// data-env="studio"></script>
//
// The script:
// 1. Reads `data-*` attributes off its own <script> tag.
@@ -75,6 +76,7 @@
width: parseInt(attr('data-width', '220'), 10) || 220,
height: parseInt(attr('data-height', '320'), 10) || 320,
controls: attr('data-controls', 'none'),
+ env: attr('data-env', 'studio'),
autoplay: attrBool('data-autoplay', true),
ground: attrBool('data-ground', false),
orbit: attrBool('data-orbit', false),
@@ -104,6 +106,7 @@
if (opts.ground === false) p.set('ground', 'false');
if (opts.orbit === false) p.set('orbit', 'false');
if (opts.bg && opts.bg !== 'transparent') p.set('bg', opts.bg);
+ if (opts.env && opts.env !== 'studio') p.set('env', opts.env);
return EMBED_ORIGIN + '/walk-embed?' + p.toString();
}
@@ -223,6 +226,10 @@
resetPose: function () {
postToFrame({ type: 'walk:resetPose' });
},
+ setEnv: function (env) {
+ state.options.env = env || 'studio';
+ postToFrame({ type: 'walk:setEnv', env: env });
+ },
on: function (name, cb) {
(state.listeners[name] = state.listeners[name] || []).push(cb);
},
diff --git a/scratch/walk-debug.tmp.mjs b/scratch/walk-debug.tmp.mjs
deleted file mode 100644
index fa26a6745..000000000
--- a/scratch/walk-debug.tmp.mjs
+++ /dev/null
@@ -1,28 +0,0 @@
-import { chromium } from 'playwright';
-
-const browser = await chromium.launch();
-const ctx = await browser.newContext({ viewport: { width: 1024, height: 768 } });
-await ctx.grantPermissions(['camera']);
-const page = await ctx.newPage();
-const logs = [];
-page.on('pageerror', (err) => logs.push('[pageerror] ' + (err?.stack || err)));
-page.on('console', (m) => logs.push(`[${m.type()}] ${m.text()}`));
-page.on('requestfailed', (req) => logs.push(`[reqfail] ${req.url()} ${req.failure()?.errorText}`));
-page.on('websocket', (ws) => {
- logs.push(`[ws-open] ${ws.url()}`);
- ws.on('framereceived', (f) => logs.push(`[ws-recv] ${typeof f.payload === 'string' ? f.payload.slice(0,80) : `<${f.payload.length}B>`}`));
- ws.on('framesent', (f) => logs.push(`[ws-send] ${typeof f.payload === 'string' ? f.payload.slice(0,80) : `<${f.payload.length}B>`}`));
- ws.on('socketerror', (e) => logs.push(`[ws-err] ${e}`));
- ws.on('close', () => logs.push(`[ws-close] ${ws.url()}`));
-});
-
-await page.goto('http://localhost:3000/walk?name=alice', { waitUntil: 'domcontentloaded' });
-await page.waitForTimeout(7000);
-
-const state = await page.evaluate(() => ({
- statusText: document.getElementById('walk-status')?.textContent,
- onlineStatus: document.getElementById('walk-online')?.dataset?.status,
- onlineLabel: document.getElementById('walk-online')?.querySelector('[data-label]')?.textContent,
-}));
-await browser.close();
-console.log(JSON.stringify({ state, logs }, null, 2));
diff --git a/scratch/walk-multi-smoke.tmp.mjs b/scratch/walk-multi-smoke.tmp.mjs
deleted file mode 100644
index 006252fe0..000000000
--- a/scratch/walk-multi-smoke.tmp.mjs
+++ /dev/null
@@ -1,97 +0,0 @@
-import { chromium } from 'playwright';
-import { mkdirSync } from 'fs';
-
-const VITE = 'http://localhost:3000';
-const TIMEOUT = 25_000;
-
-mkdirSync('scratch/screenshots', { recursive: true });
-
-const browser = await chromium.launch();
-
-async function newClient(name) {
- const ctx = await browser.newContext({ viewport: { width: 1024, height: 768 } });
- await ctx.grantPermissions(['camera']);
- const page = await ctx.newPage();
- const errs = [];
- page.on('pageerror', (err) => errs.push(`[pageerror:${name}] ${err?.stack || err}`));
- page.on('console', (m) => {
- if (m.type() === 'error') errs.push(`[console.error:${name}] ${m.text()}`);
- });
- return { ctx, page, errs };
-}
-
-const a = await newClient('A');
-const b = await newClient('B');
-
-// Each client connects with a different display name.
-await a.page.goto(`${VITE}/walk?name=alice`, { waitUntil: 'domcontentloaded', timeout: TIMEOUT });
-await b.page.goto(`${VITE}/walk?name=bob`, { waitUntil: 'domcontentloaded', timeout: TIMEOUT });
-
-// Wait for both avatars to load (status text flips to "walk it").
-const waitForReady = (p) =>
- p.waitForFunction(
- () => {
- const el = document.getElementById('walk-status');
- return el && /walk it/i.test(el.textContent || '');
- },
- { timeout: TIMEOUT },
- );
-await Promise.all([waitForReady(a.page), waitForReady(b.page)]);
-
-// Wait for the online pill on each client to flip to "online".
-const waitForOnline = (p) =>
- p.waitForFunction(
- () => {
- const el = document.getElementById('walk-online');
- return el && el.getAttribute('data-status') === 'online';
- },
- { timeout: TIMEOUT },
- );
-await Promise.all([waitForOnline(a.page), waitForOnline(b.page)]);
-
-// Push A forward (W) for ~1.2s — B should observe A's position changing.
-// We detect that by waiting for B's DOM to gain a .walk-remote-label
-// (alice's floating name tag).
-await a.page.evaluate(async () => {
- const wait = (ms) => new Promise((r) => setTimeout(r, ms));
- const fire = (type, code) => window.dispatchEvent(new KeyboardEvent(type, { code, bubbles: true }));
- fire('keydown', 'KeyW');
- await wait(1200);
- fire('keyup', 'KeyW');
-});
-
-// Give B a moment to receive the patches.
-await b.page.waitForTimeout(800);
-
-const bSawA = await b.page.evaluate(() => {
- const labels = Array.from(document.querySelectorAll('.walk-remote-label'));
- return {
- count: labels.length,
- names: labels.map((l) => l.textContent),
- countPill: document.getElementById('walk-online-count')?.textContent,
- };
-});
-const aSawB = await a.page.evaluate(() => {
- const labels = Array.from(document.querySelectorAll('.walk-remote-label'));
- return {
- count: labels.length,
- names: labels.map((l) => l.textContent),
- countPill: document.getElementById('walk-online-count')?.textContent,
- };
-});
-
-// Screenshots for visual confirmation.
-await a.page.screenshot({ path: 'scratch/screenshots/walk-multi-A.png' });
-await b.page.screenshot({ path: 'scratch/screenshots/walk-multi-B.png' });
-
-await browser.close();
-
-const errs = [...a.errs, ...b.errs];
-const ok =
- bSawA.count >= 1 &&
- bSawA.names.includes('alice') &&
- aSawB.count >= 1 &&
- aSawB.names.includes('bob') &&
- errs.length === 0;
-console.log(JSON.stringify({ ok, bSawA, aSawB, errs }, null, 2));
-process.exit(ok ? 0 : 1);
diff --git a/scratch/walk-smoke.tmp.mjs b/scratch/walk-smoke.tmp.mjs
deleted file mode 100644
index 4344f1933..000000000
--- a/scratch/walk-smoke.tmp.mjs
+++ /dev/null
@@ -1,62 +0,0 @@
-import { chromium } from 'playwright';
-import { readFileSync, mkdirSync } from 'fs';
-
-const URL = 'http://localhost:3003/walk';
-const TIMEOUT = 25_000;
-
-mkdirSync('scratch/screenshots', { recursive: true });
-
-const browser = await chromium.launch();
-const context = await browser.newContext({ viewport: { width: 1024, height: 768 } });
-await context.grantPermissions(['camera']);
-
-const page = await context.newPage();
-const pageErrors = [];
-page.on('pageerror', (err) => pageErrors.push(err?.stack || String(err)));
-page.on('console', (msg) => {
- if (msg.type() === 'error') pageErrors.push('[console.error] ' + msg.text());
-});
-
-await page.goto(URL, { waitUntil: 'domcontentloaded', timeout: TIMEOUT });
-await page.waitForFunction(
- () => {
- const el = document.getElementById('walk-status');
- return el && /walk it/i.test(el.textContent || '');
- },
- { timeout: TIMEOUT },
-);
-// Allow one extra second so idle clip settles into a deterministic pose.
-await page.waitForTimeout(800);
-
-const beforeBuf = await page.screenshot({ path: 'scratch/screenshots/walk-before.png', fullPage: false });
-
-await page.evaluate(async () => {
- const wait = (ms) => new Promise((r) => setTimeout(r, ms));
- const fireKey = (type, code) => {
- window.dispatchEvent(new KeyboardEvent(type, { code, bubbles: true }));
- };
- fireKey('keydown', 'KeyW');
- await wait(1200);
- fireKey('keyup', 'KeyW');
- await wait(400);
-});
-
-const afterBuf = await page.screenshot({ path: 'scratch/screenshots/walk-after.png', fullPage: false });
-
-// Quick byte-level diff — if the avatar moved at all, the PNGs will differ.
-// PNGs are deterministic for identical pixel input, so equal length+content
-// across two distinct frames means literally nothing changed on screen.
-const sameBytes = beforeBuf.length === afterBuf.length &&
- beforeBuf.equals(afterBuf);
-
-await browser.close();
-
-const ok = !sameBytes && pageErrors.length === 0;
-console.log(JSON.stringify({
- ok,
- sameBytes,
- beforeBytes: beforeBuf.length,
- afterBytes: afterBuf.length,
- pageErrors,
-}, null, 2));
-process.exit(ok ? 0 : 1);
diff --git a/scripts/direct-pump-launch.mjs b/scripts/direct-pump-launch.mjs
index ca3e143cf..fe29234ea 100644
--- a/scripts/direct-pump-launch.mjs
+++ b/scripts/direct-pump-launch.mjs
@@ -23,8 +23,7 @@ import {
VersionedTransaction,
LAMPORTS_PER_SOL,
} from '@solana/web3.js';
-import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
-import { PumpSdk, getBuyTokenAmountFromSolAmount } from '@pump-fun/pump-sdk';
+import { PumpSdk, OnlinePumpSdk, getBuyTokenAmountFromSolAmount } from '@pump-fun/pump-sdk';
import BN from 'bn.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -86,12 +85,24 @@ async function cmdBalance() {
}
async function cmdLaunch(name, symbol, uri, opts) {
- if (!name || !symbol || !uri) {
+ // name/symbol may be intentionally empty (a "no name / no ticker" coin), so we
+ // only require the metadata URI here.
+ if (name === undefined || symbol === undefined || !uri) {
throw new Error('Usage: launch <name> <symbol> <metadataUrl> [--buy <sol>]');
}
const buySol = opts.buy ? parseFloat(opts.buy) : 0;
if (Number.isNaN(buySol) || buySol < 0) throw new Error('Invalid --buy value');
+ // Tokenized-agent launch with creator-fee buyback. --buyback-bps 10000 = 100%.
+ const buyBackBps = opts['buyback-bps'] !== undefined ? parseInt(opts['buyback-bps'], 10) : 0;
+ if (Number.isNaN(buyBackBps) || buyBackBps < 0 || buyBackBps > 10000) {
+ throw new Error('Invalid --buyback-bps (0..10000)');
+ }
+ const isTokenizedAgent = buyBackBps > 0;
+ if (isTokenizedAgent && buySol <= 0) {
+ throw new Error('A tokenized-agent launch (--buyback-bps) requires a dev buy: pass --buy <sol>');
+ }
+
const kp = loadKeypair();
const conn = new Connection(RPC_URL, 'confirmed');
@@ -111,21 +122,27 @@ async function cmdLaunch(name, symbol, uri, opts) {
console.log('Symbol: ', symbol);
console.log('Metadata: ', uri);
console.log('Buy-in: ', buySol, 'SOL');
+ console.log('Agent: ', isTokenizedAgent ? `tokenized, buyback ${buyBackBps} bps (${buyBackBps / 100}%)` : 'no');
console.log('');
- // Build pump SDK against this RPC.
- const wallet = new Wallet(kp);
- const provider = new AnchorProvider(conn, wallet, { commitment: 'confirmed' });
- const sdk = new PumpSdk(provider);
+ // Offline SDK builds instructions; online SDK reads on-chain global state.
+ const offline = new PumpSdk();
+ const online = new OnlinePumpSdk(conn);
const instructions = [];
if (buySol > 0) {
console.log('→ fetchGlobal...');
- const global = await sdk.fetchGlobal();
+ const global = await online.fetchGlobal();
const solAmount = new BN(Math.floor(buySol * LAMPORTS_PER_SOL));
- const tokenAmount = getBuyTokenAmountFromSolAmount(global, null, solAmount);
+ const tokenAmount = getBuyTokenAmountFromSolAmount({
+ global,
+ feeConfig: null,
+ mintSupply: null,
+ bondingCurve: null,
+ amount: solAmount,
+ });
console.log('→ createAndBuyInstructions...');
- const ixs = await sdk.createAndBuyInstructions({
+ const ixs = await offline.createAndBuyInstructions({
global,
mint: mintKp.publicKey,
name, symbol, uri,
@@ -133,47 +150,64 @@ async function cmdLaunch(name, symbol, uri, opts) {
user: kp.publicKey,
solAmount,
amount: tokenAmount,
+ isTokenizedAgent,
+ buyBackBps,
});
instructions.push(...(Array.isArray(ixs) ? ixs : [ixs]));
} else {
console.log('→ createInstruction...');
- const ix = await sdk.createInstruction({
+ const ix = await offline.createInstruction({
mint: mintKp.publicKey,
name, symbol, uri,
creator: kp.publicKey,
user: kp.publicKey,
});
- instructions.push(ix);
+ instructions.push(...(Array.isArray(ix) ? ix : [ix]));
}
console.log('Instructions built:', instructions.length);
- const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');
- const msg = new TransactionMessage({
- payerKey: kp.publicKey,
- recentBlockhash: blockhash,
- instructions,
- }).compileToV0Message();
- const tx = new VersionedTransaction(msg);
- tx.sign([kp, mintKp]);
-
- console.log('→ simulate...');
- const sim = await conn.simulateTransaction(tx, { sigVerify: false });
- if (sim.value.err) {
- console.error('Simulation failed:', JSON.stringify(sim.value.err));
- console.error('Logs:');
- for (const l of sim.value.logs || []) console.error(' ', l);
- throw new Error('aborting before send (simulation failed)');
+ // Send one v0 transaction, simulate-then-send-then-confirm. Returns the sig.
+ async function sendTx(ixs, signers, { simulate = true } = {}) {
+ const { blockhash, lastValidBlockHeight } = await conn.getLatestBlockhash('confirmed');
+ const msg = new TransactionMessage({
+ payerKey: kp.publicKey,
+ recentBlockhash: blockhash,
+ instructions: ixs,
+ }).compileToV0Message();
+ const tx = new VersionedTransaction(msg);
+ tx.sign(signers);
+ if (simulate) {
+ const sim = await conn.simulateTransaction(tx, { sigVerify: false });
+ if (sim.value.err) {
+ console.error('Simulation failed:', JSON.stringify(sim.value.err));
+ for (const l of sim.value.logs || []) console.error(' ', l);
+ throw new Error('aborting before send (simulation failed)');
+ }
+ console.log(' sim OK, CU:', sim.value.unitsConsumed);
+ }
+ const sig = await conn.sendRawTransaction(tx.serialize(), { skipPreflight: false, maxRetries: 3 });
+ console.log(' sig:', sig);
+ const conf = await conn.confirmTransaction({ signature: sig, blockhash, lastValidBlockHeight }, 'confirmed');
+ if (conf.value.err) throw new Error('Confirmation error: ' + JSON.stringify(conf.value.err));
+ return sig;
}
- console.log('Simulation OK. Compute units used:', sim.value.unitsConsumed);
-
- console.log('→ sendRawTransaction...');
- const sig = await conn.sendRawTransaction(tx.serialize(), { skipPreflight: false, maxRetries: 3 });
- console.log('Signature:', sig);
- console.log('Solscan: https://solscan.io/tx/' + sig);
- console.log('→ confirm...');
- const conf = await conn.confirmTransaction({ signature: sig, blockhash, lastValidBlockHeight }, 'confirmed');
- if (conf.value.err) throw new Error('Confirmation error: ' + JSON.stringify(conf.value.err));
+ // A tokenized-agent launch is 4 instructions — too big for one tx. Split:
+ // tx1 creates the mint + dev buy, tx2 initializes the agent (after the mint
+ // exists on-chain). The agent-init is the last instruction in the array.
+ if (isTokenizedAgent && instructions.length > 3) {
+ const agentIx = instructions.pop();
+ console.log('→ tx1: create + buy...');
+ const sig1 = await sendTx(instructions, [kp, mintKp]);
+ console.log(' Solscan:', 'https://solscan.io/tx/' + sig1);
+ console.log('→ tx2: initialize tokenized agent (buyback ' + buyBackBps / 100 + '%)...');
+ const sig2 = await sendTx([agentIx], [kp], { simulate: false });
+ console.log(' Solscan:', 'https://solscan.io/tx/' + sig2);
+ } else {
+ console.log('→ submit...');
+ const sig = await sendTx(instructions, [kp, mintKp]);
+ console.log(' Solscan:', 'https://solscan.io/tx/' + sig);
+ }
console.log('');
console.log('LAUNCHED.');
diff --git a/scripts/link-direct-launch.mjs b/scripts/link-direct-launch.mjs
new file mode 100644
index 000000000..5767b6b3b
--- /dev/null
+++ b/scripts/link-direct-launch.mjs
@@ -0,0 +1,77 @@
+#!/usr/bin/env node
+// Link an already-launched pump.fun mint (e.g. from direct-pump-launch.mjs) to an
+// agent_identity, so it surfaces as that agent's coin. Mirrors the insert the
+// native /api/agents/{id}/pumpfun/launch endpoint performs into pump_agent_mints.
+//
+// Usage:
+// DATABASE_URL=postgres://... node scripts/link-direct-launch.mjs \
+// --agent <agent_id> --mint <mint> --uri <metadataUrl> \
+// --name <name> --symbol <symbol> --authority <creatorWallet> [--network mainnet]
+//
+// Idempotent on (mint, network). Verifies the agent exists before writing.
+
+import process from 'node:process';
+import { neon } from '@neondatabase/serverless';
+
+const DATABASE_URL = process.env.DATABASE_URL;
+if (!DATABASE_URL) {
+ console.error('DATABASE_URL not set.');
+ process.exit(2);
+}
+
+function parseArgs(argv) {
+ const opts = {};
+ for (let i = 0; i < argv.length; i++) {
+ if (argv[i].startsWith('--')) opts[argv[i].slice(2)] = argv[++i];
+ }
+ return opts;
+}
+const o = parseArgs(process.argv.slice(2));
+const required = ['agent', 'mint', 'uri', 'authority'];
+for (const k of required) {
+ if (!o[k]) {
+ console.error(`Missing --${k}`);
+ process.exit(2);
+ }
+}
+const network = o.network || 'mainnet';
+const name = o.name ?? '';
+const symbol = o.symbol ?? '';
+
+const sql = neon(DATABASE_URL);
+
+const [agent] = await sql`
+ select id, name, user_id from agent_identities
+ where id = ${o.agent} and deleted_at is null limit 1
+`;
+if (!agent) {
+ console.error(`agent_identities.id=${o.agent} not found (or deleted). Nothing written.`);
+ process.exit(3);
+}
+console.log(`agent: ${agent.id} "${agent.name}" (user ${agent.user_id})`);
+
+const existing = await sql`
+ select id, agent_id from pump_agent_mints where mint = ${o.mint} and network = ${network} limit 1
+`;
+if (existing.length) {
+ console.log(`note: mint already in pump_agent_mints (id ${existing[0].id}, agent ${existing[0].agent_id}) — updating.`);
+}
+
+const inserted = await sql`
+ insert into pump_agent_mints
+ (agent_id, user_id, network, mint, name, symbol, metadata_uri, agent_authority)
+ values
+ (${agent.id}, ${agent.user_id}, ${network}, ${o.mint},
+ ${name}, ${symbol}, ${o.uri}, ${o.authority})
+ on conflict (mint, network) do update set
+ updated_at = now(),
+ agent_id = excluded.agent_id,
+ name = excluded.name,
+ symbol = excluded.symbol,
+ metadata_uri = excluded.metadata_uri
+ returning id, agent_id, created_at, updated_at
+`;
+const row = inserted[0];
+console.log(`linked: pump_agent_mints.id=${row.id} agent_id=${row.agent_id}`);
+console.log(` created ${row.created_at} updated ${row.updated_at}`);
+console.log(`\nDone. /agent/${agent.id} (and /agent-next?id=${agent.id}) should now show mint ${o.mint}.`);
diff --git a/scripts/pump-upload-metadata.mjs b/scripts/pump-upload-metadata.mjs
new file mode 100644
index 000000000..2f6fa4e08
--- /dev/null
+++ b/scripts/pump-upload-metadata.mjs
@@ -0,0 +1,82 @@
+#!/usr/bin/env node
+// Pin a token image + metadata descriptor to pump.fun's IPFS endpoint and print
+// the resulting metadataUri. This is the descriptor a create-coin tx points at.
+//
+// Usage:
+// node scripts/pump-upload-metadata.mjs <imagePath> [--name "..."] [--symbol "..."] \
+// [--description "..."] [--twitter url] [--telegram url] [--website url] [--show-name]
+//
+// Name/symbol default to empty strings (a "no name / no ticker" coin).
+
+import fs from 'node:fs';
+import path from 'node:path';
+import process from 'node:process';
+
+function parseArgs(argv) {
+ const positional = [];
+ const opts = {};
+ const flags = new Set(['show-name']);
+ for (let i = 0; i < argv.length; i++) {
+ const a = argv[i];
+ if (a.startsWith('--')) {
+ const key = a.slice(2);
+ if (flags.has(key)) opts[key] = true;
+ else opts[key] = argv[++i];
+ } else {
+ positional.push(a);
+ }
+ }
+ return { positional, opts };
+}
+
+const { positional, opts } = parseArgs(process.argv.slice(2));
+const imagePath = positional[0];
+if (!imagePath) {
+ console.error('Usage: node scripts/pump-upload-metadata.mjs <imagePath> [--name ..] [--symbol ..] [--description ..] [--show-name]');
+ process.exit(1);
+}
+if (!fs.existsSync(imagePath)) {
+ console.error(`Image not found: ${imagePath}`);
+ process.exit(1);
+}
+
+const name = opts.name ?? '';
+const symbol = opts.symbol ?? '';
+const description = opts.description ?? '';
+
+const bytes = fs.readFileSync(imagePath);
+const ext = path.extname(imagePath).toLowerCase();
+const mime = ext === '.jpg' || ext === '.jpeg' ? 'image/jpeg'
+ : ext === '.gif' ? 'image/gif'
+ : ext === '.webp' ? 'image/webp'
+ : 'image/png';
+
+const form = new FormData();
+form.append('file', new Blob([bytes], { type: mime }), path.basename(imagePath));
+form.append('name', name);
+form.append('symbol', symbol);
+form.append('description', description);
+form.append('twitter', opts.twitter ?? '');
+form.append('telegram', opts.telegram ?? '');
+form.append('website', opts.website ?? '');
+form.append('showName', opts['show-name'] ? 'true' : 'false');
+
+console.error('Uploading to pump.fun IPFS…');
+console.error(' image: ', imagePath, `(${bytes.length} bytes, ${mime})`);
+console.error(' name: ', JSON.stringify(name));
+console.error(' symbol: ', JSON.stringify(symbol));
+console.error(' showName:', opts['show-name'] ? 'true' : 'false');
+
+const r = await fetch('https://pump.fun/api/ipfs', { method: 'POST', body: form });
+if (!r.ok) {
+ console.error(`Upload failed: ${r.status} ${await r.text().catch(() => '')}`);
+ process.exit(1);
+}
+const json = await r.json();
+const uri = json.metadataUri || json.metadata_uri || json.uri;
+if (!uri) {
+ console.error('No metadataUri in response:', JSON.stringify(json));
+ process.exit(1);
+}
+console.error(' image uri:', json.metadata?.image || json.image || '(in descriptor)');
+console.log(uri);
diff --git a/src/app-next-overlay.js b/src/app-next-overlay.js
index ac66e757a..ce1867bb6 100644
--- a/src/app-next-overlay.js
+++ b/src/app-next-overlay.js
@@ -58,6 +58,7 @@ function boot() {
wirePrimaryCTA();
wireAnimationSheet();
wireChatDock();
+ wireChatPanelDock();
wireShare();
wireFullscreen();
wireCameraPresets();
@@ -304,6 +305,57 @@ function wireChatDock() {
}
}
+// ── Unified chat — dock the thread panel flush onto the composer ──────────
+//
+// The NichAgent panel (conversation thread) and the chat dock (chips + input)
+// are two separate DOM trees. Left alone they render as two detached glass
+// surfaces with a gap, which reads as "two chats". This pins the thread panel's
+// bottom edge directly onto the dock's top edge and flags `nxt-chat-merged` so
+// the CSS fuses them into a single card whenever the thread is open.
+
+function wireChatPanelDock() {
+ const dock = document.getElementById('nxt-chat-dock');
+ if (!dock) return;
+
+ waitForAgent().then((agent) => {
+ const panel = agent?.panel;
+ if (!panel) return;
+
+ const syncBottom = () => {
+ if (panel.style.display === 'none') return;
+ const dockTop = dock.getBoundingClientRect().top;
+ // Flush: panel bottom edge meets dock top edge (0px gap → one card).
+ panel.style.bottom = `${Math.max(0, Math.round(window.innerHeight - dockTop))}px`;
+ };
+
+ let lastOpen = null;
+ const reflectOpenState = () => {
+ const open = panel.style.display !== 'none';
+ if (open === lastOpen) return; // ignore our own inline `bottom` writes
+ lastOpen = open;
+ document.body.classList.toggle('nxt-chat-merged', open);
+ if (open) requestAnimationFrame(syncBottom);
+ };
+
+ new MutationObserver(reflectOpenState).observe(panel, {
+ attributes: true,
+ attributeFilter: ['style'],
+ });
+
+ // Keep the seam tight as the layout shifts underneath the thread.
+ window.addEventListener('resize', () => requestAnimationFrame(syncBottom));
+ dock.addEventListener('transitionend', () => requestAnimationFrame(syncBottom));
+ const chips = document.getElementById('nxt-chat-chips');
+ if (chips) {
+ new MutationObserver(() => requestAnimationFrame(syncBottom)).observe(chips, {
+ childList: true,
+ });
+ }
+
+ reflectOpenState();
+ });
+}
+
async function triggerMicToggle(micEl) {
const agent = await waitForAgent(8000);
if (!agent) return;
diff --git a/src/editor/embed-editor.js b/src/editor/embed-editor.js
index b9468c09a..60157092a 100644
--- a/src/editor/embed-editor.js
+++ b/src/editor/embed-editor.js
@@ -1,2409 +1,487 @@
-// Embed editor — the "place, scale, preview, copy" UX.
-// Lets users drop an <agent-3d> exactly where they want on their actual site.
+// Embed editor — configure, preview live, and copy a ready-to-paste snippet
+// for embedding a three.ws avatar on any website. Mounts into /embed
+// (pages/embed.html).
//
-// Usage: import and call mountEmbedEditor(rootEl, { src, defaults }).
-
-import '../element.js'; // ensures <agent-3d> is registered
+// Four embed modes, all backed by runtimes that actually exist in this repo:
+// • Static → /walk-embed (controls=none, autoplay=false) — avatar stands.
+// • Idle → /walk-embed (controls=none, autoplay=true) — avatar drifts.
+// • Walking → /walk-embed (controls=joystick|keyboard) — interactive.
+// • Chat → /a/<id>?embed=1 iframe — talk to agent.
+//
+// Design goals:
+// • Live preview that renders the EXACT runtime the snippet ships.
+// • Real clipboard copy, no fake "copied!" states.
+// • Deep-linkable: every control reflects into the URL query so a
+// configured embed can be shared and re-opened (e.g. /embed?avatar=x).
-const POSITIONS = [
- { id: 'top-left', label: '↖' },
- { id: 'top-center', label: '↑' },
- { id: 'top-right', label: '↗' },
- { id: 'bottom-left', label: '↙' },
- { id: 'bottom-center', label: '↓' },
- { id: 'bottom-right', label: '↘' },
-];
+const ORIGIN = 'https://three.ws';
const MODES = [
- { id: 'floating', label: 'Floating bubble', hint: 'Fixed corner, follows scroll' },
- { id: 'inline', label: 'Inline', hint: 'Flows with the page content' },
- { id: 'section', label: 'Section', hint: 'Fills a container' },
- { id: 'fullscreen', label: 'Fullscreen', hint: 'Takes over the viewport' },
-];
-
-const DEVICES = [
- { id: 'desktop', label: 'Desktop', w: 1440, h: 900 },
- { id: 'tablet', label: 'Tablet', w: 768, h: 1024 },
- { id: 'mobile', label: 'Mobile', w: 390, h: 844 },
-];
-
-const RESPONSIVE_PRESETS = [
- { id: 'fixed', label: 'Fixed', hint: 'Exact px — no scaling' },
- { id: 'mobile-first', label: 'Mobile-first', hint: 'Grows from mobile min' },
- { id: 'desktop-first', label: 'Desktop-first', hint: 'Shrinks from preferred size' },
-];
-
-// Shown in the preview when the user hasn't entered a `src` yet — so the stage
-// always renders an actual avatar instead of an empty box. Not emitted in the
-// generated snippet.
-const DEFAULT_PREVIEW_SRC = '/avatars/default.glb';
-
-// Pinned <agent-3d> library version emitted in the snippet. Matches package.json
-// and the production CDN path documented in /docs/web-component.md.
-const AGENT_3D_VERSION = '1.5.1';
-const AGENT_3D_HOST = 'https://three.ws';
-
-const BACKGROUNDS = [
- { id: '', label: 'Default' },
- { id: 'transparent', label: 'Transparent' },
- { id: 'dark', label: 'Dark' },
- { id: 'light', label: 'Light' },
+ { id: 'static', label: 'Static', hint: 'Avatar stands in an idle pose. No controls.' },
+ { id: 'idle', label: 'Idle', hint: 'Avatar drifts and breathes on its own.' },
+ { id: 'walking', label: 'Walking', hint: 'Visitors move the avatar with a joystick or keys.' },
+ { id: 'chat', label: 'Chat', hint: 'Embedded agent page — visitors chat with the agent.' },
];
-// Curated demo avatars surfaced at the top of the picker. URLs match
-// api/_lib/demo-avatars.js fixtures (HEAD-checked CC-BY / MIT GLBs). The
-// picker prepends these before /api/avatars/public results so the gallery
-// always opens to something demo-worthy instead of unnamed user uploads.
-const DEMO_AVATARS = [
- { id: 'demo-cz', name: 'CZ', model_url: '/avatars/cz.glb' },
- { id: 'demo-default', name: 'Default', model_url: '/avatars/default.glb' },
- { id: 'demo-robot', name: 'Robot Expressive', model_url: '/animations/robotexpressive.glb' },
- { id: 'demo-soldier', name: 'Soldier (rigged)', model_url: '/animations/soldier.glb' },
- { id: 'demo-michelle', name: 'Michelle', model_url: 'https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Michelle.glb' },
- { id: 'demo-xbot', name: 'Xbot', model_url: 'https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/Xbot.glb' },
- { id: 'demo-kira', name: 'Kira', model_url: 'https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/models/gltf/kira.glb' },
- { id: 'demo-cesium', name: 'Cesium Man', model_url: 'https://cdn.jsdelivr.net/gh/KhronosGroup/glTF-Sample-Assets/Models/CesiumMan/glTF-Binary/CesiumMan.glb' },
+const CONTROL_OPTIONS = ['joystick', 'keyboard', 'none'];
+const ENV_OPTIONS = [
+ { id: 'studio', label: 'Studio (transparent)' },
+ { id: 'void', label: 'Void' },
+ { id: 'beach', label: 'Beach' },
+ { id: 'sunset', label: 'Sunset' },
+ { id: 'night', label: 'Night' },
+ { id: 'grid', label: 'Grid' },
];
+const SIZE_PRESETS = {
+ S: { w: 240, h: 360 },
+ M: { w: 320, h: 480 },
+ L: { w: 420, h: 640 },
+ custom: null,
+};
+
+const DEFAULTS = {
+ mode: 'walking',
+ avatar: '',
+ controls: 'joystick',
+ bg: 'transparent',
+ env: 'studio',
+ size: 'M',
+ width: 320,
+ height: 480,
+ autoplay: true,
+ snippetVariant: 'iframe', // 'iframe' | 'script'
+};
+
+function el(tag, props = {}, children = []) {
+ const node = document.createElement(tag);
+ const { style, ...rest } = props;
+ Object.assign(node, rest);
+ for (const [k, v] of Object.entries(style || {})) node.style[k] = v;
+ for (const c of [].concat(children)) {
+ if (c == null) continue;
+ node.appendChild(typeof c === 'string' ? document.createTextNode(c) : c);
+ }
+ return node;
+}
-const STYLE = `
- .editor-root {
- position: fixed;
- inset: 0;
- display: grid;
- grid-template-columns: 1fr 360px;
- grid-template-rows: minmax(0, 1fr);
- background: #0b0d10;
- color: #f4f4f5;
- font: 14px/1.4 system-ui, -apple-system, sans-serif;
- z-index: 1;
- }
- .stage-wrap {
- position: relative;
- overflow: hidden;
- background: #1a1d21;
- }
- .stage-wrap iframe {
- width: 100%;
- height: 100%;
- border: 0;
- background: white;
- }
- /* Dark hero-right mock landing — designed as the video-demo backdrop.
- Pure black + white type, Linear/Vercel vibe, single radial glow behind
- the avatar slot. The right half is reserved for the <agent-3d> wrap
- (placed via the avatar-slot guides). */
- .stage-wrap .placeholder-site {
- position: absolute;
- inset: 0;
- background: #000;
- color: #f5f5f5;
- overflow: auto;
- font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
- isolation: isolate;
- }
- /* Soft purple→cyan glow + sparkle layer behind where the avatar will sit.
- Opt-in via the Backdrop glow toggle in the panel — default is no
- background behind the avatar. Scales with the placeholder so it works
- in tablet/mobile device frames too. */
- .placeholder-site.has-glow::before {
- content: '';
- position: absolute;
- top: 24%;
- right: 8%;
- width: 620px;
- height: 620px;
- border-radius: 50%;
- background: radial-gradient(closest-side, rgba(139,92,246,0.35), rgba(34,211,238,0.08) 55%, transparent 75%);
- filter: blur(20px);
- pointer-events: none;
- z-index: 0;
- }
- .placeholder-site.has-glow::after {
- content: '';
- position: absolute;
- inset: 0;
- background:
- radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.18), transparent 60%),
- radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.10), transparent 60%),
- radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.10), transparent 60%);
- pointer-events: none;
- z-index: 0;
- }
- .placeholder-site .nav {
- position: relative;
- z-index: 2;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 22px 48px;
- background: rgba(0,0,0,0.5);
- backdrop-filter: blur(10px);
- border-bottom: 1px solid rgba(255,255,255,0.06);
- }
- .placeholder-site .brand {
- display: flex;
- align-items: center;
- gap: 10px;
- font: 600 16px/1 'Inter', system-ui;
- color: #f5f5f5;
- letter-spacing: -0.01em;
- }
- .placeholder-site .brand .logo {
- width: 26px;
- height: 26px;
- border-radius: 7px;
- background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
- box-shadow: 0 0 24px rgba(167,139,250,0.5);
- }
- .placeholder-site .nav-links {
- display: flex;
- gap: 32px;
- font: 500 13.5px 'Inter', system-ui;
- color: rgba(245,245,245,0.6);
- }
- .placeholder-site .nav-links span { cursor: default; transition: color 0.15s; }
- .placeholder-site .nav-links span:hover { color: #f5f5f5; }
- .placeholder-site .nav-cta {
- background: #f5f5f5;
- color: #000;
- padding: 8px 16px;
- border-radius: 8px;
- font: 600 13px 'Inter', system-ui;
- }
-
- /* Two-column hero: copy on the left, avatar slot on the right. The slot
- itself is purely visual (just dictates where the agent-wrap should
- land); the wrap is positioned absolutely by the editor's mode/position
- logic, not by this grid. */
- .placeholder-site .hero-grid {
- position: relative;
- z-index: 1;
- display: grid;
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
- align-items: center;
- gap: 48px;
- max-width: 1240px;
- margin: 0 auto;
- padding: 96px 56px 80px;
- min-height: calc(100vh - 80px);
- }
- .placeholder-site .hero-copy { max-width: 540px; }
- .placeholder-site .pill {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 6px 12px;
- border-radius: 999px;
- background: rgba(255,255,255,0.06);
- border: 1px solid rgba(255,255,255,0.10);
- color: rgba(245,245,245,0.85);
- font: 500 12px 'Inter', system-ui;
- letter-spacing: 0.01em;
- margin-bottom: 28px;
- }
- .placeholder-site .pill .dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background: #ffffff;
- box-shadow: 0 0 10px #ffffff;
- }
- .placeholder-site h1 {
- font: 700 58px/1.05 'Inter', system-ui;
- letter-spacing: -0.035em;
- margin: 0 0 22px;
- color: #fafafa;
- }
- .placeholder-site h1 .muted {
- color: rgba(245,245,245,0.45);
- }
- .placeholder-site p.lede {
- font-size: 17px;
- color: rgba(245,245,245,0.62);
- max-width: 460px;
- margin: 0 0 36px;
- line-height: 1.6;
- }
- .placeholder-site .cta-row {
- display: flex;
- gap: 10px;
- align-items: center;
- }
- .placeholder-site .btn-primary {
- background: #f5f5f5;
- color: #000;
- padding: 13px 22px;
- border-radius: 10px;
- font: 600 14px 'Inter', system-ui;
- letter-spacing: -0.005em;
- transition: transform 0.1s;
- }
- .placeholder-site .btn-primary:hover { transform: translateY(-1px); }
- .placeholder-site .btn-ghost {
- color: rgba(245,245,245,0.85);
- padding: 13px 22px;
- border-radius: 10px;
- font: 600 14px 'Inter', system-ui;
- border: 1px solid rgba(255,255,255,0.14);
- background: transparent;
- display: inline-flex;
- align-items: center;
- gap: 6px;
- }
- .placeholder-site .btn-ghost:hover { background: rgba(255,255,255,0.04); }
-
- /* Empty right column — the avatar wrap floats over this area via the
- editor's positioning logic. Faint corner guides hint where it'll land. */
- .placeholder-site .hero-slot {
- position: relative;
- height: 620px;
- }
-
- .placeholder-site .stats {
- position: relative;
- z-index: 1;
- max-width: 1240px;
- margin: 0 auto;
- padding: 0 56px 80px;
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- gap: 32px;
- border-top: 1px solid rgba(255,255,255,0.06);
- padding-top: 56px;
- }
- .placeholder-site .stat .num {
- font: 700 32px/1 'Inter', system-ui;
- letter-spacing: -0.02em;
- color: #fafafa;
- margin-bottom: 6px;
- }
- .placeholder-site .stat .label {
- font: 500 12.5px 'Inter', system-ui;
- color: rgba(245,245,245,0.55);
- text-transform: uppercase;
- letter-spacing: 0.08em;
- }
-
- .agent-wrap {
- position: absolute;
- cursor: grab;
- user-select: none;
- touch-action: none;
- overflow: hidden;
- border-radius: 12px;
- box-shadow: 0 8px 32px rgba(0,0,0,0.35);
- background: transparent;
- }
- .agent-wrap.dragging { cursor: grabbing; }
- .agent-wrap agent-3d {
- position: absolute;
- inset: 0;
- width: 100% !important;
- height: 100% !important;
- display: block;
- }
- .agent-wrap iframe.widget-frame {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
- border: 0;
- display: block;
- background: transparent;
- }
- .widget-badge {
- position: absolute;
- top: -28px;
- right: 0;
- background: #1e293b;
- color: #a7f3d0;
- font: 11px/1 ui-monospace, Menlo, monospace;
- padding: 4px 8px;
- border-radius: 4px;
- border: 1px solid #334155;
- }
- .size-readout {
- position: absolute;
- top: -28px;
- left: 0;
- background: #111827;
- color: #f9fafb;
- font: 11px/1 monospace;
- padding: 4px 6px;
- border-radius: 4px;
- }
-
- .anim-dock {
- position: absolute;
- left: 50%;
- bottom: 20px;
- transform: translateX(-50%);
- display: flex;
- gap: 6px;
- padding: 7px;
- background: rgba(10, 12, 16, 0.78);
- border: 1px solid rgba(255,255,255,0.08);
- border-radius: 999px;
- backdrop-filter: blur(20px);
- -webkit-backdrop-filter: blur(20px);
- box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.02) inset;
- z-index: 5;
- max-width: calc(100% - 32px);
- }
- .anim-dock[hidden] { display: none; }
- .anim-chip {
- flex: 0 0 auto;
- background: rgba(255,255,255,0.04);
- color: rgba(245,245,245,0.85);
- border: 1px solid transparent;
- border-radius: 999px;
- padding: 8px 14px;
- font: 500 13px 'Inter', system-ui;
- letter-spacing: -0.005em;
- cursor: pointer;
- white-space: nowrap;
- display: inline-flex;
- align-items: center;
- gap: 6px;
- transition: background 0.15s, color 0.15s, transform 0.1s;
- }
- .anim-chip:hover {
- background: rgba(255,255,255,0.09);
- color: #fff;
- transform: translateY(-1px);
- }
- .anim-chip[aria-pressed="true"] {
- background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
- color: #0a0c10;
- font-weight: 600;
- box-shadow: 0 0 24px rgba(139,92,246,0.45);
- }
- .anim-chip[aria-pressed="true"] .icon { transform: scale(1.15); }
- .anim-chip[aria-pressed="true"]::after {
- content: '';
- width: 7px;
- height: 7px;
- border-radius: 50%;
- background: #0a0c10;
- animation: anim-chip-pulse 1.4s ease-in-out infinite;
- margin-left: 2px;
- }
- @keyframes anim-chip-pulse {
- 0%, 100% { opacity: 1; transform: scale(1); }
- 50% { opacity: 0.35; transform: scale(0.7); }
- }
- .anim-chip .icon { font-size: 15px; line-height: 1; transition: transform 0.2s; }
- .anim-chip .kbd {
- font: 500 10px ui-monospace, Menlo, monospace;
- color: rgba(245,245,245,0.4);
- background: rgba(255,255,255,0.06);
- padding: 1px 5px;
- border-radius: 4px;
- margin-left: 2px;
- }
- .anim-chip[aria-pressed="true"] .kbd { display: none; }
- .anim-chip.more {
- background: transparent;
- color: rgba(245,245,245,0.55);
- border-color: rgba(255,255,255,0.10);
- }
- .anim-chip.more:hover { color: #fff; background: rgba(255,255,255,0.05); }
-
- /* Animation library modal — full categorized list. */
- .anim-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
- .anim-modal[hidden] { display: none; }
- .anim-modal-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,0.7); backdrop-filter: blur(4px); }
- .anim-modal-card {
- position: relative;
- width: min(720px, 92vw);
- max-height: 80vh;
- background: #0a0c10;
- border: 1px solid rgba(255,255,255,0.08);
- border-radius: 16px;
- box-shadow: 0 24px 60px rgba(0,0,0,0.6);
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
- .anim-modal-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 18px 22px;
- border-bottom: 1px solid rgba(255,255,255,0.06);
- }
- .anim-modal-header h3 { font: 700 17px 'Inter', system-ui; margin: 0; color: #fafafa; }
- .anim-modal-close {
- background: transparent;
- border: 0;
- color: rgba(245,245,245,0.55);
- font-size: 22px;
- line-height: 1;
- cursor: pointer;
- padding: 4px 8px;
- border-radius: 6px;
- }
- .anim-modal-close:hover { background: rgba(255,255,255,0.06); color: #fff; }
- .anim-modal-body { padding: 20px 22px 24px; overflow-y: auto; }
- .anim-cat-title {
- font: 600 11px 'Inter', system-ui;
- color: rgba(245,245,245,0.5);
- text-transform: uppercase;
- letter-spacing: 0.08em;
- margin: 12px 0 10px;
- }
- .anim-cat-title:first-child { margin-top: 0; }
- .anim-cat-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
- .anim-cat-grid .anim-chip { padding: 6px 12px; font-size: 12.5px; }
-
- .snapline {
- position: absolute;
- background: #3b82f6;
- opacity: 0.6;
- pointer-events: none;
- }
- .snapline.v { width: 1px; top: 0; bottom: 0; }
- .snapline.h { height: 1px; left: 0; right: 0; }
-
- .panel {
- background: #0f1216;
- border-left: 1px solid #1f2937;
- display: flex;
- flex-direction: column;
- min-height: 0;
- overflow: hidden;
- }
- .panel-header {
- padding: 16px 20px;
- border-bottom: 1px solid #1f2937;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .panel-header h2 { font: 600 16px system-ui; }
- .panel-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
- .section-title { font: 600 11px system-ui; letter-spacing: 0.08em; text-transform: uppercase; color: #9ca3af; margin: 16px 0 8px; }
-
- .mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
- .mode-card {
- padding: 10px 12px;
- border-radius: 10px;
- background: #111827;
- border: 1px solid #1f2937;
- cursor: pointer;
- transition: border-color 0.15s;
- }
- .mode-card:hover { border-color: #3b82f6; }
- .mode-card[aria-pressed="true"] { border-color: #3b82f6; background: #1e293b; }
- .mode-card .ml { font-weight: 600; margin-bottom: 2px; }
- .mode-card .mh { font-size: 12px; color: #9ca3af; }
-
- .pos-grid {
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- gap: 6px;
- }
- .pos-btn {
- aspect-ratio: 1.8;
- background: #111827;
- border: 1px solid #1f2937;
- color: #9ca3af;
- border-radius: 8px;
- font-size: 18px;
- cursor: pointer;
- }
- .pos-btn[aria-pressed="true"] { background: #3b82f6; color: white; border-color: #3b82f6; }
-
- /* Avatar trigger button in the panel — opens the modal. Replaces the
- inline grid so the panel stays light and no GLBs load on page boot. */
- .avatar-trigger {
- display: flex;
- align-items: center;
- gap: 10px;
- width: 100%;
- padding: 8px 10px;
- margin: 4px 0 12px;
- background: #111827;
- border: 1px solid #1f2937;
- border-radius: 10px;
- color: #f4f4f5;
- cursor: pointer;
- text-align: left;
- font: 500 13px system-ui;
- transition: border-color 0.15s, background 0.15s;
- }
- .avatar-trigger:hover { border-color: #3b82f6; background: #1e293b; }
- .avatar-trigger-thumb {
- flex: 0 0 36px;
- width: 36px;
- height: 36px;
- border-radius: 8px;
- background: linear-gradient(135deg, #1e3a8a, #581c87);
- background-size: cover;
- background-position: center;
- border: 1px solid #334155;
- }
- .avatar-trigger-text { flex: 1; min-width: 0; line-height: 1.25; }
- .avatar-trigger-name { display: block; font-weight: 600; }
- .avatar-trigger-hint { display: block; font-size: 11px; color: #9ca3af; }
- .avatar-trigger-chev { color: #6b7280; font-size: 18px; line-height: 1; }
-
- /* Modal — backdrop + centered card. Lazy-fetches the list when opened
- (not on init) and uses <model-viewer loading="lazy"> per card so only
- visible thumbnails actually boot a WebGL context. */
- .avatar-modal {
- position: fixed;
- inset: 0;
- z-index: 1000;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .avatar-modal[hidden] { display: none; }
- .avatar-modal-backdrop {
- position: absolute;
- inset: 0;
- background: rgba(2, 6, 23, 0.7);
- backdrop-filter: blur(4px);
- }
- .avatar-modal-card {
- position: relative;
- width: min(960px, 92vw);
- max-height: 86vh;
- background: #0f1216;
- border: 1px solid #1f2937;
- border-radius: 14px;
- box-shadow: 0 24px 60px rgba(0,0,0,0.55);
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
- .avatar-modal-header {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- padding: 18px 22px;
- border-bottom: 1px solid #1f2937;
- }
- .avatar-modal-header h3 { font: 700 17px/1.2 system-ui; margin: 0 0 4px; color: #f4f4f5; }
- .avatar-modal-sub { font: 13px system-ui; color: #9ca3af; margin: 0; }
- .avatar-modal-close {
- background: transparent;
- border: 0;
- color: #9ca3af;
- font-size: 22px;
- line-height: 1;
- cursor: pointer;
- padding: 4px 8px;
- border-radius: 6px;
- }
- .avatar-modal-close:hover { background: #1f2937; color: #f4f4f5; }
- .avatar-modal-body { padding: 18px 22px; overflow-y: auto; }
-
- .avatar-picker-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
- gap: 12px;
- }
- .avatar-card {
- position: relative;
- aspect-ratio: 1;
- background: linear-gradient(135deg, #1e293b, #0f172a);
- background-size: cover;
- background-position: center;
- border: 1px solid #1f2937;
- border-radius: 10px;
- cursor: pointer;
- overflow: hidden;
- transition: border-color 0.15s, transform 0.1s;
- }
- .avatar-card model-viewer {
- position: absolute;
- inset: 0;
- width: 100%;
- height: 100%;
- --poster-color: transparent;
- background: transparent;
- }
- .avatar-card:hover { border-color: #3b82f6; transform: translateY(-1px); }
- .avatar-card[aria-pressed="true"] { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.3); }
- .avatar-card.pinned {
- background: linear-gradient(135deg, #1e3a8a 0%, #581c87 100%);
- }
- .avatar-card .tag {
- position: absolute;
- top: 4px;
- right: 4px;
- padding: 2px 6px;
- font: 600 9px system-ui;
- color: #c7d2fe;
- background: rgba(15,23,42,0.85);
- border: 1px solid rgba(199,210,254,0.3);
- border-radius: 4px;
- letter-spacing: 0.05em;
- text-transform: uppercase;
- }
- .avatar-card .name {
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- padding: 4px 6px;
- font: 500 10px/1.2 system-ui;
- color: #f4f4f5;
- background: linear-gradient(transparent, rgba(0,0,0,0.85));
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .avatar-card.skeleton { background: #111827; animation: skeleton-pulse 1.2s ease-in-out infinite; }
- @keyframes skeleton-pulse { 50% { opacity: 0.4; } }
- .avatar-picker-more {
- width: 100%;
- margin-top: 6px;
- background: transparent;
- border: 1px solid #1f2937;
- color: #9ca3af;
- border-radius: 6px;
- padding: 6px 8px;
- font: 500 12px system-ui;
- cursor: pointer;
- }
- .avatar-picker-more:hover { color: #f4f4f5; border-color: #334155; }
- .avatar-picker-empty {
- text-align: center;
- color: #6b7280;
- font: 12px system-ui;
- padding: 12px;
- }
-
- .field-row { display: grid; grid-template-columns: 80px 1fr; gap: 8px; align-items: center; margin: 6px 0; }
- .field-row label { color: #9ca3af; font-size: 12px; }
- .field-row input, .field-row select {
- background: #111827;
- color: #f4f4f5;
- border: 1px solid #1f2937;
- border-radius: 6px;
- padding: 6px 8px;
- font: 13px system-ui;
- width: 100%;
- box-sizing: border-box;
- }
-
- .snippet-box {
- background: #0a0d12;
- border: 1px solid #1f2937;
- border-radius: 10px;
- padding: 12px;
- font: 12px/1.5 ui-monospace, Menlo, monospace;
- white-space: pre-wrap;
- word-break: break-all;
- color: #a7f3d0;
- margin-top: 12px;
- max-height: 200px;
- overflow-y: auto;
- transition: max-height 0.2s ease;
- }
- .snippet-box.collapsed {
- max-height: 56px;
- overflow: hidden;
- position: relative;
- }
- .snippet-box.collapsed::after {
- content: '';
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- height: 24px;
- background: linear-gradient(transparent, #0a0d12);
- pointer-events: none;
- }
- .snippet-collapse {
- background: transparent;
- border: 0;
- color: #6b7280;
- font: 500 11px system-ui;
- cursor: pointer;
- padding: 6px 0 0;
- text-align: left;
- }
- .snippet-collapse:hover { color: #e5e7eb; }
- .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
- .btn {
- flex: 1 1 auto;
- background: #3b82f6;
- color: white;
- border: 0;
- border-radius: 8px;
- padding: 10px 12px;
- font: 600 14px system-ui;
- cursor: pointer;
- min-width: 0;
- }
- .btn.secondary { background: transparent; border: 1px solid #1f2937; color: #e5e7eb; }
- .btn:hover { filter: brightness(1.1); }
- .btn[data-copied="true"] { background: #22c55e; }
-
- .toast {
- position: fixed;
- bottom: 24px;
- left: 50%;
- transform: translate(-50%, 24px);
- background: #0f172a;
- color: #f4f4f5;
- padding: 10px 18px;
- border-radius: 999px;
- font: 600 13px system-ui;
- box-shadow: 0 12px 32px rgba(0,0,0,0.45);
- border: 1px solid #1f2937;
- opacity: 0;
- pointer-events: none;
- transition: opacity 0.2s, transform 0.2s;
- z-index: 100;
- }
- .toast.visible {
- opacity: 1;
- transform: translate(-50%, 0);
- }
- .toast[data-kind="warn"] {
- background: #78350f;
- border-color: #b45309;
- color: #fef3c7;
- }
-
- .preview-url-row {
- display: flex;
- gap: 6px;
- padding: 10px 16px;
- background: #0f1216;
- border-bottom: 1px solid #1f2937;
- }
- .preview-url-row input {
- flex: 1;
- background: #111827;
- border: 1px solid #1f2937;
- color: #e5e7eb;
- padding: 6px 10px;
- border-radius: 6px;
- }
- .preview-url-row button { background: #3b82f6; color: white; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
-
- .stage-col { display: flex; flex-direction: column; overflow: hidden; }
- .stage-wrap { flex: 1; position: relative; overflow: hidden; background: #1a1d21; }
-
- .device-bar {
- display: flex;
- gap: 4px;
- padding: 6px 16px;
- background: #0b0d10;
- border-bottom: 1px solid #1f2937;
- align-items: center;
- }
- .device-bar span { font: 11px system-ui; color: #6b7280; margin-right: 4px; }
- .device-btn {
- padding: 3px 10px;
- border-radius: 6px;
- border: 1px solid #1f2937;
- background: #111827;
- color: #9ca3af;
- cursor: pointer;
- font: 12px system-ui;
- }
- .device-btn[aria-pressed="true"] { background: #3b82f6; color: white; border-color: #3b82f6; }
-
- /* Preview mode — hide chrome, let the wrap render where it would on a real site */
- .editor-root[data-preview="true"] { grid-template-columns: 1fr 0; }
- .editor-root[data-preview="true"] .panel { display: none; }
- .editor-root[data-preview="true"] .preview-url-row,
- .editor-root[data-preview="true"] .device-bar { display: none; }
- .editor-root[data-preview="true"] .agent-wrap { cursor: default; }
- .editor-root[data-preview="true"] .agent-wrap .size-readout,
- .editor-root[data-preview="true"] .agent-wrap .widget-badge { display: none; }
- .exit-preview {
- position: fixed;
- top: 16px;
- left: 16px;
- z-index: 10;
- background: #111827;
- color: #f4f4f5;
- border: 1px solid #1f2937;
- border-radius: 999px;
- padding: 8px 14px;
- font: 600 13px system-ui;
- cursor: pointer;
- box-shadow: 0 4px 16px rgba(0,0,0,0.4);
- display: none;
- }
- .editor-root[data-preview="true"] .exit-preview { display: inline-flex; align-items: center; gap: 6px; }
- .exit-preview:hover { background: #1e293b; }
- .preview-toggle {
- background: #1e293b;
- color: #a7f3d0;
- border: 1px solid #334155;
- border-radius: 999px;
- padding: 4px 12px;
- font: 600 12px system-ui;
- cursor: pointer;
- margin-right: 8px;
- }
- .preview-toggle:hover { background: #334155; }
- .lock-toggle {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- background: #1e293b;
- color: #cbd5e1;
- border: 1px solid #334155;
- border-radius: 999px;
- padding: 4px 10px 4px 8px;
- font: 600 12px system-ui;
- cursor: pointer;
- }
- .lock-toggle:hover { background: #334155; }
- .lock-toggle[aria-pressed="true"] {
- background: #b45309;
- color: #fef3c7;
- border-color: #d97706;
- }
- .lock-toggle .lock-icon { font-size: 13px; line-height: 1; }
-
- /* Locked mode — disables drag/resize on the wrap and signals the state. */
- .editor-root[data-locked="true"] .agent-wrap { cursor: not-allowed; }
- .editor-root[data-locked="true"] .agent-wrap .size-readout {
- background: #b45309;
- color: #fef3c7;
- }
- .editor-root[data-locked="true"] .agent-wrap .size-readout::before {
- content: '🔒 ';
- }
-
- /* Device viewport — wraps placeholder/iframe/agent-wrap so they scale
- together when simulating tablet/mobile. In desktop mode fills the stage. */
- .device-viewport {
- position: absolute;
- inset: 0;
- transform-origin: top left;
- transition: transform 0.2s, width 0.2s, height 0.2s;
- }
- .device-viewport[data-device="tablet"],
- .device-viewport[data-device="mobile"] {
- inset: auto;
- background: white;
- box-shadow: 0 0 0 2px #374151, 0 12px 40px rgba(0,0,0,0.5);
- border-radius: 12px;
- overflow: hidden;
- }
- .device-viewport .placeholder-site,
- .device-viewport > iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
-`;
-
-export function mountEmbedEditor(root, options = {}) {
- const defaults = {
- widgetId: options.widgetId || '',
- src: options.src || '',
- mode: options.mode || 'floating',
- // Hero-right placement by default — sized for the video demo's
- // in-editor mock landing (~40% of a 1440px viewport). Users can drag
- // or resize from here; "Reset" returns to these dimensions.
- position: options.position || 'top-right',
- offset: options.offset || '120px 80px',
- width: options.width || '440px',
- height: options.height || '620px',
- device: 'desktop',
- responsivePreset: 'desktop-first',
- voice: true,
- cameraControls: false,
- ar: false,
- // "Just the 3D avatar" is the default: kiosk on (chat hidden), background
- // transparent. Users opt into the chat UI / coloured background via the
- // Options panel.
- showChat: false,
- background: 'transparent',
- // Opt-in purple→cyan glow on the preview backdrop. Off by default so
- // the avatar reads against the plain hero — toggle from the Backdrop
- // glow select in the Options panel. Preview-only, not exported.
- glow: false,
- // New customization options
- defaultClip: '',
- defaultClipLoop: true,
- accentColor: '#3b82f6',
- namePlate: 'on',
- agentId: '',
- borderRadius: '16px',
- ...options,
- };
-
- const state = { ...defaults, widget: null };
- const host = document.createElement('div');
- const shadow = host.attachShadow({ mode: 'open' });
- root.appendChild(host);
-
- shadow.innerHTML = `
- <style>${STYLE}</style>
- <div class="editor-root">
- <div class="stage-col">
- <div class="preview-url-row">
- <input type="text" placeholder="Paste your site URL to preview in-place (optional)" id="url-input">
- <button id="url-load">Load site</button>
- <button id="url-clear">Reset</button>
- </div>
- <div class="device-bar" id="device-bar">
- <span>Preview:</span>
- </div>
- <div class="stage-wrap" id="stage">
- <div class="device-viewport" id="device-viewport">
- <div class="placeholder-site" id="placeholder">
- <nav class="nav">
- <div class="brand"><div class="logo"></div>three.ws</div>
- <div class="nav-links"><span>Product</span><span>Studio</span><span>Docs</span><span>Customers</span></div>
- <div class="nav-cta">Start</div>
- </nav>
- <div class="hero-grid">
- <div class="hero-copy">
- <div class="pill"><span class="dot"></span> Live · Now in beta</div>
- <h1>Your agent. <br><span class="muted">On any page.</span></h1>
- <p class="lede">Drop a 3D agent into any site in 30 seconds. Voice, text, payments, identity — yours, wherever your visitors are.</p>
- <div class="cta-row">
- <div class="btn-primary">Get started →</div>
- <div class="btn-ghost">Watch demo</div>
- </div>
- </div>
- <div class="hero-slot"></div>
- </div>
- <div class="stats">
- <div class="stat"><div class="num">30s</div><div class="label">Time to embed</div></div>
- <div class="stat"><div class="num">100%</div><div class="label">Yours, onchain</div></div>
- <div class="stat"><div class="num">12+</div><div class="label">Animations</div></div>
- <div class="stat"><div class="num">x402</div><div class="label">Native payments</div></div>
- </div>
- </div>
- <iframe id="preview-frame" hidden></iframe>
- <div class="agent-wrap" id="agent-wrap">
- <div class="size-readout" id="size-readout"></div>
- <div class="widget-badge" id="widget-badge" hidden></div>
- <iframe class="widget-frame" id="widget-frame" hidden
- allow="autoplay; clipboard-write; microphone; camera; xr-spatial-tracking"></iframe>
- <agent-3d eager kiosk name-plate="off" id="preview-agent"></agent-3d>
- </div>
- </div>
- <div class="anim-dock" id="anim-dock" hidden></div>
- </div>
- </div>
- <button class="exit-preview" id="exit-preview" type="button">← Back to editor</button>
- <aside class="panel">
- <div class="panel-header">
- <h2>Embed editor</h2>
- <div style="display:flex;align-items:center;gap:8px">
- <button class="lock-toggle" id="lock-toggle" type="button" title="Lock the box and freeze avatar motion (L)" aria-pressed="false">
- <span class="lock-icon" aria-hidden="true">🔓</span>
- <span class="lock-label">Lock</span>
- </button>
- <button class="preview-toggle" id="preview-toggle" type="button">Preview</button>
- <span style="font-size:11px;color:#6b7280">beta</span>
- </div>
- </div>
- <div class="panel-body">
- <div class="section-title">Source</div>
- <div class="field-row">
- <label>src</label>
- <input id="src-input" placeholder="agent://base/42 or ipfs://...">
- </div>
- <button class="avatar-trigger" id="avatar-trigger" type="button">
- <span class="avatar-trigger-thumb" id="avatar-trigger-thumb" aria-hidden="true"></span>
- <span class="avatar-trigger-text">
- <span class="avatar-trigger-name" id="avatar-trigger-name">Browse avatars</span>
- <span class="avatar-trigger-hint">Click to choose a different model</span>
- </span>
- <span class="avatar-trigger-chev" aria-hidden="true">›</span>
- </button>
-
- <div class="section-title">Mode</div>
- <div class="mode-grid" id="mode-grid"></div>
-
- <div class="section-title" id="pos-title">Position</div>
- <div class="pos-grid" id="pos-grid"></div>
-
- <div class="section-title">Size</div>
- <div class="field-row">
- <label>Width</label>
- <input id="w-input" value="${state.width}">
- </div>
- <div class="field-row">
- <label>Height</label>
- <input id="h-input" value="${state.height}">
- </div>
-
- <div class="section-title">Responsive</div>
- <div class="field-row">
- <label>Preset</label>
- <select id="responsive-select">
- <option value="fixed">Fixed (exact px)</option>
- <option value="mobile-first">Mobile-first (clamp, grows)</option>
- <option value="desktop-first">Desktop-first (clamp, shrinks)</option>
- </select>
- </div>
-
- <div class="section-title">Options</div>
- <div class="field-row">
- <label>Chat UI</label>
- <select id="chat-select">
- <option value="off">Hidden (just avatar)</option>
- <option value="on">Show chat panel</option>
- </select>
- </div>
- <div class="field-row">
- <label>Voice</label>
- <select id="voice-select">
- <option value="">on (default)</option>
- <option value="off">off</option>
- </select>
- </div>
- <div class="field-row">
- <label>Camera</label>
- <select id="camera-select">
- <option value="off">controls off</option>
- <option value="on">controls on</option>
- </select>
- </div>
- <div class="field-row">
- <label>AR</label>
- <select id="ar-select">
- <option value="off">off</option>
- <option value="on">on</option>
- </select>
- </div>
- <div class="field-row">
- <label>Background</label>
- <select id="bg-select">
- <option value="transparent">Transparent</option>
- <option value="dark">Dark</option>
- <option value="light">Light</option>
- </select>
- </div>
- <div class="field-row">
- <label>Backdrop glow</label>
- <select id="glow-select">
- <option value="off">Off (no background)</option>
- <option value="on">Purple → cyan glow</option>
- </select>
- </div>
-
- <div class="section-title">Identity &amp; Agent</div>
- <div class="field-row">
- <label>Agent ID</label>
- <input id="agent-id-input" placeholder="Optional — connects to AI brain">
- </div>
- <div class="field-row">
- <label>Name plate</label>
- <select id="nameplate-select">
- <option value="on">Visible</option>
- <option value="off">Hidden</option>
- </select>
- </div>
-
- <div class="section-title">Animation</div>
- <div class="field-row">
- <label>Default</label>
- <select id="default-clip-select">
- <option value="">None (idle)</option>
- </select>
- </div>
- <div class="field-row">
- <label>Loop</label>
- <select id="default-clip-loop">
- <option value="true">Loop indefinitely</option>
- <option value="false">Play once</option>
- </select>
- </div>
-
- <div class="section-title">Styling</div>
- <div class="field-row">
- <label>Accent color</label>
- <div style="display:flex;gap:6px;align-items:center;flex:1">
- <input type="color" id="accent-color-input" value="#3b82f6" style="flex:1;height:32px;cursor:pointer">
- <button id="accent-reset-btn" class="btn secondary" type="button" style="padding:4px 8px;font-size:11px;flex:0 0 auto">↺</button>
- </div>
- </div>
- <div class="field-row">
- <label>Border radius</label>
- <input id="radius-input" type="text" placeholder="16px">
- </div>
-
- <div class="section-title">Embed snippet</div>
- <div class="snippet-box collapsed" id="snippet"></div>
- <button class="snippet-collapse" id="snippet-collapse" type="button">Show full snippet ▾</button>
- <div class="actions">
- <button class="btn" id="copy-btn" type="button">Copy snippet</button>
- <button class="btn secondary" id="open-btn" type="button" title="Render the snippet against a demo page in a new tab">Open in new tab</button>
- <button class="btn secondary" id="reset-btn" type="button">Reset</button>
- </div>
- <div class="toast" id="toast" role="status" aria-live="polite"></div>
- </div>
- </aside>
- </div>
- <div class="avatar-modal" id="avatar-modal" hidden role="dialog" aria-modal="true" aria-labelledby="avatar-modal-title">
- <div class="avatar-modal-backdrop" id="avatar-modal-backdrop"></div>
- <div class="avatar-modal-card">
- <header class="avatar-modal-header">
- <div>
- <h3 id="avatar-modal-title">Choose an avatar</h3>
- <p class="avatar-modal-sub">Click any preview to load it in the embed.</p>
- </div>
- <button class="avatar-modal-close" id="avatar-modal-close" type="button" aria-label="Close (Esc)">✕</button>
- </header>
- <div class="avatar-modal-body" id="avatar-modal-body">
- <div class="avatar-picker-grid" id="avatar-grid"></div>
- <button class="avatar-picker-more" id="avatar-more" type="button" hidden>Load more</button>
- <div class="avatar-picker-empty" id="avatar-empty" hidden>No public avatars found.</div>
- </div>
- </div>
- </div>
- <div class="anim-modal" id="anim-modal" hidden role="dialog" aria-modal="true" aria-labelledby="anim-modal-title">
- <div class="anim-modal-backdrop" id="anim-modal-backdrop"></div>
- <div class="anim-modal-card">
- <header class="anim-modal-header">
- <h3 id="anim-modal-title">Animation library</h3>
- <button class="anim-modal-close" id="anim-modal-close" type="button" aria-label="Close (Esc)">✕</button>
- </header>
- <div class="anim-modal-body" id="anim-modal-body"></div>
- </div>
- </div>
- `;
-
- const $ = (sel) => shadow.querySelector(sel);
- const $$ = (sel) => shadow.querySelectorAll(sel);
-
- // Device preview buttons
- const deviceBar = $('#device-bar');
- for (const d of DEVICES) {
- const btn = document.createElement('button');
- btn.className = 'device-btn';
- btn.dataset.device = d.id;
- btn.setAttribute('aria-pressed', String(d.id === state.device));
- btn.textContent = d.label;
- btn.addEventListener('click', () => {
- state.device = d.id;
- syncDevice();
- writeSnippet();
- });
- deviceBar.appendChild(btn);
- }
-
- const stage = $('#stage');
- const agentWrap = $('#agent-wrap');
- const agentEl = $('#preview-agent');
- const widgetFrame = $('#widget-frame');
- const widgetBadge = $('#widget-badge');
- const readout = $('#size-readout');
- const snippetEl = $('#snippet');
- const srcInput = $('#src-input');
- const wInput = $('#w-input');
- const hInput = $('#h-input');
- const copyBtn = $('#copy-btn');
-
- srcInput.value = state.src;
- agentEl.setAttribute('src', state.src || DEFAULT_PREVIEW_SRC);
-
- const animDock = $('#anim-dock');
- const animModal = $('#anim-modal');
- const animModalBody = $('#anim-modal-body');
- const animModalBackdrop = $('#anim-modal-backdrop');
- const animModalClose = $('#anim-modal-close');
-
- // Curated chips visible in the always-on dock — ordered for video impact.
- // Only ones present in the loaded model's clip list are shown; the rest
- // of the library lives behind the "+ More" chip in the modal.
- const FEATURED_CLIPS = ['downdog', 'wave', 'dance', 'thriller', 'celebrate', 'kiss', 'jump'];
-
- // Pose the avatar holds when the editor first opens — looped so the rig
- // settles on a recognizable yoga frame instead of the procedural idle drift.
- const DEFAULT_POSE = 'downdog';
-
- // Buckets for the modal. Names not matched here fall into "Other".
- const CLIP_CATEGORIES = [
- { title: 'Yoga & poses', match: /^(downdog)$/ },
- { title: 'Greetings & social', match: /^(wave|kiss|pray|sitclap|sitlaugh|taunt|silly|reaction)$/ },
- { title: 'Dances', match: /^(dance|rumba|thriller|capoeira|hiphop)$/ },
- { title: 'Reactions', match: /^(celebrate|angry|defeated|reaction)$/ },
- { title: 'Locomotion', match: /^(walk|jump|stepback|dodge|removing)$/ },
- { title: 'Falls & combat', match: /^(falling|dying|shoved|falltolanding|jumpdown|jumpdown2|jumpdown3)$/ },
- { title: 'Sports', match: /^(header|goalkeeper|coverstand)$/ },
- { title: 'Idle & standing', match: /^(idle|standup)$/ },
- ];
-
- // Live registry of every chip rendered (dock + modal) keyed by clip name,
- // so playing a clip can sync aria-pressed across both surfaces at once.
- let chipsByName = new Map();
- function setActiveClip(name) {
- state.activeClip = name;
- for (const [n, chips] of chipsByName) {
- const pressed = String(n === name);
- for (const c of chips) c.setAttribute('aria-pressed', pressed);
- }
- }
- function playClip(clip) {
- setActiveClip(clip.name);
- agentEl.play?.(clip.name, { loop: clip.loop !== false, fade_ms: 250 });
- // Also set as the embed default animation
- state.defaultClip = clip.name;
- state.defaultClipLoop = clip.loop !== false;
- const sel = $('#default-clip-select');
- if (sel) sel.value = clip.name;
- const loopSel = $('#default-clip-loop');
- if (loopSel) loopSel.value = state.defaultClipLoop ? 'true' : 'false';
- writeSnippet();
- }
-
- function makeChip(clip, { shortcut, withKbd = false, extraClass = '' } = {}) {
- const chip = document.createElement('button');
- chip.type = 'button';
- chip.className = 'anim-chip' + (extraClass ? ' ' + extraClass : '');
- chip.dataset.name = clip.name;
- chip.setAttribute('aria-pressed', String(state.activeClip === clip.name));
- const kbdHtml = withKbd && shortcut ? `<span class="kbd">${shortcut}</span>` : '';
- chip.innerHTML = `<span class="icon">${clip.icon || '✨'}</span><span>${clip.label || clip.name}</span>${kbdHtml}`;
- chip.addEventListener('click', () => playClip(clip));
- if (!chipsByName.has(clip.name)) chipsByName.set(clip.name, []);
- chipsByName.get(clip.name).push(chip);
- return chip;
- }
-
- function openAnimModal() {
- animModal.hidden = false;
- }
- function closeAnimModal() {
- animModal.hidden = true;
- }
- animModalClose.addEventListener('click', closeAnimModal);
- animModalBackdrop.addEventListener('click', closeAnimModal);
-
- function renderAnimDock() {
- if (state.widgetId) { animDock.hidden = true; return; }
- const clips = (typeof agentEl._listAvailableClips === 'function')
- ? agentEl._listAvailableClips()
- : [];
- if (!clips.length) { animDock.hidden = true; return; }
-
- // Populate the default-clip dropdown with available clips
- const clipSelect = $('#default-clip-select');
- if (clipSelect) {
- const currentValue = clipSelect.value;
- clipSelect.replaceChildren();
- const noneOpt = document.createElement('option');
- noneOpt.value = '';
- noneOpt.textContent = 'None (idle)';
- clipSelect.appendChild(noneOpt);
- for (const clip of clips) {
- const opt = document.createElement('option');
- opt.value = clip.name;
- opt.textContent = `${clip.icon || '✨'} ${clip.label || clip.name}`;
- clipSelect.appendChild(opt);
- }
- clipSelect.value = currentValue;
- }
-
- chipsByName = new Map();
- animDock.replaceChildren();
- animModalBody.replaceChildren();
-
- const byName = new Map(clips.map((c) => [c.name, c]));
-
- // 1. Featured chips in the dock — in declared order, skipping any that
- // the current model doesn't expose.
- let shortcutIdx = 1;
- for (const name of FEATURED_CLIPS) {
- const clip = byName.get(name);
- if (!clip) continue;
- animDock.appendChild(makeChip(clip, { shortcut: String(shortcutIdx), withKbd: true }));
- shortcutIdx++;
- if (shortcutIdx > 6) break;
- }
-
- // 2. "+ More" chip if there are clips not shown in the featured row.
- const extraClips = clips.filter((c) => !FEATURED_CLIPS.includes(c.name));
- if (extraClips.length || clips.length > shortcutIdx - 1) {
- const more = document.createElement('button');
- more.type = 'button';
- more.className = 'anim-chip more';
- more.innerHTML = `<span class="icon">✨</span><span>More</span>`;
- more.title = 'Open animation library (A)';
- more.addEventListener('click', openAnimModal);
- animDock.appendChild(more);
- }
-
- // 3. Modal contents — every clip categorized.
- for (const cat of CLIP_CATEGORIES) {
- const inCat = clips.filter((c) => cat.match.test(c.name));
- if (!inCat.length) continue;
- const title = document.createElement('div');
- title.className = 'anim-cat-title';
- title.textContent = cat.title;
- const grid = document.createElement('div');
- grid.className = 'anim-cat-grid';
- for (const clip of inCat) grid.appendChild(makeChip(clip));
- animModalBody.appendChild(title);
- animModalBody.appendChild(grid);
- }
- // Any clip not matched by a category goes into "Other".
- const matched = new Set(
- CLIP_CATEGORIES.flatMap((cat) => clips.filter((c) => cat.match.test(c.name)).map((c) => c.name)),
- );
- const other = clips.filter((c) => !matched.has(c.name));
- if (other.length) {
- const title = document.createElement('div');
- title.className = 'anim-cat-title';
- title.textContent = 'Other';
- const grid = document.createElement('div');
- grid.className = 'anim-cat-grid';
- for (const clip of other) grid.appendChild(makeChip(clip));
- animModalBody.appendChild(title);
- animModalBody.appendChild(grid);
- }
-
- animDock.hidden = false;
- }
- agentEl.addEventListener('agent:ready', renderAnimDock);
-
- // Hold the avatar in the default pose as soon as the rig is ready, so the
- // editor opens on a recognizable frame instead of the procedural idle.
- // Skipped when a saved widget is being loaded — that flow hides the dock
- // and renders its own configured state.
- agentEl.addEventListener('agent:ready', () => {
- if (state.widgetId) return;
- const clips = (typeof agentEl._listAvailableClips === 'function')
- ? agentEl._listAvailableClips()
- : [];
- const pose = clips.find((c) => c.name === DEFAULT_POSE);
- if (pose) playClip(pose);
- });
-
- // Number-key shortcuts (1–6) play the matching featured chip. Skipped
- // while typing in any text field; skipped when the modal is open so the
- // user can scroll without firing animations.
- const onAnimKey = (e) => {
- if (e.metaKey || e.ctrlKey || e.altKey) return;
- if (animModal && !animModal.hidden) {
- if (e.key === 'Escape') { e.preventDefault(); closeAnimModal(); }
- return;
- }
- if (e.key >= '1' && e.key <= '6') {
- const chips = animDock.querySelectorAll('.anim-chip:not(.more)');
- const idx = Number(e.key) - 1;
- if (chips[idx]) {
- const path = e.composedPath?.() || [];
- const inText = path.some((n) => n?.tagName === 'INPUT' || n?.tagName === 'TEXTAREA' || n?.isContentEditable);
- if (inText) return;
- e.preventDefault();
- chips[idx].click();
- }
- } else if (e.key === 'a' || e.key === 'A') {
- const path = e.composedPath?.() || [];
- const inText = path.some((n) => n?.tagName === 'INPUT' || n?.tagName === 'TEXTAREA' || n?.isContentEditable);
- if (inText) return;
- e.preventDefault();
- if (animModal.hidden) openAnimModal();
- else closeAnimModal();
- }
- };
- document.addEventListener('keydown', onAnimKey);
-
- // ── Avatar picker (modal) ──
- // Behind a modal so the panel stays light. The list is fetched only when
- // the modal first opens, and each card uses <model-viewer loading="lazy">
- // so only thumbnails scrolled into the viewport actually boot a WebGL
- // context. Demo set is rendered immediately; public-avatars network call
- // is deferred until modal open.
- const avatarTrigger = $('#avatar-trigger');
- const avatarTriggerName = $('#avatar-trigger-name');
- const avatarTriggerThumb = $('#avatar-trigger-thumb');
- const avatarModal = $('#avatar-modal');
- const avatarModalClose = $('#avatar-modal-close');
- const avatarModalBackdrop = $('#avatar-modal-backdrop');
- const avatarGrid = $('#avatar-grid');
- const avatarMore = $('#avatar-more');
- const avatarEmpty = $('#avatar-empty');
- let avatarCursor = null;
- let avatarLoading = false;
- let avatarPopulated = false;
- let modelViewerLoading = null;
-
- // Dynamically load Google's <model-viewer> on first modal open so the
- // editor's initial bundle stays small.
- function ensureModelViewer() {
- if (customElements.get('model-viewer')) return Promise.resolve();
- if (modelViewerLoading) return modelViewerLoading;
- modelViewerLoading = new Promise((resolve, reject) => {
- const s = document.createElement('script');
- s.type = 'module';
- s.src = 'https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js';
- s.onload = () => resolve();
- s.onerror = () => reject(new Error('model-viewer failed to load'));
- document.head.appendChild(s);
- });
- return modelViewerLoading;
- }
-
- function renderSkeletons(n) {
- for (let i = 0; i < n; i++) {
- const sk = document.createElement('div');
- sk.className = 'avatar-card skeleton';
- avatarGrid.appendChild(sk);
- }
- }
- function clearSkeletons() {
- for (const el of avatarGrid.querySelectorAll('.skeleton')) el.remove();
- }
- function updateAvatarTrigger(name, modelUrl) {
- avatarTriggerName.textContent = name || 'Browse avatars';
- // Thumbnail in the trigger: if we know a thumbnail_url we use it,
- // otherwise leave the gradient fallback.
- avatarTriggerThumb.style.backgroundImage = '';
- }
- function pickAvatar(card, modelUrl, name) {
- state.src = modelUrl;
- srcInput.value = modelUrl;
- agentEl.setAttribute('src', modelUrl);
- for (const c of avatarGrid.querySelectorAll('.avatar-card'))
- c.setAttribute('aria-pressed', String(c === card));
- updateAvatarTrigger(name, modelUrl);
- writeSnippet();
- closeAvatarModal();
- }
- function renderAvatarCards(items, { pinned = false } = {}) {
- for (const a of items) {
- if (!a.model_url) continue;
- const card = document.createElement('div');
- card.className = 'avatar-card' + (pinned ? ' pinned' : '');
- card.setAttribute('role', 'button');
- card.setAttribute('tabindex', '0');
- card.dataset.id = a.id;
- card.title = a.name || a.slug || a.id;
-
- // Live 3D thumbnail via <model-viewer> with loading="lazy" so the
- // underlying GLTFLoader / WebGL context only spins up when the card
- // scrolls into the modal's viewport.
- const mv = document.createElement('model-viewer');
- mv.setAttribute('src', a.model_url);
- mv.setAttribute('alt', a.name || 'Avatar preview');
- mv.setAttribute('camera-controls', '');
- mv.setAttribute('disable-zoom', '');
- mv.setAttribute('interaction-prompt', 'none');
- mv.setAttribute('auto-rotate', '');
- mv.setAttribute('rotation-per-second', '24deg');
- mv.setAttribute('exposure', '1.05');
- mv.setAttribute('shadow-intensity', '0.6');
- mv.setAttribute('loading', 'lazy');
- mv.setAttribute('reveal', 'auto');
- if (a.thumbnail_url) mv.setAttribute('poster', a.thumbnail_url);
- card.appendChild(mv);
-
- if (pinned) {
- const tag = document.createElement('div');
- tag.className = 'tag';
- tag.textContent = 'Demo';
- card.appendChild(tag);
- }
- const name = document.createElement('div');
- name.className = 'name';
- name.textContent = a.name || a.slug || 'Avatar';
- card.appendChild(name);
- card.setAttribute('aria-pressed', String(state.src && state.src === a.model_url));
- const activate = () => pickAvatar(card, a.model_url, a.name);
- card.addEventListener('click', activate);
- card.addEventListener('keydown', (e) => {
- if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); activate(); }
- });
- avatarGrid.appendChild(card);
- }
- }
- async function loadAvatarPage() {
- if (avatarLoading) return;
- avatarLoading = true;
- avatarMore.hidden = true;
- const initial = !avatarGrid.children.length;
- if (initial) {
- // Pin the curated demo set first so the gallery opens to something
- // recognisable even before the network call returns.
- renderAvatarCards(DEMO_AVATARS, { pinned: true });
- renderSkeletons(8);
- }
- try {
- const url = new URL(`${location.origin}/api/avatars/public`);
- url.searchParams.set('limit', '24');
- if (avatarCursor) url.searchParams.set('cursor', avatarCursor);
- const res = await fetch(url.toString(), { credentials: 'omit' });
- if (!res.ok) throw new Error(`avatars/public ${res.status}`);
- const data = await res.json();
- clearSkeletons();
- renderAvatarCards(data.avatars || []);
- avatarCursor = data.next_cursor || null;
- avatarMore.hidden = !avatarCursor;
- } catch (err) {
- clearSkeletons();
- if (initial && !DEMO_AVATARS.length) {
- avatarEmpty.textContent = `Couldn't load avatars: ${err.message}`;
- avatarEmpty.hidden = false;
- }
- } finally {
- avatarLoading = false;
- }
- }
- avatarMore.addEventListener('click', loadAvatarPage);
-
- async function openAvatarModal() {
- avatarModal.hidden = false;
- document.body.style.overflow = 'hidden';
- if (!avatarPopulated) {
- avatarPopulated = true;
- try { await ensureModelViewer(); } catch (err) { console.warn('[embed-editor]', err); }
- loadAvatarPage();
- }
- }
- function closeAvatarModal() {
- avatarModal.hidden = true;
- document.body.style.overflow = '';
- }
- avatarTrigger.addEventListener('click', openAvatarModal);
- avatarModalClose.addEventListener('click', closeAvatarModal);
- avatarModalBackdrop.addEventListener('click', closeAvatarModal);
-
- // If a widget id was passed, swap the bare <agent-3d> preview for an
- // iframe loading the live widget renderer (/widget#widget=<id>&kiosk=true).
- if (state.widgetId) loadWidget(state.widgetId);
+function field(labelText, control) {
+ return el('label', { className: 'ee-field' }, [
+ el('span', { className: 'ee-label', textContent: labelText }),
+ control,
+ ]);
+}
- async function loadWidget(id) {
- const origin = location.origin;
- // Show the live widget immediately — don't wait on the metadata fetch.
- widgetFrame.src = `${origin}/widget#widget=${encodeURIComponent(id)}&kiosk=true`;
- widgetFrame.hidden = false;
- agentEl.style.display = 'none';
- widgetBadge.hidden = false;
- widgetBadge.textContent = id;
+function mountEmbedEditor(root, opts = {}) {
+ const cfg = { ...DEFAULTS, ...sanitize(opts) };
+ // If an avatar was passed in but no explicit mode, default to Walking so
+ // /embed?avatar=<id> lands on the interactive avatar embed.
+ if (opts.avatar && !opts.mode) cfg.mode = 'walking';
- try {
- const res = await fetch(`${origin}/api/widgets/${encodeURIComponent(id)}`, {
- credentials: 'include',
- });
- if (!res.ok) {
- widgetBadge.textContent = `${id} · not found`;
- widgetBadge.style.color = '#fca5a5';
- return;
- }
- const { widget } = await res.json();
- state.widget = widget;
- widgetBadge.textContent = `${widget.name || id} · ${widget.type}`;
+ injectStyles();
+ root.classList.add('embed-editor');
- // Type-aware preferred sizes (mirrors public/embed.js defaults).
- const TYPE_SIZES = {
- turntable: [600, 600],
- 'animation-gallery': [720, 720],
- 'talking-agent': [420, 600],
- passport: [480, 560],
- 'hotspot-tour': [800, 600],
- };
- const [w, h] = TYPE_SIZES[widget.type] || [600, 600];
- state.width = `${w}px`;
- state.height = `${h}px`;
- wInput.value = state.width;
- hInput.value = state.height;
+ // ── Left: controls panel ───────────────────────────────────────────────
+ const panel = el('div', { className: 'ee-panel' });
- // Pre-fill src with the avatar model so a fallback agent-3d snippet
- // works if the user later toggles off the widget id.
- if (widget.avatar?.model_url) {
- state.src = widget.avatar.model_url;
- srcInput.value = state.src;
- }
+ panel.append(
+ el('h1', { className: 'ee-title', textContent: 'Embed editor' }),
+ el('p', { className: 'ee-subtitle', textContent: 'Drop a live 3D avatar onto any site. Configure, preview, copy.' }),
+ );
- sync();
- } catch (err) {
- widgetBadge.textContent = `${id} · ${err.message}`;
- widgetBadge.style.color = '#fca5a5';
- }
- }
-
- // Mode cards
- const modeGrid = $('#mode-grid');
+ // Mode toggle
+ const modeRow = el('div', { className: 'ee-segment', role: 'tablist', 'aria-label': 'Embed mode' });
+ const modeButtons = new Map();
for (const m of MODES) {
- const card = document.createElement('div');
- card.className = 'mode-card';
- card.dataset.mode = m.id;
- card.setAttribute('aria-pressed', String(m.id === state.mode));
- card.tabIndex = 0;
- card.innerHTML = `<div class="ml">${m.label}</div><div class="mh">${m.hint}</div>`;
- card.addEventListener('click', () => {
- state.mode = m.id;
- sync();
- });
- modeGrid.appendChild(card);
- }
-
- // Position buttons
- const posGrid = $('#pos-grid');
- for (const p of POSITIONS) {
- const btn = document.createElement('button');
- btn.className = 'pos-btn';
- btn.dataset.pos = p.id;
- btn.setAttribute('aria-pressed', String(p.id === state.position));
- btn.textContent = p.label;
- btn.addEventListener('click', () => {
- state.position = p.id;
- sync();
+ const b = el('button', {
+ type: 'button',
+ className: 'ee-seg-btn',
+ textContent: m.label,
+ role: 'tab',
+ title: m.hint,
});
- posGrid.appendChild(btn);
- }
-
- // Input bindings
- srcInput.addEventListener('change', () => {
- state.src = srcInput.value;
+ b.addEventListener('click', () => { cfg.mode = m.id; sync(); });
+ modeButtons.set(m.id, b);
+ modeRow.appendChild(b);
+ }
+ const modeHint = el('p', { className: 'ee-hint' });
+ panel.append(field('Mode', modeRow), modeHint);
+
+ // Avatar id (shared by all modes)
+ const avatarInput = el('input', { type: 'text', placeholder: 'agent / avatar id (e.g. agt_abc123)', value: cfg.avatar });
+ avatarInput.addEventListener('input', () => { cfg.avatar = avatarInput.value.trim(); sync(); });
+ const avatarField = field('Avatar ID', avatarInput);
+
+ // Controls (walking only)
+ const controlsSelect = el('select', {}, CONTROL_OPTIONS.map((c) =>
+ el('option', { value: c, textContent: c, selected: c === cfg.controls })));
+ controlsSelect.addEventListener('change', () => { cfg.controls = controlsSelect.value; sync(); });
+ const controlsField = field('Controls', controlsSelect);
+
+ // Background color (avatar modes)
+ const bgWrap = el('div', { className: 'ee-bgrow' });
+ const bgTransparent = el('input', { type: 'checkbox', id: 'ee-bg-transparent', checked: cfg.bg === 'transparent' });
+ const bgTransparentLabel = el('label', { htmlFor: 'ee-bg-transparent', className: 'ee-checklabel', textContent: 'Transparent' });
+ const bgColor = el('input', { type: 'color', value: cfg.bg === 'transparent' ? '#101820' : cfg.bg, disabled: cfg.bg === 'transparent' });
+ bgTransparent.addEventListener('change', () => {
+ cfg.bg = bgTransparent.checked ? 'transparent' : bgColor.value;
+ bgColor.disabled = bgTransparent.checked;
sync();
});
- wInput.addEventListener('change', () => {
- state.width = wInput.value;
- sync();
- });
- hInput.addEventListener('change', () => {
- state.height = hInput.value;
- sync();
- });
- $('#chat-select').addEventListener('change', (e) => {
- state.showChat = e.target.value === 'on';
- applyAgentAttrs();
- sync();
- });
- $('#voice-select').addEventListener('change', (e) => {
- state.voice = e.target.value === 'off' ? false : true;
- applyAgentAttrs();
- sync();
- });
- $('#camera-select').addEventListener('change', (e) => {
- state.cameraControls = e.target.value === 'on';
- applyAgentAttrs();
- sync();
- });
- $('#ar-select').addEventListener('change', (e) => {
- state.ar = e.target.value === 'on';
- applyAgentAttrs();
- sync();
- });
- $('#bg-select').addEventListener('change', (e) => {
- state.background = e.target.value;
- applyAgentAttrs();
+ bgColor.addEventListener('input', () => { if (!bgTransparent.checked) { cfg.bg = bgColor.value; sync(); } });
+ bgWrap.append(bgColor, el('span', { className: 'ee-bgsep' }), bgTransparent, bgTransparentLabel);
+ const bgField = field('Background', bgWrap);
+
+ // Environment (avatar modes)
+ const envSelect = el('select', {}, ENV_OPTIONS.map((e) =>
+ el('option', { value: e.id, textContent: e.label, selected: e.id === cfg.env })));
+ envSelect.addEventListener('change', () => { cfg.env = envSelect.value; sync(); });
+ const envField = field('Environment', envSelect);
+
+ // Size (all modes — every runtime renders a sized iframe)
+ const sizeRow = el('div', { className: 'ee-segment ee-segment-sm' });
+ const sizeButtons = new Map();
+ for (const key of Object.keys(SIZE_PRESETS)) {
+ const b = el('button', { type: 'button', className: 'ee-seg-btn', textContent: key === 'custom' ? 'Custom' : key });
+ b.addEventListener('click', () => {
+ cfg.size = key;
+ if (SIZE_PRESETS[key]) { cfg.width = SIZE_PRESETS[key].w; cfg.height = SIZE_PRESETS[key].h; }
+ syncDims();
+ sync();
+ });
+ sizeButtons.set(key, b);
+ sizeRow.appendChild(b);
+ }
+ const sizeField = field('Size', sizeRow);
+
+ const dimRow = el('div', { className: 'ee-dimrow' });
+ const widthInput = el('input', { type: 'number', min: '120', value: String(cfg.width) });
+ const heightInput = el('input', { type: 'number', min: '120', value: String(cfg.height) });
+ const onDim = () => {
+ cfg.width = clampDim(widthInput.value);
+ cfg.height = clampDim(heightInput.value);
+ cfg.size = 'custom';
sync();
- });
- $('#glow-select').addEventListener('change', (e) => {
- state.glow = e.target.value === 'on';
- applyGlow();
- });
- $('#responsive-select').addEventListener('change', (e) => {
- state.responsivePreset = e.target.value;
- writeSnippet();
- });
- $('#agent-id-input').addEventListener('change', (e) => {
- state.agentId = e.target.value.trim();
- applyAgentAttrs();
- writeSnippet();
- });
- $('#nameplate-select').addEventListener('change', (e) => {
- state.namePlate = e.target.value;
- applyAgentAttrs();
- writeSnippet();
- });
- $('#default-clip-select').addEventListener('change', (e) => {
- state.defaultClip = e.target.value;
- writeSnippet();
- });
- $('#default-clip-loop').addEventListener('change', (e) => {
- state.defaultClipLoop = e.target.value === 'true';
- writeSnippet();
- });
- $('#accent-color-input').addEventListener('input', (e) => {
- state.accentColor = e.target.value;
- applyAgentAttrs();
- writeSnippet();
- });
- $('#accent-reset-btn').addEventListener('click', () => {
- state.accentColor = '#3b82f6';
- $('#accent-color-input').value = '#3b82f6';
- applyAgentAttrs();
- writeSnippet();
- });
- $('#radius-input').addEventListener('change', (e) => {
- state.borderRadius = e.target.value.trim();
- applyAgentAttrs();
- writeSnippet();
- });
-
- // URL preview
- const urlInput = $('#url-input');
- $('#url-load').addEventListener('click', () => {
- const u = urlInput.value.trim();
- if (!u) return;
- const iframe = $('#preview-frame');
- iframe.src = u;
- iframe.hidden = false;
- $('#placeholder').hidden = true;
- });
- $('#url-clear').addEventListener('click', () => {
- $('#preview-frame').src = 'about:blank';
- $('#preview-frame').hidden = true;
- $('#placeholder').hidden = false;
- });
-
- // Drag — also handles click-to-freeze: a pointerdown→pointerup with less
- // than TAP_THRESHOLD pixels of movement is treated as a tap on the avatar
- // and toggles state.avatarFrozen instead of dragging.
- const TAP_THRESHOLD = 5;
- let dragState = null;
- agentWrap.addEventListener('pointerdown', (e) => {
- // Don't intercept clicks on overlay chrome that sits over the wrap.
- if (e.target.closest('.size-readout, .widget-badge')) return;
- const dragAllowed = !state.previewMode && !state.locked;
- const agentRect = agentWrap.getBoundingClientRect();
- dragState = {
- kind: dragAllowed ? 'move' : 'tap-only',
- downX: e.clientX,
- downY: e.clientY,
- moved: false,
- offsetX: e.clientX - agentRect.left,
- offsetY: e.clientY - agentRect.top,
- stageRect: stage.getBoundingClientRect(),
- };
- agentWrap.setPointerCapture(e.pointerId);
- });
-
- stage.addEventListener('pointermove', (e) => {
- if (!dragState) return;
- const rect = dragState.stageRect;
- if (dragState.kind === 'move' || dragState.kind === 'tap-only') {
- // Don't start dragging (or treat as a movement) until the pointer has
- // travelled past TAP_THRESHOLD — anything shorter resolves as a tap on
- // pointerup, which toggles avatar freeze.
- if (!dragState.moved) {
- const dx = e.clientX - dragState.downX;
- const dy = e.clientY - dragState.downY;
- if (dx * dx + dy * dy < TAP_THRESHOLD * TAP_THRESHOLD) return;
- dragState.moved = true;
- if (dragState.kind === 'move') agentWrap.classList.add('dragging');
- }
- if (dragState.kind !== 'move') return;
- const x = e.clientX - rect.left - dragState.offsetX;
- const y = e.clientY - rect.top - dragState.offsetY;
- const snapped = snapToCorner(
- x,
- y,
- agentWrap.offsetWidth,
- agentWrap.offsetHeight,
- rect.width,
- rect.height,
- );
- agentWrap.style.left = snapped.x + 'px';
- agentWrap.style.top = snapped.y + 'px';
- if (snapped.corner) {
- state.position = snapped.corner;
- state.offset = `${snapped.offsetV} ${snapped.offsetH}`;
- syncPositionButtons();
- writeSnippet();
- }
- } else if (dragState.kind === 'resize') {
- const dx = e.clientX - dragState.startX;
- const dy = e.clientY - dragState.startY;
- let w = dragState.startW,
- h = dragState.startH;
- let left = dragState.startLeft,
- top = dragState.startTop;
- if (dragState.handle.includes('e')) w = dragState.startW + dx;
- if (dragState.handle.includes('s')) h = dragState.startH + dy;
- if (dragState.handle.includes('w')) {
- w = dragState.startW - dx;
- left = dragState.startLeft + dx;
- }
- if (dragState.handle.includes('n')) {
- h = dragState.startH - dy;
- top = dragState.startTop + dy;
- }
- w = Math.max(160, w);
- h = Math.max(200, h);
- agentWrap.style.width = w + 'px';
- agentWrap.style.height = h + 'px';
- agentWrap.style.left = left + 'px';
- agentWrap.style.top = top + 'px';
- state.width = Math.round(w) + 'px';
- state.height = Math.round(h) + 'px';
- wInput.value = state.width;
- hInput.value = state.height;
- readout.textContent = `${state.width} × ${state.height}`;
- writeSnippet();
- }
- });
-
- stage.addEventListener('pointerup', () => {
- if (!dragState) return;
- // Resize finalizes on pointerup regardless; only move/tap-only carry the
- // tap-to-freeze intent.
- if ((dragState.kind === 'move' || dragState.kind === 'tap-only') && !dragState.moved) {
- setAvatarFrozen(!state.avatarFrozen);
- }
- agentWrap.classList.remove('dragging');
- dragState = null;
- });
-
- const toastEl = $('#toast');
- let toastTimer = null;
- function showToast(message, { kind = 'success' } = {}) {
- toastEl.textContent = message;
- toastEl.dataset.kind = kind;
- toastEl.classList.add('visible');
- clearTimeout(toastTimer);
- toastTimer = setTimeout(() => toastEl.classList.remove('visible'), 2200);
- }
-
+ };
+ widthInput.addEventListener('input', onDim);
+ heightInput.addEventListener('input', onDim);
+ dimRow.append(
+ el('div', { className: 'ee-dim' }, [el('span', { className: 'ee-dim-label', textContent: 'W' }), widthInput]),
+ el('div', { className: 'ee-dim' }, [el('span', { className: 'ee-dim-label', textContent: 'H' }), heightInput]),
+ );
+ const dimField = field('Dimensions (px)', dimRow);
+ function syncDims() { widthInput.value = String(cfg.width); heightInput.value = String(cfg.height); }
+
+ // Autoplay (walking only — static/idle imply it)
+ const autoplayWrap = el('div', { className: 'ee-bgrow' });
+ const autoplayCheck = el('input', { type: 'checkbox', id: 'ee-autoplay', checked: cfg.autoplay });
+ const autoplayLabel = el('label', { htmlFor: 'ee-autoplay', className: 'ee-checklabel', textContent: 'Avatar starts moving on load' });
+ autoplayCheck.addEventListener('change', () => { cfg.autoplay = autoplayCheck.checked; sync(); });
+ autoplayWrap.append(autoplayCheck, autoplayLabel);
+ const autoplayField = field('Autoplay', autoplayWrap);
+
+ panel.append(avatarField, controlsField, envField, bgField, sizeField, dimField, autoplayField);
+
+ // ── Right: preview + snippet ────────────────────────────────────────────
+ const previewWrap = el('div', { className: 'ee-preview-wrap' });
+
+ const previewBar = el('div', { className: 'ee-bar' }, [
+ el('span', { className: 'ee-bar-title', textContent: 'Live preview' }),
+ el('span', { className: 'ee-bar-note', textContent: 'rendered from the real embed runtime' }),
+ ]);
+ const previewFrame = el('div', { className: 'ee-stage' });
+ const previewEmpty = el('div', { className: 'ee-empty' });
+
+ // Snippet variant tabs
+ const variantRow = el('div', { className: 'ee-segment ee-segment-sm ee-variant' });
+ const variantButtons = new Map();
+ for (const v of [{ id: 'iframe', label: 'Iframe' }, { id: 'script', label: 'Script tag' }]) {
+ const b = el('button', { type: 'button', className: 'ee-seg-btn', textContent: v.label });
+ b.addEventListener('click', () => { cfg.snippetVariant = v.id; sync(); });
+ variantButtons.set(v.id, b);
+ variantRow.appendChild(b);
+ }
+
+ const snippetBar = el('div', { className: 'ee-bar' }, [
+ el('span', { className: 'ee-bar-title', textContent: 'Snippet' }),
+ variantRow,
+ ]);
+ const snippetBox = el('textarea', { className: 'ee-snippet', readOnly: true, rows: 5, spellcheck: false });
+
+ const copyBtn = el('button', { type: 'button', className: 'ee-copy', textContent: 'Copy snippet' });
copyBtn.addEventListener('click', async () => {
- const snippet = buildSnippet();
try {
- await navigator.clipboard.writeText(snippet);
- showToast('Snippet copied to clipboard');
- } catch (err) {
- // Permissions may block clipboard in some embedded contexts. Fall back
- // to a manual selection so the user can still grab the snippet.
- const range = document.createRange();
- range.selectNodeContents(snippetEl);
- const sel = window.getSelection();
- sel.removeAllRanges();
- sel.addRange(range);
- showToast('Clipboard blocked — snippet selected, press ⌘C', { kind: 'warn' });
- }
- copyBtn.textContent = 'Copied ✓';
- copyBtn.dataset.copied = 'true';
- setTimeout(() => {
- copyBtn.textContent = 'Copy snippet';
- copyBtn.dataset.copied = 'false';
- }, 1500);
+ await navigator.clipboard.writeText(snippetBox.value);
+ copyBtn.textContent = 'Copied!';
+ copyBtn.classList.add('is-ok');
+ } catch {
+ // Fallback for non-secure contexts where the Clipboard API is blocked.
+ snippetBox.select();
+ const ok = document.execCommand && document.execCommand('copy');
+ copyBtn.textContent = ok ? 'Copied!' : 'Copy failed — select & ⌘C';
+ copyBtn.classList.toggle('is-ok', !!ok);
+ }
+ clearTimeout(copyBtn._t);
+ copyBtn._t = setTimeout(() => { copyBtn.textContent = 'Copy snippet'; copyBtn.classList.remove('is-ok'); }, 1600);
});
- const snippetCollapse = $('#snippet-collapse');
- snippetCollapse.addEventListener('click', () => {
- const collapsed = snippetEl.classList.toggle('collapsed');
- snippetCollapse.textContent = collapsed ? 'Show full snippet ▾' : 'Collapse snippet ▴';
- });
+ previewWrap.append(previewBar, previewFrame, snippetBar, snippetBox, copyBtn);
- $('#open-btn').addEventListener('click', () => {
- const html = buildStandalonePage();
- const blob = new Blob([html], { type: 'text/html' });
- const url = URL.createObjectURL(blob);
- const win = window.open(url, '_blank', 'noopener');
- if (!win) {
- showToast('Popup blocked — allow popups to open the preview', { kind: 'warn' });
- URL.revokeObjectURL(url);
- return;
- }
- // Revoke the blob URL after the new tab has had time to load it. 60s is
- // generous — the document fully parses long before this. Without revoke,
- // the blob lingers for the lifetime of the editor tab.
- setTimeout(() => URL.revokeObjectURL(url), 60_000);
- });
-
- $('#reset-btn').addEventListener('click', () => {
- Object.assign(state, defaults);
- srcInput.value = state.src;
- wInput.value = state.width;
- hInput.value = state.height;
- $('#responsive-select').value = state.responsivePreset;
- $('#chat-select').value = state.showChat ? 'on' : 'off';
- $('#voice-select').value = state.voice === false ? 'off' : '';
- $('#camera-select').value = state.cameraControls ? 'on' : 'off';
- $('#ar-select').value = state.ar ? 'on' : 'off';
- $('#bg-select').value = state.background || 'transparent';
- $('#glow-select').value = state.glow ? 'on' : 'off';
- $('#agent-id-input').value = state.agentId || '';
- $('#nameplate-select').value = state.namePlate || 'on';
- $('#default-clip-select').value = state.defaultClip || '';
- $('#default-clip-loop').value = state.defaultClipLoop !== false ? 'true' : 'false';
- $('#accent-color-input').value = state.accentColor || '#3b82f6';
- $('#radius-input').value = state.borderRadius || '16px';
- sync();
- });
+ root.append(panel, previewWrap);
- const editorRoot = shadow.querySelector('.editor-root');
- const previewToggle = $('#preview-toggle');
- const exitPreview = $('#exit-preview');
- function setPreviewMode(on) {
- state.previewMode = !!on;
- editorRoot.setAttribute('data-preview', state.previewMode ? 'true' : 'false');
- previewToggle.textContent = state.previewMode ? 'Editing' : 'Preview';
- applyToPreview();
- }
- previewToggle.addEventListener('click', () => setPreviewMode(!state.previewMode));
- exitPreview.addEventListener('click', () => setPreviewMode(false));
- previewToggle.title = 'Toggle preview (P)';
- exitPreview.title = 'Exit preview (Esc)';
-
- // ── Lock mode ──
- // Freezes the wrap (drag + resize disabled, handles hidden via CSS) and the
- // avatar itself: the Three.js animation mixer's timeScale is set to 0 so
- // the idle loop stops mid-frame, and OrbitControls is disabled so the
- // camera can't be rotated/panned/zoomed. Toggling off restores both.
- const lockToggle = $('#lock-toggle');
- // state.avatarFrozen — true when the avatar's mixer + camera controls are
- // paused (set by Lock button OR by click-on-avatar). state.locked is the
- // wider Lock-button state that also freezes the wrap.
- function applyAvatarLock() {
- const viewer = agentEl?._viewer;
- if (!viewer) return;
- if (viewer.mixer) viewer.mixer.timeScale = state.avatarFrozen ? 0 : 1;
- if (viewer.controls) viewer.controls.enabled = !state.avatarFrozen;
- editorRoot.setAttribute('data-avatar-frozen', state.avatarFrozen ? 'true' : 'false');
- }
- function setAvatarFrozen(on, { silent = false } = {}) {
- state.avatarFrozen = !!on;
- applyAvatarLock();
- if (!silent) {
- showToast(state.avatarFrozen ? 'Avatar frozen — click again to play' : 'Avatar playing', {
- kind: state.avatarFrozen ? 'warn' : 'success',
- });
- }
- }
- function setLocked(on) {
- state.locked = !!on;
- editorRoot.setAttribute('data-locked', state.locked ? 'true' : 'false');
- lockToggle.setAttribute('aria-pressed', state.locked ? 'true' : 'false');
- lockToggle.querySelector('.lock-icon').textContent = state.locked ? '🔒' : '🔓';
- lockToggle.querySelector('.lock-label').textContent = state.locked ? 'Locked' : 'Lock';
- // Lock button drives both the wrap and the avatar freeze.
- setAvatarFrozen(state.locked, { silent: true });
- showToast(state.locked ? 'Locked — drag, resize, and avatar motion frozen' : 'Unlocked', {
- kind: state.locked ? 'warn' : 'success',
- });
- }
- lockToggle.addEventListener('click', () => setLocked(!state.locked));
- // Re-apply on each agent boot so freezing persists across avatar swaps —
- // _viewer.mixer is rebuilt during setContent() so the timeScale would
- // otherwise reset to 1.
- agentEl.addEventListener('agent:ready', applyAvatarLock);
-
- // Keyboard shortcuts — Esc exits preview, P toggles. Bound on document so
- // they fire even when focus is on the stage. Suppressed while typing in any
- // text field (the editor's inputs live in the shadow root; check both light
- // DOM target and composedPath() for an editable element).
- function isTextTarget(e) {
- const path = e.composedPath?.() || [];
- for (const node of path) {
- if (!node || node.nodeType !== 1) continue;
- const tag = node.tagName;
- if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') return true;
- if (node.isContentEditable) return true;
- }
- return false;
- }
- const onKey = (e) => {
- if (e.key === 'Escape' && !avatarModal.hidden) {
- e.preventDefault();
- closeAvatarModal();
- return;
- }
- if (e.key === 'Escape' && state.previewMode) {
- e.preventDefault();
- setPreviewMode(false);
- return;
- }
- if ((e.key === 'p' || e.key === 'P') && !e.metaKey && !e.ctrlKey && !e.altKey) {
- if (isTextTarget(e)) return;
- e.preventDefault();
- setPreviewMode(!state.previewMode);
+ // ── Sync: regenerate UI visibility + preview + snippet from cfg ──────────
+ let previewEl = null;
+ function sync() {
+ const isAvatar = cfg.mode !== 'chat';
+ const isWalking = cfg.mode === 'walking';
+
+ // Active states
+ for (const [id, b] of modeButtons) {
+ const on = id === cfg.mode;
+ b.classList.toggle('is-active', on);
+ b.setAttribute('aria-selected', String(on));
+ }
+ for (const [id, b] of sizeButtons) b.classList.toggle('is-active', id === cfg.size);
+ for (const [id, b] of variantButtons) b.classList.toggle('is-active', id === cfg.snippetVariant);
+ modeHint.textContent = MODES.find((m) => m.id === cfg.mode)?.hint || '';
+
+ // Field visibility per mode
+ controlsField.style.display = isWalking ? '' : 'none';
+ autoplayField.style.display = isWalking ? '' : 'none';
+ envField.style.display = isAvatar ? '' : 'none';
+ bgField.style.display = isAvatar ? '' : 'none';
+ // Size applies to every mode — all runtimes render a sized iframe.
+ sizeField.style.display = '';
+ dimField.style.display = '';
+ // Chat is a plain iframe to the agent page — no iframe/script choice.
+ variantRow.style.display = isAvatar ? '' : 'none';
+
+ reflectUrl();
+
+ snippetBox.value = buildSnippet(cfg);
+ renderPreview();
+ }
+
+ function renderPreview() {
+ if (previewEl) { previewEl.remove(); previewEl = null; }
+ previewEmpty.remove();
+
+ if (!cfg.avatar) {
+ previewEmpty.textContent = cfg.mode === 'chat'
+ ? 'Enter an agent ID to preview the chat embed.'
+ : 'Enter an avatar ID to preview the embed.';
+ previewFrame.appendChild(previewEmpty);
return;
}
- if ((e.key === 'l' || e.key === 'L') && !e.metaKey && !e.ctrlKey && !e.altKey) {
- if (isTextTarget(e)) return;
- e.preventDefault();
- setLocked(!state.locked);
- }
- };
- document.addEventListener('keydown', onKey);
-
- // Show appropriate resize handles based on position
- function syncPositionButtons() {
- for (const btn of $$('.pos-btn'))
- btn.setAttribute('aria-pressed', String(btn.dataset.pos === state.position));
- }
- function syncModeCards() {
- for (const card of $$('.mode-card'))
- card.setAttribute('aria-pressed', String(card.dataset.mode === state.mode));
- }
-
- // Mirror toggleable agent attrs (voice/camera/AR/background) onto the live
- // preview element so flipping the panel selects has an immediate visual effect.
- // Snippet attrs are emitted separately in buildSnippet() — these only drive the
- // in-editor preview agent. Skipped in widget-iframe mode (the iframe owns its
- // own agent instance and reads its config from the widget record).
- // Toggles the purple→cyan blur layer on the preview backdrop. Preview-only
- // decoration — not exported in the snippet — so it lives outside
- // applyAgentAttrs / writeSnippet.
- function applyGlow() {
- const placeholder = $('#placeholder');
- if (!placeholder) return;
- placeholder.classList.toggle('has-glow', !!state.glow);
- }
-
- function applyAgentAttrs() {
- if (state.widgetId) return;
- // kiosk = no chat UI. Mirror state.showChat onto the live agent so the
- // editor preview matches what the snippet will emit.
- if (state.showChat) agentEl.removeAttribute('kiosk');
- else agentEl.setAttribute('kiosk', '');
- if (state.voice === false) agentEl.setAttribute('voice', 'off');
- else agentEl.removeAttribute('voice');
- if (state.cameraControls) agentEl.setAttribute('camera-controls', '');
- else agentEl.removeAttribute('camera-controls');
- if (state.ar) agentEl.setAttribute('ar', '');
- else agentEl.removeAttribute('ar');
- if (state.background) agentEl.setAttribute('background', state.background);
- else agentEl.removeAttribute('background');
- if (state.agentId) agentEl.setAttribute('agent-id', state.agentId);
- else agentEl.removeAttribute('agent-id');
- if (state.namePlate === 'off') agentEl.setAttribute('name-plate', 'off');
- else agentEl.removeAttribute('name-plate');
- // Apply CSS custom properties for styling
- const styleVars = [];
- if (state.accentColor) styleVars.push(`--agent-accent: ${state.accentColor}`);
- if (state.borderRadius) styleVars.push(`--agent-bubble-radius: ${state.borderRadius}`);
- agentEl.style.cssText = styleVars.length ? styleVars.join(';') : '';
- }
-
- function applyToPreview() {
- // Size
- agentWrap.style.width = state.width;
- agentWrap.style.height = state.height;
- readout.textContent = `${state.width} × ${state.height}`;
-
- // Position — place the wrap inside the stage per mode + position
- agentWrap.style.left =
- agentWrap.style.right =
- agentWrap.style.top =
- agentWrap.style.bottom =
- '';
- if (state.mode === 'floating') {
- const [vOff, hOff] = (state.offset || '24px 24px').split(/\s+/);
- if (state.position.includes('top')) agentWrap.style.top = vOff;
- else agentWrap.style.bottom = vOff;
- if (state.position.includes('left')) agentWrap.style.left = hOff;
- else if (state.position.includes('right')) agentWrap.style.right = hOff;
- else if (state.position.includes('center')) {
- agentWrap.style.left = '50%';
- agentWrap.style.transform = 'translateX(-50%)';
- }
- $('#pos-title').style.display = '';
- $('#pos-grid').style.display = '';
- } else if (state.mode === 'fullscreen') {
- agentWrap.style.inset = '0';
- agentWrap.style.width = '100%';
- agentWrap.style.height = '100%';
- $('#pos-title').style.display = 'none';
- $('#pos-grid').style.display = 'none';
- } else {
- // inline / section: center on stage
- agentWrap.style.left = `calc(50% - ${parseInt(state.width) / 2}px)`;
- agentWrap.style.top = `calc(50% - ${parseInt(state.height) / 2}px)`;
- $('#pos-title').style.display = 'none';
- $('#pos-grid').style.display = 'none';
- }
-
- // Agent attrs — skip when a widget is driving the preview iframe so the
- // hidden <agent-3d> doesn't fetch a GLB we'll never show. Fall back to a
- // default avatar when the user hasn't entered a src, so the preview is
- // never an empty box.
- if (!state.widgetId) {
- agentEl.setAttribute('src', state.src || DEFAULT_PREVIEW_SRC);
- }
- }
-
- function buildSnippet() {
- // Widget snippet — when a saved widget id is loaded, prefer the
- // canonical script-tag embed (matches Studio's "share" modal).
- if (state.widgetId) {
- const origin = location.origin;
- const wPx = parsePx(state.width);
- const hPx = parsePx(state.height);
- const dataAttrs = [
- `data-widget="${escapeAttr(state.widgetId)}"`,
- state.widget?.type ? `data-type="${escapeAttr(state.widget.type)}"` : '',
- wPx ? `data-width="${wPx}"` : '',
- hPx ? `data-height="${hPx}"` : '',
- ]
- .filter(Boolean)
- .join(' ');
- return `<script async src="${origin}/embed.js" ${dataAttrs}></` + 'script>';
- }
-
- const attrs = [];
- // Always emit a src so the snippet renders the same avatar the editor
- // is previewing. Falls back to the default avatar when the user hasn't
- // picked anything yet.
- attrs.push(`src="${escapeAttr(state.src || DEFAULT_PREVIEW_SRC)}"`);
- if (state.mode && state.mode !== 'inline') attrs.push(`mode="${state.mode}"`);
- if (state.mode === 'floating') {
- if (state.position !== 'bottom-right') attrs.push(`position="${state.position}"`);
- if (state.offset && state.offset !== '24px 24px')
- attrs.push(`offset="${state.offset}"`);
- }
-
- const wPx = parsePx(state.width);
- const hPx = parsePx(state.height);
- const preset = state.responsivePreset;
- if (preset !== 'fixed' && wPx && hPx) {
- // Emit clamp() CSS custom properties on the style attribute
- const wMin = Math.round(Math.max(160, wPx * 0.65));
- const hMin = Math.round(Math.max(200, hPx * 0.65));
- const wVw = Math.round((wPx / 1440) * 100);
- const hVh = Math.round((hPx / 900) * 100);
- const wClamp = `clamp(${wMin}px, ${wVw}vw, ${wPx}px)`;
- const hClamp = `clamp(${hMin}px, ${hVh}vh, ${hPx}px)`;
- attrs.push(`style="--agent-width: ${wClamp}; --agent-height: ${hClamp};"`);
- attrs.push(`responsive`);
+ const host = el('div', { className: 'ee-host' });
+ const src = cfg.mode === 'chat' ? chatSrc(cfg, true) : walkSrc(cfg, /* preview */ true);
+ const iframe = el('iframe', {
+ className: 'ee-iframe',
+ src,
+ title: cfg.mode === 'chat' ? 'Agent chat preview' : 'Walking avatar preview',
+ loading: 'lazy',
+ allow: cfg.mode === 'chat' ? 'microphone; autoplay; clipboard-write' : 'accelerometer; gyroscope; autoplay',
+ style: {
+ width: `${cfg.width}px`,
+ height: `${cfg.height}px`,
+ maxWidth: '100%',
+ maxHeight: '100%',
+ borderRadius: '16px',
+ },
+ });
+ host.appendChild(iframe);
+ previewFrame.appendChild(host);
+ previewEl = host;
+ }
+
+ function reflectUrl() {
+ const url = new URL(location.href);
+ const q = url.searchParams;
+ q.set('mode', cfg.mode);
+ if (cfg.avatar) q.set('avatar', cfg.avatar); else q.delete('avatar');
+ q.set('width', String(cfg.width));
+ q.set('height', String(cfg.height));
+ if (cfg.mode !== 'chat') {
+ q.set('env', cfg.env);
+ q.set('bg', cfg.bg);
} else {
- if (state.width) attrs.push(`width="${state.width}"`);
- if (state.height) attrs.push(`height="${state.height}"`);
- attrs.push(`responsive="false"`);
- }
-
- // Kiosk by default — emit it unless the user explicitly opts INTO the
- // chat UI. This gives a clean "just the 3D avatar" embed out of the
- // box; users who want a chat panel can flip the toggle.
- if (!state.showChat) attrs.push(`kiosk`);
- if (state.voice === false) attrs.push(`voice="off"`);
- if (state.cameraControls) attrs.push(`camera-controls`);
- if (state.ar) attrs.push(`ar`);
- // Background — default is transparent so the avatar floats over the host
- // page without a coloured box behind it. Users can pick Dark / Light if
- // they want a contained widget instead.
- attrs.push(`background="${escapeAttr(state.background || 'transparent')}"`);
-
- // Add optional attributes for customization
- if (state.agentId) attrs.push(`agent-id="${escapeAttr(state.agentId)}"`);
- if (state.namePlate === 'off') attrs.push(`name-plate="off"`);
-
- // Add style vars for accent color and border radius
- const styleVars = [];
- if (state.accentColor && state.accentColor !== '#3b82f6') {
- styleVars.push(`--agent-accent:${state.accentColor}`);
- }
- if (state.borderRadius && state.borderRadius !== '16px') {
- styleVars.push(`--agent-bubble-radius:${state.borderRadius}`);
+ q.delete('env'); q.delete('bg');
}
- if (styleVars.length) {
- // Merge with existing style attr if present
- const existingStyleIdx = attrs.findIndex(a => a.startsWith('style="'));
- const newStyle = styleVars.join(';');
- if (existingStyleIdx >= 0) {
- attrs[existingStyleIdx] = attrs[existingStyleIdx].replace(/"$/, `;${newStyle}"`);
- } else {
- attrs.push(`style="${newStyle}"`);
- }
- }
-
- const script = `<script type="module" async src="${AGENT_3D_HOST}/agent-3d/${AGENT_3D_VERSION}/agent-3d.js"></` + 'script>';
- const element = `<agent-3d ${attrs.join(' ')}></agent-3d>`;
- let snippet = `${script}\n${element}`;
-
- // Add inline script for default animation if specified
- if (state.defaultClip && !state.widgetId) {
- const loop = state.defaultClipLoop !== false ? 'true' : 'false';
- snippet += `\n<script>(function(){var a=document.currentScript.previousElementSibling;if(a)a.addEventListener('agent:ready',function(){a.play?.('${escapeAttr(state.defaultClip)}',{loop:${loop}});});})();<\/script>`;
- }
-
- if (preset !== 'fixed') {
- snippet = `<!-- generated responsive styles -->\n${snippet}`;
- }
- return snippet;
- }
-
- function writeSnippet() {
- snippetEl.textContent = buildSnippet();
- }
-
- // Build a standalone HTML page that renders the current snippet against a
- // minimal landing-page mock — opened in a new tab by "Open in new tab" so
- // demos can show the embed working in isolation. The script tag URL is
- // swapped to the local dev module when running on localhost so the new
- // tab actually loads (the production CDN path is not routed by Vite).
- function buildStandalonePage() {
- const snippet = buildSnippet();
- const isLocal = /^(localhost|127\.|0\.0\.0\.0|\[?::1\]?)/i.test(location.hostname);
- const localScript = `<script type="module" src="${location.origin}/src/element.js"></` + 'script>';
- // Rewrite ALL relative URLs (src="/...", any "/...glb", etc.) inside the
- // snippet to absolute so they resolve against the live origin instead
- // of the blob: document we're about to open the page from. Blob URLs
- // have no base, so a bare "/avatars/cz.glb" would otherwise hit the
- // Failed-to-parse-URL errors the user saw in the console.
- let wireSnippet = isLocal && !state.widgetId
- ? snippet.replace(
- /<script[^>]*src="[^"]*agent-3d\/[^"]+\/agent-3d\.js"[^>]*><\/script>/,
- localScript,
- )
- : snippet;
- // Rewrite any remaining relative src="/foo" → src="${origin}/foo".
- wireSnippet = wireSnippet.replace(
- /(\s)(src|href)="\/([^"]*)"/g,
- `$1$2="${location.origin}/$3"`,
- );
- const title = `Embed preview — ${state.src || state.widgetId || 'agent'}`;
- return `<!doctype html>
-<html lang="en">
-<head>
-<meta charset="utf-8">
-<!-- Anchor relative URLs (fetches inside agent-3d, e.g. /three.svg, /avatars/*.glb)
- against the live origin. Required because this page is served from a blob:
- URL which has no base for resolving "/..." URLs. -->
-<base href="${location.origin}/">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<title>${escapeHtml(title)}</title>
-<style>
- html, body { margin: 0; padding: 0; min-height: 100vh; font: 15px/1.5 ui-sans-serif, system-ui, sans-serif; color: #0f172a; background: #f8fafc; }
- .nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 48px; border-bottom: 1px solid #e5e7eb; background: rgba(255,255,255,0.92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 1; }
- .brand { display: flex; align-items: center; gap: 10px; font: 700 17px/1 system-ui; }
- .logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #ffffff, #ffffff); box-shadow: 0 2px 8px rgba(99,102,241,0.4); }
- .hero { max-width: 960px; margin: 0 auto; padding: 80px 48px 48px; text-align: center; }
- .pill { display: inline-block; padding: 6px 14px; border-radius: 999px; background: #ede9fe; color: #6d28d9; font: 600 12px system-ui; margin-bottom: 22px; }
- h1 { font: 800 52px/1.1 system-ui; letter-spacing: -0.02em; margin: 0 0 18px; }
- h1 .accent { background: linear-gradient(90deg, #ffffff, #ec4899); -webkit-background-clip: text; background-clip: text; color: transparent; }
- .lede { font-size: 18px; color: #475569; max-width: 640px; margin: 0 auto 28px; }
- .cta { display: flex; gap: 12px; justify-content: center; }
- .btn-primary { background: #0f172a; color: white; padding: 12px 22px; border-radius: 10px; font: 600 14px system-ui; }
- .btn-ghost { background: white; color: #0f172a; padding: 12px 22px; border-radius: 10px; font: 600 14px system-ui; border: 1px solid #e5e7eb; }
- footer { padding: 48px; text-align: center; color: #94a3b8; font-size: 13px; }
- footer code { background: #e2e8f0; padding: 2px 6px; border-radius: 4px; color: #334155; font: 12px ui-monospace, Menlo, monospace; }
-</style>
-</head>
-<body>
- <nav class="nav">
- <div class="brand"><div class="logo"></div>Acme</div>
- <div class="btn-primary" style="padding: 8px 16px; font-size: 13px;">Sign in</div>
- </nav>
- <section class="hero">
- <div class="pill">Preview · live snippet</div>
- <h1>Your <span class="accent">agent embed</span><br>on a real page.</h1>
- <p class="lede">This page renders the exact snippet from the editor. Resize, scroll, and click around to see how it behaves in production.</p>
- <div class="cta">
- <div class="btn-primary">Start free</div>
- <div class="btn-ghost">See it live</div>
- </div>
- </section>
- <footer>
- Generated by the three.ws embed editor — close this tab to return.
- </footer>
-
- <!-- ── Embed snippet ── -->
- ${wireSnippet}
-</body>
-</html>`;
+ if (cfg.mode === 'walking') { q.set('controls', cfg.controls); q.set('autoplay', String(cfg.autoplay)); }
+ else { q.delete('controls'); q.delete('autoplay'); }
+ history.replaceState(null, '', url);
}
- function escapeHtml(s) {
- return String(s)
- .replace(/&/g, '&amp;')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;')
- .replace(/"/g, '&quot;')
- .replace(/'/g, '&#39;');
- }
+ sync();
+}
- const deviceViewport = $('#device-viewport');
- function syncDevice() {
- const device = DEVICES.find((d) => d.id === state.device) || DEVICES[0];
- for (const btn of $$('.device-btn')) {
- btn.setAttribute('aria-pressed', String(btn.dataset.device === state.device));
- }
+// ── URL + snippet builders (pure) ──────────────────────────────────────────
+
+function walkSrc(cfg, preview = false) {
+ const u = new URL(`${ORIGIN}/walk-embed`);
+ const q = u.searchParams;
+ if (cfg.avatar) q.set('avatar', cfg.avatar);
+ // Mode → control + autoplay mapping.
+ if (cfg.mode === 'walking') {
+ q.set('controls', cfg.controls);
+ if (cfg.autoplay) q.set('autoplay', 'true');
+ } else if (cfg.mode === 'idle') {
+ q.set('controls', 'none');
+ q.set('autoplay', 'true');
+ } else { // static
+ q.set('controls', 'none');
+ q.set('autoplay', 'false');
+ }
+ if (cfg.bg && cfg.bg !== 'transparent') q.set('bg', cfg.bg);
+ if (cfg.env && cfg.env !== 'studio') q.set('env', cfg.env);
+ // Preview frames load over the dev/local origin so the iframe actually
+ // renders here; the copied snippet always points at the production origin.
+ if (preview) return u.toString().replace(ORIGIN, location.origin);
+ return u.toString();
+}
- // Reset placeholder/iframe inline styles — earlier versions of this code
- // scaled them individually; the viewport now owns the transform.
- const placeholder = $('#placeholder');
- if (placeholder) placeholder.style.cssText = '';
- const iframe = $('#preview-frame');
- if (iframe) iframe.style.cssText = '';
+function chatSrc(cfg, preview = false) {
+ // The agent's standalone chat page, embed-chromed. Real, existing route
+ // (vercel.json maps /a/(.*)). Same URL drives the preview and the snippet.
+ const base = preview ? location.origin : ORIGIN;
+ return `${base}/a/${encodeURIComponent(cfg.avatar)}?embed=1`;
+}
- if (state.device === 'desktop') {
- deviceViewport.style.cssText = '';
- deviceViewport.dataset.device = 'desktop';
- stage.removeAttribute('data-device');
- return;
- }
+function buildSnippet(cfg) {
+ // No avatar yet → return guidance instead of a copyable-but-broken snippet.
+ if (!cfg.avatar) {
+ return cfg.mode === 'chat'
+ ? '<!-- Enter an agent ID above to generate the chat embed snippet -->'
+ : '<!-- Enter an avatar ID above to generate the embed snippet -->';
+ }
+ if (cfg.mode === 'chat') {
+ return `<iframe\n src="${chatSrc(cfg)}"\n width="${cfg.width}"\n height="${cfg.height}"\n style="border:0;border-radius:16px"\n allow="microphone; autoplay; clipboard-write"\n loading="lazy"><\/iframe>`;
+ }
+ if (cfg.snippetVariant === 'script') {
+ const attrs = [
+ `src="${ORIGIN}/walk-embed-sdk.js"`,
+ `data-avatar="${esc(cfg.avatar)}"`,
+ cfg.mode === 'walking' ? `data-controls="${cfg.controls}"` : `data-controls="none"`,
+ cfg.bg !== 'transparent' ? `data-bg="${cfg.bg}"` : null,
+ cfg.env !== 'studio' ? `data-env="${cfg.env}"` : null,
+ autoplayFor(cfg) ? `data-autoplay="true"` : null,
+ `data-width="${cfg.width}"`,
+ `data-height="${cfg.height}"`,
+ ].filter(Boolean);
+ return `<script\n ${attrs.join('\n ')}><\/script>`;
+ }
+ // iframe variant
+ const src = walkSrc(cfg);
+ return `<iframe\n src="${src}"\n width="${cfg.width}"\n height="${cfg.height}"\n style="border:0;border-radius:16px"\n allow="accelerometer; gyroscope; autoplay"\n loading="lazy"><\/iframe>`;
+}
- // Scale the device viewport (which contains placeholder, iframe, AND the
- // agent wrap) so everything moves together. The wrap stays positioned
- // relative to the viewport, so a floating bubble at bottom-right of a
- // 768×1024 tablet appears at the tablet's bottom-right corner instead
- // of leaking out into the stage.
- const stageRect = stage.getBoundingClientRect();
- const stageW = stageRect.width || stage.offsetWidth;
- const stageH = stageRect.height || stage.offsetHeight;
- const scaleX = stageW / device.w;
- const scaleY = stageH / device.h;
- const scale = Math.min(scaleX, scaleY, 1) * 0.9;
- const frameW = device.w * scale;
- const frameH = device.h * scale;
- const offsetX = (stageW - frameW) / 2;
- const offsetY = (stageH - frameH) / 2;
+function autoplayFor(cfg) {
+ if (cfg.mode === 'idle') return true;
+ if (cfg.mode === 'static') return false;
+ return cfg.autoplay;
+}
- deviceViewport.style.cssText = `
- position: absolute;
- top: ${offsetY}px;
- left: ${offsetX}px;
- width: ${device.w}px;
- height: ${device.h}px;
- transform: scale(${scale});
- transform-origin: top left;
- `;
- deviceViewport.dataset.device = state.device;
- stage.setAttribute('data-device', state.device);
- }
+// ── helpers ────────────────────────────────────────────────────────────────
+
+function sanitize(opts) {
+ const out = {};
+ if (opts.mode && MODES.some((m) => m.id === opts.mode)) out.mode = opts.mode;
+ if (opts.avatar) out.avatar = String(opts.avatar).trim();
+ if (opts.controls && CONTROL_OPTIONS.includes(opts.controls)) out.controls = opts.controls;
+ if (opts.env && ENV_OPTIONS.some((e) => e.id === opts.env)) out.env = opts.env;
+ if (opts.bg) out.bg = opts.bg;
+ if (opts.width) out.width = clampDim(opts.width);
+ if (opts.height) out.height = clampDim(opts.height);
+ if (opts.width || opts.height) out.size = 'custom';
+ if (opts.autoplay != null && opts.autoplay !== '') out.autoplay = opts.autoplay === true || opts.autoplay === 'true';
+ return out;
+}
- function parsePx(val) {
- if (!val) return 0;
- const m = String(val).match(/^([\d.]+)px$/);
- return m ? parseFloat(m[1]) : 0;
- }
+function clampDim(v) {
+ const n = parseInt(v, 10);
+ if (!Number.isFinite(n)) return 320;
+ return Math.max(120, Math.min(1200, n));
+}
- function sync() {
- syncPositionButtons();
- syncModeCards();
- applyToPreview();
- applyAgentAttrs();
- applyGlow();
- syncDevice();
- writeSnippet();
- }
+function esc(s) {
+ return String(s).replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+}
- function snapToCorner(x, y, w, h, stageW, stageH) {
- const SNAP = 48;
- const corners = [
- { corner: 'top-left', cx: 0, cy: 0 },
- { corner: 'top-right', cx: stageW - w, cy: 0 },
- { corner: 'bottom-left', cx: 0, cy: stageH - h },
- { corner: 'bottom-right', cx: stageW - w, cy: stageH - h },
- { corner: 'top-center', cx: (stageW - w) / 2, cy: 0 },
- { corner: 'bottom-center', cx: (stageW - w) / 2, cy: stageH - h },
- ];
- for (const c of corners) {
- if (Math.abs(x - c.cx) < SNAP && Math.abs(y - c.cy) < SNAP) {
- // Compute offsets from nearest edge
- const offV = c.corner.startsWith('top')
- ? `${Math.round(c.cy)}px`
- : `${Math.round(stageH - h - c.cy)}px`;
- const offH = c.corner.endsWith('left')
- ? `${Math.round(c.cx)}px`
- : c.corner.endsWith('right')
- ? `${Math.round(stageW - w - c.cx)}px`
- : '0px';
- return { x: c.cx, y: c.cy, corner: c.corner, offsetV: offV, offsetH: offH };
- }
+function injectStyles() {
+ if (document.getElementById('ee-styles')) return;
+ const s = el('style', { id: 'ee-styles' });
+ s.textContent = `
+ .embed-editor { display:grid; grid-template-columns:minmax(300px,380px) 1fr; height:100vh; }
+ .embed-editor *, .embed-editor *::before, .embed-editor *::after { box-sizing:border-box; }
+ .ee-panel { padding:24px; border-right:1px solid #1c2026; overflow-y:auto; background:#0d0f12; }
+ .ee-title { font-size:18px; margin:0 0 4px; font-weight:700; }
+ .ee-subtitle { font-size:13px; color:#71717a; margin:0 0 22px; line-height:1.5; }
+ .ee-field { display:block; margin-bottom:16px; }
+ .ee-label { display:block; font-size:12px; color:#a1a1aa; margin-bottom:7px; font-weight:600; }
+ .ee-hint { font-size:12px; color:#71717a; margin:-8px 0 16px; min-height:16px; line-height:1.4; }
+ .embed-editor input[type=text], .embed-editor input[type=number], .embed-editor select {
+ width:100%; padding:9px 11px; background:#15181d; border:1px solid #2a2f37;
+ border-radius:8px; color:#fff; font-size:13px; outline:none; font-family:inherit;
+ transition:border-color .15s ease;
+ }
+ .embed-editor input:focus, .embed-editor select:focus { border-color:#6366f1; }
+ .ee-segment { display:flex; gap:6px; background:#121519; border:1px solid #21262e; border-radius:10px; padding:4px; }
+ .ee-segment-sm { gap:4px; }
+ .ee-seg-btn {
+ flex:1; padding:8px 10px; background:transparent; border:none; border-radius:7px;
+ color:#a1a1aa; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit;
+ transition:background .15s ease, color .15s ease; white-space:nowrap;
+ }
+ .ee-seg-btn:hover { color:#e4e4e7; }
+ .ee-seg-btn:focus-visible { outline:2px solid #6366f1; outline-offset:2px; }
+ .ee-seg-btn.is-active { background:#6366f1; color:#fff; }
+ .ee-bgrow { display:flex; align-items:center; gap:10px; }
+ .ee-bgsep { flex:1; }
+ .ee-checklabel { font-size:13px; color:#d4d4d8; cursor:pointer; }
+ .embed-editor input[type=color] { width:44px; height:34px; padding:2px; background:#15181d; border:1px solid #2a2f37; border-radius:8px; cursor:pointer; }
+ .embed-editor input[type=color]:disabled { opacity:.4; cursor:not-allowed; }
+ .embed-editor input[type=checkbox] { width:16px; height:16px; accent-color:#6366f1; cursor:pointer; }
+ .ee-dimrow { display:flex; gap:10px; }
+ .ee-dim { display:flex; align-items:center; gap:6px; flex:1; }
+ .ee-dim-label { font-size:12px; color:#71717a; font-weight:600; }
+ .ee-preview-wrap { padding:24px; display:flex; flex-direction:column; gap:14px; overflow:hidden; }
+ .ee-bar { display:flex; align-items:center; justify-content:space-between; gap:12px; }
+ .ee-bar-title { font-size:12px; color:#a1a1aa; font-weight:600; }
+ .ee-bar-note { font-size:11px; color:#52525b; }
+ .ee-variant { flex:0 0 auto; }
+ .ee-variant .ee-seg-btn { padding:5px 12px; font-size:12px; }
+ .ee-stage {
+ flex:1; border-radius:14px; border:1px solid #1c2026;
+ background:
+ radial-gradient(circle at 30% 20%, #14181f 0, #08090b 60%),
+ repeating-conic-gradient(#0c0e11 0% 25%, #0a0b0e 0% 50%) 50% / 28px 28px;
+ position:relative; overflow:hidden; min-height:300px;
+ display:flex; align-items:center; justify-content:center;
+ }
+ .ee-host { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }
+ .ee-iframe { border:0; background:transparent; }
+ .ee-empty { color:#52525b; font-size:13px; text-align:center; max-width:240px; line-height:1.5; }
+ .ee-snippet {
+ width:100%; background:#0d0f12; border:1px solid #1c2026; border-radius:10px;
+ color:#d4d4d8; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12px;
+ padding:12px; resize:none; line-height:1.5; outline:none; min-height:108px;
+ }
+ .ee-snippet:focus { border-color:#2a3340; }
+ .ee-copy {
+ align-self:flex-start; padding:10px 20px; background:#6366f1; border:none; border-radius:9px;
+ color:#fff; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit;
+ transition:background .15s ease, transform .1s ease;
+ }
+ .ee-copy:hover { background:#4f52e0; }
+ .ee-copy:active { transform:translateY(1px); }
+ .ee-copy.is-ok { background:#22c55e; }
+ @media (max-width:860px) {
+ .embed-editor { grid-template-columns:1fr; height:auto; }
+ .ee-panel { border-right:none; border-bottom:1px solid #1c2026; }
+ .ee-stage { min-height:360px; }
}
- return { x, y };
- }
-
- function escapeAttr(s) {
- return String(s).replace(/"/g, '&quot;');
- }
-
- sync();
- return { state, host };
+ `;
+ document.head.appendChild(s);
}
+
+export { mountEmbedEditor };
diff --git a/src/walk-embed.js b/src/walk-embed.js
index 5295b7aae..9280330b7 100644
--- a/src/walk-embed.js
+++ b/src/walk-embed.js
@@ -5,7 +5,7 @@
// • No multiplayer (WalkNet) — embeds don't connect strangers to a room.
// • No AR camera passthrough — embed hosts can't grant getUserMedia.
// • No HUD card, no help text, no online pill.
-// • Reads ?bg, ?controls, ?autoplay query params.
+// • Reads ?bg, ?controls, ?autoplay, ?env, ?ground, ?orbit query params.
// • postMessage's `walk:ready` on load and `walk:position` each tick.
//
// If you find yourself fixing the same bug here and in walk.js, consider
@@ -19,6 +19,7 @@ import {
Clock,
Color,
DirectionalLight,
+ Fog,
Group,
HemisphereLight,
Mesh,
@@ -26,7 +27,6 @@ import {
PCFSoftShadowMap,
PerspectiveCamera,
PMREMGenerator,
- Quaternion,
Scene,
ShadowMaterial,
Vector3,
@@ -47,6 +47,20 @@ const CONTROLS = (params.get('controls') || 'joystick').toLowerCase(); // 'joyst
const AUTOPLAY = params.get('autoplay') === 'true' || params.get('autoplay') === '1';
const SHOW_GROUND = params.get('ground') !== 'false';
const ORBIT_ENABLED = params.get('orbit') !== 'false';
+const ENV_PARAM = (params.get('env') || 'studio').toLowerCase();
+
+// Real, self-contained scene presets. Each preset retints the clear color,
+// fog, ground disc, and the hemisphere/sun lights — no external HDRIs to
+// fetch, so the embed stays a single iframe with no extra requests. An
+// explicit ?bg= always overrides the preset's background (see applyEnvironment).
+const ENVIRONMENTS = {
+ studio: { bg: null, ground: 0x202833, hemiSky: 0xbcd6ff, hemiGround: 0x202830, hemiInt: 0.6, sun: 0xffffff, sunInt: 1.4, fog: null },
+ void: { bg: 0x08090b, ground: 0x101218, hemiSky: 0x3a4250, hemiGround: 0x0a0c0f, hemiInt: 0.5, sun: 0xcdd6ff, sunInt: 1.1, fog: null },
+ beach: { bg: 0x86c5ff, ground: 0xe2c98a, hemiSky: 0xcfeaff, hemiGround: 0xb89968, hemiInt: 0.9, sun: 0xfff2d6, sunInt: 1.7, fog: [0x86c5ff, 16, 44] },
+ sunset: { bg: 0xff9d6e, ground: 0x4a3340, hemiSky: 0xffc59e, hemiGround: 0x2a1f33, hemiInt: 0.8, sun: 0xffcaa0, sunInt: 1.6, fog: [0xff9d6e, 14, 42] },
+ night: { bg: 0x0a1020, ground: 0x141a28, hemiSky: 0x2a3a66, hemiGround: 0x05070d, hemiInt: 0.45, sun: 0x9fb4ff, sunInt: 0.8, fog: [0x0a1020, 16, 46] },
+ grid: { bg: 0x0d0f12, ground: 0x1a1f2a, hemiSky: 0x4a5a80, hemiGround: 0x0d0f12, hemiInt: 0.7, sun: 0xffffff, sunInt: 1.3, fog: null },
+};
function resolveAvatarUrl() {
const id = params.get('avatar');
@@ -165,11 +179,33 @@ groundShadowCatcher.receiveShadow = true;
groundShadowCatcher.visible = !SHOW_GROUND;
scene.add(groundShadowCatcher);
+// Apply a scene preset. An explicit ?bg= wins over the preset background so
+// transparent/custom embeds keep working; otherwise the preset paints the
+// clear color and matching fog. Live-swappable via the `walk:setEnv` message.
+function applyEnvironment(id) {
+ const env = ENVIRONMENTS[id] || ENVIRONMENTS.studio;
+ if (BG_PARAM && BG_PARAM !== 'transparent') {
+ renderer.setClearColor(new Color(BG_PARAM), 1);
+ } else if (env.bg == null) {
+ renderer.setClearColor(0x000000, 0); // transparent — host page shows through
+ } else {
+ renderer.setClearColor(new Color(env.bg), 1);
+ document.body.style.background = `#${env.bg.toString(16).padStart(6, '0')}`;
+ }
+ scene.fog = env.fog ? new Fog(env.fog[0], env.fog[1], env.fog[2]) : null;
+ groundOpaque.material.color.setHex(env.ground);
+ hemi.color.setHex(env.hemiSky);
+ hemi.groundColor.setHex(env.hemiGround);
+ hemi.intensity = env.hemiInt;
+ sun.color.setHex(env.sun);
+ sun.intensity = env.sunInt;
+}
+applyEnvironment(ENV_PARAM);
+
const camera = new PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.05, 200);
const avatarRig = new Group();
scene.add(avatarRig);
-const camTarget = new Vector3();
const camDesired = new Vector3();
const camLookTarget = new Vector3();
const camLookCurrent = new Vector3();
@@ -545,6 +581,8 @@ window.addEventListener('message', async (e) => {
// Walk speed multiplier — applied to input magnitude each frame
input._speedMultiplier = Math.max(0.3, Math.min(3, msg.speed));
}
+ } else if (msg.type === 'walk:setEnv' && typeof msg.env === 'string') {
+ applyEnvironment(msg.env.toLowerCase());
}
});
diff --git a/vercel.json b/vercel.json
index 7d82e671e..de15cfd0e 100644
--- a/vercel.json
+++ b/vercel.json
@@ -39,6 +39,10 @@
"includeFiles": "src/solana/vanity/wasm/**,examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json",
"maxDuration": 60
},
+ "api/x402/pump-launch.js": {
+ "includeFiles": "examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json",
+ "maxDuration": 60
+ },
"api/**/*.js": {
"includeFiles": "examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json",
"maxDuration": 30