How to cast a ray and detect intersection with a pointcloud using Cesium

I'm currently working on a Cesium project that is supposed to cast a ray and find the point where it intersects with a Pointcloud (Cesium3DTileSet).

So far I have not been able to find a method that does this. I did manage to implement scene.pickFromRay and drillPickFromRay as so:

//CameraPosition and CameraDirection: [x, y, z]
const { cameraPosition, cameraDirection } = cameraToWorldPoint(rotationQuaternion, translation, geoTransformationMatrix)

const ray = new Cesium.Ray(new Cesium.Cartesian3(cameraPosition[0], cameraPosition[1], cameraPosition[2]), new Cesium.Cartesian3(cameraDirection[0], cameraDirection[1], cameraDirection[2]));
const intersections = viewer.scene.drillPickFromRay(ray, undefined, undefined, 5);
//Always returns an array of one object (Cesium3dTileSet)

return { x: intersections[0].position.x, y: intersections[0].position.y, z: intersections[0].position.z }

But the intersections from pickFromRay and drillPickFromRay seem to be happening with the whole CesiumTileSet object, and not the actual points in the pointcloud, which means that it doesn't return the position that I actually need.

Would someone know of different method or way of achieving this?

As I’m sure you’ve noticed, pickFromRay and drillPickFromRay are actually private functions since it’s still under development. You only get one point because the ray intersection will hide any primitive it hits to avoid repeatedly picking the same object. Although it should be giving you the point of intersection. There is a development Sandcastle example for it here:

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/Sandcastle/gallery/development/Pick%20From%20Ray.html

If you’re doing an application that needs visibility analysis/line of sight, the commercial ion SDK does have tools that help a lot with this:

https://cesium.com/ion-sdk/

If you’re interested in trying it out reach out to Tim (tim@cesium.com)