Lysa.nodes  0.0
Lysa 3D Engine
Node Class Referenceabstract

Detailed Description

The base class for all scene-tree nodes. Provides transform, hierarchy, grouping, and lifecycle callbacks.

Lua full name: lysa.nodes.Node

Public Member Functions

Node create (name: string)static
 Creates a new plain Node at the origin without a parent. More...
 
nil set_script (script: string)
 Attaches a Lua script table to the node. The table may implement _ready, _process, _physics_process, _input, _enter_scene, and _exit_scene callbacks. More...
 
boolean has_script ()
 Returns true if a Lua script is currently attached to this node. More...
 
table|nil get_script ()
 Returns the attached Lua script table, or nil if none is attached. More...
 
nil set_position (x: number, y: number, z: number)
 Sets the local-space position with explicit x, y, z components. More...
 
nil translate (vec: lysa.float3)
 Moves the node by an offset vector in local space. More...
 
nil translate (x: number, y: number, z: number)
 Moves the node by x, y, z offset components in local space. More...
 
nil set_position_global (x: number, y: number, z: number)
 Sets the world-space position with explicit x, y, z components. More...
 
nil rotate (rotation: lysa.quaternion)
 Applies a quaternion rotation to the local transformation. More...
 
nil rotate_x (angle: number)
 Rotates the local transformation around the X axis by angle radians. More...
 
nil rotate_y (angle: number)
 Rotates the local transformation around the Y axis by angle radians. More...
 
nil rotate_z (angle: number)
 Rotates the local transformation around the Z axis by angle radians. More...
 
nil set_rotation (vec: lysa.float3)
 Sets the local rotation from Euler angles (radians, pitch/yaw/roll order). More...
 
nil rotate_global_x (angle: number)
 Rotates the world transformation around the X axis by angle radians. More...
 
nil rotate_global_y (angle: number)
 Rotates the world transformation around the Y axis by angle radians. More...
 
nil rotate_global_z (angle: number)
 Rotates the world transformation around the Z axis by angle radians. More...
 
nil scale (factor: number)
 Scales the local transformation uniformly by the given factor. More...
 
nil set_scale (factor: lysa.float3)
 Sets the per-axis scale of the local transformation from a float3. More...
 
lysa.float3 get_scale ()
 Returns the per-axis scale of the local transformation. More...
 
lysa.float3 to_global (local_pos: lysa.float3)
 Transforms a local-space position into world space. More...
 
lysa.float3 to_local (global_pos: lysa.float3)
 Transforms a world-space position into this node's local space. More...
 
nil look_at (target: lysa.float3)
 Rotates the node so that its forward axis points toward the target world-space position. More...
 
lysa.Tween look_at_smooth (target: lysa.float3, duration: number, transition_type: lysa.TransitionType, callback: function|nil)
 Smoothly rotates the node toward the target over duration seconds using the given easing curve; returns the controlling Tween. More...
 
nil set_process_mode (mode: ProcessMode)
 Changes the node's processing mode (see lysa.nodes.ProcessMode). More...
 
nil add_to_group (group: string)
 Adds this node to the named group. More...
 
nil remove_from_group (group: string)
 Removes this node from the named group; silently ignored if not a member. More...
 
boolean is_in_group (group: string)
 Returns true if this node has been added to the given group. More...
 
nil remove_all_children ()
 Removes and detaches all child nodes (takes effect at the start of the next frame). More...
 
Node duplicate ()
 Returns a deep copy of this node (not supported on all node types). More...
 
Node|nil get_child (name: string)
 Returns the direct child with the given name, or nil if not found (non-recursive). More...
 
Node|nil get_child_by_path (path: string)
 Returns a descendant by relative path (e.g. 'child/grandchild'), or nil if not found. More...
 
Node|nil find_first_child (name: string)
 Recursively finds and returns the first descendant with the given name, or nil. More...
 
Node add_child (child: Node, async: boolean)
 Adds a child node. Pass async=true when batch-adding many nodes (set visibility to false first to avoid mid-frame flicker). More...
 
boolean remove_child (child: Node)
 Requests removal of a child node; takes effect at the start of the next frame. Returns true on success. More...
 
AnimationPlayer as_animation_player ()
 Casts this node to AnimationPlayer; returns nil if the type does not match. More...
 
Camera as_camera ()
 Casts this node to Camera; returns nil if the type does not match. More...
 
Character as_character ()
 Casts this node to Character; returns nil if the type does not match. More...
 
