Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(render): expose the baked clip library through the package entry point
nirholas73d5495a1f2f
diff --git a/packages/render/src/clips.js b/packages/render/src/clips.jsnew file mode 100644index 000000000..21773cd3b--- /dev/null+++ b/packages/render/src/clips.js@@ -0,0 +1,42 @@+/**+ * Animation clips from JSON.+ * --------------------------+ * three.ws ships its motion library as serialized AnimationClips+ * (`/animations/clips/<name>.json`), not as GLBs. Parsing them here means a+ * server render can pose an avatar with any clip in the library without+ * fetching a second model, and it costs one JSON parse.+ */++import './env-shim.js';+import * as THREE from 'three';++/**+ * Parse a serialized three.js AnimationClip.+ * @param {object|string} source clip JSON, or its text+ * @returns {THREE.AnimationClip}+ */+export function parseClipJson(source) {+ const json = typeof source === 'string' ? JSON.parse(source) : source;+ if (!json || !Array.isArray(json.tracks)) throw new Error('not an AnimationClip: no tracks array');+ const clip = THREE.AnimationClip.parse(json);+ if (!clip.name) clip.name = json.name || 'clip';+ return clip;+}++/**+ * Fetch and parse a clip by URL.+ * @param {string} url+ * @param {{fetchImpl?: typeof fetch, timeoutMs?: number}} [options]+ */+export async function loadClipJson(url, { fetchImpl, timeoutMs = 15_000 } = {}) {+ const doFetch = fetchImpl || globalThis.fetch;+ const controller = new AbortController();+ const timer = setTimeout(() => controller.abort(), timeoutMs);+ try {+ const res = await doFetch(url, { signal: controller.signal });+ if (!res.ok) throw new Error(`clip fetch failed: ${res.status} ${res.statusText}`);+ return parseClipJson(await res.json());+ } finally {+ clearTimeout(timer);+ }+}diff --git a/packages/render/src/index.js b/packages/render/src/index.jsindex 109ebac74..d1050d68f 100644--- a/packages/render/src/index.js+++ b/packages/render/src/index.js@@ -22,6 +22,7 @@ export { toHalfBlocks, toKitty, toITerm, detectTerminal, to256, CURSOR } from '.export { decodeImage, decodePng, buildMipmaps } from './image.js';export { parseGlb, packGlb, extractImages, stripImages } from './glb.js';export { retargetClip, normalizeBoneName } from './retarget.js';+export { parseClipJson, loadClipJson } from './clips.js';import { AvatarModel } from './model.js';import { loadModel } from './load.js';