vtk.js cellPicking seems to ignore clipping planes on mapper

It seems that the vtkCellPicker is ignoring the clipping planes on the mapper. Is there a way to circumvent this?

In a small test example with 1 cell it seemed that the clipping plane was not ignored, but in the full example I can’t seem to get it to work properly.

Is this the correct behaviour?

Full Model:

Model with clipping plane picked from the top:

Model with clipping plane picked from the side:

AFAIK vtkCellPicker should be taking the mapper’s clipping planes into account. If you have a small reproduction example (e.g. on codesandbox or some other platform) that shows a bug, that will help us track it down.

What you can do is place a breakpoint in the clipLineWithPlane function and see if it behaves correctly.

thanks for the replies. I tried debugging it a bit.

in the method:
'publicAPI.intersectWithLine = function (p1, p2, tol, mapper) ’

I think that clipLineWithPlane is finding the clipplane, but then tMin is smaller later after at the intersectActorWithLine.
line 195 (tMin < model.globalTMin) = True so it skips to return tMin (line 219);

tMin is set from a vtkMapper on line 192 in CellPicker.js

I’m not super familiar with the clipping logic, so no idea if this is correct behaviour.

I can try to make a small example this weekend on codepen. I’m pretty busy with work this week.

Interestingly that code is also making use of getClippingPlaneInDataCoords(), there is actually another issue with clipping planes here.

It would be interesting to see if you have the bug in VTK.js v22 (prior to the changes with clipping plane in data coords)

I’ll change the package version this weekend and see if it still has the same results. Is there a specific version in v22 or just the latest?

v22.0.0

For information, the other issue was due to a too old version of VTK.js

It seems that v22.0.0 doesn’t work for other parts (for instance vtkCellArray seems like it was changed).
Will be pretty hard to test that.

I think the problem is that t1 and t2 are not updated.
So once you go to intersectActorWithLine (line 200 in CellPicker) It’s still checking the range 0-1 instead of cliping.t1 - clipline.t2 .
intersectActorWithLine (line 247 in CellPicker) doesn’t seem to ever update t1 and t2 that it receives as arguments.

And then it just return the closest cell (the top of the building) because it checked the full range.

It seems that you are getting close to a fix.
Maybe you can check with the C++ implementation of it and see where it differs.

https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/Core/vtkCellPicker.cxx

Feel free to create a PR once you nailed it.

Hth,
Julien.