# GLTF load from string texture loading

**URL:** <https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955>\
**Category:** Bugs\
**Created:** [February 25, 2022, 3:16pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955 "2022-02-25T15:16:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lPaul](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lpaul/32/22511_2.png) [@lPaul](https://forum.babylonjs.com/u/lPaul)\
**Post date:** [February 25, 2022, 3:16pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/1 "2022-02-25T15:16:30Z")

</div>

Hello !

I have an issue when loading a gltf file as a string.

When I load it with `BABYLON.SceneLoader.Append("./", "test.gltf", scene, function (scene) { // do something with the scene });`, it works fine (texture are fully loaded)

However, when I pass it as a string (with embedded texture) with `BABYLON.SceneLoader.Append("", "data:" + gltfString, scene, function (scene) { // do something with the scene });` it doesn’t work.

I use exactly the same file, so I guess the issue is in the gltf-loader, am I wrong ?

> **[34.47 MB file on MEGA](https://mega.nz/file/Q5sVAaDJ#EtN8Byd2SHfbPByN_zcZjdtIV4v1g1If6yhkhD61TAI)**

---

<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:** [February 25, 2022, 7:43pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/2 "2022-02-25T19:43:41Z")

</div>

You would need to specify pluginExtension from the append function for the application to detect it is a gltf file in this case

---

<div class="post-metadata">

**Author:** ![lPaul](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lpaul/32/22511_2.png) [@lPaul](https://forum.babylonjs.com/u/lPaul)\
**Post date:** [February 28, 2022, 9:12am UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/3 "2022-02-28T09:12:55Z")

</div>

I tried to specify the extension like this : `loader = BABYLON.SceneLoader.Append("", "data:" + gltf, this.scene, undefined, undefined, undefined, ".gltf");`

The mesh is loaded but the texture still fails to load with this error : `Error: /textures/0: Error while trying to load image: data:data:{"accessors":[{"buffer... - Fallback texture was used`

Can it be because the string is not well formatted and the gltf fails to parse the texture ? I don’t understand how the loader can load the gltf as a file but not as a string, even though it is exactly the same

Edit: I also tried using a base64 encoded glb, with this gltf [glTF-Sample-Models/2.0/Avocado at master · KhronosGroup/glTF-Sample-Models · GitHub](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Avocado) , and the same error is returned : `Error: /textures/2: Error while trying to load image: data:data:application/octet-stre... - Fallback texture was used`

---

<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:** [February 28, 2022, 2:44pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/4 "2022-02-28T14:44:09Z")

</div>

@bghgary might know, and a repro in the playground could help ?

---

<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:** [February 28, 2022, 4:54pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/5 "2022-02-28T16:54:06Z")

</div>

Welcome to the forums!

Are you encoding a self-contained GLB to base64 or encoding just the glTF file?

We really need a [playground](https://doc.babylonjs.com/toolsAndResources/tools/playground) to help with this one.

---

<div class="post-metadata">

**Author:** ![lPaul](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lpaul/32/22511_2.png) [@lPaul](https://forum.babylonjs.com/u/lPaul)\
**Post date:** [March 1, 2022, 5:48pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/6 "2022-03-01T17:48:45Z")

</div>

I had the problem with glTF as a string (without encoding), or with GLB encoded with base64.

Actually I tested to upgrade Babylon.js to version 5.0.0 and it works like a charm. Unfortunately, I can’t find a gltf who fits in a string and that can be saved in the playground.

However, I tested in the playground and with version 4.2.1, I have the error during loading of textures, and with version 5.0.0 I have no errors.

You can try yourself by using this [playground](https://playground.babylonjs.com/#ZMAMG6#2) and replacing the boomBox variable with the base64 encoded string of the same GLTF. You will notice that it will works with version 5.0 but not with version 4.2 !

---

<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:** [March 1, 2022, 9:06pm UTC](https://forum.babylonjs.com/t/gltf-load-from-string-texture-loading/27955/7 "2022-03-01T21:06:47Z")

</div>

Yup several improvments have been made regarding this in 5.0 that we can not back port to 4.2.1.

5.0 is now in RC and close to ship.
