Point Cloud - selecting / segment a group of points to form a plane

If you work in screen coordinates, you may avoid raycasting. For example, loop over each point in the cloud. Calculate its screen position. Check whether this screen position is inside the selection rectangle.

While you scan points to find which are inside the rectangle, you can also collected them in a separate list and send it to your backend.

In the past I’ve help another forum member with somewhat related issue. Here is some code which is forked from his code, and slightly modified by me: https://codepen.io/boytchev/pen/NWOMrxW

Use the mouse to draw a curved selection region. Then in the console you will see how many points are in this region. Note, that this program is more complex, as it works with collection of clouds of points. It also uses another approach – it creates a shape from the selection region, then casts a ray from the camera to each point and checks for intersection. I believe your case with one cloud and a rectangular selection area will need much simpler and shorter code.