ComponentDatatype - Cesium Documentation

# ComponentDatatype

WebGL component datatypes. Components are intrinsics, which form attributes, which form vertices.

Source: Core/ComponentDatatype.js, line 29

### Members

#### staticconstantComponentDatatype.BYTE :Number

  8-bit signed byte corresponding to `gl.BYTE` and the type of an element in `Int8Array`.
  Default Value: `0x1400`
  Source: Core/ComponentDatatype.js, line 38

#### staticconstantComponentDatatype.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`.
  Default Value: `0x140A`
  Source: Core/ComponentDatatype.js, line 91

#### staticconstantComponentDatatype.FLOAT :Number

  32-bit floating-point corresponding to `FLOAT` and the type of an element in `Float32Array`.
  Default Value: `0x1406`
  Source: Core/ComponentDatatype.js, line 78

#### staticconstantComponentDatatype.SHORT :Number

  16-bit signed short corresponding to `SHORT` and the type of an element in `Int16Array`.
  Default Value: `0x1402`
  Source: Core/ComponentDatatype.js, line 58

#### staticconstantComponentDatatype.UNSIGNED_BYTE :Number

  8-bit unsigned byte corresponding to `UNSIGNED_BYTE` and the type of an element in `Uint8Array`.
  Default Value: `0x1401`
  Source: Core/ComponentDatatype.js, line 48

#### staticconstantComponentDatatype.UNSIGNED_SHORT :Number

  16-bit unsigned short corresponding to `UNSIGNED_SHORT` and the type of an element in `Uint16Array`.
  Default Value: `0x1403`
  Source: Core/ComponentDatatype.js, line 68

### Methods

#### staticComponentDatatype.createArrayBufferView(componentDatatype, buffer, byteOffset, length) → Int8Array|Uint8Array|Int16Array|Uint16Array|Float32Array|Float64Array

  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.
  Source: Core/ComponentDatatype.js, line 231

#### staticComponentDatatype.createTypedArray(componentDatatype, valuesOrLength) → Int8Array|Uint8Array|Int16Array|Uint16Array|Float32Array|Float64Array

  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);

  Source: Core/ComponentDatatype.js, line 192

#### staticComponentDatatype.fromTypedArray(array) → ComponentDatatype

  Gets the ComponentDatatype for the provided TypedArray instance.

  Name | Type | Description
  --- | --- | ---
  `array` | TypedArray | The typed array.

  ##### Returns:

  The ComponentDatatype for the provided array, or undefined if the array is not a TypedArray.
  Source: Core/ComponentDatatype.js, line 137

#### staticComponentDatatype.getSizeInBytes(componentDatatype) → Number

  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);

  Source: Core/ComponentDatatype.js, line 106

#### staticComponentDatatype.validate(componentDatatype) → Boolean

  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.');
      }

  Source: Core/ComponentDatatype.js, line 169