Spatial.xml 14 KB

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