pnext / three-loader

Point cloud loader for ThreeJS, based on the core parts of Potree
Other
206 stars 89 forks source link

Picking should use pick-window-rectangle. #165

Open fredrik-hjelmaeus opened 3 weeks ago

fredrik-hjelmaeus commented 3 weeks ago

When using static pick method in Potree, picking window is not used. Only when directly hovering within a points rendered area is it picked. The provided screenshots displays when the mouse is within and a sphere is created on pickPoint hit position. pick_hit pick_miss

I have setup a forked repo based on your example scene here: https://github.com/fredrik-hjelmaeus/pnext-three-loader-pickwindow-issue usage: When pointcloud is loaded, sphere will be displayed on any pick point hits.

When pick window works as intended, we would expect all points within specified picking rectangle window to be considered hits. And after this, the closest of those hits would be the one returned as PickPoint.

andrewjafa commented 3 days ago

Hi Fredrik,

I also ran into this recently and found a hacky workaround in case it helps (this is definitely not the solution) I force the point size to be the same as the desired pick window size during the picking

const pickParams = {
                pickWindowSize: 1,
                onBeforePickRender: (material: PointCloudMaterial) => { material.size = 9 }
            }
const pickPoint = Potree.pick(viewer.pointClouds,viewer.renderer,viewer.camera, ray, pickParams);

Additionally I've run into strange issues when using arrays of pointclouds during picking, where the closest point is not picked or no pick is returned at all. The workaround there was to iterate through the pointclouds one by one, noting the hit distances, then choosing the closest. Its marginally slower but at least gives accurate results.

Andrew