ExtentTessellator

ExtentTessellator

Contains class functions to create a mesh or vertex array from a cartographic extent.

See:
Source:

Methods

<static>

Creates a mesh from a cartographic extent.

Parameters:
Name Type Argument Default Description
description.extent Extent A cartographic extent with north, south, east and west properties in radians.
description.ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid on which the extent lies.
description.granularity Number <optional>
0.1 The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
description.surfaceHeight Number <optional>
0.0 The height from the surface of the ellipsoid.
description.relativetoCenter Cartesian3 <optional>
Cartesian3.ZERO The positions will be computed as worldPosition.subtract(relativeToCenter).
description.generateTextureCoordinates Boolean <optional>
false Whether to generate texture coordinates.
Throws:
  • DeveloperError : description.extent is required and must have north, south, east and west attributes.
  • DeveloperError : description.extent.north must be in the interval [-Pi/2, Pi/2].
  • DeveloperError : description.extent.south must be in the interval [-Pi/2, Pi/2].
  • DeveloperError : description.extent.east must be in the interval [-Pi, Pi].
  • DeveloperError : description.extent.west must be in the interval [-Pi, Pi].
  • DeveloperError : description.extent.north must be greater than extent.south.
  • DeveloperError : description.extent.east must be greater than extent.west.
  • DeveloperError : description.context is required.
Returns:
Object A mesh containing attributes for positions, possibly texture coordinates and indices from the extent for creating a vertex array. (returns undefined if no indices are found)
Example
// Create a vertex array for rendering a wireframe extent.
var mesh = ExtentTessellator.compute({
    ellipsoid : Ellipsoid.WGS84,
    extent : new Extent(
        CesiumMath.toRadians(-80.0),
        CesiumMath.toRadians(39.0),
        CesiumMath.toRadians(-74.0),
        CesiumMath.toRadians(42.0)
    ),
    granularity : 0.01,
    surfaceHeight : 10000.0
});
mesh = MeshFilters.toWireframeInPlace(mesh);
var va = context.createVertexArrayFromMesh({
    mesh             : mesh,
    attributeIndices : MeshFilters.createAttributeIndices(mesh)
});
See:

<static>

Creates arrays of vertex attributes and indices from a cartographic extent.

Parameters:
Name Type Argument Default Description
description.extent Extent A cartographic extent with north, south, east and west properties in radians.
description.ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid on which the extent lies.
description.granularity Number <optional>
0.1 The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
description.surfaceHeight Number <optional>
0.0 The height from the surface of the ellipsoid.
description.relativetoCenter Cartesian3 <optional>
Cartesian3.ZERO The positions will be computed as worldPosition.subtract(relativeToCenter).
description.generateTextureCoordinates Boolean <optional>
false Whether to generate texture coordinates.
description.interleaveTextureCoordinates Boolean <optional>
false If texture coordinates are generated, whether to interleave the positions and texture coordinates in a single buffer.
Throws:
  • DeveloperError : description.extent is required and must have north, south, east and west attributes.
  • DeveloperError : description.extent.north must be in the interval [-Pi/2, Pi/2].
  • DeveloperError : description.extent.south must be in the interval [-Pi/2, Pi/2].
  • DeveloperError : description.extent.east must be in the interval [-Pi, Pi].
  • DeveloperError : description.extent.west must be in the interval [-Pi, Pi].
  • DeveloperError : description.extent.north must be greater than extent.south. *
  • DeveloperError : description.extent.east must be greater than extent.west.
Returns:
Object An object with flattened arrays for vertex attributes and indices.
Examples
// Example 1:
// Create a vertex array for a solid extent, with separate positions and texture coordinates.
var buffers = ExtentTessellator.computeBuffers({
    ellipsoid : ellipsoid,
    extent : extent,
    generateTextureCoordinates : true
});

var datatype = ComponentDatatype.FLOAT;
var usage = BufferUsage.STATIC_DRAW;
var positionBuffer = context.createVertexBuffer(datatype.toTypedArray(buffers.positions), usage);
var textureCoordinateBuffer = context.createVertexBuffer(datatype.toTypedArray(buffers.textureCoordinates), usage);
attributes = [{
        index : attributeIndices.position,
        vertexBuffer : positionBuffer,
        componentDatatype : datatype,
        componentsPerAttribute : 3
    }, {
        index : attributeIndices.textureCoordinates,
        vertexBuffer : textureCoordinateBuffer,
        componentDatatype : datatype,
        componentsPerAttribute : 2
    }];
var indexBuffer = context.createIndexBuffer(new Uint16Array(buffers.indices), usage, IndexDatatype.UNSIGNED_SHORT);
var va = context.createVertexArray(attributes, indexBuffer);
// Example 2:
// Create a vertex array for a solid extent, with interleaved positions and texture coordinates.
var buffers = ExtentTessellator.computeBuffers({
    ellipsoid : ellipsoid,
    extent : extent,
    generateTextureCoordinates : true,
    interleaveTextureCoordinates : true
});

var datatype = ComponentDatatype.FLOAT;
var usage = BufferUsage.STATIC_DRAW;
var typedArray = datatype.toTypedArray(buffers.vertices);
var buffer = context.createVertexBuffer(typedArray, usage);
var stride = 5 * datatype.sizeInBytes;
var attributes = [{
        index : attributeIndices.position3D,
        vertexBuffer : buffer,
        componentDatatype : datatype,
        componentsPerAttribute : 3,
        normalize : false,
        offsetInBytes : 0,
        strideInBytes : stride
    }, {
        index : attributeIndices.textureCoordinates,
        vertexBuffer : buffer,
        componentDatatype : datatype,
        componentsPerAttribute : 2,
        normalize : false,
        offsetInBytes : 3 * datatype.sizeInBytes,
        strideInBytes : stride
    }];
var indexBuffer = context.createIndexBuffer(new Uint16Array(buffers.indices), usage, IndexDatatype.UNSIGNED_SHORT);
var vacontext.createVertexArray(attributes, indexBuffer);