Files
godot-docs-l10n/classes/zh_CN/class_gltfnode.rst
Max Hilbrunner 2ba6d25aa9 Revert "Rename zh_CN/zh_TW to zh_Hans/zh_Hant"
This reverts commit 57781dc0bc.
The rename, although in line with what we did in the engine, caused problems with RTD we need to fix (or push for a fix) first.
2025-12-24 07:14:31 +01:00

399 lines
19 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_GLTFNode:
GLTFNode
========
**继承:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
glTF 节点类。
.. rst-class:: classref-introduction-group
描述
----
代表 glTF 节点。glTF 节点中可以包含名称、变换、子节点glTF 节点)以及其他专门的属性(由各自不同的类表示)。
glTF 节点通常存在于表示 glTF 文件中的所有数据的 :ref:`GLTFState<class_GLTFState>` 内部。大多数 GLTFNode 的属性都是 glTF 文件中其他数据的索引。你可以使用 :ref:`get_additional_data()<class_GLTFNode_method_get_additional_data>`:ref:`set_additional_data()<class_GLTFNode_method_set_additional_data>` 来添加额外的属性,扩展 glTF 节点。
.. rst-class:: classref-introduction-group
教程
----
- :doc:`运行时文件加载与保存 <../tutorials/io/runtime_file_loading_and_saving>`
- `glTF 场景和节点规格 <https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_004_ScenesNodes.md">`__
.. rst-class:: classref-reftable-group
属性
----
.. table::
:widths: auto
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`camera<class_GLTFNode_property_camera>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`children<class_GLTFNode_property_children>` | ``PackedInt32Array()`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`height<class_GLTFNode_property_height>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`light<class_GLTFNode_property_light>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`mesh<class_GLTFNode_property_mesh>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`String<class_String>` | :ref:`original_name<class_GLTFNode_property_original_name>` | ``""`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`parent<class_GLTFNode_property_parent>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`position<class_GLTFNode_property_position>` | ``Vector3(0, 0, 0)`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`Quaternion<class_Quaternion>` | :ref:`rotation<class_GLTFNode_property_rotation>` | ``Quaternion(0, 0, 0, 1)`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`Vector3<class_Vector3>` | :ref:`scale<class_GLTFNode_property_scale>` | ``Vector3(1, 1, 1)`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`skeleton<class_GLTFNode_property_skeleton>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`int<class_int>` | :ref:`skin<class_GLTFNode_property_skin>` | ``-1`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`visible<class_GLTFNode_property_visible>` | ``true`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
| :ref:`Transform3D<class_Transform3D>` | :ref:`xform<class_GLTFNode_property_xform>` | ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)`` |
+-------------------------------------------------+-------------------------------------------------------------+-----------------------------------------------------+
.. rst-class:: classref-reftable-group
方法
----
.. table::
:widths: auto
+---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`append_child_index<class_GLTFNode_method_append_child_index>`\ (\ child_index\: :ref:`int<class_int>`\ ) |
+---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_Variant>` | :ref:`get_additional_data<class_GLTFNode_method_get_additional_data>`\ (\ extension_name\: :ref:`StringName<class_StringName>`\ ) |
+---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`NodePath<class_NodePath>` | :ref:`get_scene_node_path<class_GLTFNode_method_get_scene_node_path>`\ (\ gltf_state\: :ref:`GLTFState<class_GLTFState>`, handle_skeletons\: :ref:`bool<class_bool>` = true\ ) |
+---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_additional_data<class_GLTFNode_method_set_additional_data>`\ (\ extension_name\: :ref:`StringName<class_StringName>`, additional_data\: :ref:`Variant<class_Variant>`\ ) |
+---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
属性说明
--------
.. _class_GLTFNode_property_camera:
.. rst-class:: classref-property
:ref:`int<class_int>` **camera** = ``-1`` :ref:`🔗<class_GLTFNode_property_camera>`
.. rst-class:: classref-property-setget
- |void| **set_camera**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_camera**\ (\ )
如果该 glTF 节点是一个相机,则 :ref:`GLTFState<class_GLTFState>`:ref:`GLTFCamera<class_GLTFCamera>` 的索引将描述该相机的属性。如果为 ``-1``\ ,则该节点不是相机。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_children:
.. rst-class:: classref-property
:ref:`PackedInt32Array<class_PackedInt32Array>` **children** = ``PackedInt32Array()`` :ref:`🔗<class_GLTFNode_property_children>`
.. rst-class:: classref-property-setget
- |void| **set_children**\ (\ value\: :ref:`PackedInt32Array<class_PackedInt32Array>`\ )
- :ref:`PackedInt32Array<class_PackedInt32Array>` **get_children**\ (\ )
:ref:`GLTFState<class_GLTFState>` 中子节点的索引。如果该 glTF 节点没有子节点,则这将是一个空数组。
**Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedInt32Array<class_PackedInt32Array>` for more details.
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_height:
.. rst-class:: classref-property
:ref:`int<class_int>` **height** = ``-1`` :ref:`🔗<class_GLTFNode_property_height>`
.. rst-class:: classref-property-setget
- |void| **set_height**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_height**\ (\ )
该节点在节点层次结构中的深度。根节点的高度为 0其子节点的高度为 1依此类推。如果为 -1则尚未计算高度。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_light:
.. rst-class:: classref-property
:ref:`int<class_int>` **light** = ``-1`` :ref:`🔗<class_GLTFNode_property_light>`
.. rst-class:: classref-property-setget
- |void| **set_light**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_light**\ (\ )
如果该 glTF 节点是一盏灯,则 :ref:`GLTFState<class_GLTFState>`:ref:`GLTFLight<class_GLTFLight>` 的索引将描述该灯的属性。如果为 -1则该节点不是灯。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_mesh:
.. rst-class:: classref-property
:ref:`int<class_int>` **mesh** = ``-1`` :ref:`🔗<class_GLTFNode_property_mesh>`
.. rst-class:: classref-property-setget
- |void| **set_mesh**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_mesh**\ (\ )
如果该 glTF 节点是网格,则 :ref:`GLTFState<class_GLTFState>`:ref:`GLTFMesh<class_GLTFMesh>` 的索引将描述该网格的属性。如果为 -1则该节点不是网格。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_original_name:
.. rst-class:: classref-property
:ref:`String<class_String>` **original_name** = ``""`` :ref:`🔗<class_GLTFNode_property_original_name>`
.. rst-class:: classref-property-setget
- |void| **set_original_name**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_original_name**\ (\ )
节点的原名。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_parent:
.. rst-class:: classref-property
:ref:`int<class_int>` **parent** = ``-1`` :ref:`🔗<class_GLTFNode_property_parent>`
.. rst-class:: classref-property-setget
- |void| **set_parent**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_parent**\ (\ )
:ref:`GLTFState<class_GLTFState>` 中父节点的索引。如果为 -1则该节点为根节点。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_position:
.. rst-class:: classref-property
:ref:`Vector3<class_Vector3>` **position** = ``Vector3(0, 0, 0)`` :ref:`🔗<class_GLTFNode_property_position>`
.. rst-class:: classref-property-setget
- |void| **set_position**\ (\ value\: :ref:`Vector3<class_Vector3>`\ )
- :ref:`Vector3<class_Vector3>` **get_position**\ (\ )
该 glTF 节点相对于其父节点的位置。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_rotation:
.. rst-class:: classref-property
:ref:`Quaternion<class_Quaternion>` **rotation** = ``Quaternion(0, 0, 0, 1)`` :ref:`🔗<class_GLTFNode_property_rotation>`
.. rst-class:: classref-property-setget
- |void| **set_rotation**\ (\ value\: :ref:`Quaternion<class_Quaternion>`\ )
- :ref:`Quaternion<class_Quaternion>` **get_rotation**\ (\ )
该 glTF 节点相对于其父节点的旋转。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_scale:
.. rst-class:: classref-property
:ref:`Vector3<class_Vector3>` **scale** = ``Vector3(1, 1, 1)`` :ref:`🔗<class_GLTFNode_property_scale>`
.. rst-class:: classref-property-setget
- |void| **set_scale**\ (\ value\: :ref:`Vector3<class_Vector3>`\ )
- :ref:`Vector3<class_Vector3>` **get_scale**\ (\ )
该 glTF 节点相对于其父节点的缩放。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_skeleton:
.. rst-class:: classref-property
:ref:`int<class_int>` **skeleton** = ``-1`` :ref:`🔗<class_GLTFNode_property_skeleton>`
.. rst-class:: classref-property-setget
- |void| **set_skeleton**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_skeleton**\ (\ )
如果该 glTF 节点具有骨架,则 :ref:`GLTFState<class_GLTFState>` 中的 :ref:`GLTFSkeleton<class_GLTFSkeleton>` 的索引将描述骨架的属性。如果为 -1则该节点没有骨架。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_skin:
.. rst-class:: classref-property
:ref:`int<class_int>` **skin** = ``-1`` :ref:`🔗<class_GLTFNode_property_skin>`
.. rst-class:: classref-property-setget
- |void| **set_skin**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_skin**\ (\ )
如果该 glTF 节点有皮肤,则 :ref:`GLTFState<class_GLTFState>` 中的 :ref:`GLTFSkin<class_GLTFSkin>` 的索引将描述皮肤的属性。如果为 -1则该节点没有皮肤。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_visible:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **visible** = ``true`` :ref:`🔗<class_GLTFNode_property_visible>`
.. rst-class:: classref-property-setget
- |void| **set_visible**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_visible**\ (\ )
如果为 ``true``\ ,则 GLTF 节点可见。如果 ``false``\ ,则 GLTF 节点不可见。这会被转换为 Godot 场景中的 :ref:`Node3D.visible<class_Node3D_property_visible>` 属性,为 ``false`` 时会导出到 ``KHR_node_visibility``\ 。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_property_xform:
.. rst-class:: classref-property
:ref:`Transform3D<class_Transform3D>` **xform** = ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)`` :ref:`🔗<class_GLTFNode_property_xform>`
.. rst-class:: classref-property-setget
- |void| **set_xform**\ (\ value\: :ref:`Transform3D<class_Transform3D>`\ )
- :ref:`Transform3D<class_Transform3D>` **get_xform**\ (\ )
glTF 节点相对于其父节点的变换。由于通常首选位置、旋转和缩放属性,因此不使用该属性。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _class_GLTFNode_method_append_child_index:
.. rst-class:: classref-method
|void| **append_child_index**\ (\ child_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GLTFNode_method_append_child_index>`
将给定的子节点索引附加到 :ref:`children<class_GLTFNode_property_children>` 数组。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_method_get_additional_data:
.. rst-class:: classref-method
:ref:`Variant<class_Variant>` **get_additional_data**\ (\ extension_name\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_GLTFNode_method_get_additional_data>`
在这个 **GLTFNode** 实例中获取额外的任意数据。这可以用来保持 :ref:`GLTFDocumentExtension<class_GLTFDocumentExtension>` 类中每个节点的状态数据,这很重要,因为它们是无状态的。
参数应该是 :ref:`GLTFDocumentExtension<class_GLTFDocumentExtension>` 的名字(不必与 glTF 文件中的扩展名相匹配),而该返回值可以是你设置的任何值。如果没有设置任何值,则返回值为 ``null``\ 。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_method_get_scene_node_path:
.. rst-class:: classref-method
:ref:`NodePath<class_NodePath>` **get_scene_node_path**\ (\ gltf_state\: :ref:`GLTFState<class_GLTFState>`, handle_skeletons\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_GLTFNode_method_get_scene_node_path>`
返回该 GLTF 节点导入后在 Godot 场景树中的 :ref:`NodePath<class_NodePath>`\ 。这在使用 :ref:`GLTFObjectModelProperty<class_GLTFObjectModelProperty>` 导入 glTF 对象模型指针时非常有用,可以处理 ``KHR_animation_pointer``\ 、\ ``KHR_interactivity`` 等扩展。
如果 ``handle_skeletons````true``\ ,则会正确解析骨骼 glTF 节点的路径。例如为 ``false`` 时为 ``^"A/B/C/Bone1/Bone2/Bone3"`` 的路径在为 ``true`` 时会变成 ``^"A/B/C/Skeleton3D:Bone3"``\ 。
.. rst-class:: classref-item-separator
----
.. _class_GLTFNode_method_set_additional_data:
.. rst-class:: classref-method
|void| **set_additional_data**\ (\ extension_name\: :ref:`StringName<class_StringName>`, additional_data\: :ref:`Variant<class_Variant>`\ ) :ref:`🔗<class_GLTFNode_method_set_additional_data>`
在这个 **GLTFNode** 实例中设置额外的任意数据。这可以用来保持 :ref:`GLTFDocumentExtension<class_GLTFDocumentExtension>` 类中每个节点的状态数据,这很重要,因为它们是无状态的。
第一个参数应该是 :ref:`GLTFDocumentExtension<class_GLTFDocumentExtension>` 的名字(不必与 glTF 文件中的扩展名相匹配),第二个参数可以是任何你想要的东西。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
.. |void| replace:: :abbr:`void (无返回值。)`