@codexo/exojs-tilemap 0.16.2 → 0.18.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 +28 -75
- package/dist/esm/ImageLayerNode.d.ts +6 -4
- package/dist/esm/ImageLayerNode.d.ts.map +1 -1
- package/dist/esm/ImageLayerNode.js +7 -2
- package/dist/esm/ImageLayerNode.js.map +1 -1
- package/dist/esm/MapSpawnSession.d.ts +0 -7
- package/dist/esm/MapSpawnSession.d.ts.map +1 -1
- package/dist/esm/MapWorldRuntime.d.ts +0 -2
- package/dist/esm/MapWorldRuntime.d.ts.map +1 -1
- package/dist/esm/TileChunk.d.ts +0 -58
- package/dist/esm/TileChunk.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.d.ts +1 -73
- package/dist/esm/TileChunkNode.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.js +1 -1
- package/dist/esm/TileChunkNode.js.map +1 -1
- package/dist/esm/TileLayer.d.ts +0 -63
- package/dist/esm/TileLayer.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.d.ts +8 -8
- package/dist/esm/TileLayerNode.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.js +9 -4
- package/dist/esm/TileLayerNode.js.map +1 -1
- package/dist/esm/TileMapBand.d.ts +0 -33
- package/dist/esm/TileMapBand.d.ts.map +1 -1
- package/dist/esm/TileMapNode.d.ts +7 -2
- package/dist/esm/TileMapNode.d.ts.map +1 -1
- package/dist/esm/TileMapNode.js +9 -4
- package/dist/esm/TileMapNode.js.map +1 -1
- package/dist/esm/TileMapView.d.ts +6 -1
- package/dist/esm/TileMapView.d.ts.map +1 -1
- package/dist/esm/TileMapView.js +9 -4
- package/dist/esm/TileMapView.js.map +1 -1
- package/dist/esm/TileSet.d.ts +3 -9
- package/dist/esm/TileSet.d.ts.map +1 -1
- package/dist/esm/TileSet.js +3 -3
- package/dist/esm/TileSet.js.map +1 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts +4 -7
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +1 -1
- package/dist/esm/WorkerSampledChunkSource.js +12 -18
- package/dist/esm/WorkerSampledChunkSource.js.map +1 -1
- package/dist/esm/chunkGeometry.d.ts +1 -71
- package/dist/esm/chunkGeometry.d.ts.map +1 -1
- package/dist/esm/nodeBounds.d.ts +1 -19
- package/dist/esm/nodeBounds.d.ts.map +1 -1
- package/dist/esm/pixelSnap.d.ts +1 -12
- package/dist/esm/pixelSnap.d.ts.map +1 -1
- package/dist/esm/tileWord.d.ts +1 -11
- package/dist/esm/tileWord.d.ts.map +1 -1
- package/dist/esm/tilemapExtension.d.ts.map +1 -1
- package/dist/esm/tilemapExtension.js +5 -8
- package/dist/esm/tilemapExtension.js.map +1 -1
- package/dist/esm/tilemapSerializers.d.ts +1 -19
- package/dist/esm/tilemapSerializers.d.ts.map +1 -1
- package/dist/esm/types.d.ts +0 -6
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +1 -92
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +13 -13
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +1 -107
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +13 -13
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +1 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +1 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +1 -1
- package/package.json +3 -3
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,46 +8,34 @@ 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
|
-
|
|
34
|
-
- `
|
|
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
|
-
|
|
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
|
|
|
@@ -99,11 +84,7 @@ app.scenes.root.addChild(new TileMapNode(map));
|
|
|
99
84
|
|
|
100
85
|
### Interleaving actors between layers — `TileMapView`
|
|
101
86
|
|
|
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:
|
|
87
|
+
`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
88
|
|
|
108
89
|
```ts
|
|
109
90
|
const view = map.createView({
|
|
@@ -130,63 +111,35 @@ worldRoot.addChild(view.getLayerNodeById(groundId)!, actors, view.getLayerNodeBy
|
|
|
130
111
|
|
|
131
112
|
Actors are application-owned siblings. `TileMapView` never adopts or destroys actors.
|
|
132
113
|
|
|
133
|
-
- A band definition **selects** layers (by id, or by unique layer name); rendering order within
|
|
134
|
-
|
|
135
|
-
-
|
|
136
|
-
|
|
137
|
-
-
|
|
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.
|
|
114
|
+
- 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.
|
|
115
|
+
- Layers not listed in any band stay reachable via `view.getLayerNodeById(id)` / `view.getLayerNodesByName(name)`; they are not auto-added to any band.
|
|
116
|
+
- Destroying a view or a band destroys only the tile nodes it generated — never actors, the `TileMap`, its `TileLayer`s, or tileset textures.
|
|
117
|
+
- 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.
|
|
118
|
+
- 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.
|
|
143
119
|
|
|
144
120
|
## Renderer model
|
|
145
121
|
|
|
146
|
-
- **Chunk-first.** A `TileLayerNode` is a container of per-chunk `TileChunkNode` drawables (one
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
- **
|
|
151
|
-
|
|
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).
|
|
122
|
+
- **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.
|
|
123
|
+
- **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.
|
|
124
|
+
- **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.
|
|
125
|
+
- **Multiple tilesets** with differing tile sizes are first-class; tiles taller than the map grid are bottom-left aligned (Tiled orthogonal convention).
|
|
126
|
+
- **WebGL2 and WebGPU** share one CPU geometry builder and produce identical output (golden parity tested on both backends).
|
|
127
|
+
- **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
128
|
|
|
165
129
|
## Ownership & lifecycle
|
|
166
130
|
|
|
167
131
|
- 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
|
-
|
|
170
|
-
|
|
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.
|
|
132
|
+
- 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.
|
|
133
|
+
- `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.
|
|
134
|
+
- 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
135
|
|
|
181
136
|
## Core compatibility
|
|
182
137
|
|
|
183
|
-
|
|
184
|
-
| ----------------------- | --------------- |
|
|
185
|
-
| 0.x | matching `0.x` |
|
|
138
|
+
This package follows the Core lockstep release line and declares the compatible `@codexo/exojs` minor as a peer dependency. Install matching package versions.
|
|
186
139
|
|
|
187
140
|
## Links
|
|
188
141
|
|
|
189
|
-
- [API reference](https://
|
|
142
|
+
- [API reference](https://exoridus.github.io/ExoJS/en/api/)
|
|
190
143
|
- [`@codexo/exojs-tiled`](https://www.npmjs.com/package/@codexo/exojs-tiled) — load Tiled `.tmj` maps into this runtime
|
|
191
144
|
|
|
192
145
|
## License
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Container } from '@codexo/exojs';
|
|
2
|
-
import { PixelSnapMode
|
|
2
|
+
import { PixelSnapMode } from '@codexo/exojs/renderer-sdk';
|
|
3
3
|
import type { ImageLayer } from './ImageLayer';
|
|
4
4
|
/**
|
|
5
5
|
* A scene node that renders one Tiled {@link ImageLayer} as a single
|
|
@@ -68,13 +68,15 @@ 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
|
-
*
|
|
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;
|
|
75
79
|
set pixelSnapMode(mode: PixelSnapMode);
|
|
76
|
-
/** @internal */
|
|
77
|
-
protected _collectContent(builder: RenderPlanBuilder): void;
|
|
78
80
|
destroy(): void;
|
|
79
81
|
/**
|
|
80
82
|
* Grow the wrapped sprite along each repeating axis so it covers the visible
|
|
@@ -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,
|
|
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,CAAyC;IAI/D,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;IAmDpC,2CAA2C;IAC3C,IAAW,KAAK,IAAI,UAAU,CAE7B;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAW,aAAa,IAAI,aAAa,CAExC;IAED,IAAW,aAAa,CAAC,IAAI,EAAE,aAAa,EAW3C;IAiDe,OAAO,IAAI,IAAI;IAQ/B;;;;;;;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.
|
|
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
|
-
*
|
|
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,eAAe,MAAM;EAC1B,KAAK,eAAe,MAAM;EAE1B,KAAK,YAAY,MAAM,SAAS,MAAM,OAAO;EAC7C,KAAK,UAAU,MAAM;EAErB,MAAM,UAAU,MAAM;EAEtB,IAAI,YAAY,MAAM;GACpB,KAAK,UAAU;GACf,KAAK,cAAc;GACnB,KAAK,eAAe;GAEpB;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AAO,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,SAAS;EACd,KAAK,eAAe,MAAM;EAC1B,KAAK,eAAe,MAAM;EAE1B,KAAK,YAAY,MAAM,SAAS,MAAM,OAAO;EAC7C,KAAK,UAAU,MAAM;EAErB,MAAM,UAAU,MAAM;EAEtB,IAAI,YAAY,MAAM;GACpB,KAAK,UAAU;GACf,KAAK,cAAc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I,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"}
|
|
@@ -19,13 +19,6 @@ export declare class MapSpawnSession<Result extends Destroyable> implements Dest
|
|
|
19
19
|
readonly objects: readonly Result[];
|
|
20
20
|
private readonly _byId;
|
|
21
21
|
private _destroyed;
|
|
22
|
-
/**
|
|
23
|
-
* Sessions are produced by
|
|
24
|
-
* {@link import('./MapObjectSpawner').MapObjectSpawner.spawn}, not
|
|
25
|
-
* constructed directly.
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
constructor(entries: ReadonlyArray<readonly [id: string, result: Result]>);
|
|
29
22
|
/** Whether {@link destroy} has run. */
|
|
30
23
|
get destroyed(): boolean;
|
|
31
24
|
/**
|
|
@@ -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;
|
|
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"}
|
|
@@ -88,8 +88,6 @@ export declare class MapLevelRuntime<Result extends Destroyable = Destroyable> i
|
|
|
88
88
|
readonly spawns: MapSpawnSession<Result> | null;
|
|
89
89
|
private readonly _onDestroy;
|
|
90
90
|
private _destroyed;
|
|
91
|
-
/** Level runtimes are produced by {@link MapWorldRuntime.loadLevel}. @internal */
|
|
92
|
-
constructor(level: MapLevel, scope: LoaderScope, map: TileMap, spawns: MapSpawnSession<Result> | null, onDestroy: (runtime: MapLevelRuntime) => void);
|
|
93
91
|
/** Whether this level has been unloaded. */
|
|
94
92
|
get destroyed(): boolean;
|
|
95
93
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapWorldRuntime.d.ts","sourceR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}
|
package/dist/esm/TileChunk.d.ts
CHANGED
|
@@ -98,64 +98,6 @@ export declare class TileChunk implements ReadonlyTileChunk {
|
|
|
98
98
|
get revision(): number;
|
|
99
99
|
/** @inheritdoc */
|
|
100
100
|
cloneTiles(): Uint32Array;
|
|
101
|
-
/**
|
|
102
|
-
* Package-internal access to the underlying tile storage.
|
|
103
|
-
* Returns the actual mutable `Uint32Array` - DO NOT USE publicly.
|
|
104
|
-
*
|
|
105
|
-
* Provided for the future tilemap renderer (same package) so it can
|
|
106
|
-
* read chunk data efficiently without a full `cloneTiles()` copy per frame.
|
|
107
|
-
*
|
|
108
|
-
* External consumers and other packages MUST NOT call this.
|
|
109
|
-
* @internal
|
|
110
|
-
*/
|
|
111
|
-
_getRawStorage(): Uint32Array;
|
|
112
|
-
/**
|
|
113
|
-
* Validate a packed tile value before storing.
|
|
114
|
-
* Accepts any finite integer - `Uint32Array` stores via unsigned 32-bit
|
|
115
|
-
* truncation (`ToUint32`). Negative values produced by JavaScript's
|
|
116
|
-
* signed bitwise ops (e.g. when the transform bits set bit 31) are valid.
|
|
117
|
-
* @throws If the value is NaN, Infinity, or non-integer.
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
private _validatePacked;
|
|
121
|
-
/**
|
|
122
|
-
* Write a packed tile word at local-in-chunk coordinates.
|
|
123
|
-
* Returns true if the stored value actually changed.
|
|
124
|
-
*
|
|
125
|
-
* Package-internal: only {@link TileLayer} may call this.
|
|
126
|
-
* @internal
|
|
127
|
-
*/
|
|
128
|
-
_setRawAt(lx: number, ly: number, packed: PackedTile): boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Mark the chunk as needing a GPU rebuild.
|
|
131
|
-
* Invalidates the empty cache and increments revision.
|
|
132
|
-
*
|
|
133
|
-
* Package-internal: for future renderer use only.
|
|
134
|
-
* @internal
|
|
135
|
-
*/
|
|
136
|
-
_markDirty(): void;
|
|
137
|
-
/**
|
|
138
|
-
* Clear every cell in this chunk. Does not re-allocate storage.
|
|
139
|
-
* Increments revision if any cell was non-zero.
|
|
140
|
-
*
|
|
141
|
-
* Package-internal: only {@link TileLayer} may call this.
|
|
142
|
-
* @internal
|
|
143
|
-
*/
|
|
144
|
-
_clear(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Register a callback invoked synchronously whenever this chunk's revision
|
|
147
|
-
* advances. Multiple listeners are supported (a chunk may back more than one
|
|
148
|
-
* `TileChunkNode` - e.g. two `TileLayerNode`s over the same `TileLayer`).
|
|
149
|
-
* Package-internal: called by `TileChunkNode` to push mutations onto the
|
|
150
|
-
* scene-node content-revision chain (see the `_dirtyListeners` field).
|
|
151
|
-
* @internal
|
|
152
|
-
*/
|
|
153
|
-
_addDirtyListener(listener: () => void): void;
|
|
154
|
-
/**
|
|
155
|
-
* Unregister a listener added via {@link _addDirtyListener} (node destroy).
|
|
156
|
-
* @internal
|
|
157
|
-
*/
|
|
158
|
-
_removeDirtyListener(listener: () => void): void;
|
|
159
101
|
private _notifyDirty;
|
|
160
102
|
}
|
|
161
103
|
//# sourceMappingURL=TileChunk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileChunk.d.ts","sourceRoot":"","sources":["../../src/TileChunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;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,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU;IAKnD,kBAAkB;IAClB,IAAW,KAAK,IAAI,OAAO,CAK1B;IAED,kBAAkB;IAClB,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,kBAAkB;IACX,UAAU,IAAI,WAAW;IAuGhC,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -1,74 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Drawable } from '@codexo/exojs/renderer-sdk';
|
|
3
|
-
import type { ChunkPage } from './chunkGeometry';
|
|
4
|
-
import type { ReadonlyTileChunk } from './TileChunk';
|
|
5
|
-
import type { TileSet } from './TileSet';
|
|
6
|
-
/**
|
|
7
|
-
* A single renderable tile chunk. One `TileChunkNode` is a {@link Drawable}
|
|
8
|
-
* that owns the batched quad geometry for exactly one {@link ReadonlyTileChunk}
|
|
9
|
-
* of one {@link import('./TileLayer').TileLayer}, positioned at the chunk's
|
|
10
|
-
* pixel origin within the owning {@link TileLayerNode}.
|
|
11
|
-
*
|
|
12
|
-
* Geometry is built lazily and cached against the source chunk's `revision`:
|
|
13
|
-
* the renderer reads {@link TileChunkNode.pages} on each visible frame, but a
|
|
14
|
-
* rebuild only happens when the underlying chunk actually changed. Off-screen
|
|
15
|
-
* chunks are culled by their accurate {@link getLocalBounds} before `render`
|
|
16
|
-
* is ever called, so a camera pan rebuilds nothing.
|
|
17
|
-
*
|
|
18
|
-
* The node references - but never owns - the runtime chunk, tilesets, and
|
|
19
|
-
* tileset textures. Destroying it releases only its cached CPU geometry; the
|
|
20
|
-
* `TileMap`/`TileLayer` data and Loader-owned textures are untouched.
|
|
21
|
-
*
|
|
22
|
-
* @internal Package-internal render node; the renderer is registered for this
|
|
23
|
-
* class. Applications use {@link TileMapNode} / {@link TileLayerNode}.
|
|
24
|
-
*/
|
|
25
|
-
export declare class TileChunkNode extends Drawable {
|
|
26
|
-
private readonly _chunk;
|
|
27
|
-
private readonly _tilesets;
|
|
28
|
-
private readonly _tileWidth;
|
|
29
|
-
private readonly _tileHeight;
|
|
30
|
-
private readonly _pixelWidth;
|
|
31
|
-
private readonly _pixelHeight;
|
|
32
|
-
private _pages;
|
|
33
|
-
private _builtRevision;
|
|
34
|
-
/**
|
|
35
|
-
* Bound once so `TileChunk._addDirtyListener`/`_removeDirtyListener` add and
|
|
36
|
-
* remove the SAME function reference. Pushes the chunk's revision bump onto
|
|
37
|
-
* this node's own content revision (see `TileChunk._dirtyListeners`) so a
|
|
38
|
-
* `RetainedContainer` ancestor - which skips walking a content-clean
|
|
39
|
-
* subtree entirely - observes the mutation and re-collects instead of
|
|
40
|
-
* replaying stale cached geometry.
|
|
41
|
-
*/
|
|
42
|
-
private readonly _onChunkDirty;
|
|
43
|
-
/**
|
|
44
|
-
* @param chunk The readonly chunk this node renders.
|
|
45
|
-
* @param tilesets The owning layer's tileset array.
|
|
46
|
-
* @param tileWidth Map/layer tile cell width in pixels.
|
|
47
|
-
* @param tileHeight Map/layer tile cell height in pixels.
|
|
48
|
-
* @param chunkWidthTiles The layer's (unclamped) chunk width in tiles, used
|
|
49
|
-
* to compute the chunk's pixel origin. Edge chunks
|
|
50
|
-
* report a smaller `chunk.width`, but always start at
|
|
51
|
-
* `cx * chunkWidthTiles`.
|
|
52
|
-
* @param chunkHeightTiles The layer's (unclamped) chunk height in tiles.
|
|
53
|
-
*/
|
|
54
|
-
constructor(chunk: ReadonlyTileChunk, tilesets: readonly TileSet[], tileWidth: number, tileHeight: number, chunkWidthTiles: number, chunkHeightTiles: number);
|
|
55
|
-
/** The signed chunk coordinates this node renders. */
|
|
56
|
-
get chunkX(): number;
|
|
57
|
-
get chunkY(): number;
|
|
58
|
-
/**
|
|
59
|
-
* The revision-cached per-tileset page geometry. Rebuilt only when the source
|
|
60
|
-
* chunk's `revision` advances; otherwise the same arrays are returned.
|
|
61
|
-
* @internal Read by the per-backend tile chunk renderer.
|
|
62
|
-
*/
|
|
63
|
-
get pages(): readonly ChunkPage[];
|
|
64
|
-
/** `true` when the chunk has no drawable tiles (no geometry, no draw calls). */
|
|
65
|
-
get isEmpty(): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Recomputed lazily on read, so it writes `_localBounds` directly rather than
|
|
68
|
-
* going through `_setLocalBounds`: an invalidating write inside a getter
|
|
69
|
-
* would re-dirty the node on every read.
|
|
70
|
-
*/
|
|
71
|
-
getLocalBounds(): ReadonlyRectangle;
|
|
72
|
-
destroy(): void;
|
|
73
|
-
}
|
|
1
|
+
export {};
|
|
74
2
|
//# sourceMappingURL=TileChunkNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileChunkNode.d.ts","sourceRoot":"","sources":["../../src/TileChunkNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TileChunkNode.d.ts","sourceRoot":"","sources":["../../src/TileChunkNode.ts"],"names":[],"mappings":""}
|
|
@@ -89,7 +89,7 @@ var TileChunkNode = class extends Drawable {
|
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* Recomputed lazily on read, so it writes `_localBounds` directly rather than
|
|
92
|
-
* going through `
|
|
92
|
+
* going through `setLocalBounds`: an invalidating write inside a getter
|
|
93
93
|
* would re-dirty the node on every read.
|
|
94
94
|
*/
|
|
95
95
|
getLocalBounds() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileChunkNode.js","names":[],"sources":["../../src/TileChunkNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Drawable } from '@codexo/exojs/renderer-sdk';\n\nimport type { ChunkPage } from './chunkGeometry';\nimport { buildChunkPages } from './chunkGeometry';\nimport type { ReadonlyTileChunk } from './TileChunk';\nimport { TileChunk } from './TileChunk';\nimport type { TileSet } from './TileSet';\n\n/**\n * A single renderable tile chunk. One `TileChunkNode` is a {@link Drawable}\n * that owns the batched quad geometry for exactly one {@link ReadonlyTileChunk}\n * of one {@link import('./TileLayer').TileLayer}, positioned at the chunk's\n * pixel origin within the owning {@link TileLayerNode}.\n *\n * Geometry is built lazily and cached against the source chunk's `revision`:\n * the renderer reads {@link TileChunkNode.pages} on each visible frame, but a\n * rebuild only happens when the underlying chunk actually changed. Off-screen\n * chunks are culled by their accurate {@link getLocalBounds} before `render`\n * is ever called, so a camera pan rebuilds nothing.\n *\n * The node references - but never owns - the runtime chunk, tilesets, and\n * tileset textures. Destroying it releases only its cached CPU geometry; the\n * `TileMap`/`TileLayer` data and Loader-owned textures are untouched.\n *\n * @internal Package-internal render node; the renderer is registered for this\n * class. Applications use {@link TileMapNode} / {@link TileLayerNode}.\n */\nexport class TileChunkNode extends Drawable {\n private readonly _chunk: ReadonlyTileChunk;\n private readonly _tilesets: readonly TileSet[];\n private readonly _tileWidth: number;\n private readonly _tileHeight: number;\n private readonly _pixelWidth: number;\n private readonly _pixelHeight: number;\n\n private _pages: ChunkPage[] = [];\n private _builtRevision = -1;\n\n /**\n * Bound once so `TileChunk._addDirtyListener`/`_removeDirtyListener` add and\n * remove the SAME function reference. Pushes the chunk's revision bump onto\n * this node's own content revision (see `TileChunk._dirtyListeners`) so a\n * `RetainedContainer` ancestor - which skips walking a content-clean\n * subtree entirely - observes the mutation and re-collects instead of\n * replaying stale cached geometry.\n */\n private readonly _onChunkDirty = (): void => {\n this.invalidateContent();\n };\n\n /**\n * @param chunk The readonly chunk this node renders.\n * @param tilesets The owning layer's tileset array.\n * @param tileWidth Map/layer tile cell width in pixels.\n * @param tileHeight Map/layer tile cell height in pixels.\n * @param chunkWidthTiles The layer's (unclamped) chunk width in tiles, used\n * to compute the chunk's pixel origin. Edge chunks\n * report a smaller `chunk.width`, but always start at\n * `cx * chunkWidthTiles`.\n * @param chunkHeightTiles The layer's (unclamped) chunk height in tiles.\n */\n public constructor(\n chunk: ReadonlyTileChunk,\n tilesets: readonly TileSet[],\n tileWidth: number,\n tileHeight: number,\n chunkWidthTiles: number,\n chunkHeightTiles: number,\n ) {\n super();\n\n this._chunk = chunk;\n this._tilesets = tilesets;\n this._tileWidth = tileWidth;\n this._tileHeight = tileHeight;\n this._pixelWidth = chunk.width * tileWidth;\n this._pixelHeight = chunk.height * tileHeight;\n\n this.setPosition(chunk.cx * chunkWidthTiles * tileWidth, chunk.cy * chunkHeightTiles * tileHeight);\n\n // `loadedChunks()` always yields the concrete `TileChunk` behind the\n // readonly view (see TileLayer); the guard is defensive only.\n if (chunk instanceof TileChunk) {\n chunk._addDirtyListener(this._onChunkDirty);\n }\n }\n\n /** The signed chunk coordinates this node renders. */\n public get chunkX(): number {\n return this._chunk.cx;\n }\n\n public get chunkY(): number {\n return this._chunk.cy;\n }\n\n /**\n * The revision-cached per-tileset page geometry. Rebuilt only when the source\n * chunk's `revision` advances; otherwise the same arrays are returned.\n * @internal Read by the per-backend tile chunk renderer.\n */\n public get pages(): readonly ChunkPage[] {\n if (this._builtRevision !== this._chunk.revision) {\n this._pages = buildChunkPages(this._chunk, this._tilesets, this._tileWidth, this._tileHeight);\n this._builtRevision = this._chunk.revision;\n }\n\n return this._pages;\n }\n\n /** `true` when the chunk has no drawable tiles (no geometry, no draw calls). */\n public get isEmpty(): boolean {\n return this.pages.length === 0;\n }\n\n /**\n * Recomputed lazily on read, so it writes `_localBounds` directly rather than\n * going through `
|
|
1
|
+
{"version":3,"file":"TileChunkNode.js","names":[],"sources":["../../src/TileChunkNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Drawable } from '@codexo/exojs/renderer-sdk';\n\nimport type { ChunkPage } from './chunkGeometry';\nimport { buildChunkPages } from './chunkGeometry';\nimport type { ReadonlyTileChunk } from './TileChunk';\nimport { TileChunk } from './TileChunk';\nimport type { TileSet } from './TileSet';\n\n/**\n * A single renderable tile chunk. One `TileChunkNode` is a {@link Drawable}\n * that owns the batched quad geometry for exactly one {@link ReadonlyTileChunk}\n * of one {@link import('./TileLayer').TileLayer}, positioned at the chunk's\n * pixel origin within the owning {@link TileLayerNode}.\n *\n * Geometry is built lazily and cached against the source chunk's `revision`:\n * the renderer reads {@link TileChunkNode.pages} on each visible frame, but a\n * rebuild only happens when the underlying chunk actually changed. Off-screen\n * chunks are culled by their accurate {@link getLocalBounds} before `render`\n * is ever called, so a camera pan rebuilds nothing.\n *\n * The node references - but never owns - the runtime chunk, tilesets, and\n * tileset textures. Destroying it releases only its cached CPU geometry; the\n * `TileMap`/`TileLayer` data and Loader-owned textures are untouched.\n *\n * @internal Package-internal render node; the renderer is registered for this\n * class. Applications use {@link TileMapNode} / {@link TileLayerNode}.\n */\nexport class TileChunkNode extends Drawable {\n private readonly _chunk: ReadonlyTileChunk;\n private readonly _tilesets: readonly TileSet[];\n private readonly _tileWidth: number;\n private readonly _tileHeight: number;\n private readonly _pixelWidth: number;\n private readonly _pixelHeight: number;\n\n private _pages: ChunkPage[] = [];\n private _builtRevision = -1;\n\n /**\n * Bound once so `TileChunk._addDirtyListener`/`_removeDirtyListener` add and\n * remove the SAME function reference. Pushes the chunk's revision bump onto\n * this node's own content revision (see `TileChunk._dirtyListeners`) so a\n * `RetainedContainer` ancestor - which skips walking a content-clean\n * subtree entirely - observes the mutation and re-collects instead of\n * replaying stale cached geometry.\n */\n private readonly _onChunkDirty = (): void => {\n this.invalidateContent();\n };\n\n /**\n * @param chunk The readonly chunk this node renders.\n * @param tilesets The owning layer's tileset array.\n * @param tileWidth Map/layer tile cell width in pixels.\n * @param tileHeight Map/layer tile cell height in pixels.\n * @param chunkWidthTiles The layer's (unclamped) chunk width in tiles, used\n * to compute the chunk's pixel origin. Edge chunks\n * report a smaller `chunk.width`, but always start at\n * `cx * chunkWidthTiles`.\n * @param chunkHeightTiles The layer's (unclamped) chunk height in tiles.\n */\n public constructor(\n chunk: ReadonlyTileChunk,\n tilesets: readonly TileSet[],\n tileWidth: number,\n tileHeight: number,\n chunkWidthTiles: number,\n chunkHeightTiles: number,\n ) {\n super();\n\n this._chunk = chunk;\n this._tilesets = tilesets;\n this._tileWidth = tileWidth;\n this._tileHeight = tileHeight;\n this._pixelWidth = chunk.width * tileWidth;\n this._pixelHeight = chunk.height * tileHeight;\n\n this.setPosition(chunk.cx * chunkWidthTiles * tileWidth, chunk.cy * chunkHeightTiles * tileHeight);\n\n // `loadedChunks()` always yields the concrete `TileChunk` behind the\n // readonly view (see TileLayer); the guard is defensive only.\n if (chunk instanceof TileChunk) {\n chunk._addDirtyListener(this._onChunkDirty);\n }\n }\n\n /** The signed chunk coordinates this node renders. */\n public get chunkX(): number {\n return this._chunk.cx;\n }\n\n public get chunkY(): number {\n return this._chunk.cy;\n }\n\n /**\n * The revision-cached per-tileset page geometry. Rebuilt only when the source\n * chunk's `revision` advances; otherwise the same arrays are returned.\n * @internal Read by the per-backend tile chunk renderer.\n */\n public get pages(): readonly ChunkPage[] {\n if (this._builtRevision !== this._chunk.revision) {\n this._pages = buildChunkPages(this._chunk, this._tilesets, this._tileWidth, this._tileHeight);\n this._builtRevision = this._chunk.revision;\n }\n\n return this._pages;\n }\n\n /** `true` when the chunk has no drawable tiles (no geometry, no draw calls). */\n public get isEmpty(): boolean {\n return this.pages.length === 0;\n }\n\n /**\n * Recomputed lazily on read, so it writes `_localBounds` directly rather than\n * going through `setLocalBounds`: an invalidating write inside a getter\n * would re-dirty the node on every read.\n */\n public override getLocalBounds(): ReadonlyRectangle {\n return this._localBounds.set(0, 0, this._pixelWidth, this._pixelHeight);\n }\n\n public override destroy(): void {\n if (this._chunk instanceof TileChunk) {\n this._chunk._removeDirtyListener(this._onChunkDirty);\n }\n\n this._pages = [];\n this._builtRevision = -1;\n\n super.destroy();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,gBAAb,cAAmC,SAAS;CAC1C,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAQ,SAAsB,CAAC;CAC/B,AAAQ,iBAAiB;;;;;;;;;CAUzB,AAAiB,sBAA4B;EAC3C,KAAK,kBAAk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