5
我試圖在單一平面上製作多個材質來製作簡單的地形編輯器。所以,我創建了幾個材料,並嘗試在我的飛機分配matetrial索引每個頂點:Three.js - 多重材質飛機
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。任何幫助是偉大的thx!
http://stackoverflow.com/questions/8820591/how-to -use-multiple-materials-in-a-three-js-cube大致相同的問題 – Gero3
是的,我看到一個,但它是three.js的舊版本,似乎不工作:( –