Repository: khronosgroup/gltf-blender-io
Issue: Shapekey keyframes cause export errors 

Hi,

When trying to export an animation sequence made by keyframing shapekeys the animation does not work and I receive the following errors when testing in [the model viewer](https://gltf-viewer.donmccurdy.com/).

`ANIMATION_SAMPLER_OUTPUT_ACCESSOR_INVALID_COUNT`
`Animation sampler output accessor of count 168 expected. Found 6.`

`ANIMATION_DUPLICATE_TARGETS`
`Animation channel has the same target as channel 1.`

Please find attached the blender file in question as well as an example .glb export. In this file you will see a rigged model, keyframed (which exports no problem) and next to it a model where the animation sequence is created through shapekeys, where the problem is.

It might be worth mentioning that the shapekeys and their keyframes are being created by a script that copies the sequence from the rigged model. That script can be found in the attached file but I copy below for reference. However, I have tested by creating the same set of shapekeys and keyframes manually and the problem remains so I do not think it is the fault of the script.

Any advice would be much appreciated.

Example glb export
[animation_test.glb.zip](https://github.com/KhronosGroup/glTF-Blender-IO/files/3557118/animation_test.glb.zip)

Example blender file
[posetoshapedemo.blend.zip](https://github.com/KhronosGroup/glTF-Blender-IO/files/3557113/posetoshapedemo.blend.zip)

Script that creates shapekeys and keyframes (for reference)

```
import bpy

#save the total number of frames as var
frames = bpy.context.scene.frame_end + 1

#loop through frames, jump to each frame, add the armature, set as shapekey
for frame in range(frames):
    bpy.context.scene.frame_set(frame)
    bpy.ops.object.modifier_add(type='ARMATURE')
    bpy.context.object.modifiers["Armature"].object = bpy.data.objects["Armature"]
    bpy.ops.object.modifier_apply(apply_as='SHAPE', modifier="Armature")

#for each frame, loop through shapekeys and add as keyframe per frame
for frame in range(frames):
    bpy.context.scene.frame_set(frame)
    for shapekey in bpy.data.shape_keys:
        for i, keyblock in enumerate(shapekey.key_blocks):
            if keyblock.name != 'Basis':
               curr = i - 1
               if curr == frame:
                   keyblock.value = 1
                   keyblock.keyframe_insert("value")                 
               if curr == frame - 1 or curr == frame + 1:
                   keyblock.value = 0
                   keyblock.keyframe_insert("value")
```



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

diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
index 2477ba22..799fc645 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
@@ -187,10 +187,11 @@ def __get_channel_groups(blender_action: bpy.types.Action, blender_object: bpy.t
         else:
             try:
                 target = gltf2_blender_get.get_object_from_datapath(blender_object, object_path)
-                if blender_object.type == "MESH":
+                if blender_object.type == "MESH" and object_path.startswith("key_blocks"):
                     shape_key = blender_object.data.shape_keys.path_resolve(object_path)
                     if shape_key.mute is True:
                         continue
+                    target = blender_object.data.shape_keys
             except ValueError as e:
                 # if the object is a mesh and the action target path can not be resolved, we know that this is a morph
                 # animation.