Repository: khronosgroup/gltf-blender-io
Issue: Multi-scene export fails

**Describe the bug**

a gltf exported from a .blend file that has multiple scenes in it will export every scene into the gltf, regardless if any objects are active.  This will cause it the be larger file and cause it to not load correctly with three.js GLTFLoader. etc.    Note: The export problems will only occurs when the active scene in blender is not the first scene.    

it's also compounded by the fact that some gltf viewers will error and some will load just first scene, so you can think it's working when it's not.

also, there are bunch of secondary issues that seem related to this.

an assert when combining NLA strips
export_nla_strips=False will cause an assert when I have a blend file with multiple scenes and one of the scenes has no action associated with any of it's objects.  I shored up this edge case and found other issues all stemming from this central issue.

an assert when applying modifiers
export_apply=True causes an assert.  if only one scene is present, this works.   if two scenes are present, and any scene but first scene is set to be the active scene,  the crash on export will happen.

**To Reproduce**
Steps to reproduce the behavior:
load the attached blend file and run the script in the text editor.  there are 4 scenes in the file.  the first has no animation.  the gltf gather action script is failing, likely because it wasn't expecting multiple scenes.

note the line comment at:

export_nla_strips=False  # <-- Set False will crash or produce duplicate actions

you can also get it to happen in the GUI if you try and export from a scene  and uncheck "Group by NLA Track" (same bool)

**Expected behavior**
I expect to be able to export all scenes and have only action per .glb file, and not have the hidden data from every other scene in the .blend file cluttering up the gltf file.

if no animated elements exist for one of the scenes, I expect it to still export without animation, or create an empy action animation.  I do not expect it to crash.   I'm writing a hack workaround to save a single keyframe in each scene before export to avoid this error.  Be good if it were fixed properly given the awesomeness of GLTF and its likely ubiquity.

**.blend file/ .gltf**
[gltf_crash.zip](https://github.com/KhronosGroup/glTF-Blender-IO/files/4743748/gltf_crash.zip)


**Version**
 - OS: Windows 10
 - Blender Version 2.90.0 alpha

**Additional context**
I also note that I get the same error with apply modifiers.  (see comment in text text editor of the blend file to make it happen)

note, if you animate anything in the cube scene (the fist scene, without any animation), the scenes will export and the error will not happen.  however, if you inspect in the exported GLTF files, there will be 4 duplicate actions all named "action" instead of just the one action as expected. 


Changed files:
addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py

diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py
index c6fd2c38..8d9e5e49 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py
@@ -97,7 +97,8 @@ def __gather_animations(blender_scene, export_settings):
 
             # There is only 1 animation in the track
             # If name of the track is not a default name, use this name for action
-            animations[merged_tracks[merged_anim_track][0]].name = merged_anim_track
+            if len(merged_tracks[merged_anim_track]) != 0:
+                animations[merged_tracks[merged_anim_track][0]].name = merged_anim_track
 
             continue