javascript - three.js how to map a texture on mtl,obj file -


i'm trying map png file on mtl,obj file

before mapping

but after mapping, mtl texture disappear.

after mapping

what should ? i'm not @ english. if can't understand question, please leave comment.

this code :

           var onprogress = function(xhr) {            var percentcomplete = xhr.loaded / xhr.total * 100;            console.log(math.round(percentcomplete, 2) + '% downloaded');         };           var onerror = function(xhr) {};          three.loader.handlers.add(/\.dds$/i, new three.ddsloader());          var loader = new three.imageloader();         loader.load("../img/ang.png", function(image) {             texture.minfilter = three.linearfilter;               texture.image = image;            texture.wraps = three.clamptoedgewrapping;            texture.wrapt = three.clamptoedgewrapping;            texture.offset.set(-3, -9.5);            texture.repeat.set(13, 13);            texture.needsupdate = true;          },onprogress,onerror);          var mtlloader = new three.mtlloader();         mtlloader.setpath('../models/');         mtlloader.load('nag-green.mtl', function(materials) {             materials.preload();             var objloader = new three.objloader();            objloader.setmaterials(materials);            objloader.setpath('../models/');            objloader.load('nag-green.obj', function(object) {                object.traverse(function(child) {                   if (child instanceof three.mesh) {                     child.material.map = texture;                  }               });                object.name = "object";               object.position.y = 0;               scene.add(object);             }, onprogress, onerror);         }); 

what want map 'ang.png' file on t-shirts this

what want

thank answer radio, tried way not want do.

give name material , map

you've applied same 'ang.png' texture child meshes. think need conditional in traverse function apply texture part of mesh needs texture.

the mtl should have applied name material when first loaded. example, here pretending material name "torso". exporter original 3d editor have given other name. in case, should able query name in conditional:

          object.traverse(function(child) {              if (child instanceof three.mesh) {                           if(child.material != undefined){                     if(child.material.name=="torso"){                       child.material.map = texture;                     }                  }              }           }); 

Comments

Popular posts from this blog

php - isset function not working properly -

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -