Label3D
Displays plain text in a 3D world.
Label3D displays plain text in a 3D world. It gives you control over the horizontal and vertical alignment.
Properties
generate_triangle_mesh ( ) const | |
get_draw_flag ( flag ) const | |
void | set_draw_flag ( flag, bool enabled ) |
Enumerations
enum DrawFlags:
FLAG_SHADED = 0 —- If set, lights in the environment affect the label.
FLAG_DOUBLE_SIDED = 1 —- If set, text can be seen from the back as well. If not, the text is invisible when looking at it from behind.
FLAG_DISABLE_DEPTH_TEST = 2 —- Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.
FLAG_FIXED_SIZE = 3 —- Label is scaled by depth so that it always appears the same size on screen.
FLAG_MAX = 4 —- Represents the size of the DrawFlags enum.
enum AlphaCutMode:
ALPHA_CUT_DISABLED = 0 —- This mode performs standard alpha blending. It can display translucent areas, but transparency sorting issues may be visible when multiple transparent materials are overlapping.
ALPHA_CUT_DISCARD = 1 —- This mode only allows fully transparent or fully opaque pixels. This mode is also known as alpha testing or 1-bit transparency.
Note: This mode might have issues with anti-aliased fonts and outlines, try adjusting or using SDF font.
- ALPHA_CUT_OPAQUE_PREPASS = 2 —- This mode draws fully opaque pixels in the depth prepass. This is slower than ALPHA_CUT_DISABLED or , but it allows displaying translucent areas and smooth edges while using proper sorting.
Note: When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.
enum Align:
ALIGN_CENTER = 1 —- Align rows centered.
ALIGN_RIGHT = 2 —- Align rows to the right.
ALIGN_FILL = 3 —- Expand row whitespaces to fit the width.
enum VAlign:
VALIGN_TOP = 0 —- Align the whole text to the top.
VALIGN_CENTER = 1 —- Align the whole text to the center.
VALIGN_BOTTOM = 2 —- Align the whole text to the bottom.
VALIGN_FILL = 3 —- Align the whole text by spreading the rows.
- alpha_cut
Default |
|
Setter | set_alpha_cut_mode(value) |
Getter | get_alpha_cut_mode() |
The alpha cutting mode to use for the sprite. See AlphaCutMode for possible values.
- alpha_scissor_threshold
Default |
|
Setter | set_alpha_scissor_threshold(value) |
Getter | get_alpha_scissor_threshold() |
Threshold at which the alpha scissor will discard values.
- bool autowrap
Default |
|
Setter | set_autowrap(value) |
Getter | get_autowrap() |
If true
, wraps the text to the .
- BillboardMode billboard
Default |
|
Setter | set_billboard_mode(value) |
Getter | get_billboard_mode() |
The billboard mode to use for the label. See for possible values.
- bool double_sided
Default |
|
Setter | set_draw_flag(value) |
Getter | get_draw_flag() |
If true
, text can be seen from the back as well, if false
, it is invisible when looking at it from behind.
- fixed_size
If true
, the label is rendered at the same size regardless of distance.
- Font font
Setter | set_font(value) |
Getter | get_font() |
used for the Label3D
‘s text.
Default |
|
Setter | set_horizontal_alignment(value) |
Getter | get_horizontal_alignment() |
Controls the text’s horizontal alignment. Supports left, center, right. Set it to one of the Align constants.
- line_spacing
Default |
|
Setter | set_line_spacing(value) |
Getter | get_line_spacing() |
Vertical space between lines in multiline Label3D
.
- Color modulate
Default | |
Setter | set_modulate(value) |
Getter | get_modulate() |
Text of the Label3D
.
- bool no_depth_test
Default | |
Setter | set_draw_flag(value) |
Getter | get_draw_flag() |
If true
, depth testing is disabled and the object will be drawn in render order.
- offset
Default |
|
Setter | set_offset(value) |
Getter | get_offset() |
The text drawing offset (in pixels).
- Color outline_modulate
The tint of ‘s outline.
- int outline_render_priority
Default |
|
Setter | set_outline_render_priority(value) |
Getter | get_outline_render_priority() |
Sets the render priority for the text outline. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies if is set to ALPHA_CUT_DISABLED (default value).
Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
- pixel_size
Default |
|
Setter | set_pixel_size(value) |
Getter | get_pixel_size() |
The size of one pixel’s width on the label to scale it in 3D.
- int render_priority
Default |
|
Setter | set_render_priority(value) |
Getter | get_render_priority() |
Sets the render priority for the text. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies if is set to ALPHA_CUT_DISABLED (default value).
Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).
- shaded
Default |
|
Setter | set_draw_flag(value) |
Getter | get_draw_flag() |
If true
, the Light in the has effects on the label.
- String text
Default |
|
Setter | set_text(value) |
Getter | get_text() |
The text to display on screen.
- uppercase
Default |
|
Setter | set_uppercase(value) |
Getter | is_uppercase() |
If true
, all the text displays as UPPERCASE.
- VAlign vertical_alignment
Controls the text’s vertical alignment. Supports top, center, bottom. Set it to one of the constants.
- float width
Default |
|
Setter | set_width(value) |
Getter | get_width() |
Text width (in pixels), used for autowrap and fill alignment.
Method Descriptions
- TriangleMesh generate_triangle_mesh ( ) const
Returns a with the label’s vertices following its current configuration (such as its pixel_size).
- void set_draw_flag ( flag, bool enabled )
If true
, the specified flag will be enabled. See for a list of flags.