Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

SpriteBase3D

繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object

被繼承: AnimatedSprite3D, Sprite3D

3D 環境中的 2D 精靈節點。

說明

在 3D 環境中顯示 2D 紋理資訊的節點。另請參閱 Sprite3D,其中定義了許多其他屬性。

屬性

float

alpha_antialiasing_edge

0.0

AlphaAntiAliasing

alpha_antialiasing_mode

0

AlphaCutMode

alpha_cut

0

float

alpha_hash_scale

1.0

float

alpha_scissor_threshold

0.5

Axis

axis

2

BillboardMode

billboard

0

bool

centered

true

bool

double_sided

true

bool

fixed_size

false

bool

flip_h

false

bool

flip_v

false

Color

modulate

Color(1, 1, 1, 1)

bool

no_depth_test

false

Vector2

offset

Vector2(0, 0)

float

pixel_size

0.01

int

render_priority

0

bool

shaded

false

TextureFilter

texture_filter

3

bool

transparent

true

方法

TriangleMesh

generate_triangle_mesh() const

bool

get_draw_flag(flag: DrawFlags) const

Rect2

get_item_rect() const

void

set_draw_flag(flag: DrawFlags, enabled: bool)


列舉

enum DrawFlags: 🔗

DrawFlags FLAG_TRANSPARENT = 0

如果設定,紋理的透明度和不透明性用於使精靈的這些部分不可見。

DrawFlags FLAG_SHADED = 1

如果設定,環境中的燈光會影響精靈。

DrawFlags FLAG_DOUBLE_SIDED = 2

如果啟用,則紋理也可以從背面看到。如果未啟用,則紋理從後面查看時不可見。

DrawFlags FLAG_DISABLE_DEPTH_TEST = 3

禁用深度測試,所以這個物件被畫在所有其他物件的上面。但是,在繪製順序中,在它之後繪製的物件可能會覆蓋它。

DrawFlags FLAG_FIXED_SIZE = 4

標籤會根據深度進行縮放,從而在螢幕上始終以相同的大小顯示。

DrawFlags FLAG_MAX = 5

代表 DrawFlags 列舉的大小。


enum AlphaCutMode: 🔗

AlphaCutMode ALPHA_CUT_DISABLED = 0

這個模式會進行標準的 Alpha 混合。可以顯示半透明區域,但透明材質存在重疊時可能會暴露透明度排序問題。

AlphaCutMode ALPHA_CUT_DISCARD = 1

該模式僅允許完全透明或完全不透明的圖元。除非啟用了某種形式的螢幕空間抗鋸齒(請參閱 ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa),否則會看到粗糙的邊緣。從好的方面來說,當多個透明材質重疊時,該模式不會出現透明度排序問題。這種模式也被稱為 alpha 測試1 位透明度

AlphaCutMode ALPHA_CUT_OPAQUE_PREPASS = 2

該模式在深度預算繪階段繪製完全不透明的圖元。這比 ALPHA_CUT_DISABLEDALPHA_CUT_DISCARD 慢,但它允許在使用正確排序的同時顯示半透明區域和平滑邊緣。

AlphaCutMode ALPHA_CUT_HASH = 3

該模式繪製時會截斷所有低於空間確定性閾值的值,其餘值將保持不透明。


屬性說明

float alpha_antialiasing_edge = 0.0 🔗

  • void set_alpha_antialiasing_edge(value: float)

  • float get_alpha_antialiasing_edge()

在 Alpha 通道上套用抗鋸齒的臨界值。


AlphaAntiAliasing alpha_antialiasing_mode = 0 🔗

要套用的 Alpha 抗鋸齒類型。


AlphaCutMode alpha_cut = 0 🔗

The alpha cutting mode to use for the sprite.


float alpha_hash_scale = 1.0 🔗

  • void set_alpha_hash_scale(value: float)

  • float get_alpha_hash_scale()

Alpha Hash 的雜湊比例,建議值介於 02 之間。


