Intersections of camera positions and 3d tileset

Hi,

I’m experiencing some inaccuracies when using the pickFromRay function.

From UAV images I create photogrammetry meshes, export them to 3d tiles and then load those tiles. I also load the aerotriangulated source UAV images in the viewer. Some images have an annotation, that I want to project on the 3d tiled model. In order to do that I use pickFromRay:

function pickFromRay(startPoint, endPoint) {

	var direction = Cesium.Cartesian3.normalize(Cesium.Cartesian3.subtract(endPoint, startPoint, new Cesium.Cartesian3()), new Cesium.Cartesian3());
	var ray = new Cesium.Ray(startPoint, direction);
	var result = viewer.scene.pickFromRay(ray, []);

	return result.position
}

var intersection = pickFromRay(cameraOrigin, pointOnImage);

issues.add({
	position: intersection,
        image: "data:image////",
        alignedAxis: Cesium.Cartesian3.UNIT_Z,
        scale: 1.0,
        color: new Cesium.Color(1, 1, 1, 0.5)
});

I have about 10k of these annotation that I want to project, so when executed, all 10k are processed and projected (through a point/billboard). The precision of the projections/positions vary greatly. Sometimes when I execute the function they are exactly as they are supposed to be (matching the point on the image to the point on the model). Other times they are just off, by a meter or even more. The results vary even when everything else is the same and I just perform a refresh.

I suspect it has something to do with how granular the outline/shapes of the 3d tileset is loaded. If it isn’t loaded all the way perhaps just the general coarse outline is used to perform an intersection test. And perhaps when the tileset is properly loaded all the fine lines are there in order to be able to precisely calculate the intersection.

I can’t seem to replicate when it is precise and when it is not. Sometimes even just running it without zooming in/changing resolution yields perfect results and other times it doesn’t anymore. I have this problem with multiple different tilesets/datasets.

Anyone has an idea?

Welcome to the Cesium Community, Frank!

This thread may help you with the pickFromRay function accuracy. This was a known issue and was fixed in a recent release (v1.72).

Please follow up with any additional questions.

Can you give an example of the aerotriangulated source, and what you were using for the cameraOrigin and pointOnImage?

@dzung fter using 1.73 the pickFromRay functionality is indeed way more accurate and works for me for now. To achieve extra accuracy Omar pointed me to pickFromRayMostDetailed. I tried using that in the same way as pickFromRay, but I can’t seem to get it working. I’ve set up a sandcastle in which I also can’t get it to work: https://tinyurl.com/yyxmlzmk

@Michael_Flannery Both points are cartesian points that do work in the way intended with pickFromRay. The problem is now just with the pickFromRayMostDetailed.