From 501c97628f1597bab7571951fc090771b88c824f Mon Sep 17 00:00:00 2001
From: Julien Duroure <julien.duroure@gmail.com>
Date: Sat, 25 Jun 2022 06:45:38 +0200
Subject: [PATCH] glTF exporter: Allow custom name for merged animation

---
 io_scene_gltf2/__init__.py                         | 13 ++++++++++++-
 io_scene_gltf2/blender/exp/gltf2_blender_gather.py |  7 +++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index e9e6660e8..616ba2f21 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,7 +4,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin SchmithĂĽsen, Jim Eckerlein, and many external contributors',
-    "version": (3, 3, 6),
+    "version": (3, 3, 7),
     'blender': (3, 3, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
@@ -372,6 +372,14 @@ class ExportGLTF2_Base:
         default=True
     )
 
+    export_nla_strips_merged_animation_name: StringProperty(
+        name='Merged Animation Name',
+        description=(
+            "Name of single glTF animation to be exported"
+        ),
+        default='Animation'
+    )
+
     export_def_bones: BoolProperty(
         name='Export Deformation Bones Only',
         description='Export Deformation bones only (and needed bones for hierarchy)',
@@ -568,6 +576,7 @@ class ExportGLTF2_Base:
             else:
                 export_settings['gltf_def_bones'] = False
             export_settings['gltf_nla_strips'] = self.export_nla_strips
+            export_settings['gltf_nla_strips_merged_animation_name'] = self.export_nla_strips_merged_animation_name
             export_settings['gltf_optimize_animation'] = self.optimize_animation_size
         else:
             export_settings['gltf_frame_range'] = False
@@ -863,6 +872,8 @@ class GLTF_PT_export_animation_export(bpy.types.Panel):
         layout.prop(operator, 'export_frame_step')
         layout.prop(operator, 'export_force_sampling')
         layout.prop(operator, 'export_nla_strips')
+        if operator.export_nla_strips is False:
+            layout.prop(operator, 'export_nla_strips_merged_animation_name')
         layout.prop(operator, 'optimize_animation_size')
 
         row = layout.row()
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py
index 6153bc336..4eb8baed4 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather.py
@@ -94,9 +94,12 @@ def __gather_animations(blender_scene, export_settings):
     if export_settings['gltf_nla_strips'] is False:
         # Fake an animation with all animations of the scene
         merged_tracks = {}
-        merged_tracks['Animation'] = []
+        merged_tracks_name = 'Animation'
+        if(len(export_settings['gltf_nla_strips_merged_animation_name']) > 0):
+            merged_tracks_name = export_settings['gltf_nla_strips_merged_animation_name']
+        merged_tracks[merged_tracks_name] = []
         for idx, animation in enumerate(animations):
-            merged_tracks['Animation'].append(idx)
+            merged_tracks[merged_tracks_name].append(idx)
 
 
     to_delete_idx = []
-- 
GitLab