Hello, I might be missing some basics AND trying to do a bit too much here but let’s try. Please point me in the right direction!

I’m working on a simple modeling tool. It’s built in @react-three/fiber but this problem seem like a pure three.js one.

I’m building a custom geometry starting from vertices and indices (both are simple states I control).

Now, I would like to extrude a new face from my starting geometry. I can easily duplicate my vertices and create 4 new ones. But I’m lost when it comes to programmatically creating faces. I want to use indices to reuse my vertices but I’m struggling to create all the front facing faces I need — and in a way that works no matter which direction I extrude from/to.

(btw, I know that three and WebGL work with tris and not quads, but I’m abstracting away the problem by grouping my indices in arrays of 6, representing couples of tris)

I read that to create faces I should sort my vertices counter-clockwise but I have no idea what exactly it means and how to do it. Any pointers would be appreciated.