Class: Polygon

Polygon(boundaries, attributes)

Represents a 3D polygon. The polygon may be extruded to the ground to form a prism. It may have multiple boundaries defining empty portions. See also SurfacePolygon.

Altitudes within the polygon's positions are interpreted according to the polygon's altitude mode, which can be one of the following:

  • WorldWind.ABSOLUTE
  • WorldWind.RELATIVE_TO_GROUND
  • WorldWind.CLAMP_TO_GROUND
If the latter, the polygon positions' altitudes are ignored. (If the polygon should be draped onto the terrain, you might want to use SurfacePolygon instead.)

Polygons have separate attributes for normal display and highlighted display. They use the interior and outline attributes of ShapeAttributes. If those attributes identify an image, that image is applied to the polygon.

A polygon displays as a vertical prism if its extrude property is true. A curtain is formed around its boundaries and extends from the polygon's edges to the ground.

A polygon can be textured, including its extruded boundaries. The textures are specified via the imageSource property of the polygon's attributes. If that property is a single string or ImageSource, then it identifies the image source for the polygon's texture. If that property is an array of strings, ImageSources or a combination of those, then the first entry in the array specifies the polygon's image source and subsequent entries specify the image sources of the polygon's extruded boundaries. If the array contains two entries, the first is the polygon's image source and the second is the common image source for all extruded boundaries. If the array contains more than two entries, then the first entry is the polygon's image source and each subsequent entry is the image source for consecutive extruded boundary segments. A null value for any entry indicates that no texture is applied for the corresponding polygon or extruded edge segment. If fewer image sources are specified then there are boundary segments, the last image source specified is applied to the remaining segments. Texture coordinates for the polygon's texture are specified via this polygon's textureCoordinates property. Texture coordinates for extruded boundary segments are implicitly defined to fit the full texture to each boundary segment.

When displayed on a 2D globe, this polygon displays as a SurfacePolygon if its useSurfaceShapeFor2D property is true.

Constructor

new Polygon(boundaries, attributes)

Constructs a Polygon.
Parameters:
Name Type Description
boundaries Array.<Array.<Position>> | Array.<Position> A two-dimensional array containing the polygon boundaries. Each entry of the array specifies the vertices of one boundary. This argument may also be a simple array of positions, in which case the polygon is assumed to have only one boundary. Each boundary is considered implicitly closed, so the last position of the boundary need not and should not duplicate the first position of the boundary.
attributes ShapeAttributes The attributes to associate with this polygon. May be null, in which case default attributes are associated.
Source:
Throws:
If the specified boundaries array is null or undefined.
Type
ArgumentError

Extends

Members

altitudeMode :String

The altitude mode to use when drawing this shape. Recognized values are:
  • WorldWind.ABSOLUTE
  • WorldWind.RELATIVE_TO_GROUND
  • WorldWind.CLAMP_TO_GROUND
Type:
  • String
Inherited From:
Default Value:
  • WorldWind.ABSOLUTE
Source:

attributes :ShapeAttributes

This shape's normal (non-highlight) attributes.
Type:
Inherited From:
Source:

boundaries :Array.<Array.<Position>>|Array.<Position>

This polygon's boundaries. A two-dimensional array containing the polygon boundaries. Each entry of the array specifies the vertices of one boundary. This property may also be a simple array of positions, in which case the polygon is assumed to have only one boundary.
Type:
Source:

displayName :String

The display name of the renderable.
Type:
  • String
Inherited From:
Default Value:
  • "Renderable"
Source:

enabled :Boolean

Indicates whether to display this renderable.
Type:
  • Boolean
Inherited From:
Default Value:
  • true
Source:

expirationInterval :Number

Indicates how long to use terrain-specific shape data before regenerating it, in milliseconds. A value of zero specifies that shape data should be regenerated every frame. While this causes the shape to adapt more frequently to the terrain, it decreases performance.
Type:
  • Number
Inherited From:
Default Value:
  • 2000 (milliseconds)
Source:

extrude :Boolean

Specifies whether to extrude this polygon to the ground by drawing a filled interior from the polygon to the terrain. The filled interior uses this polygon's interior attributes.
Type:
  • Boolean
Default Value:
  • false
Source:

highlightAttributes :ShapeAttributes

