how can i define a polygon entity using availability intervals in cesium?

You can use a CallbackProperty (that is a type of Property) in the hierarchy constructor option. 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.

Try to add the next code fragment in the 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
  })
});

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top