Obj file turn black in Sandbox


I am trying to load Obj file in sandbox and also in my application but results are same.
My scene appears to be black. I have attached my expected view but In sandbox and in my application both its not near to the expected one.

Obj file

Current view in sandbox:

Expected view:

Hello and welcome ! :slight_smile:

.OBJ is fine to be used with Babylon.JS in general, but this format doesn’t handle any embedded material or textures. When you export it from a 3D software such as Blender, it will export as well some material files (.MTL) as well as some textures (.JPG, .PNG, etc…).

For testing in the playground best is to export to .GLB, (it’s a binary version of the .GLTF format, which contains embedded materials and textures)


1 Like

Should I open same Obj file in Microsoft Blender and should I export to get .MTL file and so on?

Opening this OBJ file alone in Blender won’t retrieve the missing .mtl files.
The mtl files should be generated at the same time the obj file is.
So :

  • Either you modeled this yourself (Blender, or other) and then :
    • when you export to .obj, you should have the .mtl files along with the .obj
    • when you export to .glb, materials will be embedded
  • Either you downloaded this .obj, and then should be provided the .mtl files with this .obj file (as well as, eventually, some textures files). In that case, yes, you can open it in Blender and reexport to .glb for example

(For example having a look at the content of the .obj, there is a material file linked : Banmore_Simulation_for Control with Tyre.mtl)

1 Like

Ok I got the .mtl file as well.
Over sandbox we have improvement but still not the expected one

Can you tell me how to apply this mtl file in my code.
BABYLON.SceneLoader.Append(“./”, “Banmore3D__for Control with Tyre.obj”, scene, function (scene) {
scene.createDefaultCameraOrLight(true, true, true);

The easiest thing you can do is convert your .obj file to .glb in Blender and the issue will be gone. :see_no_evil:

Import OBJ
Export GLB

Actually I dont have blender this files were shared by my client.
If you have and If you can help me will be really helpful.

It looks like the normals of the model are reversed

Believe me, you will save yourself from future troubles if you opt for .glb.

Download — blender.org :stuck_out_tongue:

1 Like

How should I check this?

In general, the brightness of the model is calculated by the normal orientation of the surface and the orientation of the light. The top of your model is dark and the bottom is light. This means that your model has non-auto-generated normals, and the normals are reversed. Anyway, this is probably a model export problem, and you can try to re-export the model using blender.

1 Like

(c) 2024 @Tricotou

1 Like

I downloaded but It appears to be completely different in blender.

1 Like

Ok, now you may check in rendered mode if everything is fine. If it’s ok, you can export to .GLB and it should work. If it’s not fine in Blender, you might be missing other files. For example, open your .MTL file with a text editor. It should contain for each material eventually some textures paths. You need to check if you have these textures.

Example of classic problem : Sometimes some softwares export texture path with absolute path, which means it contains something like "C:\Users\Username\Desktop\ProjectName\file.jpeg" this for sure will never work on another machine :slight_smile:

Could you be more talkative and precise when posting please?

After exporting load your .glb model into https://sandbox.babylonjs.com/