How to reference positions of other entities in polygon hierarchy of Cesium using javascript?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 00:23:08

问题


I am using Cesium to visualize my scenario and I want to create a polygon in JavaScript using position of other moving entities as references for its endpoints. As suggested in the answer of this question by using CZML.

I was wondering if I can do it (referencing positions of other entities as endpoints of my polygon) in JavaScript. I tried a few things and it didn't work, for example, following is my 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
})

For references I also tried :

  • just using entity and positions like: entity.position
  • Using entity$position.

None of them worked!


回答1:


Entity properties have a function getValue that takes a JulianDate time as a parameter and returns the value at that time. To get a position, you should be able to do something like

var position = entity.position.getValue(viewer.clock.currentTime);


来源:https://stackoverflow.com/questions/36586570/how-to-reference-positions-of-other-entities-in-polygon-hierarchy-of-cesium-usin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!