GUI button doesnt clear the canvas

I am using multiple graphics into one dynamicTexture and since I cannot find each image after I add them, I decided to put every image into an array and by removing image I remove that image from array, clear the whole canvas and just go through the array of images and place them on the canvas on the positions they have as values.

For the beginning I want to click on the GUI button, clear the canvas and use pop() on the array of images, then I want to go through that array without the last element.

I have 2 playgrounds which are similar but one uses GUI button as trigger, the second uses plane as trigger.
Button PG which doesnt work
Plane PG which works

Does this work - Dynamic Texture update | Babylon.js Playground (babylonjs.com) ?

The UI clicks are running outside of the render loop, so you are forced to update the dynamic texture when you are making changes.

Yes, that’s it. Thanks you, this was quite easy but I didnt know about that.

1 Like