Node3D

package
v0.0.0-...-5dcec5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package Node3D provides methods for working with Node3D object instances.

Index

Constants

View Source
const NotificationEnterWorld Object.Notification = 41 //gd:Node3D.NOTIFICATION_ENTER_WORLD
View Source
const NotificationExitWorld Object.Notification = 42 //gd:Node3D.NOTIFICATION_EXIT_WORLD
View Source
const NotificationLocalTransformChanged Object.Notification = 44 //gd:Node3D.NOTIFICATION_LOCAL_TRANSFORM_CHANGED
View Source
const NotificationTransformChanged Object.Notification = 2000 //gd:Node3D.NOTIFICATION_TRANSFORM_CHANGED
View Source
const NotificationVisibilityChanged Object.Notification = 43 //gd:Node3D.NOTIFICATION_VISIBILITY_CHANGED

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsNode3D() Instance
}

type Expanded

type Expanded [1]gdclass.Node3D

func (Expanded) LookAt

func (self Expanded) LookAt(target Vector3.XYZ, up Vector3.XYZ, use_model_front bool)

Rotates the node so that the local forward axis (-Z, [constant Vector3.FORWARD]) points toward the [param target] position. 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 zero. The [param target] and the [param up] cannot be [constant Vector3.ZERO], and shouldn't be colinear to avoid unintended rotation around local Z axis. Operations take place in global space, which means that the node must be in the scene tree. 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).

func (Expanded) LookAtFromPosition

func (self Expanded) LookAtFromPosition(position Vector3.XYZ, target Vector3.XYZ, up Vector3.XYZ, use_model_front bool)

Moves the node to the specified [param position], and then rotates the node to point toward the [param target] as per [method look_at]. Operations take place in global space.

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode3D

func (self *Extension[T]) AsNode3D() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.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. [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 @GlobalScope.deg_to_rad]. [b]Note:[/b] Be aware that "Spatial" nodes are now called "Node3D" starting with Godot 4. Any Godot 3.x references to "Spatial" nodes refer to "Node3D" in Godot 4.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddGizmo

func (self Instance) AddGizmo(gizmo Node3DGizmo.Instance)

Attach an editor gizmo to this [Node3D]. [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].

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode3D

func (self Instance) AsNode3D() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) Basis

func (self Instance) Basis() Basis.XYZ

func (Instance) ClearGizmos

func (self Instance) ClearGizmos()

Clear all gizmos attached to this [Node3D].

func (Instance) ClearSubgizmoSelection

func (self Instance) ClearSubgizmoSelection()

Clears subgizmo selection for this node in the editor. Useful when subgizmo IDs become invalid after a property change.

func (Instance) ForceUpdateTransform

func (self Instance) 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 (Instance) GetGizmos

func (self Instance) GetGizmos() []Node3DGizmo.Instance

Returns all the gizmos attached to this [Node3D].

func (Instance) GetGlobalTransformInterpolated

func (self Instance) GetGlobalTransformInterpolated() Transform3D.BasisOrigin

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.

func (Instance) GetParentNode3d

func (self Instance) GetParentNode3d() Instance

Returns the parent [Node3D], or [code]null[/code] if no parent exists, the parent is not of type [Node3D], or [member top_level] is [code]true[/code]. [b]Note:[/b] Calling this method is not equivalent to [code]get_parent() as Node3D[/code], which does not take [member top_level] into account.

func (Instance) GetWorld3d

func (self Instance) GetWorld3d() World3D.Instance

Returns the current [World3D] resource this [Node3D] node is registered to.

func (Instance) GlobalBasis

func (self Instance) GlobalBasis() Basis.XYZ

func (Instance) GlobalPosition

func (self Instance) GlobalPosition() Vector3.XYZ

func (Instance) GlobalRotate

func (self Instance) GlobalRotate(axis Vector3.XYZ, angle Angle.Radians)

Rotates the global (world) transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in global coordinate system.

func (Instance) GlobalRotation

func (self Instance) GlobalRotation() Euler.Radians

func (Instance) GlobalRotationDegrees

func (self Instance) GlobalRotationDegrees() Euler.Degrees

func (Instance) GlobalScale

