Class: Rgltf::Mesh

Inherits:
Properties::Base show all
Defined in:
lib/rgltf/properties/mesh.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, #parse_extensions!

Constructor Details

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

Returns a new instance of Mesh.



49
50
51
52
53
54
55
56
57
# File 'lib/rgltf/properties/mesh.rb', line 49

def initialize(json, document:, index:)
  super(json, document:, index:, owner_type: :mesh)
  @primitives = json.fetch('primitives').each_with_index.map do |primitive, primitive_index|
    Primitive.new(primitive, document:, mesh_index: index, index: primitive_index)
  end.freeze
  @weights = json['weights']&.freeze
rescue KeyError => e
  raise FormatError, "invalid mesh #{index}: #{e.message}"
end

Instance Attribute Details

#primitivesObject (readonly)

Returns the value of attribute primitives.



47
48
49
# File 'lib/rgltf/properties/mesh.rb', line 47

def primitives
  @primitives
end

#weightsObject (readonly)

Returns the value of attribute weights.



47
48
49
# File 'lib/rgltf/properties/mesh.rb', line 47

def weights
  @weights
end

Instance Method Details

#nested_propertiesObject



59
60
61
# File 'lib/rgltf/properties/mesh.rb', line 59

def nested_properties
  primitives
end

#replace_primitives!(values) ⇒ Object



63
64
65
# File 'lib/rgltf/properties/mesh.rb', line 63

def replace_primitives!(values)
  @primitives = values.freeze
end