I have modified the pen. There is nothing special. The new pen has function resetUVs
(at line 112) that is used on 4 different objects – a box, a triangle, a reversed triangle and a dodecahedron. It is the same function for all objects.
https://codepen.io/boytchev/full/rNZxLLK
The link that you have found also looks nice. It might provide better results in the general case.