# IndexDatatype

Core/IndexDatatype.js 12
Constants for WebGL index datatypes. These corresponds to the `type` parameter of drawElements.

##### Properties:

Name | Type | Description
--- | --- | ---
`UNSIGNED_BYTE` | Number | 8-bit unsigned byte corresponding to `UNSIGNED_BYTE` and the type of an element in `Uint8Array`.
`UNSIGNED_SHORT` | Number | 16-bit unsigned short corresponding to `UNSIGNED_SHORT` and the type of an element in `Uint16Array`.
`UNSIGNED_INT` | Number | 32-bit unsigned int corresponding to `UNSIGNED_INT` and the type of an element in `Uint32Array`.

### Members

#### static constant Cesium.IndexDatatype.UNSIGNED_BYTE : Number
Core/IndexDatatype.js 20

8-bit unsigned byte corresponding to `UNSIGNED_BYTE` and the type of an element in `Uint8Array`.

Default Value: `WebGLConstants.UNSIGNED_BYTE`

#### static constant Cesium.IndexDatatype.UNSIGNED_INT : Number
Core/IndexDatatype.js 38

32-bit unsigned int corresponding to `UNSIGNED_INT` and the type of an element in `Uint32Array`.

Default Value: `WebGLConstants.UNSIGNED_INT`

#### static constant Cesium.IndexDatatype.UNSIGNED_SHORT : Number
Core/IndexDatatype.js 29

16-bit unsigned short corresponding to `UNSIGNED_SHORT` and the type of an element in `Uint16Array`.

Default Value: `WebGLConstants.UNSIGNED_SHORT`

### Methods

#### static Cesium.IndexDatatype.createTypedArray(numberOfVertices, indicesLengthOrArray) → Uint16Array|Uint32Array
Core/IndexDatatype.js 122

Creates a typed array that will store indices, using either `<Uint16Array` or `Uint32Array` depending on the number of vertices.

Name | Type | Description
--- | --- | ---
`numberOfVertices` | Number | Number of vertices that the indices will reference.
`indicesLengthOrArray` | Number | Array | Passed through to the typed array constructor.

##### Returns:

A `Uint16Array` or `Uint32Array` constructed with `indicesLengthOrArray`.

##### Example:

    this.indices = Cesium.IndexDatatype.createTypedArray(positions.length / 3, numberOfIndices);

#### static Cesium.IndexDatatype.createTypedArrayFromArrayBuffer(numberOfVertices, sourceArray, byteOffset, length) → Uint16Array|Uint32Array
Core/IndexDatatype.js 150

Creates a typed array from a source array buffer. The resulting typed array will store indices, using either `<Uint16Array` or `Uint32Array` depending on the number of vertices.

Name | Type | Description
--- | --- | ---
`numberOfVertices` | Number | Number of vertices that the indices will reference.
`sourceArray` | ArrayBuffer | Passed through to the typed array constructor.
`byteOffset` | Number | Passed through to the typed array constructor.
`length` | Number | Passed through to the typed array constructor.

##### Returns:

A `Uint16Array` or `Uint32Array` constructed with `sourceArray`, `byteOffset`, and `length`.

#### static Cesium.IndexDatatype.fromSizeInBytes(sizeInBytes) → IndexDatatype
Core/IndexDatatype.js 74

Gets the datatype with a given size in bytes.

Name | Type | Description
--- | --- | ---
`sizeInBytes` | Number | The size of a single index in bytes.

##### Returns:

The index datatype with the given size.

#### static Cesium.IndexDatatype.getSizeInBytes(indexDatatype) → Number
Core/IndexDatatype.js 51

Returns the size, in bytes, of the corresponding datatype.

Name | Type | Description
--- | --- | ---
`indexDatatype` | IndexDatatype | The index datatype to get the size of.

##### Returns:

The size in bytes.

##### Example:

    // Returns 2
    var size = Cesium.IndexDatatype.getSizeInBytes(Cesium.IndexDatatype.UNSIGNED_SHORT);

#### static Cesium.IndexDatatype.validate(indexDatatype) → Boolean
Core/IndexDatatype.js 102

Validates that the provided index datatype is a valid `IndexDatatype`.

Name | Type | Description
--- | --- | ---
`indexDatatype` | IndexDatatype | The index datatype to validate.

##### Returns:

`true` if the provided index datatype is a valid value; otherwise, `false`.

##### Example:

    if (!Cesium.IndexDatatype.validate(indexDatatype)) {
      throw new Cesium.DeveloperError('indexDatatype must be a valid value.');
    }