three.js: MTLLoader doesn't load tga textures -


i have export of .obj files , corresponding .mtl files. textures in .tga format in same folder.

here code use load .obj:

function addcar(modelpath, modelname) {   var mtlloader = new three.mtlloader();   mtlloader.setpath(modelpath);    (var = 0; <= 2; i++) {     loadobject(mtlloader, modelpath, modelname, i);   } }  function loadobject(loader, path, name, i) {   var objectname = name + + '.obj';    loader.load(name + + '.mtl', function (materials) {     materials.preload();      var objloader = new three.objloader();     objloader.setmaterials(materials);     objloader.setpath(path);     objloader.load(objectname, function (object) {       scene.add(object);     }, function (xhr) {       onprogress(xhr, objectname)     }, onerror);   }); } 

the car loaded, not textures. appears white, , there no error in console. tried add

  mtlloader.settexturepath(modelpath); 

but didn't change anything.

i tried add

three.loader.handlers.add( /\.tga$/i, new three.tgaloader() ); 

before call addcar function. when that, warning appears in console, texture still doesn't appear. enter image description here

in examples saw, textures loaded automatically when using objloader , mtlloader, didn't example using objloader , mtlloader tga textures. i'm wondering if there worked.

any appreciated.

ps: files (.obj, .mtl , .tga) exported 3d max).

you'll have use tgaloader load .tga files. can find here.

see webgl_materials_texture_tga source example.

is there reason why using .tga texture instead of .png? purposes give identical results, , .png smaller , can natively decoded browser you'll better performance.


Comments