Hello,
is there a way to read the download size or the file size from the Texture(Texture | Babylon.js Documentation) Class ? Or any other way?
I found a way to get it from meshes by using the onProgress callback from the sceneloader(SceneLoader | Babylon.js Documentation) and reading the event.total. Is there a better way to get this information?
Thanks in advance !
Hello!
I don’t see any direct way from the Texture class, but you could get the size from the URL in some other way, like: How do you get the file size of an image on the web page with Javascript? - Stack Overflow
The meshes method is the expected way of doing that
Thanks, that works!
I assumed loading textures like this would cause higher loading time since i explicitly need to await the request.
However that doesn’t seem to be the case / the difference is small enough.
let res = await fetch(texture);
let buffer = await res.arrayBuffer();
let tex = Texture.LoadFromDataString(texture, buffer, scene);
let sizeMb = buffer.byteLength / 1000000;
1 Like