Two questions about texture preloading

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 :wink:

thanks

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 :thinking:

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 :slight_smile:

2 Likes

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 :wink:

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.

2 Likes