Dough Git

commit

Decode Draco-compressed models in the 3D viewer

commit
f0acad0e26077719b3681578e3c8608e17095083
author
Clove Twilight <[email protected]>
date
2026-11-12 21:42
Hooks DRACOLoader into the GLTF loader using the glTF decoder that ships
with three, which Vite bundles into /_app/. Models with
KHR_draco_mesh_compression, such as models/aino.glb, now load instead
of failing.

Co-Authored-By: Sandrone <[email protected]>

diff --git a/web/src/lib/ModelViewer.svelte b/web/src/lib/ModelViewer.svelte
index b10cc62..db9362b 100644
--- a/web/src/lib/ModelViewer.svelte
+++ b/web/src/lib/ModelViewer.svelte
@@ -6,6 +6,7 @@
 
   import { onMount } from "svelte";
   import * as THREE from "three";
+  import { DRACO_GLTF_CONFIG, DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
   import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
   import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
   import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
@@ -74,8 +75,13 @@
     }
 
     let mixer: THREE.AnimationMixer | undefined;
+    // The glTF-only decoder that ships with three; Vite bundles it into /_app/
+    const draco = new DRACOLoader();
+    draco.setDecoderPath(DRACO_GLTF_CONFIG);
+
     const loader = new GLTFLoader();
     loader.setMeshoptDecoder(MeshoptDecoder);
+    loader.setDRACOLoader(draco);
 
     loader.load(
       src,
@@ -115,6 +121,7 @@
       renderer.setAnimationLoop(null);
       observer.disconnect();
       controls.dispose();
+      draco.dispose();
       environment.dispose();
       scene.traverse((object) => {
         if (object instanceof THREE.Mesh) {