Class: Assimp::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/assimp/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, matrix:, children:, mesh_indices:) ⇒ Node

Returns a new instance of Node.

Raises:

  • (ArgumentError)


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

#childrenObject (readonly)

Returns the value of attribute children.



5
6
7
# File 'lib/assimp/node.rb', line 5

def children
  @children
end

#matrixObject (readonly)

Returns the value of attribute matrix.



5
6
7
# File 'lib/assimp/node.rb', line 5

def matrix
  @matrix
end

#mesh_indicesObject (readonly)

Returns the value of attribute mesh_indices.



5
6
7
# File 'lib/assimp/node.rb', line 5

def mesh_indices
  @mesh_indices
end

#nameObject (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