EncodedCartesian3

new EncodedCartesian3()

A fixed-point encoding of a Cartesian3 with 64-bit floating-point components, as two Cartesian3 values that, when converted to 32-bit floating-point and added, approximate the original input.

This is used to encode positions in vertex buffers for rendering without jittering artifacts as described in Precisions, Precisions.

See:

Members

high :Cartesian3

The high bits for each component. Bits 0 to 22 store the whole value. Bits 23 to 31 are not used.

The default is Cartesian3.ZERO.

Default Value: Cartesian3.ZERO

low :Cartesian3

The low bits for each component. Bits 7 to 22 store the whole value, and bits 0 to 6 store the fraction. Bits 23 to 31 are not used.

The default is Cartesian3.ZERO.

Default Value: Cartesian3.ZERO

Methods

staticEncodedCartesian3.encode(value, result)Object

Encodes a 64-bit floating-point value as two floating-point values that, when converted to 32-bit floating-point and added, approximate the original input. The returned object has high and low properties for the high and low bits, respectively.

The fixed-point encoding follows Precisions, Precisions.

Name Type Description
value Number The floating-point value to encode.
result Object optional The object onto which to store the result.
Returns:
The modified result parameter or a new instance if one was not provided.
Example:
var value = 1234567.1234567;
var splitValue = Cesium.EncodedCartesian3.encode(value);

staticEncodedCartesian3.fromCartesian(cartesian, result)EncodedCartesian3

Encodes a Cartesian3 with 64-bit floating-point components as two Cartesian3 values that, when converted to 32-bit floating-point and added, approximate the original input.

The fixed-point encoding follows Precisions, Precisions.

Name Type Description
cartesian Cartesian3 The cartesian to encode.
result EncodedCartesian3 optional The object onto which to store the result.
Returns:
The modified result parameter or a new EncodedCartesian3 instance if one was not provided.
Example:
var cart = new Cesium.Cartesian3(-10000000.0, 0.0, 10000000.0);
var encoded = Cesium.EncodedCartesian3.fromCartesian(cart);

staticEncodedCartesian3.writeElements(cartesian, cartesianArray, index)

Encodes the provided cartesian, and writes it to an array with high components followed by low components, i.e. [high.x, high.y, high.z, low.x, low.y, low.z].

This is used to create interleaved high-precision position vertex attributes.

Name Type Description
cartesian Cartesian3 The cartesian to encode.
cartesianArray Number[] The array to write to.
index Number The index into the array to start writing. Six elements will be written.
Throws:
Example:
var positions = [
   new Cesium.Cartesian3(),
   // ...
];
var encodedPositions = new Float32Array(2 * 3 * positions.length);
var j = 0;
for (var i = 0; i < positions.length; ++i) {
  Cesium.EncodedCartesian3.writeElement(positions[i], encodedPositions, j);
  j += 6;
}