def get_accessor(self, idx):
accessor = self.root['accessors'][idx]
buffer_view = self.get_buffer_view(accessor['bufferView'])
component_type = accessor["componentType"]
type_size = accessor["type"]
if component_type == 5126:
fmt = "<f"
elif component_type == 5123:
fmt = "<H"
elif component_type == 5125:
fmt = "<I"
else:
raise ValueError("Unknown component type: %s" % component_type)
values = [i[0] for i in struct.iter_unpack(fmt, buffer_view)]
result = values
if type_size == "VEC3":
result = [Vector(values[i:i+3]) for i in range(0, len(values), 3)]
elif type_size == "VEC2":
result = [tuple(values[i:i+2]) for i in range(0, len(values), 2)]
return result
评论列表
文章目录