import { GroundStation } from '../types'; import { Satellite } from '../3d/ZenSpace3DTypes'; /** * Minimal client interface this hook depends on. Compatible with the * `zendir-ts` `ZendirClient` surface but typed structurally so the hook * can be used with any compatible client (e.g. a test fake). */ export interface SimulationSceneClient { getSimulationStructure(simulationId: string, containerId?: string, opts?: { signal?: AbortSignal; retry?: unknown; }): Promise>; getProperties(objectId: string, properties: string | string[], containerId?: string, opts?: { signal?: AbortSignal; retry?: unknown; }): Promise; getAllProperties(objectId: string, containerId?: string, opts?: { signal?: AbortSignal; retry?: unknown; }): Promise>; } export interface UseSimulationSceneOptions { /** ZendirClient (or any compatible client). Pass `null` to defer. */ client: SimulationSceneClient | null; /** Container ID hosting the simulation. */ containerId: string; /** Simulation ID to introspect. */ simulationId: string; /** Polling interval in ms for spacecraft positions. Default: 2000. */ pollIntervalMs?: number; /** Pause polling without unmounting. Default: true. */ enabled?: boolean; } export interface SimulationSceneObject { id: string; name: string; kind: "spacecraft" | "groundStation" | "celestialBody"; } /** * Lightweight diagnostic snapshot of the raw `getSimulationStructure` * response — useful for debugging parsing mismatches in the UI without * shipping the full raw blob. */ export interface StructureDiag { /** Every top-level key the engine returned (e.g. "Objects","objects","Time"). */ topLevelKeys: string[]; /** Length of the `Objects` / `objects` array in the raw response (-1 if absent). */ rawObjectCount: number; /** Length of the `Systems` / `systems` array in the raw response (-1 if absent). */ rawSystemCount: number; } /** * Per-tick diagnostic — answers "did the position fetch succeed and what came back?". * Surfaced in the debug UI so a failed-but-silent tick (parser miss, engine * returning a different property name, all-zero positions, etc.) is visible. */ export interface PositionTickDiag { /** Wall-clock instant of the most recent tick attempt. */ attemptedAt: Date; /** Number of spacecraft IDs the tick requested positions for. */ requested: number; /** Number of position responses that parsed successfully. */ parsedOk: number; /** Number of position responses that arrived but couldn't be parsed. */ parseFailed: number; /** Number of position responses rejected by the SDK (network / 4xx / 5xx). */ requestFailed: number; /** * The exact property names this tick asked the engine for. `null` means * the schema probe failed and the tick fell back to `getAllProperties`. * Surfaced so the debug UI can show which schema variant is in use. */ requestedProps: string[] | null; /** All keys present on the first satellite's response (helps spot wrong property names). */ firstResponseKeys: string[]; /** Compact JSON of the first satellite's raw response (capped to 200 chars). */ firstResponseSample: string; } export interface UseSimulationSceneResult { /** Spacecraft with live ECI position/velocity (km, km/s). */ satellites: Satellite[]; /** Static ground stations (lat/lon). */ groundStations: GroundStation[]; /** * Celestial bodies (planets, moons, sun) with live ECI positions in km. * The simulation's central body is filtered out — Cesium renders it * natively as the focal globe. Pass directly to * ``. */ celestialBodies: CelestialBody[]; /** Objects discovered from `getSimulationStructure` (for diagnostics/UI lists). */ objects: SimulationSceneObject[]; /** True until the first structure fetch resolves. */ isLoading: boolean; /** * Set when the structure-fetch fails (polling stops). Per-tick * polling errors do NOT surface here — they retry silently to keep * the UI from flapping during transient network blips. */ error: string | null; /** Re-run structure fetch and a position tick. */ refresh: () => Promise; /** * UTC `Date` representing wall-clock at the most recent successful * tick. Pass straight into `` so * ECI/J2000 positions rotate to ECEF at "now". */ referenceDate: Date; /** * Diagnostic snapshot of the raw structure response — null until the * first fetch resolves. Use in debug panels to verify key casing and * array lengths returned by the engine. */ structureDiag: StructureDiag | null; /** * Diagnostic for the most recent position-polling tick — null until * the first tick has run. Use in debug panels to verify that * `getProperties` is actually returning parsable position vectors. */ positionTickDiag: PositionTickDiag | null; } export declare function useSimulationScene(options: UseSimulationSceneOptions): UseSimulationSceneResult; export default useSimulationScene; /** * Celestial body with the position polled from the engine's `Position` * property (in km, ECI), suitable to feed straight into * ``. The simulation's central body * (e.g. Earth in Earth-centric sims) is filtered out — Cesium renders * the focal globe natively, so emitting it as a marker would collide. */ export interface CelestialBody { id: string; name: string; /** ECI position in km. */ position: { x: number; y: number; z: number; }; }