I have an export of some .obj
files and corresponding .mtl
files. Textures are in .tga
format in the same folder.
Here is the code I use to load all my .obj
:
function addCar(modelPath, modelName) {
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath(modelPath);
for (var i = 0; i <= 2; i++) {
loadObject(mtlLoader, modelPath, modelName, i);
}
}
function loadObject(loader, path, name, i) {
var objectName = name + i + '.obj';
loader.load(name + i + '.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 is loaded, but not the textures. It appears all white, and there is no error in the console. I tried to add
mtlLoader.setTexturePath(modelPath);
but it didn't change anything.
I also tried to add
THREE.Loader.Handlers.add( /\.tga$/i, new THREE.TGALoader() );
before to call addCar
function. When I do that, some warning appears in the console, but texture still doesn't appear.
In all examples I saw, textures are loaded automatically when using OBJLoader and MTLLoader, but I didn't any example using OBJLoader and MTLLoader with TGA textures. So I'm wondering if there is something to do to get it worked.
Any help would be appreciated.
PS: the files (.obj
, .mtl
and .tga
) are exported from 3D max).