• Stars
    star
    238
  • Rank 169,306 (Top 4 %)
  • Language
  • Created about 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Specification for streaming massive terrain datasets for 3D visualization.

quantized-mesh-1.0 terrain format

Have a question? Discuss the quantized-mesh specification on the Cesium community forum.

A terrain tileset in quantized-mesh-1.0 format is a simple multi-resolution quadtree pyramid of meshes. All tiles have the extension .terrain. So, if the Tiles URL for a tileset is:

http://example.com/tiles

Then the two root files of the pyramid are found at these URLs:

The eight tiles at the next level are found at these URLs:

When requesting tiles, be sure to include the following HTTP header in the request:

Accept: application/vnd.quantized-mesh,application/octet-stream;q=0.9

Otherwise, some servers may return a different representation of the tile than the one described here.

Each tile is a specially-encoded triangle mesh where vertices overlap their neighbors at tile edges. In other words, at the root, the eastern-most vertices in the western tile have the same longitude as the western-most vertices in the eastern tile.

Terrain tiles are served gzipped. Once extracted, tiles are little-endian, binary data. The first part of the file is a header with the following format. Doubles are IEEE 754 64-bit floating-point numbers, and Floats are IEEE 754 32-bit floating-point numbers.

struct QuantizedMeshHeader
{
    // The center of the tile in Earth-centered Fixed coordinates.
    double CenterX;
    double CenterY;
    double CenterZ;

    // The minimum and maximum heights in the area covered by this tile.
    // The minimum may be lower and the maximum may be higher than
    // the height of any vertex in this tile in the case that the min/max vertex
    // was removed during mesh simplification, but these are the appropriate
    // values to use for analysis or visualization.
    float MinimumHeight;
    float MaximumHeight;

    // The tileโ€™s bounding sphere.  The X,Y,Z coordinates are again expressed
    // in Earth-centered Fixed coordinates, and the radius is in meters.
    double BoundingSphereCenterX;
    double BoundingSphereCenterY;
    double BoundingSphereCenterZ;
    double BoundingSphereRadius;

    // The horizon occlusion point, expressed in the ellipsoid-scaled Earth-centered Fixed frame.
    // If this point is below the horizon, the entire tile is below the horizon.
    // See http://cesiumjs.org/2013/04/25/Horizon-culling/ for more information.
    double HorizonOcclusionPointX;
    double HorizonOcclusionPointY;
    double HorizonOcclusionPointZ;
};

Immediately following the header is the vertex data. An unsigned int is a 32-bit unsigned integer and an unsigned short is a 16-bit unsigned integer.

struct VertexData
{
    unsigned int vertexCount;
    unsigned short u[vertexCount];
    unsigned short v[vertexCount];
    unsigned short height[vertexCount];
};

The vertexCount field indicates the size of the three arrays that follow. The three arrays contain the delta from the previous value that is then zig-zag encoded in order to make small integers, regardless of their sign, use a small number of bits. Decoding a value is straightforward:

var u = 0;
var v = 0;
var height = 0;

function zigZagDecode(value) {
    return (value >> 1) ^ (-(value & 1));
}

for (i = 0; i < vertexCount; ++i) {
    u += zigZagDecode(uBuffer[i]);
    v += zigZagDecode(vBuffer[i]);
    height += zigZagDecode(heightBuffer[i]);

    uBuffer[i] = u;
    vBuffer[i] = v;
    heightBuffer[i] = height;
}

Once decoded, the meaning of a value in each array is as follows:

Field Meaning
u The horizontal coordinate of the vertex in the tile. When the u value is 0, the vertex is on the Western edge of the tile. When the value is 32767, the vertex is on the Eastern edge of the tile. For other values, the vertex's longitude is a linear interpolation between the longitudes of the Western and Eastern edges of the tile.
v The vertical coordinate of the vertex in the tile. When the v value is 0, the vertex is on the Southern edge of the tile. When the value is 32767, the vertex is on the Northern edge of the tile. For other values, the vertex's latitude is a linear interpolation between the latitudes of the Southern and Nothern edges of the tile.
height The height of the vertex in the tile. When the height value is 0, the vertex's height is equal to the minimum height within the tile, as specified in the tile's header. When the value is 32767, the vertex's height is equal to the maximum height within the tile. For other values, the vertex's height is a linear interpolation between the minimum and maximum heights.

Immediately following the vertex data is the index data. Indices specify how the vertices are linked together into triangles. If tile has more than 65536 vertices, the tile uses the IndexData32 structure to encode indices. Otherwise, it uses the IndexData16 structure.

To enforce proper byte alignment, padding is added before the IndexData to ensure 2 byte alignment for IndexData16 and 4 byte alignment for IndexData32.

