# How to get the children Entities by Parent entity in cesium js ?

**URL:** <https://community.cesium.com/t/how-to-get-the-children-entities-by-parent-entity-in-cesium-js/4702>\
**Category:** CesiumJS\
**Created:** [October 14, 2016, 5:22am UTC](https://community.cesium.com/t/how-to-get-the-children-entities-by-parent-entity-in-cesium-js/4702 "2016-10-14T05:22:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_anjeev](https://avatars.discourse-cdn.com/v4/letter/_/ee7513/32.png) [@\_anjeev](https://community.cesium.com/u/_anjeev)\
**Post date:** [October 14, 2016, 5:22am UTC](https://community.cesium.com/t/how-to-get-the-children-entities-by-parent-entity-in-cesium-js/4702/1 "2016-10-14T05:22:27Z")

</div>

is there any method or way to get the children entities by parent entity.

This is sample code:

var boxes = entities.add(new Cesium.Entity());  
var spheres = entities.add(new Cesium.Entity());

for (var i = 0; i \< 5; ++i) {  
&nbsp;&nbsp;&nbsp;&nbsp;var height = 100000.0 + (200000.0 \* i);  
&nbsp;&nbsp;&nbsp;&nbsp;entities.add({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id:"boxes\_" + i.toString(),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent : boxes,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position : Cesium.Cartesian3.fromDegrees(-106.0, 45.0, height),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;box : {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dimensions : new Cesium.Cartesian3(90000.0, 90000.0, 90000.0),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;material : Cesium.Color.fromRandom({alpha : 1.0})  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;});

entities.add({  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id:"spheres\_"+i.toString(),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent : spheres,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position : Cesium.Cartesian3.fromDegrees(-98.0, 45.0, height),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ellipsoid : {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;radii : new Cesium.Cartesian3(67500.0, 67500.0, 67500.0),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;material : Cesium.Color.fromRandom({alpha : 1.0})  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;});  
}

so in above i am putting the boxes and spheres in seperate parent entity, than i loop through upto parent entity children length.

so, how i get the length and the children entity.

right now i am using this weird things i.e is private variables in cesium.

var entityName = spheres.\_children[0].id;  
var sphereLength = spheres.\_children.length;  
viewer.entities.getById(entityName);

so is there any way help me out.

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [October 17, 2016, 1:54pm UTC](https://community.cesium.com/t/how-to-get-the-children-entities-by-parent-entity-in-cesium-js/4702/2 "2016-10-17T13:54:01Z")

</div>

Hello,

Sorry, there doesn’t seem to be a public variable for accessing the entity children. Why do you need to access the child entities?

Best,

Hannah

---

<div class="post-metadata">

**Author:** ![\_anjeev](https://avatars.discourse-cdn.com/v4/letter/_/ee7513/32.png) [@\_anjeev](https://community.cesium.com/u/_anjeev)\
**Post date:** [October 18, 2016, 6:25am UTC](https://community.cesium.com/t/how-to-get-the-children-entities-by-parent-entity-in-cesium-js/4702/3 "2016-10-18T06:25:17Z")

</div>

Thanks for reply Hannah,

i need it becoz i separated the all entities by there respective parents. so, i don't want to loop through all the entities collection and put the new position and orientation to the model entity for animation, its continuous interval of 1 seconds.

As per performance manner this take at least less than a 1 second.

so i want a length and children entity by their parent. so, i able to loop through only the parent length and get entities by parent.
