Hi everybody! I have struggled a lot with webpack today and haven’t figured out how to solve my problem.
Stack: React + Babylon, Webpack as a bundler.
I want to import a mesh to my scene using ImportMeshAsync function, but it doesn’t work properly. In fact it generates an error (if I am using debugLayer) or just ignores me.
The lines below causes an error (I can see the error only if I toggle on the debugLayer);
You are using the url loader, which converts certain files to base64, depending on their size (or your configuration). it’ll be much better to not use base64 and have webpack generate a real URL.
do that by setting the limit to false in the webpack config.
Now you are going to get a URL. But it is not a valid path (according to our loader :-)), bcause it starts with “/”. add a “.” before the file URL, and use the window.location.href as a server address and you are good to go:
Above is working example, but I still don’t exactly understand WHY base64 does not work, and WHY your own webpack-config is managing the base64 quite well.
oh, base64 did work, but there was some weird issue with the texture. TBH - I haven’t debugged it. I can find the time later today or tomorrow to check
I would highly appreciate it if you look at the code later. The bugged code is at the branch named import-mesh-async-error, but I made it default branch in repository so you can just clone the repo.
You are initializing the scene (and engine) twice. and you load the model twice. the difference between base64 and a URL is that the URL is loaded async, whilc base64 is synchronous. And since the engine and scene is not yet ready loading the model does not work as expected. If you only load in the 2nd scene (not the best solution):
Check why your scene initializes twice. Feels like something is wrong with the Route (as it renders the dashboard a few times), but i’ll leave it to you to fix that part in the project