Off the top of my head, i guess there are two ways of making it happen pre-pick ray.
One is the mesh predicate - this function takes a mesh and returns a boolean. If it is executed with the camera in its context you could find a good way for you to decide if this mesh should be included in the (standard) picking. This way you could also make sure that the user will be able to pick “through” objects instead of picking them and “deselecting” them if they are culled.
The second is the trianglePredicate that can be passed to scene.pick (or any other picking function). There are a few catches - first there is no “default” triangle picking function in the standard pick loop, so if you want to be able to use it you should avoid the standard pick (that is executed on each frame) and implement your own picking function. The second catch is that it won’t save you any CPU time - it will go over all triangles anyhow. Not sure this would be the best way to go.
Just putting up a blocker, was my thought as well. Especially if there is just one example. Looking at complicated code a couple of months later can be a nightmare.
I was looking into implementing the trianglePredicate option to fix an issue where if the camera is inside of a front-face mesh, you don’t see the mesh but it still captures all picks.
However, looking at the signature for TrianglePickingPredicate, I don’t think it’s possible:
Wouldn’t I need the normal (or at least the face index and a reference to the mesh so I can look up the normal) to determine if the ray is hitting the front or back of the triangle?