feat(3d-nds): use draco to compress glb model

This commit is contained in:
2026-02-24 15:26:54 +01:00
parent 7035525dfc
commit 128d350b86
22 changed files with 17 additions and 1978 deletions

View File

@@ -1,5 +1,6 @@
import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
type Rect = [number, number, number, number];
@@ -50,7 +51,12 @@ const createModel = (path: string) => {
const model = new THREE.Group();
modelCache.set(path, model);
new GLTFLoader().load(
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath("/draco/");
const loader = new GLTFLoader();
loader.setDRACOLoader(dracoLoader);
loader.load(
path,
(gltf) => {
for (const child of [...gltf.scene.children]) {