2
我試圖映射在MTL png文件,OBJ文件three.js所如何映射在MTL紋理,OBJ文件
映射
之前,但映射後,mtl紋理就消失了。
映射後
我應該怎麼辦? 我不擅長英語。如果你不明白我的問題,請留下評論。
這是我的代碼:
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);
});
我想要做的就是地圖 'ang.png' 文件過那件T恤這樣
謝謝你爲你的答案無線電,我試過這種方式,但這不是我想要做的。
give a name to material and map