diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2019-02-22 00:08:58 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2019-02-22 00:08:58 +0300 |
commit | 3f91b7f68083a221c8b222860f749a85c0c810ce (patch) | |
tree | a4f71da9cf449ec799e7a000353dd4e8c984683b | |
parent | 82367d10eb5e67d4edf11611a505ac71d5d7c324 (diff) |
glTF exporter: fix export of unlit materials
-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( |