CollisionArea as_collision_area ()
 Casts this node to CollisionArea; returns nil if the type does not match. More...
 
CollisionObject as_collision_object ()
 Casts this node to CollisionObject; returns nil if the type does not match. More...
 
DirectionalLight as_directional_light ()
 Casts this node to DirectionalLight; returns nil if the type does not match. More...
 
Environment as_environment ()
 Casts this node to Environment; returns nil if the type does not match. More...
 
KinematicBody as_kinematic_body ()
 Casts this node to KinematicBody; returns nil if the type does not match. More...
 
Light as_light ()
 Casts this node to Light; returns nil if the type does not match. More...
 
MeshInstance as_mesh_instance ()
 Casts this node to MeshInstance; returns nil if the type does not match. More...
 
OmniLight as_omni_light ()
 Casts this node to OmniLight; returns nil if the type does not match. More...
 
PhysicsBody as_physics_body ()
 Casts this node to PhysicsBody; returns nil if the type does not match. More...
 
RayCast as_ray_cast ()
 Casts this node to RayCast; returns nil if the type does not match. More...
 
RigidBody as_rigid_body ()
 Casts this node to RigidBody; returns nil if the type does not match. More...
 
SpotLight as_spot_light ()
 Casts this node to SpotLight; returns nil if the type does not match. More...
 
StaticBody as_static_body ()static
 Casts this node to StaticBody; returns nil if the type does not match. More...
 
Timer as_timer ()
 Casts this node to Timer; returns nil if the type does not match. More...
 
Viewport as_viewport ()
 Casts this node to Viewport; returns nil if the type does not match. More...
 

Properties

any self
 Shared pointer to this node (for passing to engine APIs that require a shared_ptr).
 
integer id
 Unique identifier of the node. (read-only)
 
SceneTree scene_tree
 The scene tree this node belongs to. (read-only)
 
integer type
 The concrete node type (see lysa.nodes.NodeType). (read-only)
 
string name
 Display name of the node.
 
string path
 Absolute path of the node within the scene tree. (read-only)
 
lysa.float4x4 transform
 Local-space transformation matrix (relative to parent).
 
lysa.float3 position
 Local-space position (relative to parent).
 
lysa.float4x4 transform_global
 World-space transformation matrix. (read-only)
 
lysa.float3 position_global
 World-space position.
 
lysa.quaternion rotation
 Rotation of the local transformation expressed as a quaternion.
 
lysa.quaternion rotation_global
 Rotation of the world transformation expressed as a quaternion.
 
lysa.float3 rotation_euler_angles
 Rotation of the local transformation in Euler angles (radians). (read-only)
 
lysa.float3 rotation_euler_angles_global
 Rotation of the world transformation in Euler angles (radians). (read-only)
 
number rotation_x
 X-axis rotation component of the local transformation in radians.
 
number rotation_y
 Y-axis rotation component of the local transformation in radians.
 
number rotation_z
 Z-axis rotation component of the local transformation in radians.
 
number rotation_global_x
 X-axis rotation component of the world transformation in radians.
 
number rotation_global_y
 Y-axis rotation component of the world transformation in radians.
 
number rotation_global_z
 Z-axis rotation component of the world transformation in radians.
 
lysa.float3 scale_global
 Per-axis scale of the world transformation. (read-only)
 
lysa.float3 right_vector
 Normalized right (+X) direction vector in world space. (read-only)
 
lysa.float3 left_vector
 Normalized left (-X) direction vector in world space. (read-only)
 
lysa.float3 front_vector
 Normalized forward (-Z) direction vector in world space. (read-only)
 
lysa.float3 back_vector
 Normalized backward (+Z) direction vector in world space. (read-only)
 
lysa.float3 up_vector
 Normalized up (+Y) direction vector in world space. (read-only)
 
lysa.float3 down_vector
 Normalized down (-Y) direction vector in world space. (read-only)
 
boolean visible
 True if the node and its children are rendered.
 
boolean is_processed
 True if the node is currently receiving process and input callbacks. (read-only)
 
boolean have_parent
 True if this node has a parent in the scene tree. (read-only)
 

Member Function Documentation

Node create ( string  name)
static

Creates a new plain Node at the origin without a parent.

Parameters
namestring
Returns
Node
nil set_script ( string  script)

Attaches a Lua script table to the node. The table may implement _ready, _process, _physics_process, _input, _enter_scene, and _exit_scene callbacks.

Parameters
scriptstring
boolean has_script ( )

Returns true if a Lua script is currently attached to this node.

Returns
boolean
table|nil get_script ( )

Returns the attached Lua script table, or nil if none is attached.

Returns
table|nil
nil set_position ( number  x,
number  y,
number  z)

Sets the local-space position with explicit x, y, z components.

Parameters
xnumber
ynumber
znumber
nil translate ( lysa.float3  vec)

Moves the node by an offset vector in local space.

Parameters
veclysa.float3
nil translate ( number  x,
number  y,
number  z)

Moves the node by x, y, z offset components in local space.

Parameters
xnumber
ynumber
znumber
nil set_position_global ( number  x,
number  y,
number  z)

Sets the world-space position with explicit x, y, z components.

Parameters
xnumber
ynumber
znumber
nil rotate ( lysa.quaternion  rotation)

Applies a quaternion rotation to the local transformation.

Parameters
rotationlysa.quaternion
nil rotate_x ( number  angle)

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

Parameters
anglenumber
nil rotate_y ( number  angle)

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

Parameters
anglenumber
nil rotate_z ( number  angle)

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

Parameters
anglenumber
nil set_rotation ( lysa.float3  vec)

Sets the local rotation from Euler angles (radians, pitch/yaw/roll order).

Parameters
veclysa.float3
nil rotate_global_x ( number  angle)

Rotates the world transformation around the X axis by angle radians.

Parameters
anglenumber
nil rotate_global_y ( number  angle)

Rotates the world transformation around the Y axis by angle radians.

Parameters
anglenumber
nil rotate_global_z ( number  angle)

Rotates the world transformation around the Z axis by angle radians.

Parameters
anglenumber
nil scale ( number  factor)

Scales the local transformation uniformly by the given factor.

Parameters
factornumber
nil set_scale ( lysa.float3  factor)

Sets the per-axis scale of the local transformation from a float3.

Parameters
factorlysa.float3
lysa.float3 get_scale ( )

Returns the per-axis scale of the local transformation.

Returns
lysa.float3
lysa.float3 to_global ( lysa.float3  local_pos)

Transforms a local-space position into world space.

Parameters
local_poslysa.float3
Returns
lysa.float3
lysa.float3 to_local ( lysa.float3  global_pos)

Transforms a world-space position into this node's local space.

Parameters
global_poslysa.float3
Returns
lysa.float3
nil look_at ( lysa.float3  target)

Rotates the node so that its forward axis points toward the target world-space position.

Parameters
targetlysa.float3
lysa.Tween look_at_smooth ( lysa.float3  target,
number  duration,
lysa.TransitionType  transition_type,
function|nil  callback)

Smoothly rotates the node toward the target over duration seconds using the given easing curve; returns the controlling Tween.

Parameters
targetlysa.float3
durationnumber
transition_typelysa.TransitionType
callbackfunction|nil
Returns
lysa.Tween
nil set_process_mode ( ProcessMode  mode)

Changes the node's processing mode (see lysa.nodes.ProcessMode).

Parameters
modeProcessMode
nil add_to_group ( string  group)

Adds this node to the named group.

Parameters
groupstring
nil remove_from_group ( string  group)

Removes this node from the named group; silently ignored if not a member.

Parameters
groupstring
boolean is_in_group ( string  group)

Returns true if this node has been added to the given group.

Parameters
groupstring
Returns
boolean
nil remove_all_children ( )

Removes and detaches all child nodes (takes effect at the start of the next frame).

Node duplicate ( )

Returns a deep copy of this node (not supported on all node types).

Returns
Node
Node|nil get_child ( string  name)

Returns the direct child with the given name, or nil if not found (non-recursive).

Parameters
namestring
Returns
Node|nil
Node|nil get_child_by_path ( string  path)

Returns a descendant by relative path (e.g. 'child/grandchild'), or nil if not found.

Parameters
pathstring
Returns
Node|nil
Node|nil find_first_child ( string  name)

Recursively finds and returns the first descendant with the given name, or nil.

Parameters
namestring
Returns
Node|nil
Node add_child ( Node  child,
boolean  async)

Adds a child node. Pass async=true when batch-adding many nodes (set visibility to false first to avoid mid-frame flicker).

Parameters
childNode
asyncboolean
Returns
Node
boolean remove_child ( Node  child)

Requests removal of a child node; takes effect at the start of the next frame. Returns true on success.

Parameters
childNode
Returns
boolean
AnimationPlayer as_animation_player ( )

