How to compress GLB files?

How to compress GLB files? The same FBX file will be much smaller than GLB file, how to make GLB file smaller?

1 Like

Hi, welcome to the forum.
You can compress glb files with draco compression with this tool.
The relevant command is gltf-pipeline -i model.glb -d

Then you import it in three.js with this.

Draco compression works best with large meshes without animation. It does not compress textures. If you have animations you can look into gltfpack, which optimize keyframes.

1 Like

Ok thanks, let me try it. Can this tool compress GLB files smaller than FBX files?

I can’t say compared to FBX, but that’s very efficient for large non-animated meshes (compress ~ 80 - 90%, without texture)

OK, thank you very much.

I’m sorry to disturb you.
I want to ask you how to run the compressed file method in JavaScript. I only saw it running in NPM

Or do you have an example of JavaScript compression file ?

It is (much) easier to compress the files in an offline tool, not in JavaScript in the browser. Once it is compressed you can load it in JavaScript.

To compress it you need to install node.js, then run npm install --global gltf-pipeline in a terminal.

Also … it is hard to say without looking at your file what type of compression will help. It might be large because of textures, or geometry, or animation. Draco compression only helps with geometry. Sometimes converting from FBX to glTF can accidentally increase the number of vertices, too. Are you able to share one of the files?

But now the requirement is to let the client compress the GLB file through JavaScript in the browser. Do you have any way? thank you

See Can I apply DRACO Compression with GLTFExporter when exporting it? … THREE.GLTFExporter currently doesn’t support this. That’s a lot of work, and I can’t tell you how to do it sorry.

I would really suggest verifying why the file is large before you invest time in a particular way of optimizing it. A GLB file should not normally be larger than the FBX equivalent, I think something else is wrong here.

This is my output mode. The FBX of 40MB exports 170mbglb files. I did it with reference to the three.js editor. Please see if there is any problem with the export mode

This is not very much to go on. :confused: Can you not share the file?

If not:

  • How many vertices does the model have before and after FBX->glTF (can check this by opening it in Blender)
  • How many textures does the model have, and what size/resolution are they?


The number of vertices I tested in the three.js editor is basically the same because I added some models to it (there are few model points, lines and surfaces), and there is no texture in the model

My FBX File Not uploading In Forum

Is there a limit to the number of questions that can be asked in the account here? This is a colleague’s account.

I don’t know how to give you the FBX file. Email attachment? But this FBX file doesn’t make much sense because it’s just a toilet file. Basically, all FBX files are smaller than GLB. My FBX has no texture.

Maybe it’s too large to share on the forum here. But there are loads of ways of sharing files, like Google drive, dropbox etc.