Babylon.js: OBJFileLoader

Created on 28 Jun 2018  路  39Comments  路  Source: BabylonJS/Babylon.js

I dont know where to load OBJ model for repro issue on playground, but it is easy and will perproduct with every model, that is not simmetry about ZoY.

Issue is that imported model is mirrored about ZoY, and you can fix it by scaling.x = -1.

unable to reproduce

All 39 comments

hi,

we didnt have any problem with obj loading until now. The playground supports OBJ loading, wanna try reproducing it there?

Here is an example with the Stanford bunny: https://www.babylonjs-playground.com/#8INCIV#20
And it works

Ok. you see that rabbit looking for left. And try import it in 3dmax for example. You will see issue.
Better sample will be car, or something with 3d text.

understood
Do you want to submit a PR to fix the loader ?

My english not so good)) What is PR?

sorry my bad: pull request

well.. it is not so big problem. But it will be great if objloader be little better

Completely agree that's why I'm ok to merge a pull request if you want to do one :)

Ok, lets do it))

Other question, if i may do it here.. Is there sample of obj loading with texture? I think i know second issue with it..

We don't have one unfortunately :(

And thank you so much for your help

nevermind. BabylonJS is best framework i ever seen

well.. to reproduce second issue you need to load OBJ file with texture and mtl. And you see that model is very dark. Than you just create StandardMaterial with same parameters and same diffuseTexture and it will be normal. I think that the problem is in shader (effect), that attached to material after loading from obj

i can mistake though..

If you have a obj with texture I can make it available on the playground for us to test :)

We do have an MTL parser that does work (we had a batman model with textures that I can't seem to find right now).

what is the licence? Did you create it?

Nope.. just from internet somewere.. better to not use it i think.. coz i donno license

But you will see issue, than you can remove it.

Didnt think of it.. You right. Lets create just a box with texture. It is my photo. And my box ;)

https://cloud.mail.ru/public/7UsH/K4mQ6gWBQ

Interesting...this seems to come from the way we load the image (wrapping issue?)

well.. i dont know what the problem exactly.. Just setted diffuseColor to be same as in StandardTexture:
https://www.babylonjs-playground.com/#8INCIV#25
But result is not same though :( It is darker

But texture.. You can use exactly same texture from first imported material, but the result is not same - texture loaded correctly i think: https://www.babylonjs-playground.com/#8INCIV#26

Well...I agree this is weird..this needs some debug :)

Hey
how to load obj with mtl using url
i tried it using BABYLON.SceneLoader.ImportMesh() , with my url of obj file and it's mtl
and it only load the obj file without loading it's materials ,also i tried to use this line

    BABYLON.OBJFileLoader.MATERIAL_LOADING_FAILS_SILENTLY = false;

to enforce it to load the materails and still Useless.
plz help

plz help

Did you seen what is in your mtl file? I mean file paths.. Is it correct?

I don't know what is the file paths
but when i tried to load this obj and mtl localy (in project file) it worked great and loaded with it's materails
but when i tried to upload it (obj and mtl) and imported it using url it load the obj file only without materails

--
u can access this file too , hope anyone solve this

https://quizgametesting.000webhostapp.com/BtcObj/

screenshot of mtl file

image

screenshot of mtl file

And where is texture files here?
What you mean, when tell us that mtl does not loaded?

there is no texture's here dude

it just a solid color (no images)

i mean it load the obj it self without it's materails

(Without material) -- When i loaded from url
image

(With material) -- When i loaded it localy
image

pinging @brianzinn

I'm able to load it in my local playground with just changing the locations from the example "Load glTF model".
image

This works when I point it at your webserver, too.

BABYLON.SceneLoader.Append("https://quizgametesting.000webhostapp.com/BtcObj/", "Btco.obj", scene, function (newMeshes) {
        scene.activeCamera = null;
        scene.createDefaultCameraOrLight(true);
        scene.activeCamera.attachControl(canvas, false);
    });

If you are loading from elsewhere then this may be a CORS or http server issue (ie: MIME types) on your MTL file when you are loading from a URL. Can you share a repro, because for me it is working. What would help is a network tab from Dev Tools screenshot or console output. Thanks.
https://playground.babylonjs.com/#11KQCA

Thank you guys so much ,I am really appreciate this
I just noticed my mistake , the problem is that i was putting the whole obj url in "sceneFilename" parameter
without split it to two parts "rootUrl" and "sceneFilename"
i tried to split it and it worked fine ,i think that was my problem

And i have other question about the ability of make babylonjs import fbx models also like threejs
is it possible even if soon or in next version ?

thx anyway
@brianzinn @deltakosh

fbx are not supported for now but if someone is motivated to write a loader I will gladly merge it:)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nbduke picture nbduke  路  21Comments

azchatlanin picture azchatlanin  路  17Comments

yvele picture yvele  路  18Comments

sebavan picture sebavan  路  49Comments

dad72 picture dad72  路  35Comments