More Materials on ExtrudeGeometry

In this reply on another post, Mugen87 summarily states the truth about ExtrudeGeometry's material usage. My question is, would supporting more fine-grained application of materials in ExtrudeGeometry be a feature the 3js powers that be would consider adding? The above-linked post is one example of someone wanting the feature; I’m also working on a project where I want that feature (in my case, I only want the “top” face to have a unique material). I’ve gone ahead and customized ExtrudeGeometry for my own needs (as I suspect that other poster also did). Should I take it a step further, clean it up, and submit a pull request?

It’s interesting, that exactly your use-case is already covered by the standard ExtrudeGeometry():

From the documentation:

When creating a Mesh with this geometry, if you’d like to have a separate material used for its face and its extruded sides, you can use an array of materials. The first material will be applied to the face; the second material will be applied to the sides.

The documentation is slightly misleading. The first material is applied to the top and bottom faces (“caps”) and the second material to the sides. A quick glance at the code shows why; the caps are part of the same group with the same material index. I’m not going to quote the code here, because it’s a lot of lines; see ExtrudeGeometry.js lines 510-564.


I generously assumed, that the extruded geometry would be standing on its bottom face, which would become hidden from sight and so it wouldn’t really matter what material it has … :blush:

I also gave you a “like” for your precision reading and interpretation.

1 Like