Polygon

Polygon

new Polygon

DOC_TBA

Example
var polygon = new Polygon();
polygon.material.uniforms.color = {
  red   : 1.0,
  green : 0.0,
  blue  : 0.0,
  alpha : 1.0
};
polygon.setPositions([
  ellipsoid.cartographicToCartesian(new Cartographic(...)),
  ellipsoid.cartographicToCartesian(new Cartographic(...)),
  ellipsoid.cartographicToCartesian(new Cartographic(...))
]);
Demo:

Members

bufferUsage :BufferUsage

The usage hint for the polygon's vertex buffer.

ellipsoid

DOC_TBA

granularity

DOC_TBA

height

DOC_TBA

material :Material

The surface appearance of the polygon. This can be one of several built-in Material objects or a custom material, scripted with Fabric.

The default material is Material.ColorType.

Example
// 1. Change the color of the default material to yellow
polygon.material.uniforms.color = new Color(1.0, 1.0, 0.0, 1.0);

// 2. Change material to horizontal stripes
polygon.material = Material.fromType(scene.getContext(), Material.StripeType);
See:

morphTime :Number

The current morph transition time between 2D/Columbus View and 3D, with 0.0 being 2D or Columbus View and 1.0 being 3D.

scene2D

DOC_TBA

scene3D

DOC_TBA

show :Boolean

Determines if this polygon will be shown.

Methods

configureExtent

DOC_TBA

Parameters:
Name Type Description
extent. extent The cartographic extent of the tile, with north, south, east and west properties in radians.
[height=0.0]. double The height of the cartographic extent.
Example
polygon.configureExtent(new Extent(
    CesiumMath.toRadians(0.0),
    CesiumMath.toRadians(0.0),
    CesiumMath.toRadians(10.0),
    CesiumMath.toRadians(10.0)
));

configureFromPolygonHierarchy

Create a set of polygons with holes from a nested hierarchy.

Parameters:
Name Type Argument Default Description
hierarchy Object An object defining the vertex positions of each nested polygon. For example, the following polygon has two holes, and one hole has a hole. holes is optional. Leaf nodes only have positions.

{
 positions : [ ... ],    // The polygon's outer boundary
 holes : [               // The polygon's inner holes
   {
     positions : [ ... ]
   },
   {
     positions : [ ... ],
     holes : [           // A polygon within a hole
      {
        positions : [ ... ]
      }
     ]
   }
 ]
}

height Number <optional>
0.0 The height of the polygon.
textureRotationAngle Number <optional>
0.0 The angle to rotate the texture in radians.
Throws:
DeveloperError : At least three positions are required.
Example
// A triangle within a triangle
var hierarchy = {
    positions : [new Cartesian3(-634066.5629045101,-4608738.034138676,4348640.761750969),
                 new Cartesian3(-1321523.0597310204,-5108871.981065817,3570395.2500986718),
                 new Cartesian3(46839.74837473363,-5303481.972379478,3530933.5841716)],
    holes : [{
        positions :[new Cartesian3(-646079.44483647,-4811233.11175887,4123187.2266941597),
                    new Cartesian3(-1024015.4454943262,-5072141.413164587,3716492.6173834214),
                    new Cartesian3(-234678.22583880965,-5189078.820849883,3688809.059214336)]
     }]
 };

destroy

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.

Throws:
DeveloperError : This object was destroyed, i.e., destroy() was called.
Returns:
Example
polygon = polygon && polygon.destroy();
See:

getPositions

DOC_TBA

Throws:
DeveloperError : This object was destroyed, i.e., destroy() was called.
See:

isDestroyed

Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.

Returns:
Boolean true if this object was destroyed; otherwise, false.
See:

setPositions

DOC_TBA

Parameters:
Name Type Argument Default Description
positions Array The cartesian positions of the polygon.
height Number <optional>
0.0 The height of the polygon.
textureRotationAngle Number <optional>
0.0 The angle, in radians, to rotate the texture. Positive angles are counter-clockwise.
Throws:
Example
polygon.setPositions([
  ellipsoid.cartographicToCartesian(new Cartographic(...)),
  ellipsoid.cartographicToCartesian(new Cartographic(...)),
  ellipsoid.cartographicToCartesian(new Cartographic(...))
], 10.0);
See:

update

Commits changes to properties before rendering by updating the object's WebGL resources.

Throws: