Skip to content

KBE3D / KBCore / Cesium / HeightmapTerrainData

类: HeightmapTerrainData

Terrain data for a single tile where the terrain data is represented as a heightmap. A heightmap is a rectangular array of heights in row-major order from north to south and west to east.

示例

ts
const buffer = ...
const heightBuffer = new Uint16Array(buffer, 0, that._heightmapWidth * that._heightmapWidth);
const childTileMask = new Uint8Array(buffer, heightBuffer.byteLength, 1)[0];
const waterMask = new Uint8Array(buffer, heightBuffer.byteLength + 1, buffer.byteLength - heightBuffer.byteLength - 1);
const terrainData = new Cesium.HeightmapTerrainData({
  buffer : heightBuffer,
  width : 65,
  height : 65,
  childTileMask : childTileMask,
  waterMask : waterMask
});

参数

Object with the following properties:

参数

The buffer containing height data.

参数

The width (longitude direction) of the heightmap, in samples.

参数

The height (latitude direction) of the heightmap, in samples.

参数

A bit mask indicating which of this tile's four children exist. If a child's bit is set, geometry will be requested for that tile as well when it is needed. If the bit is cleared, the child tile is not requested and geometry is instead upsampled from the parent. The bit values are as follows: <table> <tr><th>Bit Position</th><th>Bit Value</th><th>Child Tile</th></tr> <tr><td>0</td><td>1</td><td>Southwest</td></tr> <tr><td>1</td><td>2</td><td>Southeast</td></tr> <tr><td>2</td><td>4</td><td>Northwest</td></tr> <tr><td>3</td><td>8</td><td>Northeast</td></tr> </table>

参数

The water mask included in this terrain data, if any. A water mask is a square Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land. Values in between 0 and 255 are allowed as well to smoothly blend between land and water.

参数

An object describing the structure of the height data.

参数

The factor by which to multiply height samples in order to obtain the height above the heightOffset, in meters. The heightOffset is added to the resulting height after multiplying by the scale.

参数

The offset to add to the scaled height to obtain the final height in meters. The offset is added after the height sample is multiplied by the heightScale.

参数

The number of elements in the buffer that make up a single height sample. This is usually 1, indicating that each element is a separate height sample. If it is greater than 1, that number of elements together form the height sample, which is computed according to the structure.elementMultiplier and structure.isBigEndian properties.

参数

The number of elements to skip to get from the first element of one height to the first element of the next height.

参数

The multiplier used to compute the height value when the stride property is greater than 1. For example, if the stride is 4 and the strideMultiplier is 256, the height is computed as follows: height = buffer[index] + buffer[index + 1] * 256 + buffer[index + 2] * 256 * 256 + buffer[index + 3] * 256 * 256 * 256 This is assuming that the isBigEndian property is false. If it is true, the order of the elements is reversed.

参数

Indicates endianness of the elements in the buffer when the stride property is greater than 1. If this property is false, the first element is the low-order element. If it is true, the first element is the high-order element.

参数

The lowest value that can be stored in the height buffer. Any heights that are lower than this value after encoding with the heightScale and heightOffset are clamped to this value. For example, if the height buffer is a Uint16Array, this value should be 0 because a Uint16Array cannot store negative numbers. If this parameter is not specified, no minimum value is enforced.

参数

The highest value that can be stored in the height buffer. Any heights that are higher than this value after encoding with the heightScale and heightOffset are clamped to this value. For example, if the height buffer is a Uint16Array, this value should be 256 * 256 - 1 or 65535 because a Uint16Array cannot store numbers larger than 65535. If this parameter is not specified, no maximum value is enforced.

参数

The encoding that is used on the buffer.

参数

True if this instance was created by upsampling another instance; otherwise, false.

属性

credits

credits: Credit[]

An array of credits for this tile.


waterMask

waterMask: HTMLCanvasElement | HTMLImageElement | ImageBitmap | Uint8Array<ArrayBufferLike> | undefined

