How can I catch a missing KTX file?

In this example, I’ve set up a texture for a URL in which I know there is no KTX file.

https://www.babylonjs-playground.com/#05Q46H#8

My use case is when a texture falls back to PNG, I’d like to know this happened on the client so I can add observability. Is this possible?

Maybe you can check tex.url?

Just from my tests, that value doesn’t get set correctly if the first texture is missing but the second one succeeds. I think it might be good to set a prop on textures with the final loaded texture format. But also add an observable for texture load failures that return the URL that failed?

Could you provide a repro? The url property should hold the right value.

Regarding the observable, pinging @Deltakosh or @sebavan.

In this example, the result of url is the PNG path whether or not the KTX fails:

https://www.babylonjs-playground.com/index.html#1SCH7H#56

You can test this by blocking the KTX url in Chrome network tools.

In this one, it’s also PNG:

https://www.babylonjs-playground.com/#05Q46H#9

In fact you get in texture.url the url with which you called the texture constructor, and in texture.getInternalTexture().url the url that has really been used to fetch the data.

Yep, that works. Thank you!