I have seen this many times and I’m not sure why users are doing this. But you should never do this:
mesh = gltf.scene.children[0];
It might work but not in all cases. Your glTF contains three 3D objects and you are currently selecting not the mesh. To avoid such issues, it’s best to do this:
mesh = gltf.scene;
In Blender, you should also ensure to only export objects you actually want. I guess it is not your intention to export the camera and light, right?