It’s not that hard once you give it some thought.
I started with simple geometric shapes and quickly moved on to much more complex ones.
https://discourse.threejs.org/t/profiledcontourgeometry-multimaterial/5801it’s along the lines of what you obviously need.
A very simple example: Prism
(see Implement the different color for each face of the shape which is made by extrude geometry - #6 by hofk)
This is a good way to get a basic understanding of the issue.
RoundedRectangle + Squircle
Round-edged box flat