Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'io_scene_gltf2/io/exp/gltf2_io_export.py')
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_export.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/io_scene_gltf2/io/exp/gltf2_io_export.py b/io_scene_gltf2/io/exp/gltf2_io_export.py
index 49cc4a78..aee74ba9 100755
--- a/io_scene_gltf2/io/exp/gltf2_io_export.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_export.py
@@ -7,6 +7,7 @@
import json
import struct
+from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions
#
# Globals
@@ -19,13 +20,18 @@ from collections import OrderedDict
def save_gltf(gltf, export_settings, encoder, glb_buffer):
- indent = None
- separators = (',', ':')
+ # Use a class here, to be able to pass data by reference to hook (to be able to change them inside hook)
+ class GlTF_format:
+ def __init__(self, indent, separators):
+ self.indent = indent
+ self.separators = separators
+
+ gltf_format = GlTF_format(None, (',', ':'))
if export_settings['gltf_format'] != 'GLB':
- indent = 4
+ gltf_format.indent = 4
# The comma is typically followed by a newline, so no trailing whitespace is needed on it.
- separators = (',', ' : ')
+ gltf_format.separators = (',', ' : ')
sort_order = [
"asset",
@@ -48,8 +54,11 @@ def save_gltf(gltf, export_settings, encoder, glb_buffer):
"samplers",
"buffers"
]
+
+ export_user_extensions('gather_gltf_encoded_hook', export_settings, gltf_format, sort_order)
+
gltf_ordered = OrderedDict(sorted(gltf.items(), key=lambda item: sort_order.index(item[0])))
- gltf_encoded = json.dumps(gltf_ordered, indent=indent, separators=separators, cls=encoder, allow_nan=False)
+ gltf_encoded = json.dumps(gltf_ordered, indent=gltf_format.indent, separators=gltf_format.separators, cls=encoder, allow_nan=False)
#