Skip to content

Instantly share code, notes, and snippets.

@alteredq
Forked from mrdoob/gist:647603
Created October 26, 2010 20:06
Show Gist options
  • Select an option

  • Save alteredq/647669 to your computer and use it in GitHub Desktop.

Select an option

Save alteredq/647669 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( head_bitmap ), new MeshBitmapUVMappingMaterial( torso_bitmap ), new MeshColorStrokeMaterial( 0xff0000 ), new MeshBitmapUVMappingMaterial( decal_bitmap ) ];
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