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...
GLTFNode
繼承: Resource < RefCounted < Object
glTF 節點類。
說明
代表 glTF 節點。glTF 節點中可以包含名稱、變換、子節點(glTF 節點)以及其他專門的屬性(由各自不同的類表示)。
glTF 節點通常存在於表示 glTF 檔案中的所有資料的 GLTFState 內部。大多數 GLTFNode 的屬性都是 glTF 檔案中其他資料的索引。你可以使用 get_additional_data() 和 set_additional_data() 來新增額外的屬性,擴充 glTF 節點。
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
append_child_index(child_index: int) |
get_additional_data(extension_name: StringName) |
|
get_scene_node_path(gltf_state: GLTFState, handle_skeletons: bool = true) |
|
void |
set_additional_data(extension_name: StringName, additional_data: Variant) |
屬性說明
如果該 glTF 節點是一個相機,則 GLTFState 中 GLTFCamera 的索引將描述該相機的屬性。如果為 -1,則該節點不是相機。
PackedInt32Array children = PackedInt32Array() 🔗
void set_children(value: PackedInt32Array)
PackedInt32Array get_children()
GLTFState 中子節點的索引。如果該 glTF 節點沒有子節點,則這將是一個空陣列。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedInt32Array for more details.
該節點在節點層次結構中的深度。根節點的高度為 0,其子節點的高度為 1,依此類推。如果為 -1,則尚未計算高度。
如果該 glTF 節點是一盞燈,則 GLTFState 中 GLTFLight 的索引將描述該燈的屬性。如果為 -1,則該節點不是燈。
如果該 glTF 節點是網格,則 GLTFState 中 GLTFMesh 的索引將描述該網格的屬性。如果為 -1,則該節點不是網格。
節點的原名。
GLTFState 中父節點的索引。如果為 -1,則該節點為根節點。
Vector3 position = Vector3(0, 0, 0) 🔗
該 glTF 節點相對於其父節點的位置。
Quaternion rotation = Quaternion(0, 0, 0, 1) 🔗
void set_rotation(value: Quaternion)
Quaternion get_rotation()
該 glTF 節點相對於其父節點的旋轉。
Vector3 scale = Vector3(1, 1, 1) 🔗
該 glTF 節點相對於其父節點的縮放。
如果該 glTF 節點具有骨架,則 GLTFState 中的 GLTFSkeleton 的索引將描述骨架的屬性。如果為 -1,則該節點沒有骨架。
如果該 glTF 節點有皮膚,則 GLTFState 中的 GLTFSkin 的索引將描述皮膚的屬性。如果為 -1,則該節點沒有皮膚。
如果為 true,則 GLTF 節點可見。如果 false,則 GLTF 節點不可見。這會被轉換為 Godot 場景中的 Node3D.visible 屬性,為 false 時會匯出到 KHR_node_visibility。
Transform3D xform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) 🔗
void set_xform(value: Transform3D)
Transform3D get_xform()
glTF 節點相對於其父節點的變換。由於通常首選位置、旋轉和縮放屬性,因此不使用該屬性。
方法說明
void append_child_index(child_index: int) 🔗
將給定的子節點索引附加到 children 陣列。
Variant get_additional_data(extension_name: StringName) 🔗
在這個 GLTFNode 實例中取得額外的任意資料。這可以用來保持 GLTFDocumentExtension 類中每個節點的狀態資料,這很重要,因為它們是無狀態的。
參數應該是 GLTFDocumentExtension 的名字(不必與 glTF 檔案中的副檔名相匹配),而該回傳值可以是你設定的任何值。如果沒有設定任何值,則回傳值為 null。
NodePath get_scene_node_path(gltf_state: GLTFState, handle_skeletons: bool = true) 🔗
回傳該 GLTF 節點匯入後在 Godot 場景樹中的 NodePath。這在使用 GLTFObjectModelProperty 匯入 glTF 物件模型指針時非常有用,可以處理 KHR_animation_pointer、KHR_interactivity 等擴充。
如果 handle_skeletons 為 true,則會正確解析骨骼 glTF 節點的路徑。例如為 false 時為 ^"A/B/C/Bone1/Bone2/Bone3" 的路徑在為 true 時會變成 ^"A/B/C/Skeleton3D:Bone3"。
void set_additional_data(extension_name: StringName, additional_data: Variant) 🔗
在這個 GLTFNode 實例中設定額外的任意資料。這可以用來保持 GLTFDocumentExtension 類中每個節點的狀態資料,這很重要,因為它們是無狀態的。
第一個參數應該是 GLTFDocumentExtension 的名字(不必與 glTF 檔案中的副檔名相匹配),第二個參數可以是任何你想要的東西。