1. A concise explanation of the problem you’re experiencing.
We are creating many entities. Selecting entities is getting slow.
How can we disable some entities so that they are visible but not selectable?
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
NA
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
The user only needs to select some entities. This allows them to see the properties.
4. The Cesium version you’re using, your operating system and browser.
Win 7, Latest Chrome.
I have come across this, in the Primitive
https://cesiumjs.org/Cesium/Build/Documentation/Primitive.html?classFilter=prim#allowPicking
Does this allow us to make certain primitives not selectable?
Is there a similar setting for entities?
I have made a sandcastle, where I have set
allowPicking: true
``
for all primitives.
But I still cannot select primitives.
How can I select those triangular blocks, so that they change colour and the properties are displayed?
Maybe they are selected but just that the colour is not changing when we click on them?
Hi Patrick,
I apologise in advance if I have misunderstood.
In my modified Sandcastle (link below) if you have allowPicking true then the Scene picker is able to pick the primitive when you click over it (drillPick returns an array of items in the scene found at the position). When it is false the primitive isn’t picked.
Sandcastle 2
You can then edit the primitive or add billboards/overlays based upon which primitive in the click handler.
Thanks,
Shane.
Thanks Shane, this is a step in the right direction.
Now I am trying to change the color, but for some reason I cannot access the geometry instances in the primitive that is returned by the pick function.
See sandcastle
If your original goal was to prevent entities from being picked then you might want to ping PR #4410 - no one has noted its status for a few months (but presumably that means still on the backlog),
https://github.com/AnalyticalGraphicsInc/cesium/pull/4410
As for picking the primitives - this sort of process works for me when picking entities, but the scene primitives appear to have been divorced from the geometryInstances.
console.log(“scene primitive 0”, scene.primitives.get(0))
``
If you run that inside the click handler its lost its geometryInstance. And if you retain a pointer to the geometry instance used to create it, mutating that object has no change on the scene.
If I have time I will have a dig - but for now it seems weird
Thanks,
Shane.
If you set releaseGeometryInstances to false when constructing the primitive, the geometryInstances will now be defined.
var primitive = new Cesium.Primitive({
allowPicking: true,
geometryInstances : [blockInstance],
shadows : Cesium.ShadowMode.ENABLED,
appearance : new Cesium.PerInstanceColorAppearance({
translucent : false
}),
releaseGeometryInstances : false
});
``
The default behavior is there to conserve memory.
Thanks,
Gabby
Thanks Shane and Gabby for your help. I have managed to get it to work using materials.
Here is my final version. This allows me to make some primitives unselectable (blue), and other primitives selectable (green). These selectable ones will change red when selected, and back to green when the selection is cleared.
Sandcastle
Great you got it working! Thanks for the updated example.