dynamicTexture.drawText(“0”, null, null, font, “#000000”, null, true);
dynamicTexture.drawText(“1”, null, null, font, “#000000”, null, true);
“1” can not replace “0” when the background color set null
dynamicTexture.drawText(“0”, null, null, font, “#000000”, null, true);
dynamicTexture.drawText(“1”, null, null, font, “#000000”, null, true);
“1” can not replace “0” when the background color set null
You may just want to call :
dynamicTexture.clear();
before rendering the text?
this function is unuseful,when i dynamicTexture.clear();
i will get the black panel
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
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.
I want my background color is transparent,you demo’s background color is grass
I had hoped you would study the code and not just looked at the result!
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.
you are right,I am too impetuous,thank you for your help:脸红: