AttributeCompression

Attribute compression and decompression functions.

Methods

static Cesium.AttributeCompression.compressTextureCoordinates(textureCoordinates) → number

Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.
Name Type Description
textureCoordinates Cartesian2 The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.
Returns:
The packed texture coordinates.

static Cesium.AttributeCompression.decodeRGB8(encoded, result) → Color

Decodes RGB values at 8-bit precision from a signle float, equivalent to 0xFFFFFF representation in JavaScript. Perceptually near-lossless in the "srgb" color space; "srgb-linear" and wide-gamut color spaces benefit from 10+ bit precision.
Name Type Description
encoded number
result Color
Returns:

static Cesium.AttributeCompression.decodeRGB565(typedArray, result)

Decode RGB565-encoded colors into a floating point typed array containing normalized RGB values.
Name Type Description
typedArray Uint16Array Array of RGB565 values
result Float32Array optional Array to store the normalized VEC3 result

static Cesium.AttributeCompression.decompressTextureCoordinates(compressed, result) → Cartesian2

Decompresses texture coordinates that were packed into a single float.
Name Type Description
compressed number The compressed texture coordinates.
result Cartesian2 The decompressed texture coordinates.
Returns:
The modified result parameter.

static Cesium.AttributeCompression.dequantize(typedArray, componentDatatype, type, count) → Float32Array

Dequantizes a quantized typed array into a floating point typed array.
Name Type Description
typedArray Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array The typed array for the quantized data.
componentDatatype ComponentDatatype The component datatype of the quantized data.
type AttributeType The attribute type of the quantized data.
count number The number of attributes referenced in the dequantized array.
Returns:
The dequantized array.
See:

static Cesium.AttributeCompression.encodeRGB8(color) → number

Encodes RGB values at 8-bit precision into a single float, equivalent to 0xFFFFFF representation in JavaScript. Perceptually near-lossless in the "srgb" color space; "srgb-linear" and wide-gamut color spaces benefit from 10+ bit precision.
Name Type Description
color Color
Returns:

static Cesium.AttributeCompression.octDecode(x, y, result) → Cartesian3

Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.
Name Type Description
x number The x component of the oct-encoded unit length vector.
y number The y component of the oct-encoded unit length vector.
result Cartesian3 The decoded and normalized vector.
Returns:
The decoded and normalized vector.
Throws:
  • DeveloperError : x and y must be an unsigned normalized integer between 0 and 255.
See:

static Cesium.AttributeCompression.octDecodeFloat(value, result) → Cartesian3

Decodes a unit-length vector in 'oct' encoding packed in a floating-point number to a normalized 3-component vector.
Name Type Description
value number The oct-encoded unit length vector stored as a single floating-point number.
result Cartesian3 The decoded and normalized vector
Returns:
The decoded and normalized vector.

static Cesium.AttributeCompression.octDecodeFromCartesian4(encoded, result) → Cartesian3

Decodes a unit-length vector in 4 byte 'oct' encoding to a normalized 3-component vector.
Name Type Description
encoded Cartesian4 The oct-encoded unit length vector.
result Cartesian3 The decoded and normalized vector.
Returns:
The decoded and normalized vector.
Throws:
  • DeveloperError : x, y, z, and w must be unsigned normalized integers between 0 and 255.
See:

static Cesium.AttributeCompression.octDecodeInRange(x, y, rangeMax, result) → Cartesian3

Decodes a unit-length vector in 'oct' encoding to a normalized 3-component vector.
Name Type Description
x number The x component of the oct-encoded unit length vector.
y number The y component of the oct-encoded unit length vector.
rangeMax number The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
result Cartesian3 The decoded and normalized vector
Returns:
The decoded and normalized vector.
Throws:
  • DeveloperError : x and y must be unsigned normalized integers between 0 and rangeMax.
See:

static Cesium.AttributeCompression.octEncode(vector, result) → Cartesian2

Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding.
Name Type Description
vector Cartesian3 The normalized vector to be compressed into 2 byte 'oct' encoding.
result Cartesian2 The 2 byte oct-encoded unit length vector.
Returns:
The 2 byte oct-encoded unit length vector.
Throws:
See:

static Cesium.AttributeCompression.octEncodeFloat(vector) → number

Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding and stores those values in a single float-point number.
Name Type Description
vector Cartesian3 The normalized vector to be compressed into 2 byte 'oct' encoding.
Returns:
The 2 byte oct-encoded unit length vector.
Throws:

static Cesium.AttributeCompression.octEncodeInRange(vector, result, rangeMax) → Cartesian2

Encodes a normalized vector into 2 SNORM values in the range of [0-rangeMax] following the 'oct' encoding. Oct encoding is a compact representation of unit length vectors. The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors", Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
Name Type Description
vector Cartesian3 The normalized vector to be compressed into 2 component 'oct' encoding.
result Cartesian2 The 2 component oct-encoded unit length vector.
rangeMax number The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
Returns:
The 2 component oct-encoded unit length vector.
Throws:
See:

static Cesium.AttributeCompression.octEncodeToCartesian4(vector, result) → Cartesian4

Name Type Description
vector Cartesian3 The normalized vector to be compressed into 4 byte 'oct' encoding.
result Cartesian4 The 4 byte oct-encoded unit length vector.
Returns:
The 4 byte oct-encoded unit length vector.
Throws:
See:

static Cesium.AttributeCompression.octPack(v1, v2, v3, result) → Cartesian2

Encodes three normalized vectors into 6 SNORM values in the range of [0-255] following the 'oct' encoding and packs those into two floating-point numbers.
Name Type Description
v1 Cartesian3 A normalized vector to be compressed.
v2 Cartesian3 A normalized vector to be compressed.
v3 Cartesian3 A normalized vector to be compressed.
result Cartesian2 The 'oct' encoded vectors packed into two floating-point numbers.
Returns:
The 'oct' encoded vectors packed into two floating-point numbers.

static Cesium.AttributeCompression.octPackFloat(encoded) → number

Packs an oct encoded vector into a single floating-point number.
Name Type Description
encoded Cartesian2 The oct encoded vector.
Returns:
The oct encoded vector packed into a single float.

static Cesium.AttributeCompression.octUnpack(packed, v1, v2, v3)

Decodes three unit-length vectors in 'oct' encoding packed into a floating-point number to a normalized 3-component vector.
Name Type Description
packed Cartesian2 The three oct-encoded unit length vectors stored as two floating-point number.
v1 Cartesian3 One decoded and normalized vector.
v2 Cartesian3 One decoded and normalized vector.
v3 Cartesian3 One decoded and normalized vector.

static Cesium.AttributeCompression.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer)

Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.
Name Type Description
uBuffer Uint16Array The buffer view of u values.
vBuffer Uint16Array The buffer view of v values.
heightBuffer Uint16Array optional The buffer view of height values.
See:
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.