我有.mtl
,.obj
和多个纹理.jpg
文件。我尝试在导出加载程序 obj 中使用不同的纹理。我能够使我的对象在场景中可见,但我的对象black
颜色可见。关于我的代码中有什么问题/缺少什么的任何想法?
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath('models/LivingRoom/Sample/');
mtlLoader.load( 'small plant.mtl', function( materials ) {
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.setPath('models/LivingRoom/Sample/');
objLoader.load( 'small plant.obj', function ( object ) {
var geometry = object.children[ 0 ].geometry;
var materials = [];
var mat1=new THREE.MeshLambertMaterial( { map : THREE.ImageUtils.loadTexture('models/LivingRoom/Sample/Listik-2.jpg')});
var mat2=new THREE.MeshLambertMaterial({ map : THREE.ImageUtils.loadTexture('models/LivingRoom/Sample/22_zemlya_oboi_1920x1080.jpg')});
materials.push(mat1);
materials.push(mat2);
mesh = THREE.SceneUtils.createMultiMaterialObject(geometry,materials);
mesh = THREE.SceneUtils.createMultiMaterialObject(geometry,threeDTexture);
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.materials = materials;
}
});
},
function ( xhr ) {
returnValue = ( xhr.loaded / xhr.total * 100 ) + '% loaded';
console.log(returnValue);
},
function ( error ) {
console.log( 'An error happened' );
}
);
});