Silent failure to load .obj?

I am attempting to load an .obj file into babylonjs but it appears to be silently failing as BABYLON.SceneLoader.ImportMeshAsync gives result.meshes with no elements in it.

There is a repo here: GitHub - AJamesPhillips/3d_sandbox
Which you can get running using:

npm install
npm run dev

Then:

I don’t observe any error, it’s just that no meshes are present.
When I drag the same .obj into https://sandbox.babylonjs.com/ it seems to work as expected.
I’ve read the docs so any tips / pointers on how to debug this would be appreciated.

Thank you :slight_smile:

why not use the ES6 libraries @babylonjs/core and @babylonjs/loaders. You can read about the side loading here - there is an optimization if you know you are only loading OBJ files:
Babylon.js ES6 support with Tree Shaking | Babylon.js Documentation (babylonjs.com)

edit: I didn’t run your repo to diagnose, but just looked at it briefly - I’m sure there is a solution using that library, but you will not get tree shaking benefits.

Thanks! I will give these a go. I am using the babylonjs-loaders library because when I searched for “babylonjs import .obj” the first link to the documentation was this one. Should we change the documentation to use those two libraries instead?

I did not understand that the first argument was used to filter the meshes by their name. I thought it was used to assign their name. When I replace this first argument with null it works as expected.

2 Likes