dharmatiles preview

Preview

A live, painted 3D view of your tiles in the browser, and their editor. Click anything on the tile and the panel beside it goes to what made it, with its controls; or switch the panel to the source and type. It rebuilds a tile every time you save it, paints overhang the way the printability gate sees it, and shows a mistake at its line. It is part of the program and works offline.

The editor with a tile open: the trail and the Tile, Map and Plates switch along the top, the tile as an outline with its stack in the panel on the left, the tile in 3D on the right, the status line under it. The editor with a tile open: the trail and the Tile, Map and Plates switch along the top, the tile as an outline with its stack in the panel on the left, the tile in 3D on the right, the status line under it.
  1. Tile, Map, Plates. What you are making. Map and Plates are for a map or a print list; a tile opens as Tile.
  2. The trail. Places, the folder, the tile. Press any step to go up to it.
  3. Outline or Source. The same column as the tile’s levels, or as the text of the file.
  4. The stack, top of the tile first; the number is build order. Press a row to open it.
  5. The view. Press a thing on the tile to select its entry; the panel goes to it.
  6. Cameras. Iso is where a tile opens. The ⋯ beside them is Display: paint, overhang, wireframe, the grid.
  7. The build’s verdict. Press it for the messages, with the full record.
  8. The build target and Export. The base system and the printer every build is for; Export writes the files.

Run it

dharmatiles                                   # Places: your tiles, the folders you added and the library, in the browser
dharmatiles preview my-tile.dtile --open      # one document
dharmatiles preview a.dtile b.dtile walls/    # several files and folders
dharmatiles preview lib:tiles/cliffs          # one library group
dharmatiles preview my-tile.dtile --system ol # start on OpenLOCK (the title bar's chip changes it)
dharmatiles preview my-tile.dtile --printer fine # start on another printer profile
dharmatiles preview slicer-export.stl         # any binary STL, through the same gate

The sidebar is two pages. The first is the folders: the levels above the tile (Places and folders). Choose a tile and the editor slides in from the right, the same slide as any level's (a folder is one level, the tile one deeper); ‹ at the left of the crumbs (Places › My tiles › dungeon › 2x2-meadow) slides back to the folder the tile is in, and the tile's name at the top right of the list, or Esc, returns to the tile. With nothing named, the places are My tiles ($DT_HOME, else ~/dharmatiles), the folders you have added, the Library, and Tests, the tiles the program's own tests build (odd shapes and edge cases among them; open one to see what a test sees, or make it yours like a library tile). Folders are watched: a new tile appears in the list within a second, and a deleted one leaves it.

It serves http://127.0.0.1:7878/ (the first free port from 7878, or --port) on the loopback address only, and refuses a request whose Host is not 127.0.0.1, localhost or [::1]. Ctrl-C stops it.

What it shows

Seeing a cloud

A cloud (a top= with a range, or a pin) is drawn as part of the selection, the way a selected region or line is. Put the caret anywhere in a top= value or in a pin line, or click or drag the top field in the property sheet, and that entry's cloud is drawn in the accent over the tile. Point at a line that writes a top, or at the sheet's top row, and it is drawn more quietly.

The debug layer

When a tile does not come out as you expect, the debug layer shows how the build made it. It is off whenever the editor opens; ⌃⌥D (Ctrl-Alt-D) or Debug layer in the ⋯ menu turns it on and off, and a legend at the top left names what is drawn, with counts. It reads in every view, Top included, and changes nothing that is built or printed.

A tile with a great many marks has them thinned evenly, and the legend says so. More elements will add what they do.

The panel

