Class: TinyGLTF::Accessor
- Inherits:
-
Object
- Object
- TinyGLTF::Accessor
show all
- Includes:
- Base
- Defined in:
- lib/tiny_gltf.rb,
ext/tiny_gltf/rb_tiny_gltf_init.c
Instance Attribute Summary
Attributes included from Base
#model
Instance Method Summary
collapse
Methods included from Base
included, #inspect, #to_h, #to_json
Instance Method Details
#buffer_view ⇒ Object
172
173
174
|
# File 'lib/tiny_gltf.rb', line 172
def buffer_view
model.buffer_views[buffer_view_index]
end
|
#byte_length ⇒ Object
157
158
159
|
# File 'lib/tiny_gltf.rb', line 157
def byte_length
byte_stride * count
end
|
#byte_stride ⇒ Object
150
151
152
153
154
155
|
# File 'lib/tiny_gltf.rb', line 150
def byte_stride
stride = buffer_view.byte_stride
stride && stride > 0 ? stride : element_size
end
|
#component_size ⇒ Object
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/tiny_gltf.rb', line 123
def component_size
case component_type
when :byte, :ubyte then 1
when :short, :ushort then 2
when :int, :uint then 4
when :float then 4
when :double then 8
else raise "Can't calculate component size for component type #{component_type.inspect}"
end
end
|
#element_size ⇒ Object
146
147
148
|
# File 'lib/tiny_gltf.rb', line 146
def element_size
component_size * num_components
end
|
#normalized? ⇒ Boolean
168
169
170
|
# File 'lib/tiny_gltf.rb', line 168
def normalized?
!!@normalized
end
|
#num_components ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/tiny_gltf.rb', line 134
def num_components
case type
when :scalar then 1
when :vec2 then 2
when :vec3 then 3
when :vec4, :mat2 then 4
when :mat3 then 9
when :mat4 then 16
else raise "Can't calculate number of components for type #{type.inspect}"
end
end
|
#to_ptr ⇒ Object
161
162
163
164
165
166
|
# File 'lib/tiny_gltf.rb', line 161
def to_ptr
view_ptr = buffer_view.to_ptr
length = byte_length
length = view_ptr.size if length > view_ptr.size
Fiddle::Pointer.new view_ptr + byte_offset, length
end
|