tower / interior-flight / files / src / ui / scales.ts
Branch interior-flight · default branch · all branches
scales.ts
| 1 | /** |
| 2 | * Slider mappings shared by the panel and the views. |
| 3 | * |
| 4 | * This lives outside views/ on purpose: the panel needs the eye-height scale to |
| 5 | * label its slider before the interior view exists, and importing the view for it |
| 6 | * would statically pull Three.js into the entry chunk — the exact regression |
| 7 | * D-021 fixed for the exterior. |
| 8 | */ |
| 9 | |
| 10 | /** Standing eye height. */ |
| 11 | export const EYE_MIN_M = 1.7 |
| 12 | /** High enough to be a fifth of the way to the axis, and see the world as a tube. */ |
| 13 | export const EYE_MAX_M = 25_000 |
| 14 | |
| 15 | /** Eye height from a 0..1 slider position. Logarithmic, so 1.7 m is reachable. */ |
| 16 | export const eyeHeightFromSlider = (v: number): number => |
| 17 | EYE_MIN_M * (EYE_MAX_M / EYE_MIN_M) ** Math.min(1, Math.max(0, v)) |
| 18 | |
| 19 | export const sliderFromEyeHeight = (h: number): number => |
| 20 | Math.log(Math.max(EYE_MIN_M, h) / EYE_MIN_M) / Math.log(EYE_MAX_M / EYE_MIN_M) |