new Polygon(options)
A renderable polygon or hierarchy of polygons.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
Object with the following properties:
|
Throws:
-
DeveloperError : Either options.positions or options.polygonHierarchy can be provided, but not both.
-
DeveloperError : When options.positions is provided, at least three positions are required.
Examples:
// Example 1
var polygon = new Cesium.Polygon({
positions : [
ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)),
ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)),
ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...))
]
});
// Example 2
var polygon = new Cesium.Polygon();
polygon.material.uniforms.color = {
red : 1.0,
green : 0.0,
blue : 0.0,
alpha : 1.0
};
polygon.positions = [ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)),
ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)),
ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...))];
Demo:
Source:
Scene/Polygon.js, line 79
Members
-
asynchronous :Boolean
-
Determines if the geometry instances will be created and batched on a web worker.
-
Default Value:
true
Source: Scene/Polygon.js, line 178 -
debugShowBoundingVolume :Boolean
-
This property is for debugging only; it is not for production use nor is it optimized.
Draws the bounding sphere for each draw command in the primitive.
-
Default Value:
false
Source: Scene/Polygon.js, line 190 -
ellipsoid :Ellipsoid
-
The ellipsoid that the polygon is drawn on.
-
Default Value:
Ellipsoid.WGS84
Source: Scene/Polygon.js, line 89 -
granularity :Number
-
The distance, in radians, between each latitude and longitude in the underlying geometry. A lower granularity fits the curvature of the
Polygon#ellipsoid
better, but uses more triangles.-
Default Value:
CesiumMath.RADIANS_PER_DEGREE
Source: Scene/Polygon.js, line 101 -
height :Number
-
The height, in meters, that the polygon is raised above the
Polygon#ellipsoid
.-
Default Value:
0.0
Source: Scene/Polygon.js, line 111 -
id :Object
-
User-defined object returned when the polygon is picked.
-
Default Value:
undefined
See:
Source: Scene/Polygon.js, line 167 -
material :Material
-
The surface appearance of the primitive. This can be one of several built-in
Material
objects or a custom material, scripted with Fabric.The default material is
Material.ColorType
.-
Default Value:
Material.fromType(Material.ColorType)
Example:
// 1. Change the color of the default material to yellow polygon.material.uniforms.color = new Cesium.Color(1.0, 1.0, 0.0, 1.0); // 2. Change material to horizontal stripes polygon.material = Cesium.Material.fromType( Material.StripeType);
See:
Source: Scene/Polygon.js, line 156 -
positions :Array.<Cartesian3>
-
Gets or sets positions that define the boundary of the polygon.
Example:
polygon.positions = [ ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)), ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)), ellipsoid.cartographicToCartesian(new Cesium.Cartographic(...)) ];
Source: Scene/Polygon.js, line 222 -
show :Boolean
-
Determines if this primitive will be shown.
-
Default Value:
true
Source: Scene/Polygon.js, line 131 -
textureRotationAngle :Number
-
The angle, in radians, relative to north that the polygon's texture is rotated. Positive angles rotate counter-clockwise.
-
Default Value:
0.0
Source: Scene/Polygon.js, line 122
Methods
-
configureFromPolygonHierarchy(hierarchy)
-
Create a set of polygons with holes from a nested hierarchy.
Name Type 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 havepositions
.{ positions : [ ... ], // The polygon's outer boundary holes : [ // The polygon's inner holes { positions : [ ... ] }, { positions : [ ... ], holes : [ // A polygon within a hole { positions : [ ... ] } ] } ] }
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
// A triangle within a triangle var hierarchy = { positions : [ new Cesium.Cartesian3(-634066.5629045101, -4608738.034138676, 4348640.761750969), new Cesium.Cartesian3(-1321523.0597310204, -5108871.981065817, 3570395.2500986718), new Cesium.Cartesian3(46839.74837473363, -5303481.972379478, 3530933.5841716) ], holes : [{ positions :[ new Cesium.Cartesian3(-646079.44483647, -4811233.11175887, 4123187.2266941597), new Cesium.Cartesian3(-1024015.4454943262, -5072141.413164587, 3716492.6173834214), new Cesium.Cartesian3(-234678.22583880965, -5189078.820849883, 3688809.059214336) ] }] };
Source: Scene/Polygon.js, line 288 -
-
destroy() → undefined
-
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 thanisDestroyed
will result in aDeveloperError
exception. Therefore, assign the return value (undefined
) to the object as done in the example.Returns:
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
polygon = polygon && polygon.destroy();
See:
Source: Scene/Polygon.js, line 423 -
-
isDestroyed() → Boolean
-
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other thanisDestroyed
will result in aDeveloperError
exception.Returns:
true
if this object was destroyed; otherwise,false
.See:
Source: Scene/Polygon.js, line 402 -
update()
-
Called when
Viewer
orCesiumWidget
render the scene to get the draw commands needed to render this primitive.Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:
Throws:
-
DeveloperError : this.ellipsoid must be defined.
-
DeveloperError : this.material must be defined.
-
DeveloperError : this.granularity must be defined.
Source: Scene/Polygon.js, line 306 -