Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

453
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda