# Two questions about texture preloading

**URL:** <https://forum.babylonjs.com/t/two-questions-about-texture-preloading/34011>\
**Category:** Questions\
**Created:** [September 18, 2022, 12:28am UTC](https://forum.babylonjs.com/t/two-questions-about-texture-preloading/34011 "2022-09-18T00:28:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaderbytes](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/shaderbytes/32/174_2.png) [@shaderbytes](https://forum.babylonjs.com/u/shaderbytes)\
**Post date:** [September 18, 2022, 12:28am UTC](https://forum.babylonjs.com/t/two-questions-about-texture-preloading/34011/1 "2022-09-18T00:28:32Z")

</div>

Hi all

So two scenarios in my app , one, when im just loading an external image for a texture

and two, when loading glb files that have emmbedded textures.

the issue is without doing this , when you set a channel to a texture object with a url argument , the asset actualy becomes invisible until the texture loads which I want to avoid.

I cant say i’ve studing both situations indepth, Just thinking, I know I can handle preloading the external textures and the only set the channel once loaded. ( although then it pulls it from the browser cache because of still passing a url) . So if I preload it can i inject the loaded texture instead of a url?

Question 2 is for glb models with textures. Does the sucess callback get called when the asset and embedded textures are loaded , im presuming this is the case because its a single file load , but my question is does it also cause the fgeometry to dissapear for a moment when it sets up the materials and textures?

Lastly , do you guys perhaps have solutions for this built into the engine? I would not want to waste time coding it is this is possible already 😉

thanks

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [September 19, 2022, 12:36pm UTC](https://forum.babylonjs.com/t/two-questions-about-texture-preloading/34011/2 "2022-09-19T12:36:17Z")

</div>

Hmmm, the callback is called after the texture is loaded, but I’m not sure before or after the shader is compiled. @sebavan do you know?

I think the best solution would be to use AssetContainer 🤔

---

<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 19, 2022, 3:26pm UTC](https://forum.babylonjs.com/t/two-questions-about-texture-preloading/34011/3 "2022-09-19T15:26:13Z")

</div>

About 1, just wait for onLoaded before assigning the texture to the material. Assuming there was already a texture, it won t require a shader compilation so you won t lose any frames.

About 2, the success callback will be called and if you wait like in the scenario 1 onLoaded for your textures, it should be pretty similar 🙂

---

<div class="post-metadata">

**Author:** ![shaderbytes](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/shaderbytes/32/174_2.png) [@shaderbytes](https://forum.babylonjs.com/u/shaderbytes)\
**Post date:** [September 20, 2022, 12:08am UTC](https://forum.babylonjs.com/t/two-questions-about-texture-preloading/34011/4 "2022-09-20T00:08:09Z")

</div>

thanks

> Texture onLoadObservable

and

> Observable addOnce

are perfect , so nice to have an observable already on the object and a method to add more than one callback and have auto removal… you guys thought of it all, I swear I think you guys have done this sort of thing before 😉

There are no longer scenarios where geometry dissapears , I did have to use this as well , isReady was not enough :

> isReadyOrNotBlocking()

You guys really are great.
