Spatial.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Spatial" inherits="Node" version="3.2">
  3. <brief_description>
  4. Most basic 3D game object, parent of all 3D-related nodes.
  5. </brief_description>
  6. <description>
  7. Most basic 3D game object, with a 3D [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.
  8. 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.
  9. </description>
  10. <tutorials>
  11. <link>https://docs.godotengine.org/en/latest/tutorials/3d/introduction_to_3d.html</link>
  12. </tutorials>
  13. <methods>
  14. <method name="force_update_transform">
  15. <return type="void">
  16. </return>
  17. <description>
  18. 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.
  19. </description>
  20. </method>
  21. <method name="get_parent_spatial" qualifiers="const">
  22. <return type="Spatial">
  23. </return>
  24. <description>
  25. Returns the parent [Spatial], or an empty [Object] if no parent exists or parent is not of type [Spatial].
  26. </description>
  27. </method>
  28. <method name="get_world" qualifiers="const">
  29. <return type="World">
  30. </return>
  31. <description>
  32. Returns the current [World] resource this [Spatial] node is registered to.
  33. </description>
  34. </method>
  35. <method name="global_rotate">
  36. <return type="void">
  37. </return>
  38. <argument index="0" name="axis" type="Vector3">
  39. </argument>
  40. <argument index="1" name="angle" type="float">
  41. </argument>
  42. <description>
  43. Rotates the global (world) transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in global coordinate system.
  44. </description>
  45. </method>
  46. <method name="global_scale">
  47. <return type="void">
  48. </return>
  49. <argument index="0" name="scale" type="Vector3">
  50. </argument>
  51. <description>
  52. Scales the global (world) transformation by the given [Vector3] scale factors.
  53. </description>
  54. </method>
  55. <method name="global_translate">
  56. <return type="void">
  57. </return>
  58. <argument index="0" name="offset" type="Vector3">
  59. </argument>
  60. <description>
  61. Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system.
  62. </description>
  63. </method>
  64. <method name="hide">
  65. <return type="void">
  66. </return>
  67. <description>
  68. Disables rendering of this node. Changes [member visible] to [code]false[/code].
  69. </description>
  70. </method>
  71. <method name="is_local_transform_notification_enabled" qualifiers="const">
  72. <return type="bool">
  73. </return>
  74. <description>
  75. Returns whether node notifies about its local transformation changes. [Spatial] will not propagate this by default.
  76. </description>
  77. </method>
  78. <method name="is_scale_disabled" qualifiers="const">
  79. <return type="bool">
  80. </return>
  81. <description>
  82. Returns whether this node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale.
  83. </description>
  84. </method>
  85. <method name="is_set_as_toplevel" qualifiers="const">
  86. <return type="bool">
  87. </return>
  88. <description>
  89. Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.
  90. </description>
  91. </method>
  92. <method name="is_transform_notification_enabled" qualifiers="const">
  93. <return type="bool">
  94. </return>
  95. <description>
  96. Returns whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default.
  97. </description>
  98. </method>
  99. <method name="is_visible_in_tree" qualifiers="const">
  100. <return type="bool">
  101. </return>
  102. <description>
  103. Returns whether the node is visible, taking into consideration that its parents visibility.
  104. </description>
  105. </method>
  106. <method name="look_at">
  107. <return type="void">
  108. </return>
  109. <argument index="0" name="target" type="Vector3">
  110. </argument>
  111. <argument index="1" name="up" type="Vector3">
  112. </argument>
  113. <description>
  114. Rotates itself so that the local -Z axis points towards the [code]target[/code] position.
  115. The transform will first be rotated around the given [code]up[/code] vector, and then fully aligned to the target by a further rotation around an axis perpendicular to both the [code]target[/code] and [code]up[/code] vectors.
  116. Operations take place in global space.
  117. </description>
  118. </method>
  119. <method name="look_at_from_position">
  120. <return type="void">
  121. </return>
  122. <argument index="0" name="position" type="Vector3">
  123. </argument>
  124. <argument index="1" name="target" type="Vector3">
  125. </argument>
  126. <argument index="2" name="up" type="Vector3">
  127. </argument>
  128. <description>
  129. Moves the node to the specified [code]position[/code], and then rotates itself to point toward the [code]target[/code] as per [method look_at]. Operations take place in global space.
  130. </description>
  131. </method>
  132. <method name="orthonormalize">
  133. <return type="void">
  134. </return>
  135. <description>
  136. Resets this node's transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node's [Transform].
  137. </description>
  138. </method>
  139. <method name="rotate">
  140. <return type="void">
  141. </return>
  142. <argument index="0" name="axis" type="Vector3">
  143. </argument>
  144. <argument index="1" name="angle" type="float">
  145. </argument>
  146. <description>
  147. Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians.
  148. </description>
  149. </method>
  150. <method name="rotate_object_local">
  151. <return type="void">
  152. </return>
  153. <argument index="0" name="axis" type="Vector3">
  154. </argument>
  155. <argument index="1" name="angle" type="float">
  156. </argument>
  157. <description>
  158. Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system.
  159. </description>
  160. </method>
  161. <method name="rotate_x">
  162. <return type="void">
  163. </return>
  164. <argument index="0" name="angle" type="float">
  165. </argument>
  166. <description>
  167. Rotates the local transformation around the X axis by angle in radians.
  168. </description>
  169. </method>
  170. <method name="rotate_y">
  171. <return type="void">
  172. </return>
  173. <argument index="0" name="angle" type="float">
  174. </argument>
  175. <description>
  176. Rotates the local transformation around the Y axis by angle in radians.
  177. </description>
  178. </method>
  179. <method name="rotate_z">
  180. <return type="void">
  181. </return>
  182. <argument index="0" name="angle" type="float">
  183. </argument>
  184. <description>
  185. Rotates the local transformation around the Z axis by angle in radians.
  186. </description>
  187. </method>
  188. <method name="scale_object_local">
  189. <return type="void">
  190. </return>
  191. <argument index="0" name="scale" type="Vector3">
  192. </argument>
  193. <description>
  194. Scales the local transformation by given 3D scale factors in object-local coordinate system.
  195. </description>
  196. </method>
  197. <method name="set_as_toplevel">
  198. <return type="void">
  199. </return>
  200. <argument index="0" name="enable" type="bool">
  201. </argument>
  202. <description>
  203. Makes the node ignore its parents transformations. Node transformations are only in global space.
  204. </description>
  205. </method>
  206. <method name="set_disable_scale">
  207. <return type="void">
  208. </return>
  209. <argument index="0" name="disable" type="bool">
  210. </argument>
  211. <description>
  212. Sets whether the node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale. Changes to the local transformation scale are preserved.
  213. </description>
  214. </method>
  215. <method name="set_identity">
  216. <return type="void">
  217. </return>
  218. <description>
  219. Reset all transformations for this node (sets its [Transform] to the identity matrix).
  220. </description>
  221. </method>
  222. <method name="set_ignore_transform_notification">
  223. <return type="void">
  224. </return>
  225. <argument index="0" name="enabled" type="bool">
  226. </argument>
  227. <description>
  228. Sets whether the node ignores notification that its transformation (global or local) changed.
  229. </description>
  230. </method>
  231. <method name="set_notify_local_transform">
  232. <return type="void">
  233. </return>
  234. <argument index="0" name="enable" type="bool">
  235. </argument>
  236. <description>
  237. Sets whether the node notifies about its local transformation changes. [Spatial] will not propagate this by default.
  238. </description>
  239. </method>
  240. <method name="set_notify_transform">
  241. <return type="void">
  242. </return>
  243. <argument index="0" name="enable" type="bool">
  244. </argument>
  245. <description>
  246. Sets whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default.
  247. </description>
  248. </method>
  249. <method name="show">
  250. <return type="void">
  251. </return>
  252. <description>
  253. Enables rendering of this node. Changes [member visible] to [code]true[/code].
  254. </description>
  255. </method>
  256. <method name="to_global" qualifiers="const">
  257. <return type="Vector3">
  258. </return>
  259. <argument index="0" name="local_point" type="Vector3">
  260. </argument>
  261. <description>
  262. Transforms [code]local_point[/code] from this node's local space to world space.
  263. </description>
  264. </method>
  265. <method name="to_local" qualifiers="const">
  266. <return type="Vector3">
  267. </return>
  268. <argument index="0" name="global_point" type="Vector3">
  269. </argument>
  270. <description>
  271. Transforms [code]global_point[/code] from world space to this node's local space.
  272. </description>
  273. </method>
  274. <method name="translate">
  275. <return type="void">
  276. </return>
  277. <argument index="0" name="offset" type="Vector3">
  278. </argument>
  279. <description>
  280. Changes the node's position by the given offset [Vector3].
  281. Note that the translation [code]offset[/code] is affected by the node's scale, so if scaled by e.g. [code](10, 1, 1)[/code], a translation by an offset of [code](2, 0, 0)[/code] would actually add 20 ([code]2 * 10[/code]) to the X coordinate.
  282. </description>
  283. </method>
  284. <method name="translate_object_local">
  285. <return type="void">
  286. </return>
  287. <argument index="0" name="offset" type="Vector3">
  288. </argument>
  289. <description>
  290. Changes the node's position by the given offset [Vector3] in local space.
  291. </description>
  292. </method>
  293. <method name="update_gizmo">
  294. <return type="void">
  295. </return>
  296. <description>
  297. Updates the [SpatialGizmo] of this node.
  298. </description>
  299. </method>
  300. </methods>
  301. <members>
  302. <member name="gizmo" type="SpatialGizmo" setter="set_gizmo" getter="get_gizmo">
  303. The [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor.
  304. </member>
  305. <member name="global_transform" type="Transform" setter="set_global_transform" getter="get_global_transform">
  306. World space (global) [Transform] of this node.
  307. </member>
  308. <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation">
  309. Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  310. [b]Note:[/b] 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 [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful.
  311. </member>
  312. <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees" default="Vector3( 0, 0, 0 )">
  313. Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  314. </member>
  315. <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
  316. Scale part of the local transformation.
  317. </member>
  318. <member name="transform" type="Transform" setter="set_transform" getter="get_transform" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
  319. Local space [Transform] of this node, with respect to the parent node.
  320. </member>
  321. <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3( 0, 0, 0 )">
  322. Local translation of this node.
  323. </member>
  324. <member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true">
  325. If [code]true[/code], this node is drawn.
  326. </member>
  327. </members>
  328. <signals>
  329. <signal name="visibility_changed">
  330. <description>
  331. Emitted when node visibility changes.
  332. </description>
  333. </signal>
  334. </signals>
  335. <constants>
  336. <constant name="NOTIFICATION_TRANSFORM_CHANGED" value="2000">
  337. Spatial nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform.
  338. In order for [constant NOTIFICATION_TRANSFORM_CHANGED] to work, users first need to ask for it, with [method set_notify_transform].
  339. </constant>
  340. <constant name="NOTIFICATION_ENTER_WORLD" value="41">
  341. Spatial nodes receives this notification when they are registered to new [World] resource.
  342. </constant>
  343. <constant name="NOTIFICATION_EXIT_WORLD" value="42">
  344. Spatial nodes receives this notification when they are unregistered from current [World] resource.
  345. </constant>
  346. <constant name="NOTIFICATION_VISIBILITY_CHANGED" value="43">
  347. Spatial nodes receives this notification when their visibility changes.
  348. </constant>
  349. </constants>
  350. </class>