Entity API is very convenient and powerful but sometimes primitives give more options and flexibility.
For example, we can control animations for primitive models through a ModelAnimationCollection, we can position a label primitive more precisely through label position property.
Before Cesium version 1.26 I used such routine to get to a label primitive associated with an entity.
Two stages - 1) finding a LabelCollection in a Scene PrimitivesCollection. and then 2) finding a right label by a reference to an entity
function getLabelForEntity(entity) {
var primitives = viewer.scene.primitives;
var primitive;
for (var i = 0; i < primitives.length; i++) {
primitive = primitives.get(i);
if (primitive instanceof Cesium.LabelCollection) {
var labelCollection = primitive;
if (!labelCollection) return undefined;
var label;
for (var j = 0; j < labelCollection.length; j++) {
label = labelCollection.get(j);
if (label instanceof Cesium.Label && label.id === entity) {
return label;
}
}
}
}
return undefined;
};
Something similar was recommended in this forum for models
function getModelForEntity(entity) {
var primitives = viewer.scene.primitives;
var primitive;
for (var i = 0; i < primitives.length; i++) {
primitive = primitives.get(i);
if (primitive instanceof Cesium.Model && primitive.id === entity) {
return primitive;
}
}
};
This approach (at least for Labels and Billboards) doesn’t work after introduction of EntityCluster in v.1.26
I can adopt my routines, but before doing that I’d like to ask if I’m doing a wrong thing and is there an other way to get to the needed primitive in an entity?
Thank you,
Vladimir.