[英]How to reference positions of other entities in polygon hierarchy of Cesium using javascript?
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.我正在使用 Cesium 来可视化我的场景,并且我想使用其他移动实体的位置作为其端点的参考在JavaScript 中创建一个多边形。 As suggested in the answer of this question by using CZML .
正如使用CZML在 这个问题的答案中所建议的那样。
I was wondering if I can do it (referencing positions of other entities as endpoints of my polygon) in JavaScript .我想知道我是否可以在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 :对于参考我也试过:
entity.position
entity.position
entity$position
.entity$position
。 None of them worked!他们都没有工作!
Entity properties have a function getValue that takes a JulianDate time as a parameter and returns the value at that time.实体属性有一个函数 getValue,它将 JulianDate 时间作为参数并返回当时的值。 To get a position, you should be able to do something like
要获得职位,您应该能够执行以下操作
var position = entity.position.getValue(viewer.clock.currentTime);
What worked for me in JavaScript was to define the positions
property with new Cesium.PositionPropertyArray([])
.在 JavaScript 中对我
new Cesium.PositionPropertyArray([])
用new Cesium.PositionPropertyArray([])
定义positions
属性。
This post on Cesium's Community Forum by Scott_Hunter helped me, specifically the second link to Sandcastle. Scott_Hunter 在 Cesium 社区论坛上的这篇文章对我有帮助,特别是 Sandcastle 的第二个链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.