struct IndexData16
{
    unsigned int triangleCount;
    unsigned short indices[triangleCount * 3];
}

struct IndexData32
{
    unsigned int triangleCount;
    unsigned int indices[triangleCount * 3];
}

Indices are encoded using the high water mark encoding from webgl-loader. Indices are decoded as follows:

var highest = 0;
for (var i = 0; i < indices.length; ++i) {
    var code = indices[i];
    indices[i] = highest - code;
    if (code === 0) {
        ++highest;
    }
}

Each triplet of indices specifies one triangle to be rendered, in counter-clockwise winding order. Following the triangle indices is four more lists of indices:

struct EdgeIndices16
{
    unsigned int westVertexCount;
    unsigned short westIndices[westVertexCount];

    unsigned int southVertexCount;
    unsigned short southIndices[southVertexCount];

    unsigned int eastVertexCount;
    unsigned short eastIndices[eastVertexCount];

    unsigned int northVertexCount;
    unsigned short northIndices[northVertexCount];
}

struct EdgeIndices32
{
    unsigned int westVertexCount;
    unsigned int westIndices[westVertexCount];

    unsigned int southVertexCount;
    unsigned int southIndices[southVertexCount];

    unsigned int eastVertexCount;
    unsigned int eastIndices[eastVertexCount];

    unsigned int northVertexCount;
    unsigned int northIndices[northVertexCount];
}

These index lists enumerate the vertices that are on the edges of the tile. It is helpful to know which vertices are on the edges in order to add skirts to hide cracks between adjacent levels of detail.

Tiling Scheme and Coordinate System

By default, the data is tiled according to the Tile Map Service (TMS) layout and global-geodetic system. These defaults can be varied by specifying the projection and scheme.

Allowed values for the projection are EPSG:3857 (Web Mercator as used by Google Maps) and EPSG:4326 (Lat/Lng coordinates in the Global-Geodetic System). It is worth noting that the EPSG3857 projection has only 1 tile at the root (zoom level 0) while EPSG:4326 has 2.

The options for the tiling scheme are tms and slippyMap. The Y coordinates are numbered from the south northwards (eg. latitudes) in the tms standard whereas slippyMap coordinates have their origin at top left (NW).

For Cesium terrain layers these options can be set in the layer.json manifest file. If not specified, they default to EPSG:4326 and tms.

Extensions

Extension data may follow to supplement the quantized-mesh with additional information. Each extension begins with an ExtensionHeader, consisting of a unique identifier and the size of the extension data in bytes. An unsigned char is a 8-bit unsigned integer.

struct ExtensionHeader
{
    unsigned char extensionId;
    unsigned int extensionLength;
}

As new extensions are defined, they will be assigned a unique identifier. If no extensions are defined for the tileset, an ExtensionHeader will not included in the quanitzed-mesh. Multiple extensions may be appended to the quantized-mesh data, where ordering of each extension is determined by the server.

Multiple extensions may be requested by the client by delimiting extension names with a -. For example, a client can request vertex normals and watermask using the following Accept header:

Accept : 'application/vnd.quantized-mesh;extensions=octvertexnormals-watermask'

The following extensions may be defined for a quantized-mesh:

Terrain Lighting

Name: Oct-Encoded Per-Vertex Normals

Id: 1

Description: Adds per vertex lighting attributes to the quantized-mesh. Each vertex normal uses oct-encoding to compress the traditional x, y, z 96-bit floating point unit vector into an x,y 16-bit representation. The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors", Cigolle et al 2014: http://jcgt.org/published/0003/02/01/

Data Definition:

struct OctEncodedVertexNormals
{
    unsigned char xy[vertexCount * 2];
}

Requesting: For oct-encoded per-vertex normals to be included in the quantized-mesh, the client must request this extension by using the following HTTP Header:

Accept : 'application/vnd.quantized-mesh;extensions=octvertexnormals'

Comments: The original implementation of this extension was requested using the extension name vertexnormals. The vertexnormals extension identifier is deprecated and implementations must now request vertex normals by adding octvertexnormals in the request header extensions parameter, as shown above.

Water Mask

Name: Water Mask

Id: 2

Description: Adds coastline data used for rendering water effects. The water mask is either 1 byte, in the case that the tile is all land or all water, or it is 256 * 256 * 1 = 65536 bytes if the tile has a mix of land and water. Each mask value is 0 for land and 255 for water. Values in the mask are defined from north-to-south, west-to-east; the first byte in the mask defines the watermask value for the northwest corner of the tile. Values between 0 and 255 are allowed as well in order to support anti-aliasing of the coastline.

Data Definition:

A Terrain Tile covered entirely by land or water is defined by a single byte.

struct WaterMask
{
    unsigned char mask;
}

A Terrain Tile containing a mix of land and water define a 256 x 256 grid of height values.

