0

I have .obj file and .mtl file and I'm trying to render those file using THREE.JS

But obj was loaded but colors and other textures from .mlt files are not loaded.

So does anyone know what I'm doing wrong here?

Is there a chance that my material (.mtl) file is broken?

Thanks in advance.

var mtlLoader = new THREE.MTLLoader();
      mtlLoader.setPath('files/');
      mtlLoader.load('interior.mtl', function(materials) {
        materials.preload();
        var objLoader = new THREE.OBJLoader();
        objLoader.setMaterials(materials);
        objLoader.setPath('files/');
        objLoader.load('interior.obj', function(object) {
          object.position.y = -95;
          // object.castShadow = true;
          // object.receiveShadow = true;
          object.traverse( function( node ) { if ( node instanceof THREE.Mesh ) { node.castShadow = true; } } );
          scene.add(object);
        }, onProgress, onError);
      });

OUTPUT --> click here for my output of 3d-obj

  • 1
    does your object load in other applications like MeshLab? remove the shadow code (for now) to see if the rest works. Without posting your object there is no way to tell if they are correct or not. – gaitat Nov 07 '17 at 13:29
  • forget about that shadow for now. my object is rendered compeletly but i have only problem with colors and textures so as of now in my screen i have only 3D object with grey color . –  Nov 07 '17 at 13:46
  • i just uploaded screenshot of current output of my code. :) –  Nov 07 '17 at 13:52
  • sorry but the image does not really help your question. – gaitat Nov 07 '17 at 13:53
  • https://free3d.com/3d-model/kids-room-interior-73776.html this is object and material files i'm trying to render but colors and texture not loading .. i hope above link help you to understand what i m actually trying to say –  Nov 07 '17 at 14:08
  • that model does not contain an .mtl file. – gaitat Nov 07 '17 at 15:26

0 Answers0