# Help with importing models from an embeded gltf file's text

**URL:** <https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060>\
**Category:** Questions\
**Created:** [April 25, 2025, 1:01pm UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060 "2025-04-25T13:01:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Warnt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/warnt/32/44486_2.png) [@Warnt](https://forum.babylonjs.com/u/Warnt)\
**Post date:** [April 25, 2025, 1:01pm UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/1 "2025-04-25T13:01:46Z")

</div>

Help me! well i am creating a babylon.js extension for turbowarp using javascript. i have done most of the things and now it is time to do gltf model importation. i want to make a function that can take in an embeded gltf file (an embeded gltf file that contains all the images and everything in a single file) as input and then add that gltf meshes using that text. and yeah i am a starter in javascript so i don’t have much experience.

---

<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:** [April 25, 2025, 3:42pm UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/2 "2025-04-25T15:42:17Z")

</div>

Did you try Babylon GLTF loader?

---

<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:** [April 25, 2025, 3:48pm UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/3 "2025-04-25T15:48:22Z")

</div>

For example, [Babylon.js Playground](https://playground.babylonjs.com/#0LR02P)

---

<div class="post-metadata">

**Author:** ![Warnt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/warnt/32/44486_2.png) [@Warnt](https://forum.babylonjs.com/u/Warnt)\
**Post date:** [April 26, 2025, 8:58am UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/4 "2025-04-26T08:58:46Z")

</div>

yes but that works for only model files and model url but i want to load through the embeded gltf file’s text instead. i mean like imagine opening the model file as a text document then copying all the data and then pasting it to babylon’s gltf loader

---

<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:** [April 26, 2025, 9:22am UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/5 "2025-04-26T09:22:44Z")

</div>

Do you mean like loading from a string? - [Babylon.js Playground](https://playground.babylonjs.com/#FAV3BP)

---

<div class="post-metadata">

**Author:** ![Warnt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/warnt/32/44486_2.png) [@Warnt](https://forum.babylonjs.com/u/Warnt)\
**Post date:** [April 26, 2025, 9:42am UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/6 "2025-04-26T09:42:46Z")

</div>

ah, yes! exactly. thanks a lot! i overcomplicated things and started thinking that i have to use base64 and stuff.

---

<div class="post-metadata">

**Author:** ![Warnt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/warnt/32/44486_2.png) [@Warnt](https://forum.babylonjs.com/u/Warnt)\
**Post date:** [April 26, 2025, 9:54am UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/7 "2025-04-26T09:54:50Z")

</div>

wait, i tried it but it doesn’t work for my case ☹ what have i done wrong? here is my code:

async gltfFile(input) {  
let gltf = input.file;

```
            await BABYLON.AppendSceneAsync(`data:${gltf}`, scene);
            scene.createDefaultCameraOrLight(true, true, true);

            gltf = null;
        }

```

it gives a big chunk of error saying that it cannot load it

---

<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:** [April 26, 2025, 10:01am UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/8 "2025-04-26T10:01:06Z")

</div>

Embedded GLTF is actually a JSON. Please add checks that you load or parse it as it should be 🙂  
Probably you may need JSON.stringify()…

---

<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:** [April 26, 2025, 10:16am UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/9 "2025-04-26T10:16:54Z")

</div>

For example - [Babylon.js Playground](https://playground.babylonjs.com/#KQNUEW)

---

<div class="post-metadata">

**Author:** ![Warnt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/warnt/32/44486_2.png) [@Warnt](https://forum.babylonjs.com/u/Warnt)\
**Post date:** [April 26, 2025, 2:02pm UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/10 "2025-04-26T14:02:32Z")

</div>

well that stingify function doesn’t work. after i made it, there is no errors at all but there is no mesh imported

---

<div class="post-metadata">

**Author:** ![Warnt](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/warnt/32/44486_2.png) [@Warnt](https://forum.babylonjs.com/u/Warnt)\
**Post date:** [April 26, 2025, 4:37pm UTC](https://forum.babylonjs.com/t/help-with-importing-models-from-an-embeded-gltf-files-text/58060/11 "2025-04-26T16:37:13Z")

</div>

well i just found out that using blobs do the job
