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
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?
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?
Any examples I could use as a good starting block?
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.
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.
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
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.