Spatial.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. <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. <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. <description>
  31. Returns the current [World] resource this [Spatial] node is registered to.
  32. </description>
  33. </method>
  34. <method name="global_rotate">
  35. <return type="void" />
  36. <argument index="0" name="axis" type="Vector3" />
  37. <argument index="1" name="angle" type="float" />
  38. <description>
  39. Rotates the global (world) transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in global coordinate system.
  40. </description>
  41. </method>
  42. <method name="global_scale">
  43. <return type="void" />
  44. <argument index="0" name="scale" type="Vector3" />
  45. <description>
  46. Scales the global (world) transformation by the given [Vector3] scale factors.
  47. </description>
  48. </method>
  49. <method name="global_translate">
  50. <return type="void" />
  51. <argument index="0" name="offset" type="Vector3" />
  52. <description>
  53. Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system.
  54. </description>
  55. </method>
  56. <method name="hide">
  57. <return type="void" />
  58. <description>
  59. Disables rendering of this node. Changes [member visible] to [code]false[/code].
  60. </description>
  61. </method>
  62. <method name="is_local_transform_notification_enabled" qualifiers="const">
  63. <return type="bool" />
  64. <description>
  65. Returns whether node notifies about its local transformation changes. [Spatial] will not propagate this by default.
  66. </description>
  67. </method>
  68. <method name="is_scale_disabled" qualifiers="const">
  69. <return type="bool" />
  70. <description>
  71. Returns whether this node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale.
  72. </description>
  73. </method>
  74. <method name="is_set_as_toplevel" qualifiers="const">
  75. <return type="bool" />
  76. <description>
  77. Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.
  78. </description>
  79. </method>
  80. <method name="is_transform_notification_enabled" qualifiers="const">
  81. <return type="bool" />
  82. <description>
  83. Returns whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default.
  84. </description>
  85. </method>
  86. <method name="is_visible_in_tree" qualifiers="const">
  87. <return type="bool" />
  88. <description>
  89. 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.
  90. </description>
  91. </method>
  92. <method name="look_at">
  93. <return type="void" />
  94. <argument index="0" name="target" type="Vector3" />
  95. <argument index="1" name="up" type="Vector3" />
  96. <description>
  97. Rotates itself so that the local -Z axis points towards the [code]target[/code] position.
  98. 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.
  99. Operations take place in global space.
  100. </description>
  101. </method>
  102. <method name="look_at_from_position">
  103. <return type="void" />
  104. <argument index="0" name="position" type="Vector3" />
  105. <argument index="1" name="target" type="Vector3" />
  106. <argument index="2" name="up" type="Vector3" />
  107. <description>
  108. 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.
  109. </description>
  110. </method>
  111. <method name="orthonormalize">
  112. <return type="void" />
  113. <description>
  114. 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].
  115. </description>
  116. </method>
  117. <method name="rotate">
  118. <return type="void" />
  119. <argument index="0" name="axis" type="Vector3" />
  120. <argument index="1" name="angle" type="float" />
  121. <description>
  122. Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians.
  123. </description>
  124. </method>
  125. <method name="rotate_object_local">
  126. <return type="void" />
  127. <argument index="0" name="axis" type="Vector3" />
  128. <argument index="1" name="angle" type="float" />
  129. <description>
  130. Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system.
  131. </description>
  132. </method>
  133. <method name="rotate_x">
  134. <return type="void" />
  135. <argument index="0" name="angle" type="float" />
  136. <description>
  137. Rotates the local transformation around the X axis by angle in radians.
  138. </description>
  139. </method>
  140. <method name="rotate_y">
  141. <return type="void" />
  142. <argument index="0" name="angle" type="float" />
  143. <description>
  144. Rotates the local transformation around the Y axis by angle in radians.
  145. </description>
  146. </method>
  147. <method name="rotate_z">
  148. <return type="void" />
  149. <argument index="0" name="angle" type="float" />
  150. <description>
  151. Rotates the local transformation around the Z axis by angle in radians.
  152. </description>
  153. </method>
  154. <method name="scale_object_local">
  155. <return type="void" />
  156. <argument index="0" name="scale" type="Vector3" />
  157. <description>
  158. Scales the local transformation by given 3D scale factors in object-local coordinate system.
  159. </description>
  160. </method>
  161. <method name="set_as_toplevel">
  162. <return type="void" />
  163. <argument index="0" name="enable" type="bool" />
  164. <description>
  165. Makes the node ignore its parents transformations. Node transformations are only in global space.
  166. </description>
  167. </method>
  168. <method name="set_disable_scale">
  169. <return type="void" />
  170. <argument index="0" name="disable" type="bool" />
  171. <description>
  172. 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.
  173. </description>
  174. </method>
  175. <method name="set_identity">
  176. <return type="void" />
  177. <description>
  178. Reset all transformations for this node (sets its [Transform] to the identity matrix).
  179. </description>
  180. </method>
  181. <method name="set_ignore_transform_notification">
  182. <return type="void" />
  183. <argument index="0" name="enabled" type="bool" />
  184. <description>
  185. Sets whether the node ignores notification that its transformation (global or local) changed.
  186. </description>
  187. </method>
  188. <method name="set_notify_local_transform">
  189. <return type="void" />
  190. <argument index="0" name="enable" type="bool" />
  191. <description>
  192. Sets whether the node notifies about its local transformation changes. [Spatial] will not propagate this by default.
  193. </description>
  194. </method>
  195. <method name="set_notify_transform">
  196. <return type="void" />
  197. <argument index="0" name="enable" type="bool" />
  198. <description>
  199. 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.
  200. </description>
  201. </method>
  202. <method name="show">
  203. <return type="void" />
  204. <description>
  205. Enables rendering of this node. Changes [member visible] to [code]true[/code].
  206. </description>
  207. </method>
  208. <method name="to_global" qualifiers="const">
  209. <return type="Vector3" />
  210. <argument index="0" name="local_point" type="Vector3" />
  211. <description>
  212. Transforms [code]local_point[/code] from this node's local space to world space.
  213. </description>
  214. </method>
  215. <method name="to_local" qualifiers="const">
  216. <return type="Vector3" />
  217. <argument index="0" name="global_point" type="Vector3" />
  218. <description>
  219. Transforms [code]global_point[/code] from world space to this node's local space.
  220. </description>
  221. </method>
  222. <method name="translate">
  223. <return type="void" />
  224. <argument index="0" name="offset" type="Vector3" />
  225. <description>
  226. Changes the node's position by the given offset [Vector3].
  227. 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.
  228. </description>
  229. </method>
  230. <method name="translate_object_local">
  231. <return type="void" />
  232. <argument index="0" name="offset" type="Vector3" />
  233. <description>
  234. Changes the node's position by the given offset [Vector3] in local space.
  235. </description>
  236. </method>
  237. <method name="update_gizmo">
  238. <return type="void" />
  239. <description>
  240. Updates the [SpatialGizmo] of this node.
  241. </description>
  242. </method>
  243. </methods>
  244. <members>
  245. <member name="gizmo" type="SpatialGizmo" setter="set_gizmo" getter="get_gizmo">
  246. The [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor.
  247. </member>
  248. <member name="global_transform" type="Transform" setter="set_global_transform" getter="get_global_transform">
  249. World space (global) [Transform] of this node.
  250. </member>
  251. <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation">
  252. Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  253. [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.
  254. </member>
  255. <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees" default="Vector3( 0, 0, 0 )">
  256. Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
  257. </member>
  258. <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
  259. Scale part of the local transformation.
  260. </member>
  261. <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 )">
  262. Local space [Transform] of this node, with respect to the parent node.
  263. </member>
  264. <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3( 0, 0, 0 )">
  265. Local translation of this node.
  266. </member>
  267. <member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true">
  268. 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]).
  269. </member>
  270. </members>
  271. <signals>
  272. <signal name="visibility_changed">
  273. <description>
  274. Emitted when node visibility changes.
  275. </description>
  276. </signal>
  277. </signals>
  278. <constants>
  279. <constant name="NOTIFICATION_TRANSFORM_CHANGED" value="2000">
  280. Spatial nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform.
  281. 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.
  282. </constant>
  283. <constant name="NOTIFICATION_ENTER_WORLD" value="41">
  284. Spatial nodes receives this notification when they are registered to new [World] resource.
  285. </constant>
  286. <constant name="NOTIFICATION_EXIT_WORLD" value="42">
  287. Spatial nodes receives this notification when they are unregistered from current [World] resource.
  288. </constant>
  289. <constant name="NOTIFICATION_VISIBILITY_CHANGED" value="43">
  290. Spatial nodes receives this notification when their visibility changes.
  291. </constant>
  292. </constants>
  293. </class>