When the DynamicTexture set null,the background color is transparent but the text can not update

documentation
#1

dynamicTexture.drawText(“0”, null, null, font, “#000000”, null, true);
image
dynamicTexture.drawText(“1”, null, null, font, “#000000”, null, true);
image

“1” can not replace “0” when the background color set null

0 Likes

Static Text to show Length of Object
#2

You may just want to call :

dynamicTexture.clear();

before rendering the text?

0 Likes

#3

this function is unuseful,when i dynamicTexture.clear();


i will get the black panel

0 Likes

#4

Leaving the background color as null means that the text to be written is written over the existing canvas so you are writing a 1 on top of your 0.

If your background is a solid color then replace null with the background color.

If your background is more complicated then you will have to re-create your background then use drawText with background color null.

dynamicTexture.clear() will fill the background with your current color which is “#000000”, ie black

1 Like

#5

The https://www.babylonjs-playground.com/#TMHF80#9 should achieve what you want. Put a textured planes as a parent of a clone textured using dynamicTexture. If is offset slightly to prvent z-fighting.

0 Likes

#6

I want my background color is transparent,you demo’s background color is grass

1 Like

#7

I had hoped you would study the code and not just looked at the result!:slightly_smiling_face:

There are TWO planes. One plane (plane) has the texture of grass, the plane (writingplane) in front of it uses dynamicTexture and is transparent and contains the numbers. The transparent writing plane is parented to the grass plane to show that you can have a background to the numbers if you wish.

By removing the grass plane you are left with just the transparent writing plane https://www.babylonjs-playground.com/#TMHF80#10 quite straightforward.

1 Like

#8

you are right,I am too impetuous,thank you for your help:脸红:

1 Like