Node3D
Most basic 3D game object, parent of all 3D-related nodes.
Node3D.swift:23class Node3D
Most basic 3D game object, with a Transform3D
and visibility settings. All other 3D game objects inherit from Node3D
. Use Node3D
as a parent node to move, scale, rotate and show/hide children in a 3D project.
Affine operations (rotate, scale, translate) happen in parent’s local coordinate system, unless the Node3D
object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the Node3D
’s transform. The word local below refers to this coordinate system. The coordinate system that is attached to the Node3D
object itself is referred to as object-local coordinate system.
This object emits the following signals:
Superclasses
class Node
Base class for all scene objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
static let notificationEnterWorld: Int
Node3D
nodes receive this notification when they are registered to newWorld3D
resource.static let notificationExitWorld: Int
Node3D
nodes receive this notification when they are unregistered from currentWorld3D
resource.static let notificationLocalTransformChanged: Int
Node3D
nodes receive this notification when their local transform changes. This is not received when the transform of a parent node is changed.static let notificationTransformChanged: Int
Node3D
nodes receive this notification when their global transform changes. This means that either the current or a parent node changed its transform.static let notificationVisibilityChanged: Int
Node3D
nodes receive this notification when their visibility changes.class var godotClassName: StringName
Instance members
var basis: Basis
Direct access to the 3x3 basis of the
transform
property.var globalBasis: Basis
Global basis of this node. This is equivalent to
global_transform.basis
.var globalPosition: Vector3
Global position of this node. This is equivalent to
global_transform.origin
.var globalRotation: Vector3
Rotation part of the global transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
var globalRotationDegrees: Vector3
Helper property to access
globalRotation
in degrees instead of radians.var globalTransform: Transform3D
World3D space (global)
Transform3D
of this node.var position: Vector3
Local position or translation of this node relative to the parent. This is equivalent to
transform.origin
.var quaternion: Quaternion
Access to the node rotation as a
Quaternion
. This property is ideal for tweening complex rotations.var rotation: Vector3
Rotation part of the local transformation in radians, specified in terms of Euler angles. The angles construct a rotation in the order specified by the
rotationOrder
property.var rotationDegrees: Vector3
Helper property to access
rotation
in degrees instead of radians.var rotationEditMode: Node3D.RotationEditMode
Specify how rotation (and scale) will be presented in the editor.
var rotationOrder: EulerOrder
Specify the axis rotation order of the
rotation
property. The final orientation is constructed by rotating the Euler angles in the order specified by this property.var scale: Vector3
Scale part of the local transformation.
var topLevel: Bool
If
true
, the node will not inherit its transformations from its parent. Node transformations are only in global space.var transform: Transform3D
Local space
Transform3D
of this node, with respect to the parent node.var visibilityChanged: SimpleSignal
Emitted when node visibility changes.
var visibilityParent: NodePath
Defines the visibility range parent for this node and its subtree. 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
visibilityRangeBegin
. Nodes hidden via thevisible
property are essentially removed from the visibility dependency tree, so dependent instances will not take the hidden node or its ancestors into account.var visible: Bool
If
true
, this node is drawn. The node is only visible if all of its ancestors are visible as well (in other words,isVisibleInTree
must returntrue
).func addGizmo(Node3DGizmo?
) Attach an editor gizmo to this
Node3D
.func clearGizmos(
) Clear all gizmos attached to this
Node3D
.func clearSubgizmoSelection(
) Clears subgizmo selection for this node in the editor. Useful when subgizmo IDs become invalid after a property change.
func forceUpdateTransform(
) 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.
func getGizmos(
) -> ObjectCollection<Node3DGizmo> Returns all the gizmos attached to this
Node3D
.func getParentNode3d(
) -> Node3D? Returns the parent
Node3D
, or an emptyObject
if no parent exists or parent is not of typeNode3D
.func getWorld3d(
) -> World3D? Returns the current
World3D
resource thisNode3D
node is registered to.func globalRotate(axis: Vector3, angle: Double
) Rotates the global (world) transformation around axis, a unit
Vector3
, by specified angle in radians. The rotation axis is in global coordinate system.func globalScale(Vector3
) Scales the global (world) transformation by the given
Vector3
scale factors.func globalTranslate(offset: Vector3
) Moves the global (world) transformation by
Vector3
offset. The offset is in global coordinate system.func hide(
) Disables rendering of this node. Changes
visible
tofalse
.func isLocalTransformNotificationEnabled(
) -> Bool Returns whether node notifies about its local transformation changes.
Node3D
will not propagate this by default.func isScaleDisabled(
) -> Bool Returns whether this node uses a scale of
(1, 1, 1)
or its local transformation scale.func isTransformNotificationEnabled(
) -> Bool Returns whether the node notifies about its global and local transformation changes.
Node3D
will not propagate this by default.func isVisibleInTree(
) -> Bool Returns
true
if the node is present in theSceneTree
, itsvisible
property istrue
and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree.func lookAt(target: Vector3, up: Vector3, useModelFront: Bool
) Rotates the node so that the local forward axis (-Z,
Vector3.FORWARD
) points toward thetarget
position.func lookAtFromPosition(Vector3, target: Vector3, up: Vector3, useModelFront: Bool
) Moves the node to the specified
position
, and then rotates the node to point toward thetarget
as perlookAt(target:up:useModelFront:)
. Operations take place in global space.func orthonormalize(
) Resets this node’s transformations (like scale, skew and taper) preserving its rotation and translation by performing Gram-Schmidt orthonormalization on this node’s
Transform3D
.func rotate(axis: Vector3, angle: Double
) Rotates the local transformation around axis, a unit
Vector3
, by specified angle in radians.func rotateObjectLocal(axis: Vector3, angle: Double
) Rotates the local transformation around axis, a unit
Vector3
, by specified angle in radians. The rotation axis is in object-local coordinate system.func rotateX(angle: Double
) Rotates the local transformation around the X axis by angle in radians.
func rotateY(angle: Double
) Rotates the local transformation around the Y axis by angle in radians.
func rotateZ(angle: Double
) Rotates the local transformation around the Z axis by angle in radians.
func scaleObjectLocal(scale: Vector3
) Scales the local transformation by given 3D scale factors in object-local coordinate system.
func setDisableScale(disable: Bool
) Sets whether the node uses a scale of
(1, 1, 1)
or its local transformation scale. Changes to the local transformation scale are preserved.func setIdentity(
) Reset all transformations for this node (sets its
Transform3D
to the identity matrix).func setIgnoreTransformNotification(enabled: Bool
) Sets whether the node ignores notification that its transformation (global or local) changed.
func setNotifyLocalTransform(enable: Bool
) Sets whether the node notifies about its local transformation changes.
Node3D
will not propagate this by default.func setNotifyTransform(enable: Bool
) Sets whether the node notifies about its global and local transformation changes.
Node3D
will not propagate this by default, unless it is in the editor context and it has a valid gizmo.func setSubgizmoSelection(gizmo: Node3DGizmo?, id: Int32, transform: Transform3D
) Set subgizmo selection for this node in the editor.
func show(
) Enables rendering of this node. Changes
visible
totrue
.func toGlobal(localPoint: Vector3
) -> Vector3 Transforms
localPoint
from this node’s local space to world space.func toLocal(globalPoint: Vector3
) -> Vector3 Transforms
globalPoint
from world space to this node’s local space.func translate(offset: Vector3
) Changes the node’s position by the given offset
Vector3
.func translateObjectLocal(offset: Vector3
) Changes the node’s position by the given offset
Vector3
in local space.func updateGizmos(
) Updates all the
Node3D
gizmos attached to this node.
Subclasses
class AudioListener3D
Overrides the location sounds are heard from.
class AudioStreamPlayer3D
Plays positional sound in 3D space.
class BoneAttachment3D
А node that dynamically copies or overrides the 3D transform of a bone in its parent
Skeleton3D
.class Camera3D
Camera node, displays from a point of view.
class CollisionObject3D
Abstract base class for 3D physics objects.
class CollisionPolygon3D
A node that provides a thickened polygon shape (a prism) to a
CollisionObject3D
parent.class CollisionShape3D
A node that provides a
Shape3D
to aCollisionObject3D
parent.class GridMap
Node for 3D tile-based maps.
class ImporterMeshInstance3D
class Joint3D
Abstract base class for all 3D physics joints.
class LightmapProbe
Represents a single manually placed probe for dynamic object lighting with
LightmapGI
.class Marker3D
Generic 3D position hint for editing.
class OccluderInstance3D
Provides occlusion culling for 3D nodes, which improves performance in closed areas.
class OpenXRHand
Node supporting finger tracking in OpenXR.
class Path3D
Contains a
Curve3D
path forPathFollow3D
nodes to follow.class PathFollow3D
Point sampler for a
Path3D
.class RayCast3D
A ray in 3D space, used to find the first
CollisionObject3D
it intersects.class RemoteTransform3D
RemoteTransform3D pushes its own
Transform3D
to anotherNode3D
derived Node in the scene.class ShapeCast3D
A 3D shape that sweeps a region of space to detect
CollisionObject3D
s.class Skeleton3D
A node containing a bone hierarchy, used to create a 3D skeletal animation.
class SpringArm3D
A 3D raycast that dynamically moves its children near the collision point.
class VehicleWheel3D
A 3D physics body for a
VehicleBody3D
that simulates the behavior of a wheel.class VisualInstance3D
Parent of all visual 3D nodes.
class XRNode3D
A spatial node that has its position automatically updated by the
XRServer
.class XROrigin3D
The origin point in AR/VR.