Placements are approximate, so map rectangles overlap where the real locations do not -- Reserve clips Customs, Lighthouse clipped Shoreline. Sampling the rendered tiles showed the stacking was technically fine (finer map always on top) but that did not help: an overlapping neighbour still covered the map you had navigated to. Stacking is now explicit. Baseline order is by maxNativeZoom then footprint so the finer map wins, and whichever map the view is centred on is lifted above everything else. Verified for Shoreline, Lighthouse, Customs, Reserve and Woods: each becomes topmost when centred. Tilt raised 31 -> 35 degrees. The original 31 came from fitting the Customs zone outline's aspect ratio, but that polygon encloses more than the playable strip so the estimate ran low; attempts to register the two polygons directly failed because the dashed outline will not flood-fill. 35 aligns better by eye. `place` lives in the rotated frame, so retilt.py converts every placement through the old and new angles -- changing the tilt no longer scatters the maps. Lighthouse's box also tightened; its PSD is nearly square while the zone is a coastal strip, so it overhung into the sea. Verified zoom 0-9: 620 tiles, zero broken. Co-Authored-By: Claude Opus 5 <[email protected]>
179 lines
5.6 KiB
Markdown
179 lines
5.6 KiB
Markdown
# Adding a map
|
||
|
||
Point the config at a PSD, name the layers holding the map art, say where it
|
||
goes on the world map, build. No application code changes.
|
||
|
||
Budget ~10 minutes plus render time (roughly 3 minutes per GB of PSD).
|
||
|
||
---
|
||
|
||
## 0. Once per machine
|
||
|
||
```bash
|
||
python -m pip install -r tools/requirements.txt
|
||
```
|
||
|
||
Put the PSD under `sources/<id>/`. That directory is gitignored — source art
|
||
lives on the shared drive, never in the repo.
|
||
|
||
---
|
||
|
||
## 1. Find the layers holding the map art
|
||
|
||
```bash
|
||
python tools/psd_tree.py sources/woods/woods.psd --depth 2
|
||
```
|
||
|
||
**There is no naming convention.** Every re3mr map does this differently, so
|
||
you have to look each time:
|
||
|
||
| Map | Base layers |
|
||
| --- | --- |
|
||
| Customs, Customs Dorms | `LOCATION` |
|
||
| Woods | `re3mr.com/Map&Art` (nested inside a wrapper group) |
|
||
| Lighthouse | `Day` (there is also a hidden `Night`) |
|
||
| Shoreline | `Baselayer` |
|
||
| Shoreline Resort | `BGCOLOR PATTERN`, `BASEMAP+2DLAYERS` |
|
||
| Interchange | `Background`, `3DRENDER` |
|
||
| Reserve | `Day copy`, `Color Fill 1`, `Group 5` |
|
||
| Streets | `Layer 1`, `Map - 3D map portion…` |
|
||
|
||
Note the two shapes this takes: several maps need **more than one** top-level
|
||
layer, and some bury the art **inside a wrapper group** (use a slash path).
|
||
|
||
Also note any `shape` layers — psd-tools renders stroke-only vector shapes as
|
||
solid fills, so they may need `excludeLayers`.
|
||
|
||
---
|
||
|
||
## 2. Add it to `maps.json`
|
||
|
||
```json
|
||
{
|
||
"id": "woods",
|
||
"name": "Woods",
|
||
"psd": "sources/woods/woods.psd",
|
||
"baseLayers": ["re3mr.com/Map&Art"],
|
||
"excludeLayers": [],
|
||
"crop": null,
|
||
"place": { "cx": 818, "cy": 652, "w": 380 }
|
||
}
|
||
```
|
||
|
||
| Field | Meaning |
|
||
| --- | --- |
|
||
| `baseLayers` | slash-paths from the document root; everything else is hidden |
|
||
| `excludeLayers` | layer names to hide anywhere inside the kept set |
|
||
| `crop` | `[x0, y0, x1, y1]` in PSD pixels, or `null` for the full canvas |
|
||
| `place` | where it sits on the world map — see step 4 |
|
||
| `pxPerMeter` | optional, from the map's scale bar; recorded for later use |
|
||
|
||
---
|
||
|
||
## 3. Render the base layer and look at it
|
||
|
||
```bash
|
||
python tools/export_base.py woods
|
||
```
|
||
|
||
Open `build/woods/base.png` and check for:
|
||
|
||
- **large flat areas of solid colour** — a shape layer is filling. Add its name
|
||
to `excludeLayers`. (Customs needs `"Map Borders"`; without it the whole
|
||
playable area renders white.)
|
||
- **leftover markers, legends or titles** — wrong `baseLayers`.
|
||
- **missing terrain** — you kept the overlay group but not the art beneath it.
|
||
- **dead canvas around the art** — that sets your `crop`.
|
||
|
||
A failed map no longer aborts the batch; check the summary at the end.
|
||
|
||
---
|
||
|
||
## 4. Position it on the world map
|
||
|
||
The base of the canvas is `sources/overall/overall.jpeg`, rotated by
|
||
`world.rotate` (31°) so north is up. `place` is in **rotated overall-map
|
||
pixels** — the north-up image you actually look at.
|
||
|
||
```bash
|
||
python tools/place_preview.py
|
||
```
|
||
|
||
That writes `build/place-preview.png`: the rotated base with a 100 px grid and
|
||
every current `place` box drawn on it. Read the coordinates for your zone
|
||
straight off the grid, set `cx`/`cy`/`w`, re-run. The loop takes seconds
|
||
because nothing is tiled.
|
||
|
||
`w` is the map's width in overall-map pixels; height follows from the source
|
||
aspect ratio. Positions are deliberately approximate — the game's individual
|
||
maps are not drawn to match the satellite view exactly, so aim for "clearly the
|
||
right place", not pixel alignment.
|
||
|
||
Because placements are approximate, map rectangles **do** overlap where the
|
||
real locations don't. That is handled in the viewer rather than by chasing
|
||
perfect boxes: the map whose centre you are viewing is always lifted to the
|
||
top, so an overlapping neighbour can never hide it.
|
||
|
||
### Changing the tilt
|
||
|
||
`place` coordinates live in the rotated frame, so editing `world.rotate` by
|
||
hand would move every map. Use the helper instead — it converts all placements
|
||
through the old and new angles so geography is preserved:
|
||
|
||
```bash
|
||
python tools/retilt.py 35
|
||
```
|
||
|
||
---
|
||
|
||
## 5. Build and verify
|
||
|
||
```bash
|
||
python tools/build.py woods
|
||
```
|
||
|
||
```bash
|
||
python tools/preview.py 4
|
||
```
|
||
|
||
`build/world-preview.png` composites everything at its world position. Then:
|
||
|
||
```bash
|
||
pwsh server/run.ps1
|
||
```
|
||
|
||
---
|
||
|
||
## Useful variations
|
||
|
||
```bash
|
||
python tools/build.py # base + every map
|
||
python tools/build.py overall # just retile the base map
|
||
python tools/build.py --tiles-only # re-tile after a place/crop change
|
||
python tools/build.py --force-export # re-render even if base.png is current
|
||
```
|
||
|
||
`build.py` skips the PSD render when `base.png` is newer than the PSD, so
|
||
iterating on `place` and `crop` is seconds, not minutes.
|
||
|
||
---
|
||
|
||
## How placement works
|
||
|
||
World pixels are overall-map pixels × `world.overallScale` (64), chosen so the
|
||
detail maps land near their native resolution — Customs works out to almost
|
||
exactly its 7832 px source width.
|
||
|
||
Tile grids have to stay integral: a map's tile-index offset must be a whole
|
||
number of tiles at every zoom, which only holds when its origin is a multiple
|
||
of `tileSize · 2^maxZoom`. That is 131 072 world pixels — far too coarse to
|
||
position anything. So rather than *moving* a map onto the grid, the tiler
|
||
**pads** it: the raster is padded up-and-left to the nearest cell boundary and
|
||
only tiles containing real content are ever visited. Exact placement, integral
|
||
grid, and the padding costs nothing.
|
||
|
||
Each map is also only tiled down to its **native level** — the deepest zoom at
|
||
which we are still downscaling its source. Past that the browser upscales,
|
||
which looks the same as upscaling during the build but without storing tiles.
|
||
`minZoom` likewise stops a map loading while it would be a speck on screen.
|