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.
Checking the stable version of the documentation...
SpriteBase3D
繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object
被繼承: AnimatedSprite3D, Sprite3D
3D 環境中的 2D 精靈節點。
說明
在 3D 環境中顯示 2D 紋理資訊的節點。另請參閱 Sprite3D,其中定義了許多其他屬性。
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
generate_triangle_mesh() const |
|
get_draw_flag(flag: DrawFlags) const |
|
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_DISABLED 或 ALPHA_CUT_DISCARD 慢,但它允許在使用正確排序的同時顯示半透明區域和平滑邊緣。
AlphaCutMode ALPHA_CUT_HASH = 3
該模式繪製時會截斷所有低於空間確定性閾值的值,其餘值將保持不透明。
屬性說明
float alpha_antialiasing_edge = 0.0 🔗
在 Alpha 通道上套用抗鋸齒的臨界值。
AlphaAntiAliasing alpha_antialiasing_mode = 0 🔗
void set_alpha_antialiasing(value: AlphaAntiAliasing)
AlphaAntiAliasing get_alpha_antialiasing()
要套用的 Alpha 抗鋸齒類型。
AlphaCutMode alpha_cut = 0 🔗
void set_alpha_cut_mode(value: AlphaCutMode)
AlphaCutMode get_alpha_cut_mode()
The alpha cutting mode to use for the sprite.
float alpha_hash_scale = 1.0 🔗
Alpha Hash 的雜湊比例,建議值介於 0 與 2 之間。
float alpha_scissor_threshold = 0.5 🔗
Alpha 裁剪丟棄數值的閾值。
紋理正面朝向的方向。
BillboardMode billboard = 0 🔗
void set_billboard_mode(value: BillboardMode)
BillboardMode get_billboard_mode()
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.
如果為 true,紋理將被居中。
如果為 true,則從後面也可以看到紋理,如果為 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.
若為 true,紋理將水平翻轉。
若為 true,紋理將垂直翻轉。
Color modulate = Color(1, 1, 1, 1) 🔗
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.
若設為 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).
精靈上一個圖元寬度的大小,以 3D 縮放。
設定該精靈的算繪優先順序。優先順序高的物體將被排序在優先順序低的物體前面。
注意:僅在 alpha_cut 為 ALPHA_CUT_DISABLED(預設值)時適用。
注意:僅適用於透明物體的排序。這不會影響透明物體相對於不透明物體的排序方式。這是因為不透明物件不被排序,而透明物件則從後往前排序(取決於優先順序)。
如果為 true,則 Environment 中的 Light3D 對該精靈有影響。
TextureFilter texture_filter = 3 🔗
void set_texture_filter(value: TextureFilter)
TextureFilter get_texture_filter()
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.
如果為 true,紋理的透明度和不透明度用於使精靈的這些部分不可見。
方法說明
TriangleMesh generate_triangle_mesh() const 🔗
返回一個 TriangleMesh,其中精靈的頂點遵循它的目前配置(例如它的 axis 和 pixel_size)。
bool get_draw_flag(flag: DrawFlags) const 🔗
返回指定旗標的值。
返回表示此精靈的矩形。
void set_draw_flag(flag: DrawFlags, enabled: bool) 🔗
If true, the specified flag will be enabled.