CosmosUI — interface and application integration
First vertical slice: the solar-system workstation. The window structure (sidebar, Metal viewport, inspector, timeline, toolbar, menus, preferences, methodology) is in place and driven by real ephemerides; later domains (stars, galaxies, laboratory, observatory, missions, studio) plug into the extension points of section 4.
swift build --scratch-path .build-ui --target CosmosUI
swift test --scratch-path .build-ui --filter CosmosUITests # 23 tests, 5 suites
Scripts/build.sh debug # app (xcodegen + xcodebuild)
Scripts/build.sh capture [dir] # 13 offscreen captures of the real window hierarchy
python3 Packages/CosmosUI/Tools/make_strings.py # regenerate the string catalogue (fails on a missing French text)1. Sources
| File | Role |
|---|---|
SolarSystemData.swift |
Loads core-ephemeris, missions and the planetary data set; list of bodies (BodyEntry: kind, parent, radii, position method, coverage); snapshot(at:lightTime:) → positions, velocities, orientations; orbit paths; ScaleSettings, LightTimeMode |
SceneAssembly.swift |
SceneAssembler: snapshot → SceneDescription (scene frame re-centred on the camera target, bodies, light, orbit lines, markers, labels) and the screen-space list used for picking and accessibility |
SceneResources.swift |
OrbitStore (orbit-line cache refreshed on a background task), TextureCatalog (registration of installed surface maps), SurfaceMapState |
CameraController.swift |
Free / orbit / follow / synchronous modes on the renderer's OrbitRig, FollowRig, FreeFlyRig; go-to flights; view history; ViewState |
TimeController.swift |
Transport over CosmosClock: rate ladder, exact steps, date parsing, read-outs, validity messages, recorded instants |
Inspector.swift |
InspectorBuilder → InspectorSnapshot (sections of DatumRow, provenance cards) |
Search.swift |
SearchEngine, SearchProvider, solar-system / coordinates / CatalogProvider providers, ranking, Naming |
Formatting.swift |
QuantityFormatter: unit systems, significant digits, locale separators, locale-independent copy text |
Localization.swift |
Localizer, L(key, english, args…), InterfaceLanguage |
PackLocation.swift |
PackLocating, DirectoryPackLocator, InstalledPack (manifest summary) |
Session.swift |
Preferences, CommandID + ShortcutBinding, SessionState, SessionStore |
AppModel.swift |
Main-actor state: per-frame assembly, 10 Hz read-outs, selection, navigation, session; the extension protocols |
Capture.swift |
--screenshot mode and the real-data benchmark scene |
Views/… |
CosmosRootView, toolbar, sidebar, inspector, timeline, viewport and input, search, welcome, methodology, preferences, CosmosCommands |
Resources/Localizable.xcstrings |
String catalogue, English and French (398 keys), generated by Tools/make_strings.py |
The application target (App/) only declares the scenes (main window, detached inspector and timeline, methodology,
settings), the menu bar (CosmosCommands) and the verification launch modes.
2. How a frame is built
Every frame, on the main actor (AppModel.frame):
SolarSystemData.snapshot(at:)— one ephemeris state per body, relative to the solar-system barycentre, ICRF, Double. Planets and the Sun come from DE440s; the Moon relative to the Earth; moons, dwarf planets, asteroids and comets from the osculating elements relative to their centre; the centres of Mars…Pluto through the ephemeris module'sPlanetCenterFromSatellites; spacecraft from the missions pack inside their coverage only. A body whose source does not cover the instant is marked unavailable and is not drawn. Outside the DE440s span everything that depends on the kernel is hidden and the interface says so.- Orientation: IAU rotation model of
pck00011.tpc(icrfToBodytransposed); the Earth usesCosmosCoordinates.EarthOrientation(IAU 2006 / 2000B, UT1 from the time system). - Optional light-time:
ApparentPosition.state(… correction: .lightTime)of the ephemeris module for every body as seen from the Earth; orientations are evaluated at the emission time. - Display positions: identical to the ephemeris in physical scale; in pedagogical scale moons are displaced
(
ScaleSettings.moonDisplacement). - The scene origin is the display position of the camera target: every position is
display − originin Double before the renderer narrows it. The camera pose comes from the rigs, relative to that origin. SceneAssembler.build: bodies (kernel radii, oblateness, textures when installed, atmosphere and rings from CosmosPlanetary), the Sun as emissive body and inverse-square light, orbit lines from the cache, markers, labels. Exposure = (distance of the target from the Sun in au)², so every planet is legible; line colours are divided by the exposure so that annotations look the same everywhere.
Orbit lines (SolarSystemData.orbitPaths): kernel bodies — the ephemeris trajectory relative to the parent over
one osculating period centred on the instant, 720 samples, open polyline, status computed, recomputed off the
main actor when the instant has moved by more than a quarter of the window (at most ten refreshes per second);
Keplerian bodies — the osculating ellipse of the installed elements, closed, status estimated (the renderer
draws it dashed); spacecraft — the sampled trajectory, one polyline per segment so that gaps stay gaps, relative
to the Earth for objects that never leave its neighbourhood (0.02 au). For Mars…Pluto the line is the trajectory
of the system barycentre.
Markers: a body whose displayed disc is under 3 pt gets a hollow ring of fixed screen size (a diamond for spacecraft), drawn without depth test; a resolved body is a filled disc. The legend states the difference. Labels have priorities selection 100 > Sun 90 > planets 80 > dwarf planets 60 > moons 50 > spacecraft 45 > small bodies 40 and fade with the apparent separation from the parent body (12 → 34 pt). Close to a body, the orbits, markers and labels of unrelated small bodies fade out.
Scale modes: physical (true sizes and distances); pedagogical (planets, moons and small bodies × N, default 300, Sun × min(N, 40) with its true total flux, every body lit as at 1 au, moons displaced by (N − 1)(R planet + R moon)), with the permanent badge "Enlarged ×N — not to scale".
3. Packs at runtime
DirectoryPackLocator.standard() searches, per pack, COSMOS_PACKS_DIR, then
~/Library/Application Support/ORIX Cosmos/Packs, then Contents/Resources/Packs of the bundle. project.yml
copies core-ephemeris, missions and textures-starter into the bundle as folders (about 70 MB of data; textures-hd
and sky-imagery are not embedded). Without core-ephemeris the model enters Phase.missingCore: a localised
panel lists the folders searched, nothing is drawn, the timeline, methodology and preferences still work.
PackLocating is the seam for CosmosDataPacks.PackStore.
4. Extension points for the next slices
| Need | Mechanism |
|---|---|
| Sidebar entries of a new domain | SidebarSectionProvider.sidebarSections() appended to AppModel.sidebarProviders (a domain appears only when its provider is registered) |
| Scene content (star fields, deep sky, grids, laboratory bodies) | SceneLayer.contribute(to:context:) in AppModel.sceneLayers; the context gives the instant, the barycentric origin to subtract in Double, the camera pose, the viewport and the scale mode |
| Inspector sections | InspectorSectionProvider.sections(for:at:formatter:) in AppModel.inspectorProviders |
| Search | any SearchProvider; CatalogSearchProvider(catalog) wraps a CatalogProvider — rebuild AppModel.searchEngine with it |
| Timeline events | TimelineEventProvider.events(in:) in AppModel.timelineProviders (ticks on the scrubber); recorded instants and the events of the selected mission are already there |
| Packs | another PackLocating passed to AppModel(packs:) |
| A new command with a shortcut | a case of CommandID (title, default binding) and one line in CosmosCommands |
| A new string | L("key", "English") in the code, the French text in Tools/make_strings.py, then run the script |
Selecting an object that the solar-system layer does not know (AppModel.perform with an unknown ObjectID) only
sets the selection: the owning domain must supply the go-to behaviour.
5. Verification
Unit and integration tests (Packages/CosmosUI/Tests, Swift Testing, run against Resources/Packs): 23 tests.
Among them: positions of the Earth, Moon, Mars and Titan in the snapshot equal to the ephemeris; the sub-solar
point of the Earth at 2025-03-20 12:00 UTC within 0.06° of the Astronomical Almanac low-precision solar formulas
(longitude −EoT = +1.87°, latitude +0.05°), both from the snapshot and from the assembled scene; coverage
enforcement (1970 for Voyager 1, 2200 for everything); light-time against apparentState; scale factors, badge
and moon displacement; markers, label priorities, rings; orbit lines against the ephemeris; search ranking and
coordinate parsing; formatting and "unknown"; rate ladder, exact steps, typed dates, validity warnings; camera
flights (monotonic, interruptible, Reduce Motion), modes, synchronous rotation, history, zoom range 3 m – 10¹⁷ m;
picking; inspector content and provenance; session round trip; preferences and shortcut reassignment; missing
core pack; pack priority order; orbit-cache refresh policy; every string present in both languages.
Captures: "ORIX Cosmos" --screenshot out.png --state … creates the real root view in an off-screen window of an
accessory application (never ordered in, never activated), draws the SwiftUI hierarchy with cacheDisplay, and
composites it over an offscreen render (renderImage) of the frame the viewport would draw, at the viewport's
size. A JSON side-car holds the accessibility summary, the inspector text and scene counts. Red night mode in a
capture is the same operation as the live tint (multiply by pure red) applied to the composite. Inspected on
2026-11-24 (in build/captures/): welcome (fr), overview (fr), Earth, Earth at the 2025 March equinox in
synchronous mode with apparent positions, Saturn with rings, enlarged Jupiter, New Horizons on 2015-07-14 in night
mode, year 2200 (fr, outside coverage), quick-search palette (fr, light appearance), methodology, preferences
(fr), missing core pack (fr).
Menus: open -g -j "ORIX Cosmos.app" --args --dump-menus out.json starts the real SwiftUI application hidden,
writes the menu bar (titles, key equivalents, check marks) and quits; checked in English and in French.
Not verified by a person or by an automated test: the live window on a display; mouse, trackpad and keyboard navigation (events cannot be injected without driving the session); the live red tint (a Core Animation compositing filter); the detached inspector and timeline windows; the shortcut recorder; full screen; VoiceOver.
6. Measured performance
"ORIX Cosmos" --benchmark 15 out.json --scene solar-system|solar-system-overview, Release build, 2026-11-24,
MacBook Pro Mac17,6 (Apple M5 Max, 18 cores, 48 GB), macOS 27.0, built-in display 120 Hz with EDR, drawable
3 456 × 2 234 px, MSAA 4×, render scale 1.00 (dynamic resolution off), 15 s after a 1.5 s warm-up, window ordered
behind the others, one-minute load average 12–13 (other builds running). Full records: Benchmarks/ui/*.json.
Earth close-up (solar-system) |
Whole system (solar-system-overview) |
|
|---|---|---|
| Content | 63 bodies assembled, Earth from 3.2 radii with albedo, clouds, night lights, specular mask, normal map, atmosphere; time 1 h/s; camera turning | 63 bodies, every orbit line, marker and label from 12 au; time 1 day/s; camera turning |
| Frame rate | 120.0 fps (display-limited), interval p99 9.45 ms | 120.0 fps, interval p99 9.07 ms |
| GPU time per frame | median 5.40 ms, p95 5.92, p99 6.15 | median 2.68 ms, p95 2.84, p99 2.88 |
| Renderer CPU per frame | median 0.28 ms, p99 0.44 | median 0.82 ms, p99 1.88 |
| Scene assembly on the main actor | median 0.20 ms, p95 0.26, p99 0.32, max 0.49 | median 0.18 ms, p95 0.22, p99 0.25, max 0.29 |
| Work | 25 draw calls, 25 289 triangles | 82 draw calls, 93 299 triangles |
| Orbit-cache refreshes (background) | 1 | 3 |
| Memory | textures 92 MB, footprint 1 078 MB | textures 17 MB, footprint 1 009 MB |
In a Debug build the assembly takes about 1.0–1.2 ms per frame. The inspector, the time read-outs and the accessibility summary are rebuilt ten times per second by a separate task and assigned only when they changed.
7. Partial and not implemented
- Stars and sky background: none; the sky is black. CosmosCatalog is not integrated (
CatalogSearchProviderexists, no provider is registered). - Astronomical events (eclipses, conjunctions): not wired; the timeline shows recorded instants and the events of the selected mission only.
- CosmosDataPacks: not used; packs are found by direct directory lookup behind
PackLocating. No pack manager. - Laboratory, cosmology, observatory, missions tour, studio: no navigation entry (left out until they exist).
- Light-time observer: the Earth only. Stellar aberration is not applied in the 3D view.
- Resolution scale: the renderer exposes dynamic resolution only; the preference is on/off plus a minimum scale, not a fixed scale. MSAA, the frame-rate cap and texture quality apply when the viewport is created.
- Increase Contrast: nothing specific beyond the system colours and materials.
- Localisation gaps: mission event labels, credits, licence texts and notes of the data sets stay in the language of the source (English). Window titles follow the language at launch.
- Pedagogical scale: moons end up close to their enlarged planet (the true surface gap is small compared with the enlarged sizes); spacecraft keep their true positions and can be inside an enlarged body (their marker stays visible).
- Estimated status of Mars…Pluto: their centre uses the satellite-based estimate; a satellite kernel pack would
make them
computed. - Uncertainties: shown for the physical values that carry one; none for positions.
- UI tests: no XCUITest was written.
- Window restoration: the session (camera, time, selection, panels, modes, favourites) is saved every two seconds and at quit, and restored at launch; window frames are left to macOS.
8. Requests to other modules
- CosmosRender: a fixed render-scale setting; a screen-space marker primitive and exposure-independent polylines (the interface builds rings as polylines and divides colours by the exposure); a picking query.
- CosmosEphemeris: expose names and kinds of the bodies of
kepler_elements.json(the interface re-reads the file); aBodyFixedRotationProviderconformance forPlanetaryConstants; a satellite-kernel pack. - CosmosPlanetary: albedo of ring segments where published (rings without one are neutral grey); localised names are held by the interface.
- CosmosDataPacks: a
PackLocatingadapter overPackStore. - CosmosAstrodynamics: a
TimelineEventProvider.