Skip to content

Commit

Permalink
accept component size in buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonnji authored and Moguri committed Oct 1, 2020
1 parent 2487c8a commit 69e2b36
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gltf/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ class Converter():
5125: GeomEnums.NT_uint32,
5126: GeomEnums.NT_float32,
}
_COMPONENT_SIZE_MAP = {
5120: 1,
5121: 1,
5122: 2,
5123: 2,
5124: 4,
5125: 4,
5126: 4,
}
_COMPONENT_NUM_MAP = {
'MAT4': 16,
'VEC4': 4,
Expand Down Expand Up @@ -771,6 +780,7 @@ def load_primitive(self, geom_node, gltf_primitive, gltf_mesh, gltf_data):
internal_name = InternalName.make(attrib_name)
num_components = self._COMPONENT_NUM_MAP[acc['type']]
numeric_type = self._COMPONENT_TYPE_MAP[acc['componentType']]
numeric_size = self._COMPONENT_SIZE_MAP[acc['componentType']]
content = self._ATTRIB_CONTENT_MAP.get(attrib_name, GeomEnums.C_other)

if '_target' in acc:
Expand All @@ -788,7 +798,7 @@ def load_primitive(self, geom_node, gltf_primitive, gltf_mesh, gltf_data):
buffview['buffer'],
acc.get('byteOffset', 0) + buffview.get('byteOffset', 0),
acc['count'],
buffview.get('byteStride', 4 * num_components)
buffview.get('byteStride', numeric_size * num_components)
))

if is_interleaved:
Expand Down

0 comments on commit 69e2b36

Please sign in to comment.