How to know if a Texture and Texture Canvas is ready?

For example here

Is there a way to run code/function after a Texture is ready and the context of the Texture Canvas is ready to draw?

I have done it with SetTimeout by waiting some miliseconds and then running it but I feel like it is “unsafe” or unreliable and there should be a better way to do it.

You may try
(Get if the texture is ready to be used (downloaded, converted, mip mapped…).

(Get if the texture is ready to be consumed (either it is ready or it is not blocking))

Both will return true or false.

See API - Texture | Babylon.js Documentation


I think I figured it out.

In the case of the Texture there is this “onLoadObservable” similar to “onPointerObservable” that “triggers” when it is ready.

The Texture Canvas also has a onLoadObservable but I don’t know. It seems like it doesn’t work?

1 Like