Class: Assimp::Node
- Inherits:
-
Object
- Object
- Assimp::Node
- Defined in:
- lib/assimp/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
-
#mesh_indices ⇒ Object
readonly
Returns the value of attribute mesh_indices.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #find(name) ⇒ Object
-
#initialize(name:, matrix:, children:, mesh_indices:) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(name:, matrix:, children:, mesh_indices:) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 13 14 15 |
# File 'lib/assimp/node.rb', line 7 def initialize(name:, matrix:, children:, mesh_indices:) @name = String(name).dup.freeze @matrix = matrix.map { |value| Float(value) }.freeze raise ArgumentError, "node matrix must contain 16 values" unless @matrix.length == 16 @children = children.freeze @mesh_indices = mesh_indices.map { |index| Integer(index) }.freeze freeze end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/assimp/node.rb', line 5 def children @children end |
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
5 6 7 |
# File 'lib/assimp/node.rb', line 5 def matrix @matrix end |
#mesh_indices ⇒ Object (readonly)
Returns the value of attribute mesh_indices.
5 6 7 |
# File 'lib/assimp/node.rb', line 5 def mesh_indices @mesh_indices end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/assimp/node.rb', line 5 def name @name end |
Instance Method Details
#find(name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/assimp/node.rb', line 17 def find(name) target = String(name) stack = [self] until stack.empty? node = stack.pop return node if node.name == target stack.concat(node.children.reverse) end nil end |