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

Hi all,

Starting a new project where I need to create an editor to interact with pointclouds.

Just to get going I need to do the following

  • A way to select a group of points from a loaded pointcloud with the mouse - a rectangular, circular selection is absolutely fine to start with
  • Highlight these selected points in a another color
  • Segment these points for processing in the back end (probably use point cloud library) so that I can fit a plane to them
  • Show the new plane drawn on top of the point cloud in threejs

Before I go too far my questions are

  1. I’ll need raycasting of some sort but I’m not sure how to use it when selecting a group / area of points using the mouse. Has anyone done anything like this before?

  2. Is there a method that allows the user to segment out a section of a point cloud so that these points can be processed in the back end to fit a plane to them?

  3. Any examples I could use as a good starting block?

Thanks in advance

JT

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.

From the bottom of my snipets folder (click on titles for links to demos):

Point cloud intersection by modeling points as degenerate triangles with MeshBVH, using three-mesh-bvh plugin

Lasso 3d selection based on three-mesh-bvh plugin and discussion

Official Box selection from threejs repo

Points rectangle box selection GPGPU by @ towrabbit

Hope it helps!

1 Like

Many thanks for the answer. So just to clarify it is possible to get the screen position relative to the camera view of a point in the point cloud? Is that correct? Do you know what that parameter name is inside the buffer geometry object?

@Antonio Thanks for the links. I had come across some of these but not all. I’ll take a look and hopefully between these two answers there is a solution I can work with

1 Like

I’m not sure I understand the question. It is possible to find the position of a 3D point on the 2D screen (taking care of possible rotations, scaling, translation etc.) I.e., when a 3D point is projected onto the screen, you can get these 2D coordinates.

The screen coordinates do not exist as data in the buffer geometry. However, they can be calculated from the data in the buffer geometry by using project method.