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: integrate meshopt decoder for GLTFLoader across multiple modules
nrpo89cf216f68f0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2937d1391..16a4d3c24 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr## 2026-07-04+- **3D avatars load about 4x faster - and reliably everywhere** — Seven of the heaviest built-in avatars were compressed from a combined 42 MB down to under 10 MB (76% smaller), so avatar pickers, NPC scenes, and the walk companion appear much sooner - especially on slower connections. Along the way we fixed a loading bug: a few pages, including the live agent-to-agent trade demo, could silently show placeholder capsule figures instead of the real 3D avatars. Every 3D surface on the site now decodes compressed avatars correctly. `[improvement, fix]`- **A little Fourth of July on the homepage** — Visit the homepage this week and you'll catch some quiet Independence Day touches: a thin red-white-and-blue line across the top of the page and the occasional tiny firework sparkling in the hero. Nothing loud — it keeps the site clean, respects reduced-motion settings, works in both light and dark themes, and retires itself automatically after July 5. (`/`) `[improvement]`- **Deploys restored — the platform ships again, and builds are 4× lighter** — three.ws was briefly unreachable while production moved to new infrastructure: every deploy was timing out at the build platform's 45-minute ceiling. The root cause is fixed — a monitoring SDK was being baked into every one of the platform's ~800 API functions, inflating the deploy payload to 2.3 GB; it now loads only where it is actually enabled, cutting that to 540 MB. Two smaller deploy blockers found along the way (a build-order race and two missing packages) are fixed too. The site is back, deploys complete with time to spare, and nothing about how you use the platform changes. `[infra, fix]`- **Four gestures return to the walk companion — nod, shrug, jog, celebrate** — The gesture wheel regained four expressive moves that had been silently dropped: nod (a quick upper-body affirm), shrug, jog (a full-body run loop), and celebrate (a whole-body cheer). Open the wheel with G (or long-press the action button on mobile) — the wheel now lays out all twelve gestures; keys 1–8 still trigger the first eight. Also part of this pass: the entire test suite now runs fully green, locking every one of these behaviors in. (`/walk`) `[fix]`diff --git a/data/changelog.json b/data/changelog.jsonindex 5ccebd662..b79650116 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,15 @@{"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-07-04",+ "title": "3D avatars load about 4x faster - and reliably everywhere",+ "summary": "Seven of the heaviest built-in avatars were compressed from a combined 42 MB down to under 10 MB (76% smaller), so avatar pickers, NPC scenes, and the walk companion appear much sooner - especially on slower connections. Along the way we fixed a loading bug: a few pages, including the live agent-to-agent trade demo, could silently show placeholder capsule figures instead of the real 3D avatars. Every 3D surface on the site now decodes compressed avatars correctly.",+ "tags": [+ "improvement",+ "fix"+ ]+ },{"date": "2026-07-04","title": "A little Fourth of July on the homepage",diff --git a/page-agent-sdk/src/stage.js b/page-agent-sdk/src/stage.jsindex 8ac7f3d05..1eacec267 100644--- a/page-agent-sdk/src/stage.js+++ b/page-agent-sdk/src/stage.js@@ -22,6 +22,17 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';import { buildMorphMap } from './lipsync.js';+// Catalog rigs served by three.ws (e.g. cz.glb) carry EXT_meshopt_compression;+// GLTFLoader throws "setMeshoptDecoder must be called" without a decoder.+// Lazy + memoized so pages using only uncompressed rigs skip the wasm init.+let _meshoptPromise = null;+function getMeshoptDecoder() {+ if (!_meshoptPromise) {+ _meshoptPromise = import('three/addons/libs/meshopt_decoder.module.js').then((m) => m.MeshoptDecoder);+ }+ return _meshoptPromise;+}+const FRAMING = {// [vertical fraction of model height to center on, distance multiplier]bust: { center: 0.86, dist: 0.62, fov: 28 },@@ -131,6 +142,7 @@ export class AvatarStage {async load(url, opts = {}) {const token = ++this._loadToken;const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.loadAsync(url);if (token !== this._loadToken) return null; // supersededdiff --git a/public/avatars/dancing-twerk.glb b/public/avatars/dancing-twerk.glbindex 122a91c50..94439353d 100644Binary files a/public/avatars/dancing-twerk.glb and b/public/avatars/dancing-twerk.glb differdiff --git a/public/avatars/michelle.glb b/public/avatars/michelle.glbindex d5ff31b73..ecf99ec96 100644Binary files a/public/avatars/michelle.glb and b/public/avatars/michelle.glb differdiff --git a/public/avatars/realistic-female.glb b/public/avatars/realistic-female.glbindex da2c17f73..70117a7b6 100644Binary files a/public/avatars/realistic-female.glb and b/public/avatars/realistic-female.glb differdiff --git a/public/avatars/realistic-halfbody.glb b/public/avatars/realistic-halfbody.glbindex f4e3a3c96..006210004 100644Binary files a/public/avatars/realistic-halfbody.glb and b/public/avatars/realistic-halfbody.glb differdiff --git a/public/avatars/realistic-male.glb b/public/avatars/realistic-male.glbindex a51f42a4d..f0604cd5f 100644Binary files a/public/avatars/realistic-male.glb and b/public/avatars/realistic-male.glb differdiff --git a/public/avatars/selfie-girl.glb b/public/avatars/selfie-girl.glbindex 018245771..d92d7e7ad 100644Binary files a/public/avatars/selfie-girl.glb and b/public/avatars/selfie-girl.glb differdiff --git a/public/avatars/xbot.glb b/public/avatars/xbot.glbindex 3805d73e7..7110bcb9a 100644Binary files a/public/avatars/xbot.glb and b/public/avatars/xbot.glb differdiff --git a/public/changelog.json b/public/changelog.jsonindex bfda7b6e3..08021a212 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,11 +1,22 @@{- "generated_at": "2026-07-04T01:06:01.924Z",+ "generated_at": "2026-07-04T01:40:18.971Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws","url": "https://three.ws"},"entries": [+ {+ "date": "2026-07-04",+ "type": "update",+ "title": "3D avatars load about 4x faster - and reliably everywhere",+ "summary": "Seven of the heaviest built-in avatars were compressed from a combined 42 MB down to under 10 MB (76% smaller), so avatar pickers, NPC scenes, and the walk companion appear much sooner - especially on slower connections. Along the way we fixed a loading bug: a few pages, including the live agent-to-agent trade demo, could silently show placeholder capsule figures instead of the real 3D avatars. Every 3D surface on the site now decodes compressed avatars correctly.",+ "link": null,+ "tags": [+ "improvement",+ "fix"+ ]+ },{"date": "2026-07-04","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex cd57dc55e..51908be5e 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -6,6 +6,14 @@<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/><description>What's new on three.ws — features, improvements, and releases, newest first.</description><language>en</language>+ <item>+ <title>3D avatars load about 4x faster - and reliably everywhere</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-04:3D avatars load about 4x faster - and reliably everywhere</guid>+ <pubDate>Sat, 04 Jul 2026 12:00:00 GMT</pubDate>+ <category>improvement</category>+ <description>Seven of the heaviest built-in avatars were compressed from a combined 42 MB down to under 10 MB (76% smaller), so avatar pickers, NPC scenes, and the walk companion appear much sooner - especially on slower connections. Along the way we fixed a loading bug: a few pages, including the live agent-to-agent trade demo, could silently show placeholder capsule figures instead of the real 3D avatars. Every 3D surface on the site now decodes compressed avatars correctly.</description>+ </item><item><title>A little Fourth of July on the homepage</title><link>https://three.ws/</link>diff --git a/public/features.json b/public/features.jsonindex b2fbaf830..0baa7634d 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-04T01:06:01.907Z",+ "generated_at": "2026-07-04T01:40:18.947Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/agent-accessories.js b/src/agent-accessories.jsindex d61c08e4e..e192f1d0c 100644--- a/src/agent-accessories.js+++ b/src/agent-accessories.js@@ -10,6 +10,7 @@import { Box3, Group, Quaternion, Vector3 } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { resolveURI } from './ipfs.js';import { collectSlotTargets } from './avatar-wardrobe.js';import { log } from './shared/log.js';@@ -21,6 +22,8 @@ export class AccessoryManager {constructor(viewer) {this.viewer = viewer;this._loader = new GLTFLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ this._meshoptReady = getMeshoptDecoder().then((d) => this._loader.setMeshoptDecoder(d));// id → { preset, object?: THREE.Group, morphs?: Array<{node,name,idx}> }this._applied = new Map();// material.uuid → original THREE.Color, captured the first time we tint a@@ -162,6 +165,7 @@ export class AccessoryManager {// ── Private ──────────────────────────────────────────────────────────────async _applyGLB(preset) {+ await this._meshoptReady;let gltf;try {gltf = await _loadGLB(this._loader, preset.glbUrl);diff --git a/src/agent-trade.js b/src/agent-trade.jsindex 2a96ea32a..5f0a1c0cc 100644--- a/src/agent-trade.js+++ b/src/agent-trade.js@@ -7,6 +7,7 @@ import * as THREE from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';+import { getMeshoptDecoder } from './viewer/internal.js';// ── Constants ──────────────────────────────────────────────────────────────const BUYER_COL = new THREE.Color(0x4589ff); // IBM blue@@ -121,6 +122,9 @@ const gltfLoader = new GLTFLoader();const draco = new DRACOLoader();draco.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.7/');gltfLoader.setDRACOLoader(draco);+// default.glb is meshopt-compressed — without this decoder every load threw+// and the scene silently degraded to the capsule fallback figures.+const meshoptReady = getMeshoptDecoder().then((d) => gltfLoader.setMeshoptDecoder(d));// Label tracking positions (above each avatar's head)const labelPos = {@@ -157,7 +161,7 @@ function makeFallbackFigure(col) {}function loadAvatar(worldPos, col, yaw, onLoaded) {- gltfLoader.load(AVATAR_GLB, (gltf) => {+ meshoptReady.then(() => gltfLoader.load(AVATAR_GLB, (gltf) => {const s = gltf.scene.clone(true);applyTint(s, col);s.position.copy(worldPos);@@ -172,7 +176,7 @@ function loadAvatar(worldPos, col, yaw, onLoaded) {s.rotation.y = yaw;scene.add(s);onLoaded(s, new THREE.Vector3(worldPos.x, 2.15, worldPos.z));- });+ }));}loadAvatar(BUYER_POS, BUYER_COL, 0.12, (m, top) => { buyerMesh = m; labelPos.buyer = top; });diff --git a/src/avatar-drop.js b/src/avatar-drop.jsindex eddc3086b..0071cdcb0 100644--- a/src/avatar-drop.js+++ b/src/avatar-drop.js@@ -14,6 +14,7 @@ import {LoopOnce,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { reserveWebGLContext } from './webgl-budget.js';import { log } from './shared/log.js';import { resolveDevR2Url } from './shared/dev-r2-proxy.js';@@ -355,11 +356,13 @@ export function initAvatarDrop(sectionEl) {timedFetch(`${location.origin}/api/avatars/${AVATAR_ID}`).then(r => r.json())- .then(d => {+ .then(async d => {const glb = resolveDevR2Url(d.avatar?.model_url || d.avatar?.url);if (!glb) return;- new GLTFLoader().load(glb, gltf => {+ const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());+ loader.load(glb, gltf => {avatar = gltf.scene;avatar.traverse(n => {if (!rootBone && /^(Hips|Root|mixamorig:?Hips)$/i.test(n.name))diff --git a/src/avatar-export.js b/src/avatar-export.jsindex 35799c8fc..e3a6edf20 100644--- a/src/avatar-export.js+++ b/src/avatar-export.js@@ -23,6 +23,7 @@*/import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';import { glbBlobToUsdzBlob } from './usdz-pipeline.js';@@ -512,6 +513,7 @@ function encodeGlb(jsonBytes, binBytes) {async function loadGlb(blob) {const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const buf = await blob.arrayBuffer();return new Promise((resolve, reject) => {loader.parse(buf, '', resolve, reject);diff --git a/src/avatar-picker.js b/src/avatar-picker.jsindex da08237e9..759f00ef8 100644--- a/src/avatar-picker.js+++ b/src/avatar-picker.js@@ -137,9 +137,10 @@ const _thumbCache = new Map(); // glbUrl → data:image/pngasync function getOffscreenCtx() {if (_offscreenCtx) return _offscreenCtx;const [{ WebGLRenderer, Scene, PerspectiveCamera, AmbientLight, DirectionalLight, Box3, Vector3 },- { GLTFLoader }] = await Promise.all([+ { GLTFLoader }, { getMeshoptDecoder }] = await Promise.all([import('three'),import('three/addons/loaders/GLTFLoader.js'),+ import('./viewer/internal.js'),]);const cvs = document.createElement('canvas');cvs.width = 256; cvs.height = 256;@@ -158,7 +159,10 @@ async function getOffscreenCtx() {const fill = new DirectionalLight(0xaaccff, 0.5);fill.position.set(-2, 2, -1);scene.add(fill);- _offscreenCtx = { renderer, camera, scene, loader: new GLTFLoader(), Box3, Vector3 };+ const loader = new GLTFLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ loader.setMeshoptDecoder(await getMeshoptDecoder());+ _offscreenCtx = { renderer, camera, scene, loader, Box3, Vector3 };return _offscreenCtx;}diff --git a/src/avatar-pose.js b/src/avatar-pose.jsindex 25c99c897..57d126daa 100644--- a/src/avatar-pose.js+++ b/src/avatar-pose.js@@ -25,6 +25,7 @@ import {ACESFilmicToneMapping,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';@@ -36,6 +37,8 @@ const MANIFEST_URL = '/animations/manifest.json';const _loader = new GLTFLoader();_loader.setDRACOLoader(dracoLoader);+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const _meshoptReady = getMeshoptDecoder().then((d) => _loader.setMeshoptDecoder(d));/*** @typedef {{name:string,url:string,label:string,icon:string,loop:boolean}} PoseDef@@ -135,6 +138,7 @@ export class PoseStage {this._resizeObserver = new ResizeObserver(() => this._resize());this._resizeObserver.observe(this.host);+ await _meshoptReady;const gltf = await _loader.loadAsync(this.glbUrl);if (this._disposed) return { supported: false };this.model = gltf.scene;diff --git a/src/demo/os-combined.js b/src/demo/os-combined.jsindex 7877a469b..44b16a917 100644--- a/src/demo/os-combined.js+++ b/src/demo/os-combined.js@@ -27,6 +27,7 @@ import {} from 'three';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';import { FilesetResolver, FaceLandmarker } from '@mediapipe/tasks-vision';import { TRIANGULATION } from './triangulation.js';@@ -94,6 +95,7 @@ async function loadBody(url, label) {setStatus(bodyStatus, `loading ${label || url}…`);try {const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.loadAsync(url);if (bodyRoot) {viewer.scene.remove(bodyRoot);diff --git a/src/demo/os-studio.js b/src/demo/os-studio.jsindex 7f4eb6467..2b7b75b00 100644--- a/src/demo/os-studio.js+++ b/src/demo/os-studio.js@@ -20,6 +20,7 @@ import {Vector3,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';const PUBLIC_STUDIO = 'https://m3-org.github.io/CharacterStudio';@@ -129,6 +130,7 @@ async function renderPreview(blob) {const url = URL.createObjectURL(blob);try {const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.loadAsync(url);gltf.scene.userData.kind = 'avatar';scene.add(gltf.scene);diff --git a/src/diorama/renderer.js b/src/diorama/renderer.jsindex 9cdcba00f..92abf5faa 100644--- a/src/diorama/renderer.js+++ b/src/diorama/renderer.js@@ -12,6 +12,7 @@import * as THREE from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';@@ -433,6 +434,8 @@ export function createDioramaRenderer(container, opts = {}) {const dracoLoader = new DRACOLoader().setDecoderPath(DRACO_PATH);const gltfLoader = new GLTFLoader();gltfLoader.setDRACOLoader(dracoLoader);+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ const meshoptReady = getMeshoptDecoder().then((d) => gltfLoader.setMeshoptDecoder(d));// controlsconst controls = new OrbitControls(camera, renderer.domElement);@@ -812,7 +815,7 @@ export function createDioramaRenderer(container, opts = {}) {const seed = seeds.get(objectId);if (seed) setSeedStatus(seed, 'forging');- gltfLoader.load(+ meshoptReady.then(() => gltfLoader.load(glbUrl,(gltf) => {try {@@ -845,7 +848,7 @@ export function createDioramaRenderer(container, opts = {}) {needsRender = true;reject(err instanceof Error ? err : new Error(`Failed to load GLB: ${glbUrl}`));},- );+ ));});}@@ -1420,6 +1423,7 @@ export async function renderThumbnail(canvas, diorama) {const dracoLoader = new DRACOLoader().setDecoderPath(DRACO_PATH);const gltfLoader = new GLTFLoader();gltfLoader.setDRACOLoader(dracoLoader);+ gltfLoader.setMeshoptDecoder(await getMeshoptDecoder());loaders.push(dracoLoader);const forged = d.objects.filter((o) => o.glbUrl).slice(0, 8);diff --git a/src/erc8004/thumbnail.js b/src/erc8004/thumbnail.jsindex 0ccdd9ab1..f55917026 100644--- a/src/erc8004/thumbnail.js+++ b/src/erc8004/thumbnail.js@@ -20,6 +20,7 @@ import {ACESFilmicToneMapping,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';/*** Render a GLB/GLTF file to a PNG blob.@@ -33,6 +34,7 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';export async function glbFileToThumbnail(file, { size = 512, background = '#1a1a1a' } = {}) {const buffer = await file.arrayBuffer();const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await new Promise((resolve, reject) => {loader.parse(buffer, '', resolve, reject);});diff --git a/src/forge-gameready.js b/src/forge-gameready.jsindex 8ca64fc9a..0fbcfb538 100644--- a/src/forge-gameready.js+++ b/src/forge-gameready.js@@ -558,10 +558,11 @@ if (resultPanel && viewer && triggerBtn) {if (wire.ready || wire.loading) return wire.ready;wire.loading = true;try {- const [THREE, { GLTFLoader }, { OrbitControls }] = await Promise.all([+ const [THREE, { GLTFLoader }, { OrbitControls }, { getMeshoptDecoder }] = await Promise.all([import('three'),import('three/addons/loaders/GLTFLoader.js'),import('three/addons/controls/OrbitControls.js'),+ import('./viewer/internal.js'),]);wire.THREE = THREE;wire.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });@@ -577,6 +578,7 @@ if (resultPanel && viewer && triggerBtn) {wire.group = new THREE.Group();wire.scene.add(wire.group);wire._loader = new GLTFLoader();+ wire._loader.setMeshoptDecoder(await getMeshoptDecoder());sizeWireRenderer();wire.ro = new ResizeObserver(sizeWireRenderer);wire.ro.observe(wireOverlay);diff --git a/src/forge-refine.js b/src/forge-refine.jsindex fab42c20a..9013de959 100644--- a/src/forge-refine.js+++ b/src/forge-refine.js@@ -15,6 +15,7 @@// geometry work is real synchronous compute behind a busy indicator.import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';import { refineScene, REFINE_PRESETS, REFINE_PRESET_BY_KEY, specForPreset } from './shared/mesh-refine.js';@@ -39,6 +40,8 @@ if (resultPanel && viewer) {injectPanel();const loader = new GLTFLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ const meshoptReady = getMeshoptDecoder().then((d) => loader.setMeshoptDecoder(d));const exporter = new GLTFExporter();let sourceUrl = ''; // the GLB this panel is refining (the forge result)@@ -239,9 +242,9 @@ if (resultPanel && viewer) {// Parse a *copy* of the buffer: GLTFLoader.parse can detach/consume the// ArrayBuffer, and we keep the original for every subsequent re-run.const copy = arrayBuffer.slice(0);- return new Promise((resolve, reject) => {+ return meshoptReady.then(() => new Promise((resolve, reject) => {loader.parse(copy, '', resolve, reject);- });+ }));}function exportGlb(scene) {diff --git a/src/forge-reveal.js b/src/forge-reveal.jsindex 92e1349cc..622a34835 100644--- a/src/forge-reveal.js+++ b/src/forge-reveal.js@@ -148,17 +148,20 @@ export async function playForgeReveal({ container, glbUrl, waitFor }) {activeCancel = cancel;try {- const [THREE, { GLTFLoader }, { RoomEnvironment }] = await Promise.all([+ const [THREE, { GLTFLoader }, { RoomEnvironment }, { getMeshoptDecoder }] = await Promise.all([import('three'),import('three/addons/loaders/GLTFLoader.js'),import('three/addons/environments/RoomEnvironment.js'),+ import('./viewer/internal.js'),]);if (cancelled) return null;// Fetch + parse the GLB first — the overlay only ever appears with a// model in hand, so a slow or failed load degrades to the plain viewer.+ const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await Promise.race([- new GLTFLoader().loadAsync(glbUrl),+ loader.loadAsync(glbUrl),new Promise((resolve) => setTimeout(() => resolve(null), LOAD_TIMEOUT_MS)),]);if (!gltf || cancelled) return null;diff --git a/src/forge-studio/forge-gameready.js b/src/forge-studio/forge-gameready.jsindex 705176c1d..ef3c28248 100644--- a/src/forge-studio/forge-gameready.js+++ b/src/forge-studio/forge-gameready.js@@ -558,10 +558,11 @@ if (resultPanel && viewer && triggerBtn) {if (wire.ready || wire.loading) return wire.ready;wire.loading = true;try {- const [THREE, { GLTFLoader }, { OrbitControls }] = await Promise.all([+ const [THREE, { GLTFLoader }, { OrbitControls }, { getMeshoptDecoder }] = await Promise.all([import('three'),import('three/addons/loaders/GLTFLoader.js'),import('three/addons/controls/OrbitControls.js'),+ import('../viewer/internal.js'),]);wire.THREE = THREE;wire.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });@@ -577,6 +578,7 @@ if (resultPanel && viewer && triggerBtn) {wire.group = new THREE.Group();wire.scene.add(wire.group);wire._loader = new GLTFLoader();+ wire._loader.setMeshoptDecoder(await getMeshoptDecoder());sizeWireRenderer();wire.ro = new ResizeObserver(sizeWireRenderer);wire.ro.observe(wireOverlay);diff --git a/src/forge-studio/forge-refine.js b/src/forge-studio/forge-refine.jsindex 79561d524..41a37bc14 100644--- a/src/forge-studio/forge-refine.js+++ b/src/forge-studio/forge-refine.js@@ -15,6 +15,7 @@// geometry work is real synchronous compute behind a busy indicator.import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';import { refineScene, REFINE_PRESETS, REFINE_PRESET_BY_KEY, specForPreset } from '../shared/mesh-refine.js';@@ -39,6 +40,8 @@ if (resultPanel && viewer) {injectPanel();const loader = new GLTFLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ const meshoptReady = getMeshoptDecoder().then((d) => loader.setMeshoptDecoder(d));const exporter = new GLTFExporter();let sourceUrl = ''; // the GLB this panel is refining (the forge result)@@ -239,9 +242,9 @@ if (resultPanel && viewer) {// Parse a *copy* of the buffer: GLTFLoader.parse can detach/consume the// ArrayBuffer, and we keep the original for every subsequent re-run.const copy = arrayBuffer.slice(0);- return new Promise((resolve, reject) => {+ return meshoptReady.then(() => new Promise((resolve, reject) => {loader.parse(copy, '', resolve, reject);- });+ }));}function exportGlb(scene) {diff --git a/src/forge-studio/forge-reveal.js b/src/forge-studio/forge-reveal.jsindex 92e1349cc..e65ff46bb 100644--- a/src/forge-studio/forge-reveal.js+++ b/src/forge-studio/forge-reveal.js@@ -148,17 +148,20 @@ export async function playForgeReveal({ container, glbUrl, waitFor }) {activeCancel = cancel;try {- const [THREE, { GLTFLoader }, { RoomEnvironment }] = await Promise.all([+ const [THREE, { GLTFLoader }, { RoomEnvironment }, { getMeshoptDecoder }] = await Promise.all([import('three'),import('three/addons/loaders/GLTFLoader.js'),import('three/addons/environments/RoomEnvironment.js'),+ import('../viewer/internal.js'),]);if (cancelled) return null;// Fetch + parse the GLB first — the overlay only ever appears with a// model in hand, so a slow or failed load degrades to the plain viewer.+ const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await Promise.race([- new GLTFLoader().loadAsync(glbUrl),+ loader.loadAsync(glbUrl),new Promise((resolve) => setTimeout(() => resolve(null), LOAD_TIMEOUT_MS)),]);if (!gltf || cancelled) return null;diff --git a/src/forge-studio/lab/lab.js b/src/forge-studio/lab/lab.jsindex 2ee1e8b49..e01f3e054 100644--- a/src/forge-studio/lab/lab.js+++ b/src/forge-studio/lab/lab.js@@ -20,6 +20,7 @@import * as THREE from 'three';import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../../viewer/internal.js';import { GENERATORS } from './generators.js';import { meshToSplatBuffer } from './mesh-to-splat.js';import { launchTalk } from '../talk-launch.js';@@ -254,6 +255,7 @@ async function exportGlb(object3d) {async function loadGlbScene(arrayBuffer) {const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.parseAsync(arrayBuffer, '');return gltf.scene;}diff --git a/src/game/ambient-crowd.js b/src/game/ambient-crowd.jsindex 3dc4e02a0..3bdda778e 100644--- a/src/game/ambient-crowd.js+++ b/src/game/ambient-crowd.js@@ -13,6 +13,7 @@import { Group, Vector3 } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { Box3, Mesh, CapsuleGeometry, SphereGeometry, MeshStandardMaterial } from 'three';import { AnimationManager } from '../animation-manager.js';@@ -29,6 +30,8 @@ const NAMES = ['satoshi', 'anon', 'gm_ser', 'degenape', 'moonboy', 'pepe', 'wagmconst LINES = ['gm ☀️', 'wen moon', 'lfg 🚀', 'wagmi', 'probably nothing', 'few understand', 'based', 'diamond hands 💎', 'ser…', 'this is the way', 'bullish af', 'vibes immaculate', 'we so back', 'iykyk', 'up only 📈'];const _gltf = new GLTFLoader();+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const _meshoptReady = getMeshoptDecoder().then((d) => _gltf.setMeshoptDecoder(d));let _defs = null; // [idle, walk] animation defslet _emotes = null; // a handful of emote defslet _avatars = null; // pool of public-gallery GLB URLs ([] once the fetch settles)@@ -65,6 +68,7 @@ async function loadAvatarPool() {// back to a simple stand-in so a wanderer is never invisible.async function buildAvatar(rig, anim, url) {try {+ await _meshoptReady;const gltf = await _gltf.loadAsync(url || AVATAR_DEFAULT);const model = gltf.scene;model.traverse((n) => { if (n.isMesh) { n.castShadow = true; n.receiveShadow = false; } });diff --git a/src/game/avatar-upload.js b/src/game/avatar-upload.jsindex 71776e8ce..dce53db3f 100644--- a/src/game/avatar-upload.js+++ b/src/game/avatar-upload.js@@ -13,6 +13,7 @@import { Box3, Vector3 } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';// Kept in sync with MAX_GLB_BYTES in api/avatar/presign-glb.js.export const MAX_GLB_BYTES = 16 * 1024 * 1024;@@ -20,6 +21,8 @@ export const MAX_GLB_MB = MAX_GLB_BYTES / (1024 * 1024);const GLB_CONTENT_TYPE = 'model/gltf-binary';const _loader = new GLTFLoader();+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const _meshoptReady = getMeshoptDecoder().then((d) => _loader.setMeshoptDecoder(d));function disposeScene(scene) {scene.traverse((n) => {@@ -42,6 +45,7 @@ export async function validateGlb(file) {throw new Error(`That .glb is ${(file.size / (1024 * 1024)).toFixed(1)} MB — the limit is ${MAX_GLB_MB} MB. Decimate the mesh or shrink textures and try again.`);}+ await _meshoptReady;let gltf;try {gltf = await _loader.parseAsync(await file.arrayBuffer(), '');diff --git a/src/game/cosmetics-visual.js b/src/game/cosmetics-visual.jsindex 7ef3615a6..5c5fb6aeb 100644--- a/src/game/cosmetics-visual.js+++ b/src/game/cosmetics-visual.js@@ -19,6 +19,7 @@ import {AdditiveBlending, DoubleSide,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { dracoLoader } from './avatar-rig.js';import { log } from '../shared/log.js';@@ -26,13 +27,15 @@ import { log } from '../shared/log.js';// GLBs (which may be Draco-compressed) decode without a second decoder instance.const _loader = new GLTFLoader();_loader.setDRACOLoader(dracoLoader);+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const _meshoptReady = getMeshoptDecoder().then((d) => _loader.setMeshoptDecoder(d));// Cache each prop's loaded scene once; every wearer gets a deep clone so they// never share (and mutate) one another's meshes.const _propCache = new Map(); // url -> Promise<Object3D|null>function loadProp(url) {if (!_propCache.has(url)) {- _propCache.set(url, _loader.loadAsync(url)+ _propCache.set(url, _meshoptReady.then(() => _loader.loadAsync(url)).then((g) => g.scene).catch((err) => { log.warn('[cosmetics] prop load failed:', url, err?.message); return null; }));}diff --git a/src/game/world-objects.js b/src/game/world-objects.jsindex d9db588cb..9a4297358 100644--- a/src/game/world-objects.js+++ b/src/game/world-objects.js@@ -25,6 +25,7 @@ import {CanvasTexture, SRGBColorSpace,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { log } from '../shared/log.js';// Same lerp constant RemotePlayer uses, so objects glide between server updates@@ -207,6 +208,8 @@ function propCrystal() {// ── GLB template cache (shared geometry/materials across instances) ──────────const _gltf = new GLTFLoader();+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const _meshoptReady = getMeshoptDecoder().then((d) => _gltf.setMeshoptDecoder(d));const _glbCache = new Map(); // url → { template, waiters:[] }function loadTemplate(url) {@@ -214,12 +217,12 @@ function loadTemplate(url) {if (rec) return rec;rec = { template: null, waiters: [] };_glbCache.set(url, rec);- _gltf.load(url, (gltf) => {+ _meshoptReady.then(() => _gltf.load(url, (gltf) => {const root = gltf.scene;root.traverse((o) => { if (o.isMesh) { o.castShadow = true; o.receiveShadow = true; } });rec.template = root;for (const w of rec.waiters.splice(0)) { try { w(root); } catch (e) { log.warn('[world-objects] glb waiter threw', e); } }- }, undefined, (err) => log.warn('[world-objects] GLB load failed', url, err?.message || err));+ }, undefined, (err) => log.warn('[world-objects] GLB load failed', url, err?.message || err)));return rec;}diff --git a/src/home-act2-viewer.js b/src/home-act2-viewer.jsindex 33485f038..ab5b11093 100644--- a/src/home-act2-viewer.js+++ b/src/home-act2-viewer.js@@ -26,6 +26,7 @@ import {PMREMGenerator,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';const CROSSFADE = 0.35;@@ -71,6 +72,8 @@ export class Act2Viewer {this._manifestPromise = null;this._loader = new GLTFLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ this._meshoptReady = getMeshoptDecoder().then((d) => this._loader.setMeshoptDecoder(d));this._clock = new Timer();this._modelYaw = 0;this._modelFocusY = 1.0;@@ -222,6 +225,7 @@ export class Act2Viewer {this.clips.clear();}+ await this._meshoptReady;const gltf = await this._loader.loadAsync(url);this.model = gltf.scene;this.scene.add(this.model);diff --git a/src/ibm-vision.js b/src/ibm-vision.jsindex 596516ae8..2ac4b4044 100644--- a/src/ibm-vision.js+++ b/src/ibm-vision.js@@ -12,6 +12,7 @@import * as THREE from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';@@ -378,7 +379,9 @@ function loadModel(url) {disposeObject(modelRoot);modelRoot = null;}- gltfLoader().load(+ const loader = gltfLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ getMeshoptDecoder().then((d) => loader.setMeshoptDecoder(d)).then(() => loader.load(url,(gltf) => {if (token !== loadToken) { disposeObject(gltf.scene); return; }@@ -400,7 +403,7 @@ function loadModel(url) {);}},- );+ ));}function frameModel(root) {diff --git a/src/irl/world-line-ar.js b/src/irl/world-line-ar.jsindex 763ddef0f..315f1d8c9 100644--- a/src/irl/world-line-ar.js+++ b/src/irl/world-line-ar.js@@ -16,6 +16,7 @@ import {Scene, PerspectiveCamera, WebGLRenderer, AmbientLight, DirectionalLight,RingGeometry, Mesh, MeshBasicMaterial, Group,} from 'three';+import { getMeshoptDecoder } from '../viewer/internal.js';// ── Agent voice (TTS) ────────────────────────────────────────────────────────let _voiceAudio = null;@@ -293,7 +294,9 @@ export class WorldLineCeremony {const cam = new PerspectiveCamera(35, 1, 0.1, 100);cam.position.set(0, 1.4, 2.6);const root = new Group(); scene.add(root);- const gltf = await new GLTFLoader().loadAsync(this.avatarUrl);+ const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());+ const gltf = await loader.loadAsync(this.avatarUrl);root.add(gltf.scene);gltf.scene.position.y = -1.2;let raf;@@ -331,8 +334,11 @@ export class WorldLineCeremony {reticle.visible = false; reticle.matrixAutoUpdate = false; scene.add(reticle);const root = new Group(); root.visible = false; scene.add(root);- import('three/addons/loaders/GLTFLoader.js').then(({ GLTFLoader }) => {- if (this.avatarUrl) new GLTFLoader().loadAsync(this.avatarUrl).then((g) => root.add(g.scene)).catch(() => {});+ import('three/addons/loaders/GLTFLoader.js').then(async ({ GLTFLoader }) => {+ if (!this.avatarUrl) return;+ const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());+ loader.loadAsync(this.avatarUrl).then((g) => root.add(g.scene)).catch(() => {});});const overlay = document.createElement('div');diff --git a/src/runtime/scene.js b/src/runtime/scene.jsindex 66ed5d22b..cdb5df721 100644--- a/src/runtime/scene.js+++ b/src/runtime/scene.js@@ -5,6 +5,7 @@import { Vector3 } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { resolveURI } from '../ipfs.js';import { resolveSlot } from './animation-slots.js';import { log } from '../shared/log.js';@@ -24,6 +25,8 @@ export class SceneController {constructor(viewer) {this.viewer = viewer;this._loader = new GLTFLoader();+ // three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+ this._meshoptReady = getMeshoptDecoder().then((d) => this._loader.setMeshoptDecoder(d));this._userTarget = new Vector3(0, 1.6, 2); // approx user head positionthis._animationMap = {};this._group = null;@@ -180,6 +183,7 @@ export class SceneController {}async loadClip(uri) {+ await this._meshoptReady;const resolved = resolveURI(uri);return new Promise((resolve, reject) => {this._loader.load(@@ -192,6 +196,7 @@ export class SceneController {}async loadGLB(uri) {+ await this._meshoptReady;const resolved = resolveURI(uri);return new Promise((resolve, reject) => {this._loader.load(resolved, resolve, undefined, reject);diff --git a/src/scene-compose.js b/src/scene-compose.jsindex 2d0a83249..4c168fb3a 100644--- a/src/scene-compose.js+++ b/src/scene-compose.js@@ -25,6 +25,7 @@import * as THREE from 'three';import { createLogger } from './shared/log.js';import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';@@ -312,10 +313,12 @@ function toast(msg, duration = 2500) {// ── GLB loader ────────────────────────────────────────────────────────────────const gltfLoader = new GLTFLoader();+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const meshoptReady = getMeshoptDecoder().then((d) => gltfLoader.setMeshoptDecoder(d));function loadGLB(url, name, opts = {}) {return new Promise((resolve, reject) => {- gltfLoader.load(url, (gltf) => {+ meshoptReady.then(() => gltfLoader.load(url, (gltf) => {const group = gltf.scene;group.traverse((n) => {if (n.isMesh) { n.castShadow = true; n.receiveShadow = true; }@@ -335,7 +338,7 @@ function loadGLB(url, name, opts = {}) {const bones = [];group.traverse((n) => { if (n.isBone) bones.push({ name: n.name, bone: n }); });resolve({ group, gltf, bones });- }, undefined, reject);+ }, undefined, reject));});}diff --git a/src/segment.js b/src/segment.jsindex c49db270e..face7140f 100644--- a/src/segment.js+++ b/src/segment.js@@ -9,6 +9,7 @@import * as THREE from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';@@ -178,7 +179,8 @@ function partIdFor(obj) {function loadSegmentedModel(glbUrl, manifest) {return new Promise((resolve, reject) => {const loader = new GLTFLoader();- loader.load(+ const meshoptReady = getMeshoptDecoder().then((d) => loader.setMeshoptDecoder(d));+ meshoptReady.then(() => loader.load(glbUrl,(gltf) => {clearModel();@@ -232,7 +234,7 @@ function loadSegmentedModel(glbUrl, manifest) {},undefined,(err) => reject(new Error(`Could not load the segmented model: ${err?.message || err}`)),- );+ ));});}diff --git a/src/shared/agent-watch-panel.js b/src/shared/agent-watch-panel.jsindex 93e5a1274..b4307a259 100644--- a/src/shared/agent-watch-panel.js+++ b/src/shared/agent-watch-panel.js@@ -20,6 +20,7 @@ import {AmbientLight, DirectionalLight, Box3,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from '../viewer/internal.js';import { clone as cloneSkinnedScene } from 'three/addons/utils/SkeletonUtils.js';// Top-level endpoint — this is the real-time frame+log SSE stream.@@ -1189,6 +1190,7 @@ class WatchPanel {try {const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.loadAsync(this.avatarUrl);if (this._destroyed) return;diff --git a/src/walk-agent-desk.js b/src/walk-agent-desk.jsindex 87ef43956..8d7cc6418 100644--- a/src/walk-agent-desk.js+++ b/src/walk-agent-desk.js@@ -25,6 +25,7 @@ import {Vector3, Box3,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { clone as cloneSkinnedScene } from 'three/addons/utils/SkeletonUtils.js';import { AnimationManager } from './animation-manager.js';import { createAgentScreenClient } from './shared/agent-screen-client.js';@@ -56,6 +57,8 @@ const PAL = {// ── shared GLTF loader ───────────────────────────────────────────────────────const gltfLoader = new GLTFLoader();+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const meshoptReady = getMeshoptDecoder().then((d) => gltfLoader.setMeshoptDecoder(d));/*** Build a desk + monitor group and attach it to the scene. Returns a desk@@ -148,7 +151,7 @@ function createDesk(scene, opts = {}) {let avatarManager = null;if (avatarUrl) {- gltfLoader.loadAsync(avatarUrl).then((gltf) => {+ meshoptReady.then(() => gltfLoader.loadAsync(avatarUrl)).then((gltf) => {const model = cloneSkinnedScene(gltf.scene);// Scale and position: seated at the deskdiff --git a/src/walk-embed-preview.js b/src/walk-embed-preview.jsindex acf86e9cc..f14b79716 100644--- a/src/walk-embed-preview.js+++ b/src/walk-embed-preview.js@@ -25,6 +25,7 @@ import {WebGLRenderer,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';import nipplejs from 'nipplejs';import { AnimationManager } from './animation-manager.js';@@ -284,6 +285,7 @@ export function initWalkPreview(container) {avatar = null;}const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.loadAsync(AVATAR_URL);const model = gltf.scene;model.traverse((c) => {diff --git a/src/walk-environments.js b/src/walk-environments.jsindex a43da8719..b4bffab46 100644--- a/src/walk-environments.js+++ b/src/walk-environments.js@@ -22,6 +22,7 @@import { Color, EquirectangularReflectionMapping, GridHelper, Group, PMREMGenerator } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { HDRLoader } from 'three/addons/loaders/HDRLoader.js';const MANIFEST_URL = '/environments/index.json';@@ -29,6 +30,8 @@ const ASSET_BASE = '/environments/';let _manifestPromise = null;const _gltfLoader = new GLTFLoader();+// three.ws GLBs may carry EXT_meshopt_compression — decoder required before load+const _meshoptReady = getMeshoptDecoder().then((d) => _gltfLoader.setMeshoptDecoder(d));// Fetch + cache the environment manifest. Resolves to// { version, default, environments: [...] }. The promise is memoised so the@@ -80,6 +83,7 @@ export async function loadEnvironmentScenery(meta, { heightAt } = {}) {return { group, dispose: () => disposeGroup(group) };}+ await _meshoptReady;const gltf = await _gltfLoader.loadAsync(ASSET_BASE + meta.scene);const root = gltf.scene;const snap = typeof heightAt === 'function';diff --git a/src/walk-npcs.js b/src/walk-npcs.jsindex 2364fc67b..3467c943e 100644--- a/src/walk-npcs.js+++ b/src/walk-npcs.js@@ -23,6 +23,7 @@import { Box3, Group, Vector3 } from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { clone as cloneSkinnedScene } from 'three/addons/utils/SkeletonUtils.js';import { AnimationManager } from './animation-manager.js';import { log } from './shared/log.js';@@ -96,7 +97,10 @@ function loadTemplate(url) {let p = _templateCache.get(url);if (!p) {const loader = new GLTFLoader();- p = loader.loadAsync(url).then((gltf) => gltf.scene);+ p = getMeshoptDecoder()+ .then((d) => loader.setMeshoptDecoder(d))+ .then(() => loader.loadAsync(url))+ .then((gltf) => gltf.scene);_templateCache.set(url, p);}return p;diff --git a/src/xr.js b/src/xr.jsindex c8b3b16ec..7c070f478 100644--- a/src/xr.js+++ b/src/xr.js@@ -19,6 +19,7 @@ import {WebGLRenderer,} from 'three';import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';+import { getMeshoptDecoder } from './viewer/internal.js';import { OrbitControls } from 'three/addons/controls/OrbitControls.js';import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';import { AnimationManager } from './animation-manager.js';@@ -442,6 +443,7 @@ async function loadAvatar(idOrUrl) {_clearAvatar();const loader = new GLTFLoader();+ loader.setMeshoptDecoder(await getMeshoptDecoder());const gltf = await loader.loadAsync(url);const root = gltf.scene;root.traverse((obj) => {