Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

455
Views
Is it possible to load .obj file with colors if I don't have .mtl?

I'm new to three.js and I came up to this problem. I made a 3D scan of my face and it gave me only .obj file. If I open that file on Meshlab model comes with color on it. But after I load it on three.js it is without texture.

            
    
            // Loader 
            
            const loader = new OBJLoader();

            loader.load( './models/scene.obj', 
            function ( OBJ ) {
            
            var boundingBox = new THREE.Box3().setFromObject( OBJ );
            boundingBox.getCenter( OBJ.position ).negate();
            
                scene.add( OBJ );
                
            },
            
            

            function ( xhr ) {

                console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

            },
            

    function ( error ) {

        console.log( 'An error happened' );

    }
);

It's how my 3D model looks on three.js

also it's one-sided from the wrong side

Also tried this solution but that's not working. "An error happened" shows up without explanation

objLoader.load('assets/faceimage9.obj', function(object) {
  scene.add(object);
  object.traverse(node => {
    if (node.material) {
      node.material.vertexColors = true;
    }
  });
});

Thank you for your answers!

Edit: My .obj looks like it at first ~50000 lines My obj and then like it enter image description here

Here is full .obj https://drive.google.com/drive/folders/1x9MaZVWHTa-wSDkv8xzdRKU-ASPuJLOw?usp=sharing

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The OBJ asset defines vertex colors in the range [0,255] which is not supported by THREE.OBJLoader. Color data have to be defined in the normalized [0,1] range. Unfortunately the OBJ spec does not mention vertex colors so applications do not consistently export such data.

A simple fix to improve the rendering of your asset in three.js is this:

objLoader.load('assets/faceimage9.obj', function(object) {
  scene.add(object);
  object.traverse(node => {
    if (node.material) {
      node.material.side = THREE.BackSide;
    }
  });
});

In this way, the faces should be correctly displayed (but without vertex colors).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!