# ComponentDatatype

Core/ComponentDatatype.js 12
WebGL component datatypes. Components are intrinsics, which form attributes, which form vertices.

##### Properties:

Name | Type | Description
--- | --- | ---
`BYTE` | Number | 8-bit signed byte corresponding to `gl.BYTE` and the type of an element in `Int8Array`.
`UNSIGNED_BYTE` | Number | 8-bit unsigned byte corresponding to `UNSIGNED_BYTE` and the type of an element in `Uint8Array`.
`SHORT` | Number | 16-bit signed short corresponding to `SHORT` and the type of an element in `Int16Array`.
`UNSIGNED_SHORT` | Number | 16-bit unsigned short corresponding to `UNSIGNED_SHORT` and the type of an element in `Uint16Array`.
`INT` | Number | 32-bit signed int corresponding to `INT` and the type of an element in `Int32Array`.
`UNSIGNED_INT` | Number | 32-bit unsigned int corresponding to `UNSIGNED_INT` and the type of an element in `Uint32Array`.
`FLOAT` | Number | 32-bit floating-point corresponding to `FLOAT` and the type of an element in `Float32Array`.
`DOUBLE` | Number | 64-bit floating-point corresponding to `gl.DOUBLE` (in Desktop OpenGL; this is not supported in WebGL, and is emulated in Cesium via `GeometryPipeline.encodeAttribute`) and the type of an element in `Float64Array`.

### Members

#### static constant Cesium.ComponentDatatype.BYTE : Number
Core/ComponentDatatype.js 20

8-bit signed byte corresponding to `gl.BYTE` and the type of an element in `Int8Array`.

Default Value: `WebGLConstants.BYTE`

#### static constant Cesium.ComponentDatatype.DOUBLE : Number
Core/ComponentDatatype.js 91

64-bit floating-point corresponding to `gl.DOUBLE` (in Desktop OpenGL; this is not supported in WebGL, and is emulated in Cesium via `GeometryPipeline.encodeAttribute`) and the type of an element in `Float64Array`.

Default Value: `WebGLConstants.DOUBLE`

#### static constant Cesium.ComponentDatatype.FLOAT : Number
Core/ComponentDatatype.js 78

32-bit floating-point corresponding to `FLOAT` and the type of an element in `Float32Array`.

Default Value: `WebGLConstants.FLOAT`

#### static constant Cesium.ComponentDatatype.INT : Number
Core/ComponentDatatype.js 58

32-bit signed int corresponding to `INT` and the type of an element in `Int32Array`.

Default Value: `WebGLConstants.INT`

#### static constant Cesium.ComponentDatatype.SHORT : Number
Core/ComponentDatatype.js 38

16-bit signed short corresponding to `SHORT` and the type of an element in `Int16Array`.

Default Value: `WebGLConstants.SHORT`

#### static constant Cesium.ComponentDatatype.UNSIGNED_BYTE : Number
Core/ComponentDatatype.js 29

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

Default Value: `WebGLConstants.UNSIGNED_BYTE`

#### static constant Cesium.ComponentDatatype.UNSIGNED_INT : Number
Core/ComponentDatatype.js 69

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

Default Value: `WebGLConstants.UNSIGNED_INT`

#### static constant Cesium.ComponentDatatype.UNSIGNED_SHORT : Number
Core/ComponentDatatype.js 47

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

Default Value: `WebGLConstants.UNSIGNED_SHORT`

### Methods

#### static Cesium.ComponentDatatype.createArrayBufferView(componentDatatype, buffer, byteOffset, length) → Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array
Core/ComponentDatatype.js 253

Creates a typed view of an array of bytes.

Name | Type | Description
--- | --- | ---
`componentDatatype` | ComponentDatatype | The type of the view to create.
`buffer` | ArrayBuffer | The buffer storage to use for the view.
`byteOffset` | Number | optional The offset, in bytes, to the first element in the view.
`length` | Number | optional The number of elements in the view.

##### Returns:

A typed array view of the buffer.

##### Throws:

- DeveloperError : componentDatatype is not a valid value.

#### static Cesium.ComponentDatatype.createTypedArray(componentDatatype, valuesOrLength) → Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array
Core/ComponentDatatype.js 208

Creates a typed array corresponding to component data type.

Name | Type | Description
--- | --- | ---
`componentDatatype` | ComponentDatatype | The component data type.
`valuesOrLength` | Number | Array | The length of the array to create or an array.

##### Returns:

A typed array.

##### Throws:

- DeveloperError : componentDatatype is not a valid value.

##### Example:

    // creates a Float32Array with length of 100
    var typedArray = Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, 100);

#### static Cesium.ComponentDatatype.fromName(name) → ComponentDatatype
Core/ComponentDatatype.js 298

Get the ComponentDatatype from its name.

Name | Type | Description
--- | --- | ---
`name` | String | The name of the ComponentDatatype.

##### Returns:

The ComponentDatatype.

##### Throws:

- DeveloperError : name is not a valid value.

#### static Cesium.ComponentDatatype.fromTypedArray(array) → ComponentDatatype
Core/ComponentDatatype.js 143

Gets the `ComponentDatatype` for the provided TypedArray instance.

Name | Type | Description
--- | --- | ---
`array` | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | The typed array.

##### Returns:

The ComponentDatatype for the provided array, or undefined if the array is not a TypedArray.

#### static Cesium.ComponentDatatype.getSizeInBytes(componentDatatype) → Number
Core/ComponentDatatype.js 106

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

Name | Type | Description
--- | --- | ---
`componentDatatype` | ComponentDatatype | The component datatype to get the size of.

##### Returns:

The size in bytes.

##### Throws:

- DeveloperError : componentDatatype is not a valid value.

##### Example:

    // Returns Int8Array.BYTES_PER_ELEMENT
    var size = Cesium.ComponentDatatype.getSizeInBytes(Cesium.ComponentDatatype.BYTE);

#### static Cesium.ComponentDatatype.validate(componentDatatype) → Boolean
Core/ComponentDatatype.js 181

Validates that the provided component datatype is a valid `ComponentDatatype`

Name | Type | Description
--- | --- | ---
`componentDatatype` | ComponentDatatype | The component datatype to validate.

##### Returns:

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

##### Example:

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