Phase 2c: eclipse/overpass calculators + live-map camera polish
CI / Lint, typecheck, test, build (pull_request) Failing after 9s
CI / Lint, typecheck, test, build (pull_request) Failing after 9s
Calculators (apps/live-map/src/calculators/): - eclipse.ts: findEclipseWindows(bodies, opts) — coarse scan with threshold-crossing detection, bisection to refine start/end, ternary search to find peak. Handles eclipse already in progress at scan-start. Uses sun = parentId===null body. - overpass.ts: findOverpasses(opts) — coarse scan for local distance minima, ternary refinement. Targets: vessel, body, ground station (lat/lon/alt → heliocentric). UI: - panels/CalculatorsPanel.tsx: collapsible bottom-center panel with two tabs. Eclipse form: observer, eclipser, from UT → 3 windows. Overpass form: observer vessel, target kind+id, max dist → 5 passes. - timeFormat.ts: shared KSP-time formatters. Live-map camera polish (apps/live-map/src/scene/): - camera.ts: CameraController — log-scale distance (z→exp(z)*1e8 m, range -3..12), spherical orbit around target, smooth lerp to selected body/vessel. Mouse wheel zooms, drag rotates, click raycasts for track toggle. Pointer-move-distance gate to distinguish click from drag. - glow.ts: additive shader-based atmospheric halo (rim-falloff fragment shader, BackSide) attached as child of body mesh. - layout.ts: bodyPositionAt now returns true heliocentric (walks parent chain); previous version returned parent-relative for non-root children which broke the eclipse calculator. Bug fix: - packages/orbital-math/src/occultation.ts: sign of projection check was inverted. `proj <= 0` correctly returns 0 (occluder behind observer), `proj > 0` triggers eclipse computation. Tests: 28 live-map tests (10 scene + 12 calculator + 6 camera), 45 total across the workspace, all passing.
This commit is contained in:
@@ -28,10 +28,14 @@ export function shadowFraction(
|
||||
const sy = observerToSun.y / sunDist;
|
||||
const sz = observerToSun.z / sunDist;
|
||||
|
||||
// Project occluder center onto the sun-direction line
|
||||
// Project occluder center onto the sun-direction line.
|
||||
// Both `observerToSun` and `occluderToObserver` point AWAY from
|
||||
// the observer (toward the sun / toward the occluder). When the
|
||||
// occluder sits between observer and sun, both vectors point in
|
||||
// roughly the same direction and `proj` is positive.
|
||||
const proj = occluderToObserver.x * sx + occluderToObserver.y * sy + occluderToObserver.z * sz;
|
||||
if (proj >= 0) {
|
||||
// Occluder is behind the observer relative to the sun → no eclipse
|
||||
if (proj <= 0) {
|
||||
// Occluder is behind the observer (opposite direction from sun) → no eclipse
|
||||
return 0;
|
||||
}
|
||||
// Perpendicular distance from occluder center to sun ray
|
||||
|
||||
Reference in New Issue
Block a user