class
Eagle::Node3D
- Eagle::Node3D
- Eagle::Node
- Reference
- Object
Overview
A node with a 3D position, rotation and scale. It is the base of every 3D object.
As in 2D, children move with their parent. Rotation is a Quat, but you rarely touch
it directly: #rotate_y, #look_at, #euler= and #set_euler cover most needs.
class Spinner < Node3D
def ready : Nil
add(MeshInstance3D.new(Mesh.cube, Material.new(Color::ORANGE)))
end
def process(dt : Float32) : Nil
rotate_y(dt) # turn around the world's up axis
translate_local(Vec3::FORWARD * dt) # move the way it faces
end
end
s = Spinner.new
s.position = v3(0, 1, 0)
s.set_euler(0, Mathf.deg2rad(45), 0)
s.look_at(v3(5, 1, 0))
Direct Known Subclasses
Defined in:
eagle/nodes/node3d.crConstructors
-
.new(name : String = "", position : Eagle::Vec3 = Vec3::ZERO, rotation : Eagle::Quat = Quat::IDENTITY, scale : Eagle::Vec3 = Vec3::ONE)
Creates a 3D node.
Instance Method Summary
-
#back : Vec3
The opposite of
#forward. -
#distance_to(o : Node3D) : Float32
Distance to another 3D node.
-
#draw_tree(g : Graphics) : Nil
3D nodes don't draw in the 2D pass, but children still may.
-
#euler : Vec3
Rotation as Euler angles
(pitch, yaw, roll)in radians. -
#euler=(e : Vec3)
Sets the rotation from Euler angles in radians.
-
#forward : Vec3
The direction the node faces, in world space.
-
#global_position : Vec3
Position in world space.
-
#global_position=(p : Vec3)
Moves the node so it ends up at p in world space.
-
#global_rotation : Quat
Orientation in world space.
-
#global_transform : Mat4
The transform from this node's space to world space.
-
#look_at(target : Vec3, up : Vec3 = Vec3::UP) : Nil
Turns the node so
#forwardpoints at a world-space target. -
#parent_3d : Node3D | Nil
The nearest ancestor that is a
Node3D, ornil. -
#position : Vec3
Position relative to the parent.
-
#position=(position : Vec3)
Position relative to the parent.
-
#right : Vec3
The node's right direction in world space.
-
#rotate(axis : Vec3, rad : Number) : Nil
Rotates around a world-space axis.
-
#rotate_local(axis : Vec3, rad : Number) : Nil
Rotates around an axis in the node's own space.
-
#rotate_x(rad : Number) : Nil
Rotates around the world X axis (pitch).
-
#rotate_y(rad : Number) : Nil
Rotates around the world Y axis (yaw), the usual way to turn a character.
-
#rotate_z(rad : Number) : Nil
Rotates around the Z axis (roll).
-
#rotation : Quat
Orientation relative to the parent.
-
#rotation=(rotation : Quat)
Orientation relative to the parent.
-
#scale : Vec3
Scale relative to the parent.
-
#scale=(s : Vec3)
Sets the scale per axis.
-
#scale=(s : Number)
Sets a uniform scale.
-
#set_euler(pitch : Number, yaw : Number, roll : Number = 0) : self
Sets the rotation from pitch, yaw and roll in radians.
-
#to_global(local : Vec3) : Vec3
Converts a local point to world space.
-
#to_local(global : Vec3) : Vec3
Converts a world-space point to local space.
-
#top_level=(top_level : Bool)
When true, the node ignores its parent's transform.
-
#top_level? : Bool
When true, the node ignores its parent's transform.
-
#transform : Mat4
The local transform matrix.
-
#translate(v : Vec3) : Nil
Moves by v in parent space.
-
#translate_local(v : Vec3) : Nil
Moves by v in the node's own space, so
Vec3::FORWARDmoves the way it faces. -
#up : Vec3
The node's up direction in world space.
Instance methods inherited from class Eagle::Node
<<(child : Node) : self
<<,
[](path : String) : Node
[],
[]?(path : String) : Node | Nil
[]?,
add(child : Node) : Nodeadd(*children : Node) : Nil add, add_child(child : Node) : Node add_child, add_to_group(group : String) : self add_to_group, ancestor_of?(node : Node) : Bool ancestor_of?, can_process? : Bool can_process?, child?(name : String) : Node | Nil child?, child_added : Eagle::Emitter(Node) child_added, child_count : Int32 child_count, child_removed : Eagle::Emitter(Node) child_removed, children : Array(Eagle::Node) children, children_of(type : T.class) : Array(T) forall T children_of, clear_children : Nil clear_children, draw(g : Graphics) : Nil draw, dump(io : IO = STDOUT, indent = 0) : Nil dump, each_ancestor(& : Node -> ) : Nil each_ancestor, each_child(& : Node -> ) : Nil each_child, each_descendant(&block : Node -> ) : Nil each_descendant, emit_child_added(*args) : Nil emit_child_added, emit_child_removed(*args) : Nil emit_child_removed, emit_tree_entered(*args) : Nil emit_tree_entered, emit_tree_exited(*args) : Nil emit_tree_exited, enter_tree : Nil enter_tree, exit_tree : Nil exit_tree, find(name : String) : Node | Nil find, find_all(type : T.class) : Array(T) forall T find_all, first_child : Node | Nil first_child, free : Nil free, get_node(path : String, type : T.class) : T forall T
get_node(path : String) : Node get_node, get_node?(path : String) : Node | Nil get_node?, groups : Set(String) groups, in_group?(group : String) : Bool in_group?, in_tree? : Bool in_tree?, input(event : Event) : Nil input, name : String name, name=(name : String) name=, on_child_added(&block : Node -> Nil) : Proc(Node, Nil) on_child_added, on_child_removed(&block : Node -> Nil) : Proc(Node, Nil) on_child_removed, on_tree_entered(&block : -> Nil) : Proc(Nil) on_tree_entered, on_tree_exited(&block : -> Nil) : Proc(Nil) on_tree_exited, parent : Node | Nil parent, path : String path, physics_process(dt : Float32) : Nil physics_process, process(dt : Float32) : Nil process, process_mode : Eagle::Node::ProcessMode process_mode, process_mode=(process_mode : Eagle::Node::ProcessMode) process_mode=, queue_free : Nil queue_free, queued_free? : Bool queued_free?, ready : Nil ready, ready_called? : Bool ready_called?, remove(child : Node) : Nil remove, remove_child(child : Node) : Nil remove_child, remove_from_group(group : String) : Nil remove_from_group, remove_from_parent : Nil remove_from_parent, resized(width : Int32, height : Int32) : Nil resized, root : Node root, to_s(io : IO) : Nil to_s, tree_entered : Eagle::Emitter() tree_entered, tree_exited : Eagle::Emitter() tree_exited, visible=(visible : Bool) visible=, visible? : Bool visible?, z_index : Int32 z_index, z_index=(z_index : Int32) z_index=
Constructor methods inherited from class Eagle::Node
new(name : String = "")
new
Constructor Detail
Creates a 3D node.
Instance Method Detail
Rotates around the world Y axis (yaw), the usual way to turn a character.
Sets the rotation from pitch, yaw and roll in radians. Returns self.