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.
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:
-
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:
Methods
-
<static> encode
-
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
highandlowproperties for the high and low bits, respectively.The fixed-point encoding follows Precisions, Precisions.
Parameters:
Name Type Argument Description valueNumber The floating-point value to encode. resultObject <optional>
The object onto which to store the result. Throws:
DeveloperError : value is required.Returns:
Object The modified result parameter or a new instance if one was not provided.Example
var value = 1234567.1234567; var splitValue = EncodedCartesian3.encode(value);
-
<static> fromCartesian
-
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 cartesianCartesian3 The cartesian to encode. resultEncodedCartesian3 <optional>
The object onto which to store the result. Throws:
DeveloperError : cartesian is required.Returns:
EncodedCartesian3 The modified result parameter or a new EncodedCartesian3 instance if one was not provided.Example
var cart = new Cartesian3(-10000000.0, 0.0, 10000000.0); var encoded = EncodedCartesian3.fromCartesian(cart);
-
<static> writeElements
-
Encodes the provided
cartesian, and writes it to an array withhighcomponents followed bylowcomponents, 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 cartesianCartesian3 The cartesian to encode. cartesianArrayArray The array to write to. indexNumber The index into the array to start writing. Six elements will be written. Throws:
-
DeveloperError : cartesian is required.
-
DeveloperError : cartesianArray is required.
-
DeveloperError : index must be a number greater than or equal to 0.
Example
var positions = [ new Cartesian3(), // ... ]; var encodedPositions = new Float32Array(2 * 3 * positions.length); var j = 0; for (var i = 0; i < positions.length; ++i) { EncodedCartesian3.writeElement(positions[i], encodedPositions, j); j += 6; } -
