Is there an event that I can watch for when a texture does not load (HTTP 404)?
How are you loading the texture? The AssetManager loads assets async, and so you would have the promise rejection or catch handler you might use.
If you’re just doing new Texture(…)
you might consider subscribing to the appropriate XHR event, as textures are loaded via an XHR call IIRC
There is a onError callback on the texture constructor that you can use for this
Or you could take that approach, which is much more simple, reasonable, and effective!
I am loading the .babylon file which references many textures - I would like to know which ones fail.
Unfortunately we do not support this at the moment Would gladly accept a PR though ?
Once the scene loads, can I iterate through all the textures to find out if any did not load?
static handleInvalidImages(scene:BABYLON.Scene){
scene.textures.forEach((texture: BABYLON.BaseTexture)=>{
// ❓ what do I do here, attach an event handler or check a value?
});
}
You can check texture.loadingError and texture.errorObject
I’m not finding those properties in TypeScript.
This was added only a month ago so it is only available in preview.
so no way to check with BJS 4.2, right?
nope
is there any way to replace the default red and black checkerboard pattern?
You can set BABYLON.Tools.FallbackTexture = a base 64 endoded image as we do here:Babylon.js/tools.ts at master · BabylonJS/Babylon.js · GitHub