English中文

HeightmapTerrainData

new Cesium.HeightmapTerrainData(options)

单个图块的地形数据,其中地形数据表示为高度图。高度图是从北到南、从西到东按行优先顺序排列的高度矩形数组。 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.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
buffer Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array 包含高度数据的缓冲区。 The buffer containing height data.
width number 高度图的宽度(经度方向),以样本为单位。 The width (longitude direction) of the heightmap, in samples.
height number 高度图的高度(纬度方向),以样本为单位。 The height (latitude direction) of the heightmap, in samples.
childTileMask number 15 可选 optional 一个位掩码,指示该图块的四个子级中存在哪一个。如果设置了子位,则在需要时也会请求该图块的几何形状。如果该位被清除,则不会请求子图块,而是从父图块对几何图形进行上采样。位值如下: 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:
位位置 Bit Position位值 Bit Value儿童瓷砖 Child Tile
01Southwest
12Southeast
24Northwest
38Northeast
waterMask Uint8Array 可选 optional 该地形数据中包含的水掩模(如果有)。水蒙版是一个方形 Uint8Array 或图像,其中值 255 表示水,值 0 表示陆地。 0 到 255 之间的值也允许在陆地和水之间平滑地混合。 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.
structure object 可选 optional 描述高度数据结构的对象。 An object describing the structure of the height data.
名称 Name 类型 Type 默认值 Default 说明 Description
heightScale number 1.0 可选 optional 与高度样本相乘的系数,以获得高于 heightOffset 的高度(以米为单位)。 heightOffset 乘以比例后添加到所得高度。 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.
heightOffset number 0.0 可选 optional 添加到缩放高度以获得最终高度(以米为单位)的偏移量。在高度样本乘以 heightScale 之后添加偏移量。 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.
elementsPerHeight number 1 可选 optional 缓冲区中构成单个高度样本的元素数量。这通常是1,表示每个元素都是一个单独的高度样本。如果它大于 1,则该数量的元素一起形成高度样本,该高度样本是根据 Structure.elementMultiplier 和 Structure.isBigEndian 属性计算的。 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.
stride number 1 可选 optional 从一个高度的第一个元素到下一个高度的第一个元素要跳过的元素数。 The number of elements to skip to get from the first element of one height to the first element of the next height.
elementMultiplier number 256.0 可选 optional 当 stride 属性大于 1 时,用于计算高度值的乘数。例如,如果 stride 为 4,strideMultiplier 为 256,则高度计算如下:`height = buffer[index] + buffer[index + 1] * 256 + buffer[index + 2] * 256 * 256 + buffer[index + 3] * 256 * 256 * 256` 这是假设 isBigEndian 属性为 false。如果为真,则元素的顺序相反。 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.
isBigEndian boolean false 可选 optional 指示当 stride 属性大于 1 时缓冲区中元素的字节顺序。如果该属性为 false,则第一个元素是低位元素。如果为真,则第一个元素是高阶元素。 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.
lowestEncodedHeight number 可选 optional 可以存储在高度缓冲区中的最低值。使用“heightScale”和“heightOffset”编码后低于此值的任何高度都会被限制为该值。例如,如果高度缓冲区是“Uint16Array”,则该值应为 0,因为“Uint16Array”不能存储负数。如果未指定此参数,则不强制执行最小值。 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.
highestEncodedHeight number 可选 optional 高度缓冲区中可以存储的最高值。使用“heightScale”和“heightOffset”编码后高于此值的任何高度都会被限制为该值。例如,如果高度缓冲区是“Uint16Array”,则该值应为“256 * 256 - 1”或 65535,因为“Uint16Array”无法存储大于 65535 的数字。如果未指定此参数,则不会强制使用最大值。 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.
encoding HeightmapEncoding HeightmapEncoding.NONE 可选 optional 缓冲区上使用的编码。 The encoding that is used on the buffer.
createdByUpsampling boolean false 可选 optional 如果此实例是通过对另一个实例进行上采样创建的,则为 True;否则为假。 True if this instance was created by upsampling another instance; otherwise, false.
示例: Example:
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
});
另见: See:

成员 Members

该图块的一系列制作人员名单。 An array of credits for this tile.

waterMask : Uint8Array|HTMLImageElement|HTMLCanvasElement|ImageBitmap|undefined

该地形数据中包含的水掩模(如果有)。水蒙版是一个方形 Uint8Array 或图像,其中值 255 表示水,值 0 表示陆地。 0 到 255 之间的值也允许在陆地和水之间平滑地混合。 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.

方法 Methods

interpolateHeight(rectangle, longitude, latitude)number

计算指定经度和纬度处的地形高度。 Computes the terrain height at a specified longitude and latitude.
名称 Name 类型 Type 说明 Description
rectangle Rectangle 该地形数据覆盖的矩形。 The rectangle covered by this terrain data.
longitude number 以弧度表示的经度。 The longitude in radians.
latitude number 以弧度为单位的纬度。 The latitude in radians.
返回: Returns:
指定位置的地形高度。如果位置位于矩形之外,此方法将推断高度,这对于远离矩形之外的位置可能非常不正确。 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.

isChildAvailable(thisX, thisY, childX, childY)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.
名称 Name 类型 Type 说明 Description
thisX number 此(父)图块的图块 X 坐标。 The tile X coordinate of this (the parent) tile.
thisY number 此(父)图块的图块 Y 坐标。 The tile Y coordinate of this (the parent) tile.
childX number 用于检查可用性的子图块的图块 X 坐标。 The tile X coordinate of the child tile to check for availability.
childY number 用于检查可用性的子图块的图块 Y 坐标。 The tile Y coordinate of the child tile to check for availability.
返回: Returns:
如果子图块可用,则为 True;否则为假。 True if the child tile is available; otherwise, false.

upsample(tilingScheme, thisX, thisY, thisLevel, descendantX, descendantY, descendantLevel)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.
名称 Name 类型 Type 说明 Description
tilingScheme TilingScheme 该地形数据的切片方案。 The tiling scheme of this terrain data.
thisX number 切片方案中该切片的 X 坐标。 The X coordinate of this tile in the tiling scheme.
thisY number 切片方案中该切片的 Y 坐标。 The Y coordinate of this tile in the tiling scheme.
thisLevel number 该切片在切片方案中的级别。 The level of this tile in the tiling scheme.
descendantX number 我们正在对其进行上采样的后代切片的切片方案中的 X 坐标。 The X coordinate within the tiling scheme of the descendant tile for which we are upsampling.
descendantY number 我们要对其进行上采样的后代切片的切片方案中的 Y 坐标。 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.
返回: Returns:
承诺为后代图块提供上采样高度图地形数据,或者如果网格不可用则未定义。 A promise for upsampled heightmap terrain data for the descendant tile, or undefined if the mesh is unavailable.

wasCreatedByUpsampling()boolean

获取一个值,该值指示此地形数据是否是通过对较低分辨率地形数据进行上采样而创建的。如果该值为 false,则数据是从其他来源获取的,例如从远程服务器下载。对于从调用返回的实例,此方法应返回 true 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.
返回: Returns:
如果此实例是通过上采样创建的,则为 True;否则为假。 True if this instance was created by upsampling; otherwise, false.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.