Galaxy View

3D star map showing all star systems at galactic scale.

Purpose

Galaxy View is a top-level view (peer to Cockpit, Map, Fleet, and Admin) that displays all known star systems in a 3D navigable star map. It provides situational awareness of the galaxy as multi-system support comes online.

Initially shows only Sol; additional systems (Alpha Centauri, Barnard’s Star) light up as they are added in later phases.

Scale Convention

  • 1 unit = 1 light-year in the Galaxy View scene
  • System positions from sharedConfig.SYSTEMS use meters; convert to ly by dividing by 9.461e15 (meters per light-year)
  • Sol is at origin (0, 0, 0)

Star Rendering

Each system is rendered as a THREE.Group containing:

Element Geometry Material Notes
Star sphere SphereGeometry(0.15) MeshBasicMaterial Color from star_color in shared config
Glow sprite SpriteMaterial AdditiveBlending, opacity 0.6 Procedural radial gradient texture (64×64 canvas)
Pulse ring RingGeometry MeshBasicMaterial Only on current system; animated opacity

Glow Texture

Procedural 64×64 canvas with radial gradient: white center → transparent edge. Cached as class property, shared by all star sprites. Scale (1.2, 1.2, 1).

Labels

CSS2DObject labels below each star showing:

  • System name (bold)
  • Spectral type (dimmed)
  • Distance from Sol in light-years

Label classes: galaxy-star-label, galaxy-star-name, galaxy-star-type, galaxy-star-dist.

Camera

  • PerspectiveCamera(60, aspect, 0.01, 10000)
  • Initial position: (0, 5, 10) looking at origin
  • OrbitControls with damping, minDistance 0.5, maxDistance 500
  • Camera position/target persisted to settings.galaxyCamera
  • Restored on re-entry; centered on current system on first activation

Selection

  • Raycaster click handler on renderer canvas
  • Click on star sphere → select system, show info panel
  • Click on empty space → clear selection

Grid

  • GridHelper(20, 20) on XZ plane
  • Each grid square = 1 ly
  • Dim gray color

Lighting

  • Ambient light (dim) for baseline visibility
  • Point light at origin with sun-like warmth

Connection Lines

  • THREE.Line with LineDashedMaterial between each pair of systems
  • Only drawn when ≥2 systems exist
  • Shows interstellar routes/distances

Info Panel

#galaxy-info-panel (mirrors #map-info-panel styling):

  • System name (header)
  • Spectral type
  • Distance from Sol
  • Body count (from server)
  • Player count (from server)
  • “Current System” badge if applicable

Server Integration

  • sendRequestSystems() sends { type: 'request_systems' } on activate
  • Server responds with galaxy:systems message containing system data (body counts, player counts)
  • View merges server data with sharedConfig.SYSTEMS for rendering
  • View menu item: “Galaxy View” (after Fleet View)
  • Data action: toggle-galaxy-view
  • Keyboard shortcut: G
  • Checkmark when active

System Preview (Double-Click)

Double-clicking a star in Galaxy View opens a read-only Map View snapshot of that system. This lets players inspect remote systems without affecting their own ship or active system.

Interaction

  • Double-click a remote system: Sends request_system_snapshot to the server, which responds with a one-shot system_snapshot containing all bodies, ships, stations, and jump gates for that system. The client switches to Map View in read-only “remote mode”.
  • Double-click own system: Switches to the normal (live) Map View instead (dispatches switch-cockpit-view then toggle-map-view).
  • Click debounce: Single-click uses a 250ms timeout; double-click cancels the pending single-click to prevent both firing.

Remote Mode (Map View)

When Map View is in remote mode:

  • Static snapshot: No continuous tick updates — entities are frozen at the moment the snapshot was taken.
  • No targeting: Click-to-target is disabled; no target selection or server notifications.
  • No extrapolation: Position extrapolation is skipped.
  • State routing guard: Live state messages are not routed to Map View.
  • Preview banner: A fixed banner at the top of the screen displays “PREVIEW — [System Name] — Press Escape to return”.
  • Escape to return: Pressing Escape clears remote state and switches back to Galaxy View.

Data Flow

Galaxy View dblclick → sendRequestSystemSnapshot(systemId)
                     → server fetches bodies/ships/stations/gates for system
                     → responds with { type: "system_snapshot", ... }
                     → main.js populates remote state fields
                     → switches to Map View in remote mode
                     → MapView rebuilds from remote state (read-only)
                     → Escape/back → switchView('galaxy')

Remote State Fields (state.js)

remoteSystemId       — system_id being previewed, null when not in preview
remoteBodyData       — name → body data (snapshot)
remoteShipStates     — ship_id → ship data (snapshot)
remoteStationStates  — station_id → station data (snapshot)
remoteJumpgateStates — jumpgate_id → jumpgate data (snapshot)

View Lifecycle

  • activate(): Show renderers, resize, request systems, rebuild scene, center camera on first activation
  • deactivate(): Save camera, hide renderers, remove listeners, hide info panel
  • animate(): Early exit if inactive; animate pulse ring; update controls; render scene + CSS overlay

Back to top

Galaxy — Kubernetes-based multiplayer space game

This site uses Just the Docs, a documentation theme for Jekyll.