How to validate integrity while loading *.babylon or *.gltf files?

It seldom happens running my project. For meshes and skeletons loaded with same file, may be failed to play their all animations. And I saw no error logged in console. (I don’t use cloning, each one of them are separately loaded by SceneLoader.ImportMeshAsync and animation ranges are also got separately after loading)

I guess it’s because the file the page downloaded corrupted but not for sure. So how to validate intergrity while using SceneLoader.ImportMesh? I think I just need to get a hash checksum during that but no idea how to make it

You could compare the file size in the response reader with the size of the downloaded content maybe?

2 Likes

Eventually I find it’s okay to add “onProgress” function for “ImportMeshAsync”, the argument in that function has “.originalTarget.response” as downloaded content.

My validate method is like:

const result = await SceneLoader.ImportMeshAsync('', '/path/', 'abc.babylon', scene, event => {
  if (event.loaded === event.total) {
    // @ts-ignore
    const message = event.originalTarget.response // "ISceneLoaderProgressEvent" didn't define these
    if (CryptoJS.MD5(message).toString() === 'my hash checksum generated locally') {
      console.log('Validate successfully')
    }
  }
})
3 Likes