Variable segmentIndexConst
segmentIndex: (
length: number,
timeAt: (index: number) => number,
time: number,
) => number = ...
Type Declaration
-
- (length: number, timeAt: (index: number) => number, time: number): number
-
Parameters
- length: number
- timeAt: (index: number) => number
- time: number
Returns number
The lower index of the segment straddling
timein a strictly increasing sequence oflengthkey times read throughtimeAt: theloin `[0, lengthwithtimeAt(lo) <= time <= timeAt(lo + 1), resolving an exact hit on an interior key to the segment ENDING at it (sotime === timeAt(k)yieldslo === k - 1`). That tie rule reproduces the historical front-to-back linear scan the pose and track samplers used, so swapping this binary search in leaves every interpolated result byte-identical.Runs in
O(log length). The caller must already have handled the ends (time <= timeAt(0)andtime >= timeAt(length - 1)); this searches the strict interiortimeAt(0) < time < timeAt(length - 1), wherelength >= 2and the answer is in[0, length - 2].The accessor form (rather than a
readonly number[]) lets the pose sampler search keyframes without materializing a times array on the hot path.