orbital-engine
    Preparing search index...

    Function distanceToFit

    • Camera distance that fits a world-space radius comfortably in view, for the default 50° vertical FOV — same idea as fitting a frustum, just solved for a perspective camera's distance instead of an orthographic zoom factor.

      The floor here used to be a flat 0.3, which made it physically impossible to ever zoom close enough to tell a true-scale body like the ISS apart from Earth (real bodies here run many orders of magnitude smaller than 0.3 — the ISS's own radius is ~5×10⁻⁸ world units, see scale.ts's trueRadius) — exactly the case true scale + bubble-cursor selection exists to make possible. Floored now via minCameraDistanceForRadius, derived from the SAME worldRadius being fit — not one fixed constant — so fitting a tiny leaf body (nothing orbiting it, framing 4x its own radius) doesn't get dragged back out to a floor sized for a whole solar system. See minCameraDistanceForRadius's own comment for why a fixed floor was the actual reason zoom felt capped even after true scale landed.

      Parameters

      • worldRadius: number
      • marginFactor: number = 2.2

      Returns number