IndexDatatype

IndexDatatype()

用于WebGL索引数据类型的常量。 这些对应drawElementstype参数

Members

staticconstantCesium.IndexDatatype.UNSIGNED_BYTE : Number

对应于UNSIGNED_BYTE的8位无符号字节和Uint8Array中的元素类型。

staticconstantCesium.IndexDatatype.UNSIGNED_INT : Number

对应UNSIGNED_INT的32位无符号int以及Uint32Array中的元素类型。

staticconstantCesium.IndexDatatype.UNSIGNED_SHORT : Number

对应UNSIGNED_SHORT >的16位无符号short以及Uint16Array >中的元素类型。

Methods

staticCesium.IndexDatatype.createTypedArray(numberOfVertices, indicesLengthOrArray)Uint16Array|Uint32Array

创建一个将存储索引的类型化数组,根据顶点的数量使用Uint32Array
Name Type Description
numberOfVertices Number 索引将引用的顶点数。
indicesLengthOrArray Number | Array 传递给类型化数组构造函数。
Returns:
一个Uint16ArrayUint32Array构建的indicesLengthOrArray
Example:
this.indices = Cesium.IndexDatatype.createTypedArray(positions.length / 3, numberOfIndices);

staticCesium.IndexDatatype.createTypedArrayFromArrayBuffer(numberOfVertices, sourceArray, byteOffset, length)Uint16Array|Uint32Array

从源数组缓冲区创建类型化数组。得到的类型化数组将存储索引,根据顶点的数量使用Uint32Array
Name Type Description
numberOfVertices Number Number of vertices that the indices will reference.
sourceArray ArrayBuffer 传递给类型化数组构造函数。
byteOffset Number 传递给类型化数组构造函数。
length Number 传递给类型化数组构造函数。
Returns:
一个Uint16ArrayUint32Array构造sourceArraybyteOffsetlength

staticCesium.IndexDatatype.fromSizeInBytes(sizeInBytes)IndexDatatype

获取具有给定大小(以字节为单位)的数据类型。
Name Type Description
sizeInBytes Number 单个索引的大小(以字节为单位)。
Returns:
具有给定大小的索引数据类型。

staticCesium.IndexDatatype.getSizeInBytes(indexDatatype)Number

返回相应数据类型的大小(以字节为单位)。
Name Type Description
indexDatatype IndexDatatype 获取大小的索引数据类型。
Returns:
字节大小。
Example:
// Returns 2
var size = Cesium.IndexDatatype.getSizeInBytes(Cesium.IndexDatatype.UNSIGNED_SHORT);

staticCesium.IndexDatatype.validate(indexDatatype)Boolean

验证所提供的索引数据类型是有效的IndexDatatype
Name Type Description
indexDatatype IndexDatatype 要验证的索引数据类型。
Returns:
如果提供的索引数据类型是有效值,则true;否则,false
Example:
if (!Cesium.IndexDatatype.validate(indexDatatype)) {
  throw new Cesium.DeveloperError('indexDatatype must be a valid value.');
}