Class: Rgltf::Skin

Inherits:
Properties::Base show all
Defined in:
lib/rgltf/properties/skin.rb

Instance Attribute Summary collapse

Attributes inherited from Properties::Base

#extensions, #extras, #index, #name, #owner_type, #source_json

Instance Method Summary collapse

Methods inherited from Properties::Base

#extension, #nested_properties, #parse_extensions!

Constructor Details

#initialize(json, document:, index:) ⇒ Skin

Returns a new instance of Skin.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rgltf/properties/skin.rb', line 7

def initialize(json, document:, index:)
  super(json, document:, index:, owner_type: :skin)
  @joints = json.fetch('joints').each_with_index.map do |node_index, joint_index|
    document.fetch_reference(:nodes, node_index, "skins/#{index}/joints/#{joint_index}")
  end.freeze
  @inverse_bind_matrices = optional_reference(document, :accessors, json['inverseBindMatrices'],
                                              "skins/#{index}/inverseBindMatrices")
  @skeleton = optional_reference(document, :nodes, json['skeleton'], "skins/#{index}/skeleton")
rescue KeyError => e
  raise FormatError, "invalid skin #{index}: #{e.message}"
end

Instance Attribute Details

#inverse_bind_matricesObject (readonly)

Returns the value of attribute inverse_bind_matrices.



5
6
7
# File 'lib/rgltf/properties/skin.rb', line 5

def inverse_bind_matrices
  @inverse_bind_matrices
end

#jointsObject (readonly)

Returns the value of attribute joints.



5
6
7
# File 'lib/rgltf/properties/skin.rb', line 5

def joints
  @joints
end

#skeletonObject (readonly)

Returns the value of attribute skeleton.



5
6
7
# File 'lib/rgltf/properties/skin.rb', line 5

def skeleton
  @skeleton
end