Babylon.js: OBJFileLoader does not exist on babylonjs

Created on 4 Feb 2019  路  7Comments  路  Source: BabylonJS/Babylon.js

i'm using 4.0.0-alpha.22 for babylonjs and babylonjs-loaders.

It works for loading obj from a file but when I'm trying to access BABYLON.OBJFileLoader.COMPUTE_NORMALS, i got an error indicating 'OBJFileLoader' does not exist on type 'typeof import('babylonjs)'. Seems like it's not properly exported, been following the instructions and not sure how to fix this.

Much appreciated for any help.

modules

Most helpful comment

So it is normal cause the when you import not using the namespace (which is the good way to go), you can only use the types included in the import.

The ObjFileLoader is part of loaders and not babylonjs.

You can slighty modify your imports like this:
import * as BABYLON from 'babylonjs';
import { OBJFileLoader } from 'babylonjs-loaders';
import 'babylonjs-materials';

OBJFileLoader.COMPUTE_NORMALS;

All 7 comments

Hello, are you using namespaces or modules in your code (it looks like you have a mix) ?

Thanks for your reply. I think i followed the online doc for each sublibrary and this is what i did in my code (angular7 component):
import * as BABYLON from 'babylonjs'; import 'babylonjs-loaders'; import 'babylonjs-materials';

Let me try locally and I ll come back to you.

So it is normal cause the when you import not using the namespace (which is the good way to go), you can only use the types included in the import.

The ObjFileLoader is part of loaders and not babylonjs.

You can slighty modify your imports like this:
import * as BABYLON from 'babylonjs';
import { OBJFileLoader } from 'babylonjs-loaders';
import 'babylonjs-materials';

OBJFileLoader.COMPUTE_NORMALS;

Let me know if that works :-)

It's working now. Not sure if I understand your comment correctly, but the npm doc here states when do import 'babylonjs-loaders, its classes are extended to BABYLON namespace. Is this specifically caused by babylonjs-loaders since material classes seem to be fine?
Thanks a lot for the help.

I ll go back over the doc ASAP and it might be a side effect of the es6 works. I will also check why it would work with materials.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

individ2016 picture individ2016  路  39Comments

deltakosh picture deltakosh  路  39Comments

maxime1992 picture maxime1992  路  17Comments

deltakosh picture deltakosh  路  61Comments

PatrickRyanMS picture PatrickRyanMS  路  18Comments