inconsistent .drillPick results (on RIGHT_CLICK)

I am getting inconsistent results with picking in Cesium 1.17. Below is a sandcastle snippet that will reproduce the problem. RIGHT_CLICK on the shapes only seems to highlight them about 50% of the time. The LEFT_CLICK event does not seem to have this problem.

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

selectionIndicator : false,

infoBox : false

});

var scene = viewer.scene;

var handler;

Sandcastle.addToolbarButton(‘Drill-Down Picking’, function() {

var pickedEntities = new Cesium.EntityCollection();

var pickColor = Cesium.Color.YELLOW.withAlpha(0.5);

function makeProperty(entity, color) {

var colorProperty = new Cesium.CallbackProperty(function(time, result) {

if (pickedEntities.contains(entity)) {

return pickColor.clone(result);

}

return color.clone(result);

}, false);

entity.polygon.material = new Cesium.ColorMaterialProperty(colorProperty);

}

var red = viewer.entities.add({

polygon : {

hierarchy : Cesium.Cartesian3.fromDegreesArray([-70.0, 30.0,

-60.0, 30.0,

-60.0, 40.0,

-70.0, 40.0])

}

});

makeProperty(red, Cesium.Color.RED.withAlpha(0.5));

var blue = viewer.entities.add({

polygon : {

hierarchy : Cesium.Cartesian3.fromDegreesArray([-75.0, 34.0,

-63.0, 34.0,

-63.0, 40.0,

-75.0, 40.0])

}

});

makeProperty(blue, Cesium.Color.BLUE.withAlpha(0.5));

var green = viewer.entities.add({

polygon : {

hierarchy : Cesium.Cartesian3.fromDegreesArray([-67.0, 36.0,

-55.0, 36.0,

-55.0, 30.0,

-67.0, 30.0])

}

});

makeProperty(green, Cesium.Color.GREEN.withAlpha(0.5));

// Move the primitive that the mouse is over to the top.

handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

handler.setInputAction(function(movement) {

    // get an array of all primitives at the mouse position

var pickedObjects = scene.drillPick(movement.position);

if (Cesium.defined(pickedObjects)) {

//Update the collection of picked entities.

pickedEntities.removeAll();

for (var i = 0; i < pickedObjects.length; ++i) {

var entity = pickedObjects[i].id;

pickedEntities.add(entity);

}

}

}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);

});

``

Also, this problem doesn’t happen in Cesium 1.16.

Hello,

Thank you for reporting this and including an example!

This was fixed here: https://github.com/AnalyticalGraphicsInc/cesium/pull/3391

The fix will be included in Cesium 1.18

Best,

Hannah