Label3D

Inherits: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object

Displays plain text in a 3D world.

Description

Label3D displays plain text in a 3D world. It gives you control over the horizontal and vertical alignment.

Properties

AlphaCutMode

alpha_cut

0

float

alpha_scissor_threshold

0.5

AutowrapMode

autowrap_mode

0

BillboardMode

billboard

0

bool

double_sided

true

bool

fixed_size

false

Font

font

int

font_size

16

HorizontalAlignment

horizontal_alignment

1

String

language

""

float

line_spacing

0.0

Color

modulate

Color(1, 1, 1, 1)

bool

no_depth_test

false

Vector2

offset

Vector2(0, 0)

Color

outline_modulate

Color(0, 0, 0, 1)

int

outline_render_priority

-1

int

outline_size

0

float

pixel_size

0.01

int

render_priority

0

bool

shaded

false

StructuredTextParser

structured_text_bidi_override

0

Array

structured_text_bidi_override_options

[]

String

text

""

Direction

text_direction

0

TextureFilter

texture_filter

3

bool

uppercase

false

VerticalAlignment

vertical_alignment

1

float

width

500.0

Methods

TriangleMesh

generate_triangle_mesh ( ) const

bool

get_draw_flag ( DrawFlags flag ) const

void

set_draw_flag ( DrawFlags 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 texture 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. Harsh edges will be visible unless some form of screen-space antialiasing is enabled (see ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa). 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 alpha_scissor_threshold or using MSDF font.

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.

  • ALPHA_CUT_OPAQUE_PREPASS = 2 --- This mode draws fully opaque pixels in the depth prepass. This is slower than ALPHA_CUT_DISABLED or ALPHA_CUT_DISCARD, 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.

Property Descriptions

Default

0

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.


  • float alpha_scissor_threshold

Default

0.5

Setter

set_alpha_scissor_threshold(value)

Getter

get_alpha_scissor_threshold()

Threshold at which the alpha scissor will discard values.


Default

0

Setter

set_autowrap_mode(value)

Getter

get_autowrap_mode()

If set to something other than TextServer.AUTOWRAP_OFF, the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. To see how each mode behaves, see AutowrapMode.


Default

0

Setter

set_billboard_mode(value)

Getter

get_billboard_mode()

The billboard mode to use for the label. See BillboardMode for possible values.


Default

true

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.


Default

false

Setter

set_draw_flag(value)

Getter

get_draw_flag()

If true, the label is rendered at the same size regardless of distance.


Setter

set_font(value)

Getter

get_font()

Font configuration used to display text.


  • int font_size

Default

16

Setter

set_font_size(value)

Getter

get_font_size()

Font size of the Label3D's text.


Default

1

Setter

set_horizontal_alignment(value)

Getter

get_horizontal_alignment()

Controls the text's horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of the HorizontalAlignment constants.


Default

""

Setter

set_language(value)

Getter

get_language()

Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.


Default

0.0

Setter

set_line_spacing(value)

Getter

get_line_spacing()

Vertical space between lines in multiline Label3D.


Default

Color(1, 1, 1, 1)

Setter

set_modulate(value)

Getter

get_modulate()

Text Color of the Label3D.


  • bool no_depth_test

Default

false

Setter

set_draw_flag(value)

Getter

get_draw_flag()

If true, depth testing is disabled and the object will be drawn in render order.


Default

Vector2(0, 0)

Setter

set_offset(value)

Getter

get_offset()

The text drawing offset (in pixels).


Default

Color(0, 0, 0, 1)

Setter

set_outline_modulate(value)

Getter

get_outline_modulate()

The tint of text outline.


  • int outline_render_priority

Default

-1

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.

Node: This only applies if alpha_cut 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).


  • int outline_size

Default

0

Setter

set_outline_size(value)

Getter

get_outline_size()

Text outline size.


Default

0.01

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

0

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.

Node: This only applies if alpha_cut 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).


Default

false

Setter

set_draw_flag(value)

Getter

get_draw_flag()

If true, the Light3D in the Environment has effects on the label.


Default

0

Setter

set_structured_text_bidi_override(value)

Getter

get_structured_text_bidi_override()

Set BiDi algorithm override for the structured text.


  • Array structured_text_bidi_override_options

Default

[]

Setter

set_structured_text_bidi_override_options(value)

Getter

get_structured_text_bidi_override_options()

Set additional options for BiDi override.


Default

""

Setter

set_text(value)

Getter

get_text()

The text to display on screen.


Default

0

Setter

set_text_direction(value)

Getter

get_text_direction()

Base text writing direction.


Default

3

Setter

set_texture_filter(value)

Getter

get_texture_filter()

Filter flags for the texture. See TextureFilter for options.


Default

false

Setter

set_uppercase(value)

Getter

is_uppercase()

If true, all the text displays as UPPERCASE.


Default

1

Setter

set_vertical_alignment(value)

Getter

get_vertical_alignment()

Controls the text's vertical alignment. Supports top, center, bottom. Set it to one of the VerticalAlignment constants.


Default

500.0

Setter

set_width(value)

Getter

get_width()

Text width (in pixels), used for autowrap and fill alignment.

Method Descriptions

Returns a TriangleMesh with the label's vertices following its current configuration (such as its pixel_size).


Returns the value of the specified flag.


If true, the specified flag will be enabled. See DrawFlags for a list of flags.