diff options
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_export.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export.py b/io_scene_gltf2/blender/exp/gltf2_blender_export.py index f3e4a469..071b4884 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_export.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_export.py @@ -92,11 +92,7 @@ def __fix_json(obj): if isinstance(obj, dict): fixed = {} for key, value in obj.items(): - if value is None: - continue - elif isinstance(value, dict) and len(value) == 0: - continue - elif isinstance(value, list) and len(value) == 0: + if not __should_include_json_value(key, value): continue fixed[key] = __fix_json(value) elif isinstance(obj, list): @@ -110,6 +106,20 @@ def __fix_json(obj): return fixed +def __should_include_json_value(key, value): + allowed_empty_collections = ["KHR_materials_unlit"] + + if value is None: + return False + elif __is_empty_collection(value) and key not in allowed_empty_collections: + return False + return True + + +def __is_empty_collection(value): + return (isinstance(value, dict) or isinstance(value, list)) and len(value) == 0 + + def __write_file(json, buffer, export_settings): try: gltf2_io_export.save_gltf( |