diff options
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 |