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
fix(viewer,wallet): load the vendored draco and ktx2 decoders from our own origin, and price a wallet's tokens through the fallback chain when the batch feed misses
nirholas875cb177bec7
diff --git a/src/shared/wallet-networth.js b/src/shared/wallet-networth.jsindex 8426210b5..4ea1e5926 100644--- a/src/shared/wallet-networth.js+++ b/src/shared/wallet-networth.js@@ -24,7 +24,7 @@* influence the look generically, by their real USD proportion — never by name.*/-import { getSolPriceUsd } from './usd-price.js';+import { getSolPriceUsd, getTokenPriceUsd } from './usd-price.js';// $THREE — the only coin three.ws features. Holding it earns the brand accent.export const THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';@@ -39,6 +39,8 @@ const USDC_MINT_BY_CLUSTER = {};const JUP_PRICE_URL = 'https://lite-api.jup.ag/price/v3';+// A wallet card must not wait on a stalled price feed; unpriced reads as $0.+const PRICE_TIMEOUT_MS = 5_000;const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;// ── Tiers ───────────────────────────────────────────────────────────────────@@ -96,17 +98,34 @@ async function priceMints(mints, network) {else need.push(m);}if (!need.length) return out;+ // One batched Jupiter call is the cheap path (a whole wallet in one request).+ // Anything it does not price falls back to the shared per-mint chain+ // (DexScreener, GeckoTerminal, DefiLlama), so a Jupiter outage or a token it+ // has never indexed no longer silently reports a funded wallet as $0.+ let priced = new Set();try {- const r = await fetch(`${JUP_PRICE_URL}?ids=${encodeURIComponent(need.join(','))}`);+ const r = await fetch(`${JUP_PRICE_URL}?ids=${encodeURIComponent(need.join(','))}`, {+ signal: AbortSignal.timeout(PRICE_TIMEOUT_MS),+ });if (r.ok) {const data = await r.json();for (const m of need) {const p = data?.[m]?.usdPrice ?? data?.[m]?.price ?? null;- if (Number(p) > 0) out.set(m, Number(p));+ if (Number(p) > 0) {+ out.set(m, Number(p));+ priced.add(m);+ }}}} catch {- /* feed down — those mints stay unpriced ($0); SOL still prices below */+ /* batch feed down: every mint falls through to the per-mint chain below */+ }+ const missing = need.filter((m) => !priced.has(m));+ if (missing.length) {+ const resolved = await Promise.all(missing.map((m) => getTokenPriceUsd(m).catch(() => null)));+ missing.forEach((m, i) => {+ if (Number(resolved[i]) > 0) out.set(m, Number(resolved[i]));+ });}return out;}diff --git a/src/viewer/internal.js b/src/viewer/internal.jsindex cc3483296..fe362ab43 100644--- a/src/viewer/internal.js+++ b/src/viewer/internal.js@@ -6,6 +6,41 @@ export const Preset = { ASSET_GENERATOR: 'assetgenerator' };export const MANAGER = new LoadingManager();const THREE_PATH = `https://unpkg.com/three@0.${REVISION}.x`;+// Decoder binaries. scripts/copy-three-decoders.mjs vendors them into+// public/three/ on every install and audit-deploy-artifacts.mjs fails a deploy+// that ships without them, so the same-origin copy is the reliable source and+// unpkg is only the backstop. Resolving against import.meta.url rather than a+// site-absolute path is what makes this correct inside a third-party+// <agent-3d> embed: the URL points at the origin serving this module (three.ws),+// not at the embedding page's origin, where /three/* would 404.+const LOCAL_THREE_PATH = (() => {+ try {+ return new URL('../../three/', import.meta.url).href.replace(/\/$/, '');+ } catch {+ return '/three';+ }+})();++// One probe, memoised: does the vendored copy actually answer here? A stale+// deploy or a bundler that dropped public/three falls back to unpkg rather than+// failing every compressed model with an opaque decoder error.+let _decoderBase = null;+async function decoderBase() {+ if (_decoderBase) return _decoderBase;+ try {+ const res = await fetch(`${LOCAL_THREE_PATH}/draco/gltf/draco_decoder.wasm`, {+ method: 'HEAD',+ signal: AbortSignal.timeout(4000),+ });+ _decoderBase = res.ok+ ? { draco: `${LOCAL_THREE_PATH}/draco/gltf/`, basis: `${LOCAL_THREE_PATH}/basis/` }+ : { draco: `${THREE_PATH}/examples/jsm/libs/draco/gltf/`, basis: `${THREE_PATH}/examples/jsm/libs/basis/` };+ } catch {+ _decoderBase = { draco: `${THREE_PATH}/examples/jsm/libs/draco/gltf/`, basis: `${THREE_PATH}/examples/jsm/libs/basis/` };+ }+ return _decoderBase;+}+/*** Lazy, memoized setup of the Draco/KTX2/Meshopt decoders. Dynamically imports* each module the first time a model is loaded, so the first-paint bundle does@@ -20,13 +55,10 @@ export function getDecoders() {import('three/addons/loaders/DRACOLoader.js'),import('three/addons/loaders/KTX2Loader.js'),import('three/addons/libs/meshopt_decoder.module.js'),- ]).then(([dracoMod, ktx2Mod, meshoptMod]) => {- const dracoLoader = new dracoMod.DRACOLoader(MANAGER).setDecoderPath(- `${THREE_PATH}/examples/jsm/libs/draco/gltf/`,- );- const ktx2Loader = new ktx2Mod.KTX2Loader(MANAGER).setTranscoderPath(- `${THREE_PATH}/examples/jsm/libs/basis/`,- );+ decoderBase(),+ ]).then(([dracoMod, ktx2Mod, meshoptMod, base]) => {+ const dracoLoader = new dracoMod.DRACOLoader(MANAGER).setDecoderPath(base.draco);+ const ktx2Loader = new ktx2Mod.KTX2Loader(MANAGER).setTranscoderPath(base.basis);return { dracoLoader, ktx2Loader, meshoptDecoder: meshoptMod.MeshoptDecoder };});return _decodersPromise;