Jump to content

SceneLoader.ImportMeshAsync returns a String and not a mesh


nathanidp
 Share

Recommended Posts

Hello,

We are using the SceneLoader.ImportMeshAsync function for our project. However in local there's no particular problem but when we deploy the project it seems that the function don't work well.
The promise called with ImportMeshAsync seems to break and it never resolve (the callback function in '.then' is never called). We tried to do a catch but no error is catched.

What we do is we are using a proxy because the .obj files are stored in another website. Then we create a blob from the returned data by the proxy. Eventually we load the blob using the ImportMeshAsync function.

We tried to put some breakpoint on the promise call in the browser (it don't work with every browser) and the weird thing is that ImportMeshAsync returns a string in the deployed project but it returns a mesh locally.

Thank you for your help.
 

Link to comment
Share on other sites

We changed the babylonjs-loaders version to 3.2 and it resolves our problem.

There must be something that changed between 3.2 and 3.3 in the importMeshAsync  function.

We don't know how to repro it in the playground since we don't know what loader version is used and the files we are using are from a private link we cannot communicate... 
 

But here's how we call the function :

return new Promise((resolve) => {(
                "",
                url, // The url of the blob
                "",
                that.scene, // our babylon scene
                null,
                this.fileExtension // ".obj"
            ).then((importedData) => {
                // We never get here ...
                (...)
            }).catch((err) => {
               // We never get here to ...
                self.app.log.error(err);
    });
});

 

Link to comment
Share on other sites

  • 3 months later...

I am running into the same issue. 

https://www.babylonjs-playground.com/#JUKXQD#113

This playground scene works when I use:  BABYLON.SceneLoader.ImportMesh

Notice that the loaded mesh (skull) parents to the small rotating box.

But if I change it to:  BABYLON.SceneLoader.ImportMeshAsync

it doesn't parent to the box.

and it doesn't appear to call the onsuccess function at all.

I tested it in 3.3 and 4.0 prerelease with the same issue.

 

 

Never mind... Looks like I found the answer here: https://doc.babylonjs.com/how_to/promises

    BABYLON.SceneLoader.ImportMeshAsync("", "scenes/", "skull.babylon", scene).then( function (newMeshes) {
        newMeshes.meshes[0].parent = box;
    });

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...