orbital-engine
    Preparing search index...

    Function thinByScreenProximity

    • Greedy screen-space declutter: processes candidates from highest priority (lowest number) to lowest, keeping one unless it falls within minSeparationPx of an already-kept, higher-priority candidate. This is the shared algorithm behind both label declutter (computeVisibleLabels, below — "Sun > Earth > Moon" wins when their labels would otherwise land on top of each other) and body-visibility proximity thinning (see ProximitySelector in OrbitalSystemScene.tsx, which runs this same pass over rendered body dots, not just their text labels) — both are exactly the same problem: too many things projected too close together on screen, thin by priority, don't care what the things actually are. Ties (equal priority, e.g. two sibling moons) resolve by whichever appears first in the input.

      Kept candidates are bucketed into a grid of minSeparationPx-sized cells, so each candidate only checks the 3×3 cells around it rather than every kept candidate — O(n) per frame instead of O(n²) for a dense system, with exactly the same result (anything within minSeparationPx of a point is, by construction, in one of those nine cells).

      Parameters

      Returns Set<string>