我有这个方法:
self.create_from_prototype_1 = function (x, y, z, body_textures, left_leg_textures, right_leg_textures) {
var body_geo = new THREE.Geometry();
var left_leg_geo = new THREE.Geometry();
var right_leg_geo = new THREE.Geometry();
self.merge_parts(body_geo, self.get_face(x, y, z), 0);
self.merge_parts(body_geo, self.get_head(x, y, z), 1);
self.merge_parts(body_geo, self.get_neck(x, y, z), 2);
self.merge_parts(body_geo, self.get_body_front(x, y, z), 3);
self.merge_parts(body_geo, self.get_body(x, y, z), 4);
self.merge_parts(body_geo, self.get_left_arm(x, y, z), 5);
self.merge_parts(body_geo, self.get_right_arm(x, y, z), 6);
self.merge_parts(body_geo, self.get_left_forearm(x, y, z), 7);
self.merge_parts(body_geo, self.get_right_forearm(x, y, z), 8);
self.merge_parts(body_geo, self.get_left_hand(x, y, z), 9);
self.merge_parts(body_geo, self.get_right_hand(x, y, z), 10);
self.merge_parts(left_leg_geo, self.get_left_leg(x, y, z), 0);
self.merge_parts(left_leg_geo, self.get_left_thigh(x, y, z), 1);
self.merge_parts(left_leg_geo, self.get_left_foot(x, y, z), 2);
self.merge_parts(right_leg_geo, self.get_right_leg(x, y, z), 0);
self.merge_parts(right_leg_geo, self.get_right_thigh(x, y, z), 1);
self.merge_parts(right_leg_geo, self.get_right_foot(x, y, z), 2);
var body_materials = [];
var left_leg_materials = [];
var right_leg_materials = [];
var i;
for (i = 0; i <= 10; i++) {
body_materials.push(new THREE.MeshBasicMaterial({
map : body_textures[ i ]
}));
}
for (i = 0; i <= 2; i++) {
left_leg_materials.push(new THREE.MeshBasicMaterial({
map : left_leg_textures[ i ]
}));
}
for (i = 0; i <= 2; i++) {
right_leg_materials.push(new THREE.MeshBasicMaterial({
map : right_leg_textures[ i ]
}));
}
var body = new THREE.Mesh(body_geo); // no textures yet :/
body.geometry.computeFaceNormals();
body.geometry.computeVertexNormals();
var left_leg = new THREE.Mesh(left_leg_geo); // no textures yet :/
left_leg.geometry.computeFaceNormals();
left_leg.geometry.computeVertexNormals();
var right_leg = new THREE.Mesh(right_leg_geo); // no textures yet :/
right_leg.geometry.computeFaceNormals();
right_leg.geometry.computeVertexNormals();
Game.scene.add(body);
Game.scene.add(left_leg);
Game.scene.add(right_leg);
return {
body : body,
left_leg : left_leg,
right_leg : right_leg
};
}
它工作正常并正确渲染最终网格但是如果我不添加材料。但是,如果我使用MeshFaceMaterial对象添加我在上面创建的材质数组,如下所示:
var body = new THREE.Mesh(body_geo, new THREE.MeshFaceMaterial(body_materials)); // no textures yet :/
body.geometry.computeFaceNormals();
body.geometry.computeVertexNormals();
var left_leg = new THREE.Mesh(left_leg_geo, new THREE.MeshFaceMaterial(left_leg_materials)); // no textures yet :/
left_leg.geometry.computeFaceNormals();
left_leg.geometry.computeVertexNormals();
var right_leg = new THREE.Mesh(right_leg_geo, new THREE.MeshFaceMaterial(right_leg_materials)); // no textures yet :/
right_leg.geometry.computeFaceNormals();
right_leg.geometry.computeVertexNormals();
控制台抛出&#34;无法读取属性&#39;属性&#39;未定义的。&#34;。这是一个错误吗?我在Google搜索并在一整天内检查了我的代码,我找不到与此问题相关的任何解决方案(我甚至尝试直接加载和添加MeshBasicMaterials用于纹理而且都没有工作)..任何帮助.. ?感谢&#39;!小号