WebGL component datatypes. Components are intrinsics,
which form attributes, which form vertices.
- Source:
Members
(static, constant) BYTE :Number
8-bit signed byte corresponding to
gl.BYTE
and the type
of an element in Int8Array
.
Type:
- Number
- Source:
(static, constant) FLOAT :Number
32-bit floating-point corresponding to
FLOAT
and the type
of an element in Float32Array
.
Type:
- Number
- Source:
(static, constant) SHORT :Number
16-bit signed short corresponding to
SHORT
and the type
of an element in Int16Array
.
Type:
- Number
- Source:
(static, constant) UNSIGNED_BYTE :Number
8-bit unsigned byte corresponding to
UNSIGNED_BYTE
and the type
of an element in Uint8Array
.
Type:
- Number
- Source:
(static, constant) UNSIGNED_SHORT :Number
16-bit unsigned short corresponding to
UNSIGNED_SHORT
and the type
of an element in Uint16Array
.
Type:
- Number
- Source:
Methods
(static) createArrayBufferView(componentDatatype, buffer, byteOffsetopt, lengthopt) → {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array}
Creates a typed view of an array of bytes.
Parameters:
Name | Type | Attributes | 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. |
- Source:
Throws:
-
componentDatatype is not a valid value.
- Type
- DeveloperError
Returns:
A typed array view of the buffer.
- Type
- Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array
(static) createTypedArray(componentDatatype, valuesOrLength) → {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array}
Creates a typed array corresponding to component data type.
Parameters:
Name | Type | Description |
---|---|---|
componentDatatype |
ComponentDatatype | The component data type. |
valuesOrLength |
Number | Array | The length of the array to create or an array. |
- Source:
Throws:
-
componentDatatype is not a valid value.
- Type
- DeveloperError
Returns:
A typed array.
- Type
- Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array
Example
// creates a Float32Array with length of 100
var typedArray = Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, 100);
(static) fromName(name) → {ComponentDatatype}
Get the ComponentDatatype from its name.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the ComponentDatatype. |
- Source:
Throws:
-
name is not a valid value.
- Type
- DeveloperError
Returns:
The ComponentDatatype.
- Type
- ComponentDatatype
(static) fromTypedArray(array) → {ComponentDatatype}
Gets the
ComponentDatatype
for the provided TypedArray instance.
Parameters:
Name | Type | Description |
---|---|---|
array |
TypedArray | The typed array. |
- Source:
Returns:
The ComponentDatatype for the provided array, or undefined if the array is not a TypedArray.
- Type
- ComponentDatatype
(static) getSizeInBytes(componentDatatype) → {Number}
Returns the size, in bytes, of the corresponding datatype.
Parameters:
Name | Type | Description |
---|---|---|
componentDatatype |
ComponentDatatype | The component datatype to get the size of. |
- Source:
Throws:
-
componentDatatype is not a valid value.
- Type
- DeveloperError
Returns:
The size in bytes.
- Type
- Number
Example
// Returns Int8Array.BYTES_PER_ELEMENT
var size = Cesium.ComponentDatatype.getSizeInBytes(Cesium.ComponentDatatype.BYTE);
(static) validate(componentDatatype) → {Boolean}
Validates that the provided component datatype is a valid
ComponentDatatype
Parameters:
Name | Type | Description |
---|---|---|
componentDatatype |
ComponentDatatype | The component datatype to validate. |
- Source:
Returns:
true
if the provided component datatype is a valid value; otherwise, false
.
- Type
- Boolean
Example
if (!Cesium.ComponentDatatype.validate(componentDatatype)) {
throw new Cesium.DeveloperError('componentDatatype must be a valid value.');
}