float alpha_scissor_threshold = 0.5 🔗

  • void set_alpha_scissor_threshold(value: float)

  • float get_alpha_scissor_threshold()

Alpha 裁剪丟棄數值的閾值。


Axis axis = 2 🔗

  • void set_axis(value: Axis)

  • Axis get_axis()

紋理正面朝向的方向。


BillboardMode billboard = 0 🔗

The billboard mode to use for the sprite.

Note: When billboarding is enabled and the material also casts shadows, billboards will face the camera in the scene when rendering shadows. In scenes with multiple cameras, the intended shadow cannot be determined and this will result in undefined behavior. See GitHub Pull Request #72638 for details.


bool centered = true 🔗

  • void set_centered(value: bool)

  • bool is_centered()

如果為 true,紋理將被居中。


bool double_sided = true 🔗

如果為 true,則從後面也可以看到紋理,如果為 false,則從後面看它是不可見的。


bool fixed_size = false 🔗

If true, the texture is rendered at the same size regardless of distance. The texture's size on screen is the same as if the camera was 1.0 units away from the texture's origin, regardless of the actual distance from the camera. The Camera3D's field of view (or Camera3D.size when in orthogonal/frustum mode) still affects the size the sprite is drawn at.


bool flip_h = false 🔗

  • void set_flip_h(value: bool)

  • bool is_flipped_h()

若為 true,紋理將水平翻轉。


bool flip_v = false 🔗

  • void set_flip_v(value: bool)

  • bool is_flipped_v()

若為 true,紋理將垂直翻轉。


Color modulate = Color(1, 1, 1, 1) 🔗

  • void set_modulate(value: Color)

  • Color get_modulate()

A color value used to multiply the texture's colors. Can be used for mood-coloring or to simulate the color of ambient light.

Note: Unlike CanvasItem.modulate for 2D, colors with values above 1.0 (overbright) are not supported.

Note: If a GeometryInstance3D.material_override is defined on the SpriteBase3D, the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in modulate will be ignored. For a BaseMaterial3D, BaseMaterial3D.vertex_color_use_as_albedo must be true. For a ShaderMaterial, ALBEDO *= COLOR.rgb; must be inserted in the shader's fragment() function.


bool no_depth_test = false 🔗

若設為 true,將停用深度測試,物件依繪製順序顯示。


Vector2 offset = Vector2(0, 0) 🔗

The texture's drawing offset.

Note: When you increase offset.y in Sprite3D, the sprite moves upward in world space (i.e., +Y is up).


float pixel_size = 0.01 🔗

  • void set_pixel_size(value: float)

  • float get_pixel_size()

精靈上一個圖元寬度的大小,以 3D 縮放。


int render_priority = 0 🔗

  • void set_render_priority(value: int)

  • int get_render_priority()

設定該精靈的算繪優先順序。優先順序高的物體將被排序在優先順序低的物體前面。

注意:僅在 alpha_cutALPHA_CUT_DISABLED(預設值)時適用。

注意:僅適用於透明物體的排序。這不會影響透明物體相對於不透明物體的排序方式。這是因為不透明物件不被排序,而透明物件則從後往前排序(取決於優先順序)。


bool shaded = false 🔗

如果為 true,則 Environment 中的 Light3D 對該精靈有影響。


TextureFilter texture_filter = 3 🔗

Filter flags for the texture.

Note: Linear filtering may cause artifacts around the edges, which are especially noticeable on opaque textures. To prevent this, use textures with transparent or identical colors around the edges.


bool transparent = true 🔗

如果為 true,紋理的透明度和不透明度用於使精靈的這些部分不可見。


方法說明

TriangleMesh generate_triangle_mesh() const 🔗

返回一個 TriangleMesh,其中精靈的頂點遵循它的目前配置(例如它的 axispixel_size)。


bool get_draw_flag(flag: DrawFlags) const 🔗

返回指定旗標的值。


Rect2 get_item_rect() const 🔗

返回表示此精靈的矩形。


void set_draw_flag(flag: DrawFlags, enabled: bool) 🔗

If true, the specified flag will be enabled.