pixi-tiledmap 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,13 +12,17 @@ Load and render [Tiled Map Editor](http://www.mapeditor.org/) maps with [PixiJS
12
12
  - **All orientations** — orthogonal, isometric, staggered, hexagonal
13
13
  - **Render order** — right-down, right-up, left-down, left-up
14
14
  - **Infinite maps** — chunk-based tile layer rendering
15
- - **Tile features** — animated tiles, flip/rotation flags, image-collection tilesets, tint color
16
- - **Object rendering** — rectangles, ellipses, polygons, polylines, points, text, tile objects
17
- - **Data encoding** — CSV and base64 (uncompressed, gzip, zlib)
15
+ - **Tile features** — animated tiles, flip/rotation flags, image-collection tilesets, tint color, tile offset, `tilerendersize` / `fillmode`
16
+ - **Object rendering** — rectangles, ellipses, polygons, polylines, points, text (with underline/strikeout), tile objects
17
+ - **Object templates** — automatic `.tx` / `.tj` resolution with gid remapping between template and map tileset spaces
18
+ - **Parallax scrolling** — per-layer `parallaxx` / `parallaxy` and map-level `parallaxorigin`, composed multiplicatively through group layers, applied via `TiledMap.applyParallax(cameraX, cameraY)`
19
+ - **Data encoding** — CSV (both `.tmx` and `.tmj`) and base64 (uncompressed, gzip, zlib)
18
20
  - **External tilesets** — automatic resolution via the asset loader (`.tsj` and `.tsx`)
19
21
  - **Tree-shakable** — ESM + CJS dual build, side-effect-free
20
22
  - **Typed** — comprehensive TypeScript types for the full Tiled spec
21
23
 
24
+ > **Notes on Tiled-spec coverage.** `zstd`-compressed tile data is not supported — the browser's `DecompressionStream` API only exposes `gzip` and `deflate`, and this library intentionally ships with zero runtime dependencies. Wang sets and terrains are parsed and exposed on `ResolvedTileset` for introspection, but they are editor-only metadata with no runtime rendering behaviour.
25
+
22
26
  ## Installation
23
27
 
24
28
  ```sh
@@ -87,6 +91,7 @@ app.stage.addChild(container);
87
91
  | `parseMapAsync(data)` | Async variant (required for gzip/zlib compressed data) |
88
92
  | `parseTmx(xml)` | Parse TMX XML string → `TiledMap` data (same shape as JSON) |
89
93
  | `parseTsx(xml)` | Parse TSX XML string → `TiledTileset` data |
94
+ | `parseTx(xml)` | Parse TX XML string → `TiledObjectTemplate` data |
90
95
  | `decodeGid(raw)` | Decode a raw GID into tile ID + flip flags |
91
96
 
92
97
  ### `TiledMap` Container
@@ -104,8 +109,39 @@ map.mapHeight; // tile rows
104
109
  map.tileWidth; // tile pixel width
105
110
  map.tileHeight; // tile pixel height
106
111
  map.getLayer('ground'); // find layer Container by name
112
+
113
+ // Parallax: call after moving your camera each frame. Layers with
114
+ // parallaxx/parallaxy < 1 move slower than the camera; layers with
115
+ // parallax 0 are pinned in screen space. Group-layer parallax composes
116
+ // multiplicatively with its children.
117
+ map.applyParallax(camera.x, camera.y);
107
118
  ```
108
119
 
120
+ ### Object Templates
121
+
122
+ When loading through the asset loader, any object with a `template` field
123
+ is resolved automatically — referenced `.tx` / `.tj` files are fetched in
124
+ parallel and merged into the map before rendering.
125
+
126
+ For manual construction (`parseMap` / `parseMapAsync`), pass templates via
127
+ `ParseOptions.templates`:
128
+
129
+ ```ts
130
+ import { parseMap, parseTx } from 'pixi-tiledmap';
131
+
132
+ const templates = new Map();
133
+ templates.set('sign.tx', parseTx(await (await fetch('sign.tx')).text()));
134
+
135
+ const mapData = parseMap(data, { externalTilesets, templates });
136
+ ```
137
+
138
+ Template-instance merging follows Tiled semantics: the template's object
139
+ fields are the base, and the instance overrides any field it explicitly
140
+ sets (name, type, size, properties, gid, shape). If the template carries
141
+ an external-tileset reference whose `source` also exists in the map,
142
+ `gid` is translated from the template firstgid-space to the map
143
+ firstgid-space, preserving flip flags.
144
+
109
145
  ## Migration from v1
110
146
 
111
147
  | v1 (PixiJS v4) | v2 (PixiJS v8) |