Trying to import a mesh in the form of a Blob generated from a GLTF file

Hi there:

The case is that I have some 3d models encrypted files and, in order to consume them in my code, I’m generating a Uint8Array (plaintextbytes in the following program abstracts) with the help of a generic decrypter algorithm.

It works flawless with GLB files:

    ...
    var blob = new Blob([plaintextbytes], { type: "model/gltf-binary" });
    BABYLON.SceneLoader.ImportMeshAsync("","",URL.createObjectURL(blob),_scene,onProgress,".glb")
}

But in order to be able to share textures among several 3d models (with a great saving in bandwidth and storage space) I prefer to use GLTF.

The case is that, when I try to apply the same previous schema to GLTFs it doesn´t work.

I suppose I must change:

  1. type: "model/gltf-binary" to maybe type: "model/gltf+json" but it is not working
  2. the ending parameter in ImportMeshAsync, the plugin type ".glb", could need to be ".gltf", but again it is not working nether.

Any direction about it? I mean, about such a gltf vs glb specification in the call to APIs.

Thanks for your time.

cc @bghgary

What do you mean by this? Can you share a repro?

If you intend on loading a .glTF, the loader needs to know how to load the reference resources. You can use preprocessUrlAsync on the loader to redirect them to the right place.

Hi there, @bghgary:

I’ve finally managed to solve my problem. It was an error with the exporter.

Thanks for your time.

2 Likes