Hi everyone, I am strugulling to access the image data once the texture is loaded.
I have explored the call stack for a long time and found the img variable I need to access in the fileTool.ts but I can’t find a way to add an observer or a callback to retrive this object.
Can someone help please ?
Here is a simple example of what I want.
PS: The goal is to benefit from the image data; I don’t want to fetch it again to access it because it’s causing performance issues in my app.
Hi Tricotou, thanks for your answer; no in fact I need the original fetch response from the server or the complete image; I want to read the exifr data in the header of the png which contain useful informations
Hi Labris, thanks for your anwser; yes it’s very fast because they are in cache but if it can be done only 1 time it’s better as the number of images to load can be big.
Your exemple is closer than want I want to do but this uses a glb file. I’m not sure how to adapt this to load a texture.
They are simple png containing size and position informations;
I load them by giving the url to the texture.
I tried to mix your suggestions but the texture._buffer which contains the exifr informations in the Labris’s example is null is my case.
The image is created from pixel data, so there will be no exif information from the original image.
But if you already have original PNGs, I believe you don’t need to use readPixels which is CPU perf consuming. Just extract all needed information from PNGs at the moment of texture creation and store as texture.metadata for later use.
thanks for your answer, I give up on that, internally that’s what Babylon does when you give a buffer or an image element so you always end up making 2 requests.
I can’t find a way to make [creating the texture using the url and requesting the metadata from a separate file] slower [than fetching the data, extracting the exifr and instantiating the texture with a blob url].
So I’ll keep my data in a separate file (which seemed counterintuitive at first)