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

@@ -7,6 +7,6 @@ node_modules
*.JPG *.JPG
*.png *.png
*.webp *.webp
*.gltf *.glb
*.blend *.blend
*.blend1 *.blend1

View File

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

View File

@@ -29,7 +29,7 @@ type ImageData = {
}; };
const IMAGE_EXTENSIONS = [".png", ".webp"]; const IMAGE_EXTENSIONS = [".png", ".webp"];
const MODEL_EXTENSIONS = [".gltf"]; const MODEL_EXTENSIONS = [".glb"];
const MAX_WIDTH = 2048; const MAX_WIDTH = 2048;
const toCamelCase = (str: string) => { const toCamelCase = (str: string) => {

View File

@@ -36,4 +36,12 @@ export default defineNuxtConfig({
quality: 80, quality: 80,
format: ["webp"], format: ["webp"],
}, },
nitro: {
publicAssets: [
{
baseURL: "/draco",
dir: "./node_modules/three/examples/jsm/libs/draco/gltf",
},
],
},
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 534 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1000 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB