<?xml version="1.0" encoding="UTF-8" ?> <class name="Node3D" inherits="Node" keywords="spatial" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <brief_description> Base object in 3D space, inherited by all 3D nodes. </brief_description> <description> The [Node3D] node is the base representation of a node in 3D space. All other 3D nodes inherit from this class. Affine operations (translation, rotation, scale) are calculated in the coordinate system relative to the parent, unless the [Node3D]'s [member top_level] is [code]true[/code]. In this coordinate system, affine operations correspond to direct affine operations on the [Node3D]'s [member transform]. The term [i]parent space[/i] refers to this coordinate system. The coordinate system that is attached to the [Node3D] itself is referred to as object-local coordinate system, or [i]local space[/i]. [b]Note:[/b] Unless otherwise specified, all methods that need angle parameters must receive angles in [i]radians[/i]. To convert degrees to radians, use [method @GlobalScope.deg_to_rad]. [b]Note:[/b] In Godot 3 and older, [Node3D] was named [i]Spatial[/i]. </description> <tutorials> <link title="Introduction to 3D">$DOCS_URL/tutorials/3d/introduction_to_3d.html</link> <link title="All 3D Demos">https://github.com/godotengine/godot-demo-projects/tree/master/3d</link> </tutorials> <methods> <method name="add_gizmo"> <return type="void" /> <param index="0" name="gizmo" type="Node3DGizmo" /> <description> Attaches the given [param gizmo] to this node. Only works in the editor. [b]Note:[/b] [param gizmo] should be an [EditorNode3DGizmo]. The argument type is [Node3DGizmo] to avoid depending on editor classes in [Node3D]. </description> </method> <method name="clear_gizmos"> <return type="void" /> <description> Clears all [EditorNode3DGizmo] objects attached to this node. Only works in the editor. </description> </method> <method name="clear_subgizmo_selection"> <return type="void" /> <description> Deselects all subgizmos for this node. Useful to call when the selected subgizmo may no longer exist after a property change. Only works in the editor. </description> </method> <method name="force_update_transform"> <return type="void" /> <description> Forces the node's [member global_transform] to update, by sending [constant NOTIFICATION_TRANSFORM_CHANGED]. Fails if the node is not inside the tree. [b]Note:[/b] For performance reasons, transform changes are usually accumulated and applied [i]once[/i] at the end of the frame. The update propagates through [Node3D] children, as well. Therefore, use this method only when you need an up-to-date transform (such as during physics operations). </description> </method> <method name="get_gizmos" qualifiers="const"> <return type="Node3DGizmo[]" /> <description> Returns all the [EditorNode3DGizmo] objects attached to this node. Only works in the editor. </description> </method> <method name="get_global_transform_interpolated"> <return type="Transform3D" /> <description> 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). This is particularly important for frame-based operations that take place in [method Node._process], rather than [method Node._physics_process]. Examples include [Camera3D]s focusing on a node, or finding where to fire lasers from on a frame rather than physics tick. [b]Note:[/b] This function creates an interpolation pump on the [Node3D] the first time it is called, which can respond to physics interpolation resets. If you get problems with "streaking" when initially following a [Node3D], be sure to call [method get_global_transform_interpolated] at least once [i]before[/i] resetting the [Node3D] physics interpolation. </description> </method> <method name="get_parent_node_3d" qualifiers="const"> <return type="Node3D" /> <description> Returns the parent [Node3D] that directly affects this node's [member global_transform]. Returns [code]null[/code] if no parent exists, the parent is not a [Node3D], or [member top_level] is [code]true[/code]. [b]Note:[/b] This method is not always equivalent to [method Node.get_parent], which does not take [member top_level] into account. </description> </method> <method name="get_world_3d" qualifiers="const"> <return type="World3D" /> <description> Returns the [World3D] this node is registered to. Usually, this is the same as the world used by this node's viewport (see [method Node.get_viewport] and [method Viewport.find_world_3d]). </description> </method> <method name="global_rotate"> <return type="void" /> <param index="0" name="axis" type="Vector3" /> <param index="1" name="angle" type="float" /> <description> Rotates this node's [member global_basis] around the global [param axis] by the given [param angle], in radians. This operation is calculated in global space (relative to the world) and preserves the [member global_position]. </description> </method> <method name="global_scale"> <return type="void" /> <param index="0" name="scale" type="Vector3" /> <description> Scales this node's [member global_basis] by the given [param scale] factor. This operation is calculated in global space (relative to the world) and preserves the [member global_position]. [b]Note:[/b] This method is not to be confused with the [member scale] property. </description> </method> <method name="global_translate"> <return type="void" /> <param index="0" name="offset" type="Vector3" /> <description> Adds the given translation [param offset] to the node's [member global_position] in global space (relative to the world). </description> </method> <method name="hide"> <return type="void" /> <description> Prevents this node from being rendered. Equivalent to setting [member visible] to [code]false[/code]. This is the opposite of [method show]. </description> </method> <method name="is_local_transform_notification_enabled" qualifiers="const"> <return type="bool" /> <description> Returns [code]true[/code] if the node receives [constant NOTIFICATION_LOCAL_TRANSFORM_CHANGED] whenever [member transform] changes. This is enabled with [method set_notify_local_transform]. </description> </method> <method name="is_scale_disabled" qualifiers="const"> <return type="bool" /> <description> Returns [code]true[/code] if this node's [member global_transform] is automatically orthonormalized. This results in this node not appearing distorted, as if its global scale were set to [constant Vector3.ONE] (or its negative counterpart). See also [method set_disable_scale] and [method orthonormalize]. [b]Note:[/b] [member transform] is not affected by this setting. </description> </method> <method name="is_transform_notification_enabled" qualifiers="const"> <return type="bool" /> <description> Returns [code]true[/code] if the node receives [constant NOTIFICATION_TRANSFORM_CHANGED] whenever [member global_transform] changes. This is enabled with [method set_notify_transform]. </description> </method> <method name="is_visible_in_tree" qualifiers="const"> <return type="bool" /> <description> Returns [code]true[/code] if this node is inside the scene tree and the [member visible] property is [code]true[/code] for this node and all of its [Node3D] ancestors [i]in sequence[/i]. An ancestor of any other type (such as [Node] or [Node2D]) breaks the sequence. See also [method Node.get_parent]. [b]Note:[/b] This method cannot take [member VisualInstance3D.layers] into account, so even if this method returns [code]true[/code], the node may not be rendered. </description> </method> <method name="look_at"> <return type="void" /> <param index="0" name="target" type="Vector3" /> <param index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)" /> <param index="2" name="use_model_front" type="bool" default="false" /> <description> Rotates the node so that the local forward axis (-Z, [constant Vector3.FORWARD]) points toward the [param target] position. This operation is calculated in global space (relative to the world). The local up axis (+Y) points as close to the [param 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. The [param target] position cannot be the same as the node's position, the [param up] vector cannot be [constant Vector3.ZERO]. Furthermore, the direction from the node's position to the [param target] position cannot be parallel to the [param up] vector, to avoid an unintended rotation around the local Z axis. If [param use_model_front] is [code]true[/code], the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the [param target] position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right). [b]Note:[/b] This method fails if the node is not in the scene tree. If necessary, use [method look_at_from_position] instead. </description> </method> <method name="look_at_from_position"> <return type="void" /> <param index="0" name="position" type="Vector3" /> <param index="1" name="target" type="Vector3" /> <param index="2" name="up" type="Vector3" default="Vector3(0, 1, 0)" /> <param index="3" name="use_model_front" type="bool" default="false" /> <description> Moves the node to the specified [param position], then rotates the node to point toward the [param target] position, similar to [method look_at]. This operation is calculated in global space (relative to the world). </description> </method> <method name="orthonormalize"> <return type="void" /> <description> Orthonormalizes this node's [member basis]. This method sets this node's [member scale] to [constant Vector3.ONE] (or its negative counterpart), but preserves the [member position] and [member rotation]. See also [method Transform3D.orthonormalized]. </description> </method> <method name="rotate"> <return type="void" /> <param index="0" name="axis" type="Vector3" /> <param index="1" name="angle" type="float" /> <description> Rotates this node's [member basis] around the [param axis] by the given [param angle], in radians. This operation is calculated in parent space (relative to the parent) and preserves the [member position]. </description> </method> <method name="rotate_object_local"> <return type="void" /> <param index="0" name="axis" type="Vector3" /> <param index="1" name="angle" type="float" /> <description> Rotates this node's [member basis] around the [param axis] by the given [param angle], in radians. This operation is calculated in local space (relative to this node) and preserves the [member position]. </description> </method> <method name="rotate_x"> <return type="void" /> <param index="0" name="angle" type="float" /> <description> Rotates this node's [member basis] around the X axis by the given [param angle], in radians. This operation is calculated in parent space (relative to the parent) and preserves the [member position]. </description> </method> <method name="rotate_y"> <return type="void" /> <param index="0" name="angle" type="float" /> <description> Rotates this node's [member basis] around the Y axis by the given [param angle], in radians. This operation is calculated in parent space (relative to the parent) and preserves the [member position]. </description> </method> <method name="rotate_z"> <return type="void" /> <param index="0" name="angle" type="float" /> <description> Rotates this node's [member basis] around the Z axis by the given [param angle], in radians. This operation is calculated in parent space (relative to the parent) and preserves the [member position]. </description> </method> <method name="scale_object_local"> <return type="void" /> <param index="0" name="scale" type="Vector3" /> <description> Scales this node's [member basis] by the given [param scale] factor. This operation is calculated in local space (relative to this node) and preserves the [member position]. </description> </method> <method name="set_disable_scale"> <return type="void" /> <param index="0" name="disable" type="bool" /> <description> If [code]true[/code], this node's [member global_transform] is automatically orthonormalized. This results in this node not appearing distorted, as if its global scale were set to [constant Vector3.ONE] (or its negative counterpart). See also [method is_scale_disabled] and [method orthonormalize]. [b]Note:[/b] [member transform] is not affected by this setting. </description> </method> <method name="set_identity"> <return type="void" /> <description> Sets this node's [member transform] to [constant Transform3D.IDENTITY], which resets all transformations in parent space ([member position], [member rotation], and [member scale]). </description> </method> <method name="set_ignore_transform_notification"> <return type="void" /> <param index="0" name="enabled" type="bool" /> <description> If [code]true[/code], the node will not receive [constant NOTIFICATION_TRANSFORM_CHANGED] or [constant NOTIFICATION_LOCAL_TRANSFORM_CHANGED]. It may useful to call this method when handling these notifications to prevent infinite recursion. </description> </method> <method name="set_notify_local_transform"> <return type="void" /> <param index="0" name="enable" type="bool" /> <description> If [code]true[/code], the node will receive [constant NOTIFICATION_LOCAL_TRANSFORM_CHANGED] whenever [member transform] changes. [b]Note:[/b] Some 3D nodes such as [CSGShape3D] or [CollisionShape3D] automatically enable this to function correctly. </description> </method> <method name="set_notify_transform" keywords="set_notify_global_transform"> <return type="void" /> <param index="0" name="enable" type="bool" /> <description> If [code]true[/code], the node will receive [constant NOTIFICATION_TRANSFORM_CHANGED] whenever [member global_transform] changes. [b]Note:[/b] Most 3D nodes such as [VisualInstance3D] or [CollisionObject3D] automatically enable this to function correctly. [b]Note:[/b] In the editor, nodes will propagate this notification to their children if a gizmo is attached (see [method add_gizmo]). </description> </method> <method name="set_subgizmo_selection"> <return type="void" /> <param index="0" name="gizmo" type="Node3DGizmo" /> <param index="1" name="id" type="int" /> <param index="2" name="transform" type="Transform3D" /> <description> Selects the [param gizmo]'s subgizmo with the given [param id] and sets its transform. Only works in the editor. [b]Note:[/b] The gizmo object would typically be an instance of [EditorNode3DGizmo], but the argument type is kept generic to avoid creating a dependency on editor classes in [Node3D]. </description> </method> <method name="show"> <return type="void" /> <description> Allows this node to be rendered. Equivalent to setting [member visible] to [code]true[/code]. This is the opposite of [method hide]. </description> </method> <method name="to_global" qualifiers="const"> <return type="Vector3" /> <param index="0" name="local_point" type="Vector3" /> <description> Returns the [param local_point] converted from this node's local space to global space. This is the opposite of [method to_local]. </description> </method> <method name="to_local" qualifiers="const"> <return type="Vector3" /> <param index="0" name="global_point" type="Vector3" /> <description> Returns the [param global_point] converted from global space to this node's local space. This is the opposite of [method to_global]. </description> </method> <method name="translate"> <return type="void" /> <param index="0" name="offset" type="Vector3" /> <description> Adds the given translation [param offset] to the node's position, in local space (relative to this node). [b]Note:[/b] Prefer using [method translate_object_local], instead, as this method may be changed in a future release. [b]Note:[/b] Despite the naming convention, this operation is [b]not[/b] calculated in parent space for compatibility reasons. To translate in parent space, add [param offset] to the [member position] ([code]node_3d.position += offset[/code]). </description> </method> <method name="translate_object_local"> <return type="void" /> <param index="0" name="offset" type="Vector3" /> <description> Adds the given translation [param offset] to the node's position, in local space (relative to this node). </description> </method> <method name="update_gizmos"> <return type="void" /> <description> Updates all the [EditorNode3DGizmo] objects attached to this node. Only works in the editor. </description> </method> </methods> <members> <member name="basis" type="Basis" setter="set_basis" getter="get_basis"> Basis of the [member transform] property. Represents the rotation, scale, and shear of this node in parent space (relative to the parent node). </member> <member name="global_basis" type="Basis" setter="set_global_basis" getter="get_global_basis"> Basis of the [member global_transform] property. Represents the rotation, scale, and shear of this node in global space (relative to the world). [b]Note:[/b] If the node is not inside the tree, getting this property fails and returns [constant Basis.IDENTITY]. </member> <member name="global_position" type="Vector3" setter="set_global_position" getter="get_global_position" keywords="global_translation"> Global position (translation) of this node in global space (relative to the world). This is equivalent to the [member global_transform]'s [member Transform3D.origin]. [b]Note:[/b] If the node is not inside the tree, getting this property fails and returns [constant Vector3.ZERO]. </member> <member name="global_rotation" type="Vector3" setter="set_global_rotation" getter="get_global_rotation"> Global rotation of this node as [url=https://en.wikipedia.org/wiki/Euler_angles]Euler angles[/url], in radians and in global space (relative to the world). This value is obtained from [member global_basis]'s rotation. - The [member Vector3.x] is the angle around the global X axis (pitch); - The [member Vector3.y] is the angle around the global Y axis (yaw); - The [member Vector3.z] is the angle around the global Z axis (roll). [b]Note:[/b] Unlike [member rotation], this property always follows the YXZ convention ([constant EULER_ORDER_YXZ]). [b]Note:[/b] If the node is not inside the tree, getting this property fails and returns [constant Vector3.ZERO]. </member> <member name="global_rotation_degrees" type="Vector3" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees"> The [member global_rotation] of this node, in degrees instead of radians. [b]Note:[/b] If the node is not inside the tree, getting this property fails and returns [constant Vector3.ZERO]. </member> <member name="global_transform" type="Transform3D" setter="set_global_transform" getter="get_global_transform"> The transformation of this node, in global space (relative to the world). Contains and represents this node's [member global_position], [member global_rotation], and global scale. [b]Note:[/b] If the node is not inside the tree, getting this property fails and returns [constant Transform3D.IDENTITY]. </member> <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3(0, 0, 0)" keywords="translation"> Position (translation) of this node in parent space (relative to the parent node). This is equivalent to the [member transform]'s [member Transform3D.origin]. </member> <member name="quaternion" type="Quaternion" setter="set_quaternion" getter="get_quaternion"> Rotation of this node represented as a [Quaternion] in parent space (relative to the parent node). This value is obtained from [member basis]'s rotation. [b]Note:[/b] Quaternions are much more suitable for 3D math but are less intuitive. Setting this property can be useful for interpolation (see [method Quaternion.slerp]). </member> <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation" default="Vector3(0, 0, 0)"> Rotation of this node as [url=https://en.wikipedia.org/wiki/Euler_angles]Euler angles[/url], in radians and in parent space (relative to the parent node). This value is obtained from [member basis]'s rotation. - The [member Vector3.x] is the angle around the local X axis (pitch); - The [member Vector3.y] is the angle around the local Y axis (yaw); - The [member Vector3.z] is the angle around the local Z axis (roll). The order of each consecutive rotation can be changed with [member rotation_order] (see [enum EulerOrder] constants). By default, the YXZ convention is used ([constant EULER_ORDER_YXZ]). [b]Note:[/b] This property is edited in degrees in the inspector. If you want to use degrees in a script, use [member rotation_degrees]. </member> <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees"> The [member rotation] of this node, in degrees instead of radians. [b]Note:[/b] This is [b]not[/b] the property available in the Inspector dock. </member> <member name="rotation_edit_mode" type="int" setter="set_rotation_edit_mode" getter="get_rotation_edit_mode" enum="Node3D.RotationEditMode" default="0"> How this node's rotation and scale are displayed in the Inspector dock. </member> <member name="rotation_order" type="int" setter="set_rotation_order" getter="get_rotation_order" enum="EulerOrder" default="2"> The axis rotation order of the [member rotation] property. The final orientation is calculated by rotating around the local X, Y, and Z axis in this order. </member> <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)"> Scale of this node in local space (relative to this node). This value is obtained from [member basis]'s scale. [b]Note:[/b] The behavior of some 3D node types is not affected by this property. These include [Light3D], [Camera3D], [AudioStreamPlayer3D], and more. [b]Warning:[/b] The scale's components must either be all positive or all negative, and [b]not[/b] exactly [code]0.0[/code]. Otherwise, it won't be possible to obtain the scale from the [member basis]. This may cause the intended scale to be lost when reloaded from disk, and potentially other unstable behavior. </member> <member name="top_level" type="bool" setter="set_as_top_level" getter="is_set_as_top_level" default="false"> If [code]true[/code], the node does not inherit its transformations from its parent. As such, node transformations will only be in global space, which also means that [member global_transform] and [member transform] will be identical. </member> <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> The local transformation of this node, in parent space (relative to the parent node). Contains and represents this node's [member position], [member rotation], and [member scale]. </member> <member name="visibility_parent" type="NodePath" setter="set_visibility_parent" getter="get_visibility_parent" default="NodePath("")"> Path to the visibility range parent for this node and its descendants. The visibility parent must be a [GeometryInstance3D]. Any visual instance will only be visible if the visibility parent (and all of its visibility ancestors) is hidden by being closer to the camera than its own [member GeometryInstance3D.visibility_range_begin]. Nodes hidden via the [member Node3D.visible] property are essentially removed from the visibility dependency tree, so dependent instances will not take the hidden node or its descendants into account. </member> <member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true"> If [code]true[/code], this node can be visible. The node is only rendered when all of its ancestors are visible, as well. That means [method is_visible_in_tree] must return [code]true[/code]. </member> </members> <signals> <signal name="visibility_changed"> <description> Emitted when this node's visibility changes (see [member visible] and [method is_visible_in_tree]). This signal is emitted [i]after[/i] the related [constant NOTIFICATION_VISIBILITY_CHANGED] notification. </description> </signal> </signals> <constants> <constant name="NOTIFICATION_TRANSFORM_CHANGED" value="2000" keywords="NOTIFICATION_GLOBAL_TRANSFORM_CHANGED"> Notification received when this node's [member global_transform] changes, if [method is_transform_notification_enabled] is [code]true[/code]. See also [method set_notify_transform]. [b]Note:[/b] Most 3D nodes such as [VisualInstance3D] or [CollisionObject3D] automatically enable this to function correctly. [b]Note:[/b] In the editor, nodes will propagate this notification to their children if a gizmo is attached (see [method add_gizmo]). </constant> <constant name="NOTIFICATION_ENTER_WORLD" value="41"> Notification received when this node is registered to a new [World3D] (see [method get_world_3d]). </constant> <constant name="NOTIFICATION_EXIT_WORLD" value="42"> Notification received when this node is unregistered from the current [World3D] (see [method get_world_3d]). </constant> <constant name="NOTIFICATION_VISIBILITY_CHANGED" value="43"> Notification received when this node's visibility changes (see [member visible] and [method is_visible_in_tree]). This notification is received [i]before[/i] the related [signal visibility_changed] signal. </constant> <constant name="NOTIFICATION_LOCAL_TRANSFORM_CHANGED" value="44"> Notification received when this node's [member transform] changes, if [method is_local_transform_notification_enabled] is [code]true[/code]. This is not received when a parent [Node3D]'s [member transform] changes. See also [method set_notify_local_transform]. [b]Note:[/b] Some 3D nodes such as [CSGShape3D] or [CollisionShape3D] automatically enable this to function correctly. </constant> <constant name="ROTATION_EDIT_MODE_EULER" value="0" enum="RotationEditMode"> The rotation is edited using a [Vector3] in [url=https://en.wikipedia.org/wiki/Euler_angles]Euler angles[/url]. </constant> <constant name="ROTATION_EDIT_MODE_QUATERNION" value="1" enum="RotationEditMode"> The rotation is edited using a [Quaternion]. </constant> <constant name="ROTATION_EDIT_MODE_BASIS" value="2" enum="RotationEditMode"> The rotation is edited using a [Basis]. In this mode, the raw [member basis]'s axes can be freely modified, but the [member scale] property is not available. </constant> </constants> </class>