Marking an entity as not pickable?

Hi guys,

I have a scene made from a very large flat rectangle and a bunch of small extruded ellipses.

At most angles, everything is fine and the ellipses extrude overtop of the rectangle. At some angles however, the rectangle goes overtop of the ellipses and they are no longer pickable by clicking.

The Visualizing Spacial Data tutorial hints that it’s possible to disable selection of an entity:

“Unless we specifically disable it, clicking on an entity in the Viewer will show the SelectionIndicator widget at the Entity’s location…”

I’ve poured over all the docs and can’t find any mention of how this behavior can be disabled for a particular entity. Am I missing something?

Thanks,

–Mike

Hello Mike,

That comment from the tutorial means to say the SelectionIndicator will show unless you disable the SelectionIndicator. Right now, there isn’t currently a way to disable picking for entities.

We have an issue open here: https://github.com/AnalyticalGraphicsInc/cesium/issues/1592

It’s a very frequently requested feature, so hopefully someone will get a chance to work on it soon.

Best,

Hannah

Hi Hannah,

Thanks that was actually really helpful.

I’ve now got a version of Viewer.pickEntity that behaves the way I want (won’t return things if Entity.pickable is set to false) and it works… but I have to hack the Cesium code, which is not ideal.

I have tried several different ways to override Viewer.pickEntity from outside cesium but to no avail:

// Doesn’t work #1

var viewer = Cesium.Viewer(…);

viewer.pickEntity = function(viewer,e) {…};

// Doesn’t work #2

var viewer = Cesium.Viewer(…);

function override_pickEntity(viewer, options) {

alert(‘mixin called!’);

viewer.pickEntity = function(viewer, e) {…};

}

viewer.extend(override_pickEntity, {});

// Doesn’t work #3

var orig_Mybasefunction = Cesium.Viewer;

Cesium.Viewer = function(container, options) {

orig_Mybasefunction(container, options);

this.pickEntity = function(viewer, e) { … }

}

var viewer = Cesium.Viewer(…);

Attempts #1 and #2 seem to do nothing, my pickEntity function is never called. Attempt #3 produces a run-time error.

I don’t know JavaScript well enough to understand how you guys are building up your objects, what is the correct way to override this function on my Cesium.Viewer instance?

Thanks,

–Mike

Hi Mike,

pickEnttiy is a private function within Viewer, so you can’t override it outside of Cesium. You will have to download the code, make the change and combine the changes in to a new Cesium.js file.

Take a look at our build guide: https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/BuildGuide

That will give you instructions for getting the code base and running our build scripts. You can use the ‘minify’ command to get a minified Cesium.js file.

Best,

Hannah