Node3D

package
v0.0.0-...-029f470 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package Node3D provides methods for working with Node3D object instances.

Index

Constants

This section is empty.

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 EulerOrder

type EulerOrder int
const (
	/*Specifies that Euler angles should be in XYZ order. When composing, the order is X, Y, Z. When decomposing, the order is reversed, first Z, then Y, and X last.*/
	EulerOrderXyz EulerOrder = 0
	/*Specifies that Euler angles should be in XZY order. When composing, the order is X, Z, Y. When decomposing, the order is reversed, first Y, then Z, and X last.*/
	EulerOrderXzy EulerOrder = 1
	/*Specifies that Euler angles should be in YXZ order. When composing, the order is Y, X, Z. When decomposing, the order is reversed, first Z, then X, and Y last.*/
	EulerOrderYxz EulerOrder = 2
	/*Specifies that Euler angles should be in YZX order. When composing, the order is Y, Z, X. When decomposing, the order is reversed, first X, then Z, and Y last.*/
	EulerOrderYzx EulerOrder = 3
	/*Specifies that Euler angles should be in ZXY order. When composing, the order is Z, X, Y. When decomposing, the order is reversed, first Y, then X, and Z last.*/
	EulerOrderZxy EulerOrder = 4
	/*Specifies that Euler angles should be in ZYX order. When composing, the order is Z, Y, X. When decomposing, the order is reversed, first X, then Y, and Z last.*/
	EulerOrderZyx EulerOrder = 5
)

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 [1]gdclass.Node3DGizmo)

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() [][1]gdclass.Node3DGizmo

Returns all the gizmos attached to this [Node3D].

func (Instance) GetParentNode3d

func (self Instance) GetParentNode3d() [1]gdclass.Node3D

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() [1]gdclass.World3D

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 Float.X)

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() Vector3.XYZ

func (Instance) GlobalRotationDegrees

func (self Instance) GlobalRotationDegrees() Vector3.XYZ

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) 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.

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, and the direction from the node's position to the [param target] vector cannot be parallel to the [param up] vector. 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())

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 Float.X)

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 Float.X)

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 Float.X)

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

func (Instance) RotateY

func (self Instance) RotateY(angle Float.X)

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

func (Instance) RotateZ

func (self Instance) RotateZ(angle Float.X)

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

func (Instance) Rotation

func (self Instance) Rotation() Vector3.XYZ

func (Instance) RotationDegrees

func (self Instance) RotationDegrees() Vector3.XYZ

func (Instance) RotationEditMode

func (self Instance) RotationEditMode() gdclass.Node3DRotationEditMode

func (Instance) RotationOrder

func (self Instance) RotationOrder() EulerOrder

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 Vector3.XYZ)

func (Instance) SetGlobalRotationDegrees

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

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) 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 Vector3.XYZ)

func (Instance) SetRotationDegrees

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

func (Instance) SetRotationEditMode

func (self Instance) SetRotationEditMode(value gdclass.Node3DRotationEditMode)

func (Instance) SetRotationOrder

func (self Instance) SetRotationOrder(value EulerOrder)

func (Instance) SetScale

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

func (Instance) SetSubgizmoSelection

func (self Instance) SetSubgizmoSelection(gizmo [1]gdclass.Node3DGizmo, 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) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

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 = gdclass.Node3DRotationEditMode //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