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(fetch-mixamo-catalog): add script to bulk-download Mixamo animation catalog

nirholas6dc7aee8210e
diff --git a/package.json b/package.json
index ddd3bcca5..3763c8fc8 100644
--- a/package.json
+++ b/package.json
@@ -51,6 +51,7 @@
"clean": "rm -rf dist/* dist-lib/* || true",
"generate-icons": "node scripts/generate-pwa-icons.mjs",
"fetch-animations": "node scripts/download-animations.mjs",
+ "fetch:mixamo-catalog": "node scripts/fetch-mixamo-catalog.mjs",
"test": "vitest run",
"test:pages": "node scripts/test-pages.mjs",
"test:all": "npm run test && npm run test:pages",
diff --git a/scripts/fetch-mixamo-catalog.mjs b/scripts/fetch-mixamo-catalog.mjs
new file mode 100644
index 000000000..8e5c4c353
--- /dev/null
+++ b/scripts/fetch-mixamo-catalog.mjs
@@ -0,0 +1,234 @@
+#!/usr/bin/env node
+// Bulk-download the Mixamo animation catalog as FBX (Without Skin) against Y-Bot.
+// Resumable: re-run to pick up where it left off. Concurrent retargets are
+// limited to be polite to Mixamo's servers.
+//
+// Usage:
+// MIXAMO_TOKEN=eyJ... node scripts/fetch-mixamo-catalog.mjs
+// # or put MIXAMO_TOKEN=... in .env.local
+//
+// Optional flags:
+// --concurrency=N parallel retarget jobs (default 3)
+// --limit=N stop after N successful downloads (default: all)
+// --character=UUID override Y-Bot character id
+
+import { mkdirSync, writeFileSync, existsSync, readFileSync, renameSync } from 'node:fs';
+import { join } from 'node:path';
+
+// ── Config ────────────────────────────────────────────────────────────────
+const Y_BOT_ID = '403e7206-d314-416a-9ef2-c618e26a8b6e';
+const API = 'https://www.mixamo.com/api/v1';
+const PAGE_LIMIT = 96;
+const POLL_INTERVAL_MS = 2000;
+const POLL_MAX_ATTEMPTS = 45;
+
+const args = Object.fromEntries(
+ process.argv.slice(2).map((a) => {
+ const m = a.match(/^--([^=]+)(?:=(.*))?$/);
+ return m ? [m[1], m[2] ?? true] : [a, true];
+ }),
+);
+
+const CONCURRENCY = Number(args.concurrency) || 3;
+const MAX_DOWNLOADS = args.limit ? Number(args.limit) : Infinity;
+const CHARACTER_ID = args.character || Y_BOT_ID;
+
+// ── Token loading (env or .env.local) ─────────────────────────────────────
+function loadToken() {
+ if (process.env.MIXAMO_TOKEN) return process.env.MIXAMO_TOKEN.trim();
+ const envPath = join(process.cwd(), '.env.local');
+ if (existsSync(envPath)) {
+ const line = readFileSync(envPath, 'utf8')
+ .split('\n')
+ .find((l) => l.startsWith('MIXAMO_TOKEN='));
+ if (line) return line.slice('MIXAMO_TOKEN='.length).trim().replace(/^["']|["']$/g, '');
+ }
+ return null;
+}
+
+const TOKEN = loadToken();
+if (!TOKEN) {
+ console.error('❌ MIXAMO_TOKEN not set. Add it to .env.local or pass as env var.');
+ console.error(' Get it from DevTools on mixamo.com → Application → localStorage → access_token');
+ process.exit(1);
+}
+
+const headers = {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${TOKEN}`,
+ 'X-Api-Key': 'mixamo2',
+};
+
+// ── Output paths ──────────────────────────────────────────────────────────
+const OUT_DIR = join(process.cwd(), 'public', 'animations', 'mixamo');
+const CATALOG_PATH = join(OUT_DIR, 'catalog.json');
+mkdirSync(OUT_DIR, { recursive: true });
+
+const catalog = existsSync(CATALOG_PATH)
+ ? JSON.parse(readFileSync(CATALOG_PATH, 'utf8'))
+ : { character_id: CHARACTER_ID, generated_at: null, animations: {} };
+
+function saveCatalog() {
+ catalog.generated_at = new Date().toISOString();
+ const tmp = `${CATALOG_PATH}.tmp`;
+ writeFileSync(tmp, JSON.stringify(catalog, null, 2));
+ renameSync(tmp, CATALOG_PATH);
+}
+
+// ── Helpers ───────────────────────────────────────────────────────────────
+const slugify = (s) =>
+ s
+ .toLowerCase()
+ .replace(/[^a-z0-9]+/g, '-')
+ .replace(/^-+|-+$/g, '')
+ .slice(0, 80);
+
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+
+async function api(path, init = {}) {
+ const res = await fetch(`${API}${path}`, { ...init, headers: { ...headers, ...init.headers } });
+ if (!res.ok) {
+ const body = await res.text().catch(() => '');
+ throw new Error(`HTTP ${res.status} ${path} ${body.slice(0, 200)}`);
+ }
+ return res.json();
+}
+
+// ── Step 1: list all Motion products across all pages ────────────────────
+async function listAllAnimations() {
+ const all = [];
+ let page = 1;
+ while (true) {
+ process.stdout.write(`\r📚 Listing animations: page ${page} (${all.length} so far)... `);
+ const data = await api(
+ `/products?page=${page}&limit=${PAGE_LIMIT}&type=Motion&order=relevance`,
+ );
+ const results = data.results || [];
+ all.push(...results);
+ const totalPages = data.pagination?.num_pages ?? Math.ceil((data.pagination?.num_results ?? 0) / PAGE_LIMIT);
+ if (!totalPages || page >= totalPages || results.length === 0) break;
+ page += 1;
+ await sleep(150);
+ }
+ process.stdout.write('\n');
+ return all;
+}
+
+// ── Step 2: retarget + poll + download a single animation ───────────────
+async function downloadOne(product) {
+ const slug = slugify(product.description || product.name || product.id);
+ const fbxPath = join(OUT_DIR, `${slug}.fbx`);
+
+ if (catalog.animations[product.id]?.file && existsSync(join(OUT_DIR, catalog.animations[product.id].file))) {
+ return { skipped: true, slug };
+ }
+
+ const exportRes = await fetch(`${API}/animations/export`, {
+ method: 'POST',
+ headers,
+ body: JSON.stringify({
+ character_id: CHARACTER_ID,
+ product_id: product.id,
+ product_name: product.description,
+ preferences: { format: 'fbx7', skin: 'false', fps: '30', reducekf: '0' },
+ }),
+ });
+ if (!exportRes.ok) throw new Error(`export ${exportRes.status}`);
+
+ let downloadUrl = null;
+ for (let i = 0; i < POLL_MAX_ATTEMPTS; i++) {
+ await sleep(POLL_INTERVAL_MS);
+ const status = await api(
+ `/animations/export/${product.id}?character_id=${CHARACTER_ID}`,
+ );
+ if (status.status === 'completed' && status.result?.url) {
+ downloadUrl = status.result.url;
+ break;
+ }
+ if (status.status === 'failed') throw new Error('retarget failed');
+ }
+ if (!downloadUrl) throw new Error('poll timeout');
+
+ const fileRes = await fetch(downloadUrl);
+ if (!fileRes.ok) throw new Error(`download ${fileRes.status}`);
+ const buf = Buffer.from(await fileRes.arrayBuffer());
+ writeFileSync(fbxPath, buf);
+
+ catalog.animations[product.id] = {
+ id: product.id,
+ name: product.description || product.name,
+ file: `${slug}.fbx`,
+ bytes: buf.length,
+ downloaded_at: new Date().toISOString(),
+ };
+ saveCatalog();
+
+ return { slug, bytes: buf.length };
+}
+
+// ── Step 3: concurrency-limited worker pool ─────────────────────────────
+async function runPool(products) {
+ let cursor = 0;
+ let ok = 0;
+ let fail = 0;
+ let skipped = 0;
+
+ async function worker(workerId) {
+ while (cursor < products.length && ok + fail < MAX_DOWNLOADS) {
+ const i = cursor++;
+ const product = products[i];
+ const label = `[${i + 1}/${products.length}]`;
+ try {
+ const result = await downloadOne(product);
+ if (result.skipped) {
+ skipped++;
+ console.log(`${label} ⏭ ${result.slug} (already downloaded)`);
+ } else {
+ ok++;
+ console.log(`${label} ✅ ${result.slug} (${(result.bytes / 1024).toFixed(0)} KB)`);
+ }
+ } catch (err) {
+ fail++;
+ console.warn(`${label} ❌ ${product.description}: ${err.message}`);
+ if (err.message.includes('HTTP 401') || err.message.includes('HTTP 403')) {
+ console.error('🛑 Auth failure — token expired. Refresh MIXAMO_TOKEN and re-run.');
+ process.exit(2);
+ }
+ }
+ }
+ }
+
+ const workers = Array.from({ length: CONCURRENCY }, (_, i) => worker(i));
+ await Promise.all(workers);
+ return { ok, fail, skipped };
+}
+
+// ── Main ──────────────────────────────────────────────────────────────────
+(async () => {
+ console.log(`🎬 Mixamo catalog fetcher`);
+ console.log(` Character: ${CHARACTER_ID}`);
+ console.log(` Output: ${OUT_DIR}`);
+ console.log(` Concurrency: ${CONCURRENCY}\n`);
+
+ const products = await listAllAnimations();
+ console.log(`📦 Catalog: ${products.length} animations\n`);
+
+ const t0 = Date.now();
+ const { ok, fail, skipped } = await runPool(products);
+ const mins = ((Date.now() - t0) / 60000).toFixed(1);
+
+ console.log(`\n═══════════════════════════════════════════`);
+ console.log(`✅ Downloaded: ${ok}`);
+ console.log(`⏭ Skipped: ${skipped}`);
+ console.log(`❌ Failed: ${fail}`);
+ console.log(`⏱ Time: ${mins} min`);
+ console.log(`📂 ${OUT_DIR}`);
+ console.log(`\nNext: convert FBX → GLB:`);
+ console.log(` for f in ${OUT_DIR}/*.fbx; do`);
+ console.log(` fbx2gltf -i "$f" -o "\${f%.fbx}.glb"`);
+ console.log(` done`);
+})().catch((err) => {
+ console.error('💥', err);
+ process.exit(1);
+});