Using base64 data url for Babylon GUI Image

For my UI, I have what is essentially a spritesheet that contains the icons used in the UI. The whole image file is relatively small, and right now I’ve converted it to base64 and include it directly in my code as a static string variable. Then I simply refer to that variable when creating the Babylon GUI Image objects, and then set the appropriate sourceLeft/sourceTop properties, etc.

But it occurred to me that this may be wasting memory, as unlike a typical image file URL, each Image is not referring to the “same” data url; is my assumption correct? (Would it be better to just have the icon sprite sheet downloaded and cached as a file url or have each icon as a seperate base64 image, as opposed to a base64 spritesheet?)

Thanks

1 Like

This should be good but I would like to confirm it if you can repro your use case in the playground

https://playground.babylonjs.com/#Q33X48

What I’m doing is similar to this method, and img1, img2, img3, and img4 are the “icons” that refer to the same data url.

1 Like

I’m so sorry!! For some reasons I forgot to reply to your post. My apologies!

So no worries, you are all good!

Great, good to know. Thanks for clearing it up