This answer only applies to versions of three.js prior to r.125.
Here is how you set and change the colors of a cube's faces:
var geometry = new THREE.BoxGeometry( size, size, size );
for ( var i = 0; i < geometry.faces.length; i ++ ) {
geometry.faces[ i ].color.setHex( Math.random() * 0xffffff );
}
var material = new THREE.MeshBasicMaterial( { color: 0xffffff, vertexColors: true } );
If geometry.faces[i].color
is changed after the geometry has been rendered, you must set geometry.colorsNeedUpdate = true
.
three.js r.124
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…