Reference · The Sun, Moon and planets: pure parts
createTrackfunction
Answers for any moment from two real ones: at(ms) asks astronomy-engine only when ms leaves the span the last two answers cover, and then looks
stepMs ahead, so playing time at a steady rate costs one pair of lookups every stepMs and every draw in between is arithmetic.
Import it
import { createTrack } from "@johnmorrisdotca/chikyu-earth/space";
Definition
function createTrack(initialStepMs?: number): { at(ms: number): Frame; ends(): [Frame, Frame] | undefined; readonly lookups: number; reset(): void; setStep(ms: number): void; }
Parameters
| Name | Type | Description |
|---|---|---|
initialStepMs (optional) | number | How far ahead the second answer looks, in milliseconds. |
Returns
{ at(ms: number): Frame; ends(): [Frame, Frame] | undefined; readonly lookups: number; reset(): void; setStep(ms: number): void; }
A track: at(ms) for a frame, lookups for how many times the ephemeris was asked, ends() for the two answers it is between (undefined before the first at), reset() and setStep(ms).
Examples
import { createTrack } from "@johnmorrisdotca/chikyu-earth/space";
const track = createTrack(1000);
const start = Date.UTC(2026, 10, 2);
for (let step = 0; step < 10; step += 1) track.at(start + step * 50);
console.log(track.lookups);2What it prints (run when this page was built)