In fact I can change the mesh.material by doing :
mesh.material = colorMaterial;
but I'd like to change the material of the faces one by one by doing :
mesh.material = null;
for each (var face:Face in mesh.faces){
face.material = hereanewmaterial;
}
But it doesn't work. The faces doesn't get any colormaterial and the
color of the mesh is randomly chosen by away3d.
On 17 nov, 12:10, Flo711 <[email protected]> wrote:
> Hello,
>
> I'm trying to change the material of faces that belong to a mesh
> contained in several ObjectContainer3D.
> Here is what I have written:
>
> for each (var face:Face in mesh.faces){
> trace (String(face.material));
> // it traces
> "null"
> face.material = colorMaterial;
> trace (String(face.material));
> // it tracesd
> "[object ColorMaterial]"
>
> if(i%2==1) face.visible=false;
> // it makes
> invisible alf of the faces
>
> i++;
> }
>
> I think I have succeeded to acces the faces and change their material.
> I don't get a "null" when I trace (face.material) but I can't get the
> visual result. The initial texture of the objet is still displayed.
>
> What I don't understand is why I get a null fisrt because the mesh is
> textured
> and why when I change the face material I cant' see the result.