Limiting scene.pickPosition to return only positions on a point cloud?

1. A concise explanation of the problem you’re experiencing.

The user needs to be able to click on individual points in a point cloud. I’m trying to use scene.pickPosition(), but sometimes (when the point cloud isn’t very dense) the position picked is on the globe behind it. This happens even after scene.drillPick() returns the point cloud primitive for the same mouse position.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

// in ScreenSpaceEventHandler.setInputAction for LEFT_DOWN
var pointCloud = viewer.scene.drillPick(movement.endPosition, 1)[0];
console.log(pointCloud.primitive instanceof Cesium.Cesium3DTileset); // true
var cursorPosition = viewer.scene.pickPosition(movement.endPosition);
console.log(cursorPosition); // returns a position on the globe, not one of the points in the pointcloud

``

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

The user needs to be able to click on individual points in a point cloud, similar to Potree: http://potree.org/potree/examples/measurements.html

4. The Cesium version you’re using, your operating system and browser.

cesium@1.61.0, Mac Mojave, Chrome latest

Hey Jonathan,

There’s an open feature request to make it easier to snap to point cloud points, but I was also able to reproduce the issue you’re seeing here, where scene.pick gets the point cloud, but pickPosition gets a point far on the horizon. I’ve put my debugging notes here:

https://github.com/AnalyticalGraphicsInc/cesium/issues/7953#issuecomment-562217824

I’ll update this thread if I know of a workaround, but feel free to track that issue as well.

Thank you Omar, I’ll be happy to see if there’s a workaround.
Jonathan

Are you using attenuation when visualizing your point cloud? I think the inconsistency is coming from the fact that scene.pick renders a 3x3 window around the mouse, and checks to see if a point was hit in that location, whereas the scene.pickPosition will only check the pixel under the mouse. Changing scene.pick(mousePosition) to scene.pick(mousePosition, 1, 1) seems to make the results between pick and pickPosition consistent. Do you see the same result when you try that in your app?