KeyDesign
A design for octant keys.
3D coordinates are packed into a single integer to obtain a unique key. This class describes the bit allotment for each coordinate and provides methods for key packing and unpacking.
See KeyDesign.BITS for the total amount of available bits.
Static Member Summary
Static Public Members | ||
public static get |
The total amount of available bits for safe integers. |
|
public static get |
The amount of available bits in the high DWord. |
|
public static get |
The amount of available bits in the low DWord. |
Constructor Summary
Public Constructor | ||
public |
constructor(x: Number, y: Number, z: Number) Constructs a new key design. |
Member Summary
Public Members | ||
public |
halfRange: Vector3 The key range divided by two. |
|
public |
The amount of distinct integers that can be represented with X bits. |
|
public |
The amount of distinct integers that can be represented with X + Y bits. |
|
public |
The amount of distinct integers that can be represented with Y bits. |
|
public |
The amount of distinct integers that can be represented with Z bits. |
|
public |
The amount of bits reserved for the X-coordinate. |
|
public |
The amount of bits reserved for the Y-coordinate. |
|
public |
The amount of bits reserved for the Z-coordinate. |
Method Summary
Public Methods | ||
public |
keyRange(min: Vector3, max: Vector3): KeyIterator Returns a new key range iterator. |
|
public |
Packs a 3D position into a unique key. |
|
public |
Sets the bit distribution. |
|
public |
Converts the information of this key design into a string. |
|
public |
Extracts the 3D coordinates from a given key. |
Static Public Members
public static get BITS: Number source
The total amount of available bits for safe integers.
JavaScript uses IEEE 754 binary64 Doubles for Numbers and, as a result, only supports 53-bit integers as of ES2015.
For more information see: http://2ality.com/2012/04/number-encoding.html
Public Constructors
public constructor(x: Number, y: Number, z: Number) source
Constructs a new key design.
Params:
Name | Type | Attribute | Description |
x | Number |
|
The amount of bits used for the X-coordinate. |
y | Number |
|
The amount of bits used for the Y-coordinate. |
z | Number |
|
The amount of bits used for the Z-coordinate. |
Public Members
Public Methods
public keyRange(min: Vector3, max: Vector3): KeyIterator source
Returns a new key range iterator.
The key iterator will return all keys in the specified coordinate range, including those at min and max.
Params:
Name | Type | Attribute | Description |
min | Vector3 | The lower key index bounds (zero-based unsigned integer coordinates). |
|
max | Vector3 | The upper key index bounds (zero-based unsigned integer coordinates). |
public packKey(position: Vector3): Number source
Packs a 3D position into a unique key.
Params:
Name | Type | Attribute | Description |
position | Vector3 | A position. |
public set(x: Number, y: Number, z: Number) source
Sets the bit distribution.
Make sure to clear your octree after changing the key design!
public unpackKey(key: Number, target: Vector3): Vector3 source
Extracts the 3D coordinates from a given key.
Params:
Name | Type | Attribute | Description |
key | Number | The key. |
|
target | Vector3 |
|
A target for the extracted coordinates. If none is provided, a new vector will be created. |
Return:
Vector3 | The extracted coordinates. |