0

I have this file, I can display it in Blender, Cinema4D and Photoshop, but can´t import it successfully with Three.js OBJLoader.

https://drive.google.com/file/d/0B8Hv0HwLV830VDZqVVlseFhEMkk/view?usp=sharing

I see the loaded model in black, but with the right geometry.

My scene is ok, with lights and other elements correctly displayed. The Browser's console shows the images loaded, and the materials created. This is the code I use to load the model:

    var mtlfile = filename.split('/').pop().replace('.obj', '.mtl');
    var objfile = filename.split('/').pop();

    var mtlLoader = new THREE.MTLLoader();
    mtlLoader.setPath( path );
    mtlLoader.load( mtlfile, function( materials ) {

        materials.preload();

        console.log( materials );

        var objLoader = new THREE.OBJLoader();
        objLoader.setMaterials( materials );
        objLoader.setPath( path );
        objLoader.load( objfile, function ( object ) {

            handleMesh(object);

        }, onProgress, onError );

    });
gman
  • 100,619
  • 31
  • 269
  • 393
  • `handleMesh` function could be doing literally anything. Perhaps it would be useful if you post the contents of it. – pailhead Aug 28 '17 at 17:31
  • sorry, the handleMesh function just adds the object to the scene... thank you – fanguitocoder Aug 31 '17 at 13:53
  • well, then, this code doesn't have enough information to illustrate your problem. It seems to be working fine if it's loading the geometry, and the material could be anything, while still correct. How do you know it's a non-black, lit material? – pailhead Aug 31 '17 at 18:00
  • I have found the problem, I needed to set also mtlLoader.setBaseUrl(...), that solved the problem... – fanguitocoder Aug 31 '17 at 19:56

0 Answers0