diff options
Diffstat (limited to 'io_scene_gltf2/io/imp/gltf2_io_binary.py')
-rwxr-xr-x | io_scene_gltf2/io/imp/gltf2_io_binary.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py index 92450672..f7a101df 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_binary.py +++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py @@ -46,8 +46,11 @@ class BinaryData(): return buffer[accessor_offset + bufferview_offset:accessor_offset + bufferview_offset + bufferView.byte_length] @staticmethod - def get_data_from_accessor(gltf, accessor_idx): + def get_data_from_accessor(gltf, accessor_idx, cache=False): """Get data from accessor.""" + if accessor_idx in gltf.accessor_cache: + return gltf.accessor_cache[accessor_idx] + accessor = gltf.data.accessors[accessor_idx] bufferView = gltf.data.buffer_views[accessor.buffer_view] # TODO initialize with 0 when not present! @@ -102,6 +105,9 @@ class BinaryData(): new_tuple += (float(i),) data[idx] = new_tuple + if cache: + gltf.accessor_cache[accessor_idx] = data + return data @staticmethod |