Skip to content

Design: NWN Bake, nwn-bake as a desktop app

Status: built, not released. Revision 4, 2026-11-30: every screen is in app/ and the page runs in a browser too (What is built); no version with the app is tagged yet. Revisions 1 to 3, 2026-11-29: the design, written for the maintainer's review before any code, every question decided the same day.

A signed desktop app that opens a module and shows it: every area as a picture and in 3D, every character, item and placeable, and what changed between two versions. It turns any of them into files for a website. It is built on the nwn-bake library, so it draws what the command draws, the same way, and every screen can show the command that would do the same job. The same page runs in a browser on the visitor's own game files.

Words used here:

  • NWN Bake: the app (question 1). nwn-bake stays the name of the command and the library.
  • Shell: the app's own program. It opens the window and calls the library.
  • Webview: the system's browser engine the window draws its pages with: WebView2 on Windows, WKWebView on macOS, WebKitGTK on Linux.
  • Tauri: the Rust framework (version 2) that opens a webview window and builds each system's installer. The area editor (nwn-landscaper) ships its desktop app with it.
  • Atlas: the grid of every area's picture, drawn from the cache.
  • WASI: a standard set of system calls for WebAssembly; nwn-bake builds for it (wasm32-wasip1) to run in a browser.
  • OPFS: a site's private file storage in the browser (Origin Private File System), kept across visits.

The short version

  • For four kinds of people: builders checking a module, administrators and wiki writers publishing it, content makers showing off a hak, and players who want a picture of their own character.
  • Nine screens, each over commands that exist: open a module, the atlas, an area, changes, 3D, characters, the scene composer, the asset browser and publishing. A job queue runs under all of them.
  • The library runs inside the app, on worker threads: one program to sign, no second process to leave behind. The app's code is app/ in this repository, released with the command.
  • The page is plain JavaScript with a vendored three.js, as the area editor's page is: no build step, and its 3D viewer can be shared.
  • The same page runs in a browser from the start. In the browser, nwn-bake built for WASI does the work in a worker, on the visitor's own game folder. Screens that need a GPU (characters, scenes, pictures of objects) are desktop only at first.
  • Signing and installers reuse the area editor's release jobs: Azure Artifact Signing on Windows and a notarized Developer ID on macOS already sign the nwn-bake binary (0.7.1). The app needs one more key, for updates.
  • The first version is the module opener, the atlas, the area screen, the job queue and the static site export, in the app and in the browser.
  • Engine work for later screens: cancelling a job, progress inside one area, a comparison of two module versions in the library, and frames for a turntable.

Who it is for

  • Builders. They see every area at once, find a door that leads nowhere or a placeable sunk in the floor, read a game point off the map for a script, and check what a hak rebuild changed before they ship it.
  • Administrators and wiki writers. They publish a world map, area pages and character viewers without writing a script, and keep them current as the module changes: the cache redraws only the areas that changed.
  • Content makers. They make clean pictures of their placeables, items and creatures for a release page: a lineup, an item sheet, a turntable.
  • Players. They open their own .bic and save a portrait.

What exists today

Every screen below stands on a command or library call that exists in nwn-bake at fbf713c (after 0.7.2):

