I am trying to import a .glb file My folder structure looks like this:
When I use let res= BABYLON.SceneLoader.ImportMeshAsync("", "/img/", "crate.glb", scene);, I get the following error:
which made me think I had the wrong path. I tried alot of different things to get “the right path”, but nothing works.
When I use new BABYLON.Texture('/img/block.jpg', scene), everything works fine and the material has the desired texture from the block.jpg.
When using devTools to look at the requests, both seem to have a very similar url but one fails
Also, I opened the crate.glb with the BabylonJS Sandbox and it worked fine, so the file itself shouldn’t be the problem.
does opening the URL returning the file / download the file? i.e. https://localhost:7022/img/crate.glb should be available. If it isn’t, and is still returning 404, something might be wrong with your server definition. Not sure it is a CORS issue, especially since your image is working. Might be a mime-type issue (i.e. - server is not sending any file it doesn’t know what mime-type it is)
@labris I read the article and didn’t find something that struck me as the solution to my problem, but maybe I’m just too tired The article seems to be about behaviour for cross-origin requests, but my request is same-origin:
@RaananW That’s one of the first things I tried as well, and no it didn’t download the file, its a 404. Just to make sure I moved the .glb file from the folder I originally had it in to the folder /img where block.jpg is which I knew worked. But it still isn’t found.
I can only think of mime-type support. change the filename of the glb to png and see if you can download it (of course not a solution but will get you closer to resolving the issue). It is probably not related, but make sure you are case-sensitive.
But it could be many other reasons. Server-related for sure.
So after suffering through almost a day worth of reading & trying solution from SO, forums etc., I’ve finally found a solution that works (for now at least). What I had to do was add < add mimeType="model/gltf-binary" enabled="true" /> to my applicationhost.config file in the IISExpress folder. In addition, I had to add the following to my Program.cs file: (ASP.NET specific)