text(data, x, y, z)
Use this for your code
As I said you can just bring your text forward by increasing the Z position in P3D, Now the text you are adding is in the 0 Z position and your rectangle in the 30, so logically it would appear in front.
Regards Jose