Export SkinnedMesh with Skeleton using GLTFExporter

Hello, first time here. I am trying to export a SkinnedMesh (JSFiddle: Three.js: Export SkinnedMesh with GTLFExporter - JSFiddle - Code Playground) from example (three.js docs) into gltf/glb using GLTFExporter. All works fine until I import the file into Blender.

Python: Traceback (most recent call last):
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/__init__.py", line 1064, in execute
    return self.import_gltf2(context)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/__init__.py", line 1078, in import_gltf2
    if self.unit_import(path, import_settings) == {'FINISHED'}:
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/__init__.py", line 1098, in unit_import
    BlenderGlTF.create(gltf_importer)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py", line 42, in create
    BlenderGlTF._create(gltf)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_gltf.py", line 49, in _create
    BlenderScene.create(gltf)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_scene.py", line 45, in create
    BlenderNode.create_vnode(gltf, 'root')
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_node.py", line 51, in create_vnode
    BlenderNode.create_vnode(gltf, child)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_node.py", line 51, in create_vnode
    BlenderNode.create_vnode(gltf, child)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_node.py", line 38, in create_vnode
    BlenderNode.create_object(gltf, vnode_id)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_node.py", line 58, in create_object
    obj = BlenderNode.create_mesh_object(gltf, vnode)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_node.py", line 211, in create_mesh_object
    mesh = BlenderMesh.create(gltf, pynode.mesh, pynode.skin)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py", line 34, in create
    return create_mesh(gltf, mesh_idx, skin_idx)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py", line 52, in create_mesh
    do_primitives(gltf, mesh_idx, skin_idx, mesh, tmp_ob)
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py", line 249, in do_primitives
    skin_into_bind_pose(
  File "/snap/blender/1237/3.0/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py", line 518, in skin_into_bind_pose
    skinning_mats += ws[:, i].reshape(len(ws), 1, 1) * joint_mats[js[:, i]]
IndexError: index 5 is out of bounds for axis 0 with size 5

location: <unknown location>:-1

I have also tried using glTF Validator to validate the files, it gave these errors.

{
    "uri": "scene.gltf",
    "mimeType": "model/gltf+json",
    "validatorVersion": "2.0.0-dev.3.4",
    "validatedAt": "2022-01-21T16:28:22.044Z",
    "issues": {
        "numErrors": 9,
        "numWarnings": 36,
        "numInfos": 1,
        "numHints": 0,
        "messages": [
            {
                "code": "UNUSED_OBJECT",
                "message": "This object may be unused.",
                "severity": 2,
                "pointer": "/meshes/0/primitives/0/attributes/TEXCOORD_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 1 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 5 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 9 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 13 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 17 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 21 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 25 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 29 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_INDEX_OOB",
                "message": "Joints accessor element at index 33 (component index 1) has value 5 that is greater than the maximum joint index (4) set by skin 0.",
                "severity": 0,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 109 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 113 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 117 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 121 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 125 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 129 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 133 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 137 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 141 (component index 1) is used with zero weight but has non-zero value (4).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 217 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 221 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 225 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 229 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 233 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 237 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 241 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 245 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 249 (component index 1) is used with zero weight but has non-zero value (3).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 325 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 329 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 333 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 337 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 341 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 345 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 349 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 353 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 357 (component index 1) is used with zero weight but has non-zero value (2).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 433 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 437 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 441 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 445 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 449 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 453 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 457 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 461 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            },
            {
                "code": "ACCESSOR_JOINTS_USED_ZERO_WEIGHT",
                "message": "Joints accessor element at index 465 (component index 1) is used with zero weight but has non-zero value (1).",
                "severity": 1,
                "pointer": "/meshes/0/primitives/0/attributes/JOINTS_0"
            }
        ],
        "truncated": false
    },
    "info": {
        "version": "2.0",
        "generator": "THREE.GLTFExporter",
        "resources": [
            {
                "pointer": "/buffers/0",
                "mimeType": "application/gltf-buffer",
                "storage": "data-uri",
                "byteLength": 8024
            }
        ],
        "animationCount": 0,
        "materialCount": 1,
        "hasMorphTargets": false,
        "hasSkins": true,
        "hasTextures": false,
        "hasDefaultScene": true,
        "drawCallCount": 1,
        "totalVertexCount": 117,
        "totalTriangleCount": 192,
        "maxUVs": 1,
        "maxInfluences": 4,
        "maxAttributes": 5
    }
}

Here is the screenshot when I imported into Blender

Hope someone can shed some light on this… :,)

I changed

skinIndices.push(skinIndex, skinIndex + 1, 0, 0);

to

skinIndices.push(skinIndex, skinIndex, 0, 0);

and the error went away and the mesh does show up in blender…