struct WaterMask
{
    unsigned char mask[256 * 256];
}

Requesting: For the watermask to be included in the quantized-mesh, the client must request this extension by using the following HTTP Header:

Accept : 'application/vnd.quantized-mesh;extensions=watermask'

Metadata

Name: Metadata

Id: 4

Description: Adds a JSON object to each tile that can store extra information about the tile. Potential uses include storing the what type of land is in the tile (eg. forest, desert, etc) or availability of child tiles.

Data Definition:

struct Metadata
{
    unsigned int jsonLength;
    char json[jsonLength];
}

Requesting: For the metadata to be included in the quantized-mesh, the client must request this extension by using the following HTTP Header:

Accept : 'application/vnd.quantized-mesh;extensions=metadata'

More Repositories

1

cesium

An open-source JavaScript library for world-class 3D globes and maps ๐ŸŒŽ
JavaScript
12,828
star
2

3d-tiles

Specification for streaming massive heterogeneous 3D geospatial datasets ๐ŸŒŽ
Batchfile
2,110
star
3

gltf-pipeline

Content pipeline tools for optimizing glTF assets. ๐ŸŒ
JavaScript
1,915
star
4

obj2gltf

Convert OBJ assets to glTF
JavaScript
1,706
star
5

cesium-unreal

Bringing the 3D geospatial ecosystem to Unreal Engine
C++
924
star
6

cesium-native

C++
423
star
7

3d-tiles-validator

Validator for 3D Tiles ๐Ÿšฆ
TypeScript
420
star
8

webglreport

A web page that reports a browser's WebGL capabilities, including supported extensions and implementation specific capabilities, such as the maximum number of texture units.
JavaScript
401
star
9

cesium-unity

Bringing the 3D geospatial ecosystem to Unity
C#
349
star
10

3d-tiles-tools

TypeScript
295
star
11

3d-tiles-samples

Sample tilesets for learning how to use 3D Tiles ๐Ÿ“š
JavaScript
274
star
12

cesium-webpack-example

The minimal recommended setup for an application using Cesium with Webpack.
JavaScript
246
star
13

cesium-unity-samples

Sample project for Cesium for Unity
C#
229
star
14

cesium-threejs-experiment

A small example for using Three JS on Cesium to emulate a combined scene.
JavaScript
187
star
15

cesium-unreal-samples

Getting Started Sample Project for Cesium for Unreal
183
star
16

cesium-workshop

An example application that visualizes and annotates a 3D city using the Cesium platform.
JavaScript
164
star
17

wetzel

Generate Markdown documentation from JSON Schema
JavaScript
133
star
18

cesium-google-earth-examples

Google Earth plugin API samples ported to Cesium
JavaScript
94
star
19

cesium-materials-pack

A Cesium plugin with procedurally-shaded materials such as bricks, wood, and noise patterns
JavaScript
85
star
20

cdb-to-3dtiles

Convert CDB to 3D Tiles
C++
76
star
21

cesium-o3de

Cesium for O3DE
C++
74
star
22

cesium-omniverse

Bringing the 3D geospatial ecosystem to Omniverse
C++
56
star
23

cesium-ion-rest-api-examples

Code examples for using the Cesium ion REST API ๐ŸŒŽ
JavaScript
35
star
24

cesium-vite-example

The minimal recommended setup for an application using Cesium with Vite.
JavaScript
34
star
25

cesium-unreal-vr-tutorial

Unreal Engine project, assets, and code used in the Cesium for Unreal VR Tutorial Series
33
star
26

cesium-ion-blender-addon

Blender add-on for uploading and tiling models with Cesium ion. https://cesium.com
Python
22
star
27

collada2gltf-web-service

Simple Node.js web service to convert 3D models from COLLADA to glTF
JavaScript
20
star
28

cesium-ion-3ds-max-plugin

Autodesk 3DS Max plugin for uploading and tiling models with Cesium ion.
MAXScript
15
star
29

cesium-omniverse-samples

Sample projects for Cesium for Omniverse
14
star
30

3d-tiles-samples-generator

TypeScript
12
star
31

webstorm-plugin

Kotlin
8
star
32

cesium-ion-sketchup-extension

SketchUp extension for uploading and tiling models with Cesium ion.
Ruby
8
star
33

OpenPhillyGlobe

"Google Earth for Philadelphia" with open source and open data.
JavaScript
7
star
34

cesium-o3de-samples

Samples project for Cesium for O3DE
CMake
6
star
35

cesium-concierge

I automate common GitHub tasks
JavaScript
6
star
36

strip-pragma-loader

JavaScript
4
star
37

eslint-config-cesium

ESLint Configuration for Cesium
JavaScript
1
star
38

cesium-ion-plugin-template

1
star