Randomness in Click Event

Using latest version of Cesium 1.119
With no options for viewer object.
In below code, I’m drawing around 2000 entities. Just polygon boxes.
And trying to add Click event on it just to highlight it.
But when i do that, it just selects random entities. But it does happen in pattern, e.g. like same 4- entities will be selected if I continue clicking at one point.

viewer = new Cesium.Viewer('cesiumContainer');
.
.
.
.
$.each(AllBuildingDetails, function (index, EachBuilding) {
				if(typeof EachBuilding != "undefined")
				{
					ent = viewer.entities.add({
						id: "bldg-"+EachBuilding.id,
						polygon : {
							hierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(eval("["+EachBuilding.LatLonCoordinatesString+"]"))),
							material : Cesium.Color.fromCssColorString("#ff0000").withAlpha(0.5),
							classificationType : Cesium.ClassificationType.BOTH
						}
					});
				}
			});

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
		handler.setInputAction(function(click) {
			var pickedObject = viewer.scene.pick(click.position);
			console.log("pickedObject");
			console.log(pickedObject);
			console.log(pickedObject.id._id);
			if(lastSelectedId != null)
				viewer.entities.getById(lastSelectedId).polygon.material = Cesium.Color.RED.withAlpha(0.5);
			
			viewer.entities.getById(pickedObject.id._id).polygon.material = Cesium.Color.RED.withAlpha(1);
			lastSelectedId = pickedObject.id._id;
			
		}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

Here is what is happening
image

他目前确实有这个问题,我也在做和你相同的事情,目前我只能通过getPickRay提高精度也是不能100%解决问题。期待后续能解决这个问题。

Hi @yhexin0921 ,
Thanks for your post and welcome to the Cesium community.
Apologies @swapnil.k00 that you seem not to have gotten a response to the original post in this thread, but hopefully this conversation will help you too if you are still working on the issue.

I am not totally able to tell what is happening from the attached screenshot. Is the picking error happening in the same way at all zoom levels?

One possibility is that multiple objects overlap and Scene.pick docs link is returning the top one. From the docs:

Returns an object with a primitive property that contains the first (top) primitive in the scene at a particular window coordinate or undefined if nothing is at the location.

Please let me know if that is not helpful, some additional details would also be useful.
Thank you,
Luke