RLViser replay

Watching traces and scenarios in 3D with RLViser, on the desktop or in the browser.

5 min read

RLViser is a 3D viewer for RocketSim games. A copy lives in vendor/rlviser, with changes that add a browser build and snapshot playback (listed in vendor/rlviser/PATCHES.md). It needs no Rocket League install.

sh
just rlviser             # desktop viewer (just view and just watch open it)
just rlviser-web         # browser viewer, into apps/web/public/rlviser/
just rlviser-web-public  # browser viewer without Rocket League's assets (what the deployed site serves)

All need Bun. The first two download RLViser's meshes (cache.zip), which are exported from the game and not committed. The browser builds also need the wasm target and a matching wasm-bindgen. If they are missing, the build stops and prints the command that installs them.

The public build draws an arena of our own, generated from a few named dimensions (vendor/rlviser/arena/dimensions.ts): plane positions and the radii of the ramps and bends between them. Cars are boxes the size of their hitboxes, the ball is a sphere and boost pads are discs. It only changes the picture: replays were already simulated against the real collision meshes. just arena-check reports how far the drawn arena is from the real surface, region by region (a few units on the walls and ramps, up to about 35 in the corners and goals).

Replaying traces and scenarios#

sh
just view recordings/ball-drop-center-500.rocketsim.jsonl            # replay once at real time
just view recordings/x.rocketsim.jsonl --scenario scenarios/car/x.json --loop --speed 0.25
just view --live scenarios/ball/ball-drop-center-500.json             # run in RocketSim now, then stream
OptionMeaning
--scenario FILEScenario the trace came from. Traces do not store car team or body, so without this every car is drawn as a Blue Octane (with a warning)
--live FILERun this scenario with sim_runner::run (meshes from --meshes, default collision_meshes) and stream the result
--speed 1.0Playback speed (1 = 120 Hz real time)
--loopRepeat until Ctrl-C
--port PStream to another UDP port instead of the RLViser that physlab view opens. --port 40244 streams to the Command Center's browser viewer
--no-launchDon't open RLViser
--export FILEWrite a snapshot (.rlvsnap) for the browser viewer instead of streaming. --loop and --speed don't apply
--export-hz 30Frames per second the snapshot keeps (the viewer smooths between them)
--from S, --to SClip the snapshot to seconds S after the first sample

How it works:

  • Frames are rlviser-rocketsim =0.1.2 GameState packets built from rocketsim::ArenaState::new_empty(..). They are sent with the raw PacketCodec after a Connection message. Quit is never sent, so RLViser stays open between replays. (The crate's Rlviser type sends Quit when dropped, which closes the window.)

  • tick_count increases strictly, also across --loop passes, because RLViser ignores frames whose tick count does not change.

  • Pacing uses deadlines at the trace's physics rate divided by the speed. A late frame moves the schedule instead of sending a burst of catch-up frames.

  • RLViser sends its pause and speed keys to 127.0.0.1:34254. The replay binds that port on loopback when it is free and follows those keys. If another process holds the port, it says so and ignores them.

  • Things the trace cannot provide are filled in explicitly:

    • The ball's orientation is not recorded, so it is drawn unrotated.

    • Boost pads use RocketSim's standard Soccar layout, in arena order. Cooldowns are rebuilt from car_pickup_boost events using the default cooldowns (10 s big, 4 s small).

    • Missing car gameplay fields keep RocketSim's spawn defaults.

    • An entity missing from a sample is parked at z = -10000.

    • the_void traces are shown in TheVoid mode, with no pads.

  • With --no-launch or another --port and nothing listening, sending fails silently and the replay still runs.

In the browser#

The browser viewer plays snapshots and live streams:

  • Snapshots are what a replay would stream, saved to a file. For example, just view recordings/x.rocketsim.jsonl --scenario scenarios/x.json --export tmp/snapshots/x.rlvsnap. --export also works with --live, and just watch … --snapshot DIR saves every game it plays. Put a snapshot in apps/web/public/replays/ and show it on a page with ::Replay{src="/replays/x.rlvsnap" title="…"}, like the one above. Playback has a timeline bar: play or pause, seek, and loop.

  • Live: the Command Center's Viewer tab shows whatever streams to port 40244, for example just view … --port 40244 or just watch RUN --port 40244.

The viewer is a separate page, /rlviser/index.html?src=… or ?live=…, and pages always embed it in an iframe. The page's parameters are listed at the top of vendor/rlviser/web/viewer.js. The browser build draws a plain sky instead of RLViser's atmosphere, which WebGL 2 can't run.

Controls#

KeyAction
EscOpen or close the menu (it frees the mouse; camera keys are ignored while the menu is open)
1–8Follow car 1–8 (car numbers as printed by watch; Blue first)
9Director camera (switches between cars automatically)
0Free camera: W A S D to move, Space up, Left Ctrl down, Left Shift faster, mouse to look (in the browser, drag with the left button)
PPause or resume
+ (Shift + =, or numpad +) / -Playback speed ±0.5 (0.1 to 10)
= (or numpad =)Playback speed back to 1
RThrow the ball (RLViser's own test; the next streamed frame overrides it)