Weird behavior of onSVGAttributes playground

From The Babylon GUI | Babylon.js Documentation Batch loading of SVG images from icon sheet doc part, we have a playground showing us how to use an SVG asset : Babylon.js Playground

The first time the playground shows up, no problem, but as soon as we’re clicking on Play button, width is messing up (no matter if we are in latest BJS or 4.2.0)

uisvg

That’s not a bug, that’s a feature!.. :wink:

@msDestiny14 , want to take a look at this one?

2 Likes

Yep. Let me take a peak. :smiley:

1 Like

This might actually be a feature? :joy:

I believe the reason has to do with some optimizations we are making on the load image. onSVGAttributesComputedObservable is only called on the first instance of launching the website. When you rerun the code segment the file is the is already loaded so the attributes are not computed again and that function is not called. The default to image is 100% by 100% which is why it appears bigger.

I wonder if you have an await when you create a image and then just get the width and height using the auto scale property. Then you can scale it to the size you want. I can try to get a playground to show. :slight_smile:

Also interested in a second thought from @RaananW if this is a bug or not. Also is this exclusive to the playground based on how we have the run button.

Why not using this instead ? https://playground.babylonjs.com/#E5CARD#43

At least in this case it might make more sense to rely on imageLoaded ?

2 Likes