The idea of implementing the fill as in the game 3d

I’m trying to implement a gameplay like in a game 3d, but I have no idea how to do it.

gameplay video (youtube)

My first try to use convexmesh (drawing using mouse and raycaster):

but for obvious reasons, the convex part of the mesh is ignored.

I also moved towards using ExtrudeGeometry, but this means that the extruded mesh must have a lot of triangles to make it look smooth.

Can you give me some ideas on how to implement such a thing?

1 Like

How did you handle the curve with extrude geometry?

So far I’ve only been thinking about the extrude and haven’t implemented anything. But the idea was to find the faces that enter the zone that we circled.
Perhaps a stupid way is to shoot raycasts all over the selected area to collect faces.

perhaps you can somehow work with the mesh in 2d space by unwrap it?

it looks complicated(

So basically you want to split the mesh into 2 parts based on a line.
For that, first get all the faces along the contour. You can do this with raycast from the mouse.
Then pick the first face and traverse all the faces by its neighbours(like BFS), stop at any face that’s in the contour.
After you have all the faces in a set it will either be inside or outside, so you can pick the inside one and move all the vertices by some amount along the normal.
You will need to add some extra points along the line if you want to make very fine edges.

1 Like