Exporting gltf embedded

Hello, I am trying to export a gltf File but the goal is to have only one file without the .bin

                BABYLON.GLTF2Export.GLTFAsync(scene, "newName").then((gltf) => {
                    let blob = gltf.glTFFiles["myGltf" + ".gltf"];
                    let bin = gltf.glTFFiles["myGltf" + ".bin"];
                    gltf.downloadFiles();
                }

It is possible to download the bin and the gltf file and both can be used together. My goal is to make only one file by encoding the bin and putting it into uri-field in the gltf file. It has probably to be a data:application/octet-stream;base64, encoding. I don’t know how to approach or solve it after few failed attemps. I tried btoa() for encoding.

https://playground.babylonjs.com/#WGZLGJ#6034

Probably you need to use BABYLON.GLTF2Export.GLBAsync instead of BABYLON.GLTF2Export.GLTFAsync

Example - https://playground.babylonjs.com/#WGZLGJ#6035 (see blob in console).

I used this function as well to check if everything else does work. But I can’t use it because it does convert to binary and .glb files.

1 Like

Adding @bghgary.

We don’t have an option for base64 encoded single-file glTF. It probably can be added. Why do you want this? It’s much less efficient than using a GLB.

1 Like

Yes but it’s human readable and can be changed with any text editor.

:thinking: Base64 is not human readable. I’m not sure how you would edit it with a text editor.

1 Like

Hi. If you plan use babylon better use their native format babylon its fully json styled format The .babylon File Format | Babylon.js Documentation

1 Like