Skip to content

Class: PickIdLayout<T> ​

Experimental

Contiguous id-range layout, rebuilt for every pick: each pickable draw gets size ids starting right after the previous one (instanced markers need one per instance, meshes one per vertex / triangle / instance, or one for the whole object). Rebuilding per pick keeps the id space compact with no bookkeeping when counts change, and costs O(pickables). Ranges are stored in reused arrays, so the steady state does not allocate.

Type Parameters ​

Type Parameter
T

Constructors ​

Constructor ​

ts
new PickIdLayout<T>(): PickIdLayout<T>;

Experimental

Returns ​

PickIdLayout<T>

Accessors ​

count ​

Get Signature ​

ts
get count(): number;

Experimental

Number of ranges.

Returns ​

number


total ​

Get Signature ​

ts
get total(): number;

Experimental

Total ids allocated.

Returns ​

number

Methods ​

allocate() ​

ts
allocate(entry, size): number;

Experimental

Append a range of size ids for entry and return its base id.

Parameters ​

ParameterType
entryT
sizenumber

Returns ​

number

Throws ​

RangeError when the id space (2³² − 1 ids) is exhausted.


lookup() ​

ts
lookup(id, out): boolean;

Experimental

Find the range containing id (binary search; bases are ascending). Writes it into out and returns true, or returns false when no range contains id.

Parameters ​

ParameterType
idnumber
outPickIdRange<T>

Returns ​

boolean


reset() ​

ts
reset(): void;

Experimental

Forget all ranges (keeps capacity).

Returns ​

void

Released under the MIT License.