title: How to reference positions of other entities in polygon hierarchy of Cesium using javascript?
body: <p>I am using Cesium to visualize my scenario and I want to create a polygon in <em>JavaScript</em> using position of other moving entities as references for its endpoints. As suggested in the answer of <a href="https://groups.google.com/forum/#!topic/cesium-dev/SK8wN7t2MGs" rel="nofollow">this question</a> by using <em>CZML</em>. </p>
  
  <p>I was wondering if I can do it (referencing positions of other entities as endpoints of my polygon) in <em>JavaScript</em>. I tried a few things and it didn't work, for example, following is my code:</p>
  
  <pre><code>var newPoly= viewer.entities.add({                                            
      id : resourceSet[objIndex].id+"poly",
      name:resourceSet[objIndex].id+"poly",
      availability : new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
          start : start,
          stop : stop
      })]),
      polygon:{
          hierarchy :{
              positions:{
                  references:[
                       Cesium.ReferenceProperty.fromString(collection, ''+entityName+'#position'),
                       Cesium.ReferenceProperty.fromString(collection, ''+baseEntity[0].id+'#position'),
                       Cesium.ReferenceProperty.fromString(collection, ''+baseEntity[1].id+'#position')
                  ]
              }
          },
          material :Cesium.Color.AQUA.withAlpha(0.5),
          perPositionHeight : true,
          show : true
      },
      show: true
  })
  </code></pre>
  
  <p>For references I also tried :</p>
  
  <ul>
  <li>just using entity and positions like: <code>entity.position</code></li>
  <li>Using <code>entity$position</code>.</li>
  </ul>
  
  <p>None of them worked!</p>