Body Color Pipeline Fix

Problem

Mars (and potentially other bodies) appears as a blue sphere (#6688ff) in the cockpit 3D view when far away. Two root causes:

  1. Color not propagated through physics service: The color field exists in ephemeris-j2000.json and the galaxy service proto, but the physics service CelestialBody model, Redis state, and BodyState proto all omit it. The api-gateway therefore cannot include color in tick broadcasts.

  2. Texture lazy-load distance threshold: Textures only load when the ship is within 200 * body.radius of the body. For distant targets (e.g., Mars at 350 Gm), the texture never loads and the fallback data.color || '#6688ff' is used. Since data.color is undefined (cause #1), the blue fallback shows.

Fix

1. Propagate color through physics pipeline

  • physics.proto BodyState: Add string color = 10
  • physics/src/models.py CelestialBody: Add color: str = ""
  • physics/src/redis_state.py: Include color in _body_to_mapping and get_body/get_all_bodies
  • physics/src/grpc_server.py InitializeBodies: Read b.color from proto; GetAllBodies: Include color in BodyState
  • api-gateway/src/websocket_manager.py: Include "color": b.color in body dict

2. Force-load texture for targeted body

  • web-client/src/cockpitView.js _checkTextureLoading(): If state.targetId is a body and its texture isn’t loaded, request it regardless of distance.

Back to top

Galaxy — Kubernetes-based multiplayer space game

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