# Path: blendergltf/exporters/base.py
# class BaseExporter:
#     gltf_key = ''
#     blender_key = ''
# 
#     @classmethod
#     def get_custom_properties(cls, blender_data):
#         custom_props = {
#             key: value.to_list() if hasattr(value, 'to_list') else value
#             for key, value in blender_data.items()
#             if key not in _IGNORED_CUSTOM_PROPS
#         }
# 
#         custom_props = {
#             key: value for key, value in custom_props.items()
#             if _is_serializable(value)
#         }
# 
#         return custom_props
# 
#     @classmethod
#     def check(cls, state, blender_data):
#         return True
# 
#     @classmethod
#     def default(cls, state, blender_data):
#         return {
#             'name': blender_data.name
#         }
# 
#     @classmethod
#     def export(cls, state, blender_data):
#         return {}
# 
# Path: blendergltf/exporters/common.py
# class Reference:
#     __slots__ = (
#         "blender_type",
#         "blender_name",
#         "source",
#         "prop",
#         "value",
#     )
# 
#     def __init__(self, blender_type, blender_name, source, prop):
#         self.blender_type = blender_type
#         self.blender_name = blender_name
#         self.source = source
#         self.prop = prop
#         self.value = None
# 
#     def __str__(self):
#         return json.dumps([self.blender_type, self.blender_name, self.value])


from distutils.version import StrictVersion as Version
from .base import BaseExporter
from .common import (
    Reference,
)
    blender_key = 'materials'

    @classmethod
    def export(cls, state, blender_data):
        gltf = {
            'name': blender_data.name,
        }

        if state['version'] < Version('2.0'):
            return gltf

        if hasattr(blender_data, 'pbr_export_settings'):
            gltf['doubleSided'] = not blender_data.game_settings.use_backface_culling
            pbr_settings = blender_data.pbr_export_settings
            pbr = {
                'baseColorFactor': pbr_settings.base_color_factor[:],
                'metallicFactor': pbr_settings.metallic_factor,
                'roughnessFactor': pbr_settings.roughness_factor,
            }

            gltf['alphaMode'] = pbr_settings.alpha_mode
            if gltf['alphaMode'] == 'MASK':
                gltf['alphaCutoff'] = pbr_settings.alpha_cutoff

            input_textures = [texture.name for texture in state['input']['textures']]
            base_color_text = pbr_settings.base_color_texture
            if base_color_text and base_color_text in input_textures:
                pbr['baseColorTexture'] = {
                    'texCoord': pbr_settings.base_color_text_index,
                }

# Path: blendergltf/exporters/base.py
# class BaseExporter:
#     gltf_key = ''
#     blender_key = ''
# 
#     @classmethod
#     def get_custom_properties(cls, blender_data):
#         custom_props = {
#             key: value.to_list() if hasattr(value, 'to_list') else value
#             for key, value in blender_data.items()
#             if key not in _IGNORED_CUSTOM_PROPS
#         }
# 
#         custom_props = {
#             key: value for key, value in custom_props.items()
#             if _is_serializable(value)
#         }
# 
#         return custom_props
# 
#     @classmethod
#     def check(cls, state, blender_data):
#         return True
# 
#     @classmethod
#     def default(cls, state, blender_data):
#         return {
#             'name': blender_data.name
#         }
# 
#     @classmethod
#     def export(cls, state, blender_data):
#         return {}
# 
# Path: blendergltf/exporters/common.py
# class Reference:
#     __slots__ = (
#         "blender_type",
#         "blender_name",
#         "source",
#         "prop",
#         "value",
#     )
# 
#     def __init__(self, blender_type, blender_name, source, prop):
#         self.blender_type = blender_type
#         self.blender_name = blender_name
#         self.source = source
#         self.prop = prop
#         self.value = None
# 
#     def __str__(self):
#         return json.dumps([self.blender_type, self.blender_name, self.value])


# Path: blendergltf/exporters/material.py
from distutils.version import StrictVersion as Version
from .base import BaseExporter
from .common import (
    Reference,
)

    blender_key = 'materials'

    @classmethod
    def export(cls, state, blender_data):
        gltf = {
            'name': blender_data.name,
        }

        if state['version'] < Version('2.0'):
            return gltf

        if hasattr(blender_data, 'pbr_export_settings'):
            gltf['doubleSided'] = not blender_data.game_settings.use_backface_culling
            pbr_settings = blender_data.pbr_export_settings
            pbr = {
                'baseColorFactor': pbr_settings.base_color_factor[:],
                'metallicFactor': pbr_settings.metallic_factor,
                'roughnessFactor': pbr_settings.roughness_factor,
            }

            gltf['alphaMode'] = pbr_settings.alpha_mode
            if gltf['alphaMode'] == 'MASK':
                gltf['alphaCutoff'] = pbr_settings.alpha_cutoff

            input_textures = [texture.name for texture in state['input']['textures']]
            base_color_text = pbr_settings.base_color_texture
            if base_color_text and base_color_text in input_textures:
                pbr['baseColorTexture'] = {
                    'texCoord': pbr_settings.base_color_text_index,
                }

                pbr['baseColorTexture']['index'] = Reference(