Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Forked from alteredq/gist:647596
Created October 26, 2010 19:29
Show Gist options
  • Save mrdoob/647603 to your computer and use it in GitHub Desktop.
Save mrdoob/647603 to your computer and use it in GitHub Desktop.
// Approach 1 (links)
// Once the renderer finds a *MeshFaceMaterial*, it'll process the face material array
var head_material = [ new MeshBitmapUVMappingMaterial( head_bitmap ) ];
var torso_material = [ new MeshBitmapUVMappingMaterial( torso_bitmap ) ]
mesh.material = [ new MeshFaceMaterial(), new MeshColorStrokeMaterial( 0xff0000 ) ];
mesh.faces[ 0 ].material = head_material;
mesh.faces[ 1 ].material = head_material;
mesh.faces[ 2 ].material = head_material;
mesh.faces[ 3 ].material = torso_material;
mesh.faces[ 4 ].material = torso_material;
mesh.faces[ 5 ].material = torso_material;
// Approach 2 (indices)
// This is current solution in alteredq branch
// ColorStroke material will be automagically applied to the whole mesh
// for other FaceColor / Color / BitmapUV materials you need to set decalIndex property
mesh.material = [ new MeshBitmapUVMappingMaterial( bitmap ), new MeshBitmapUVMappingMaterial( bitmap ), new MeshColorStrokeMaterial( 0xff0000 ) ];
mesh.material[3].decalIndex = 1; // decal will go to head
// torso
mesh.faces[ 0 ].material = 0;
mesh.faces[ 1 ].material = 0;
mesh.faces[ 2 ].material = 0;
// head
mesh.faces[ 3 ].material = 1;
mesh.faces[ 4 ].material = 1;
mesh.faces[ 5 ].material = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment