PolygonGeometry

new Cesium.PolygonGeometry(options)

A description of a polygon on the ellipsoid. The polygon is defined by a polygon hierarchy. Polygon geometry can be rendered with both Primitive and GroundPrimitive.
Name Type Description
options object Object with the following properties:
Name Type Default Description
polygonHierarchy PolygonHierarchy A polygon hierarchy that can include holes.
height number 0.0 optional The distance in meters between the polygon and the ellipsoid surface.
extrudedHeight number optional The distance in meters between the polygon's extruded face and the ellipsoid surface.
vertexFormat VertexFormat VertexFormat.DEFAULT optional The vertex attributes to be computed.
stRotation number 0.0 optional The rotation of the texture coordinates, in radians. A positive rotation is counter-clockwise.
ellipsoid Ellipsoid Ellipsoid.default optional The ellipsoid to be used as a reference.
granularity number CesiumMath.RADIANS_PER_DEGREE optional The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
perPositionHeight boolean false optional Use the height of options.positions for each position instead of using options.height to determine the height.
closeTop boolean true optional When false, leaves off the top of an extruded polygon open.
closeBottom boolean true optional When false, leaves off the bottom of an extruded polygon open.
arcType ArcType ArcType.GEODESIC optional The type of line the polygon edges must follow. Valid options are ArcType.GEODESIC and ArcType.RHUMB.
textureCoordinates PolygonHierarchy optional Texture coordinates as a PolygonHierarchy of Cartesian2 points. Has no effect for ground primitives.
Example:
// 1. create a polygon from points
const polygon = new Cesium.PolygonGeometry({
  polygonHierarchy : new Cesium.PolygonHierarchy(
    Cesium.Cartesian3.fromDegreesArray([
      -72.0, 40.0,
      -70.0, 35.0,
      -75.0, 30.0,
      -70.0, 30.0,
      -68.0, 40.0
    ])
  )
});
const geometry = Cesium.PolygonGeometry.createGeometry(polygon);

// 2. create a nested polygon with holes
const polygonWithHole = new Cesium.PolygonGeometry({
  polygonHierarchy : new Cesium.PolygonHierarchy(
    Cesium.Cartesian3.fromDegreesArray([
      -109.0, 30.0,
      -95.0, 30.0,
      -95.0, 40.0,
      -109.0, 40.0
    ]),
    [new Cesium.PolygonHierarchy(
      Cesium.Cartesian3.fromDegreesArray([
        -107.0, 31.0,
        -107.0, 39.0,
        -97.0, 39.0,
        -97.0, 31.0
      ]),
      [new Cesium.PolygonHierarchy(
        Cesium.Cartesian3.fromDegreesArray([
          -105.0, 33.0,
          -99.0, 33.0,
          -99.0, 37.0,
          -105.0, 37.0
        ]),
        [new Cesium.PolygonHierarchy(
          Cesium.Cartesian3.fromDegreesArray([
            -103.0, 34.0,
            -101.0, 34.0,
            -101.0, 36.0,
            -103.0, 36.0
          ])
        )]
      )]
    )]
  )
});
const geometry = Cesium.PolygonGeometry.createGeometry(polygonWithHole);

// 3. create extruded polygon
const extrudedPolygon = new Cesium.PolygonGeometry({
  polygonHierarchy : new Cesium.PolygonHierarchy(
    Cesium.Cartesian3.fromDegreesArray([
      -72.0, 40.0,
      -70.0, 35.0,
      -75.0, 30.0,
      -70.0, 30.0,
      -68.0, 40.0
    ])
  ),
  extrudedHeight: 300000
});
const geometry = Cesium.PolygonGeometry.createGeometry(extrudedPolygon);
Demo:
See:
  • PolygonGeometry#createGeometry
  • PolygonGeometry#fromPositions

Members

The number of elements used to pack the object into an array.

Methods

static Cesium.PolygonGeometry.computeRectangleFromPositions(positions, ellipsoid, arcType, result)Rectangle

Computes a rectangle which encloses the polygon defined by the list of positions, including cases over the international date line and the poles.
Name Type Default Description
positions Array.<Cartesian3> A linear ring defining the outer boundary of the polygon.
ellipsoid Ellipsoid Ellipsoid.default optional The ellipsoid to be used as a reference.
arcType ArcType ArcType.GEODESIC optional The type of line the polygon edges must follow. Valid options are ArcType.GEODESIC and ArcType.RHUMB.
result Rectangle optional An object in which to store the result.
Returns:
The result rectangle

static Cesium.PolygonGeometry.createGeometry(polygonGeometry)Geometry|undefined

Computes the geometric representation of a polygon, including its vertices, indices, and a bounding sphere.
Name Type Description
polygonGeometry PolygonGeometry A description of the polygon.
Returns:
The computed vertices and indices.

static Cesium.PolygonGeometry.fromPositions(options)PolygonGeometry

A description of a polygon from an array of positions. Polygon geometry can be rendered with both Primitive and GroundPrimitive.
Name Type Description
options object Object with the following properties:
Name Type Default Description
positions Array.<Cartesian3> An array of positions that defined the corner points of the polygon.
height number 0.0 optional The height of the polygon.
extrudedHeight number optional The height of the polygon extrusion.
vertexFormat VertexFormat VertexFormat.DEFAULT optional The vertex attributes to be computed.
stRotation number 0.0 optional The rotation of the texture coordinates, in radians. A positive rotation is counter-clockwise.
ellipsoid Ellipsoid Ellipsoid.default optional The ellipsoid to be used as a reference.
granularity number CesiumMath.RADIANS_PER_DEGREE optional The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
perPositionHeight boolean false optional Use the height of options.positions for each position instead of using options.height to determine the height.
closeTop boolean true optional When false, leaves off the top of an extruded polygon open.
closeBottom boolean true optional When false, leaves off the bottom of an extruded polygon open.
arcType ArcType ArcType.GEODESIC optional The type of line the polygon edges must follow. Valid options are ArcType.GEODESIC and ArcType.RHUMB.
textureCoordinates PolygonHierarchy optional Texture coordinates as a PolygonHierarchy of Cartesian2 points. Has no effect for ground primitives.
Returns:
Example:
// create a polygon from points
const polygon = Cesium.PolygonGeometry.fromPositions({
  positions : Cesium.Cartesian3.fromDegreesArray([
    -72.0, 40.0,
    -70.0, 35.0,
    -75.0, 30.0,
    -70.0, 30.0,
    -68.0, 40.0
  ])
});
const geometry = Cesium.PolygonGeometry.createGeometry(polygon);
See:
  • PolygonGeometry#createGeometry

static Cesium.PolygonGeometry.pack(value, array, startingIndex)Array.<number>

Stores the provided instance into the provided array.
Name Type Default Description
value PolygonGeometry The value to pack.
array Array.<number> The array to pack into.
startingIndex number 0 optional The index into the array at which to start packing the elements.
Returns:
The array that was packed into

static Cesium.PolygonGeometry.unpack(array, startingIndex, result)

Retrieves an instance from a packed array.
Name Type Default Description
array Array.<number> The packed array.
startingIndex number 0 optional The starting index of the element to be unpacked.
result PolygonGeometry optional The object into which to store the result.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.