Get material's texture from url show delay

In my project, I get material’s texture from a url, I found when the meshes is loaded and loading screen disappears, it still takes several seconds for the new texture of the material to be shown, is there any way to fix this? Thanks

Could try using scene.whenReadyAsync() to wait until the scene is ready to hide the loading UI, that should work I think. :slight_smile:

1 Like

Thank you @Blake , could you think of any other way instead of touching the loading screen? Since the loading screen logic is a little complicated in my project, I also tested it in my project, it looks like does not work, still has delay

Hmm that’s the only way I can think of… :thinking:

Maybe it’s the way I test it has some problem, I found in my project, we never call the hideLoadingUI(), but it gets executed, this is the callstack, really confused about this :thinking:do you know how I can manually change when we call the hideLoadingUI()

If you call engine.displayLoadingUI() then it shouldn’t hide until you call engine.hideLoadingUI() AFAIK… Are you sure you’re calling engine.displayLoadingUI?

No, I do not see the entire project call engine.displayLoadingUI either, but we do have custom loading screen

If you call engine.displayLoadingUI() to show the loading screen then you can call engine.hideLoadingUI() when you want to hide it AFAIK… Maybe you can make a PG to show how you’re doing it that’s not working? :slight_smile:

2 Likes

Every texture has an onLoaded callback you can use. Ass suggested, hide the loading screen only when all textures were loaded. @Blake gave you all tips and tricks you need to get that to work, but as he says - it is impossible to know what the issue is without a reproduction.

Short answer - onLoaded for each texture should help you do what you want. Right answer - we have sadly no idea until we see a reproduction of what’s not working :slight_smile:

3 Likes

Trying to add one playground here, custom loading screen into playground | Babylon.js Playground (babylonjs.com)

The loading screen hides before I apply the new texture to the box, hope the loading screen can hide only when the texture has applied, so we won’t see a delay of texture appear on the box

Thanks, that helps see what’s going on. :slight_smile: So here I waited to call onReadyObservable until after the material is assigned to the mesh and also commented out the extra call to hideLoadingUI() and then it doesn’t hide until everything is ready. But IDK, maybe instead you wanted to hide the loading screen when everything’s ready but wait to assign the material until later? :thinking:

1 Like

Thank you, I’m trying to do something similar in your playground, that’s helpful, but my own project still gets some issue since we just auto show and hide the loading screen (hope can improve this by using display and hide loading screen), will try to reproduce that in playground if possible :slight_smile:

1 Like