This shape's highlight attributes. If null or undefined and this shape's highlight flag is true, this shape's normal attributes are used. If they in turn are null or undefined, this shape is not drawn.
Type:
Inherited From:
Default Value:
  • null
Source:

highlighted :Boolean

Indicates whether this shape uses its normal attributes or its highlight attributes when displayed. If true, the highlight attributes are used, otherwise the normal attributes are used. The normal attributes are also used if no highlight attributes have been specified.
Type:
  • Boolean
Inherited From:
Default Value:
  • false
Source:

pickDelegate :Object

Indicates the object to return as the userObject of this shape when picked. If null, then this shape is returned as the userObject.
Type:
  • Object
Inherited From:
Default Value:
  • null
Source:
See:

textureCoordinates :Array.<Array.<Vec2>>

This polygon's texture coordinates if this polygon is to be textured. A texture coordinate must be provided for each boundary position. The texture coordinates are specified as a two-dimensional array, each entry of which specifies the texture coordinates for one boundary. Each texture coordinate is a Vec2 containing the s and t coordinates.
Type:
  • Array.<Array.<Vec2>>
Default Value:
  • null
Source:

timeRange :Array.<Date>

An array with two elements: start time and end time of the visible range.
Type:
  • Array.<Date>
Inherited From:
Source:

userProperties :Object

An application defined object associated with this renderable. A typical use case is to associate application defined data with a picked renderable.
Type:
  • Object
Inherited From:
Default Value:
  • An empty object
Source:

useSurfaceShapeFor2D :Boolean

Indicates whether to use a surface shape to represent this shape when drawn on a 2D globe.
Type:
  • Boolean
Inherited From:
Default Value:
  • false
Source:

Methods

(protected) applyMvpMatrix(dc)

Apply the current navigator's model-view-projection matrix.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:

(protected) applyMvpMatrixForOutline(dc)

Apply the current navigator's model-view-projection matrix with an offset to make this shape's outline stand out.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:

(protected) beginDrawing(dc)

Called during ordered rendering. Subclasses may override this method in order to perform operations prior to drawing the shape. Applications do not call this method.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Overrides:
Source:

(protected) createShapeDataObject() → {Object}

Creates a new shape data object for the current globe state. Subclasses may override this method to modify the shape data object that this method creates, but must also call this method on this base class. Applications do not call this method.
Inherited From:
Source:
Returns:
The shape data object.
Type
Object

(protected) doMakeOrderedRenderable(dc)

Called during rendering. Subclasses must override this method with one that creates and enques an ordered renderable for this shape if this shape is to be displayed. Applications do not call this method.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Overrides:
Source:

(protected) doRenderOrdered(dc)

Called during ordered rendering. Subclasses must override this method to render the shape using the current shape data.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Overrides:
Source:

(protected) endDrawing(dc)

Called during ordered rendering. Subclasses may override this method in order to perform operations after the shape is drawn. Applications do not call this method.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Overrides:
Source:

(protected) isShapeDataCurrent(dc, shapeData) → {Boolean}

Indicates whether a specified shape data object is current. Subclasses may override this method to add criteria indicating whether the shape data object is current, but must also call this method on this base class. Applications do not call this method.
Parameters:
Name Type Description
dc DrawContext The current draw context.
shapeData Object The object to validate.
Inherited From:
Source:
Returns:
true if the object is current, otherwise false.
Type
Boolean

(protected) isWithinProjectionLimits(dc) → {Boolean}

Indicates whether this shape is within the current globe's projection limits. Subclasses may implement this method to perform the test. The default implementation returns true. Applications do not call this method.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:
Returns:
true if this shape is is within or intersects the current globe's projection limits, otherwise false.
Type
Boolean

render(dc)

Render this renderable. Some shapes actually draw themselves during this call, others only add themselves to the draw context's ordered rendering list for subsequent drawing when their renderOrdered method is called. This method is intended to be called by layers such as RenderableLayer and not by applications.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:

renderOrdered(dc)

Draws this shape during ordered rendering. Implements the OrderedRenderable interface. This method is called by the WorldWindow and is not intended to be called by applications.
Parameters:
Name Type Description
dc DrawContext The current draw context.
Inherited From:
Source:

(protected) reset()

Clears this shape's data cache. Should be called by subclasses when state changes invalidate cached data.
Inherited From:
Source: