generatePairID

View sourcegeneratePairID(idA: number, idB: number): string

Creates the stable string key used for an unordered entity pair.

Numeric IDs are written with the larger value first and separated by a space, so swapping the arguments produces the same key. Callers can use this key to track an unordered entity pair without depending on argument order. Equal IDs are allowed and produce a repeated value, such as "4 4". Inputs are interpolated into a string without validation or entity lookup; callers should pass the numeric entity indices used by the engine.

Examples

import { generatePairID } from '@wimaengine/narrowphase'

generatePairID(12, 3) === generatePairID(3, 12) // true
generatePairID(12, 3) // "12 3"

Parameters

NameDescriptionDefault
idA

Numeric index for the first entity.

—
idB

Numeric index for the second entity.

—

Returns

The pair key with the larger ID first.