feat(3d-nds): use draco to compress glb model
@@ -7,6 +7,6 @@ node_modules
|
||||
*.JPG
|
||||
*.png
|
||||
*.webp
|
||||
*.gltf
|
||||
*.glb
|
||||
*.blend
|
||||
*.blend1
|
||||
|
||||
@@ -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]) {
|
||||
|
||||
@@ -29,7 +29,7 @@ type ImageData = {
|
||||
};
|
||||
|
||||
const IMAGE_EXTENSIONS = [".png", ".webp"];
|
||||
const MODEL_EXTENSIONS = [".gltf"];
|
||||
const MODEL_EXTENSIONS = [".glb"];
|
||||
const MAX_WIDTH = 2048;
|
||||
|
||||
const toCamelCase = (str: string) => {
|
||||
|
||||
@@ -36,4 +36,12 @@ export default defineNuxtConfig({
|
||||
quality: 80,
|
||||
format: ["webp"],
|
||||
},
|
||||
nitro: {
|
||||
publicAssets: [
|
||||
{
|
||||
baseURL: "/draco",
|
||||
dir: "./node_modules/three/examples/jsm/libs/draco/gltf",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 8.6 KiB |
BIN
public/nds/models/nitendo-ds/model.glb
Normal file
|
Before Width: | Height: | Size: 145 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 534 KiB |
|
Before Width: | Height: | Size: 145 KiB |
|
Before Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 226 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 1000 KiB |
|
Before Width: | Height: | Size: 1.9 MiB |