我试图在一个平面上使用多种材质来制作一个简单的地形编辑器。所以我创建了几个材质,并尝试为平面中的每个顶点分配一个材质索引:
var materials = [];
materials.push(new THREE.MeshFaceMaterial( { color: 0xff0000 }));
materials.push(new THREE.MeshFaceMaterial( { color: 0x00ff00 }));
materials.push(new THREE.MeshFaceMaterial( { color: 0x0000ff }));
// Plane
var planegeo = new THREE.PlaneGeometry( 500, 500, 10, 10 );
planegeo.materials = materials;
for(var i = 0; i < planegeo.faces.length; i++)
{
planegeo.faces[i].materialIndex = (i%3);
}
planegeo.dynamic = true;
this.plane = THREE.SceneUtils.createMultiMaterialObject(planegeo, materials);
但是我总是在着色器中得到一大堆错误,或者如果我使用MeshBasicMaterial
而不是FaceMaterial
. 我究竟做错了什么?