Compress 3D model files with Draco

Posted :

Draco is a 3D model files compressing / decompressing library, especially for Web use.

Draco compression reduces over 90% of file size.

here is a compression result.

Original OBJ file: 16.5MB, Draco compressed file: 343KB

In this article, I will show how to compress with Draco compressor.

1. get Draco Repo

Visit Draco repositry and download entire repository.

2. Install CMake

In order to build Draco, you need to use CMake

download and extract dmg, then install CMake.app

3. CMake

Make a folder and run CMake with the folder. When you press “Generate” button, you will have a XCode project file.

You will see following log when CMake has been done.

and you should have several files in the folder.

4. build with XCode

Open draco.excodeproj in XCode.

then press build button.

after that, CLIs will be generated. In order to compress with Draco, we will use “draco_encoder”

4. Compress with Draco

open Terminal and exec draco_encoder. Encoder take 3 arguments. Path to input file, output file name and compression level

FYI: Draco can only take OBJ and PLY format so far.

  • -i is the path to input file.
  • -o is the name of the compressed file.
  • -cl is the compression level. You can set a number from 0 to 10.
1
./draco_encoder -i testdata/my-3d-model.obj -o out.drc -cl 8

Here is a final example.

three.js + draco example

Zip compression

If you need another compressor for other formats such as three.js JSON, glTF, There is Zip compression. Zip reduce about 70%, because three.js JSON consist mostly of number.

Here is a zip encoder for JS.

three.js + unzip example

Unzip JS library is available on NPM