@codexo/exojs-tilemap 0.17.0 → 0.19.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.
Files changed (87) hide show
  1. package/README.md +84 -109
  2. package/dist/esm/ChunkStreamer.d.ts.map +1 -1
  3. package/dist/esm/ChunkStreamer.js +28 -6
  4. package/dist/esm/ChunkStreamer.js.map +1 -1
  5. package/dist/esm/ImageLayer.d.ts +1 -1
  6. package/dist/esm/ImageLayer.d.ts.map +1 -1
  7. package/dist/esm/ImageLayerNode.d.ts +5 -1
  8. package/dist/esm/ImageLayerNode.d.ts.map +1 -1
  9. package/dist/esm/ImageLayerNode.js +7 -2
  10. package/dist/esm/ImageLayerNode.js.map +1 -1
  11. package/dist/esm/MapObject.d.ts +2 -2
  12. package/dist/esm/MapObject.d.ts.map +1 -1
  13. package/dist/esm/MapObject.js.map +1 -1
  14. package/dist/esm/MapObjectSpawner.d.ts.map +1 -1
  15. package/dist/esm/MapSpawnSession.d.ts.map +1 -1
  16. package/dist/esm/MapWorld.d.ts +8 -8
  17. package/dist/esm/MapWorld.d.ts.map +1 -1
  18. package/dist/esm/MapWorldRuntime.d.ts.map +1 -1
  19. package/dist/esm/ObjectLayer.d.ts +26 -10
  20. package/dist/esm/ObjectLayer.d.ts.map +1 -1
  21. package/dist/esm/ObjectLayer.js +28 -0
  22. package/dist/esm/ObjectLayer.js.map +1 -1
  23. package/dist/esm/SampledChunkSource.d.ts.map +1 -1
  24. package/dist/esm/TileAnimator.d.ts.map +1 -1
  25. package/dist/esm/TileChunk.d.ts.map +1 -1
  26. package/dist/esm/TileChunkNode.js +47 -10
  27. package/dist/esm/TileChunkNode.js.map +1 -1
  28. package/dist/esm/TileLayer.d.ts +11 -2
  29. package/dist/esm/TileLayer.d.ts.map +1 -1
  30. package/dist/esm/TileLayer.js +20 -10
  31. package/dist/esm/TileLayer.js.map +1 -1
  32. package/dist/esm/TileLayerNode.d.ts +12 -5
  33. package/dist/esm/TileLayerNode.d.ts.map +1 -1
  34. package/dist/esm/TileLayerNode.js +44 -24
  35. package/dist/esm/TileLayerNode.js.map +1 -1
  36. package/dist/esm/TileMap.d.ts +6 -2
  37. package/dist/esm/TileMap.d.ts.map +1 -1
  38. package/dist/esm/TileMap.js +13 -12
  39. package/dist/esm/TileMap.js.map +1 -1
  40. package/dist/esm/TileMapBand.d.ts.map +1 -1
  41. package/dist/esm/TileMapNode.d.ts +6 -1
  42. package/dist/esm/TileMapNode.d.ts.map +1 -1
  43. package/dist/esm/TileMapNode.js +12 -4
  44. package/dist/esm/TileMapNode.js.map +1 -1
  45. package/dist/esm/TileMapView.d.ts +6 -1
  46. package/dist/esm/TileMapView.d.ts.map +1 -1
  47. package/dist/esm/TileMapView.js +9 -4
  48. package/dist/esm/TileMapView.js.map +1 -1
  49. package/dist/esm/TileProjection.d.ts +59 -0
  50. package/dist/esm/TileProjection.d.ts.map +1 -0
  51. package/dist/esm/TileProjection.js +106 -0
  52. package/dist/esm/TileProjection.js.map +1 -0
  53. package/dist/esm/TileSet.d.ts.map +1 -1
  54. package/dist/esm/WangSet.d.ts.map +1 -1
  55. package/dist/esm/WorkerSampledChunkSource.d.ts +4 -7
  56. package/dist/esm/WorkerSampledChunkSource.d.ts.map +1 -1
  57. package/dist/esm/WorkerSampledChunkSource.js +12 -18
  58. package/dist/esm/WorkerSampledChunkSource.js.map +1 -1
  59. package/dist/esm/autoTile.d.ts.map +1 -1
  60. package/dist/esm/chunkGeometry.js +78 -50
  61. package/dist/esm/chunkGeometry.js.map +1 -1
  62. package/dist/esm/index.js +2 -1
  63. package/dist/esm/projectObject.d.ts +4 -0
  64. package/dist/esm/projectObject.d.ts.map +1 -0
  65. package/dist/esm/projectObject.js +87 -0
  66. package/dist/esm/projectObject.js.map +1 -0
  67. package/dist/esm/public.d.ts +1 -0
  68. package/dist/esm/public.d.ts.map +1 -1
  69. package/dist/esm/tileCollision.d.ts +2 -2
  70. package/dist/esm/tileCollision.d.ts.map +1 -1
  71. package/dist/esm/tileCollision.js +48 -16
  72. package/dist/esm/tileCollision.js.map +1 -1
  73. package/dist/esm/tilemapSerializers.js +1 -1
  74. package/dist/esm/tilemapSerializers.js.map +1 -1
  75. package/dist/esm/types.d.ts +3 -3
  76. package/dist/esm/types.d.ts.map +1 -1
  77. package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +8 -7
  78. package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
  79. package/dist/esm/webgl2/shaders/tile-chunk.frag.js +1 -1
  80. package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +1 -1
  81. package/dist/esm/webgl2/shaders/tile-chunk.vert.js +1 -1
  82. package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +1 -1
  83. package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +67 -31
  84. package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +1 -1
  85. package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +1 -1
  86. package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +1 -1
  87. package/package.json +4 -4
package/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # @codexo/exojs-tilemap
2
2
 
