Obj+mtl model is loaded but is black

the way our .mtl file is produced was changed recently, now our models appear as black.
here’s the code in a repo to show what I try.
the example is taken from the threejs examples, only files were change

what I already tried:
play with the lights, camera etc without success

tried following this advice:

but got an error ‘no multimaterials allowed’

this website was able to succesfuly convert to gltf: modelconverter.com
which was then succesfuly loaded in three.js editor with colors etc

Changing file format is not the answer.

Does the OBJ file have normals?

Changing the format was done to validate that it’s a code issue.
Regarding your question, how do I check for normals?

There are no vn definitions in your OBJ asset and thus no vertex normals. But you can compute them manually after loading like so:

object.traverse( function( child ) {

	if ( child.isMesh ) child.geometry.computeVertexNormals();

} );

Doing this in the three.js editor and then OBJ looks like so:

1 Like

1 - Open the obj file in any 3d editor.
2 - Open the obj file in any text editor and
See if you have lines starting with
a “vn some_number some_number some_number\n”
b “f some_number/some_number/some_number” or “f some_number//some_number”

(notice the slash f/2/2/2 or f 2//2)

f 40183/111824 40368/111857 40092/111823 from scene_mesh_decimated_textured.obj
f some_number/some_number => f vertex/uv/no normal

I would not use computeVertexNormals, better use a 3d editor. Doing normals is a matter of both science and art.

I would not say that. Normals are even sometimes generated in the shader on-the-fly. Using computeVertexNormals() seems to provide a proper result.

adding this to code results in a blank screen:

new OBJLoader(manager).setMaterials(materials).load(
    function (object) {
      // object.position.y = -95;
      object.traverse(function (child) {
        if (child.isMesh) child.geometry.computeVertexNormals();

computeVertexNormals does not account for seems nor face weight.

This is irrelevant for this use case.

Do you see any errors in the browser console?

No errors in the console.

can you show me where to add your code in the threejs editor ?