Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Created October 26, 2010 19:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrdoob/647576 to your computer and use it in GitHub Desktop.
Save mrdoob/647576 to your computer and use it in GitHub Desktop.
Three.js - Material system
// Approach 1 (links)
// Once the renderer finds a *MeshFaceMaterial*, it'll process the face material array
var common_material = [ new BitmapUVMaterial( bitmap ) ];
mesh.material = [ new MeshFaceMaterial(), new MeshColorStrokeMaterial( 0xff0000 ) ];
mesh.faces[ 0 ].material = common_material;
mesh.faces[ 1 ].material = common_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 BitmapUVMaterial( bitmap ), new MeshColorStrokeMaterial( 0xff0000 ) ];
mesh.faces[ 0 ].material = 0;
mesh.faces[ 1 ].material = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment