Class CesiumViewer

Class Documentation

class CesiumViewer

Public Functions

CesiumViewer(int port = 8080, const std::string &host = "127.0.0.1")

Construct a Cesium-based 3D visualization server.

Created by Simulation::Init (see lupnt/core/simulation.h, GetCesiumViewer) when the simulation config enables Cesium output; agents (e.g. Satellite) then call AddEntity each step to stream their trajectory to the served CZML viewer. Requires the CESIUM_TOKEN environment variable to be set; copies and patches the CesiumViewer/index.html template (with the token substituted) into the local cache directory.

Parameters:
  • port – Local TCP port to serve the viewer on

  • host – Host/IP address to bind the server to

~CesiumViewer()

Stops the server (if running) and releases resources.

void Run()

Start the Cesium web server on a background thread.

Called once after construction (typically by Simulation::Init) so the viewer is reachable at <host>:<port> for the remainder of the simulation run.

void AddEntity(const VecX &times, const MatX3 &positions, const std::string &entity_id = "Entity", const std::string &name = "Entity", const std::vector<int> &color = {255, 0, 255}, const std::string &description = "Entity orbit", BodyId body_id = BodyId::MOON, int size = 5)

Register (or replace) a trajectory entity to be displayed in the Cesium viewer.

Called once per agent (and again whenever its propagated trajectory is updated) to push the agent’s time history of positions for rendering as a CZML path; served on request via /entities/<id>.czml.

Parameters:
  • times – Sample times [s, elapsed since the simulation’s initial UTC epoch]

  • positions – Body-fixed (body_id’s “FIXED” frame) positions [m], one row per sample (x, y, z columns)

  • entity_id – Unique identifier for the entity (used in CZML and the /entities/<id>.czml route)

  • name – Display name shown in the Cesium viewer

  • color – RGB color {r, g, b} (0-255) used for the point and path

  • description – Text description shown in the entity’s info box

  • body_id – Central body the positions are expressed relative to (sets the CZML reference body)

  • size – Point marker size [pixels]

void ClearEntities()

Remove all registered entities from the viewer.

void Stop()

Stop the background server thread started by Run.