mrdoob/three.js — Issue #668: dynamically changing face colors.
Author: daiArna
Created: 2011-10-20 18:08:06+00:00
State: open

i assigned 3 material to a geometry.

function createScene( geometry ) {

geometry.materials[0].push( new THREE.MeshLambertMaterial( { color: 0xFF0000 } ) );
geometry.materials[1].push( new THREE.MeshLambertMaterial( { color: 0x00FF00 } ) );
geometry.materials[2].push( new THREE.MeshLambertMaterial( { color: 0x0000FF } ) );

var m = [ new THREE.MeshFaceMaterial() ];

zmesh = new THREE.Mesh( geometry, m);
scene.addObject(zmesh);
}

now i would like to change the color.

var i, l = meshes.length;

for ( i = 0; i < l; i++ ) {

meshes[ i ].geometry.faces[ 0 ].materials[ 0 ].color.setHex( 0x0000bb );
meshes[ i ].geometry.faces[ 0 ].materials[ 1 ].color.setHex( 0x0000bb );
meshes[ i ].geometry.faces[ 0 ].materials[ 2 ].color.setHex( 0x0000bb );
}

what am i doing wrong?