Get DynamicTexture text and change it

I copied the following playground into my scene and got the text working.
I want to be able to change/update the text on the Dynamic Texture afterwards, and also need a way to read what text is on the DynamicTexture. Couldn’t find what I’m looking in my research:


Hope this helps.

1 Like

Thank you! This worked.

However I still have a small problem.

Updating the texture with a transparent background doesnt seem to delete the previous text:



Any way of fixing this?

And how would I be able to recalculate the width of the plane to fit the text?

Here is the fix Fix dynamic texture clear with transparency by sebavan · Pull Request #14507 · BabylonJS/Babylon.js · GitHub


Thanks for the PR.

For anyone interested, a workaround to this issue would be to do the following, before updating the text:

const ctx = dynamicTexture.getContext();
ctx.clearRect(0, 0, 1000, 1000); //
1 Like