The left of the page is one panel that shows one level of the tile at a time, full height. A level is a place on a path: the tile, one thing of it, one control of that. Nothing opens inline: choosing a row slides the panel to its level, from the right; ‹, a crumb, Esc or ⌘[ slides it back, and the level you left is where you left it (its scroll position is kept). The slide takes about 200 ms, and is a plain swap when your system asks for reduced motion. A map's levels (the map, one piece, a property of it) are the same panel: one shell shows whichever document's level is the one you are at, slides by depth (a deeper level from the right, a shallower from the left, the same for a tile and a map), keeps each level's scroll, puts the keyboard in the new level after a slide when it was in the panel, and reads Esc, ‹, ⌘[ and ⌘] the same. A level's own view only draws what it holds; it never shows, hides or slides itself. The folder levels, the folders of a map's Add step (Add › Places › My tiles › dungeon, each a level, in the trail above the panel and not a second bar inside it) and the step between a folder and a document are steps of the same trail, and slide by the same rule with the same timing, scroll and keyboard: opening a tile or a map from its folder is one level deeper, ‹ or a crumb back to the folder one shallower. There is one function that animates a level change (js/slide.js).

The panel at one stack entry, grass in bank: its name and place in the stack, its controls with their values, and Hide and Delete at the foot; the grass is outlined in the view. The panel at one stack entry, grass in bank: its name and place in the stack, its controls with their values, and Hide and Delete at the foot; the grass is outlined in the view.
  1. The trail has gone one level deeper, to the entry.
  2. The entry: its name, its element and where it stands in the stack.
  3. Its controls, each with its value; default marks one the document does not write. Press a value to type it.
  4. › opens a control that has more to say, such as a range.
  5. Hide and Delete. Hide comments the entry out; both can be undone.
  6. The entry is outlined on the tile.
The panel at one control, the length of the grass: what it is, its value, the odds along a range, what it takes and the value as written. The panel at one control, the length of the grass: what it is, its value, the odds along a range, what it takes and the value as written.
  1. The trail ends at the control.
  2. One control in full: what it is, its value, how likely each value is, what it takes and how the source writes it.

Places and folders

Above the tile are the folder levels, in the same panel with the same slide, crumbs and strip. Places is the top: My tiles, any folder you have added, then the Library and Tests (read only). A place opens to a folder level: its subfolders first, each with how many tiles are under it, then the tiles in it, each with its name, its size (2×1) and a small picture of its footprint, the squares across and up, and a dot for its build. A subfolder is another level; a filter above the list searches the whole place, at any depth, and says where each match is. The strip under the crumbs says how many tiles the folder holds (14 tiles (2 here) · 3 folders) and where it is on disk, as a short path (~/dharmatiles/dungeon/combo); the library's says library · tiles/ground · read only. ↑ ↓ Home End move between rows, → or Enter opens, ← or ⌘[ goes up a level (from a place to Places, from a tile to its folder), ⌘] goes back to the tile you left.

A folder level of the editor: the trail, a filter and four buttons, then the folder’s tiles, each with its size and a have or need mark. A folder level of the editor: the trail, a filter and four buttons, then the folder’s tiles, each with its size and a have or need mark.
  1. The trail ends at this folder; every step goes up to its level.
  2. Filter and New. The filter searches the whole place; the buttons make a tile, folder, map or print list here.
  3. The tiles with their size and a drawing of their footprint, and a mark for the build.
  4. Have and need, from the inventory, for the base system in the title bar.

The folder level lists documents by kind, from one table in the program (roots.rs) and one in the page (folders.js): a .dtile that is a tile, and an .stl (shown, and opened to look at; not renamed or moved). A new kind of document is one more entry in each.

The panel is beside the view, on the left or (Panel on the right in the ⋯ menu) on the right; its edge is a sash to drag, or double-click to reset. One button, at the left of the title bar, hides it for the view alone and brings it back (\ does the same). The width is remembered in the browser. On a narrow screen the panel goes under the view.

Selecting

Every triangle of a built tile knows the entry that made it, so the view, the property sheet and the document share one selection: the rest of the tile fades behind it. What is under the pointer shows the same way, lighter: with nothing selected the rest dims a little round it; with a selection, it lifts part way out of the fade. With the fade off, the selection and the pointer's thing are tinted with the theme's accent instead.

Water owns the surface it fills, so clicking the pool selects the water; put the cursor in the ground's line to reach the ground beneath it.

Editing

Every change is a change to the document's source, and the source is the tile: what you change in the view you can read, and keep, in the file.

The editor with the panel turned to the tile’s source, line numbered, beside the tile in 3D. The editor with the panel turned to the tile’s source, line numbered, beside the tile in 3D.
  1. Source turns the same column into the file.
  2. The text is the tile. Edit it and the tile builds again; a mistake is marked on its line.
  3. The view carries on beside it.

Only a page served by this run of the program can change a file: each change carries a secret the page reads from the program, and a page from any other site is refused.

Placing and drawing

The bar under the view puts new things on the tile. Type an element, a definition of the document, line or region (A goes there), choose with the arrows and press Enter; anything after the name, such as rock size=12, is written with it. Each gesture writes one node into the source, saves it, and selects what it made. Esc puts the tool down.

Moving round a tile

Orbit with the left button, pan with the right button or Shift, zoom with the wheel or a pinch, toward the point under the pointer. A fling keeps turning and settles. Picking a view turns the tile there rather than cutting; moving the camera clears that preset. The page tells the view what it shows and the view decides its own camera: a view you moved stays through rebuilds and edits, and each tile (and each map or plate list, in each of its views) comes back as you left it when you open it again. The shortcut row always holds ISO, Top and the two most recently used other views; all nine remain in ⋯.

KeyDoes
1–9Views: iso, top, front, right, back, left, low, close-up, under
pPerspective or orthographic, keeping the view
cPaint on or off (off is plain grey plastic; overhang colours stay)
oOverhang colours
wWireframe
gThe grid on the plate
tLight or dark
⌃⌥D (Ctrl-Alt-D)The debug layer
fFly to the selection
A or /The bar: place or draw
\Hide or show the panel
Esc ⌘[Up a level of the panel (from the tile, ⌘[ goes to its folder; on a folder level, up to its parent, then Places)
⌘]Back down the level you left
↑ ↓ Home End EnterIn the tile level: move between rows; open one
⌘1 ⌘2 ⌘3Put the keyboard in the source, the view, the tile's levels
?Every key, in the editor
⌘FFind and replace in the document
Tab / Shift-TabIndent or unindent the selected document lines
⌘S or Ctrl-SCheck and save now
EscPut a tool down, close a menu, else clear the selection

Single keys work when the document is not being typed into. Choices are remembered in the browser. With reduced motion set in your system, views cut and nothing coasts.

The build target

On a print list or a map the chip names the printer that document uses (Bambu Lab X1 · this map), read from the document as it is now, as the status line does; its card changes that document's printer, and Undo takes it back. Elsewhere the chip at the right of the title bar names what every build is for: the base system (DungeonBlocks or OpenLOCK) and the printer profile, such as DungeonBlocks · default. Click it to change either. The tile you are looking at, and every other tile you have built, builds again for the new target; the gate's angles and the numbers in the record are the chosen printer's. The choice is remembered in $DT_HOME (else ~/dharmatiles) for the next run; --system and --printer on the command line start the run on another one. Each printer is listed by the squares that fit its bed (6 × 6 squares · 1 colour · 220 × 220 mm) and drawn at one scale with those squares in it, using the square of the base system chosen above (35 mm for DungeonBlocks, 25.4 mm for OpenLOCK); choosing the other system redraws every bed. The slicer imports are one menu, Import from a slicer. The printers are the library's (library/printers/) and your own: a printers/ folder beside your tiles, one .dtile file each, named like the file (see Printing and Printers, where a profile is also a machine, by brand and model, such as bambu/x1c). There is no both: one build is one target. With a print list or a map open, the chip names that document's own printer (Bambu Lab X1 Carbon · this map), and choosing a printer in its card changes that document's plates line, as its plates panel does; the base system there stays the one tiles build for.

The build target card open over the view: the base system, DungeonBlocks or OpenLOCK, and the list of printers. The build target card open over the view: the base system, DungeonBlocks or OpenLOCK, and the list of printers.
  1. The card: the base system, then the printer, from the library, from your own profiles and from slicers you import.
  2. The chip in the title bar names the target and opens the card.

Export

Export, beside the verdict, runs the same build as dharmatiles build on the saved file and writes it to out/: the project's (beside the nearest dharmatiles.dtile above the tile), else one beside the tile, as out/db/my-tile-db.stl. A library tile is never written into the library: it goes to out/ in My tiles (~/dharmatiles/out/db/ground/1x1-grass-db.stl). The card says where before you export. It builds for the build target in the title bar, written to out/<target>/ (out/ol-fine/my-tile-ol-fine.stl for OpenLOCK and the printer fine); choose Also a painted 3MF for a 3MF painted by material (a Bambu Studio project when ~/dharmatiles/bambu.3mf exists; see Printing). Reveal in Finder shows what was written. Export waits while the tile builds or has unsaved changes, and is refused, with the reason, while the tile fails the printability gate.

Plates

A .dmap in a folder is a print list: open it and the view shows the printer's bed, its edge and any excluded zones, with one plate on it, and the panel becomes the plates' panel. The Tile and Plates switch in the title bar follows what you have open.

Maps

A map is a .dmap with placed pieces, and the title bar's Map is its view: every piece's tile at its place, turned and raised, in the same 3D view, on the ground of the backdrop you chose (Wilderness, Cavern, Table or Plain, in the ⋯ menu; the choice is kept in this browser and used for the tile editor too, and the plates keep the printer's bed).

Inventory

The inventory is a file, inventory.dinv, listed in My tiles once it exists. In the page it is four things: have and need pills on a tile's row in a folder (for the system the title bar's chip names), 3 printed · seeds 7, 12, 97 with I have this on a tile's level (it adds one good print of the tile's seed, in the colour mode you pick, without exporting), N in inventory · M to print and After the print in the plates' panel, and the document's own view, opened like any document: the pieces grouped by tile with filters for system, colour and have, Gone and Reprint on each piece, a one-click Re-link for a tile that moved, and Source for the file's KDL. Renaming or moving a tile in My tiles adds a renamed line, so the counts follow it.

Live updates

Save the document, or any file it uses, and the tile rebuilds. Your camera stays; the old tile fades at once, so it never passes for the new one. As the build goes, each stage's parts take its place, faded too: the ground within a moment, then each element as it finishes. A cliff shows its rough blocks within a second or so, long before its stones are cut. What stands for work still going breathes, its transparency rising and falling: the rough blocks, and the old tile until the first new part arrives (not with reduced motion). Opening a tile mid-build shows what it has made so far. The finished tile replaces them all, solid, with its verdict. What shows while a tile builds is never judged by the gate, and a large stage is sent thinned. A rebuild starts from the first step your edit changes: the program keeps the tile as it stood after each step of the last build (in the order the plan runs them, surfaces and ground first), so changing the boulders by a cliff rebuilds the boulders and joins and checks the tile again, in about two seconds, without carving the cliff again. Changing a surface, such as the dirt's level, rebuilds everything after it. The last few tiles you worked on keep theirs; drafts keep their own. A mistake shows over the view as file:line:column with a hint, in front of the last good build; the next good save clears it. One tile builds at a time: tiles named on the command line are built at the start, and a tile picked from a folder is built when you pick it.

If the program stops, the page says so the way it says a build is running: the status line says reconnecting… with a pulsing dot, and the tile fades and breathes. Start the program again and the page carries on by itself, whenever that is: it finds your tile again by its file, rebuilds it if it needs to, and keeps your camera. An edit typed while it was away is kept and saved once it is back (the title bar says not saved yet until then).

The cache of builds

A tile that has been built once is not built again until something it depends on changes. Every finished build is kept in one cache folder, under a key that is a hash of everything the build read, so a build that is found there is the build, byte for byte: the same STL, the same paint, the same gate verdict. Open a tile whose build is kept and it is on screen at once, with no build; the status line says passes · cached and the messages say From the cache (2.1 s when it was built), then the gate's verdict as for any build. dharmatiles build and build --all read the same folder (they still write the STL), so a second sweep of the library takes seconds, and Export reuses the build you were looking at.

An entry made on another machine is not trusted: determinism is tested on this machine, so copy only the library's previews, which are for looking, never a build to print.

Messages

Everything the program learns about a tile (a check, a build and how long it took, the printability gate's verdict and numbers, an export, a mistake, a note, a failure) is one message in one stream. The status line, the panel, the marks in the source and anything that reads the stream are views of it, so none of them says anything the others do not.

The messages panel open over the lower part of the view: the build’s verdict with two bars against the overhang budget, and a yellow note about the dirt’s edge. The messages panel open over the lower part of the view: the build’s verdict with two bars against the overhang budget, and a yellow note about the dirt’s edge.
  1. The panel rises over the view when you press the status line or ⌃J.
  2. Filters: all, errors, notes, build.
  3. The verdict: how long the build took, whether it passes the gate, and two bars of overhang against the budget.
  4. A note is yellow: something the checker saw in a tile that is fine. Show on tile goes to its place.
  5. The status line says the same in a few words.

When something goes wrong

A mistake in your tile shows where you made it: beside the line (a mark in the gutter and a wavy underline, for a mistake the build finds as well as one the check finds), in the messages as file:line:column with a hint, and in the status line (1 error); a tile that fails the printability gate says so there too. Those are not failures.

When something breaks that is not your tile's fault it is a message too, in red, in the same panel. A failure the program can explain, such as a file it could not write, says so in its own words, with what to do. Anything else says what it was doing and the technical words under it. The row's copy icon puts a report on the clipboard to paste into a bug report: what happened, the page's stack and the program's backtrace and causes, and the dharmatiles version, build target, tile, browser and time. If the browser will not let the page copy, the icon says so. A row of a failure has an × that puts it away. A mistake in your tile is listed at its line (Go to line), and every row, mistake or bug, copies its code, where it is, its source lines and this environment.

Paint

Every material is painted like a quick acrylic job: a dark basecoat, mid tones, and pale highlights drybrushed on whatever stands proud, so joints and cracks stay dark and edges catch the light. Each material's ramp is a line in library/palettes/default.dtile. Give your own copy to dharmatiles preview --palette my.dtile, which repaints when you save it, or to build --png --palette my.dtile.

Limits