我正在尝试加载从blender导出的JSON文件。 文件中有两个网格和两个材质。 这是我用来加载JSON的代码。
var self = this;
var mushroomLoader = new THREE.JSONLoader();
mushroomLoader.load('/js/Mushroom.js', function(mushroomGeometry, mushroomMaterial) {
var shrooms = new THREE.Object3D();
var mushroomCount = 10;
var radius = 30;
for(var i = 0; i < mushroomCount; i++) {
var m = new THREE.Object3D();
m.add(new THREE.Mesh(mushroomGeometry, mushroomMaterial[0]));
m.add(new THREE.Mesh(mushroomGeometry, mushroomMaterial[1]));
m.position.x = radius * Math.cos(Math.PI * 2 * i / mushroomCount);
m.position.z = radius * Math.sin(Math.PI * 2 * i / mushroomCount);
shrooms.add(m);
}
self.scene.add(shrooms);
}, 'images/textures');
将蘑菇分成两个网,顶部和树干。我正在使用MeshPhongMaterial。闪烁/消失的纹理位于顶部。奇怪的是,其中一些显示正确。
答案 0 :(得分:0)
你是对的@WestLangley! 我改变了我的代码
var m = new THREE.Object3D();
m.add(new THREE.Mesh(mushroomGeometry, mushroomMaterial[0]));
m.add(new THREE.Mesh(mushroomGeometry, mushroomMaterial[1]));
到
var m = new THREE.Mesh(mushroomGeometry, new THREE.MeshFaceMaterial(mushroomMaterial));
我不再有问题了。回想起来似乎很简单。我认为THREE.SceneUtils.createMultiMaterialObject对两个网格都使用相同的几何体是很奇怪的。