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.

VisualInstance3D

繼承: Node3D < Node < Object

被繼承: Decal, FogVolume, GeometryInstance3D, GPUParticlesAttractor3D, GPUParticlesCollision3D, Light3D, LightmapGI, OccluderInstance3D, OpenXRVisibilityMask, ReflectionProbe, RootMotionView, VisibleOnScreenNotifier3D, VoxelGI

所有可視 3D 節點的父節點。

說明

VisualInstance3D 可用於將資源連接到視覺表示。所有的視覺化 3D 節點都繼承自 VisualInstance3D。一般來說,你不應該直接存取 VisualInstance3D 的屬性,因為它們是由繼承自 VisualInstance3D 的節點存取和管理的。VisualInstance3DRenderingServer 實例的節點表示。

屬性

int

layers

1

float

sorting_offset

0.0

bool

sorting_use_aabb_center

方法

AABB

_get_aabb() virtual const

AABB

get_aabb() const

RID

get_base() const

RID

get_instance() const

bool

get_layer_mask_value(layer_number: int) const

void

set_base(base: RID)

void

set_layer_mask_value(layer_number: int, value: bool)


屬性說明

int layers = 1 🔗

  • void set_layer_mask(value: int)

  • int get_layer_mask()

繪製該 VisualInstance3D 的算繪層。

Camera3D 的剔除遮罩包含該 VisualInstance3D 所設定的任何算繪層時,該物件才在該相機中可見。

對於 Light3D,可以用於控制指定的燈光能夠影響哪些 VisualInstance3D。對於 GPUParticles3D,可以用於控制哪些粒子受到吸引器的影響。對於 Decal,可以用於控制哪些 VisualInstance3D 受到指定裝飾的影響。

要在腳本中更加方便地調整 layers,請使用 get_layer_mask_value()set_layer_mask_value()

注意:VoxelGI、SDFGI、LightmapGI 在確定全域光照影響時始終會考慮所有算繪層。如果不希望這樣,請將網格的 GeometryInstance3D.gi_mode 設定為 GeometryInstance3D.GI_MODE_DISABLED,將燈光的 Light3D.light_bake_mode 設定為 Light3D.BAKE_DISABLED,這樣就能從全域光照中剔除。


float sorting_offset = 0.0 🔗

  • void set_sorting_offset(value: float)

  • float get_sorting_offset()

按深度排序時該 VisualInstance3D 的深度將調整的量。使用與引擎相同的單位(通常是米)。將其調整為更高的值,將使 VisualInstance3D 可靠地繪製在位於同一位置的其他 VisualInstance3D 之上。為確保它始終繪製在它周圍的其他物件之上(不位於同一位置),請將值設定為大於該 VisualInstance3D 與附近其他 VisualInstance3D 之間的距離值。


bool sorting_use_aabb_center 🔗

  • void set_sorting_use_aabb_center(value: bool)

  • bool is_sorting_use_aabb_center()

如果為 true,則該物件會根據其 AABB 中心點排序。否則會根據其全局位置排序。

對 3D 模型而言,根據 AABB 的中心點排序一般更為精確。使用 GPUParticles3DCPUParticles3D 時,根據位置排序能夠更好地控制繪製順序。


方法說明

AABB _get_aabb() virtual const 🔗

There is currently no description for this method. Please help us by contributing one!


AABB get_aabb() const 🔗

返回此 VisualInstance3DAABB(也叫邊界框)。


RID get_base() const 🔗

返回與此 VisualInstance3D 相關聯的資源的 RID。例如,如果該節點是 MeshInstance3D,則會返回相關聯的 Mesh 的 RID。


RID get_instance() const 🔗

返回這個實例的 RID。這個 RID 與 RenderingServer.instance_create() 返回的 RID 相同。如果你想為這個 VisualInstance3D 直接呼叫 RenderingServer 函數,就需要這個 RID。


bool get_layer_mask_value(layer_number: int) const 🔗

返回是否啟用了 layers 的指定層,該層由一個介於 1 和 20 之間的 layer_number 指定。


void set_base(base: RID) 🔗

設定由該 VisualInstance3D 產生實體的資源,這將改變引擎在底層對該 VisualInstance3D 的處理方式。相當於 RenderingServer.instance_set_base()


void set_layer_mask_value(layer_number: int, value: bool) 🔗

基於 value,啟用或禁用 layers 中的指定層,該層由一個介於 1 和 20 之間的給定 layer_number 指定。