PointPicker Selecting the Back Object Instead of the Front Object in Complex Scenes

Hello everyone,

I’m currently working on a VTK.js project where I need to select points in a 3D scene using vtkPointPicker. The scene includes complex geometries with multiple overlapping objects on different planes.

The issue I’m facing is that when I click on a point in the view, the vtkPointPicker sometimes selects a point from an object that is further back in the scene, instead of selecting the point on the front object that is directly under the cursor. This is problematic because I need the picker to always select the point on the closest object in the view.

Here’s a summary of what I’m doing:

  1. I’m using vtkPointPicker with a small tolerance value to improve precision.
  2. The objects in my scene are overlapping in the view, and they are in different planes.
  3. I noticed that when two objects overlap, the picker often selects the point from the object that is farther away instead of the one closer to the camera.

Is there a way to ensure that vtkPointPicker selects the point on the frontmost object, or do I need to use a different approach or picker type for this scenario? Any advice or suggestions on how to tackle this problem would be greatly appreciated.

Thank you!

Maybe you have a transform (e.g. UserMatrix) associated to your actors, it seems that vtkPointPicker does not consider those but simply rely on the polydata bounds. You might want to double check that.

1 Like

I am not applying nor associating any transforms to my actor.

Could this have something to do with the bounding box?

it seems that vtkPointPicker does not consider those but simply rely on the polydata bounds

I take that back, while vtkPointPicker does not consider the transform, vtkPicker does hence it should not be a problem.

I think you now have to “debug” the picker code. E.g. check the value of pickedPosition for each actor in Picker/index.js:175.

1 Like

I’ll take a look at that, thank you, Julien.

By the way, do you know if vtkVolumePicker will be implemented in vtk.js anytime soon? I thought it might come in handy for this case.

To my knowledge, there is no plan for a vtkVolumePicker but vtkCellPicker supports vtkVolumeMapper.

Thanks. vtkCellPicker kind of fixes the issue yet I discarded it long ago for this project since the click interaction takes too long to give a response (around 1.5s with vtkCellPicker and 50ms with vtkPointPicker). Also tried applying vtkHardwareSelector to my project but doesn’t to fix the input lag at all.

The C++ implementation of vtkCellPicker has an AddLocator() method where you can add a vtkCellLocator for each complex mesh in the scene. Adding locators can speed up vtkCellPicker by many orders of magnitude. This is not very difficult to implement, if someone wants to add it to vtk.js.

For information, vtkIncrementalOctreePointLocator already exists in VTK.js