Some OBJ files give unhandled expression on load - babylonjs loaders

Hi guys.

Some OBJ files cannot be loaded into the scene. I open these files normally with the 3D software. There are some negative values in the file, I am not sure what is going on though. Any ideas??

Here is a playground with the specific OBJ that doesn’t work


Seems like negative indices issue existed in some other engines

Can I do something about this, or this is engine side issue?

Did you try playing with the OBJLoader options?

I feel like one of them should work

How do it set those options? I am importing babylonjs-loaders module, and loading files like in a playground, with the loader plugin defined inside the importMesh method.

You should be able to set them as static ong the class as well (check the code of objloader, it is pretty straightforward)

Okay, I managed to play with the properties. But nothing helped. Maybe I missed something. This is kinda major issue in the project at the moment. If I don’t find solution for this I will have to go for some server side conversion process, which I would really like to avoid (as models like this are coming from the one of the major platforms that we need to support).

Every model exported from has same issue. It seems that they are using nurbs modeling technique which sets these negative indices values.

This is what my colleague reported to me

based on the babylonjs.loaders.min.js file it looks like line 1001 of babylonjs.loaders.js is where the error is thrown: “Cannot read property ‘x’ of undefined” … the undefined var is wrappedPositionForBabylon[l]

Any help is appreciated.

If you look at the console you’ll see that the OBJLOader is not recognizing the attribute v which is used a log. There is something you need to change at exportation level I guess

I’ll try to what is happening in the meantime

Wait I think I know what is wrong

OK issue found…Will be live in a couple of hours

1 Like

Thank you @Deltakosh. You are a lifesaver, as usual. :smiley: It works now in the playground, but not in my app still.

Do I have to do something to make it work in my app? I forgot to note that I am using latest preview, not 4.1.0 As 4.1.0 is missing one of key features I need.

Is that an issue now?

I checked this file, the changes are in.

So make sure you retrieved the latest babylonjs.loaders.js file / that the cache of the browser is cleaned.

Hey guys. I still didn’t make this work in the app. So if I install v4.2.0-alpha.27 and use

import ‘babylonjs-loaders’ this should work?

I tried reinstalling packages, upgrading, downgrading. I think cache is not an issue. It feels to me like I am not grabbing the right dependency somehow.

Solved this by manually grabbing that file from the CDN. npm install seems like didn’t grab the right file. Not sure what is going. But I will mark this as solved.

Thank you guys for you help. Cheers.

1 Like