Class: TriangleMesh

TriangleMesh(positions, indices, attributes)

Represents a 3D triangle mesh.

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

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

Meshes 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 mesh. Texture coordinates for the image may be specified, but if not specified the full image is stretched over the full mesh. If texture coordinates are specified, there must be one texture coordinate for each vertex in the mesh.

Constructor

new TriangleMesh(positions, indices, attributes)

Constructs a triangle mesh.
Parameters:
Name Type Description
positions Array.<Position> An array containing the mesh vertices. There must be no more than 65536 positions. Use split to subdivide large meshes into smaller ones that fit this limit.
indices Array.<Number> An array of integers identifying the positions of each mesh triangle. Each sequence of three indices defines one triangle in the mesh. The indices identify the index of the position in the associated positions array. The indices for each triangle should be in counter-clockwise order to identify the triangles as front-facing.
attributes ShapeAttributes The attributes to associate with this mesh. May be null, in which case default attributes are associated.
Source:
Throws:
If the specified positions array is null, empty or undefined, the number of indices is less than 3 or too many positions are specified (limit is 65536).
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:

altitudeScale :Number

Scales the altitudes of this mesh.
Type:
  • Number
Inherited From:
Default Value:
  • 1
Source:

attributes :ShapeAttributes

This shape's normal (non-highlight) attributes.
Type:
Inherited From:
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:

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:

indices :Array.<Number>

The mesh indices, an array of integers identifying the indexes of each triangle. Each index in this array identifies the index of the corresponding position in the positions array. Each group of three indices in this array identifies the positions of one triangle.
Type:
  • Array.<Number>
Source:

outlineIndices :Array.<Number>

The mesh outline indices, an array of integers identifying the positions in the outline. Each index in this array identifies the index of the corresponding position in the positions array. The collection of these positions forms the outline of this mesh. May be null, in which case no outline is drawn.
Type:
  • Array.<Number>
Default Value:
  • null
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:

pickTransparentImagePixels :Boolean

Indicates whether this mesh is pickable when the pick point intersects transparent pixels of the image applied to this mesh. If no image is applied to this mesh, this property is ignored. If this property is true and an image with fully transparent pixels is applied to the mesh, the mesh is pickable at those transparent pixels, otherwise this mesh is not pickable at those transparent pixels.
Type:
  • Boolean
Inherited From:
Default Value:
  • true
Source:

positions :Array.<Position>

This mesh's positions.
Type:
Source:

textureCoordinates :Array.<Vec2>

This mesh's texture coordinates if this mesh is textured. A texture coordinate must be provided for each mesh position. Each texture coordinate is a Vec2 containing the s and t coordinates, in that order. If no texture coordinates are specified then texture is not applied to this mesh.
Type:
Default Value:
  • null
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

(static) split(positions, indices, textureCoords, outlineIndices) → {Array.<Object>}

Splits a triangle mesh into several meshes, each of which contains fewer than 65536 positions.
Parameters:
Name Type Description
positions Array.<Position> An array containing the mesh vertices.
indices Array.<Number> An array of integers identifying the positions of each mesh triangle. Each sequence of three indices defines one triangle in the mesh. The indices identify the index of the position in the associated positions array.
textureCoords Array.<Vec2> The mesh's texture coordinates.
outlineIndices Array.<Number> The mesh's outline indices.
Source:
Returns:
An array of objects, each of which defines one subdivision of the full mesh. Each object in the array has the properties of the same name as the input arguments.
Type
Array.<Object>

(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.
Inherited From:
Source:

(protected) computeMeshIndices(currentData)

Computes or copies the indices of this mesh into a Uint16Array. Subclasses must implement this method. An exception is thrown if it is not implemented.
Parameters:
Name Type Description
currentData Object This shape's current data.
Overrides:
Source:

(protected) computeMeshPoints(dc, currentData) → {Float32Array}

Computes this mesh's Cartesian points. Called by this abstract class during rendering to compute Cartesian points from geographic positions. This method must be overridden by subclasses. An exception is thrown if it is not. This method must also assign currentData.eyeDistance to be the minimum distance from this mesh to the current eye point.
Parameters:
Name Type Description
dc DrawContext The current draw context.
currentData Object The current data for this shape.
Overrides:
Source:
Returns:
The Cartesian mesh points.
Type
Float32Array

(protected) computeOutlineIndices(currentData)

Computes or copies the outline indices of this mesh into a Uint16Array. Subclasses must implement this method if they have outlines. The default implementation returns null.
Parameters:
Name Type Description
currentData Object This shape's current data.
Overrides:
Source:

(protected) computeTexCoords() → {Float32Array}

Computes the texture coordinates for this shape. Called by this abstract class during rendering to copy or compute texture coordinates into a typed array. Subclasses should implement this method if the shape they define has texture coordinates. The default implementation returns null.
Overrides:
Source:
Returns:
The texture coordinates.
Type
Float32Array

(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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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: