Class Node
Node is the base class of all display objects.
Node object can be assigned as a child of another node, resulting in a tree arrangement. You need to inherit from the Node class to create your own display object.
Fields
node.name | Name of node. |
node.children | Children of this node. |
node.parent | Parent of this node. |
node.detach_flag | Flag that is used to detach this node from its parent during the next scene update. |
node.update_flag | Flag that sets whether the node is updated during the scene update pass. |
node.render_flag | Flag that sets whether the node is rendered during the scene render pass. |
node.update_transform_flag | Flag that sets whether the node transformations will be updated. |
node.mat4 | Local transformation matrix |
node.mat4 | World transformation matrix based on world (parent) factors. |
node.position | Local position. |
node.rotation | Local rotation. |
node.scale | Local scale. |
Methods
node:init ([name='node']) | The public constructor. |
node:clone ([new_object]) | Clone a node object. |
node:set_position (x[, y[, z]]) | Set Node local position. |
node:set_rotation (q) | Set Node local rotation. |
node:set_scale (sx[, sy[, sz]]) | Set Node local scale. |
node:get_world_position ([retvalue]) | Get world space position of the Node. |
node:get_world_rotation ([retvalue]) | Get world space rotation of the Node. |
node:get_world_scale ([retvalue]) | Get world space scale of the Node. |
node:right ([retvalue]) | Get the right axis of the transform in world space. |
node:up ([retvalue]) | Get the up axis of the transform in world space. |
node:forward ([retvalue]) | Get the forward axis of the transform in world space. |
node:get_aabb () | Calculate the largest AABB down the hierarchy of nodes. |
node:recursive_update_transform ([force]) | Update all transforms up the hierarchy to the root node. |
node:update_transform ([parent_world_matrix]) | Update transform only for this node. |
node:get_child_by_index (index) | Get child Node by index. |
node:remove_children () | Remove all children from this node. |
node:attach (...) | Attach child node(s) to this node. |
node:detach (child) | Detach child node from this node. |
node:find (name) | Find a child node by name. |
node:traverse (callback[, _index]) | Recursively traverse all nodes. |
node:detach_from_parent () | Detach this node from its parent node. |
node:get_root_node ([upto]) | Get the topmost Node in the hierarchy. |
node:children_count () | Get the number of children attached to this node. |
node:debug_print ([node[, tabs]]) | Recursively print all the children attached to this node. |
Fields
- node.name
-
Name of node.
- name string (default "node")
- node.children
-
Children of this node.
- children
- node.parent
-
Parent of this node.
- parent
- node.detach_flag
-
Flag that is used to detach this node from its parent during the next scene update.
- detach_flag boolean (default false)
- node.update_flag
-
Flag that sets whether the node is updated during the scene update pass.
- update_flag boolean (default true)
- node.render_flag
-
Flag that sets whether the node is rendered during the scene render pass.
- render_flag boolean (default true)
- node.update_transform_flag
-
Flag that sets whether the node transformations will be updated.
- update_transform_flag boolean (default true)
- node.mat4
-
Local transformation matrix
- mat4 local_matrix readonly
- node.mat4
-
World transformation matrix based on world (parent) factors.
- mat4 world_matrix readonly
- node.position
-
Local position.
- position vec3 readonly
- node.rotation
-
Local rotation.
- rotation quat readonly
- node.scale
-
Local scale.
- scale vec3 readonly
Methods
- node:init ([name='node'])
-
The public constructor.
Parameters:
- name string Node name (default 'node')
- node:clone ([new_object])
-
Clone a node object.
Parameters:
- new_object menori.Node Target object to copy data to (optional)
Returns:
-
menori.Node
Cloned node object
- node:set_position (x[, y[, z]])
-
Set Node local position.
Parameters:
- x number or vec3 Position x coordinate or vec3 position vector
- y number Position y coordinate (optional)
- z number Position z coordinate (optional)
- node:set_rotation (q)
-
Set Node local rotation.
Parameters:
- q quat Rotation quaternion.
- node:set_scale (sx[, sy[, sz]])
-
Set Node local scale.
Parameters:
- sx number or vec3 Scale x factor or vec3 scale vector
- sy number Scale y factor (optional)
- sz number Scale z factor (optional)
- node:get_world_position ([retvalue])
-
Get world space position of the Node.
Parameters:
- retvalue vec3 Optional vec3 object to store the result (optional)
Returns:
-
vec3
World space position vector
- node:get_world_rotation ([retvalue])
-
Get world space rotation of the Node.
Parameters:
- retvalue quat Optional quat object to store the result (optional)
Returns:
-
quat
World space rotation quaternion
- node:get_world_scale ([retvalue])
-
Get world space scale of the Node.
Parameters:
- retvalue vec3 Optional vec3 object to store the result (optional)
Returns:
-
vec3
World space scale vector
- node:right ([retvalue])
-
Get the right axis of the transform in world space.
Parameters:
- retvalue vec3 Optional vec3 object to store the result (optional)
Returns:
-
vec3
Right axis vector (red axis)
- node:up ([retvalue])
-
Get the up axis of the transform in world space.
Parameters:
- retvalue vec3 Optional vec3 object to store the result (optional)
Returns:
-
vec3
Up axis vector (green axis)
- node:forward ([retvalue])
-
Get the forward axis of the transform in world space.
Parameters:
- retvalue vec3 Optional vec3 object to store the result (optional)
Returns:
-
vec3
Forward axis vector (blue axis)
- node:get_aabb ()
-
Calculate the largest AABB down the hierarchy of nodes.
Returns:
-
bound3
Axis-aligned bounding box
- node:recursive_update_transform ([force])
-
Update all transforms up the hierarchy to the root node.
Parameters:
- force bool Force update transformations of all nodes up to the root node (optional)
- node:update_transform ([parent_world_matrix])
-
Update transform only for this node.
Parameters:
- parent_world_matrix mat4 Parent world matrix to use for transformation (optional)
- node:get_child_by_index (index)
-
Get child Node by index.
Parameters:
- index number Child index
Returns:
-
menori.Node
Child node object
- node:remove_children ()
- Remove all children from this node.
- node:attach (...)
-
Attach child node(s) to this node.
Parameters:
- ... menori.Node One or more node objects to attach
Returns:
-
menori.Node
... The attached node object(s)
- node:detach (child)
-
Detach child node from this node.
Parameters:
- child menori.Node Child node to detach
- node:find (name)
-
Find a child node by name.
Parameters:
- name string Node name. If name contains a '/' character it will access the Node in the hierarchy like a path name
Returns:
-
menori.Node or nil
The found child node or nil if not found
- node:traverse (callback[, _index])
-
Recursively traverse all nodes.
Parameters:
- callback function Function that is called for every child node with params (child, index)
- _index number Internal parameter for recursion (optional)
- node:detach_from_parent ()
- Detach this node from its parent node.
- node:get_root_node ([upto])
-
Get the topmost Node in the hierarchy.
Parameters:
- upto menori.Node The Node where the hierarchy recursion will stop if it exists (optional)
Returns:
-
menori.Node
Root node of the hierarchy
- node:children_count ()
-
Get the number of children attached to this node.
Returns:
-
number
Number of children
- node:debug_print ([node[, tabs]])
-
Recursively print all the children attached to this node.
Parameters:
- node menori.Node Node to start printing from (defaults to self) (optional)
- tabs string Indentation string for formatting (optional)