Breaklines in terrain meshes
Delatin keeps every grid sample within its error tolerance. Between samples it can be far off, and it has no way to follow a known line such as a cliff edge or a coastline. A constrained TIN built with cdtr takes those lines as breaklines. The same tolerance then holds along the feature too. The examples below were meshed in R, and Delatin ran in Node.
Oblique cliff
This is the roadmap's step fixture: a 40-unit cliff, 4 cells wide, at 30° across a 257 × 257 grid with curved terrain behind it. The breaklines are the top and bottom edges of the cliff as 3D lines, with a vertex every 4 cells. Surface error is measured against the analytic surface on a lattice 4 × finer than the samples.
At a 0.25 tolerance Delatin meets the sample check, but it is 2.4 off the true surface along the cliff. With breaklines the surface error matches the tolerance, and at 0.5 or finer the mesh is also smaller than Delatin's.
Hobart coast
This window covers kunanyi/Mt Wellington and the Derwent estuary: 513 × 513 samples from the AWS open terrain tiles at zoom 10, about 56 m on the ground. The coastline is height 0, simplified to within one cell. It is both a breakline at 0 m and the edge of the mesh, so the sea is left out as nodata. Error is measured on land only: at the samples, and against the bilinear surface between them on a 4 × finer lattice.
Delatin's coastline drifts by up to tens of metres from sea level. Between 1,115 and 2,734 of its triangles join land and sea samples, and it has to mesh the sea as well. The constrained mesh holds the coastline exactly.
Pacific coast, math.gl's fixture
This is math.gl's own pacific-streaming input: 257 × 257 samples from AWS terrain tile 8/40/98, around Point Reyes, with bathymetry. The coastline is treated as for Hobart.
Delatin's shoreline is up to 176 m off sea level here. The constrained mesh holds the coast exactly, with a similar triangle count, and covers land only.
Sierra Nevada with nodata, math.gl's fixture
This is sierra-nodata-streaming: a 65 × 65 nodata block, plus single missing samples every 16th row and 8th column. math.gl's Delatin and MARTINI adapters refuse it. Its regular mesh drops every cell that has a missing corner. The constrained mesh uses that same domain, with the outline as constraints, and meshes it adaptively.
The adaptive mesh covers exactly the regular mesh's area. Every outline vertex is a valid sample, so no height is invented.
How this was made
The constrained mesh uses greedy Garland–Heckbert refinement, the same family as Delatin, on top of cdtr's constrained Delaunay triangulation. Each round inserts the worst grid sample in each triangle over tolerance. Breakline vertices go in first and their segments stay fixed. One evaluator measures every mesh, and it matches Delatin's own reported error. The Greedy, no lines column runs the same R code without constraints. It needs about 35% more triangles than Delatin, because this prototype inserts points in batches rather than one at a time. That gap comes from the batching, not from the constraints.
The meshes are plain arrays: Float32 positions and 0-based Uint32 triangle indices, counter-clockwise in xy. That is the same shape as math.gl's TerrainGridMesh and the mesh spec v0.2. Context: visgl/math.gl#341.