Casts this node to AnimationPlayer; returns nil if the type does not match.

Returns
AnimationPlayer
Camera as_camera ( )

Casts this node to Camera; returns nil if the type does not match.

Returns
Camera
Character as_character ( )

Casts this node to Character; returns nil if the type does not match.

Returns
Character
CollisionArea as_collision_area ( )

Casts this node to CollisionArea; returns nil if the type does not match.

Returns
CollisionArea
CollisionObject as_collision_object ( )

Casts this node to CollisionObject; returns nil if the type does not match.

Returns
CollisionObject
DirectionalLight as_directional_light ( )

Casts this node to DirectionalLight; returns nil if the type does not match.

Returns
DirectionalLight
Environment as_environment ( )

Casts this node to Environment; returns nil if the type does not match.

Returns
Environment
KinematicBody as_kinematic_body ( )

Casts this node to KinematicBody; returns nil if the type does not match.

Returns
KinematicBody
Light as_light ( )

Casts this node to Light; returns nil if the type does not match.

Returns
Light
MeshInstance as_mesh_instance ( )

Casts this node to MeshInstance; returns nil if the type does not match.

Returns
MeshInstance
OmniLight as_omni_light ( )

Casts this node to OmniLight; returns nil if the type does not match.

Returns
OmniLight
PhysicsBody as_physics_body ( )

Casts this node to PhysicsBody; returns nil if the type does not match.

Returns
PhysicsBody
RayCast as_ray_cast ( )

Casts this node to RayCast; returns nil if the type does not match.

Returns
RayCast
RigidBody as_rigid_body ( )

Casts this node to RigidBody; returns nil if the type does not match.

Returns
RigidBody
SpotLight as_spot_light ( )

Casts this node to SpotLight; returns nil if the type does not match.

Returns
SpotLight
StaticBody as_static_body ( )
static

Casts this node to StaticBody; returns nil if the type does not match.

Returns
StaticBody
Timer as_timer ( )

Casts this node to Timer; returns nil if the type does not match.

Returns
Timer
Viewport as_viewport ( )

Casts this node to Viewport; returns nil if the type does not match.

Returns
Viewport

Property Documentation

any self

Shared pointer to this node (for passing to engine APIs that require a shared_ptr).

integer id

Unique identifier of the node. (read-only)

SceneTree scene_tree

The scene tree this node belongs to. (read-only)

integer type

The concrete node type (see lysa.nodes.NodeType). (read-only)

string name

Display name of the node.

string path

Absolute path of the node within the scene tree. (read-only)

lysa.float4x4 transform

Local-space transformation matrix (relative to parent).

lysa.float3 position

Local-space position (relative to parent).

lysa.float4x4 transform_global

World-space transformation matrix. (read-only)

lysa.float3 position_global

World-space position.

lysa.quaternion rotation

Rotation of the local transformation expressed as a quaternion.

lysa.quaternion rotation_global

Rotation of the world transformation expressed as a quaternion.

lysa.float3 rotation_euler_angles

Rotation of the local transformation in Euler angles (radians). (read-only)

lysa.float3 rotation_euler_angles_global

Rotation of the world transformation in Euler angles (radians). (read-only)

number rotation_x

X-axis rotation component of the local transformation in radians.

number rotation_y

Y-axis rotation component of the local transformation in radians.

number rotation_z

Z-axis rotation component of the local transformation in radians.

number rotation_global_x

X-axis rotation component of the world transformation in radians.

number rotation_global_y

Y-axis rotation component of the world transformation in radians.

number rotation_global_z

Z-axis rotation component of the world transformation in radians.

lysa.float3 scale_global

Per-axis scale of the world transformation. (read-only)

lysa.float3 right_vector

Normalized right (+X) direction vector in world space. (read-only)

lysa.float3 left_vector

Normalized left (-X) direction vector in world space. (read-only)

lysa.float3 front_vector

Normalized forward (-Z) direction vector in world space. (read-only)

lysa.float3 back_vector

Normalized backward (+Z) direction vector in world space. (read-only)

lysa.float3 up_vector

Normalized up (+Y) direction vector in world space. (read-only)

lysa.float3 down_vector

Normalized down (-Y) direction vector in world space. (read-only)

boolean visible

True if the node and its children are rendered.

boolean is_processed

True if the node is currently receiving process and input callbacks. (read-only)

boolean have_parent

True if this node has a parent in the scene tree. (read-only)