openOMSI GitHub Discord

Docs / Making content

HTML textures

Draw a texture from an HTML page.

17 min readEdit this pagedocs/HTMLTEXTURE.md

On this page
  1. Example model config:
  2. LED destination signs
  3. A page as a surface: lit
  4. Html file

Previously, you had to use scriptTexture in Omsi 2; to make things easier for both modders and developers, openOmsi now offers htmlTexture. These can be used, for example, as IBIS or other information in vehicles, giving you a few more design options.

This documentation explains how to use the API in HTML. If anything is missing or you encounter any issues, please feel free to open an issue with relevant information and steps to reproduce the problem.

Working html example: docs/examples/htmltexture/demo.html.

Example model config:#

OMSI file
[htmltexture]
1024
512
html\index.html

##########################################

[mesh]
generic\AFR4\AFR4_Display.o3d

[visible]
AFR4_Display
1

[matl]
afr4.dds
0

[useHtmlTexture]
0

[matl_lightmap]
1px_lm.bmp
0.5

[matl_freetex]
afr4.dds
AFR4_ST_texture

[matl_transmap]
\S:7

[viewpoint]
3

[useHtmlTexture] describes which [htmlTexture] it is; \S:7 is the corresponding script texture ID in this case. Note: An [htmlTexture] is registered as a [scriptTexture], but it is also registered as an [htmlTexture].

This means: If an htmlTexture follows scriptTexture 6, the htmlTexture is automatically scriptTexture 7. But it is not htmlTexture 7.

LED destination signs#

A page drawn on an LED matrix burns like the Krueger and K++ panels in Enhanced when it is declared lit (below) and its material has a dot mask and a white light map: either the \S:n mask above, or a plain picture of the dots as [matl_transmap] (black between the dots), with a [matl_lightmap] that is white all over.

The lit dots then burn at the LED glow setting's brightness and bloom, and, like the Krueger's and K++ panels', the slot stays one of the bus's own screens: its dots keep the display's glow over the burn.

A page's sign keeps that brightness at night even where it sits inside the cab (behind a coach's windscreen); a script texture's panel in the cab (a dashboard's LCD) dims.

A page as a surface: lit#

A page is a display by default: drawn at its own brightness, which is what a bus's own panel is. A page that is a surface - a road sign, a poster, a notice board - wants the world's light instead, so put lit on the line after its path:

OMSI file
[htmltexture]
512
160
sign\route.html
lit

With it the page is shaded like every other material - the sun, the street's lamps, the fog, the eye's own adaptation - so a sign face dims with the night it stands in, and the slot showing it stops being the bus's own screen with it (its bright pixels glow as a surface's do - an LED page, above, keeps the screen and its dots' glow).

The word is the page's own: it reaches every slot that shows the page, wherever that slot is - a scenery object's and a vehicle's alike. Without the word nothing changes at all, and the word is openOMSI's own: Omsi.exe knows neither [htmltexture] nor lit and draws the slot unlit.

Html file#

html\index.html is the relative path from the bus path. Example: Data\Vehicles\MAN_NewLionsCity\html\index.html = html\index.html

Chapters

1The basic ideaYour page is normal HTML with a <script>. The game gives it one global object, window.omsi (you can also just write omsi), and the page uses it for th…1 min
2Reading the vehiclewindow.omsi.update = function (d) { d.num, d.str // script variables that changed since the last call (everything on the first call) d.vehicle // the …1 min
3Time, date, localeThese are set before omsi.update runs and change with the simulation clock, once per second. Use omsi.locale to pick your texts, and fall back to Engl…1 min
4omsi.vehicle (version 1)doors.anyOpen follows what the passengers are told is open (PAX_*_Open) if the bus has those variables, and the door leaves (door_<n>) if not. Some mo…1 min
5The route and the timetableEverything about the current trip lives in omsi.vehicle.route. A few things worth knowing: served is true once a stop has been handled. When the last …1 min
6Departures of a stopomsi.getDepartures(stop) gives the departures at a bus stop for the next 2 hours, soonest first, at most 20. stop is the stop's name as in the timetab…1 min
7Acting on the vehicleTwo details that trip people up: setNextStop goes both ways. Forwards, the stops in between are skipped. Backwards (a "back one stop" button), the sto…1 min
8The depot file: omsi.depotomsi.depot describes what the bus's depot file (.hof) offers, so your page can build a line picker or destination list without hard-coding anything. I…1 min
9Touch and mouseThe app passes presses, releases and movements of the pointer on the texture to the page. They turn into events on the element under the pointer and b…1 min
10Scenery objectsA scenery object (.sco) can show pages too: [htmltexture] in its model config and [useHtmlTexture] on the material, the same as in a vehicle - and the…1 min
11What the HTML engine supportsThe engine is deliberately small. It is not a browser, so a page that looks fine in Chrome may need a few changes. When something doesn't show up, che…2 min
12Tips for beginnersStart from demo.html and change one thing at a time. If the texture goes blank, the last thing you touched is the culprit. Write to the log. console.l…1 min
13For developersThe snapshot is built by omsi_sim::vehicle_api (snapshot and depot, both unit-tested without any game content) and handed to the backend through HtmlR…1 min
14The modern engine (opt-in)A second engine with flexbox, positioning, modern CSS and JavaScript (modules, Promise, fetch) is available for pages that ask for it with <meta name=…1 min

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

↑↓ to move↵ to open