2017-03-28 4 views
0

ich ein einfaches UV-Mapping für ein STL-Modell auf einem einziges Gesicht aufgetragen, das ist das Ergebnis:threejs UV-Mapping in OBJ-Datei

enter image description here

Jetzt exportiere ich die .obj und .mtl Dateien vom Mixer. Here können Sie sie herunterladen, wenn Sie möchten. Als ich diese obj und mtl Dateien laden mit OBJLoader und MTLLoader das Ergebnis wird im Anschluss an die:

enter image description here

Warum die Abbildung ist nicht das Gleiche? Ich könnte three.js könnte die UV-Mapping von Dateien lesen. Gibt es eine andere Möglichkeit, die UV-Karte in das Modell zu exportieren oder mache ich etwas falsch?

Dies ist der Code, den ich die obj und mtl Dateien zu laden verwenden, um:

this.loadOBJ = function (baseURL, objFile, mtlFile, type) { 
     return new Promise(function (resolve, reject) { 
      console.log("Adding OBJ file '" + objFile + "' with MTL file '" + mtlFile + "'"); 
      scope.clearScene(); 

      // OBJ file loader 
      function loadOBJ(materials) { 
       var objLoader = new THREE.OBJLoader(); 
       if (materials) { 
        objLoader.setMaterials(materials); 
       } 

       objLoader.setPath(baseURL); 
       objLoader.load(objFile, function (object) { 

        loadedMesh = object.children[0]; 

        scene.add(loadedMesh); 
        centerCamera(loadedMesh); 

        render(); 
        resolve(); 
       }, function (xhr) { 
        if (xhr.lengthComputable) { 
         var percentComplete = xhr.loaded/xhr.total * 100; 
         console.log("Loading OBJ file: " + Math.round(percentComplete, 2) + '% downloaded'); 
        } 
       }, function (xhr) { 
        console.log("Error loading OBJ: " + JSON.stringify(xhr)); 
        reject(); 
       }); 
      }; 

      if (!mtlFile) { 
       console.log("No MTL file specified, just loading OBJ"); 
       loadOBJ(); 
      } 
      else { 
       // Try to load the materials file first 
       var mtlLoader = new THREE.MTLLoader(); 
       mtlLoader.setPath(baseURL); 
       mtlLoader.load(mtlFile, function (materials) { 

        // File loaded, load the OBJ file now 
        materials.preload(); 
        loadOBJ(materials); 

       }, function (xhr) { 
        if (xhr.lengthComputable) { 
         var percentComplete = xhr.loaded/xhr.total * 100; 
         console.log("Loading MTL file: " + Math.round(percentComplete, 2) + '% downloaded'); 
        } 
       }, function (xhr) { 
        // We couldn't load the MTL file, load the OBJ anyway 
        console.log("Error loading MTL file: " + JSON.stringify(xhr) + ". Will load only OBJ file"); 
        loadOBJ(); 
       }); 
      } 
     }); 
    } 
+0

die UV-Mapping ist die gleiche, Ihre Geometrie ist anders. – gaitat

+0

Also wird die Geometrie nicht auf die gleiche Weise wie in Blender erstellt? – Andres

Antwort

1

es gut war nur ein Blender-Export-Problem. Ich habe gerade mein Modell mit diesen Einstellungen exportiert und es hat perfekt funktioniert!

enter image description here

0

In Ihrer mtl Datei ändert diese Zeile:

map_Kd uv_checker large.png 

zu

map_Kd large.png