3
- Generic, format-independent tilemap runtime **and** WebGL2/WebGPU chunk renderer for
4
- [ExoJS](https://exojs.dev). No Tiled (or any other on-disk format) vocabulary leaks into this
5
- package — adapters such as [`@codexo/exojs-tiled`](https://www.npmjs.com/package/@codexo/exojs-tiled)
6
- parse their format and hand this runtime fully-resolved tiles.
3
+ Generic, format-independent tilemap runtime **and** WebGL2/WebGPU chunk renderer for [ExoJS](https://exoridus.github.io/ExoJS/). No Tiled (or any other on-disk format) vocabulary leaks into this package - adapters such as [`@codexo/exojs-tiled`](https://www.npmjs.com/package/@codexo/exojs-tiled) parse their format and hand this runtime fully resolved tiles.
7
4
 
8
5
  ## Installation
9
6
 
@@ -11,99 +8,95 @@ parse their format and hand this runtime fully-resolved tiles.
11
8
  npm install @codexo/exojs @codexo/exojs-tilemap
12
9
  ```
13
10
 
14
- `@codexo/exojs` is a peer dependency, so install it explicitly. This package is itself a peer of
15
- the format adapters (`@codexo/exojs-tiled`, `@codexo/exojs-ldtk`) rather than something they pull
16
- in transitively — install it whether you use an adapter or build procedural / custom-format maps
17
- directly.
11
+ `@codexo/exojs` is a peer dependency, so install it explicitly. This package is itself a peer of the format adapters (`@codexo/exojs-tiled`, `@codexo/exojs-ldtk`) rather than something they pull in transitively — install it whether you use an adapter or build procedural / custom-format maps directly.
18
12
 
19
13
  ## What this package provides
20
14
 
21
15
  **Runtime (data model)** — pure data, no scene graph:
22
16
 
23
17
  - `TileMap` — a finite, chunk-first map: dimensions, tile size, `tilesets`, ordered `layers`.
24
- - `TileLayer` — one tile layer; packed `Uint32Array` chunk storage, `visible` / `opacity` /
25
- `offsetX/Y`, queries, and revision tracking.
18
+ - `TileLayer` — one tile layer; packed `Uint32Array` chunk storage, `visible` / `opacity` / `offsetX/Y`, queries, and revision tracking.
26
19
  - `TileSet` — a resolved tileset grid over a Core `TextureRegion` (Loader-owned texture).
27
- - `ResolvedTile` / `TileTransform` — value-typed tile references with `flipX` / `flipY` /
28
- `diagonal` orientation.
20
+ - `ResolvedTile` / `TileTransform` — value-typed tile references with `flipX` / `flipY` / `diagonal` orientation.
29
21
 
30
22
  **Worlds and level lifetime** — format-neutral, driven by whichever adapter loaded the data:
31
23
 
32
- - `MapWorld` / `MapLevel` — where levels sit: stable id, world bounds, neighbour graph,
33
- externality. Metadata only; no tiles, no textures.
34
- - `MapWorldRuntime` — explicit `loadLevel` / `unloadLevel`, one child `LoaderScope` per level,
35
- at most one live level per id. No camera policy: the game decides what to load.
36
- - `MapLevelRuntime` — one loaded level's map, scope and spawn session, with a single
37
- `destroy()` that tears all three down in a safe order.
24
+ - `MapWorld` / `MapLevel` — where levels sit: stable id, world bounds, neighbour graph, externality. Metadata only; no tiles, no textures.
25
+ - `MapWorldRuntime` — explicit `loadLevel` / `unloadLevel`, one child `LoaderScope` per level, at most one live level per id. No camera policy: the game decides what to load.
26
+ - `MapLevelRuntime` — one loaded level's map, scope and spawn session, with a single `destroy()` that tears all three down in a safe order.
38
27
 
39
28
  **Map object spawning**:
40
29
 
41
- - `MapObjectSpawner` — a local (never global) dispatch table from object class to a factory.
42
- Deterministic order, atomic rollback, `AbortSignal` cancellation.
30
+ - `MapObjectSpawner` — a local (never global) dispatch table from object class to a factory. Deterministic order, atomic rollback, `AbortSignal` cancellation.
43
31
  - `MapObjectDescriptor` — the format-neutral view of one authored object handed to a factory.
44
- - `MapSpawnSession` — owns what one spawn produced; constant-time lookup by stable source id,
45
- reverse-order teardown.
32
+ - `MapSpawnSession` — owns what one spawn produced; constant-time lookup by stable source id, reverse-order teardown.
46
33
 
47
34
  **Scene / rendering (`@advanced`)**:
48
35
 
49
36
  - `TileMapNode` — convenience root that renders a whole `TileMap`.
50
- - `TileLayerNode` — renders one `TileLayer`; generated per layer by `TileMapView` (or construct
51
- directly).
52
- - `TileMapView` — groups a map's layers into independently placeable layer nodes and named
53
- `TileMapBand`s for actor interleaving (a helper, not a scene node).
37
+ - `TileLayerNode` — renders one `TileLayer`; generated per layer by `TileMapView` (or construct directly).
38
+ - `TileMapView` — groups a map's layers into independently placeable layer nodes and named `TileMapBand`s for actor interleaving (a helper, not a scene node).
54
39
  - `TileMapBand` — a `Container` of tile-layer nodes produced by `TileMapView`.
55
40
  - `tilemapExtension` — extension descriptor carrying the WebGL2/WebGPU renderer bindings.
56
41
 
57
42
  ## Usage — procedural map
58
43
 
59
44
  ```ts
60
- import { Application, TextureRegion } from '@codexo/exojs';
45
+ import { Application, Scene, type Texture, TextureRegion } from '@codexo/exojs';
61
46
  import { TileLayer, TileMap, TileMapNode, TileSet, tilemapExtension, TILE_TRANSFORM_IDENTITY } from '@codexo/exojs-tilemap';
62
47
 
63
- const app = new Application({ extensions: [tilemapExtension] /* canvas, … */ });
64
-
65
- // Tileset over a Loader-owned atlas texture (the runtime never destroys it).
66
- const atlas = await app.loader.load('tiles.png');
67
- const terrain = new TileSet({
68
- name: 'terrain',
69
- texture: new TextureRegion(atlas, { x: 0, y: 0, width: atlas.width, height: atlas.height }),
70
- tileWidth: 16,
71
- tileHeight: 16,
72
- tileCount: 256,
73
- });
48
+ class WorldScene extends Scene {
49
+ private atlas: Texture | null = null;
50
+
51
+ public override async load(): Promise<void> {
52
+ // A Loader-owned atlas texture: the tilemap runtime never destroys it.
53
+ this.atlas = await this.loader.load('tiles.png');
54
+ }
55
+
56
+ public override init(): void {
57
+ const atlas = this.atlas!;
58
+ const terrain = new TileSet({
59
+ name: 'terrain',
60
+ texture: new TextureRegion(atlas, { x: 0, y: 0, width: atlas.width, height: atlas.height }),
61
+ tileWidth: 16,
62
+ tileHeight: 16,
63
+ tileCount: 256,
64
+ });
65
+
66
+ const ground = new TileLayer({
67
+ id: 1,
68
+ name: 'ground',
69
+ width: 64,
70
+ height: 64,
71
+ tileWidth: 16,
72
+ tileHeight: 16,
73
+ tilesets: [terrain],
74
+ });
75
+ ground.setTileAt(0, 0, { tileset: terrain, localTileId: 5, transform: TILE_TRANSFORM_IDENTITY });
76
+
77
+ const map = new TileMap({
78
+ name: 'world',
79
+ width: 64,
80
+ height: 64,
81
+ tileWidth: 16,
82
+ tileHeight: 16,
83
+ tilesets: [terrain],
84
+ layers: [ground],
85
+ });
86
+
87
+ // Render the whole map: a scene draws its root without a draw() override.
88
+ this.addChild(new TileMapNode(map));
89
+ }
90
+ }
74
91
 
75
- const ground = new TileLayer({
76
- id: 1,
77
- name: 'ground',
78
- width: 64,
79
- height: 64,
80
- tileWidth: 16,
81
- tileHeight: 16,
82
- tilesets: [terrain],
83
- });
84
- ground.setTileAt(0, 0, { tileset: terrain, localTileId: 5, transform: TILE_TRANSFORM_IDENTITY });
85
-
86
- const map = new TileMap({
87
- name: 'world',
88
- width: 64,
89
- height: 64,
90
- tileWidth: 16,
91
- tileHeight: 16,
92
- tilesets: [terrain],
93
- layers: [ground],
94
- });
92
+ const app = new Application({ extensions: [tilemapExtension] /* canvas, … */ });
95
93
 
96
- // Render the whole map.
97
- app.scenes.root.addChild(new TileMapNode(map));
94
+ await app.start(WorldScene);
98
95
  ```
99
96
 
100
97
  ### Interleaving actors between layers — `TileMapView`
101
98
 
102
- `TileMapNode` owns **only** the map's layer nodes and renders them back-to-front — use it when
103
- nothing renders between layers. To draw application actors _between_ tile layers, create a
104
- `TileMapView`: it generates one `TileLayerNode` per map layer (stable identity, map document
105
- order) and groups them into named `TileMapBand`s that you parent yourself, as siblings of your
106
- own actor containers:
99
+ `TileMapNode` owns **only** the map's layer nodes and renders them back-to-front — use it when nothing renders between layers. To draw application actors _between_ tile layers, create a `TileMapView`: it generates one `TileLayerNode` per map layer (stable identity, map document order) and groups them into named `TileMapBand`s that you parent yourself, as siblings of your own actor containers:
107
100
 
108
101
  ```ts
109
102
  const view = map.createView({
@@ -130,63 +123,45 @@ worldRoot.addChild(view.getLayerNodeById(groundId)!, actors, view.getLayerNodeBy
130
123
 
131
124
  Actors are application-owned siblings. `TileMapView` never adopts or destroys actors.
132
125
 
133
- - A band definition **selects** layers (by id, or by unique layer name); rendering order within
134
- a band always follows map document order — definitions never reorder layers.
135
- - Layers not listed in any band stay reachable via `view.getLayerNodeById(id)` /
136
- `view.getLayerNodesByName(name)`; they are not auto-added to any band.
137
- - Destroying a view or a band destroys only the tile nodes it generated — never actors, the
138
- `TileMap`, its `TileLayer`s, or tileset textures.
139
- - There is no map-replacement API: to swap maps, destroy the old view and create a new view from
140
- the new map — the actor tree is untouched.
141
- - After layers are structurally added to or removed from the map, call `view.refreshLayers()`:
142
- unchanged layer nodes keep their identity and bands keep their placement in your scene graph.
126
+ - A band definition **selects** layers (by id, or by unique layer name); rendering order within a band always follows map document order — definitions never reorder layers.
127
+ - Layers not listed in any band stay reachable via `view.getLayerNodeById(id)` / `view.getLayerNodesByName(name)`; they are not auto-added to any band.
128
+ - Destroying a view or a band destroys only the tile nodes it generated — never actors, the `TileMap`, its `TileLayer`s, or tileset textures.
129
+ - There is no map-replacement API: to swap maps, destroy the old view and create a new view from the new map — the actor tree is untouched.
130
+ - After layers are structurally added to or removed from the map, call `view.refreshLayers()`: unchanged layer nodes keep their identity and bands keep their placement in your scene graph.
131
+
132
+ ## Isometric grids
133
+
134
+ Supply a shared `TileProjection({ orientation: 'isometric', tileWidth, tileHeight, originX, originY })` to the map and each tile layer. Orthogonal is the default. `tileToPixel()` projects the cell's top diamond vertex; `pixelToTile()` inversely projects and floors both grid axes, including negative coordinates. Cell boundaries are half-open. `projection.logicalToPixel()` and `pixelToLogical()` preserve fractional coordinates. Isometric logical cells are squares of side `tileHeight`; display diamonds may have any positive integer width and height.
135
+
136
+ Layer offsets are display translations. `TileLayer.logicalOffset` exposes the corresponding logical vector for simulation. A map's pixel dimensions describe the projected grid AABB, while `projection.getBounds()` also supplies its possibly negative origin. Scene-node bounds include isometric artwork overhangs and tileset offsets. Picking describes cells, not opaque pixels of tall artwork; apply inverse scene and camera transforms before calling the map/layer helpers.
137
+
138
+ Isometric rendering splits resident storage chunks into diagonal draw sections, sorted across chunks by increasing `tx + ty`, then increasing `tx`. Only consecutive tiles with the same texture are batched, so tall tiles preserve painter order across texture and chunk boundaries. Geometry stays revision-cached. All sections share a layer-grid snap origin, including odd tile sizes. More draw sections and texture changes can cost more than orthogonal batching; no throughput improvement is promised.
139
+
140
+ Object layers remain data-only. With a projection their objects use logical coordinates; `layer.getDisplayObject(object)` returns display geometry with the layer offset applied. Rectangles may become polygons and ellipses retain their exact affine shape. Tile/text dimensions stay in display pixels. Actors remain application-owned; bands interleave them between layers, not automatically among individual terrain tiles.
143
141
 
144
142
  ## Renderer model
145
143
 
146
- - **Chunk-first.** A `TileLayerNode` is a container of per-chunk `TileChunkNode` drawables (one
147
- per non-empty loaded chunk). The renderer batches tiles by `(shader, tileset texture)` and
148
- issues one instanced draw per batch — draw calls scale with _visible chunks × layers_, not
149
- total tile count.
150
- - **Revision-cached geometry.** Each chunk's quad geometry is built once and cached against the
151
- source chunk's `revision`. Unchanged chunks never rebuild; a camera pan rebuilds nothing —
152
- off-screen chunks are culled by their local bounds before any geometry is touched.
153
- - **Orientation.** `flipX` / `flipY` / `diagonal` are baked into the chunk geometry / resolved in
154
- the shader (all 8 combinations), with no per-tile matrix or per-frame cost.
155
- - **Multiple tilesets** with differing tile sizes are first-class; tiles taller than the map grid
156
- are bottom-left aligned (Tiled orthogonal convention).
157
- - **WebGL2 and WebGPU** share one CPU geometry builder and produce identical output (golden
158
- parity tested on both backends).
159
- - **Sampling.** Tile UVs are exact (no half-texel inset), which assumes **nearest** atlas
160
- filtering — the typical pixel-art case. Under linear or mipmap filtering, author tilesets with
161
- extruded tile margins to avoid neighbour bleed at tile edges (extrusion-aware tilemap UV
162
- insetting is a planned follow-up; the `NineSlice` / `RepeatingSprite` geometry paths already
163
- inset).
144
+ - **Chunk-first.** A `TileLayerNode` is a container of per-chunk `TileChunkNode` drawables (one per non-empty loaded chunk). The renderer batches tiles by `(shader, tileset texture)` and issues one instanced draw per batch — draw calls scale with _visible chunks × layers_, not total tile count.
145
+ - **Revision-cached geometry.** Each chunk's quad geometry is built once and cached against the source chunk's `revision`. Unchanged chunks never rebuild; a camera pan rebuilds nothing — off-screen chunks are culled by their local bounds before any geometry is touched.
146
+ - **Orientation.** `flipX` / `flipY` / `diagonal` are baked into the chunk geometry / resolved in the shader (all 8 combinations), with no per-tile matrix or per-frame cost.
147
+ - **Multiple tilesets** with differing tile sizes are first-class; tiles taller than the map grid are bottom-left aligned (Tiled orthogonal convention).
148
+ - **WebGL2 and WebGPU** share one CPU geometry builder and produce identical output (golden parity tested on both backends).
149
+ - **Sampling.** Tile UVs are exact (no half-texel inset), which assumes **nearest** atlas filtering - the typical pixel-art case. Under linear or mipmap filtering, author tilesets with extruded tile margins to avoid neighbour bleed at tile edges; the tilemap renderer does not apply an extrusion-aware inset.
164
150
 
165
151
  ## Ownership & lifecycle
166
152
 
167
153
  - Tileset **textures are Loader-owned**. The runtime and renderer never destroy them.
168
- - A `MapWorldRuntime` owns the scope it creates under the one you give it, plus one child scope
169
- per loaded level - never the scope you passed in. A `MapLevelRuntime` owns the `TileMap` its
170
- provider returned, its spawn session, and its scope; `destroy()` releases them in that order.
171
- - `TileMapNode` / `TileMapView` / `TileMapBand` / `TileLayerNode` reference — but never own —
172
- the `TileMap`. Destroying a map node, view, or band frees only the tile nodes it generated
173
- (detaching them from their application parents) and their cached geometry; application actors,
174
- the `TileMap` data, its `TileLayer`s, and textures all survive. Free those via
175
- `TileMap.destroy()` and `Loader.destroy()` respectively.
176
- - A `TileMapNode` or `TileMapView` reflects the layer set at construction time. After layers are
177
- structurally added to or removed from the map call `node.refreshLayers()` /
178
- `view.refreshLayers()`; after tiles are written into previously-empty chunks call
179
- `layerNode.refresh()`. In-place edits to existing chunks are picked up automatically.
154
+ - A `MapWorldRuntime` owns the scope it creates under the one you give it, plus one child scope per loaded level - never the scope you passed in. A `MapLevelRuntime` owns the `TileMap` its provider returned, its spawn session, and its scope; `destroy()` releases them in that order.
155
+ - `TileMapNode` / `TileMapView` / `TileMapBand` / `TileLayerNode` reference — but never own — the `TileMap`. Destroying a map node, view, or band frees only the tile nodes it generated (detaching them from their application parents) and their cached geometry; application actors, the `TileMap` data, its `TileLayer`s, and textures all survive. Free those via `TileMap.destroy()` and `Loader.destroy()` respectively.
156
+ - A `TileMapNode` or `TileMapView` reflects the layer set at construction time. After layers are structurally added to or removed from the map call `node.refreshLayers()` / `view.refreshLayers()`; after tiles are written into previously-empty chunks call `layerNode.refresh()`. In-place edits to existing chunks are picked up automatically.
180
157
 
181
158
  ## Core compatibility
182
159
 
183
- | `@codexo/exojs-tilemap` | `@codexo/exojs` |
184
- | ----------------------- | --------------- |
185
- | 0.x | matching `0.x` |
160
+ This package follows the Core lockstep release line and declares the compatible `@codexo/exojs` minor as a peer dependency. Install matching package versions.
186
161
 
187
162
  ## Links
188
163
 
189
- - [API reference](https://exojs.dev/api/exojs-tilemap)
164
+ - [API reference](https://exoridus.github.io/ExoJS/en/api/)
190
165
  - [`@codexo/exojs-tiled`](https://www.npmjs.com/package/@codexo/exojs-tiled) — load Tiled `.tmj` maps into this runtime
191
166
 
192
167
  ## License
@@ -1 +1 @@
1
- {"version":3,"file":"ChunkStreamer.d.ts","sourceRoot":"","sources":["../../src/ChunkStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,aAAa,CAAC;AAGzD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CACzC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmE;IAC7F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IACvD,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;gBAER,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAapG,0EAA0E;IAC1E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,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAE3B,YAAmB,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,oBAAoB,EAWnG;IAED,0EAA0E;IAC1E,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;;;;;;OAOG;IACI,MAAM,IAAI,IAAI,CA0CpB;IAED;;;;;;;;;;OAUG;IACI,OAAO,IAAI,IAAI,CASrB;IAED,OAAO,CAAC,iBAAiB;IAmDzB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,QAAQ;IAqChB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CAUpB"}
@@ -126,14 +126,36 @@ var ChunkStreamer = class {
126
126
  const shiftX = centerX * (1 - layer.parallaxX);
127
127
  const shiftY = centerY * (1 - layer.parallaxY);
128
128
  const scale = layer.parallaxScale;
129
- const layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;
130
- const layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;
131
- const layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;
132
- const layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;
129
+ let layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;
130
+ let layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;
131
+ let layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;
132
+ let layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;
133
+ if (layer.projection.orientation === "isometric") {
134
+ let left = 0;
135
+ let top = 0;
136
+ let right = 0;
137
+ let bottom = 0;
138
+ for (const tileset of layer.tilesets) {
139
+ left = Math.max(left, tileset.tileWidth - layer.tileWidth / 2 + tileset.offsetX);
140
+ top = Math.max(top, layer.tileHeight + tileset.offsetY);
141
+ right = Math.max(right, layer.tileWidth / 2 - tileset.offsetX);
142
+ bottom = Math.max(bottom, tileset.tileHeight - layer.tileHeight - tileset.offsetY);
143
+ }
144
+ layerLeft -= left;
145
+ layerTop -= top;
146
+ layerRight += right;
147
+ layerBottom += bottom;
148
+ }
133
149
  const topLeftTile = layer.pixelToTile(layerLeft, layerTop);
134
150
  const bottomRightTile = layer.pixelToTile(layerRight, layerBottom);
135
- const topLeftChunk = tileToChunkCoord(topLeftTile.tx, topLeftTile.ty, layer.chunkWidth, layer.chunkHeight);
136
- const bottomRightChunk = tileToChunkCoord(bottomRightTile.tx, bottomRightTile.ty, layer.chunkWidth, layer.chunkHeight);
151
+ const topRightTile = layer.pixelToTile(layerRight, layerTop);
152
+ const bottomLeftTile = layer.pixelToTile(layerLeft, layerBottom);
153
+ const minTx = Math.min(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);
154
+ const minTy = Math.min(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);
155
+ const maxTx = Math.max(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);
156
+ const maxTy = Math.max(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);
157
+ const topLeftChunk = tileToChunkCoord(minTx, minTy, layer.chunkWidth, layer.chunkHeight);
158
+ const bottomRightChunk = tileToChunkCoord(maxTx, maxTy, layer.chunkWidth, layer.chunkHeight);
137
159
  return {
138
160
  minCx: topLeftChunk.cx,
139
161
  minCy: topLeftChunk.cy,
@@ -1 +1 @@
1
- {"version":3,"file":"ChunkStreamer.js","names":[],"sources":["../../src/ChunkStreamer.ts"],"sourcesContent":["import { logger, type View } from '@codexo/exojs';\n\nimport type { ChunkPayload, ChunkSource } from './ChunkSource';\nimport type { ChunkRange, TileLayer } from './TileLayer';\nimport { tileToChunkCoord } from './types';\n\n/**\n * Options for a {@link ChunkStreamer}. All optional.\n * @advanced\n */\nexport interface ChunkStreamerOptions {\n /**\n * Chunks within this many chunk-units (Chebyshev distance to the visible\n * chunk range) of the view are loaded. Default `1`.\n */\n readonly loadRadius?: number;\n /**\n * Own-resident chunks beyond this many chunk-units of the view are\n * evicted. Must be `>= loadRadius` - the gap between the two is\n * deliberate hysteresis that prevents load/unload thrashing when the\n * view sits near a chunk boundary. Default `2`.\n */\n readonly unloadRadius?: number;\n /**\n * Maximum number of new chunk loads issued per {@link ChunkStreamer.update}\n * call, after the very first call (which loads the entire initial wanted\n * set unbudgeted, so the starting view never pops in). Default `8`.\n */\n readonly maxChunkLoadsPerFrame?: number;\n}\n\nconst DEFAULT_LOAD_RADIUS = 1;\nconst DEFAULT_UNLOAD_RADIUS = 2;\nconst DEFAULT_MAX_CHUNK_LOADS_PER_FRAME = 8;\n\nconst chunkKey = (cx: number, cy: number): string => `${cx},${cy}`;\n\nconst isThenable = (value: unknown): value is Promise<ChunkPayload | null> =>\n value !== null && typeof value === 'object' && typeof (value as { then?: unknown }).then === 'function';\n\n/**\n * Drives {@link TileLayer._adoptChunk}/{@link TileLayer._evictChunk} calls\n * from a {@link View}'s position: chunks near the view are requested from a\n * {@link ChunkSource} and installed; chunks that scroll far enough away are\n * evicted. Works on both unbounded and bounded layers (a bounded-but-large\n * layer still benefits from not keeping every chunk resident at once) - for\n * a bounded layer, the wanted range is clamped to {@link TileLayer.chunkRange}.\n *\n * Touches only the {@link TileLayer} data layer -\n * {@link import('./TileLayerNode').TileLayerNode} reacts to\n * `_adoptChunk`/`_evictChunk` on its own via a structural listener, so this\n * class has no rendering dependency and no reference to any scene node.\n *\n * Tracks its own resident set (chunks *this instance* has loaded), never\n * touching chunks that predate its attachment or were installed by another\n * source.\n *\n * Tick it from your update loop, like {@link import('./TileAnimator').TileAnimator}:\n *\n * ```ts\n * const streamer = new ChunkStreamer(layer, mySource, view);\n * scene.systems.add({ update: () => streamer.update() });\n * ```\n *\n * @advanced\n */\nexport class ChunkStreamer {\n private readonly _layer: TileLayer;\n private readonly _source: ChunkSource;\n private readonly _view: View;\n private readonly _loadRadius: number;\n private readonly _unloadRadius: number;\n private readonly _maxChunkLoadsPerFrame: number;\n\n private readonly _resident = new Map<string, { readonly cx: number; readonly cy: number }>();\n private readonly _inFlight = new Map<string, number>();\n private _requestCounter = 0;\n private _primed = false;\n private _destroyed = false;\n\n public constructor(layer: TileLayer, source: ChunkSource, view: View, options?: ChunkStreamerOptions) {\n this._layer = layer;\n this._source = source;\n this._view = view;\n this._loadRadius = options?.loadRadius ?? DEFAULT_LOAD_RADIUS;\n this._unloadRadius = options?.unloadRadius ?? DEFAULT_UNLOAD_RADIUS;\n this._maxChunkLoadsPerFrame = options?.maxChunkLoadsPerFrame ?? DEFAULT_MAX_CHUNK_LOADS_PER_FRAME;\n\n if (this._unloadRadius < this._loadRadius) {\n throw new Error(`ChunkStreamer unloadRadius (${this._unloadRadius}) must be >= loadRadius (${this._loadRadius}).`);\n }\n }\n\n /** Number of chunks this instance currently has resident in the layer. */\n public get residentCount(): number {\n return this._resident.size;\n }\n\n /**\n * Recompute the wanted chunk set from the view's current position; evict\n * own-resident chunks that fell outside `unloadRadius`, then request\n * chunks newly inside `loadRadius`. The very first call loads the entire\n * initial wanted set unbudgeted; every later call is capped at\n * {@link ChunkStreamerOptions.maxChunkLoadsPerFrame}. No-op once\n * {@link destroy}ed.\n */\n public update(): void {\n if (this._destroyed) return;\n\n const core = this._computeCoreRange();\n\n this._unload(core);\n\n const range = this._layer.chunkRange();\n let minCx = core.minCx - this._loadRadius;\n let minCy = core.minCy - this._loadRadius;\n let maxCx = core.maxCx + this._loadRadius;\n let maxCy = core.maxCy + this._loadRadius;\n if (range !== null) {\n minCx = Math.max(minCx, range.minCx);\n minCy = Math.max(minCy, range.minCy);\n maxCx = Math.min(maxCx, range.maxCx);\n maxCy = Math.min(maxCy, range.maxCy);\n }\n\n const toLoad: Array<{ cx: number; cy: number }> = [];\n for (let cy = minCy; cy <= maxCy; cy++) {\n for (let cx = minCx; cx <= maxCx; cx++) {\n const key = chunkKey(cx, cy);\n if (this._resident.has(key) || this._inFlight.has(key)) continue;\n toLoad.push({ cx, cy });\n }\n }\n\n if (!this._primed) {\n this._primed = true;\n for (const { cx, cy } of toLoad) {\n this._request(cx, cy);\n }\n return;\n }\n\n toLoad.sort((a, b) => this._rangeDistance(a.cx, a.cy, core) - this._rangeDistance(b.cx, b.cy, core));\n\n const budget = Math.min(this._maxChunkLoadsPerFrame, toLoad.length);\n for (const { cx, cy } of toLoad.slice(0, budget)) {\n this._request(cx, cy);\n }\n }\n\n /**\n * Evict every chunk this instance has loaded and stop responding to\n * {@link update}. Does not affect chunks predating attachment or\n * installed by another source. Idempotent.\n *\n * Does not destroy the {@link ChunkSource} passed to the constructor: this\n * class only reads from it and never took ownership. A source with its own\n * `destroy()` (e.g. {@link import('./WorkerSampledChunkSource').createWorkerSampledChunkSource}'s,\n * which tears down a real `Worker`) must be destroyed separately by\n * whoever created it.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n\n for (const { cx, cy } of this._resident.values()) {\n this._layer._evictChunk(cx, cy);\n }\n this._resident.clear();\n this._inFlight.clear();\n }\n\n private _computeCoreRange(): ChunkRange {\n const layer = this._layer;\n const view = this._view;\n const bounds = view.getBounds();\n const centerX = view.center.x;\n const centerY = view.center.y;\n\n const shiftX = centerX * (1 - layer.parallaxX);\n const shiftY = centerY * (1 - layer.parallaxY);\n const scale = layer.parallaxScale;\n\n const layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;\n const layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;\n const layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;\n const layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;\n const topLeftTile = layer.pixelToTile(layerLeft, layerTop);\n const bottomRightTile = layer.pixelToTile(layerRight, layerBottom);\n\n const topLeftChunk = tileToChunkCoord(topLeftTile.tx, topLeftTile.ty, layer.chunkWidth, layer.chunkHeight);\n const bottomRightChunk = tileToChunkCoord(bottomRightTile.tx, bottomRightTile.ty, layer.chunkWidth, layer.chunkHeight);\n\n return {\n minCx: topLeftChunk.cx,\n minCy: topLeftChunk.cy,\n maxCx: bottomRightChunk.cx,\n maxCy: bottomRightChunk.cy,\n };\n }\n\n private _rangeDistance(cx: number, cy: number, range: ChunkRange): number {\n const dx = Math.max(range.minCx - cx, 0, cx - range.maxCx);\n const dy = Math.max(range.minCy - cy, 0, cy - range.maxCy);\n return Math.max(dx, dy);\n }\n\n private _unload(core: ChunkRange): void {\n for (const [key, { cx, cy }] of this._resident) {\n if (this._rangeDistance(cx, cy, core) > this._unloadRadius) {\n this._layer._evictChunk(cx, cy);\n this._resident.delete(key);\n }\n }\n }\n\n private _request(cx: number, cy: number): void {\n const key = chunkKey(cx, cy);\n const token = ++this._requestCounter;\n this._inFlight.set(key, token);\n\n let result: ChunkPayload | null | Promise<ChunkPayload | null>;\n try {\n result = this._source.getChunk(cx, cy);\n } catch (error) {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) threw synchronously.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n\n return;\n }\n\n if (isThenable(result)) {\n result.then(\n payload => {\n this._onResolved(key, cx, cy, token, payload);\n },\n (error: unknown) => {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) rejected.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n },\n );\n return;\n }\n\n this._onResolved(key, cx, cy, token, result);\n }\n\n /**\n * Ignore-on-resolve: only the `_destroyed` and in-flight-token checks\n * guard installation - a chunk that scrolled out of the wanted set while\n * its request was in flight is still installed if it resolves (installing\n * it is cheap and self-correcting: the next {@link update} call's unload\n * pass evicts it again if it's genuinely no longer wanted). There is no\n * edit-persistence to protect, so discarding is never destructive.\n */\n private _onResolved(key: string, cx: number, cy: number, token: number, payload: ChunkPayload | null): void {\n if (this._destroyed) return;\n if (this._inFlight.get(key) !== token) return;\n this._inFlight.delete(key);\n\n if (payload === null) return;\n\n this._layer._adoptChunk(cx, cy, payload);\n this._resident.set(key, { cx, cy });\n }\n}\n"],"mappings":";;;;AA+BA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,oCAAoC;AAE1C,MAAM,YAAY,IAAY,OAAuB,GAAG,GAAG,GAAG;AAE9D,MAAM,cAAc,UAClB,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAQ,MAA6B,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/F,IAAa,gBAAb,MAA2B;CACzB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAiB,4BAAY,IAAI,IAA0D;CAC3F,AAAiB,4BAAY,IAAI,IAAoB;CACrD,AAAQ,kBAAkB;CAC1B,AAAQ,UAAU;CAClB,AAAQ,aAAa;CAErB,AAAO,YAAY,OAAkB,QAAqB,MAAY,SAAgC;EACpG,KAAK,SAAS;EACd,KAAK,UAAU;EACf,KAAK,QAAQ;EACb,KAAK,cAAc,SAAS,cAAc;EAC1C,KAAK,gBAAgB,SAAS,gBAAgB;EAC9C,KAAK,yBAAyB,SAAS,yBAAyB;EAEhE,IAAI,KAAK,gBAAgB,KAAK,aAC5B,MAAM,IAAI,MAAM,+BAA+B,KAAK,cAAc,2BAA2B,KAAK,YAAY,GAAG;CAErH;;CAGA,IAAW,gBAAwB;EACjC,OAAO,KAAK,UAAU;CACxB;;;;;;;;;CAUA,AAAO,SAAe;EACpB,IAAI,KAAK,YAAY;EAErB,MAAM,OAAO,KAAK,kBAAkB;EAEpC,KAAK,QAAQ,IAAI;EAEjB,MAAM,QAAQ,KAAK,OAAO,WAAW;EACrC,IAAI,QAAQ,KAAK,QAAQ,KAAK;EAC9B,IAAI,QAAQ,KAAK,QAAQ,KAAK;EAC9B,IAAI,QAAQ,KAAK,QAAQ,K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A,AAAQ,SAAS,IAAY,IAAkB;EAC7C,MAAM,MAAM,SAAS,IAAI,EAAE;EAC3B,MAAM,QAAQ,EAAE,KAAK;EACrB,KAAK,UAAU,IAAI,KAAK,KAAK;EAE7B,IAAI;EACJ,IAAI;GACF,SAAS,KAAK,QAAQ,SAAS,IAAI,EAAE;EACvC,SAAS,OAAO;GACd,KAAK,UAAU,OAAO,GAAG;GACzB,OAAO,KAAK,kCAAkC,GAAG,IAAI,GAAG,yBAAyB;IAC/E,QAAQ;IACR,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GACjE,CAAC;GAED;EACF;EAEA,IAAI,WAAW,MAAM,GAAG;GACtB,OAAO,MACL,YAAW;IACT,KAAK,YAAY,KAAK,IAAI,IAAI,OAAO,OAAO;GAC9C,IACC,UAAmB;IAClB,KAAK,UAAU,OAAO,GAAG;IACzB,OAAO,KAAK,kCAAkC,GAAG,IAAI,GAAG,cAAc;KACpE,QAAQ;KACR,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;IACjE,CAAC;GACH,CACF;GACA;EACF;EAEA,KAAK,YAAY,KAAK,IAAI,IAAI,OAAO,MAAM;CAC7C;;;;;;;;;CAUA,AAAQ,YAAY,KAAa,IAAY,IAAY,OAAe,SAAoC;EAC1G,IAAI,KAAK,YAAY;EACrB,IAAI,KAAK,UAAU,IAAI,GAAG,MAAM,OAAO;EACvC,KAAK,UAAU,OAAO,GAAG;EAEzB,IAAI,YAAY,MAAM;EAEtB,KAAK,OAAO,YAAY,IAAI,IAAI,OAAO;EACvC,KAAK,UAAU,IAAI,KAAK;GAAE;GAAI;EAAG,CAAC;CACpC;AACF"}
1
+ {"version":3,"file":"ChunkStreamer.js","names":[],"sources":["../../src/ChunkStreamer.ts"],"sourcesContent":["import { logger, type View } from '@codexo/exojs';\n\nimport type { ChunkPayload, ChunkSource } from './ChunkSource';\nimport type { ChunkRange, TileLayer } from './TileLayer';\nimport { tileToChunkCoord } from './types';\n\n/**\n * Options for a {@link ChunkStreamer}. All optional.\n * @advanced\n */\nexport interface ChunkStreamerOptions {\n /**\n * Chunks within this many chunk-units (Chebyshev distance to the visible\n * chunk range) of the view are loaded. Default `1`.\n */\n readonly loadRadius?: number;\n /**\n * Own-resident chunks beyond this many chunk-units of the view are\n * evicted. Must be `>= loadRadius` - the gap between the two is\n * deliberate hysteresis that prevents load/unload thrashing when the\n * view sits near a chunk boundary. Default `2`.\n */\n readonly unloadRadius?: number;\n /**\n * Maximum number of new chunk loads issued per {@link ChunkStreamer.update}\n * call, after the very first call (which loads the entire initial wanted\n * set unbudgeted, so the starting view never pops in). Default `8`.\n */\n readonly maxChunkLoadsPerFrame?: number;\n}\n\nconst DEFAULT_LOAD_RADIUS = 1;\nconst DEFAULT_UNLOAD_RADIUS = 2;\nconst DEFAULT_MAX_CHUNK_LOADS_PER_FRAME = 8;\n\nconst chunkKey = (cx: number, cy: number): string => `${cx},${cy}`;\n\nconst isThenable = (value: unknown): value is Promise<ChunkPayload | null> =>\n value !== null && typeof value === 'object' && typeof (value as { then?: unknown }).then === 'function';\n\n/**\n * Drives {@link TileLayer._adoptChunk}/{@link TileLayer._evictChunk} calls\n * from a {@link View}'s position: chunks near the view are requested from a\n * {@link ChunkSource} and installed; chunks that scroll far enough away are\n * evicted. Works on both unbounded and bounded layers (a bounded-but-large\n * layer still benefits from not keeping every chunk resident at once) - for\n * a bounded layer, the wanted range is clamped to {@link TileLayer.chunkRange}.\n *\n * Touches only the {@link TileLayer} data layer -\n * {@link import('./TileLayerNode').TileLayerNode} reacts to\n * `_adoptChunk`/`_evictChunk` on its own via a structural listener, so this\n * class has no rendering dependency and no reference to any scene node.\n *\n * Tracks its own resident set (chunks *this instance* has loaded), never\n * touching chunks that predate its attachment or were installed by another\n * source.\n *\n * Tick it from your update loop, like {@link import('./TileAnimator').TileAnimator}:\n *\n * ```ts\n * const streamer = new ChunkStreamer(layer, mySource, view);\n * scene.systems.add({ update: () => streamer.update() });\n * ```\n *\n * @advanced\n */\nexport class ChunkStreamer {\n private readonly _layer: TileLayer;\n private readonly _source: ChunkSource;\n private readonly _view: View;\n private readonly _loadRadius: number;\n private readonly _unloadRadius: number;\n private readonly _maxChunkLoadsPerFrame: number;\n\n private readonly _resident = new Map<string, { readonly cx: number; readonly cy: number }>();\n private readonly _inFlight = new Map<string, number>();\n private _requestCounter = 0;\n private _primed = false;\n private _destroyed = false;\n\n public constructor(layer: TileLayer, source: ChunkSource, view: View, options?: ChunkStreamerOptions) {\n this._layer = layer;\n this._source = source;\n this._view = view;\n this._loadRadius = options?.loadRadius ?? DEFAULT_LOAD_RADIUS;\n this._unloadRadius = options?.unloadRadius ?? DEFAULT_UNLOAD_RADIUS;\n this._maxChunkLoadsPerFrame = options?.maxChunkLoadsPerFrame ?? DEFAULT_MAX_CHUNK_LOADS_PER_FRAME;\n\n if (this._unloadRadius < this._loadRadius) {\n throw new Error(`ChunkStreamer unloadRadius (${this._unloadRadius}) must be >= loadRadius (${this._loadRadius}).`);\n }\n }\n\n /** Number of chunks this instance currently has resident in the layer. */\n public get residentCount(): number {\n return this._resident.size;\n }\n\n /**\n * Recompute the wanted chunk set from the view's current position; evict\n * own-resident chunks that fell outside `unloadRadius`, then request\n * chunks newly inside `loadRadius`. The very first call loads the entire\n * initial wanted set unbudgeted; every later call is capped at\n * {@link ChunkStreamerOptions.maxChunkLoadsPerFrame}. No-op once\n * {@link destroy}ed.\n */\n public update(): void {\n if (this._destroyed) return;\n\n const core = this._computeCoreRange();\n\n this._unload(core);\n\n const range = this._layer.chunkRange();\n let minCx = core.minCx - this._loadRadius;\n let minCy = core.minCy - this._loadRadius;\n let maxCx = core.maxCx + this._loadRadius;\n let maxCy = core.maxCy + this._loadRadius;\n if (range !== null) {\n minCx = Math.max(minCx, range.minCx);\n minCy = Math.max(minCy, range.minCy);\n maxCx = Math.min(maxCx, range.maxCx);\n maxCy = Math.min(maxCy, range.maxCy);\n }\n\n const toLoad: Array<{ cx: number; cy: number }> = [];\n for (let cy = minCy; cy <= maxCy; cy++) {\n for (let cx = minCx; cx <= maxCx; cx++) {\n const key = chunkKey(cx, cy);\n if (this._resident.has(key) || this._inFlight.has(key)) continue;\n toLoad.push({ cx, cy });\n }\n }\n\n if (!this._primed) {\n this._primed = true;\n for (const { cx, cy } of toLoad) {\n this._request(cx, cy);\n }\n return;\n }\n\n toLoad.sort((a, b) => this._rangeDistance(a.cx, a.cy, core) - this._rangeDistance(b.cx, b.cy, core));\n\n const budget = Math.min(this._maxChunkLoadsPerFrame, toLoad.length);\n for (const { cx, cy } of toLoad.slice(0, budget)) {\n this._request(cx, cy);\n }\n }\n\n /**\n * Evict every chunk this instance has loaded and stop responding to\n * {@link update}. Does not affect chunks predating attachment or\n * installed by another source. Idempotent.\n *\n * Does not destroy the {@link ChunkSource} passed to the constructor: this\n * class only reads from it and never took ownership. A source with its own\n * `destroy()` (e.g. {@link import('./WorkerSampledChunkSource').createWorkerSampledChunkSource}'s,\n * which tears down a real `Worker`) must be destroyed separately by\n * whoever created it.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n\n for (const { cx, cy } of this._resident.values()) {\n this._layer._evictChunk(cx, cy);\n }\n this._resident.clear();\n this._inFlight.clear();\n }\n\n private _computeCoreRange(): ChunkRange {\n const layer = this._layer;\n const view = this._view;\n const bounds = view.getBounds();\n const centerX = view.center.x;\n const centerY = view.center.y;\n\n const shiftX = centerX * (1 - layer.parallaxX);\n const shiftY = centerY * (1 - layer.parallaxY);\n const scale = layer.parallaxScale;\n\n let layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;\n let layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;\n let layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;\n let layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;\n if (layer.projection.orientation === 'isometric') {\n let left = 0;\n let top = 0;\n let right = 0;\n let bottom = 0;\n for (const tileset of layer.tilesets) {\n left = Math.max(left, tileset.tileWidth - layer.tileWidth / 2 + tileset.offsetX);\n top = Math.max(top, layer.tileHeight + tileset.offsetY);\n right = Math.max(right, layer.tileWidth / 2 - tileset.offsetX);\n bottom = Math.max(bottom, tileset.tileHeight - layer.tileHeight - tileset.offsetY);\n }\n layerLeft -= left;\n layerTop -= top;\n layerRight += right;\n layerBottom += bottom;\n }\n const topLeftTile = layer.pixelToTile(layerLeft, layerTop);\n const bottomRightTile = layer.pixelToTile(layerRight, layerBottom);\n\n const topRightTile = layer.pixelToTile(layerRight, layerTop);\n const bottomLeftTile = layer.pixelToTile(layerLeft, layerBottom);\n const minTx = Math.min(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);\n const minTy = Math.min(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);\n const maxTx = Math.max(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);\n const maxTy = Math.max(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);\n const topLeftChunk = tileToChunkCoord(minTx, minTy, layer.chunkWidth, layer.chunkHeight);\n const bottomRightChunk = tileToChunkCoord(maxTx, maxTy, layer.chunkWidth, layer.chunkHeight);\n\n return {\n minCx: topLeftChunk.cx,\n minCy: topLeftChunk.cy,\n maxCx: bottomRightChunk.cx,\n maxCy: bottomRightChunk.cy,\n };\n }\n\n private _rangeDistance(cx: number, cy: number, range: ChunkRange): number {\n const dx = Math.max(range.minCx - cx, 0, cx - range.maxCx);\n const dy = Math.max(range.minCy - cy, 0, cy - range.maxCy);\n return Math.max(dx, dy);\n }\n\n private _unload(core: ChunkRange): void {\n for (const [key, { cx, cy }] of this._resident) {\n if (this._rangeDistance(cx, cy, core) > this._unloadRadius) {\n this._layer._evictChunk(cx, cy);\n this._resident.delete(key);\n }\n }\n }\n\n private _request(cx: number, cy: number): void {\n const key = chunkKey(cx, cy);\n const token = ++this._requestCounter;\n this._inFlight.set(key, token);\n\n let result: ChunkPayload | null | Promise<ChunkPayload | null>;\n try {\n result = this._source.getChunk(cx, cy);\n } catch (error) {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) threw synchronously.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n\n return;\n }\n\n if (isThenable(result)) {\n result.then(\n payload => {\n this._onResolved(key, cx, cy, token, payload);\n },\n (error: unknown) => {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) rejected.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n },\n );\n return;\n }\n\n this._onResolved(key, cx, cy, token, result);\n }\n\n /**\n * Ignore-on-resolve: only the `_destroyed` and in-flight-token checks\n * guard installation - a chunk that scrolled out of the wanted set while\n * its request was in flight is still installed if it resolves (installing\n * it is cheap and self-correcting: the next {@link update} call's unload\n * pass evicts it again if it's genuinely no longer wanted). There is no\n * edit-persistence to protect, so discarding is never destructive.\n */\n private _onResolved(key: string, cx: number, cy: number, token: number, payload: ChunkPayload | null): void {\n if (this._destroyed) return;\n if (this._inFlight.get(key) !== token) return;\n this._inFlight.delete(key);\n\n if (payload === null) return;\n\n this._layer._adoptChunk(cx, cy, payload);\n this._resident.set(key, { cx, cy });\n }\n}\n"],"mappings":";;;;AA+BA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,oCAAoC;AAE1C,MAAM,YAAY,IAAY,OAAuB,GAAG,GAAG,GAAG;AAE9D,MAAM,cAAc,UAClB,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAQ,MAA6B,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/F,IAAa,gBAAb,MAA2B;CACzB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAiB,4BAAY,IAAI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AAI,GAAG,MAAM,OAAO;EACvC,KAAK,UAAU,OAAO,GAAG;EAEzB,IAAI,YAAY,MAAM;EAEtB,KAAK,OAAO,YAAY,IAAI,IAAI,OAAO;EACvC,KAAK,UAAU,IAAI,KAAK;GAAE;GAAI;EAAG,CAAC;CACpC;AACF"}
@@ -51,7 +51,7 @@ export interface ImageLayerOptions {
51
51
  */
52
52
  export declare class ImageLayer {
53
53
  /** Layer-kind discriminant. */
54
- readonly kind: "image";
54
+ readonly kind: 'image';
55
55
  /** Layer id (unique within the map). */
56
56
  readonly id: number;
57
57
  /** Layer name. */
@@ -1 +1 @@
1
- {"version":3,"file":"ImageLayer.d.ts","sourceRoot":"","sources":["../../src/ImageLayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kBAAkB;IAClB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,CAAC,SA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3C,YAAmB,OAAO,EAAE,iBAAiB,EAoB5C;CACF"}
@@ -68,7 +68,11 @@ export declare class ImageLayerNode extends Container {
68
68
  * is simply stored. Setting the current value is a no-op; an invalid value
69
69
  * throws and leaves the prior mode unchanged.
70
70
  *
71
- * @default PixelSnapMode.None
71
+ * Defaults to `Geometry`, matching the tile layers it is composed with, so a
72
+ * repeated backdrop does not sample between two device pixels and shimmer as
73
+ * the view moves. Set `None` to opt out.
74
+ *
75
+ * @default PixelSnapMode.Geometry
72
76
  * @stable
73
77
  */
74
78
  get pixelSnapMode(): PixelSnapMode;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageLayerNode.d.ts","sourceRoot":"","sources":["../../src/ImageLayerNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,aAAa,EAA0B,MAAM,4BAA4B,CAAC;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,cAAc,CAAqC;IAI3D,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,cAAc,CAAc;IACpC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,WAAW,CAAc;gBAEd,KAAK,EAAE,UAAU;IAgDpC,2CAA2C;IAC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a,EAW3C;IAiDe,OAAO,IAAI,IAAI,CAM9B;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;CA4D9B"}
@@ -49,7 +49,7 @@ var ImageLayerNode = class extends Container {
49
49
  _baseOffsetY;
50
50
  _imageWidth;
51
51
  _imageHeight;
52
- _pixelSnapMode = PixelSnapMode.None;
52
+ _pixelSnapMode = PixelSnapMode.Geometry;
53
53
  _covViewX = NaN;
54
54
  _covViewY = NaN;
55
55
  _covViewWidth = NaN;
@@ -84,6 +84,7 @@ var ImageLayerNode = class extends Container {
84
84
  const b = tintColor === null ? 255 : tintColor & 255;
85
85
  sprite.tint.set(r, g, b, layer.opacity);
86
86
  this._sprite = sprite;
87
+ sprite.pixelSnapMode = this._pixelSnapMode;
87
88
  this.addChild(sprite);
88
89
  if (layer.repeatX || layer.repeatY || layer.parallaxX !== 1 || layer.parallaxY !== 1 || layer.parallaxScale !== 1) this.cullable = false;
89
90
  }
@@ -102,7 +103,11 @@ var ImageLayerNode = class extends Container {
102
103
  * is simply stored. Setting the current value is a no-op; an invalid value
103
104
  * throws and leaves the prior mode unchanged.
104
105
  *
105
- * @default PixelSnapMode.None
106
+ * Defaults to `Geometry`, matching the tile layers it is composed with, so a
107
+ * repeated backdrop does not sample between two device pixels and shimmer as
108
+ * the view moves. Set `None` to opt out.
109
+ *
110
+ * @default PixelSnapMode.Geometry
106
111
  * @stable
107
112
  */
108
113
  get pixelSnapMode() {
@@ -1 +1 @@
1
- {"version":3,"file":"ImageLayerNode.js","names":[],"sources":["../../src/ImageLayerNode.ts"],"sourcesContent":["import { Container, RepeatingSprite } from '@codexo/exojs';\nimport { PixelSnapMode, type RenderPlanBuilder } from '@codexo/exojs/renderer-sdk';\n\nimport type { ImageLayer } from './ImageLayer';\nimport { assertPixelSnapMode } from './pixelSnap';\n\n/**\n * A scene node that renders one Tiled {@link ImageLayer} as a single\n * {@link RepeatingSprite} wrapped in a {@link Container}.\n *\n * The layer's pixel `offset` becomes this node's position; `parallax` is\n * resolved per frame in {@link _collectContent} by patching the node position\n * against the camera centre (exactly like {@link import('./TileLayerNode').TileLayerNode}),\n * then restoring it. When `repeatX`/`repeatY` is set the wrapped sprite is\n * grown each frame to cover the visible view with a period-aligned origin, so\n * the pattern tiles seamlessly and scrolls with parallax. A repeat axis or a\n * `parallax` factor other than `1` both make this node's rendered position\n * and/or size camera-dependent at collect time, so its static bounds cannot be\n * culled against - such a node opts out of view culling (`cullable = false`).\n *\n * `visible`, `opacity`, and `tintColor` are applied **once at construction**:\n * {@link ImageLayer} is immutable, so there is nothing to re-sync per frame.\n * A layer whose `texture` is `null` (image failed to load / not yet available)\n * produces an empty node with no children - it occupies its offset in the\n * scene graph but draws nothing.\n *\n * The node references - but never owns - the {@link ImageLayer} and its\n * Loader-owned texture: {@link destroy} frees the wrapped sprite but leaves the\n * layer and texture intact. Image-layer nodes are band-selectable exactly like\n * tile-layer nodes: list the image layer in a\n * {@link import('./TileMapView').TileMapViewOptions.bands} definition and the\n * band stacks it by the map's combined document order, or parent an unbanded\n * node into the scene directly wherever the image belongs in draw order.\n *\n * For a `repeatX`/`repeatY` node, bounds and hit-test queries reflect the\n * coverage geometry computed by the last {@link _collectContent} call (since\n * that geometry is recomputed per collect, not maintained incrementally),\n * which is also why such a node force-disables `cullable`. A repeating or\n * parallax node also re-sizes its wrapped sprite as the camera crosses period\n * boundaries, which content-dirties an enclosing retained group the same way\n * a streamed layer does - give it the same treatment (its own\n * `RetainedContainer`, or none).\n *\n * @advanced\n */\nexport class ImageLayerNode extends Container {\n private readonly _layer: ImageLayer;\n private readonly _sprite: RepeatingSprite | null;\n private readonly _baseOffsetX: number;\n private readonly _baseOffsetY: number;\n private readonly _imageWidth: number;\n private readonly _imageHeight: number;\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.None;\n\n // Repeat-coverage cache: the view span and patched origin that last drove a\n // resize. A static camera pays one comparison per frame and skips the rebuild.\n private _covViewX = Number.NaN;\n private _covViewY = Number.NaN;\n private _covViewWidth = Number.NaN;\n private _covViewHeight = Number.NaN;\n private _covOriginX = Number.NaN;\n private _covOriginY = Number.NaN;\n\n public constructor(layer: ImageLayer) {\n super();\n\n this._layer = layer;\n this._baseOffsetX = layer.offsetX;\n this._baseOffsetY = layer.offsetY;\n\n this.setPosition(layer.offsetX, layer.offsetY);\n this.visible = layer.visible;\n\n const texture = layer.texture;\n\n if (texture === null) {\n this._sprite = null;\n this._imageWidth = 0;\n this._imageHeight = 0;\n\n return;\n }\n\n this._imageWidth = texture.width;\n this._imageHeight = texture.height;\n\n // Non-repeating axes use `'stretch'` so the axis shows exactly one un-tiled\n // copy at its natural size; repeating axes use `'repeat'` and are grown to\n // cover the view in `_collectContent`.\n const sprite = new RepeatingSprite(texture, {\n modeX: layer.repeatX ? 'repeat' : 'stretch',\n modeY: layer.repeatY ? 'repeat' : 'stretch',\n width: texture.width,\n height: texture.height,\n });\n\n const tintColor = layer.tintColor;\n const r = tintColor === null ? 255 : (tintColor >> 16) & 0xff;\n const g = tintColor === null ? 255 : (tintColor >> 8) & 0xff;\n const b = tintColor === null ? 255 : tintColor & 0xff;\n\n sprite.tint.set(r, g, b, layer.opacity);\n\n this._sprite = sprite;\n this.addChild(sprite);\n\n if (layer.repeatX || layer.repeatY || layer.parallaxX !== 1 || layer.parallaxY !== 1 || layer.parallaxScale !== 1) {\n this.cullable = false;\n }\n }\n\n /** The runtime layer this node renders. */\n public get layer(): ImageLayer {\n return this._layer;\n }\n\n /**\n * Render-only pixel-snap mode forwarded to the wrapped {@link RepeatingSprite}\n * (which snaps its rendered origin, and - in `PixelSnapMode.Geometry` mode for\n * axis-aligned transforms - its repeat-segment boundaries, to the render\n * target's device-pixel grid). Purely visual: the layer offset, parallax, and\n * repeat coverage are never changed.\n *\n * For a `null`-texture layer there is no drawable to forward to, so the mode\n * is simply stored. Setting the current value is a no-op; an invalid value\n * throws and leaves the prior mode unchanged.\n *\n * @default PixelSnapMode.None\n * @stable\n */\n public get pixelSnapMode(): PixelSnapMode {\n return this._pixelSnapMode;\n }\n\n public set pixelSnapMode(mode: PixelSnapMode) {\n if (mode === this._pixelSnapMode) {\n return;\n }\n\n assertPixelSnapMode(mode);\n this._pixelSnapMode = mode;\n\n if (this._sprite !== null) {\n this._sprite.pixelSnapMode = mode;\n }\n }\n\n /** @internal */\n protected override _collectContent(builder: RenderPlanBuilder): void {\n if (this._sprite === null) {\n super._collectContent(builder);\n\n return;\n }\n\n const layer = this._layer;\n\n const patchesPosition = layer.parallaxX !== 1 || layer.parallaxY !== 1;\n const patchesScale = layer.parallaxScale !== 1;\n\n if (patchesPosition || patchesScale) {\n const camCenter = builder.view.center;\n const prevX = this.x;\n const prevY = this.y;\n const prevScaleX = this.scale.x;\n const prevScaleY = this.scale.y;\n\n if (patchesPosition) {\n this.x = this._baseOffsetX + camCenter.x * (1 - layer.parallaxX);\n this.y = this._baseOffsetY + camCenter.y * (1 - layer.parallaxY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX * layer.parallaxScale, prevScaleY * layer.parallaxScale);\n }\n\n try {\n this._updateRepeatCoverage(builder, layer.parallaxScale);\n super._collectContent(builder);\n } finally {\n if (patchesPosition) {\n this.setPosition(prevX, prevY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX, prevScaleY);\n }\n }\n } else {\n this._updateRepeatCoverage(builder);\n super._collectContent(builder);\n }\n }\n\n public override destroy(): void {\n const sprite = this._sprite;\n\n super.destroy();\n\n sprite?.destroy();\n }\n\n /**\n * Grow the wrapped sprite along each repeating axis so it covers the visible\n * view, with a period-aligned local origin so the pattern offset stays zero\n * (seamless tiling). Non-repeating axes keep the natural image size at local\n * `0`. Reads `this.x`/`this.y` after the parallax patch, so the pattern anchor\n * follows the parallax-shifted origin. Skips the rebuild when neither the view\n * span nor the patched origin changed since the last frame.\n */\n private _updateRepeatCoverage(builder: RenderPlanBuilder, parallaxScale = 1): void {\n const layer = this._layer;\n const sprite = this._sprite;\n\n if (sprite === null || (!layer.repeatX && !layer.repeatY)) {\n return;\n }\n\n const bounds = builder.view.getBounds();\n const originX = this.x;\n const originY = this.y;\n\n if (\n bounds.x === this._covViewX &&\n bounds.y === this._covViewY &&\n bounds.width === this._covViewWidth &&\n bounds.height === this._covViewHeight &&\n originX === this._covOriginX &&\n originY === this._covOriginY\n ) {\n return;\n }\n\n this._covViewX = bounds.x;\n this._covViewY = bounds.y;\n this._covViewWidth = bounds.width;\n this._covViewHeight = bounds.height;\n this._covOriginX = originX;\n this._covOriginY = originY;\n\n let childX = 0;\n let childY = 0;\n let childWidth = this._imageWidth;\n let childHeight = this._imageHeight;\n\n if (layer.repeatX) {\n const imgW = this._imageWidth;\n const localViewMin = (bounds.x - originX) / parallaxScale;\n const localViewWidth = bounds.width / parallaxScale;\n const startLocal = Math.floor(localViewMin / imgW) * imgW;\n const periods = Math.ceil((localViewMin + localViewWidth - startLocal) / imgW);\n\n childX = startLocal;\n childWidth = periods * imgW;\n }\n\n if (layer.repeatY) {\n const imgH = this._imageHeight;\n const localViewMin = (bounds.y - originY) / parallaxScale;\n const localViewHeight = bounds.height / parallaxScale;\n const startLocal = Math.floor(localViewMin / imgH) * imgH;\n const periods = Math.ceil((localViewMin + localViewHeight - startLocal) / imgH);\n\n childY = startLocal;\n childHeight = periods * imgH;\n }\n\n sprite.setPosition(childX, childY);\n sprite.setSize(childWidth, childHeight);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,iBAAb,cAAoC,UAAU;CAC5C,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,iBAAgC,cAAc;CAItD,AAAQ,YAAY;CACpB,AAAQ,YAAY;CACpB,AAAQ,gBAAgB;CACxB,AAAQ,iBAAiB;CACzB,AAAQ,cAAc;CACtB,AAAQ,cAAc;CAEtB,AAAO,YAAY,OAAmB;EACpC,MAAM;EAEN,KAAK,SAAS;EACd,KAAK,e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B,KAAK,iBAAiB,OAAO;EAC7B,KAAK,cAAc;EACnB,KAAK,cAAc;EAEnB,IAAI,SAAS;EACb,IAAI,SAAS;EACb,IAAI,aAAa,KAAK;EACtB,IAAI,cAAc,KAAK;EAEvB,IAAI,MAAM,SAAS;GACjB,MAAM,OAAO,KAAK;GAClB,MAAM,gBAAgB,OAAO,IAAI,WAAW;GAC5C,MAAM,iBAAiB,OAAO,QAAQ;GACtC,MAAM,aAAa,KAAK,MAAM,eAAe,IAAI,IAAI;GACrD,MAAM,UAAU,KAAK,MAAM,eAAe,iBAAiB,cAAc,IAAI;GAE7E,SAAS;GACT,aAAa,UAAU;EACzB;EAEA,IAAI,MAAM,SAAS;GACjB,MAAM,OAAO,KAAK;GAClB,MAAM,gBAAgB,OAAO,IAAI,WAAW;GAC5C,MAAM,kBAAkB,OAAO,SAAS;GACxC,MAAM,aAAa,KAAK,MAAM,eAAe,IAAI,IAAI;GACrD,MAAM,UAAU,KAAK,MAAM,eAAe,kBAAkB,cAAc,IAAI;GAE9E,SAAS;GACT,cAAc,UAAU;EAC1B;EAEA,OAAO,YAAY,QAAQ,MAAM;EACjC,OAAO,QAAQ,YAAY,WAAW;CACxC;AACF"}
1
+ {"version":3,"file":"ImageLayerNode.js","names":[],"sources":["../../src/ImageLayerNode.ts"],"sourcesContent":["import { Container, RepeatingSprite } from '@codexo/exojs';\nimport { PixelSnapMode, type RenderPlanBuilder } from '@codexo/exojs/renderer-sdk';\n\nimport type { ImageLayer } from './ImageLayer';\nimport { assertPixelSnapMode } from './pixelSnap';\n\n/**\n * A scene node that renders one Tiled {@link ImageLayer} as a single\n * {@link RepeatingSprite} wrapped in a {@link Container}.\n *\n * The layer's pixel `offset` becomes this node's position; `parallax` is\n * resolved per frame in {@link _collectContent} by patching the node position\n * against the camera centre (exactly like {@link import('./TileLayerNode').TileLayerNode}),\n * then restoring it. When `repeatX`/`repeatY` is set the wrapped sprite is\n * grown each frame to cover the visible view with a period-aligned origin, so\n * the pattern tiles seamlessly and scrolls with parallax. A repeat axis or a\n * `parallax` factor other than `1` both make this node's rendered position\n * and/or size camera-dependent at collect time, so its static bounds cannot be\n * culled against - such a node opts out of view culling (`cullable = false`).\n *\n * `visible`, `opacity`, and `tintColor` are applied **once at construction**:\n * {@link ImageLayer} is immutable, so there is nothing to re-sync per frame.\n * A layer whose `texture` is `null` (image failed to load / not yet available)\n * produces an empty node with no children - it occupies its offset in the\n * scene graph but draws nothing.\n *\n * The node references - but never owns - the {@link ImageLayer} and its\n * Loader-owned texture: {@link destroy} frees the wrapped sprite but leaves the\n * layer and texture intact. Image-layer nodes are band-selectable exactly like\n * tile-layer nodes: list the image layer in a\n * {@link import('./TileMapView').TileMapViewOptions.bands} definition and the\n * band stacks it by the map's combined document order, or parent an unbanded\n * node into the scene directly wherever the image belongs in draw order.\n *\n * For a `repeatX`/`repeatY` node, bounds and hit-test queries reflect the\n * coverage geometry computed by the last {@link _collectContent} call (since\n * that geometry is recomputed per collect, not maintained incrementally),\n * which is also why such a node force-disables `cullable`. A repeating or\n * parallax node also re-sizes its wrapped sprite as the camera crosses period\n * boundaries, which content-dirties an enclosing retained group the same way\n * a streamed layer does - give it the same treatment (its own\n * `RetainedContainer`, or none).\n *\n * @advanced\n */\nexport class ImageLayerNode extends Container {\n private readonly _layer: ImageLayer;\n private readonly _sprite: RepeatingSprite | null;\n private readonly _baseOffsetX: number;\n private readonly _baseOffsetY: number;\n private readonly _imageWidth: number;\n private readonly _imageHeight: number;\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.Geometry;\n\n // Repeat-coverage cache: the view span and patched origin that last drove a\n // resize. A static camera pays one comparison per frame and skips the rebuild.\n private _covViewX = Number.NaN;\n private _covViewY = Number.NaN;\n private _covViewWidth = Number.NaN;\n private _covViewHeight = Number.NaN;\n private _covOriginX = Number.NaN;\n private _covOriginY = Number.NaN;\n\n public constructor(layer: ImageLayer) {\n super();\n\n this._layer = layer;\n this._baseOffsetX = layer.offsetX;\n this._baseOffsetY = layer.offsetY;\n\n this.setPosition(layer.offsetX, layer.offsetY);\n this.visible = layer.visible;\n\n const texture = layer.texture;\n\n if (texture === null) {\n this._sprite = null;\n this._imageWidth = 0;\n this._imageHeight = 0;\n\n return;\n }\n\n this._imageWidth = texture.width;\n this._imageHeight = texture.height;\n\n // Non-repeating axes use `'stretch'` so the axis shows exactly one un-tiled\n // copy at its natural size; repeating axes use `'repeat'` and are grown to\n // cover the view in `_collectContent`.\n const sprite = new RepeatingSprite(texture, {\n modeX: layer.repeatX ? 'repeat' : 'stretch',\n modeY: layer.repeatY ? 'repeat' : 'stretch',\n width: texture.width,\n height: texture.height,\n });\n\n const tintColor = layer.tintColor;\n const r = tintColor === null ? 255 : (tintColor >> 16) & 0xff;\n const g = tintColor === null ? 255 : (tintColor >> 8) & 0xff;\n const b = tintColor === null ? 255 : tintColor & 0xff;\n\n sprite.tint.set(r, g, b, layer.opacity);\n\n this._sprite = sprite;\n // The sprite's own default is `None`; without this it would render\n // unsnapped while this node reports the mode it was constructed with.\n sprite.pixelSnapMode = this._pixelSnapMode;\n this.addChild(sprite);\n\n if (layer.repeatX || layer.repeatY || layer.parallaxX !== 1 || layer.parallaxY !== 1 || layer.parallaxScale !== 1) {\n this.cullable = false;\n }\n }\n\n /** The runtime layer this node renders. */\n public get layer(): ImageLayer {\n return this._layer;\n }\n\n /**\n * Render-only pixel-snap mode forwarded to the wrapped {@link RepeatingSprite}\n * (which snaps its rendered origin, and - in `PixelSnapMode.Geometry` mode for\n * axis-aligned transforms - its repeat-segment boundaries, to the render\n * target's device-pixel grid). Purely visual: the layer offset, parallax, and\n * repeat coverage are never changed.\n *\n * For a `null`-texture layer there is no drawable to forward to, so the mode\n * is simply stored. Setting the current value is a no-op; an invalid value\n * throws and leaves the prior mode unchanged.\n *\n * Defaults to `Geometry`, matching the tile layers it is composed with, so a\n * repeated backdrop does not sample between two device pixels and shimmer as\n * the view moves. Set `None` to opt out.\n *\n * @default PixelSnapMode.Geometry\n * @stable\n */\n public get pixelSnapMode(): PixelSnapMode {\n return this._pixelSnapMode;\n }\n\n public set pixelSnapMode(mode: PixelSnapMode) {\n if (mode === this._pixelSnapMode) {\n return;\n }\n\n assertPixelSnapMode(mode);\n this._pixelSnapMode = mode;\n\n if (this._sprite !== null) {\n this._sprite.pixelSnapMode = mode;\n }\n }\n\n /** @internal */\n protected override _collectContent(builder: RenderPlanBuilder): void {\n if (this._sprite === null) {\n super._collectContent(builder);\n\n return;\n }\n\n const layer = this._layer;\n\n const patchesPosition = layer.parallaxX !== 1 || layer.parallaxY !== 1;\n const patchesScale = layer.parallaxScale !== 1;\n\n if (patchesPosition || patchesScale) {\n const camCenter = builder.view.center;\n const prevX = this.x;\n const prevY = this.y;\n const prevScaleX = this.scale.x;\n const prevScaleY = this.scale.y;\n\n if (patchesPosition) {\n this.x = this._baseOffsetX + camCenter.x * (1 - layer.parallaxX);\n this.y = this._baseOffsetY + camCenter.y * (1 - layer.parallaxY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX * layer.parallaxScale, prevScaleY * layer.parallaxScale);\n }\n\n try {\n this._updateRepeatCoverage(builder, layer.parallaxScale);\n super._collectContent(builder);\n } finally {\n if (patchesPosition) {\n this.setPosition(prevX, prevY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX, prevScaleY);\n }\n }\n } else {\n this._updateRepeatCoverage(builder);\n super._collectContent(builder);\n }\n }\n\n public override destroy(): void {\n const sprite = this._sprite;\n\n super.destroy();\n\n sprite?.destroy();\n }\n\n /**\n * Grow the wrapped sprite along each repeating axis so it covers the visible\n * view, with a period-aligned local origin so the pattern offset stays zero\n * (seamless tiling). Non-repeating axes keep the natural image size at local\n * `0`. Reads `this.x`/`this.y` after the parallax patch, so the pattern anchor\n * follows the parallax-shifted origin. Skips the rebuild when neither the view\n * span nor the patched origin changed since the last frame.\n */\n private _updateRepeatCoverage(builder: RenderPlanBuilder, parallaxScale = 1): void {\n const layer = this._layer;\n const sprite = this._sprite;\n\n if (sprite === null || (!layer.repeatX && !layer.repeatY)) {\n return;\n }\n\n const bounds = builder.view.getBounds();\n const originX = this.x;\n const originY = this.y;\n\n if (\n bounds.x === this._covViewX &&\n bounds.y === this._covViewY &&\n bounds.width === this._covViewWidth &&\n bounds.height === this._covViewHeight &&\n originX === this._covOriginX &&\n originY === this._covOriginY\n ) {\n return;\n }\n\n this._covViewX = bounds.x;\n this._covViewY = bounds.y;\n this._covViewWidth = bounds.width;\n this._covViewHeight = bounds.height;\n this._covOriginX = originX;\n this._covOriginY = originY;\n\n let childX = 0;\n let childY = 0;\n let childWidth = this._imageWidth;\n let childHeight = this._imageHeight;\n\n if (layer.repeatX) {\n const imgW = this._imageWidth;\n const localViewMin = (bounds.x - originX) / parallaxScale;\n const localViewWidth = bounds.width / parallaxScale;\n const startLocal = Math.floor(localViewMin / imgW) * imgW;\n const periods = Math.ceil((localViewMin + localViewWidth - startLocal) / imgW);\n\n childX = startLocal;\n childWidth = periods * imgW;\n }\n\n if (layer.repeatY) {\n const imgH = this._imageHeight;\n const localViewMin = (bounds.y - originY) / parallaxScale;\n const localViewHeight = bounds.height / parallaxScale;\n const startLocal = Math.floor(localViewMin / imgH) * imgH;\n const periods = Math.ceil((localViewMin + localViewHeight - startLocal) / imgH);\n\n childY = startLocal;\n childHeight = periods * imgH;\n }\n\n sprite.setPosition(childX, childY);\n sprite.setSize(childWidth, childHeight);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,iBAAb,cAAoC,UAAU;CAC5C,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,iBAAgC,cAAc;CAItD,AAAQ,YAAY;CACpB,AAAQ,YAAY;CACpB,AAAQ,gBAAgB;CACxB,AAAQ,iBAAiB;CACzB,AAAQ,cAAc;CACtB,AAAQ,cAAc;CAEtB,AAAO,YAAY,OAAmB;EACpC,MAAM;EAEN,KAAK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xB,KAAK,YAAY,OAAO;EACxB,KAAK,gBAAgB,OAAO;EAC5B,KAAK,iBAAiB,OAAO;EAC7B,KAAK,cAAc;EACnB,KAAK,cAAc;EAEnB,IAAI,SAAS;EACb,IAAI,SAAS;EACb,IAAI,aAAa,KAAK;EACtB,IAAI,cAAc,KAAK;EAEvB,IAAI,MAAM,SAAS;GACjB,MAAM,OAAO,KAAK;GAClB,MAAM,gBAAgB,OAAO,IAAI,WAAW;GAC5C,MAAM,iBAAiB,OAAO,QAAQ;GACtC,MAAM,aAAa,KAAK,MAAM,eAAe,IAAI,IAAI;GACrD,MAAM,UAAU,KAAK,MAAM,eAAe,iBAAiB,cAAc,IAAI;GAE7E,SAAS;GACT,aAAa,UAAU;EACzB;EAEA,IAAI,MAAM,SAAS;GACjB,MAAM,OAAO,KAAK;GAClB,MAAM,gBAAgB,OAAO,IAAI,WAAW;GAC5C,MAAM,kBAAkB,OAAO,SAAS;GACxC,MAAM,aAAa,KAAK,MAAM,eAAe,IAAI,IAAI;GACrD,MAAM,UAAU,KAAK,MAAM,eAAe,kBAAkB,cAAc,IAAI;GAE9E,SAAS;GACT,cAAc,UAAU;EAC1B;EAEA,OAAO,YAAY,QAAQ,MAAM;EACjC,OAAO,QAAQ,YAAY,WAAW;CACxC;AACF"}
@@ -35,9 +35,9 @@ export interface MapObjectDescriptor {
35
35
  readonly kind: string | null;
36
36
  /** Object name; may be empty and is not unique. */
37
37
  readonly name: string;
38
- /** X of the object origin in object-layer pixel space. */
38
+ /** X of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */
39
39
  readonly x: number;
40
- /** Y of the object origin in object-layer pixel space. */
40
+ /** Y of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */
41
41
  readonly y: number;
42
42
  /** Bounding width in px (0 for points). */
43
43
  readonly width: number;
@@ -1 +1 @@
1
- {"version":3,"file":"MapObject.d.ts","sourceRoot":"","sources":["../../src/MapObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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K,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uGAAuG;IACvG,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,uGAAuG;IACvG,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,WAAY,aAAa,SAAS,WAAW,KAAG,mBAY9E,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAAmB,OAAO,KAAG,SAAS,CAAC,mBAAmB,CAM1F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MapObject.js","names":[],"sources":["../../src/MapObject.ts"],"sourcesContent":["import type { ObjectLayer, TileMapObject } from './ObjectLayer';\nimport type { TileMap } from './TileMap';\nimport type { TileProperties } from './types';\n\n/**\n * A format-neutral view of one map object, as handed to a\n * {@link import('./MapObjectSpawner').MapObjectFactory}.\n *\n * The descriptor is what game code writes against: it resolves the two things\n * that differ between authoring formats - stable identity and the dispatch\n * key - and pairs the object with the layer it came from. The parsed object\n * itself stays reachable through {@link object}, and the untouched source\n * record through {@link TileMapObject.source}.\n */\nexport interface MapObjectDescriptor {\n /**\n * Stable identity for this object.\n *\n * Uniqueness domain is **one {@link TileMap}**: Tiled object ids are unique\n * within a map, and LDtk entity iids are unique globally, so an LDtk-sourced\n * id keeps that stronger guarantee. Combine with the owning level's id if a\n * world-wide key is needed.\n *\n * Derived from {@link TileMapObject.sourceId} when the format supplies one,\n * otherwise from the numeric {@link TileMapObject.id}.\n */\n readonly id: string;\n /**\n * Canonical dispatch key - the object's class/type string, or `null` when the\n * source declares none.\n *\n * LDtk fills it with the entity definition identifier, Tiled with the\n * object's class. A {@link import('./MapObjectSpawner').MapObjectSpawner}\n * uses it to pick a factory unless an `identify` strategy overrides that.\n */\n readonly kind: string | null;\n /** Object name; may be empty and is not unique. */\n readonly name: string;\n /** X of the object origin in object-layer pixel space. */\n readonly x: number;\n /** Y of the object origin in object-layer pixel space. */\n readonly y: number;\n /** Bounding width in px (0 for points). */\n readonly width: number;\n /** Bounding height in px (0 for points). */\n readonly height: number;\n /** Rotation in degrees, clockwise. See {@link TileMapObject} for the pivot. */\n readonly rotation: number;\n /** The object's immutable custom properties. */\n readonly properties: TileProperties;\n /** The object layer this object was authored on, with its placement metadata. */\n readonly layer: ObjectLayer;\n /** The parsed object itself - narrow on `object.kind` to read geometry. */\n readonly object: TileMapObject;\n}\n\n/**\n * Build the {@link MapObjectDescriptor} for one object of `layer`.\n *\n * Exposed for code that spawns from a hand-picked object rather than from a\n * whole map; {@link mapObjectDescriptors} covers the common case.\n */\nexport const mapObjectDescriptor = (object: TileMapObject, layer: ObjectLayer): MapObjectDescriptor => ({\n id: object.sourceId ?? String(object.id),\n kind: object.type === '' ? null : object.type,\n name: object.name,\n x: object.x,\n y: object.y,\n width: object.width,\n height: object.height,\n rotation: object.rotation,\n properties: object.properties,\n layer,\n object,\n});\n\n/**\n * Every object of `map`, in a defined order: object-layer order first, then\n * object order within each layer.\n *\n * This is the order a {@link import('./MapObjectSpawner').MapObjectSpawner}\n * spawns in, so the same map always produces the same sequence.\n */\nexport const mapObjectDescriptors = function* (map: TileMap): Generator<MapObjectDescriptor> {\n for (const layer of map.objectLayers) {\n for (const object of layer.objects) {\n yield mapObjectDescriptor(object, layer);\n }\n }\n};\n"],"mappings":";;;;;;;AA8DA,MAAa,uBAAuB,QAAuB,WAA6C;CACtG,IAAI,OAAO,YAAY,OAAO,OAAO,EAAE;CACvC,MAAM,OAAO,SAAS,KAAK,OAAO,OAAO;CACzC,MAAM,OAAO;CACb,GAAG,OAAO;CACV,GAAG,OAAO;CACV,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,YAAY,OAAO;CACnB;CACA;AACF;;;;;;;;AASA,MAAa,uBAAuB,WAAW,KAA8C;CAC3F,KAAK,MAAM,SAAS,IAAI,cACtB,KAAK,MAAM,UAAU,MAAM,SACzB,MAAM,oBAAoB,QAAQ,KAAK;AAG7C"}
1
+ {"version":3,"file":"MapObject.js","names":[],"sources":["../../src/MapObject.ts"],"sourcesContent":["import type { ObjectLayer, TileMapObject } from './ObjectLayer';\nimport type { TileMap } from './TileMap';\nimport type { TileProperties } from './types';\n\n/**\n * A format-neutral view of one map object, as handed to a\n * {@link import('./MapObjectSpawner').MapObjectFactory}.\n *\n * The descriptor is what game code writes against: it resolves the two things\n * that differ between authoring formats - stable identity and the dispatch\n * key - and pairs the object with the layer it came from. The parsed object\n * itself stays reachable through {@link object}, and the untouched source\n * record through {@link TileMapObject.source}.\n */\nexport interface MapObjectDescriptor {\n /**\n * Stable identity for this object.\n *\n * Uniqueness domain is **one {@link TileMap}**: Tiled object ids are unique\n * within a map, and LDtk entity iids are unique globally, so an LDtk-sourced\n * id keeps that stronger guarantee. Combine with the owning level's id if a\n * world-wide key is needed.\n *\n * Derived from {@link TileMapObject.sourceId} when the format supplies one,\n * otherwise from the numeric {@link TileMapObject.id}.\n */\n readonly id: string;\n /**\n * Canonical dispatch key - the object's class/type string, or `null` when the\n * source declares none.\n *\n * LDtk fills it with the entity definition identifier, Tiled with the\n * object's class. A {@link import('./MapObjectSpawner').MapObjectSpawner}\n * uses it to pick a factory unless an `identify` strategy overrides that.\n */\n readonly kind: string | null;\n /** Object name; may be empty and is not unique. */\n readonly name: string;\n /** X of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */\n readonly x: number;\n /** Y of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */\n readonly y: number;\n /** Bounding width in px (0 for points). */\n readonly width: number;\n /** Bounding height in px (0 for points). */\n readonly height: number;\n /** Rotation in degrees, clockwise. See {@link TileMapObject} for the pivot. */\n readonly rotation: number;\n /** The object's immutable custom properties. */\n readonly properties: TileProperties;\n /** The object layer this object was authored on, with its placement metadata. */\n readonly layer: ObjectLayer;\n /** The parsed object itself - narrow on `object.kind` to read geometry. */\n readonly object: TileMapObject;\n}\n\n/**\n * Build the {@link MapObjectDescriptor} for one object of `layer`.\n *\n * Exposed for code that spawns from a hand-picked object rather than from a\n * whole map; {@link mapObjectDescriptors} covers the common case.\n */\nexport const mapObjectDescriptor = (object: TileMapObject, layer: ObjectLayer): MapObjectDescriptor => ({\n id: object.sourceId ?? String(object.id),\n kind: object.type === '' ? null : object.type,\n name: object.name,\n x: object.x,\n y: object.y,\n width: object.width,\n height: object.height,\n rotation: object.rotation,\n properties: object.properties,\n layer,\n object,\n});\n\n/**\n * Every object of `map`, in a defined order: object-layer order first, then\n * object order within each layer.\n *\n * This is the order a {@link import('./MapObjectSpawner').MapObjectSpawner}\n * spawns in, so the same map always produces the same sequence.\n */\nexport const mapObjectDescriptors = function* (map: TileMap): Generator<MapObjectDescriptor> {\n for (const layer of map.objectLayers) {\n for (const object of layer.objects) {\n yield mapObjectDescriptor(object, layer);\n }\n }\n};\n"],"mappings":";;;;;;;AA8DA,MAAa,uBAAuB,QAAuB,WAA6C;CACtG,IAAI,OAA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AO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAuE9G;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"MapSpawnSession.d.ts","sourceRoot":"","sources":["../../src/MapSpawnSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe,CAAC,MAAM,SAAS,WAAW,CAAE,YAAW,WAAW;IAC7E;;;OAGG;IACH,SAAgB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAE3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,UAAU,CAAS;IAqB3B,uCAAuC;IACvC,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;;;;;OAOG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIhD,+DAA+D;IACxD,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIrC;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI;CAqBvB"}
1
+ {"version":3,"file":"MapSpawnSession.d.ts","sourceRoot":"","sources":["../../src/MapSpawnSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe,CAAC,MAAM,SAAS,WAAW,CAAE,YAAW,WAAW;IAC7E;;;OAGG;IACH,SAAgB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAE3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,UAAU,CAAS;IAqB3B,uCAAuC;IACvC,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;;;;;OAOG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/C;IAED,+DAA+D;IACxD,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpC;IAED;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI,CAoBrB;CACF"}