Draco compressed embeded gltf to gltf+bin files


There is a C++ framework named Open Cascade that is unable to read Draco-compressed embedded GLTF files due to an internal issue with Open Cascade itself.

As we know the structure of Draco-compressed embedded GLTF and Draco-compressed GLTF+BIN structures:

  1. Draco-compressed embedded GLTF buffer URI:

  2. Draco-compressed GLTF+BIN file buffers URI structure:

Since Open Cascade is unable to read Draco-compressed embedded GLTF files, I wanted to convert Draco-compressed embedded GLTF to GLTF+BIN structure.

I tried to extract the Base64 data from the Draco-compressed embedded GLTF to convert it into a GLTF+BIN file. However, despite using online converters and some C++ libraries, I was not able to convert the data properly.

Could anyone please suggest how to achieve this conversion?

One option on the CLI, requiring Node.js, would be:

npm install --global @gltf-transform/cli

gltf-transform cp input.gltf output.gltf

You’ll see a warning in the logs, mentioning that Draco compression was removed. This tool will always create external .bin files unless you select .glb output.

Or you can open the model on https://gltf.report/, select Format → “JSON” and Compression → “Uncompressed” in the dropdowns on the right, and export.

I wanted to read the compressed embedded GLTF in C++ itself. Since we are not able to do it in OpenCASCADE,
I wanted to extract the base64 data from the embedded GLTF and, after converting it to binary, save it as a .bin file by using any c++ libraries.
This will create a separate compressed GLTF+BIN structure. I don’t want to uncompress it; I just want to separate it.

Oops, I see. In that case it is mainly a matter of decoding JSON, decoding the Data URIs within that JSON, writing each resource to a .bin file, and replacing the original JSON. You should not need to interact with any other glTF-specific data.

If you haven’t tried cgltf yet, that is a solid library and automatically decodes Data URIs. But it should be possible to do this with any C/C++ JSON decoder, you don’t necessarily need a glTF-specific library for it.

1 Like