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.

fix(gltf-inspect): register the meshopt decoder so compressed GLBs inspect

nirholas06057b5b4a10
diff --git a/src/gltf-inspect.js b/src/gltf-inspect.js
index 7d40baad4..162e9da7c 100644
--- a/src/gltf-inspect.js
+++ b/src/gltf-inspect.js
@@ -16,8 +16,39 @@ function isGLB(bytes) {
return view.getUint32(0, true) === GLB_MAGIC;
}
-async function readDocument(bytes) {
+// EXT_meshopt_compression is registered by ALL_EXTENSIONS but cannot DECODE
+// without its wasm decoder wired in as a glTF-Transform dependency. Every
+// three.ws avatar optimized by the GLB pipeline ships meshopt-compressed, so
+// without this the inspector threw
+// [EXT_meshopt_compression] Please install extension dependency, "meshopt.decoder"
+// on the majority of real models (the paid /api/x402/model-check route turned
+// that into a 422 on michelle/xbot/cz/realistic-male/dancing-twerk).
+// Loaded lazily so the browser /validation bundle only pays for the decoder
+// when a compressed model actually arrives, and memoized per process.
+let _meshoptDecoderPromise = null;
+function loadMeshoptDecoder() {
+ if (!_meshoptDecoderPromise) {
+ _meshoptDecoderPromise = import('meshoptimizer')
+ .then(async (mod) => {
+ const decoder = mod.MeshoptDecoder;
+ if (!decoder) return null;
+ if (decoder.ready) await decoder.ready;
+ return decoder;
+ })
+ .catch(() => null);
+ }
+ return _meshoptDecoderPromise;
+}
+
+async function createIO() {
const io = new WebIO().registerExtensions(ALL_EXTENSIONS);
+ const decoder = await loadMeshoptDecoder();
+ if (decoder) io.registerDependencies({ 'meshopt.decoder': decoder });
+ return io;
+}
+
+async function readDocument(bytes) {
+ const io = await createIO();
if (isGLB(bytes)) return io.readBinary(bytes);
// Fall back to JSON glTF (rare, usually requires external buffers we don't have).
const text = new TextDecoder().decode(bytes);