Refactor Viewer to be a base class owning the communication with the simulation, handler registry, core visualization objects and the render function

ViewerApp is simplified, interacting with the endpoint and handlers through the Viewer instance. This change makes it possible to write simulation viewers without using the UI/UX provided by ViewerApp (which should be renamed StudioApp)

PiperOrigin-RevId: 943642660
Change-Id: Id8eb3d4e6a27ceda93833367fec4699fa6bc838e
This commit is contained in:
Matija Kecman
2026-07-06 20:49:58 -07:00
committed by Copybara-Service
parent ae58855c15
commit 8079ab3d4d
9 changed files with 384 additions and 322 deletions
+17 -1
View File
@@ -116,9 +116,25 @@ class ResetEvent(Event):
@dataclasses.dataclass(frozen=True)
class ModelEvent(Event):
"""An event that transports a MuJoCo model."""
"""An event that transports a MuJoCo model.
Attributes:
model: The compiled MuJoCo model.
path: Optional file path the model was loaded from.
"""
model: mujoco.MjModel
path: str = ''
@dataclasses.dataclass(frozen=True)
class BuildGuiEvent(Event):
"""Lifecycle event dispatched on every frame on the viewer side to build ImGui elements."""
@dataclasses.dataclass(frozen=True)
class UpdateEvent(Event):
"""Lifecycle event dispatched on every frame on the viewer side before building GUI."""
@dataclasses.dataclass(frozen=True)