Multiple polylines (or other primitives) in one entity

Good time of a day for everybody.

I’d like to group more primitives under an Entity “umbrella” than it is allowed now by a list of Entity properties.
For example, if I wish to have two crossing lines “managed” an entity I expect the following code to work (code is ready for Sandcastle)

var viewer = new Cesium.Viewer(‘cesiumContainer’);
var position = Cesium.Cartesian3.fromDegrees(0,0,0);

var entity = viewer.entities.add({
position : position,
point : {
pixelSize : 10
},
polyline : {
positions : Cesium.Cartesian3.fromDegreesArray([
-1, -1,
1, 1]) ,
followSurface : false
}
});
entity.addProperty(‘polyline1’);
entity.polyline1 = new Cesium.PolylineGraphics({
positions : Cesium.Cartesian3.fromDegreesArray([
-1, 1,
1, -1]) ,
followSurface : false
});
viewer.trackedEntity = entity;

Unfortunately only one polyline is visible - the entity native polyline.
The one that was added by custom property doesn’t show.

The question is:
is this an architectural limitation of an Entity layer and each instance on an entity is limited only to one instance of a primitive?
Or may be I miss some code to “activate” added property?

Vladimir

Hello Vladimir,

Yes, the Entity API is only designed to have one primitive per type per entity, so you cannot add another polyline onto the entity the way you are trying to in the code example you posted.

We do have a concept of parent entities however, and you may find it helpful to group entities that way. See this example for toggling the visibility of multiple entities by giving them a parent: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Show%20or%20Hide%20Entities.html&label=Beginner

Best,

Hannah

Hi Hannah, This is a bit of an old thread, but I’m looking for a way to have the ‘children’ move and rotate along with the parent entity. I tried to do this in the sandcastle: https://sandcastle.cesium.com/index.html?src=Show%20or%20Hide%20Entities.html but that doesn’t seem to work. I can see in the (browser) console that the parent’s position has changed, but the children remain static. Is there a way to have the position of the children be relative to that of the parent entity? Thanks, Mark
update: I see now that the link above doesn’t link to my edited version of the sandcastle. I also saw several posts pointing towards using a CallbackProperty, and I’m currently exploring that.