Class: Rgltf::BufferView

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

Constant Summary collapse

TARGETS =
{ 34_962 => :array_buffer, 34_963 => :element_array_buffer }.freeze

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:) ⇒ BufferView

Returns a new instance of BufferView.



9
10
11
12
13
14
15
16
# File 'lib/rgltf/properties/buffer_view.rb', line 9

def initialize(json, document:, index:)
  super(json, document:, index:, owner_type: :buffer_view)
  @buffer = document.fetch_reference(:buffers, json.fetch('buffer'), "bufferViews/#{index}/buffer")
  @byte_offset = json.fetch('byteOffset', 0)
  @byte_length = json.fetch('byteLength')
  @byte_stride = json['byteStride']
  @target = TARGETS.fetch(json['target'], json['target'])
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



7
8
9
# File 'lib/rgltf/properties/buffer_view.rb', line 7

def buffer
  @buffer
end

#byte_lengthObject (readonly)

Returns the value of attribute byte_length.



7
8
9
# File 'lib/rgltf/properties/buffer_view.rb', line 7

def byte_length
  @byte_length
end

#byte_offsetObject (readonly)

Returns the value of attribute byte_offset.



7
8
9
# File 'lib/rgltf/properties/buffer_view.rb', line 7

def byte_offset
  @byte_offset
end

#byte_strideObject (readonly)

Returns the value of attribute byte_stride.



7
8
9
# File 'lib/rgltf/properties/buffer_view.rb', line 7

def byte_stride
  @byte_stride
end

#targetObject (readonly)

Returns the value of attribute target.



7
8
9
# File 'lib/rgltf/properties/buffer_view.rb', line 7

def target
  @target
end