diff options
4 files changed, 44 insertions, 20 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py index 38e2c2c4..1e4a4f90 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_material_normal_texture_info_class.py @@ -67,6 +67,8 @@ def __gather_extensions(blender_shader_sockets_or_texture_slots, export_settings texture_node = texture_socket.links[0].from_node texture_transform = gltf2_blender_get.get_texture_transform_from_texture_node(texture_node) + if texture_transform is None: + return None extension = Extension("KHR_texture_transform", texture_transform) return {"KHR_texture_transform": extension} diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py index e1c17480..74375145 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials.py @@ -88,6 +88,11 @@ def __gather_alpha_mode(blender_material, export_settings): def __gather_double_sided(blender_material, export_settings): + old_double_sided_socket = gltf2_blender_get.get_socket_or_texture_slot_old(blender_material, "DoubleSided") + if old_double_sided_socket is not None and\ + not old_double_sided_socket.is_linked and\ + old_double_sided_socket.default_value > 0.5: + return True return None diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_generate_extras.py b/io_scene_gltf2/blender/exp/gltf2_blender_generate_extras.py index c26c494a..247a3c9a 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_generate_extras.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_generate_extras.py @@ -32,33 +32,47 @@ def generate_extras(blender_element): if custom_property in black_list: continue - value = blender_element[custom_property] + value = __to_json_compatible(blender_element[custom_property]) - add_value = False + if value is not None: + extras[custom_property] = value + count += 1 - if isinstance(value, bpy.types.ID): - add_value = True + if count == 0: + return None - if isinstance(value, str): - add_value = True + return extras - if isinstance(value, (int, float)): - add_value = True - if hasattr(value, "to_list"): - value = value.to_list() - add_value = True +def __to_json_compatible(value): + """Make a value (usually a custom property) compatible with json""" - if hasattr(value, "to_dict"): - value = value.to_dict() - add_value = gltf2_blender_json.is_json_convertible(value) + if isinstance(value, bpy.types.ID): + return value - if add_value: - extras[custom_property] = value - count += 1 + elif isinstance(value, str): + return value - if count == 0: - return None + elif isinstance(value, (int, float)): + return value - return extras + # for list classes + elif isinstance(value, list): + value = list(value) + # make sure contents are json-compatible too + for index in range(len(value)): + value[index] = __to_json_compatible(value[index]) + return value + + # for IDPropertyArray classes + elif hasattr(value, "to_list"): + value = value.to_list() + return value + + elif hasattr(value, "to_dict"): + value = value.to_dict() + if gltf2_blender_json.is_json_convertible(value): + return value + + return None diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_get.py b/io_scene_gltf2/blender/exp/gltf2_blender_get.py index 08e3a307..d3c7d148 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_get.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_get.py @@ -372,6 +372,9 @@ def get_texture_transform_from_texture_node(texture_node): if texture_transform["rotation"] == 0: del(texture_transform["rotation"]) + if len(texture_transform) == 0: + return None + return texture_transform |