From a texture, how to get the native image object?

For a project in Babylon.js I would like to access the native object (the underlying data object, that may be a canvas reference, a HTMLImgElement or whatever).
From a texture reference, how to achieve this?
Three.js textures have an “source” property for this. What’s the Babylon.js equivalent?

We usually do not keep track of it to ensure early memory release but we keep track of the url.

Hi @sebavan, thx.

So if one needs to share a resource (an image) between Babylon JS and other processes (e.g. image analysis), what do you think is the best way to avoid duplicating the image? Create the image and only provide a reference to the texture?

I’m not sure I understand 100% how the textures work, but according to the source code it seems that the buffer is ignored for the creation of the internal texture, only the url being considered, does this mean that the texture will be doubled in RAM?

nope, here we keep a cache of gpu texture per url to dedup at the gpu level and save memory if 2 textures are being created with the url.

I would suggest to load the picture as ImageBitmap in this case so you can use it in both cases :slight_smile: