astro.Function.nearestNebulae - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / astro / nearestNebulae
nearestNebulae(
coords,nebulae,count?):NebulaWithDistance[]
Defined in: src/astro/nebulae.ts:174
The nebulae closest to a point, nearest first.
The point to measure from, in light-years (Sol at origin). A
ProceduralSystem.position value fits once you have narrowed it — it is
GalacticPosition | null, and is null unless that system was built from an address
and you supplied its coordinates, so null-check it first.
readonly Nebula[]
The catalogue to search — REAL_NEBULAE, PLANETARY_NEBULAE,
PROCGEN_NEBULAE, ALL_NEBULAE, or any subset you have filtered yourself.
number = 3
How many to return. Defaults to 3. Fractional values are truncated
towards zero, values <= 0 and NaN yield an empty array, and a count larger than
the catalogue returns the whole catalogue.
Up to count nebulae sorted by ascending NebulaWithDistance.distanceLy.
Ties keep catalogue order. The input array is not modified.
import { nearestNebulae } from '@elite-dangerous-almanac/core/astro/nebulae';
import { REAL_NEBULAE } from '@elite-dangerous-almanac/core/astro/nebulae-real';
// The three real nebulae nearest Sol
nearestNebulae({ x: 0, y: 0, z: 0 }, REAL_NEBULAE).map((n) => n.name);
// -> [ 'Pleiades', 'R Cra', 'Lupus Dark Region B' ] (nearest first)
nearestNebulae({ x: 0, y: 0, z: 0 }, REAL_NEBULAE, 1)[0]?.distanceLy; // -> ≈383.31