ProceduralTerrain

Extends: EmptyTerrain

Source: ProceduralTerrain.ts:81

Terrain with the heights made by a function, without a server.

Fires

  • event:load
  • event:loadend

Example

CODE
// Heights made right away are reduced in the main thread
new ProceduralTerrain("Flat", {
    getHeights: (segment) => new Float32Array(129 * 129).fill(100)
});

// Promised heights are reduced in a worker
new ProceduralTerrain("Loaded", {
    getHeights: (segment) => loadTilePixels(segment) // Promise<Float32Array>
});

Constructor

new ProceduralTerrain( name?: string, options: IProceduralTerrainParams, ): ProceduralTerrain

Parameters

  • name (string, optional, default: "\"ProceduralTerrain\"") — Terrain provider name.
  • options (IProceduralTerrainParams) — Provider options:
    • options.getHeights (GetHeightsFunc) — Returns the segment heights, or a promise of them, rows from north to south, vertices evenly spaced in segment.getExtent(), or null when the segment has no terrain. (plainGridSize + 1)² heights are taken as they are. Larger (2^n + 1)² vertices, or 2^n x 2^n pixels, are reduced to them keeping peaks and pits. Segments of the height requests are not in the quad tree, their node is null. The function runs in the main thread. Returned heights are reduced in the main thread too and applied right away, promised heights are reduced in a worker when the promise is resolved.
    • options.plainGridSize (number, optional, default: 32) — Elevation grid size.
    • options.maxNativeZoom (number, optional, default: "maxZoom") — Last zoom of the height requests. Deeper segments are the subdivision levels of the maxNativeZoom segment heights, as RgbTerrain ones, its pixels keep their heights there.
    • options.nativeCacheSize (number, optional, default: 50) — Number of maxNativeZoom segments which pixels are kept to make their levels when they are needed. The least recently used are dropped and requested again.
    • options.gridSizeByZoom (Array.<number>, optional) — Segment grid sizes by zoom, the same as RgbTerrain ones by default.
    • options.noDataValues (Array.<number>, optional) — Heights of no data.

Instance Methods

getHeightAsync()

Returns the height under the point from the zoom tile heights, they are made for the request if there are none. Calls back right away and returns true when the heights are ready.

_getSegmentHeights()

Returns the segment heights, or the promise of them while they are made. Every tile heights are requested once, failed requests are made again next time.

_getLevelHeights()

Returns the subdivision level heights of the maxNativeZoom segment, made of its pixels when they are needed. Levels end at the vertex grid, deeper segments have no heights and take the terrain of the level above.

_getNativeSegment()

Returns the maxNativeZoom segment of the deeper segment, out of the quad tree for the height requests.

_toGridHeights()

Returns the grid heights of the segment, or the promise of them the worker makes. The maxNativeZoom segment with subdivision levels keeps its pixels to make them.

setUrlRewriteCallback(ur: UrlRewriteFunc)

Inherited from EmptyTerrain#setUrlRewriteCallback

Overrides: EmptyTerrain#setUrlRewriteCallback

Sets url rewrite callback, used for custom url rewriting for every tile loading.

Parameters

  • ur (UrlRewriteFunc) — The callback that returns tile custom created url.

setAttribution(html: string)

Inherited from EmptyTerrain#setAttribution

Overrides: EmptyTerrain#setAttribution

Sets terrain provider attribution text.

Parameters

  • html (string) — HTML string that represents terrain provider attribution.

getAttribution(): string

Inherited from EmptyTerrain#getAttribution

Overrides: EmptyTerrain#getAttribution

Gets terrain provider attribution.

Returns

  • string — Terrain provider attribution.

handleSegmentTerrain(segment: Segment)

Inherited from EmptyTerrain#handleSegmentTerrain

Overrides: EmptyTerrain#handleSegmentTerrain

Loads or creates segment elevation data.

Parameters

  • segment (Segment) — Segment to create elevation data.

getExtent(): Extent

Inherited from EmptyTerrain#getExtent

Overrides: EmptyTerrain#getExtent

Returns the terrain extent, the whole globe by default.

Returns

flyExtent()

Inherited from EmptyTerrain#flyExtent

Overrides: EmptyTerrain#flyExtent

Flies the camera of the planet the terrain is active on to the terrain extent.

getMaxHeight(): number

Inherited from EmptyTerrain#getMaxHeight

Overrides: EmptyTerrain#getMaxHeight

Returns the highest terrain point over the ellipsoid with the terrain height factor, in meters.

Returns

  • number

getCacheInfo(): ITerrainCacheInfo | null

Inherited from EmptyTerrain#getCacheInfo

Overrides: EmptyTerrain#getCacheInfo

Returns the cache state, null when the terrain has no cache.

Returns

  • ITerrainCacheInfo | null

Instance Fields

iconSrc

Inherited from EmptyTerrain#iconSrc

Overrides: EmptyTerrain#iconSrc

Gets terrain provider icon.

Returns

  • string | null — Icon source.