如何使用javascript引用铯多边形层次结构中其他实体的位置? [英] How to reference positions of other entities in polygon hierarchy of Cesium using javascript?

查看:66
本文介绍了如何使用javascript引用铯多边形层次结构中其他实体的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Cesium 来可视化我的场景,我想在 JavaScript 中创建一个多边形,使用其他移动实体的位置作为其端点的参考.正如这个问题的回答中所建议的,使用CZML.

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.

我想知道我是否可以在 JavaScript 中做到(将其他实体的位置引用为多边形的端点).我尝试了几件事,但没有奏效,例如,以下是我的代码:

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
})

对于参考我也试过:

  • 仅使用实体和位置,例如:entity.position
  • 使用entity$position.

他们都没有工作!

推荐答案

实体属性有一个 getValue 函数,它以 JulianDate 时间作为参数并返回当时的值.要获得职位,您应该能够执行类似

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);

这篇关于如何使用javascript引用铯多边形层次结构中其他实体的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