什麼this sample?它創建材料數組,然後將其添加到網格。所以,你可以重新使用它。
相關代碼:
// Create an array of materials to be used in a cube, one for each side
var cubeMaterialArray = [];
// order to add materials: x+,x-,y+,y-,z+,z-
cubeMaterialArray.push(new THREE.MeshBasicMaterial({ color: 0xff3333 }));
cubeMaterialArray.push(new THREE.MeshBasicMaterial({ color: 0xff8800 }));
cubeMaterialArray.push(new THREE.MeshBasicMaterial({ color: 0xffff33 }));
cubeMaterialArray.push(new THREE.MeshBasicMaterial({ color: 0x33ff33 }));
cubeMaterialArray.push(new THREE.MeshBasicMaterial({ color: 0x3333ff }));
cubeMaterialArray.push(new THREE.MeshBasicMaterial({ color: 0x8833ff }));
var cubeMaterials = new THREE.MeshFaceMaterial(cubeMaterialArray);
// Cube parameters: width (x), height (y), depth (z),
// (optional) segments along x, segments along y, segments along z
var cubeGeometry = new THREE.CubeGeometry(100, 100, 100, 1, 1, 1);
// using THREE.MeshFaceMaterial() in the constructor below
// causes the mesh to use the materials stored in the geometry
cube = new THREE.Mesh(cubeGeometry, cubeMaterials);
哈哈哈!驚人!非常感謝! (我想我檢查了這個網站上的所有演示除外) –
@JeremyDicaire - 很高興幫助 – acarlon