func (self Instance) GlobalScale(scale Vector3.XYZ)

Scales the global (world) transformation by the given [Vector3] scale factors.

func (Instance) GlobalTransform

func (self Instance) GlobalTransform() Transform3D.BasisOrigin

func (Instance) GlobalTranslate

func (self Instance) GlobalTranslate(offset Vector3.XYZ)

Moves the global (world) transformation by [Vector3] offset. The offset is in global coordinate system.

func (Instance) Hide

func (self Instance) Hide()

Disables rendering of this node. Changes [member visible] to [code]false[/code].

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsLocalTransformNotificationEnabled

func (self Instance) IsLocalTransformNotificationEnabled() bool

Returns whether node notifies about its local transformation changes. [Node3D] will not propagate this by default.

func (Instance) IsScaleDisabled

func (self Instance) IsScaleDisabled() bool

Returns whether this node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale.

func (Instance) IsTransformNotificationEnabled

func (self Instance) IsTransformNotificationEnabled() bool

Returns whether the node notifies about its global and local transformation changes. [Node3D] will not propagate this by default.

func (Instance) IsVisibleInTree

func (self Instance) IsVisibleInTree() bool

Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree. Visibility is checked only in parent nodes that inherit from [Node3D]. If the parent is of any other type (such as [Node], [AnimationPlayer], or [Node2D]), it is assumed to be visible. [b]Note:[/b] This method does not take [member VisualInstance3D.layers] into account, so even if this method returns [code]true[/code], the node might end up not being rendered.

func (Instance) LookAt

func (self Instance) LookAt(target Vector3.XYZ)

Rotates the node so that the local forward axis (-Z, [constant Vector3.FORWARD]) points toward the [param target] position. 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 zero. The [param target] and the [param up] cannot be [constant Vector3.ZERO], and shouldn't be colinear to avoid unintended rotation around local Z axis. Operations take place in global space, which means that the node must be in the scene tree. 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).

func (Instance) LookAtFromPosition

func (self Instance) LookAtFromPosition(position Vector3.XYZ, target Vector3.XYZ)

Moves the node to the specified [param position], and then rotates the node to point toward the [param target] as per [method look_at]. Operations take place in global space.

func (Instance) OnVisibilityChanged

func (self Instance) OnVisibilityChanged(cb func(), flags ...Signal.Flags)

func (Instance) Orthonormalize

func (self Instance) 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 (Instance) Position

func (self Instance) Position() Vector3.XYZ

func (Instance) Quaternion

func (self Instance) Quaternion() Quaternion.IJKX

func (Instance) Rotate

func (self Instance) Rotate(axis Vector3.XYZ, angle Angle.Radians)

Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians.

func (Instance) RotateObjectLocal

func (self Instance) RotateObjectLocal(axis Vector3.XYZ, angle Angle.Radians)

Rotates the local transformation around axis, a unit [Vector3], by specified angle in radians. The rotation axis is in object-local coordinate system.

func (Instance) RotateX

func (self Instance) RotateX(angle Angle.Radians)

Rotates the local transformation around the X axis by angle in radians.

func (Instance) RotateY

func (self Instance) RotateY(angle Angle.Radians)

Rotates the local transformation around the Y axis by angle in radians.

func (Instance) RotateZ

func (self Instance) RotateZ(angle Angle.Radians)

Rotates the local transformation around the Z axis by angle in radians.

func (Instance) Rotation

func (self Instance) Rotation() Euler.Radians

func (Instance) RotationDegrees

func (self Instance) RotationDegrees() Euler.Degrees

func (Instance) RotationEditMode

func (self Instance) RotationEditMode() RotationEditMode

func (Instance) RotationOrder

func (self Instance) RotationOrder() Angle.Order

func (Instance) Scale

func (self Instance) Scale() Vector3.XYZ

func (Instance) ScaleObjectLocal

func (self Instance) ScaleObjectLocal(scale Vector3.XYZ)

Scales the local transformation by given 3D scale factors in object-local coordinate system.

func (Instance) SetBasis

func (self Instance) SetBasis(value Basis.XYZ)

func (Instance) SetDisableScale

func (self Instance) SetDisableScale(disable bool)

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.

