How to pass model converted to blob type url in SceneLoader.ImportMesh?

I have saved my model as blob type, then, I convert blob to a url using URL.createObjectURL() and I want to use this url in SceneLoader.ImportMesh("", “”, blob-url).
I have tried passing the url in the ImportMesh(), but it shows error: Unable to import meshes from blob:http://localhost:3000/0921b8e5-8278-4de3-b5cb-b7e7e5d0bb08: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

I don’t want to use SceneLoader.Append() because it returns the complete scene object in the success callback and I want to work upon the meshes just added to the scene. i.e.,

In Append:
SceneLoader.Append("", “”, blob-url, function(scene){
//Need to work on meshes of blob-url only and not complete scene
}
)

In ImportMesh,
SceneLoader.ImportMesh("", “”, blob-url, function(meshes){
//Need to work on meshes of blob-url only
//meshes array gives the meshes related to blob-url only which is my use-case
})

@Deltakosh

What type of object are you trying to load? is it a .babylon file, or something else? You will need to define the extension type when importing (i think it is the 7th or 8th parameter in the importMesh function).

Also make sure that the correct loader is available (gltf/obj, etc’)

Your solution worked.
SceneLoader.ImportMesh("", “”, url, scene, function (newMeshes) {
//
}, null, null, “.glb”)

Thanks @RaananW.

4 Likes

Have similar prob with AssetManager.addMeshTask
How we can determinate extension for AssetsManager.addMeshTask?
I see that function use SceneLoader.ImportMesh inside, but how we can set extension?

1 Like