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.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:
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:
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!