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.local_matrix | Local transformation matrix |
Node.world_matrix | 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 an 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]) | The world space scale of the Node. |
Node:right ([retvalue]) | The red axis of the transform in world space. |
Node:up ([retvalue]) | The green axis of the transform in world space. |
Node:forward ([retvalue]) | The blue axis of the transform in world space. |
Node:get_aabb () | Calculate the largest AABB in down the hierarchy of nodes. |
Node:recursive_update_transform ([force]) | Update all transform 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 (object) | Attach child node to this node. |
Node:detach (child) | Detach child node. |
Node:find (name) | Find a child node by name. |
Node:traverse (callback) | Recursively traverse all nodes. |
Node:detach_from_parent () | Detach this node from the parent node. |
Node:get_root_node ([upto]) | Get the topmost Node in the hierarchy. |
Node:children_count () | 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 bool (default false)
- Node.update_flag
-
Flag that sets whether the node is updated during the scene update pass.
- update_flag bool (default true)
- Node.render_flag
-
Flag that sets whether the node is rendered during the scene render pass.
- render_flag bool (default true)
- Node.update_transform_flag
-
Flag that sets whether the node transformations will be updated.
- update_transform_flag bool (default true)
- Node.local_matrix
-
Local transformation matrix
- local_matrix readonly
- Node.world_matrix
-
World transformation matrix based on world (parent) factors.
- 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 an object.
Parameters:
- new_object
Returns:
-
menori.Node
object
- Node:set_position (x, y, z)
-
Set Node local position.
Parameters:
- x number position x or vec3
- y number position y
- z number position z
- Node:set_rotation (q)
-
Set Node local rotation.
Parameters:
- q ml.quat Rotation quaternion.
- Node:set_scale (sx, sy, sz)
-
Set Node local scale.
Parameters:
- sx number scale x or vec3
- sy number scale y
- sz number scale z
- Node:get_world_position ([retvalue])
-
Get world space position of the Node.
Parameters:
- retvalue vec3 (optional)
Returns:
-
vec3
object
- Node:get_world_rotation ([retvalue])
-
Get world space rotation of the Node.
Parameters:
- retvalue quat (optional)
Returns:
-
quat
object
- Node:get_world_scale ([retvalue])
-
The world space scale of the Node.
Parameters:
- retvalue vec3 (optional)
Returns:
-
vec3 object
- Node:right ([retvalue])
-
The red axis of the transform in world space.
Parameters:
- retvalue vec3 (optional)
Returns:
-
vec3 object
- Node:up ([retvalue])
-
The green axis of the transform in world space.
Parameters:
- retvalue vec3 (optional)
Returns:
-
vec3 object
- Node:forward ([retvalue])
-
The blue axis of the transform in world space.
Parameters:
- retvalue vec3 (optional)
Returns:
-
vec3
object
- Node:get_aabb ()
-
Calculate the largest AABB in down the hierarchy of nodes.
Returns:
-
bound3
object
- Node:recursive_update_transform ([force])
-
Update all transform up the hierarchy to the root node.
Parameters:
- force bool Forced 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
- Node:get_child_by_index (index)
-
Get child Node by index.
Parameters:
- index number
Returns:
-
menori.Node
object
- Node:remove_children ()
- Remove all children from this node.
- Node:attach (object)
-
Attach child node to this node.
Parameters:
- object menori.Node
Returns:
-
menori.Node
object
- Node:detach (child)
-
Detach child node.
Parameters:
- child menori.Node
- Node:find (name)
-
Find a child node by name.
Parameters:
- name string If name contains a '/' character it will access the Node in the hierarchy like a path name.
Returns:
-
menori.Node
The found child or nil
- Node:traverse (callback)
-
Recursively traverse all nodes.
Parameters:
- callback function Function that is called for every child node with params (child, index)
- Node:detach_from_parent ()
- Detach this node from the 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 exist (optional)
- Node:children_count ()
- The number of children attached to this node.
- Node:debug_print (node, tabs)
-
Recursively print all the children attached to this node.
Parameters:
- node
- tabs