Creating a mesh with multiple materials

When you create THREE.Mesh, you can only specify a single material that can be used for that mesh. In most scenarios, this will be sufficient. However, there are also cases where you want to combine multiple materials. For instance, you might want to combine THREE.MeshLambertMaterial with a material that shows you the wireframe of the geometry. In this recipe, we'll show you the required steps to create a mesh that uses multiple materials.

Getting ready

For this recipe, we don't require additional resources or libraries. If you want to look at the result of this recipe, open up the 04.05-create-a-mesh-with-multiple-materials.html example in your browser.

In the preceding screenshot, you can see a cylinder. ...

Get Three.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.