简体   繁体   English

如何使用 Cesium 中的可用性间隔定义多边形实体?

[英]How can I define a polygon entity using availability intervals in Cesium?

I am defining a realy huge polygon that changes its position and shape using inertial reference frame.我正在定义一个非常大的多边形,它使用惯性参考系改变其位置和形状。

First, I tryed to define a set of CZML polygons, each one with an availability and its coordinates like the "california" object in this sandcastle example , but this exceeds the maximum memory limit and blocks the browser and eventually the computer.首先,我尝试定义一组 CZML 多边形,每个多边形都有可用性及其坐标,就像这个沙堡示例中的“加利福尼亚”对象,但这超出了最大内存限制并阻止了浏览器,最终阻止了计算机。 Then, I had it working using only one polygon in CZML providing a list with an interval and the polygon shape coordinates, like the "dynamicPolygon" in the same sandcastle example .然后,我让它在 CZML 中只使用一个多边形工作,提供一个带有间隔和多边形形状坐标的列表,就像同一个沙堡示例中的“dynamicPolygon”。

Now I am trying to change the CZML implementation to use entities but the entity documentation allows to use a PolygonGraphics that allows to use a Property or a PolygonHierarchy to configure the shape, and I can not figure out how to do the same "dynamicPolygon" using entities.现在我正在尝试更改 CZML 实现以使用实体,但实体文档允许使用PolygonGraphics ,该PolygonGraphics允许使用PropertyPolygonHierarchy来配置形状,我无法弄清楚如何使用相同的“dynamicPolygon”实体。

You can use a CallbackProperty (that is a type of Property ) in the hierarchy constructor option.您可以在层次结构构造函数选项中使用CallbackProperty (即Property类型)。 There should not be issues with memory due to there is only one object and the positions are being calculated dynamically.由于只有一个对象并且位置是动态计算的,因此应该不会出现内存问题。 You also can use a collection like TimeIntervalCollectionProperty and then ask for the value for an specific time.您还可以使用TimeIntervalCollectionProperty类的集合,然后询问特定时间的值。

Try to add the next code fragment in the Hello World Cesium sandcastle :尝试在Hello World Cesium sandcastle 中添加下一个代码片段:

viewer.entities.add({
    id: "dynamicPolygon",
    name: "dynamicPolygon",
    polygon: new Cesium.PolygonGraphics({
      hierarchy: new Cesium.CallbackProperty(function (time, result) {
        var n = time.secondsOfDay%10;
        result = new Cesium.PolygonHierarchy([
            Cesium.Cartesian3.fromDegrees(2*n, n),
            Cesium.Cartesian3.fromDegrees(-2*n, n),
            Cesium.Cartesian3.fromDegrees(-2*n, -n),
            Cesium.Cartesian3.fromDegrees(2*n, -n)
        ]);
        return result;
      }, false),
      material: Cesium.Color.WHITE
  })
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM