Class: Rgltf::Mesh
- Inherits:
-
Properties::Base
- Object
- Properties::Base
- Rgltf::Mesh
- Defined in:
- lib/rgltf/properties/mesh.rb
Instance Attribute Summary collapse
-
#primitives ⇒ Object
readonly
Returns the value of attribute primitives.
-
#weights ⇒ Object
readonly
Returns the value of attribute weights.
Attributes inherited from Properties::Base
#extensions, #extras, #index, #name, #owner_type, #source_json
Instance Method Summary collapse
-
#initialize(json, document:, index:) ⇒ Mesh
constructor
A new instance of Mesh.
- #nested_properties ⇒ Object
- #replace_primitives!(values) ⇒ Object
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.}" end |
Instance Attribute Details
#primitives ⇒ Object (readonly)
Returns the value of attribute primitives.
47 48 49 |
# File 'lib/rgltf/properties/mesh.rb', line 47 def primitives @primitives end |
#weights ⇒ Object (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_properties ⇒ Object
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 |