func (Instance) SetGlobalBasis

func (self Instance) SetGlobalBasis(value Basis.XYZ)

func (Instance) SetGlobalPosition

func (self Instance) SetGlobalPosition(value Vector3.XYZ)

func (Instance) SetGlobalRotation

func (self Instance) SetGlobalRotation(value Euler.Radians)

func (Instance) SetGlobalRotationDegrees

func (self Instance) SetGlobalRotationDegrees(value Euler.Degrees)

func (Instance) SetGlobalTransform

func (self Instance) SetGlobalTransform(value Transform3D.BasisOrigin)

func (Instance) SetIdentity

func (self Instance) SetIdentity()

Reset all transformations for this node (sets its [Transform3D] to the identity matrix).

func (Instance) SetIgnoreTransformNotification

func (self Instance) SetIgnoreTransformNotification(enabled bool)

Sets whether the node ignores notification that its transformation (global or local) changed.

func (Instance) SetNotifyLocalTransform

func (self Instance) SetNotifyLocalTransform(enable bool)

Sets whether the node notifies about its local transformation changes. [Node3D] will not propagate this by default.

func (Instance) SetNotifyTransform

func (self Instance) 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 (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPosition

func (self Instance) SetPosition(value Vector3.XYZ)

func (Instance) SetQuaternion

func (self Instance) SetQuaternion(value Quaternion.IJKX)

func (Instance) SetRotation

func (self Instance) SetRotation(value Euler.Radians)

func (Instance) SetRotationDegrees

func (self Instance) SetRotationDegrees(value Euler.Degrees)

func (Instance) SetRotationEditMode

func (self Instance) SetRotationEditMode(value RotationEditMode)

func (Instance) SetRotationOrder

func (self Instance) SetRotationOrder(value Angle.Order)

func (Instance) SetScale

func (self Instance) SetScale(value Vector3.XYZ)

func (Instance) SetSubgizmoSelection

func (self Instance) SetSubgizmoSelection(gizmo Node3DGizmo.Instance, id int, transform Transform3D.BasisOrigin)

Set subgizmo selection for this node 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].

func (Instance) SetTopLevel

func (self Instance) SetTopLevel(value bool)

func (Instance) SetTransform

func (self Instance) SetTransform(value Transform3D.BasisOrigin)

func (Instance) SetVisibilityParent

func (self Instance) SetVisibilityParent(value string)

func (Instance) SetVisible

func (self Instance) SetVisible(value bool)

func (Instance) Show

func (self Instance) Show()

Enables rendering of this node. Changes [member visible] to [code]true[/code].

func (Instance) ToGlobal

func (self Instance) ToGlobal(local_point Vector3.XYZ) Vector3.XYZ

Transforms [param local_point] from this node's local space to world space.

func (Instance) ToLocal

func (self Instance) ToLocal(global_point Vector3.XYZ) Vector3.XYZ

Transforms [param global_point] from world space to this node's local space.

func (Instance) TopLevel

func (self Instance) TopLevel() bool

func (Instance) Transform

func (self Instance) Transform() Transform3D.BasisOrigin

func (Instance) Translate

func (self Instance) Translate(offset Vector3.XYZ)

Changes the node's position by the given offset [Vector3]. Note that the translation [param offset] 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.

func (Instance) TranslateObjectLocal

func (self Instance) TranslateObjectLocal(offset Vector3.XYZ)

Changes the node's position by the given offset [Vector3] in local space.

func (Instance) UpdateGizmos

func (self Instance) UpdateGizmos()

Updates all the [Node3D] gizmos attached to this node.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) VisibilityParent

func (self Instance) VisibilityParent() string

func (Instance) Visible

func (self Instance) Visible() bool

type RotationEditMode

type RotationEditMode int //gd:Node3D.RotationEditMode
const (
	/*The rotation is edited using [Vector3] Euler angles.*/
	RotationEditModeEuler RotationEditMode = 0
	/*The rotation is edited using a [Quaternion].*/
	RotationEditModeQuaternion RotationEditMode = 1
	/*The rotation is edited using a [Basis]. In this mode, [member scale] can't be edited separately.*/
	RotationEditModeBasis RotationEditMode = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL