Skip to main content

Terrain module · writer API

QuantizedMeshWriter

Encode loaders.gl mesh or Mesh Arrow table data as compact quantized mesh terrain tiles for tile-based terrain delivery.

What it writes

Put a terrain surface into a tile-ready encoding.

QuantizedMeshWriter normalizes mesh input, quantizes positions within bounds, and writes the core terrain header, vertices, indices, and edge structures expected by quantized mesh readers.

Input

Mesh or Mesh Arrow table

Output

Binary `.terrain` quantized mesh

Geometry

Triangle-list positions and indices

Control

Bounds and quantization options

Detailed guide

QuantizedMeshWriter reference

The sections below document usage, input normalization, output structure, and writer options.

The QuantizedMeshWriter writes Mesh or Mesh Arrow table terrain data as quantized mesh binary data.

WriterCharacteristic
File FormatQuantized Mesh
Data FormatMesh Arrow table, Mesh
File Extension.terrain
File TypeBinary
MIME Typeapplication/vnd.quantized-mesh
Supported APIsencode, encodeSync

Usage​

import {encode} from '@loaders.gl/core';
import type {Mesh, MeshArrowTable} from '@loaders.gl/core/schema';
import {QuantizedMeshWriter} from '@loaders.gl/raster/terrain';

declare const terrainMesh: Mesh | MeshArrowTable;

const arrayBuffer = await encode(terrainMesh, QuantizedMeshWriter, {
'quantized-mesh': {
bounds: [0, 0, 1, 1]
}
});

Data Format​

QuantizedMeshWriter accepts Mesh Arrow tables and legacy Mesh objects. Legacy Mesh input is normalized through the Mesh Arrow table conversion path before quantized mesh binary data is encoded.

The writer requires triangle-list mesh data with a POSITION attribute. It writes the quantized mesh core header, vertex arrays, triangle indices, and empty edge-index lists.

Options​

OptionTypeDefaultDescription
quantized-mesh.bounds[number, number, number, number]Mesh XY bounding boxBounds used to map x/y positions to quantized u/v coordinates, in [minX, minY, maxX, maxY].