Screen What it uses
Open a module ModuleSource::open (a .mod, a folder, a nasher project, one area file), the hak list, Game
Atlas, area area-iso with --all and --cache, its manifest's matrix, --look, --region, --mark, area-scene
Changes the scene digest (area-scene), the keys, --region and --mark, examples/module_compare.rs
3D area-3d: the .glb, the manifest's doors, the .floor file
Characters describe, look, part, thumb, missing_items
Scene composer scene, with character and camera.view (#24)
Assets placeables, placeable-thumb, item-thumb, textures, plt, plain, palettes, resources
Publish the JSON Schemas under docs/, area-3d --tex-uri

The area batch calls back once per area (area3d::batch::run's done), which is enough for a progress bar per area.

The app, screen by screen

1. Open a module

  • The first start finds the game as the command does (NWN_ROOT, then the usual places). When it can't, it asks for the folder and keeps the answer: an app started from a menu doesn't see a variable set in a shell.
  • A module is anything the command takes: a .mod, a folder, a nasher project or one area file. Recent modules are listed.
  • The hak list in load order, a hak that isn't found in red, and the talk table in use.
  • The module's contents in one list with a search: areas (with their size, tileset and whether they are interiors), creatures, items and placeables.

2. Atlas

  • Every area's picture in a grid, drawn in the background by area-iso --all into the app's cache. A second opening draws only what the keys say changed, so a module of 1,338 areas opens as fast as its folder reads.
  • Sort and filter by name, tileset, size or kind. An area that failed shows its error in place.

3. An area

  • The picture, zoomable, with the four corner views and the top view.
  • The look on sliders: scale, light (day or the area's own), shadows, the roof cut (including ground:<metres>), exposure, the sun and the shadow length. A look lab edits the --look constants live and saves them as a preset.
  • The pointer's game point under it, read through the manifest's matrix. A click copies X, Y, Z for a script or a waypoint.
  • Doors as links: a click opens the area a door leads to. With the atlas this is a world map.

4. Changes

  • Two versions side by side: two .mod files, two commits of a nasher project, or one module before and after a hak rebuild.
  • The list of areas whose scene digest differs, each with a slider between the old and new picture, and --region close-ups with each changed spot ringed (--mark).
  • One button saves a comparison as a picture for a pull request or a forum post.

5. 3D

  • The area's .glb in a viewer: orbit, and a walk on the .floor file's walkable floor. Placeables and doors on and off.
  • A click on a placeable or a door names its resref, tag and position.

6. Characters

  • A .bic or .utc in 3D from look's parts: change a part or a colour and see it at once.
  • An animation list and a time slider (anim, t).
  • Equipped items that aren't found, listed by slot (missing_items), with where the app looked.
  • Portraits: framing, background and light, saved as PNG; later a turntable (engine work).

7. Scene composer

  • Placeables, creatures, items and described characters dropped onto a ground plane, moved, turned and scaled. The camera is perspective or orthographic, free or at a side (camera.view). Lines and axis markers drawn on top.
  • The scene saves as the spec scene reads (docs/scene.schema.json), so a script can draw it again.
  • Templates: a lineup, two models side by side, an item sheet, a chess board.
  • A batch: one picture for each file in a folder or each row of a CSV, for example every item in a hak.

8. Assets

  • Every placeables.2da row as a picture, with its size, footprint, light and particles from placeables.
  • Textures and PLT palettes (plt, plain, palettes), and the icons the game has for an item appearance (resources).

9. Publish

  • One button writes a folder of static pages: the world map, a page per area with its pictures and 3D view, character viewers and the asset gallery. Any static host serves it (GitHub Pages, Cloudflare Pages, a plain web server).
  • Choices: texture size and quality (--max-tex, --quality), the address the textures load from (--tex-uri), and which parts to include.
  • "Copy embed code" for one area or one character.

Jobs, under every screen

  • A queue with a bar per area (from the batch's callback), the areas that failed with their errors, and retry.
  • Threads and memory as two settings (--jobs, --cache-mb), with the README's measurements beside them: a 32x32 area peaked at about 1.4 GB; a 40-thread batch of 1,338 areas at 21.5 GB.
  • The command line: every job shows the nwn-bake command that would do the same, to copy into a script or CI.

What is built

Revision 4 records what landed on 2026-11-29 and 2026-11-30. Each screen is on the desktop; the browser column says what the page does on nwn-bake for WASI.

Part Pull request Browser
Turntables in scene #26 no (GPU)
Cancel and stage events (nwn_bake::control), serve's area_3d #27 yes
compare, two versions of a module #28, #37 (--user-a, --user-b) the library only
wasi-request and the WASM build in CI #29 yes
Screens 1, 2, 3, the job queue, Publish #30 yes (#35)
Screen 5, 3D #31 yes
Screen 6, characters, portraits and turntables; GPU adapter choice #32 a note: desktop only
Installers, signing, in-app updates #33 not applicable
Screens 7 and 8, the scene composer and the assets #34 assets' lists; the composer is desktop only
The page in a browser: module_info, site, the OPFS cache, scripts/pack-browser.sh #35 yes
Screen 4, changes, with a 1 mm tolerance in compare #36 a note: desktop only
The particle flag in placeables; items a creature may not wear, named #38 yes

Still to do, none of it a new decision:

  • The first tagged release with the app: the signing, notarizing and updater steps run only on a tag.
  • Where the browser page is hosted. The CI artifact is ready for any static host; publishing it is the maintainer's call.
  • One shared list of screens, so a new screen adds a file and does not edit the navigation, the command registration and the stylesheet that every other screen edits.
  • In the 3D screen, walking avoids walls but not placeables. In the characters screen, the 3D view is lit brighter than portraits, and particle emitters are not drawn.
  • The scene composer edits on a 2D plan; a live 3D view is optional.
  • A real GPU, a real Mac and Windows have not run the app beyond CI: the 3D screen draws about 1,000 calls for a town.

The first version

Screens 1, 2 and 3, the job queue and the static site export from screen 9 (maps and area pages), in the desktop app and in a browser. On the desktop these use only what the library has today; the browser needs a WASI entry point (Engine work). They make the app the place a builder keeps open while working. Screens 4 to 8 follow in the build order.

Decisions

Each question was put to the maintainer with a recommendation on 2026-11-29. All but question 6 went with the recommendation.

1. The app's name

The download and the window carry it. Decided (2026-11-29): "NWN Bake", as the area editor's app is "NWN Landscaper", so the two read as a family and a search for the command finds the app.

2. How the app runs the engine

Decided: in the shell, as a library. The shell calls nwn_bake on worker threads. One program to sign, nothing left running when the window closes, and the library's types reach the page without a protocol in between. The area editor chose the same for its engine. Not chosen: nwn-bake serve as a second process, which has no area-3D request and no progress inside a request, and is a second binary to sign, ship and stop.

3. Where the app's code lives

Decided: app/ in this repository. It builds against the library at the same commit, CI tests both together, and one tag releases both, as the area editor does with its app/. Not chosen: a repository of its own, which would pin nwn-bake and Moonglow at the same commit (MOONGLOW.md) and need a second release kept in step.

4. The page

Decided: plain JavaScript and a vendored three.js, no build step, as the area editor's page (nwn-landscaper-web) is. Its .glb viewer and its STYLE.md checks come with it.

5. Installers, signing and updates

Decided: copy the area editor's release jobs. NSIS on Windows (per user), one universal .dmg on macOS, an AppImage and a .deb on Linux, each installed and started in CI. The signing identities are already in this repository's release environment. The updater needs its own key pair: TAURI_SIGNING_PRIVATE_KEY and its password, made when the release job is written and kept as secrets in that environment. The command's archives stay as they are, beside the installers.

6. A browser version

Decided: alongside the desktop app from the start (the recommendation was after the first release). 0.7.2 builds for WASI (wasm32-wasip1), and area pictures and .glb files need no GPU. What follows from it:

  • One page, two engines. The page asks an engine object for every job. On the desktop it calls the shell (Tauri commands); in the browser it posts to a worker that runs nwn-bake for WASI through a small JavaScript library for the system calls, as the area editor's "try it" page runs its engine.
  • The visitor's own game. The browser reads the game folder and the module the visitor picks; nothing of the game is on the server. The cache lives in the site's private browser storage (OPFS).
  • What runs where. Open a module, the atlas, an area, changes, 3D, the asset lists and publishing run in both. Characters, scenes and pictures of objects use wgpu, which the WASI build has not got: desktop only until a WebGPU path is designed.
  • Speed. The WASI build runs on one thread: the area editor measured its single-threaded native build 1.1 to 2.8 times faster than WASI, and every core 3 times faster again. The browser suits one module a visit, not a 1,338-area batch.

7. What the static site export writes

Decided: the batch layout area-iso --all and area-3d --all already write, plus an index.html and one page per area, so a site built by script and one built by the app are the same files.

Engine work

Change For Size
Cancelling a batch or a request (a flag the workers check between areas and views) jobs small
Progress inside one area: building the scene, each view jobs, large areas small
module_compare as a library call that pairs the areas of two sources and their digests changes medium
Frames of a turning camera, for a turntable GIF or WebM characters, scenes medium
serve: an area_3d request, for scripts that want the same as the app scripts small
A WASI entry point: one job a run, its request on stdin and its answer on stdout, as the area editor's engine does browser small
Reading the game folder from a WASI preopen with no install search, and the cache in OPFS browser medium

Build order

  1. The page's engine object with its two sides: the shell (window, finding the game, opening a module) and the WASI worker (entry point, game folder, OPFS cache). The job queue on the batch's callback.
  2. The atlas and the area screen, with the game point under the pointer and doors as links, in both.
  3. The static site export of maps and area pages. First release: the signed app with updates, and the browser page.
  4. Cancelling and progress inside an area (engine).
  5. The 3D screen, then the characters screen (desktop).
  6. The changes screen, after the comparison moves into the library.
  7. The scene composer (desktop) and the asset browser.
  8. Turntables, then a WebGPU path for the desktop-only screens.

Risks

  • Large modules in a webview. A grid of 1,338 pictures must load only what is on screen; the atlas needs a virtual list from the start.
  • Memory. The app holds the caches between jobs. The default --cache-mb (4096) is high for a laptop; the app should start lower and say what it costs.
  • macOS. The area editor's 3D view drew on a virtual Mac only some of the time; a real Mac must confirm the 3D screen.
  • Characters need wgpu. Without a GPU the app falls back to Mesa lavapipe as the command does, which is slower for live part changes.
  • Two engines, one page. Every feature is built and tested twice, native and WASI. CI runs the page's tests against both.
  • Browser storage. A browser may clear OPFS under storage pressure, and a large module's cache can run to gigabytes; the page must treat its cache as disposable and say how much it holds.

What this design could not check

  • No part of the app is built; the screens are a plan, not a prototype.
  • The atlas timings assume the cache behaves as the README measures it on Linux; nothing is measured on Windows or macOS.
  • How the page's 3D viewer runs in each webview is taken from the area editor's prototype, not tested here.
  • Whether nwn-bake's area bake runs whole under WASI with a real install is taken from 0.7.2's WASI work for the area editor; this design has not run an area-iso batch in a browser.