我正在通过构建自定义定位面来创建自定义几何图形。我正在使用MeshNormalMaterial
for 材料,我想彼此独立地定义面的颜色。但是,无论我设置什么颜色,我仍然得到相同的外观结果。
我的代码如下:
var geometry = new THREE.Geometry();
for (var i = 0; i < length - 1; i++) {
for (var j = 0; j < length - 1; j++) {
geometry.vertices.push(new THREE.Vector3(x[i][j], y[i][j], z[i][j]));
geometry.vertices.push(new THREE.Vector3(x[i + 1][j], y[i + 1][j], z[i + 1][j]));
geometry.vertices.push(new THREE.Vector3(x[i + 1][j + 1], y[i + 1][j + 1], z[i + 1][j + 1]));
geometry.vertices.push(new THREE.Vector3(x[i][j + 1], y[i][j + 1], z[i][j + 1]));
var face = new THREE.Face4(index, index + 1, index + 2, index + 3);
face.color.setHex(color);
geometry.faces.push(face);
index += 4;
}
}
geometry.computeFaceNormals();
var object = new THREE.Mesh(geometry, new MeshNormalMaterial());
parent.add(object);
我应该对上面的代码进行什么更改,例如我可以设置面部颜色并让它们实际显示我设置的颜色?