# Exporting gltf embedded

**URL:** <https://forum.babylonjs.com/t/exporting-gltf-embedded/33590>\
**Category:** Questions\
**Tags:** material, gltf\
**Created:** [September 1, 2022, 2:47pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590 "2022-09-01T14:47:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DSparky](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DSparky](https://forum.babylonjs.com/u/DSparky)\
**Post date:** [September 1, 2022, 2:47pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/1 "2022-09-01T14:47:34Z")

</div>

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

```auto
                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](https://playground.babylonjs.com/#WGZLGJ#6034)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [September 1, 2022, 2:55pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/2 "2022-09-01T14:55:05Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![DSparky](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DSparky](https://forum.babylonjs.com/u/DSparky)\
**Post date:** [September 1, 2022, 4:13pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/3 "2022-09-01T16:13:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [September 1, 2022, 8:13pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/4 "2022-09-01T20:13:01Z")

</div>

Adding @bghgary.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 1, 2022, 8:29pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/5 "2022-09-01T20:29:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DSparky](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DSparky](https://forum.babylonjs.com/u/DSparky)\
**Post date:** [September 2, 2022, 7:05am UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/6 "2022-09-02T07:05:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 2, 2022, 4:19pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/7 "2022-09-02T16:19:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kvasss](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kvasss/32/3774_2.png) [@kvasss](https://forum.babylonjs.com/u/kvasss)\
**Post date:** [September 2, 2022, 7:34pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/8 "2022-09-02T19:34:13Z")

</div>

Hi. If you plan use babylon better use their native format babylon its fully json styled format [The .babylon File Format | Babylon.js Documentation](https://doc.babylonjs.com/advanced_topics/.babylonFileFormat)

---

<div class="post-metadata">

**Author:** ![Kalila](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kalila/32/39877_2.png) [@Kalila](https://forum.babylonjs.com/u/Kalila)\
**Post date:** [September 5, 2024, 2:50am UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/9 "2024-09-05T02:50:47Z")

</div>

The reason for it is so you can change the rest of the properties (sans the base64) data, while keeping it all bundled together. I’d say that’s quite useful in many scenarios.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 5, 2024, 4:05pm UTC](https://forum.babylonjs.com/t/exporting-gltf-embedded/33590/10 "2024-09-05T16:05:13Z")

</div>

It might be slightly easier to use, but it is not efficient. If the binary part is very small, I suppose it’s okay to use. Generally, if you want a single file for a glTF asset, use [glTF-Binary (GLB)](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#glb-file-format-specification). Using tools like [glTF Tools for vscode](https://marketplace.visualstudio.com/items?itemName=cesium.gltf-vscode), you can easily convert back and forth between `.gltf` and `.glb`.
