Skip to main content

Crate quantized_mesh

Crate quantized_mesh 

Source
Expand description

Encoder and decoder for Cesium quantized-mesh-1.0 terrain format.

This crate provides encoding and decoding functionality for the quantized-mesh terrain format used by CesiumJS for efficient 3D terrain streaming.

For the legacy heightmap-1.0 format see terrain_codec::heightmap::cesium.

§References

§Example

use quantized_mesh::{
    QuantizedMeshEncoder, QuantizedMeshHeader, QuantizedVertices,
    EdgeIndices, TileBounds,
};

// Create header with tile metadata
let header = QuantizedMeshHeader {
    center: [0.0, 0.0, 6378137.0],
    min_height: 0.0,
    max_height: 100.0,
    bounding_sphere_center: [0.0, 0.0, 6378137.0],
    bounding_sphere_radius: 1000.0,
    horizon_occlusion_point: [0.0, 0.0, 1.0],
};

// Create vertices (simple 2-triangle mesh)
let vertices = QuantizedVertices {
    u: vec![0, 32767, 0, 32767],
    v: vec![0, 0, 32767, 32767],
    height: vec![0, 0, 0, 0],
};

// Triangle indices (2 triangles)
let indices = vec![0, 1, 2, 1, 3, 2];

// Edge indices
let edge_indices = EdgeIndices {
    west: vec![0, 2],
    south: vec![0, 1],
    east: vec![1, 3],
    north: vec![2, 3],
};

// Encode to quantized-mesh format
let encoder = QuantizedMeshEncoder::new(header, vertices, indices, edge_indices);
let data = encoder.encode();

Modules§

coords
Coordinate transformations and geodetic constants.

Structs§

AvailableRange
Tile availability range for metadata extension.
DecodedExtensions
Decoded extensions from quantized-mesh format.
DecodedMesh
Fully owned decoded quantized-mesh data.
EdgeIndices
Edge indices for skirt generation.
EncodeOptions
Options for encoding quantized mesh.
ExtensionsView
Extensions viewed as borrowed slices into the source buffer.
HighWaterMarkIter
Iterator that applies inverse high-water-mark decoding to an inner iterator of raw u32 codes.
QuantizedMeshEncoder
Quantized mesh encoder.
QuantizedMeshHeader
Quantized mesh header (88 bytes).
QuantizedMeshView
Zero-copy view over a parsed quantized-mesh stream.
QuantizedVertices
Quantized vertex data.
TileBounds
Tile bounds in geographic coordinates (degrees).
TileMetadata
Metadata for quantized-mesh extension.
ZigzagDeltaIter
Iterator that applies inverse zigzag-delta decoding to a stream of raw little-endian u16 bytes, yielding decoded u16 values.

Enums§

DecodeError
Error type for quantized-mesh decoding.
ExtensionId
Extension IDs for quantized-mesh format.
IndicesView
Triangle / edge indices viewed as borrowed bytes.
RawIndexIter
Iterator over raw little-endian-encoded indices (u16 or u32) yielding u32.
WaterMask
Water mask data.
WaterMaskView
Water mask viewed as borrowed bytes.

Constants§

QUANTIZED_MAX
Maximum value for quantized coordinates (2^15 - 1).

Functions§

decompress_gzip
Decompress a gzip-compressed quantized-mesh blob. Returns the input unchanged (copied) if it isn’t gzip.
is_gzip
Check if data starts with the gzip magic number.
iter_oct_normals
Iterator over oct-encoded normals (2 bytes each), yielding [f32; 3].
oct_decode_normal
Decode oct-encoded normal to unit vector.
oct_encode_normal
Oct-encode a unit normal vector to 2 bytes.
zigzag_decode
Decode a zig-zag encoded value.
zigzag_encode
Encode a value using zig-zag encoding.

Type Aliases§

DecodeResult
Result type for quantized-mesh decoding.