Importing .babylon mesh fails because of missing plugin/file is not well-formed

Hello! :slight_smile:

I’ve checked the previously asked questions on this topic and it seems my specific issue hasn’t come up before.

I’m having an issue importing a mesh I have created and exported as a .babylon file. I’m running my project locally using a webpack setup. At first I thought I had issues related to webpack, but I’ve added .babylon files to be handled by the url-loader in webpack, and my asset in this format is available on my webpack-dev-server when I run it. The .babylon file displays fine (as text) in the browser, so the issue does not seem to lie with the file itself.

The specific issue I’m having is that when using SceneLoader.ImportMesh or SceneLoader.ImportMeshAsync I receive errors indicating that there is no plugin to load the file.

The error I receive:

Unable to find a plugin to load .babylon files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf).

It is my understanding that no plugin should be needed to load .babylon files and that the functionality should be included without additional imports. I am, using ES6, however so my next steps was first to try to install the @babylonjs/loaders lib and add it as a “side-effect” import in my file, like so:
import "@babylonjs/loaders";
I did not find a plugin for .babylon files in there, and doing this gave me the same error.

My next step was to look around and see if there was a different side-effect import I could find that would solve my issue. At this point I found:
import "@babylonjs/core/Loading/Plugins/babylonFileLoader"
With this import I was given a different error:

XML Parsing Error: not well-formed
Location: http://localhost:8080/c68243ebbcd0295e907238cea2524365.babylon
Line Number 1, Column 1:

Edit: I discovered now that my .babylon file seems to contain JSON, not XML, which would explain the error above. Question still stands as to how I can import this file correctly.

So at this point it seems to be attempting to load the file, but fails when parsing. I did export the .babylon file directly from the inspector running inside the preview environment, without any changes to it.

As I’m not sure whether my last “side-effect” import is the correct one, I’m not sure if my last error is the one I should focus on.

I guess my question is, either:

  • Am I using the correct importer (should a side-effect import even be done to accomplish this)?
  • Why is the .babylon file exported directly from preview not well-formed?

One possible answer to the last question could be that it includes something that is not supported in an export. If that is the case a more descriptive error message would be very helpful. The mesh in question includes a spehere and a particle system, which I think should be possible to export as .babylon.

Thanks in advance!

You have nothing to do. bjs loader is by default in the engine if you import loaders.

Babylon.js by the way is a json file so this seems correct for me

1 Like

Thanks, good to know!

I am getting true for: SceneLoader.IsPluginForExtensionAvailable(".babylon"), by the way. My error (from my original post) still seems to indicate it is getting a XML parsing error when reading the file, however. And this is with the loader from the core lib imported. If I import the loaders lib instead, I am getting false for the above function call.

We will need a repro somewhere to help further :frowning:

Exact same issue. The .babylon loader is not loaded even if I add import "@babylonjs/loaders"; at the top level. I’m using webpack.

Repro: GitHub - Ruin0x11/ikpose at bd90b840084d89926e8fe28b58cf0d197cc2e8a1