Why I can't use ImportMesh?

When I use BABYLON.SceneLoader.ImportMesh('', '/public/', 'model4.gltf')
Why has the error? No scene available to import mesh to
Who can tell me? thanks.

Hi, according to the doc I think the issue is the 3rd argument.

You could try BABYLON.SceneLoader.ImportMesh('', '/public/model4.gltf') instead.

And make sure you have called the Scene constructor before.

1 Like

The optional scene does not mean that no scene needs to exist :slight_smile:

You need to make sure a scene was created already before imporintg a mesh to it. The 4th variable is a scene that you can pass to which the model will be loaded.

1 Like

Thank you. I solved it yesterday, using BABYLON.SceneLoader ImportMesh('', '/public/', 'model4.gltf', scene) , only the fourth parameter is added. But I tried your method, which is also OK.

1 Like

Thank you very much for your answer. Yesterday, I solved the problem by searching for information, and the result is that the fourth parameter is really needed.