class_spatial.rst 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Spatial.xml.
  6. .. _class_Spatial:
  7. Spatial
  8. =======
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`ARVRAnchor<class_ARVRAnchor>`, :ref:`ARVRController<class_ARVRController>`, :ref:`ARVROrigin<class_ARVROrigin>`, :ref:`AudioStreamPlayer3D<class_AudioStreamPlayer3D>`, :ref:`BoneAttachment<class_BoneAttachment>`, :ref:`Camera<class_Camera>`, :ref:`CollisionObject<class_CollisionObject>`, :ref:`CollisionPolygon<class_CollisionPolygon>`, :ref:`CollisionShape<class_CollisionShape>`, :ref:`CullInstance<class_CullInstance>`, :ref:`GridMap<class_GridMap>`, :ref:`Joint<class_Joint>`, :ref:`Listener<class_Listener>`, :ref:`LOD<class_LOD>`, :ref:`MergeGroup<class_MergeGroup>`, :ref:`Navigation<class_Navigation>`, :ref:`NavigationMeshInstance<class_NavigationMeshInstance>`, :ref:`Occluder<class_Occluder>`, :ref:`Path<class_Path>`, :ref:`PathFollow<class_PathFollow>`, :ref:`Portal<class_Portal>`, :ref:`Position3D<class_Position3D>`, :ref:`ProximityGroup<class_ProximityGroup>`, :ref:`RayCast<class_RayCast>`, :ref:`RemoteTransform<class_RemoteTransform>`, :ref:`Room<class_Room>`, :ref:`RoomGroup<class_RoomGroup>`, :ref:`RoomManager<class_RoomManager>`, :ref:`ShapeCast<class_ShapeCast>`, :ref:`Skeleton<class_Skeleton>`, :ref:`SpringArm<class_SpringArm>`, :ref:`VehicleWheel<class_VehicleWheel>`
  11. Most basic 3D game object, parent of all 3D-related nodes.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Most basic 3D game object, with a 3D :ref:`Transform<class_Transform>` and visibility settings. All other 3D game objects inherit from Spatial. Use **Spatial** as a parent node to move, scale, rotate and show/hide children in a 3D project.
  16. Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless the **Spatial** object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the **Spatial**'s transform. The word local below refers to this coordinate system. The coordinate system that is attached to the **Spatial** object itself is referred to as object-local coordinate system.
  17. \ **Note:** Unless otherwise specified, all methods that have angle parameters must have angles specified as *radians*. To convert degrees to radians, use :ref:`@GDScript.deg2rad<class_@GDScript_method_deg2rad>`.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`Introduction to 3D <../tutorials/3d/introduction_to_3d>`
  22. - `All 3D Demos <https://github.com/godotengine/godot-demo-projects/tree/master/3d>`__
  23. .. rst-class:: classref-reftable-group
  24. Properties
  25. ----------
  26. .. table::
  27. :widths: auto
  28. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  29. | :ref:`SpatialGizmo<class_SpatialGizmo>` | :ref:`gizmo<class_Spatial_property_gizmo>` | |
  30. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  31. | :ref:`Vector3<class_Vector3>` | :ref:`global_position<class_Spatial_property_global_position>` | |
  32. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  33. | :ref:`Vector3<class_Vector3>` | :ref:`global_rotation<class_Spatial_property_global_rotation>` | |
  34. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  35. | :ref:`Transform<class_Transform>` | :ref:`global_transform<class_Spatial_property_global_transform>` | |
  36. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  37. | :ref:`Vector3<class_Vector3>` | :ref:`global_translation<class_Spatial_property_global_translation>` | |
  38. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`lod_range<class_Spatial_property_lod_range>` | ``10.0`` |
  40. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  41. | :ref:`MergingMode<enum_Spatial_MergingMode>` | :ref:`merging_mode<class_Spatial_property_merging_mode>` | ``0`` |
  42. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  43. | :ref:`Vector3<class_Vector3>` | :ref:`position<class_Spatial_property_position>` | |
  44. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  45. | :ref:`Vector3<class_Vector3>` | :ref:`rotation<class_Spatial_property_rotation>` | |
  46. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  47. | :ref:`Vector3<class_Vector3>` | :ref:`rotation_degrees<class_Spatial_property_rotation_degrees>` | ``Vector3( 0, 0, 0 )`` |
  48. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  49. | :ref:`Vector3<class_Vector3>` | :ref:`scale<class_Spatial_property_scale>` | ``Vector3( 1, 1, 1 )`` |
  50. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  51. | :ref:`Transform<class_Transform>` | :ref:`transform<class_Spatial_property_transform>` | ``Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )`` |
  52. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  53. | :ref:`Vector3<class_Vector3>` | :ref:`translation<class_Spatial_property_translation>` | ``Vector3( 0, 0, 0 )`` |
  54. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`visible<class_Spatial_property_visible>` | ``true`` |
  56. +----------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------+
  57. .. rst-class:: classref-reftable-group
  58. Methods
  59. -------
  60. .. table::
  61. :widths: auto
  62. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`force_update_transform<class_Spatial_method_force_update_transform>` **(** **)** |
  64. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Transform<class_Transform>` | :ref:`get_global_transform_interpolated<class_Spatial_method_get_global_transform_interpolated>` **(** **)** |
  66. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Spatial<class_Spatial>` | :ref:`get_parent_spatial<class_Spatial_method_get_parent_spatial>` **(** **)** |const| |
  68. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`World<class_World>` | :ref:`get_world<class_Spatial_method_get_world>` **(** **)** |const| |
  70. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`global_rotate<class_Spatial_method_global_rotate>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  72. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`global_scale<class_Spatial_method_global_scale>` **(** :ref:`Vector3<class_Vector3>` scale **)** |
  74. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`global_translate<class_Spatial_method_global_translate>` **(** :ref:`Vector3<class_Vector3>` offset **)** |
  76. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`hide<class_Spatial_method_hide>` **(** **)** |
  78. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_Spatial_method_is_local_transform_notification_enabled>` **(** **)** |const| |
  80. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`is_scale_disabled<class_Spatial_method_is_scale_disabled>` **(** **)** |const| |
  82. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_Spatial_method_is_set_as_toplevel>` **(** **)** |const| |
  84. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_Spatial_method_is_transform_notification_enabled>` **(** **)** |const| |
  86. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_Spatial_method_is_visible_in_tree>` **(** **)** |const| |
  88. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`look_at<class_Spatial_method_look_at>` **(** :ref:`Vector3<class_Vector3>` target, :ref:`Vector3<class_Vector3>` up **)** |
  90. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`look_at_from_position<class_Spatial_method_look_at_from_position>` **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` target, :ref:`Vector3<class_Vector3>` up **)** |
  92. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`orthonormalize<class_Spatial_method_orthonormalize>` **(** **)** |
  94. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`rotate<class_Spatial_method_rotate>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  96. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`rotate_object_local<class_Spatial_method_rotate_object_local>` **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)** |
  98. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`rotate_x<class_Spatial_method_rotate_x>` **(** :ref:`float<class_float>` angle **)** |
  100. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`rotate_y<class_Spatial_method_rotate_y>` **(** :ref:`float<class_float>` angle **)** |
  102. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`rotate_z<class_Spatial_method_rotate_z>` **(** :ref:`float<class_float>` angle **)** |
  104. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`scale_object_local<class_Spatial_method_scale_object_local>` **(** :ref:`Vector3<class_Vector3>` scale **)** |
  106. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`set_as_toplevel<class_Spatial_method_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
  108. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`set_disable_scale<class_Spatial_method_set_disable_scale>` **(** :ref:`bool<class_bool>` disable **)** |
  110. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`set_identity<class_Spatial_method_set_identity>` **(** **)** |
  112. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_ignore_transform_notification<class_Spatial_method_set_ignore_transform_notification>` **(** :ref:`bool<class_bool>` enabled **)** |
  114. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_notify_local_transform<class_Spatial_method_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  116. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`set_notify_transform<class_Spatial_method_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  118. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`show<class_Spatial_method_show>` **(** **)** |
  120. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`Vector3<class_Vector3>` | :ref:`to_global<class_Spatial_method_to_global>` **(** :ref:`Vector3<class_Vector3>` local_point **)** |const| |
  122. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`Vector3<class_Vector3>` | :ref:`to_local<class_Spatial_method_to_local>` **(** :ref:`Vector3<class_Vector3>` global_point **)** |const| |
  124. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`translate<class_Spatial_method_translate>` **(** :ref:`Vector3<class_Vector3>` offset **)** |
  126. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`translate_object_local<class_Spatial_method_translate_object_local>` **(** :ref:`Vector3<class_Vector3>` offset **)** |
  128. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`update_gizmo<class_Spatial_method_update_gizmo>` **(** **)** |
  130. +-----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. .. rst-class:: classref-section-separator
  132. ----
  133. .. rst-class:: classref-descriptions-group
  134. Signals
  135. -------
  136. .. _class_Spatial_signal_gameplay_entered:
  137. .. rst-class:: classref-signal
  138. **gameplay_entered** **(** **)**
  139. Emitted by portal system gameplay monitor when a node enters the gameplay area.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_Spatial_signal_gameplay_exited:
  143. .. rst-class:: classref-signal
  144. **gameplay_exited** **(** **)**
  145. Emitted by portal system gameplay monitor when a node exits the gameplay area.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_Spatial_signal_visibility_changed:
  149. .. rst-class:: classref-signal
  150. **visibility_changed** **(** **)**
  151. Emitted when node visibility changes.
  152. .. rst-class:: classref-section-separator
  153. ----
  154. .. rst-class:: classref-descriptions-group
  155. Enumerations
  156. ------------
  157. .. _enum_Spatial_MergingMode:
  158. .. rst-class:: classref-enumeration
  159. enum **MergingMode**:
  160. .. _class_Spatial_constant_MERGING_MODE_INHERIT:
  161. .. rst-class:: classref-enumeration-constant
  162. :ref:`MergingMode<enum_Spatial_MergingMode>` **MERGING_MODE_INHERIT** = ``0``
  163. Inherits merging mode from the node's parent. For the root node, it is equivalent to :ref:`MERGING_MODE_ON<class_Spatial_constant_MERGING_MODE_ON>`. Default.
  164. .. _class_Spatial_constant_MERGING_MODE_OFF:
  165. .. rst-class:: classref-enumeration-constant
  166. :ref:`MergingMode<enum_Spatial_MergingMode>` **MERGING_MODE_OFF** = ``1``
  167. Turn off merging in this node and children set to :ref:`MERGING_MODE_INHERIT<class_Spatial_constant_MERGING_MODE_INHERIT>`.
  168. .. _class_Spatial_constant_MERGING_MODE_ON:
  169. .. rst-class:: classref-enumeration-constant
  170. :ref:`MergingMode<enum_Spatial_MergingMode>` **MERGING_MODE_ON** = ``2``
  171. Turn on merging in this node and children set to :ref:`MERGING_MODE_INHERIT<class_Spatial_constant_MERGING_MODE_INHERIT>`.
  172. .. rst-class:: classref-section-separator
  173. ----
  174. .. rst-class:: classref-descriptions-group
  175. Constants
  176. ---------
  177. .. _class_Spatial_constant_NOTIFICATION_TRANSFORM_CHANGED:
  178. .. rst-class:: classref-constant
  179. **NOTIFICATION_TRANSFORM_CHANGED** = ``2000``
  180. Spatial nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform.
  181. In order for :ref:`NOTIFICATION_TRANSFORM_CHANGED<class_Spatial_constant_NOTIFICATION_TRANSFORM_CHANGED>` to work, users first need to ask for it, with :ref:`set_notify_transform<class_Spatial_method_set_notify_transform>`. The notification is also sent if the node is in the editor context and it has a valid gizmo.
  182. .. _class_Spatial_constant_NOTIFICATION_ENTER_WORLD:
  183. .. rst-class:: classref-constant
  184. **NOTIFICATION_ENTER_WORLD** = ``41``
  185. Spatial nodes receives this notification when they are registered to new :ref:`World<class_World>` resource.
  186. .. _class_Spatial_constant_NOTIFICATION_EXIT_WORLD:
  187. .. rst-class:: classref-constant
  188. **NOTIFICATION_EXIT_WORLD** = ``42``
  189. Spatial nodes receives this notification when they are unregistered from current :ref:`World<class_World>` resource.
  190. .. _class_Spatial_constant_NOTIFICATION_VISIBILITY_CHANGED:
  191. .. rst-class:: classref-constant
  192. **NOTIFICATION_VISIBILITY_CHANGED** = ``43``
  193. Spatial nodes receives this notification when their visibility changes.
  194. .. _class_Spatial_constant_NOTIFICATION_ENTER_GAMEPLAY:
  195. .. rst-class:: classref-constant
  196. **NOTIFICATION_ENTER_GAMEPLAY** = ``45``
  197. Spatial nodes receives this notification if the portal system gameplay monitor detects they have entered the gameplay area.
  198. .. _class_Spatial_constant_NOTIFICATION_EXIT_GAMEPLAY:
  199. .. rst-class:: classref-constant
  200. **NOTIFICATION_EXIT_GAMEPLAY** = ``46``
  201. Spatial nodes receives this notification if the portal system gameplay monitor detects they have exited the gameplay area.
  202. .. rst-class:: classref-section-separator
  203. ----
  204. .. rst-class:: classref-descriptions-group
  205. Property Descriptions
  206. ---------------------
  207. .. _class_Spatial_property_gizmo:
  208. .. rst-class:: classref-property
  209. :ref:`SpatialGizmo<class_SpatialGizmo>` **gizmo**
  210. .. rst-class:: classref-property-setget
  211. - void **set_gizmo** **(** :ref:`SpatialGizmo<class_SpatialGizmo>` value **)**
  212. - :ref:`SpatialGizmo<class_SpatialGizmo>` **get_gizmo** **(** **)**
  213. The :ref:`SpatialGizmo<class_SpatialGizmo>` for this node. Used for example in :ref:`EditorSpatialGizmo<class_EditorSpatialGizmo>` as custom visualization and editing handles in Editor.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_Spatial_property_global_position:
  217. .. rst-class:: classref-property
  218. :ref:`Vector3<class_Vector3>` **global_position**
  219. .. rst-class:: classref-property-setget
  220. - void **set_global_translation** **(** :ref:`Vector3<class_Vector3>` value **)**
  221. - :ref:`Vector3<class_Vector3>` **get_global_translation** **(** **)**
  222. Global position of this node. This is a forward-compatible alias for :ref:`global_translation<class_Spatial_property_global_translation>`.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_Spatial_property_global_rotation:
  226. .. rst-class:: classref-property
  227. :ref:`Vector3<class_Vector3>` **global_rotation**
  228. .. rst-class:: classref-property-setget
  229. - void **set_global_rotation** **(** :ref:`Vector3<class_Vector3>` value **)**
  230. - :ref:`Vector3<class_Vector3>` **get_global_rotation** **(** **)**
  231. Rotation part of the global transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  232. \ **Note:** In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a :ref:`Vector3<class_Vector3>` data structure not because the rotation is a vector, but only because :ref:`Vector3<class_Vector3>` exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_Spatial_property_global_transform:
  236. .. rst-class:: classref-property
  237. :ref:`Transform<class_Transform>` **global_transform**
  238. .. rst-class:: classref-property-setget
  239. - void **set_global_transform** **(** :ref:`Transform<class_Transform>` value **)**
  240. - :ref:`Transform<class_Transform>` **get_global_transform** **(** **)**
  241. World space (global) :ref:`Transform<class_Transform>` of this node.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_Spatial_property_global_translation:
  245. .. rst-class:: classref-property
  246. :ref:`Vector3<class_Vector3>` **global_translation**
  247. .. rst-class:: classref-property-setget
  248. - void **set_global_translation** **(** :ref:`Vector3<class_Vector3>` value **)**
  249. - :ref:`Vector3<class_Vector3>` **get_global_translation** **(** **)**
  250. Global position of this node. This is equivalent to ``global_transform.origin``.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_Spatial_property_lod_range:
  254. .. rst-class:: classref-property
  255. :ref:`float<class_float>` **lod_range** = ``10.0``
  256. .. rst-class:: classref-property-setget
  257. - void **set_lod_range** **(** :ref:`float<class_float>` value **)**
  258. - :ref:`float<class_float>` **get_lod_range** **(** **)**
  259. Determines the threshold distance at which this node will be shown or hidden when this node is parented by a :ref:`LOD<class_LOD>` node.
  260. For example, a first child with a range of ``2`` will be shown from distance 0 to 2. A second child with a range of ``5`` will be shown from distance 2 to 7, etc.
  261. .. rst-class:: classref-item-separator
  262. ----
  263. .. _class_Spatial_property_merging_mode:
  264. .. rst-class:: classref-property
  265. :ref:`MergingMode<enum_Spatial_MergingMode>` **merging_mode** = ``0``
  266. .. rst-class:: classref-property-setget
  267. - void **set_merging_mode** **(** :ref:`MergingMode<enum_Spatial_MergingMode>` value **)**
  268. - :ref:`MergingMode<enum_Spatial_MergingMode>` **get_merging_mode** **(** **)**
  269. The merging mode determines whether merging features of the engine (:ref:`MergeGroup<class_MergeGroup>` and :ref:`RoomManager<class_RoomManager>`) will attempt to operate on branches of the scene tree.
  270. The default mode inherited from the scene tree root is :ref:`MERGING_MODE_ON<class_Spatial_constant_MERGING_MODE_ON>`.
  271. \ **Note:** Merging mode determines whether the merging is **allowed** to be performed. It does not guarantee that merging will occur, which depends on whether there are suitable matching objects.
  272. .. rst-class:: classref-item-separator
  273. ----
  274. .. _class_Spatial_property_position:
  275. .. rst-class:: classref-property
  276. :ref:`Vector3<class_Vector3>` **position**
  277. .. rst-class:: classref-property-setget
  278. - void **set_translation** **(** :ref:`Vector3<class_Vector3>` value **)**
  279. - :ref:`Vector3<class_Vector3>` **get_translation** **(** **)**
  280. Local position of this node. This is a forward-compatible alias for :ref:`translation<class_Spatial_property_translation>`.
  281. .. rst-class:: classref-item-separator
  282. ----
  283. .. _class_Spatial_property_rotation:
  284. .. rst-class:: classref-property
  285. :ref:`Vector3<class_Vector3>` **rotation**
  286. .. rst-class:: classref-property-setget
  287. - void **set_rotation** **(** :ref:`Vector3<class_Vector3>` value **)**
  288. - :ref:`Vector3<class_Vector3>` **get_rotation** **(** **)**
  289. Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  290. \ **Note:** In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a :ref:`Vector3<class_Vector3>` data structure not because the rotation is a vector, but only because :ref:`Vector3<class_Vector3>` exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_Spatial_property_rotation_degrees:
  294. .. rst-class:: classref-property
  295. :ref:`Vector3<class_Vector3>` **rotation_degrees** = ``Vector3( 0, 0, 0 )``
  296. .. rst-class:: classref-property-setget
  297. - void **set_rotation_degrees** **(** :ref:`Vector3<class_Vector3>` value **)**
  298. - :ref:`Vector3<class_Vector3>` **get_rotation_degrees** **(** **)**
  299. Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_Spatial_property_scale:
  303. .. rst-class:: classref-property
  304. :ref:`Vector3<class_Vector3>` **scale** = ``Vector3( 1, 1, 1 )``
  305. .. rst-class:: classref-property-setget
  306. - void **set_scale** **(** :ref:`Vector3<class_Vector3>` value **)**
  307. - :ref:`Vector3<class_Vector3>` **get_scale** **(** **)**
  308. Scale part of the local transformation.
  309. \ **Note:** Mixed negative scales in 3D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, the scale values will either be all positive or all negative.
  310. \ **Note:** Not all nodes are visually scaled by the :ref:`scale<class_Spatial_property_scale>` property. For example, :ref:`Light<class_Light>`\ s are not visually affected by :ref:`scale<class_Spatial_property_scale>`.
  311. .. rst-class:: classref-item-separator
  312. ----
  313. .. _class_Spatial_property_transform:
  314. .. rst-class:: classref-property
  315. :ref:`Transform<class_Transform>` **transform** = ``Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )``
  316. .. rst-class:: classref-property-setget
  317. - void **set_transform** **(** :ref:`Transform<class_Transform>` value **)**
  318. - :ref:`Transform<class_Transform>` **get_transform** **(** **)**
  319. Local space :ref:`Transform<class_Transform>` of this node, with respect to the parent node.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_Spatial_property_translation:
  323. .. rst-class:: classref-property
  324. :ref:`Vector3<class_Vector3>` **translation** = ``Vector3( 0, 0, 0 )``
  325. .. rst-class:: classref-property-setget
  326. - void **set_translation** **(** :ref:`Vector3<class_Vector3>` value **)**
  327. - :ref:`Vector3<class_Vector3>` **get_translation** **(** **)**
  328. Local translation of this node.
  329. .. rst-class:: classref-item-separator
  330. ----
  331. .. _class_Spatial_property_visible:
  332. .. rst-class:: classref-property
  333. :ref:`bool<class_bool>` **visible** = ``true``
  334. .. rst-class:: classref-property-setget
  335. - void **set_visible** **(** :ref:`bool<class_bool>` value **)**
  336. - :ref:`bool<class_bool>` **is_visible** **(** **)**
  337. If ``true``, this node is drawn. The node is only visible if all of its ancestors are visible as well (in other words, :ref:`is_visible_in_tree<class_Spatial_method_is_visible_in_tree>` must return ``true``).
  338. .. rst-class:: classref-section-separator
  339. ----
  340. .. rst-class:: classref-descriptions-group
  341. Method Descriptions
  342. -------------------
  343. .. _class_Spatial_method_force_update_transform:
  344. .. rst-class:: classref-method
  345. void **force_update_transform** **(** **)**
  346. Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
  347. .. rst-class:: classref-item-separator
  348. ----
  349. .. _class_Spatial_method_get_global_transform_interpolated:
  350. .. rst-class:: classref-method
  351. :ref:`Transform<class_Transform>` **get_global_transform_interpolated** **(** **)**
  352. When using physics interpolation, there will be circumstances in which you want to know the interpolated (displayed) transform of a node rather than the standard transform (which may only be accurate to the most recent physics tick).
  353. This is particularly important for frame-based operations that take place in :ref:`Node._process<class_Node_method__process>`, rather than :ref:`Node._physics_process<class_Node_method__physics_process>`. Examples include :ref:`Camera<class_Camera>`\ s focusing on a node, or finding where to fire lasers from on a frame rather than physics tick.
  354. \ **Note:** This function creates an interpolation pump on the **Spatial** the first time it is called, which can respond to physics interpolation resets. If you get problems with "streaking" when initially following a **Spatial**, be sure to call :ref:`get_global_transform_interpolated<class_Spatial_method_get_global_transform_interpolated>` at least once *before* resetting the **Spatial** physics interpolation.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_Spatial_method_get_parent_spatial:
  358. .. rst-class:: classref-method
  359. :ref:`Spatial<class_Spatial>` **get_parent_spatial** **(** **)** |const|
  360. Returns the parent **Spatial**, or an empty :ref:`Object<class_Object>` if no parent exists or parent is not of type **Spatial**.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_Spatial_method_get_world:
  364. .. rst-class:: classref-method
  365. :ref:`World<class_World>` **get_world** **(** **)** |const|
  366. Returns the current :ref:`World<class_World>` resource this **Spatial** node is registered to.
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_Spatial_method_global_rotate:
  370. .. rst-class:: classref-method
  371. void **global_rotate** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  372. Rotates the global (world) transformation around axis, a unit :ref:`Vector3<class_Vector3>`, by specified angle in radians. The rotation axis is in global coordinate system.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_Spatial_method_global_scale:
  376. .. rst-class:: classref-method
  377. void **global_scale** **(** :ref:`Vector3<class_Vector3>` scale **)**
  378. Scales the global (world) transformation by the given :ref:`Vector3<class_Vector3>` scale factors.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_Spatial_method_global_translate:
  382. .. rst-class:: classref-method
  383. void **global_translate** **(** :ref:`Vector3<class_Vector3>` offset **)**
  384. Moves the global (world) transformation by :ref:`Vector3<class_Vector3>` offset. The offset is in global coordinate system.
  385. .. rst-class:: classref-item-separator
  386. ----
  387. .. _class_Spatial_method_hide:
  388. .. rst-class:: classref-method
  389. void **hide** **(** **)**
  390. Disables rendering of this node. Changes :ref:`visible<class_Spatial_property_visible>` to ``false``.
  391. .. rst-class:: classref-item-separator
  392. ----
  393. .. _class_Spatial_method_is_local_transform_notification_enabled:
  394. .. rst-class:: classref-method
  395. :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** |const|
  396. Returns whether node notifies about its local transformation changes. **Spatial** will not propagate this by default.
  397. .. rst-class:: classref-item-separator
  398. ----
  399. .. _class_Spatial_method_is_scale_disabled:
  400. .. rst-class:: classref-method
  401. :ref:`bool<class_bool>` **is_scale_disabled** **(** **)** |const|
  402. Returns whether this node uses a scale of ``(1, 1, 1)`` or its local transformation scale.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _class_Spatial_method_is_set_as_toplevel:
  406. .. rst-class:: classref-method
  407. :ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** |const|
  408. Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.
  409. .. rst-class:: classref-item-separator
  410. ----
  411. .. _class_Spatial_method_is_transform_notification_enabled:
  412. .. rst-class:: classref-method
  413. :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** |const|
  414. Returns whether the node notifies about its global and local transformation changes. **Spatial** will not propagate this by default.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_Spatial_method_is_visible_in_tree:
  418. .. rst-class:: classref-method
  419. :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** |const|
  420. Returns ``true`` if the node is present in the :ref:`SceneTree<class_SceneTree>`, its :ref:`visible<class_Spatial_property_visible>` property is ``true`` and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_Spatial_method_look_at:
  424. .. rst-class:: classref-method
  425. void **look_at** **(** :ref:`Vector3<class_Vector3>` target, :ref:`Vector3<class_Vector3>` up **)**
  426. Rotates the node so that the local forward axis (-Z) points toward the ``target`` position.
  427. The local up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the local forward axis. The resulting transform is orthogonal, and the scale is preserved. Non-uniform scaling may not work correctly.
  428. The ``target`` position cannot be the same as the node's position, the ``up`` vector cannot be zero, and the direction from the node's position to the ``target`` vector cannot be parallel to the ``up`` vector.
  429. Operations take place in global space.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_Spatial_method_look_at_from_position:
  433. .. rst-class:: classref-method
  434. void **look_at_from_position** **(** :ref:`Vector3<class_Vector3>` position, :ref:`Vector3<class_Vector3>` target, :ref:`Vector3<class_Vector3>` up **)**
  435. Moves the node to the specified ``position``, and then rotates itself to point toward the ``target`` as per :ref:`look_at<class_Spatial_method_look_at>`. Operations take place in global space.
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_Spatial_method_orthonormalize:
  439. .. rst-class:: classref-method
  440. void **orthonormalize** **(** **)**
  441. Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's :ref:`Transform<class_Transform>`.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_Spatial_method_rotate:
  445. .. rst-class:: classref-method
  446. void **rotate** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  447. Rotates the local transformation around axis, a unit :ref:`Vector3<class_Vector3>`, by specified angle in radians.
  448. .. rst-class:: classref-item-separator
  449. ----
  450. .. _class_Spatial_method_rotate_object_local:
  451. .. rst-class:: classref-method
  452. void **rotate_object_local** **(** :ref:`Vector3<class_Vector3>` axis, :ref:`float<class_float>` angle **)**
  453. Rotates the local transformation around axis, a unit :ref:`Vector3<class_Vector3>`, by specified angle in radians. The rotation axis is in object-local coordinate system.
  454. .. rst-class:: classref-item-separator
  455. ----
  456. .. _class_Spatial_method_rotate_x:
  457. .. rst-class:: classref-method
  458. void **rotate_x** **(** :ref:`float<class_float>` angle **)**
  459. Rotates the local transformation around the X axis by angle in radians.
  460. .. rst-class:: classref-item-separator
  461. ----
  462. .. _class_Spatial_method_rotate_y:
  463. .. rst-class:: classref-method
  464. void **rotate_y** **(** :ref:`float<class_float>` angle **)**
  465. Rotates the local transformation around the Y axis by angle in radians.
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_Spatial_method_rotate_z:
  469. .. rst-class:: classref-method
  470. void **rotate_z** **(** :ref:`float<class_float>` angle **)**
  471. Rotates the local transformation around the Z axis by angle in radians.
  472. .. rst-class:: classref-item-separator
  473. ----
  474. .. _class_Spatial_method_scale_object_local:
  475. .. rst-class:: classref-method
  476. void **scale_object_local** **(** :ref:`Vector3<class_Vector3>` scale **)**
  477. Scales the local transformation by given 3D scale factors in object-local coordinate system.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_Spatial_method_set_as_toplevel:
  481. .. rst-class:: classref-method
  482. void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
  483. Makes the node ignore its parents transformations. Node transformations are only in global space.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_Spatial_method_set_disable_scale:
  487. .. rst-class:: classref-method
  488. void **set_disable_scale** **(** :ref:`bool<class_bool>` disable **)**
  489. Sets whether the node uses a scale of ``(1, 1, 1)`` or its local transformation scale. Changes to the local transformation scale are preserved.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_Spatial_method_set_identity:
  493. .. rst-class:: classref-method
  494. void **set_identity** **(** **)**
  495. Reset all transformations for this node (sets its :ref:`Transform<class_Transform>` to the identity matrix).
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_Spatial_method_set_ignore_transform_notification:
  499. .. rst-class:: classref-method
  500. void **set_ignore_transform_notification** **(** :ref:`bool<class_bool>` enabled **)**
  501. Sets whether the node ignores notification that its transformation (global or local) changed.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_Spatial_method_set_notify_local_transform:
  505. .. rst-class:: classref-method
  506. void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
  507. Sets whether the node notifies about its local transformation changes. **Spatial** will not propagate this by default.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_Spatial_method_set_notify_transform:
  511. .. rst-class:: classref-method
  512. void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
  513. Sets whether the node notifies about its global and local transformation changes. **Spatial** will not propagate this by default, unless it is in the editor context and it has a valid gizmo.
  514. .. rst-class:: classref-item-separator
  515. ----
  516. .. _class_Spatial_method_show:
  517. .. rst-class:: classref-method
  518. void **show** **(** **)**
  519. Enables rendering of this node. Changes :ref:`visible<class_Spatial_property_visible>` to ``true``.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_Spatial_method_to_global:
  523. .. rst-class:: classref-method
  524. :ref:`Vector3<class_Vector3>` **to_global** **(** :ref:`Vector3<class_Vector3>` local_point **)** |const|
  525. Transforms ``local_point`` from this node's local space to world space.
  526. .. rst-class:: classref-item-separator
  527. ----
  528. .. _class_Spatial_method_to_local:
  529. .. rst-class:: classref-method
  530. :ref:`Vector3<class_Vector3>` **to_local** **(** :ref:`Vector3<class_Vector3>` global_point **)** |const|
  531. Transforms ``global_point`` from world space to this node's local space.
  532. .. rst-class:: classref-item-separator
  533. ----
  534. .. _class_Spatial_method_translate:
  535. .. rst-class:: classref-method
  536. void **translate** **(** :ref:`Vector3<class_Vector3>` offset **)**
  537. Changes the node's position by the given offset :ref:`Vector3<class_Vector3>`.
  538. Note that the translation ``offset`` is affected by the node's scale, so if scaled by e.g. ``(10, 1, 1)``, a translation by an offset of ``(2, 0, 0)`` would actually add 20 (``2 * 10``) to the X coordinate.
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _class_Spatial_method_translate_object_local:
  542. .. rst-class:: classref-method
  543. void **translate_object_local** **(** :ref:`Vector3<class_Vector3>` offset **)**
  544. Changes the node's position by the given offset :ref:`Vector3<class_Vector3>` in local space.
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_Spatial_method_update_gizmo:
  548. .. rst-class:: classref-method
  549. void **update_gizmo** **(** **)**
  550. Updates the :ref:`SpatialGizmo<class_SpatialGizmo>` of this node.
  551. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  552. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  553. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  554. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`