Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render gltf from binary?

Tags:

3d

gltf

I've been given a csv file with rows of objects, each one containing various data and each row has an "Element Mesh" column in a format such as:

(this snippet goes on and on) after the end... data:model/gltf-binary;base64,Z2xURgIAAACMCAAASAMAAEpTT057ImFzc2V0Ijp7ImNvcHlya

It looks like some kind of gltf data exported into binary? Is there a way to display each of these rows? I thought maybe I could just copy and paste (minus the "data:") into a file and save it with a GLB or GLTF extension. No luck. Do I have to create a JSON file and then have this binary stream as the value of a field?

like image 622
Brian Lorraine Avatar asked Aug 20 '26 03:08

Brian Lorraine


1 Answers

This is what's known as a "Data URI" or "Data URL" (Mozilla's documentation says it was renamed, and explains the structure in more detail).

The short answer is, you must base64-decode everything after the base64, part at the start of the string. Various programming environments come with helpers for this. For example in JavaScript, it's just atob(string), but be warned that you may get back the binary contents of a GLB file.

The MIME type shown here is model/gltf-binary, which indicates that the base64-encoded contents are in the binary form of the glTF format, meaning they should match the contents of a *.glb file when decoded.

What to do with the file contents from there depends on what platform, language, environment, and rendering engine you have at your disposal here.

like image 50
emackey Avatar answered Aug 23 '26 04:08

emackey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!