openOMSI GitHub Discord

Docs / Making content / HTML textures: modern engine

For developers

1 min readEdit this pagedocs/HTMLTEXTURE_MODERN.md

The snapshot is built by omsi_sim::vehicle_api (snapshot and depot, both unit-tested without any game content) and handed to the backend through HtmlRenderer::set_vehicle and set_depot, which a backend may ignore.

The requests from setRoute, setLine, setDestination, clearLine and setNextStop become HtmlRequest values that the game picks up between two frames (take_requests, at most 32 per frame).

A scenery object's page is created with PageApi::Scenery (HtmlTexture::with_api), whose window.omsi has none of the vehicle's parts; drive_pages then gets no snapshot and no depot.

To add a signal, add it to vehicle_api::snapshot, write a test next to the others, and list it in the table above and in the module docs. Existing names stay stable within an API version.

What the engine itself understands is listed at the top of crates/omsi-sim/src/htmlengine/mod.rs. If you add a feature there, add it to the "What the HTML engine supports" section here as well.

Benchmark#

bench_htmlengine times the engine (parse + scripts, cold and warm render, an update with a frame, the pointer hit test) at 512x256, 1024x512 and 2048x1024. It is ignored in the normal test run; start it in release mode, debug numbers mean nothing:

shell
cargo test -p omsi-sim --release --lib bench_htmlengine -- --ignored --nocapture

HTMLBENCH_PAGE=path/to/page.html measures your own page instead of demo.html, and HTMLBENCH_RUNS=n sets the number of timed runs (default 200).

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open