This repository compresses glTF files exported from cg software (Blender, etc.) into glb files.
- node: v.17.0.0
- npm: 8.1.0
※ Operation confirmed version
// install
npm i
// compressor
npm run meshopt
-
Place the gltf file in
/src/
. -
run
npm run meshopt
-
If you have a zipped glb file inside the
/dist/
you are done
- Confirmed to work with three.js r148
import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { MeshoptDecoder } from "three/examples/jsm/libs/meshopt_decoder.module.js";
const loader = new GLTFLoader();
loader.setMeshoptDecoder(MeshoptDecoder);
async function init() {
const glb = loader.loadAsync("./hoge-meshopt.glb");
const model = glb.scene;
scene.add(model);
}
/
├── dist/
│ └── hoge-meshopt.glb // compressed glb file
├── node_modules/
├── src/
│ └── hoge.gltf // before compression
├── .gitignore
├── compress-meshopt.js
├── package-lock.json
├── package.json
└── Readme.md
This is a site where you can check if the glb and gltf files are displayed correctly on the web.