Docs / Making content
HTML textures: modern engine
The opt-in engine with flexbox, positioning and modern CSS.
The classic engine of HTMLTEXTURE.md runs every [htmltexture] page as it
always did. This page describes a second engine with modern CSS (flexbox, positioning, borders,
calc(), gradients ...) and a full JavaScript engine (modules, Promise, fetch of the page's
own files). A page asks for it in its <head>:
<meta name="omsi-engine" content="modern">A page without that line is never touched. OMSI_HTML_ENGINE=modern runs every page on the
modern engine, to compare the two. The rest of this page describes the modern engine; the
vehicle API (window.omsi) is the same as in HTMLTEXTURE.md.
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:#
[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:
[htmltexture]
512
160
sign\route.html
litWith 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
| 1 | The basic idea | Your 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 |
| 2 | Reading the vehicle | window.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 |
| 3 | Time, date, locale | These 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 |
| 4 | omsi.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 |
| 5 | The route and the timetable | Everything 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 |
| 6 | Departures of a stop | omsi.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 |
| 7 | Acting on the vehicle | Two 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 |
| 8 | The depot file: omsi.depot | omsi.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 |
| 9 | Touch and mouse | The 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 |
| 10 | Scenery objects | A 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 |
| 11 | What the HTML engine supports | A page can be a small site: .html, .css, .js files (and ES modules) in its folder, linked as on the web. The engine is not a browser, so a page that l… | 4 min |
| 12 | Tips for beginners | Start 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 |
| 13 | For developers | 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 HtmlR… | 1 min |
Something wrong or missing? Fix it on GitHub or open an issue.