diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2022-07-07 09:03:39 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2022-07-07 09:03:39 +0300 |
commit | 042fbefac686666190915d206600a5dab8e03066 (patch) | |
tree | 52bb07b361d72b14b98275a07418f7d72489b5bf /io_scene_gltf2/io/com/gltf2_io_variants.py | |
parent | 09d752e8453415daff11e94f87d8692a04b4eeff (diff) |
glTF importer/exporter: Manage some official Khronos Extensions about Materials
KHR_materials_ior
KHR_materials_sheen
KHR_materials_specular
KHR_materials_transmission
KHR_materials_variants
KHR_materials_emissive_strength
KHR_materials_volume
Documentation update is still in progress
Diffstat (limited to 'io_scene_gltf2/io/com/gltf2_io_variants.py')
-rw-r--r-- | io_scene_gltf2/io/com/gltf2_io_variants.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/io_scene_gltf2/io/com/gltf2_io_variants.py b/io_scene_gltf2/io/com/gltf2_io_variants.py new file mode 100644 index 00000000..3824fee4 --- /dev/null +++ b/io_scene_gltf2/io/com/gltf2_io_variants.py @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2018-2022 The glTF-Blender-IO authors. + +from io_scene_gltf2.io.com.gltf2_io import from_dict, from_union, from_none, from_float, from_str, from_list +from io_scene_gltf2.io.com.gltf2_io import to_float, to_class + +class Variant: + """defines variant for use with glTF 2.0.""" + def __init__(self, name, extensions, extras): + self.name = name + self.extensions = extensions + self.extras = extras + + @staticmethod + def from_dict(obj): + assert isinstance(obj, dict) + name = from_union([from_str, from_none], obj.get("name")) + extensions = from_union([lambda x: from_dict(lambda x: from_dict(lambda x: x, x), x), from_none], + obj.get("extensions")) + extras = obj.get("extras") + return Variant(name, extensions, extras) + + def to_dict(self): + result = {} + result["name"] = from_union([from_str, from_none], self.name) + result["extensions"] = from_union([lambda x: from_dict(lambda x: from_dict(lambda x: x, x), x), from_none], + self.extensions) + result["extras"] = self.extras + return result |