EncodedCartesian3

EncodedCartesian3

new

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:
Source:

Members

: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

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:

Methods

<static>

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.

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

<static>

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.

Parameters:
Name Type Argument Description
cartesian Cartesian3 The cartesian to encode.
result EncodedCartesian3 <optional>
The object onto which to store the result.
Returns:
EncodedCartesian3 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);

<static>

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.

Parameters:
Name Type Description
cartesian Cartesian3 The cartesian to encode.
cartesianArray Array The array to write to.
index Number The index into the array to start writing. Six elements will be written.
Throws:
DeveloperError : index must be a number greater than or equal to 0.
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;
}