Class: Rgltf::Accessor::Sparse::Indices

Inherits:
Properties::Base show all
Defined in:
lib/rgltf/properties/accessor.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:, accessor_index:) ⇒ Indices

Returns a new instance of Indices.

Raises:



112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/rgltf/properties/accessor.rb', line 112

def initialize(json, document:, accessor_index:)
  super(json, document:, owner_type: :accessor_sparse_indices)
  @buffer_view = document.fetch_reference(
    :buffer_views,
    json.fetch('bufferView'),
    "accessors/#{accessor_index}/sparse/indices/bufferView"
  )
  @byte_offset = json.fetch('byteOffset', 0)
  type = AccessorReader::COMPONENT_TYPES.fetch(json.fetch('componentType'))[:sym]
  raise FormatError, 'sparse indices must be unsigned integers' unless %i[u8 u16 u32].include?(type)

  @component_type = type
end

Instance Attribute Details

#buffer_viewObject (readonly)

Returns the value of attribute buffer_view.



110
111
112
# File 'lib/rgltf/properties/accessor.rb', line 110

def buffer_view
  @buffer_view
end

#byte_offsetObject (readonly)

Returns the value of attribute byte_offset.



110
111
112
# File 'lib/rgltf/properties/accessor.rb', line 110

def byte_offset
  @byte_offset
end

#component_typeObject (readonly)

Returns the value of attribute component_type.



110
111
112
# File 'lib/rgltf/properties/accessor.rb', line 110

def component_type
  @component_type
end