The water mask included in this terrain data, if any. A water mask is a square Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land. Values in between 0 and 255 are allowed as well to smoothly blend between land and water.

方法

interpolateHeight()

interpolateHeight(rectangle: Rectangle, longitude: number, latitude: number): number

Computes the terrain height at a specified longitude and latitude.

参数

rectangle

Rectangle

The rectangle covered by this terrain data.

longitude

number

The longitude in radians.

latitude

number

The latitude in radians.

返回

number

The terrain height at the specified position. If the position is outside the rectangle, this method will extrapolate the height, which is likely to be wildly incorrect for positions far outside the rectangle.


upsample()

upsample(tilingScheme: TilingScheme, thisX: number, thisY: number, thisLevel: number, descendantX: number, descendantY: number, descendantLevel: number): Promise<HeightmapTerrainData> | undefined

Upsamples this terrain data for use by a descendant tile. The resulting instance will contain a subset of the height samples in this instance, interpolated if necessary.

参数

tilingScheme

TilingScheme

The tiling scheme of this terrain data.

thisX

number

The X coordinate of this tile in the tiling scheme.

thisY

number

The Y coordinate of this tile in the tiling scheme.

thisLevel

number

The level of this tile in the tiling scheme.

descendantX

number

The X coordinate within the tiling scheme of the descendant tile for which we are upsampling.

descendantY

number

The Y coordinate within the tiling scheme of the descendant tile for which we are upsampling.

descendantLevel

number

The level within the tiling scheme of the descendant tile for which we are upsampling.

返回

Promise<HeightmapTerrainData> | undefined

A promise for upsampled heightmap terrain data for the descendant tile, or undefined if the mesh is unavailable.


isChildAvailable()

isChildAvailable(thisX: number, thisY: number, childX: number, childY: number): boolean

Determines if a given child tile is available, based on the HeightmapTerrainData.childTileMask. The given child tile coordinates are assumed to be one of the four children of this tile. If non-child tile coordinates are given, the availability of the southeast child tile is returned.

参数

thisX

number

The tile X coordinate of this (the parent) tile.

thisY

number

The tile Y coordinate of this (the parent) tile.

childX

number

The tile X coordinate of the child tile to check for availability.

childY

number

The tile Y coordinate of the child tile to check for availability.

返回

boolean

True if the child tile is available; otherwise, false.


wasCreatedByUpsampling()

wasCreatedByUpsampling(): boolean

Gets a value indicating whether or not this terrain data was created by upsampling lower resolution terrain data. If this value is false, the data was obtained from some other source, such as by downloading it from a remote server. This method should return true for instances returned from a call to HeightmapTerrainData#upsample.

返回

boolean

True if this instance was created by upsampling; otherwise, false.

构造函数

构造函数

new HeightmapTerrainData(options: { buffer: Float32Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>; width: number; height: number; childTileMask?: number; waterMask?: Uint8Array<ArrayBufferLike>; structure?: { heightScale?: number; heightOffset?: number; elementsPerHeight?: number; stride?: number; elementMultiplier?: number; isBigEndian?: boolean; lowestEncodedHeight?: number; highestEncodedHeight?: number; }; encoding?: HeightmapEncoding; createdByUpsampling?: boolean; }): HeightmapTerrainData

参数

options
buffer

Float32Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>

width

number

height

number

childTileMask?

number

waterMask?

Uint8Array<ArrayBufferLike>

structure?

{ heightScale?: number; heightOffset?: number; elementsPerHeight?: number; stride?: number; elementMultiplier?: number; isBigEndian?: boolean; lowestEncodedHeight?: number; highestEncodedHeight?: number; }

structure.heightScale?

number

structure.heightOffset?

number

structure.elementsPerHeight?

number

structure.stride?

number

structure.elementMultiplier?

number

structure.isBigEndian?

boolean

structure.lowestEncodedHeight?

number

structure.highestEncodedHeight?

number

encoding?

HeightmapEncoding

createdByUpsampling?

boolean

返回

HeightmapTerrainData

KBE3D @3.0.0 Copyright © 2024-present KBE3D