Closed jadh4v closed 2 years ago
@agirault @floryst Based on @FezVrasta 's suggestion, we could change the mouse picking to return the closes pixel to current mouse position. The case is trivial where there already is an object at the mouse position. Otherwise, we will return the object that has a foreground pixel closest to current mouse position.
@martinken mentioned to me that on VTK/C++ we have a radius that enable the expected behavior. We should implement it on the JS side.
@martinken mentioned to me that on VTK/C++ we have a radius that enable the expected behavior. We should implement it on the JS side.
Do you have a link to where the C++ implementation is?
See https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/Core/vtkHardwareSelector.cxx#L729
Basically it picks from the center, and if nothing is found starts workout out radially until it finds something or hits max distance.
Cool. This is great. But would this mean that the selector would now only return one result? Or would it be better to implement the new logic as a different function generateSelection(xp, yp, maxDistance)
?
Apologies for this going stale for so long. I will allocate some time soon to resurrect this.
@floryst @jourdain Ready for review.
@jourdain waiting for your green flag. Also I don't have write privileges, so someone will have to merge for me.
:tada: This PR is included in version 1.10.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
EDIT (outdated / previous commit):
EDIT (approach has been changed):
Add
View.pickClosest(xp, yp, maxDistance)
function to select / return a single object that is the closest to the mouse pointer position. Search region is restricted based on thepointerSize
property. Earlier, the function simply returned/handled the first object in theselection
array, which was unpredictable. This change affects the 'click' and 'hover' picking modes. The 'select' picking mode (which uses a shift + click-drag a rectangular region) continues to use the previous implementation, which returns all objects within that rectangular region (selection zone) in no particular order.The algorithm for searching the closest object in the pixel buffer (mentioned here) is already present in vtk-js as
vtkOpenGLHardwareSelector.getPixelInformation()
.A corresponding fix was required in vtk-js described here: 2263.