簡體   English   中英

如何使用javascript引用銫多邊形層次結構中其他實體的位置?

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

我正在使用 Cesium 來可視化我的場景,並且我想使用其他移動實體的位置作為其端點的參考在JavaScript 中創建一個多邊形。 正如使用CZML這個問題的答案中所建議的那樣

我想知道我是否可以在JavaScript 中做到(將其他實體的位置作為多邊形的端點)。 我嘗試了幾件事,但沒有奏效,例如,以下是我的代碼:

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 時間作為參數並返回當時的值。 要獲得職位,您應該能夠執行以下操作

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

在 JavaScript 中對我new Cesium.PositionPropertyArray([])new Cesium.PositionPropertyArray([])定義positions屬性。

Scott_Hunter 在 Cesium 社區論壇上的這篇文章對我有幫助,特別是 Sandcastle 的第二個鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM