Spatial.xml 15 KB

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