@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
@@ -1,4 +1,5 @@
1
1
  import { validatePairedDimensions, validatePositiveInteger } from "./types.js";
2
+ import { TileProjection } from "./TileProjection.js";
2
3
  import { TileMapView } from "./TileMapView.js";
3
4
 
4
5
  //#region src/TileMap.ts
@@ -18,6 +19,7 @@ import { TileMapView } from "./TileMapView.js";
18
19
  * @advanced
19
20
  */
20
21
  var TileMap = class {
22
+ projection;
21
23
  /** Map name (debug). */
22
24
  name;
23
25
  /** Map width in tiles, or `undefined` if unbounded. */
@@ -30,11 +32,11 @@ var TileMap = class {
30
32
  tileHeight;
31
33
  /** Pixel width, or `undefined` if unbounded. */
32
34
  get pixelWidth() {
33
- return this.width === void 0 ? void 0 : this.width * this.tileWidth;
35
+ return this.width === void 0 || this.height === void 0 ? void 0 : this.projection.getBounds(0, 0, this.width, this.height).width;
34
36
  }
35
37
  /** Pixel height, or `undefined` if unbounded. */
36
38
  get pixelHeight() {
37
- return this.height === void 0 ? void 0 : this.height * this.tileHeight;
39
+ return this.width === void 0 || this.height === void 0 ? void 0 : this.projection.getBounds(0, 0, this.width, this.height).height;
38
40
  }
39
41
  /** `true` if this map has a fixed width/height; `false` if unbounded. */
40
42
  get bounded() {
@@ -76,6 +78,11 @@ var TileMap = class {
76
78
  this.height = options.height;
77
79
  this.tileWidth = options.tileWidth;
78
80
  this.tileHeight = options.tileHeight;
81
+ this.projection = options.projection ?? new TileProjection({
82
+ tileWidth: options.tileWidth,
83
+ tileHeight: options.tileHeight
84
+ });
85
+ if (this.projection.tileWidth !== this.tileWidth || this.projection.tileHeight !== this.tileHeight) throw new Error("Projection tile dimensions must match the layer or map.");
79
86
  this.chunkWidth = chunkWidth;
80
87
  this.chunkHeight = chunkHeight;
81
88
  this.class = options.class ?? "";
@@ -346,24 +353,18 @@ var TileMap = class {
346
353
  layer.clearTileAt(tx, ty);
347
354
  }
348
355
  /**
349
- * Convert a tile coordinate to the pixel position of its top-left corner
356
+ * Convert a grid vertex to display pixels (the top diamond vertex for isometric cells)
350
357
  * in map-local space (ignoring layer offsets).
351
358
  */
352
359
  tileToPixel(tx, ty) {
353
- return {
354
- x: tx * this.tileWidth,
355
- y: ty * this.tileHeight
356
- };
360
+ return this.projection.tileToPixel(tx, ty);
357
361
  }
358
362
  /**
359
- * Convert a pixel position in map-local space to the tile coordinate
363
+ * Convert a display position in map-local space to the tile coordinate
360
364
  * that contains it. Uses `floor`. May return coordinates outside map bounds.
361
365
  */
362
366
  pixelToTile(px, py) {
363
- return {
364
- tx: Math.floor(px / this.tileWidth),
365
- ty: Math.floor(py / this.tileHeight)
366
- };
367
+ return this.projection.pixelToTile(px, py);
367
368
  }
368
369
  /**
369
370
  * Monotonic map revision counter. Increments on structural changes only
@@ -1 +1 @@
1
- {"version":3,"file":"TileMap.js","names":[],"sources":["../../src/TileMap.ts"],"sourcesContent":["import { type ImageLayer } from './ImageLayer';\nimport type { ObjectLayer, ObjectSchema } from './ObjectLayer';\nimport { type TileLayer } from './TileLayer';\nimport type { TileMapViewOptions } from './TileMapView';\nimport { TileMapView } from './TileMapView';\nimport { type TileSet } from './TileSet';\nimport type { ResolvedTile, TileProperties } from './types';\nimport { validatePairedDimensions, validatePositiveInteger } from './types';\n\n/**\n * Options for constructing a {@link TileMap}.\n * @advanced\n */\nexport interface TileMapOptions {\n /** Map name (for debugging). */\n readonly name?: string;\n /**\n * Map width in tiles. Omit together with {@link height} for an unbounded\n * map - layers you add are then free to be unbounded too (this option\n * does not constrain per-layer dimensions either way).\n */\n readonly width?: number;\n /** Map height in tiles. Must be provided iff {@link width} is. */\n readonly height?: number;\n /** Width of each tile in pixels. */\n readonly tileWidth: number;\n /** Height of each tile in pixels. */\n readonly tileHeight: number;\n /** Tilesets available to this map. */\n readonly tilesets?: readonly TileSet[];\n /** Layers (constructed externally and owned by the map after construction). */\n readonly layers?: readonly TileLayer[];\n /** Object layers (data-only; spawn points, triggers, collision regions). */\n readonly objectLayers?: readonly ObjectLayer[];\n /** Image layers (data-only; background/foreground images from Tiled image layers). */\n readonly imageLayers?: readonly ImageLayer[];\n /** Chunk width for layers (default 32). */\n readonly chunkWidth?: number;\n /** Chunk height for layers (default 32). */\n readonly chunkHeight?: number;\n /** Map class/type string (Tiled `class`). Defaults to `''`. */\n readonly class?: string;\n /**\n * Map background colour as a `0xRRGGBB` integer, or `null` (Tiled\n * `backgroundcolor`). Informational - the renderer does not auto-clear to it.\n * Default `null`.\n */\n readonly backgroundColor?: number | null;\n /** Tile draw order (Tiled `renderorder`), informational. Default `'right-down'`. */\n readonly renderOrder?: string;\n /** Map-level properties (copied and frozen). */\n readonly properties?: TileProperties;\n /**\n * Combined document order across tile and image layers, as an ordered list\n * of layer ids - exposed via {@link TileMap.renderableLayers}. Every tile\n * and image layer passed to this map (via {@link layers} / {@link\n * imageLayers}) must appear exactly once; an id that belongs to neither\n * kind, or is listed more than once, throws. The list's length must also\n * equal the total number of tile/image layer instances - nothing enforces\n * unique ids across image layers, so two image layers sharing an id would\n * otherwise both satisfy the id-based checks while one silently drops out\n * of {@link TileMap.renderableLayers}; that mismatch throws too.\n *\n * A tile layer and an image layer sharing the same id makes the order\n * ambiguous - that combination throws when `documentOrder` is provided.\n * It is NOT rejected when this option is omitted: the fallback order below\n * is unambiguous by construction (tile layers are always listed before\n * image layers), so hand-built maps that predate this option are\n * unaffected even if such an id collision exists.\n *\n * Omit to fall back to all tile layers in insertion order, followed by all\n * image layers in insertion order - the map's implicit ordering before\n * this option existed.\n *\n * Named `documentOrder` rather than `renderOrder` to avoid colliding with\n * the unrelated {@link renderOrder} option above (Tiled's tile-draw-\n * direction string, e.g. `'right-down'`).\n */\n readonly documentOrder?: readonly number[];\n}\n\n/**\n * A generic, format-independent tile map.\n *\n * Owns a finite grid of {@link TileLayer}s and a shared set of {@link TileSet}s.\n * Tile data is stored in compact chunked arrays - no per-tile heap objects.\n *\n * The map does NOT own tileset textures (those are Loader-owned) and does\n * NOT own SceneNode children - see {@link import('./TileMapNode').TileMapNode},\n * which owns those.\n *\n * Multiple tilesets are supported: each cell stores a packed tileset index\n * and local tile ID, so different tilesets may have different tile dimensions.\n *\n * @advanced\n */\nexport class TileMap {\n /** Map name (debug). */\n public readonly name: string;\n\n /** Map width in tiles, or `undefined` if unbounded. */\n public readonly width: number | undefined;\n /** Map height in tiles, or `undefined` if unbounded. */\n public readonly height: number | undefined;\n\n /** Tile width in pixels. */\n public readonly tileWidth: number;\n /** Tile height in pixels. */\n public readonly tileHeight: number;\n\n /** Pixel width, or `undefined` if unbounded. */\n public get pixelWidth(): number | undefined {\n return this.width === undefined ? undefined : this.width * this.tileWidth;\n }\n /** Pixel height, or `undefined` if unbounded. */\n public get pixelHeight(): number | undefined {\n return this.height === undefined ? undefined : this.height * this.tileHeight;\n }\n /** `true` if this map has a fixed width/height; `false` if unbounded. */\n public get bounded(): boolean {\n return this.width !== undefined && this.height !== undefined;\n }\n\n /** Default chunk width for layers. */\n public readonly chunkWidth: number;\n /** Default chunk height for layers. */\n public readonly chunkHeight: number;\n\n /** Map class/type string (Tiled `class`; may be empty). */\n public readonly class: string;\n /** Map background colour as `0xRRGGBB`, or `null`. Informational. */\n public readonly backgroundColor: number | null;\n /** Tile draw order (Tiled `renderorder`). Informational. */\n public readonly renderOrder: string;\n\n /** Map-level properties (immutable). */\n public readonly properties: TileProperties;\n\n private readonly _tilesets: TileSet[];\n private readonly _layers: TileLayer[] = [];\n private readonly _layerById = new Map<number, TileLayer>();\n private readonly _objectLayers: ObjectLayer[] = [];\n private readonly _imageLayers: ImageLayer[] = [];\n private readonly _documentOrder: Array<TileLayer | ImageLayer> = [];\n\n private _revision = 0;\n private _destroyed = false;\n\n /**\n * @throws When dimensions or other options are invalid.\n */\n public constructor(options: TileMapOptions) {\n validatePairedDimensions(options.width, options.height, 'TileMap', 'map');\n validatePositiveInteger(options.tileWidth, 'map.tileWidth');\n validatePositiveInteger(options.tileHeight, 'map.tileHeight');\n\n const chunkWidth = options.chunkWidth ?? 32;\n const chunkHeight = options.chunkHeight ?? 32;\n validatePositiveInteger(chunkWidth, 'chunkWidth');\n validatePositiveInteger(chunkHeight, 'chunkHeight');\n\n this.name = options.name ?? 'TileMap';\n this.width = options.width;\n this.height = options.height;\n this.tileWidth = options.tileWidth;\n this.tileHeight = options.tileHeight;\n this.chunkWidth = chunkWidth;\n this.chunkHeight = chunkHeight;\n this.class = options.class ?? '';\n this.backgroundColor = options.backgroundColor ?? null;\n this.renderOrder = options.renderOrder ?? 'right-down';\n\n this._tilesets = options.tilesets ? [...options.tilesets] : [];\n this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});\n\n if (options.layers) {\n for (const layer of options.layers) {\n this._addLayer(layer);\n }\n }\n\n if (options.objectLayers) {\n this._objectLayers.push(...options.objectLayers);\n }\n\n if (options.imageLayers) {\n for (const layer of options.imageLayers) {\n this._addImageLayer(layer);\n }\n }\n\n this._documentOrder.push(...this._buildDocumentOrder(options.documentOrder));\n }\n\n /**\n * Validate an explicit `documentOrder` option against current tile/image\n * layer membership and resolve it to layer instances, or compute the\n * fallback order (tile layers in insertion order, then image layers) when\n * omitted. The order stores instance references - not ids - so a\n * cross-kind id collision in a fallback map can never resolve to the\n * wrong layer.\n * @throws Per the validation rules documented on {@link\n * TileMapOptions.documentOrder}.\n */\n private _buildDocumentOrder(documentOrder: readonly number[] | undefined): Array<TileLayer | ImageLayer> {\n if (!documentOrder) {\n return [...this._layers, ...this._imageLayers];\n }\n\n const tileIds = new Set(this._layers.map(l => l.id));\n const imageIds = new Set(this._imageLayers.map(l => l.id));\n\n for (const id of tileIds) {\n if (imageIds.has(id)) {\n throw new Error(`Layer ID ${id} exists as both a tile layer and an image layer in map \"${this.name}\"; documentOrder cannot disambiguate them.`);\n }\n }\n\n const seen = new Set<number>();\n for (const id of documentOrder) {\n if (!tileIds.has(id) && !imageIds.has(id)) {\n throw new Error(`documentOrder references unknown layer ID ${id} in map \"${this.name}\".`);\n }\n if (seen.has(id)) {\n throw new Error(`documentOrder lists layer ID ${id} more than once in map \"${this.name}\".`);\n }\n seen.add(id);\n }\n\n const totalLayers = tileIds.size + imageIds.size;\n if (seen.size !== totalLayers) {\n for (const id of [...tileIds, ...imageIds]) {\n if (!seen.has(id)) {\n throw new Error(`documentOrder is missing layer ID ${id} in map \"${this.name}\".`);\n }\n }\n }\n\n // The checks above are id-SET based, so they can't see a duplicate\n // image-layer id (nothing enforces image-layer id uniqueness): two\n // image layers sharing an id collapse to one entry in `imageIds`,\n // letting a documentOrder that covers every distinct id still be one\n // instance short. Compare against the actual instance counts so that\n // case throws instead of silently dropping an instance from\n // renderableLayers.\n const instanceCount = this._layers.length + this._imageLayers.length;\n if (documentOrder.length !== instanceCount) {\n throw new Error(\n `documentOrder has ${documentOrder.length} entries but map \"${this.name}\" has ${instanceCount} tile/image layer instances; check for a duplicate image-layer ID.`,\n );\n }\n\n // Ids are unique across kinds here (the cross-kind check above threw\n // otherwise), so resolving each id to an instance is unambiguous. The\n // count check above does not guarantee the ids themselves match, so an\n // unresolvable one is reported rather than left as a hole in the list.\n return documentOrder.map(id => {\n const layer = this._layerById.get(id) ?? this._imageLayers.find(imageLayer => imageLayer.id === id);\n\n if (!layer) {\n throw new Error(`documentOrder references layer id ${id}, but map \"${this.name}\" has no tile or image layer with that id.`);\n }\n\n return layer;\n });\n }\n\n // ── Tilesets ──────────────────────────────────────────────────────────\n\n /** Immutable list of tilesets available to this map. */\n public get tilesets(): readonly TileSet[] {\n return this._tilesets;\n }\n\n /**\n * Add a tileset. Tilesets must have unique names.\n * @throws If a tileset with the same name already exists, or the map is destroyed.\n */\n public addTileset(tileset: TileSet): void {\n this._checkDestroyed();\n if (this._tilesets.some(ts => ts.name === tileset.name)) {\n throw new Error(`Tileset \"${tileset.name}\" already exists in map \"${this.name}\".`);\n }\n this._tilesets.push(tileset);\n this._revision++;\n }\n\n /**\n * Get a tileset by name, or undefined.\n */\n public getTileset(name: string): TileSet | undefined {\n return this._tilesets.find(ts => ts.name === name);\n }\n\n // ── Layers ────────────────────────────────────────────────────────────\n\n /** Immutable snapshot of layers (ordered). */\n public get layers(): readonly TileLayer[] {\n return this._layers;\n }\n\n private _addLayer(layer: TileLayer): void {\n if (this._layerById.has(layer.id)) {\n throw new Error(`Layer ID ${layer.id} already exists in map \"${this.name}\".`);\n }\n this._layerById.set(layer.id, layer);\n this._layers.push(layer);\n }\n\n /**\n * Add a layer after construction. Appended to the end of {@link\n * renderableLayers}'s document order.\n * @throws If a layer with the same ID already exists.\n */\n public addLayer(layer: TileLayer): void {\n this._checkDestroyed();\n this._addLayer(layer);\n this._documentOrder.push(layer);\n this._revision++;\n }\n\n /**\n * Get a tile layer by ID.\n */\n public getTileLayerById(id: number): TileLayer | undefined {\n return this._layerById.get(id);\n }\n\n /**\n * Get a tile layer by name. Returns the first match in insertion order.\n */\n public getTileLayer(name: string): TileLayer | undefined {\n return this._layers.find(l => l.name === name);\n }\n\n /**\n * Remove a layer by ID. The layer is destroyed and spliced out of {@link\n * renderableLayers}'s document order.\n * @returns true if the layer was found and removed.\n */\n public removeLayer(id: number): boolean {\n this._checkDestroyed();\n const layer = this._layerById.get(id);\n if (!layer) return false;\n this._layers.splice(this._layers.indexOf(layer), 1);\n this._layerById.delete(id);\n const orderIndex = this._documentOrder.indexOf(layer);\n if (orderIndex !== -1) this._documentOrder.splice(orderIndex, 1);\n layer.destroy();\n this._revision++;\n return true;\n }\n\n // ── Object layers (data-only) ─────────────────────────────────────────\n\n /** Immutable snapshot of object layers (insertion order). */\n public get objectLayers(): readonly ObjectLayer[] {\n return this._objectLayers;\n }\n\n /**\n * Add an object layer after construction.\n * @throws If the map is destroyed.\n */\n public addObjectLayer(layer: ObjectLayer): void {\n this._checkDestroyed();\n this._objectLayers.push(layer);\n this._revision++;\n }\n\n /**\n * Get an object layer by name (first match in insertion order), or undefined.\n *\n * Supply an {@link ObjectSchema} type argument `S` to obtain a typed view of\n * the layer - `getObjectLayer<LevelObjects>('Entities')` returns an\n * `ObjectLayer<LevelObjects>` whose {@link ObjectLayer.byType} / {@link\n * ObjectLayer.where} accessors narrow `properties`. The schema is a static\n * developer promise only; no runtime validation is performed and the call\n * remains fully back-compatible when omitted.\n */\n public getObjectLayer<S extends ObjectSchema = ObjectSchema>(name: string): ObjectLayer<S> | undefined {\n return this._objectLayers.find(layer => layer.name === name) as ObjectLayer<S> | undefined;\n }\n\n /**\n * Get an object layer by ID.\n *\n * Supply an {@link ObjectSchema} type argument `S` to obtain a typed view of\n * the layer, as with {@link getObjectLayer}.\n */\n public getObjectLayerById<S extends ObjectSchema = ObjectSchema>(id: number): ObjectLayer<S> | undefined {\n return this._objectLayers.find(layer => layer.id === id) as ObjectLayer<S> | undefined;\n }\n\n /**\n * Remove an object layer by ID.\n * @returns true if the layer was found and removed.\n */\n public removeObjectLayer(id: number): boolean {\n this._checkDestroyed();\n const index = this._objectLayers.findIndex(layer => layer.id === id);\n if (index === -1) return false;\n this._objectLayers.splice(index, 1);\n this._revision++;\n return true;\n }\n\n // ── Image layers (data-only) ──────────────────────────────────────────\n\n /** Immutable snapshot of image layers (insertion order). */\n public get imageLayers(): readonly ImageLayer[] {\n return this._imageLayers;\n }\n\n /**\n * Add an image layer after construction. Appended to both {@link\n * imageLayers} and the end of {@link renderableLayers}'s document order.\n * @throws If an image layer with the same ID already exists. An ID shared\n * with a *tile* layer is permitted - the two kinds keep separate ID\n * spaces, and all internal bookkeeping is instance-based.\n */\n public addImageLayer(layer: ImageLayer): void {\n this._checkDestroyed();\n this._addImageLayer(layer);\n this._documentOrder.push(layer);\n this._revision++;\n }\n\n /** Shared by the constructor and {@link addImageLayer}: enforce ID uniqueness within the image-layer kind. */\n private _addImageLayer(layer: ImageLayer): void {\n if (this._imageLayers.some(existing => existing.id === layer.id)) {\n throw new Error(`Image layer ID ${layer.id} already exists in map \"${this.name}\".`);\n }\n this._imageLayers.push(layer);\n }\n\n /**\n * Get an image layer by name (first match in insertion order), or undefined.\n */\n public getImageLayer(name: string): ImageLayer | undefined {\n return this._imageLayers.find(layer => layer.name === name);\n }\n\n /**\n * Get an image layer by ID.\n */\n public getImageLayerById(id: number): ImageLayer | undefined {\n return this._imageLayers.find(layer => layer.id === id);\n }\n\n /**\n * Remove an image layer by ID. Spliced out of {@link renderableLayers}'s\n * document order.\n * @returns true if the layer was found and removed.\n */\n public removeImageLayer(id: number): boolean {\n this._checkDestroyed();\n const layer = this._imageLayers.find(l => l.id === id);\n if (!layer) return false;\n this._imageLayers.splice(this._imageLayers.indexOf(layer), 1);\n const orderIndex = this._documentOrder.indexOf(layer);\n if (orderIndex !== -1) this._documentOrder.splice(orderIndex, 1);\n this._revision++;\n return true;\n }\n\n // ── Combined render order ─────────────────────────────────────────────\n\n /**\n * Tile and image layers combined into a single document order (see {@link\n * TileMapOptions.documentOrder}), maintained live as membership changes.\n * Reflects `addLayer` / `addImageLayer` / `removeLayer` /\n * `removeImageLayer` calls made after construction. Holds instance\n * references, so entries stay correct even when a tile layer and an image\n * layer share an id in a fallback-ordered map. Object layers are\n * data-only and never appear here.\n */\n public get renderableLayers(): ReadonlyArray<TileLayer | ImageLayer> {\n return this._documentOrder;\n }\n\n // ── Scene composition ─────────────────────────────────────────────────\n\n /**\n * Create a new {@link TileMapView} that groups this map's layers into\n * independently placeable band / layer scene nodes for interleaving\n * application actors between tile layers.\n *\n * Each call returns a fresh, independent view - the map does **not** cache a\n * single global view, so multiple coexisting views of the same map are\n * allowed. The view references this map but never owns it: destroying the\n * view frees only its generated layer/band nodes - never the map, its layers,\n * tileset textures, or any application actors.\n *\n * @advanced\n */\n public createView(options?: TileMapViewOptions): TileMapView {\n return new TileMapView(this, options);\n }\n\n // ── Queries ───────────────────────────────────────────────────────────\n\n /**\n * Get a resolved tile from a given layer at tile coordinates.\n * Convenience for `map.getTileLayerById(id)?.getTileAt(tx, ty)`.\n * Returns null for an empty cell, out-of-bounds, or missing layer.\n */\n public getTileAt(layerId: number, tx: number, ty: number): ResolvedTile | null {\n const layer = this._layerById.get(layerId);\n if (!layer) return null;\n return layer.getTileAt(tx, ty);\n }\n\n /**\n * Set a tile on a given layer at tile coordinates.\n * Convenience for `map.getTileLayerById(id)?.setTileAt(tx, ty, tile)`.\n * @throws If the layer does not exist, coordinates are out of bounds,\n * or the tile reference is invalid.\n */\n public setTileAt(layerId: number, tx: number, ty: number, tile: ResolvedTile): void {\n const layer = this._layerById.get(layerId);\n if (!layer) throw new Error(`Layer ${layerId} not found in map \"${this.name}\".`);\n layer.setTileAt(tx, ty, tile);\n }\n\n /**\n * Clear a tile on a given layer at tile coordinates.\n * Convenience for `map.getTileLayerById(id)?.clearTileAt(tx, ty)`.\n * @throws If the layer does not exist or coordinates are out of bounds.\n */\n public clearTileAt(layerId: number, tx: number, ty: number): void {\n const layer = this._layerById.get(layerId);\n if (!layer) throw new Error(`Layer ${layerId} not found in map \"${this.name}\".`);\n layer.clearTileAt(tx, ty);\n }\n\n // ── Coordinate conversion (base layer) ────────────────────────────────\n\n /**\n * Convert a tile coordinate to the pixel position of its top-left corner\n * in map-local space (ignoring layer offsets).\n */\n public tileToPixel(tx: number, ty: number): { x: number; y: number } {\n return {\n x: tx * this.tileWidth,\n y: ty * this.tileHeight,\n };\n }\n\n /**\n * Convert a pixel position in map-local space to the tile coordinate\n * that contains it. Uses `floor`. May return coordinates outside map bounds.\n */\n public pixelToTile(px: number, py: number): { tx: number; ty: number } {\n return {\n tx: Math.floor(px / this.tileWidth),\n ty: Math.floor(py / this.tileHeight),\n };\n }\n\n // ── Revision / lifecycle ──────────────────────────────────────────────\n\n /**\n * Monotonic map revision counter. Increments on structural changes only\n * (add/remove layer, add tileset). Cell mutations are tracked per-chunk\n * and per-layer; the renderer reads chunk-level revisions directly.\n * @advanced\n */\n public get revision(): number {\n return this._revision;\n }\n\n /** Whether the map has been destroyed. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n private _checkDestroyed(): void {\n if (this._destroyed) {\n throw new Error(`TileMap \"${this.name}\" has been destroyed.`);\n }\n }\n\n /**\n * Destroy the map and all owned layers and chunk storage.\n *\n * Is idempotent. Does NOT destroy tileset textures (Loader-owned) or\n * any SceneNodes (those do not exist yet in this slice).\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n for (const layer of this._layers) {\n layer.destroy();\n }\n this._layers.length = 0;\n this._layerById.clear();\n this._objectLayers.length = 0;\n this._imageLayers.length = 0;\n this._documentOrder.length = 0;\n this._tilesets.length = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgGA,IAAa,UAAb,MAAqB;;CAEnB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,IAAW,aAAiC;EAC1C,OAAO,KAAK,UAAU,SAAY,SAAY,KAAK,QAAQ,KAAK;CAClE;;CAEA,IAAW,cAAkC;EAC3C,OAAO,KAAK,WAAW,SAAY,SAAY,KAAK,SAAS,KAAK;CACpE;;CAEA,IAAW,UAAmB;EAC5B,OAAO,KAAK,UAAU,UA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GAAG,KAAK,KAAK;EACf;CACF;;;;;CAMA,AAAO,YAAY,IAAY,IAAwC;EACrE,OAAO;GACL,IAAI,KAAK,MAAM,KAAK,KAAK,SAAS;GAClC,IAAI,KAAK,MAAM,KAAK,KAAK,UAAU;EACrC;CACF;;;;;;;CAUA,IAAW,WAAmB;EAC5B,OAAO,KAAK;CACd;;CAGA,IAAW,YAAqB;EAC9B,OAAO,KAAK;CACd;CAEA,AAAQ,kBAAwB;EAC9B,IAAI,KAAK,YACP,MAAM,IAAI,MAAM,YAAY,KAAK,KAAK,sBAAsB;CAEhE;;;;;;;CAQA,AAAO,UAAgB;EACrB,IAAI,KAAK,YAAY;EACrB,KAAK,aAAa;EAClB,KAAK,MAAM,SAAS,KAAK,SACvB,MAAM,QAAQ;EAEhB,KAAK,QAAQ,SAAS;EACtB,KAAK,WAAW,MAAM;EACtB,KAAK,cAAc,SAAS;EAC5B,KAAK,aAAa,SAAS;EAC3B,KAAK,eAAe,SAAS;EAC7B,KAAK,UAAU,SAAS;CAC1B;AACF"}
1
+ {"version":3,"file":"TileMap.js","names":[],"sources":["../../src/TileMap.ts"],"sourcesContent":["import { type ImageLayer } from './ImageLayer';\nimport type { ObjectLayer, ObjectSchema } from './ObjectLayer';\nimport { type TileLayer } from './TileLayer';\nimport type { TileMapViewOptions } from './TileMapView';\nimport { TileMapView } from './TileMapView';\nimport { TileProjection } from './TileProjection';\nimport { type TileSet } from './TileSet';\nimport type { ResolvedTile, TileProperties } from './types';\nimport { validatePairedDimensions, validatePositiveInteger } from './types';\n\n/**\n * Options for constructing a {@link TileMap}.\n * @advanced\n */\nexport interface TileMapOptions {\n /** Shared projection; defaults to an orthogonal grid of the supplied tile size. */\n readonly projection?: TileProjection;\n /** Map name (for debugging). */\n readonly name?: string;\n /**\n * Map width in tiles. Omit together with {@link height} for an unbounded\n * map - layers you add are then free to be unbounded too (this option\n * does not constrain per-layer dimensions either way).\n */\n readonly width?: number;\n /** Map height in tiles. Must be provided iff {@link width} is. */\n readonly height?: number;\n /** Width of each tile in pixels. */\n readonly tileWidth: number;\n /** Height of each tile in pixels. */\n readonly tileHeight: number;\n /** Tilesets available to this map. */\n readonly tilesets?: readonly TileSet[];\n /** Layers (constructed externally and owned by the map after construction). */\n readonly layers?: readonly TileLayer[];\n /** Object layers (data-only; spawn points, triggers, collision regions). */\n readonly objectLayers?: readonly ObjectLayer[];\n /** Image layers (data-only; background/foreground images from Tiled image layers). */\n readonly imageLayers?: readonly ImageLayer[];\n /** Chunk width for layers (default 32). */\n readonly chunkWidth?: number;\n /** Chunk height for layers (default 32). */\n readonly chunkHeight?: number;\n /** Map class/type string (Tiled `class`). Defaults to `''`. */\n readonly class?: string;\n /**\n * Map background colour as a `0xRRGGBB` integer, or `null` (Tiled\n * `backgroundcolor`). Informational - the renderer does not auto-clear to it.\n * Default `null`.\n */\n readonly backgroundColor?: number | null;\n /** Tile draw order (Tiled `renderorder`), informational. Default `'right-down'`. */\n readonly renderOrder?: string;\n /** Map-level properties (copied and frozen). */\n readonly properties?: TileProperties;\n /**\n * Combined document order across tile and image layers, as an ordered list\n * of layer ids - exposed via {@link TileMap.renderableLayers}. Every tile\n * and image layer passed to this map (via {@link layers} / {@link\n * imageLayers}) must appear exactly once; an id that belongs to neither\n * kind, or is listed more than once, throws. The list's length must also\n * equal the total number of tile/image layer instances - nothing enforces\n * unique ids across image layers, so two image layers sharing an id would\n * otherwise both satisfy the id-based checks while one silently drops out\n * of {@link TileMap.renderableLayers}; that mismatch throws too.\n *\n * A tile layer and an image layer sharing the same id makes the order\n * ambiguous - that combination throws when `documentOrder` is provided.\n * It is NOT rejected when this option is omitted: the fallback order below\n * is unambiguous by construction (tile layers are always listed before\n * image layers), so hand-built maps that predate this option are\n * unaffected even if such an id collision exists.\n *\n * Omit to fall back to all tile layers in insertion order, followed by all\n * image layers in insertion order - the map's implicit ordering before\n * this option existed.\n *\n * Named `documentOrder` rather than `renderOrder` to avoid colliding with\n * the unrelated {@link renderOrder} option above (Tiled's tile-draw-\n * direction string, e.g. `'right-down'`).\n */\n readonly documentOrder?: readonly number[];\n}\n\n/**\n * A generic, format-independent tile map.\n *\n * Owns a finite grid of {@link TileLayer}s and a shared set of {@link TileSet}s.\n * Tile data is stored in compact chunked arrays - no per-tile heap objects.\n *\n * The map does NOT own tileset textures (those are Loader-owned) and does\n * NOT own SceneNode children - see {@link import('./TileMapNode').TileMapNode},\n * which owns those.\n *\n * Multiple tilesets are supported: each cell stores a packed tileset index\n * and local tile ID, so different tilesets may have different tile dimensions.\n *\n * @advanced\n */\nexport class TileMap {\n public readonly projection: TileProjection;\n /** Map name (debug). */\n public readonly name: string;\n\n /** Map width in tiles, or `undefined` if unbounded. */\n public readonly width: number | undefined;\n /** Map height in tiles, or `undefined` if unbounded. */\n public readonly height: number | undefined;\n\n /** Tile width in pixels. */\n public readonly tileWidth: number;\n /** Tile height in pixels. */\n public readonly tileHeight: number;\n\n /** Pixel width, or `undefined` if unbounded. */\n public get pixelWidth(): number | undefined {\n return this.width === undefined || this.height === undefined ? undefined : this.projection.getBounds(0, 0, this.width, this.height).width;\n }\n /** Pixel height, or `undefined` if unbounded. */\n public get pixelHeight(): number | undefined {\n return this.width === undefined || this.height === undefined ? undefined : this.projection.getBounds(0, 0, this.width, this.height).height;\n }\n /** `true` if this map has a fixed width/height; `false` if unbounded. */\n public get bounded(): boolean {\n return this.width !== undefined && this.height !== undefined;\n }\n\n /** Default chunk width for layers. */\n public readonly chunkWidth: number;\n /** Default chunk height for layers. */\n public readonly chunkHeight: number;\n\n /** Map class/type string (Tiled `class`; may be empty). */\n public readonly class: string;\n /** Map background colour as `0xRRGGBB`, or `null`. Informational. */\n public readonly backgroundColor: number | null;\n /** Tile draw order (Tiled `renderorder`). Informational. */\n public readonly renderOrder: string;\n\n /** Map-level properties (immutable). */\n public readonly properties: TileProperties;\n\n private readonly _tilesets: TileSet[];\n private readonly _layers: TileLayer[] = [];\n private readonly _layerById = new Map<number, TileLayer>();\n private readonly _objectLayers: ObjectLayer[] = [];\n private readonly _imageLayers: ImageLayer[] = [];\n private readonly _documentOrder: Array<TileLayer | ImageLayer> = [];\n\n private _revision = 0;\n private _destroyed = false;\n\n /**\n * @throws When dimensions or other options are invalid.\n */\n public constructor(options: TileMapOptions) {\n validatePairedDimensions(options.width, options.height, 'TileMap', 'map');\n validatePositiveInteger(options.tileWidth, 'map.tileWidth');\n validatePositiveInteger(options.tileHeight, 'map.tileHeight');\n\n const chunkWidth = options.chunkWidth ?? 32;\n const chunkHeight = options.chunkHeight ?? 32;\n validatePositiveInteger(chunkWidth, 'chunkWidth');\n validatePositiveInteger(chunkHeight, 'chunkHeight');\n\n this.name = options.name ?? 'TileMap';\n this.width = options.width;\n this.height = options.height;\n this.tileWidth = options.tileWidth;\n this.tileHeight = options.tileHeight;\n this.projection = options.projection ?? new TileProjection({ tileWidth: options.tileWidth, tileHeight: options.tileHeight });\n if (this.projection.tileWidth !== this.tileWidth || this.projection.tileHeight !== this.tileHeight) {\n throw new Error('Projection tile dimensions must match the layer or map.');\n }\n this.chunkWidth = chunkWidth;\n this.chunkHeight = chunkHeight;\n this.class = options.class ?? '';\n this.backgroundColor = options.backgroundColor ?? null;\n this.renderOrder = options.renderOrder ?? 'right-down';\n\n this._tilesets = options.tilesets ? [...options.tilesets] : [];\n this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});\n\n if (options.layers) {\n for (const layer of options.layers) {\n this._addLayer(layer);\n }\n }\n\n if (options.objectLayers) {\n this._objectLayers.push(...options.objectLayers);\n }\n\n if (options.imageLayers) {\n for (const layer of options.imageLayers) {\n this._addImageLayer(layer);\n }\n }\n\n this._documentOrder.push(...this._buildDocumentOrder(options.documentOrder));\n }\n\n /**\n * Validate an explicit `documentOrder` option against current tile/image\n * layer membership and resolve it to layer instances, or compute the\n * fallback order (tile layers in insertion order, then image layers) when\n * omitted. The order stores instance references - not ids - so a\n * cross-kind id collision in a fallback map can never resolve to the\n * wrong layer.\n * @throws Per the validation rules documented on {@link\n * TileMapOptions.documentOrder}.\n */\n private _buildDocumentOrder(documentOrder: readonly number[] | undefined): Array<TileLayer | ImageLayer> {\n if (!documentOrder) {\n return [...this._layers, ...this._imageLayers];\n }\n\n const tileIds = new Set(this._layers.map(l => l.id));\n const imageIds = new Set(this._imageLayers.map(l => l.id));\n\n for (const id of tileIds) {\n if (imageIds.has(id)) {\n throw new Error(`Layer ID ${id} exists as both a tile layer and an image layer in map \"${this.name}\"; documentOrder cannot disambiguate them.`);\n }\n }\n\n const seen = new Set<number>();\n for (const id of documentOrder) {\n if (!tileIds.has(id) && !imageIds.has(id)) {\n throw new Error(`documentOrder references unknown layer ID ${id} in map \"${this.name}\".`);\n }\n if (seen.has(id)) {\n throw new Error(`documentOrder lists layer ID ${id} more than once in map \"${this.name}\".`);\n }\n seen.add(id);\n }\n\n const totalLayers = tileIds.size + imageIds.size;\n if (seen.size !== totalLayers) {\n for (const id of [...tileIds, ...imageIds]) {\n if (!seen.has(id)) {\n throw new Error(`documentOrder is missing layer ID ${id} in map \"${this.name}\".`);\n }\n }\n }\n\n // The checks above are id-SET based, so they can't see a duplicate\n // image-layer id (nothing enforces image-layer id uniqueness): two\n // image layers sharing an id collapse to one entry in `imageIds`,\n // letting a documentOrder that covers every distinct id still be one\n // instance short. Compare against the actual instance counts so that\n // case throws instead of silently dropping an instance from\n // renderableLayers.\n const instanceCount = this._layers.length + this._imageLayers.length;\n if (documentOrder.length !== instanceCount) {\n throw new Error(\n `documentOrder has ${documentOrder.length} entries but map \"${this.name}\" has ${instanceCount} tile/image layer instances; check for a duplicate image-layer ID.`,\n );\n }\n\n // Ids are unique across kinds here (the cross-kind check above threw\n // otherwise), so resolving each id to an instance is unambiguous. The\n // count check above does not guarantee the ids themselves match, so an\n // unresolvable one is reported rather than left as a hole in the list.\n return documentOrder.map(id => {\n const layer = this._layerById.get(id) ?? this._imageLayers.find(imageLayer => imageLayer.id === id);\n\n if (!layer) {\n throw new Error(`documentOrder references layer id ${id}, but map \"${this.name}\" has no tile or image layer with that id.`);\n }\n\n return layer;\n });\n }\n\n // ── Tilesets ──────────────────────────────────────────────────────────\n\n /** Immutable list of tilesets available to this map. */\n public get tilesets(): readonly TileSet[] {\n return this._tilesets;\n }\n\n /**\n * Add a tileset. Tilesets must have unique names.\n * @throws If a tileset with the same name already exists, or the map is destroyed.\n */\n public addTileset(tileset: TileSet): void {\n this._checkDestroyed();\n if (this._tilesets.some(ts => ts.name === tileset.name)) {\n throw new Error(`Tileset \"${tileset.name}\" already exists in map \"${this.name}\".`);\n }\n this._tilesets.push(tileset);\n this._revision++;\n }\n\n /**\n * Get a tileset by name, or undefined.\n */\n public getTileset(name: string): TileSet | undefined {\n return this._tilesets.find(ts => ts.name === name);\n }\n\n // ── Layers ────────────────────────────────────────────────────────────\n\n /** Immutable snapshot of layers (ordered). */\n public get layers(): readonly TileLayer[] {\n return this._layers;\n }\n\n private _addLayer(layer: TileLayer): void {\n if (this._layerById.has(layer.id)) {\n throw new Error(`Layer ID ${layer.id} already exists in map \"${this.name}\".`);\n }\n this._layerById.set(layer.id, layer);\n this._layers.push(layer);\n }\n\n /**\n * Add a layer after construction. Appended to the end of {@link\n * renderableLayers}'s document order.\n * @throws If a layer with the same ID already exists.\n */\n public addLayer(layer: TileLayer): void {\n this._checkDestroyed();\n this._addLayer(layer);\n this._documentOrder.push(layer);\n this._revision++;\n }\n\n /**\n * Get a tile layer by ID.\n */\n public getTileLayerById(id: number): TileLayer | undefined {\n return this._layerById.get(id);\n }\n\n /**\n * Get a tile layer by name. Returns the first match in insertion order.\n */\n public getTileLayer(name: string): TileLayer | undefined {\n return this._layers.find(l => l.name === name);\n }\n\n /**\n * Remove a layer by ID. The layer is destroyed and spliced out of {@link\n * renderableLayers}'s document order.\n * @returns true if the layer was found and removed.\n */\n public removeLayer(id: number): boolean {\n this._checkDestroyed();\n const layer = this._layerById.get(id);\n if (!layer) return false;\n this._layers.splice(this._layers.indexOf(layer), 1);\n this._layerById.delete(id);\n const orderIndex = this._documentOrder.indexOf(layer);\n if (orderIndex !== -1) this._documentOrder.splice(orderIndex, 1);\n layer.destroy();\n this._revision++;\n return true;\n }\n\n // ── Object layers (data-only) ─────────────────────────────────────────\n\n /** Immutable snapshot of object layers (insertion order). */\n public get objectLayers(): readonly ObjectLayer[] {\n return this._objectLayers;\n }\n\n /**\n * Add an object layer after construction.\n * @throws If the map is destroyed.\n */\n public addObjectLayer(layer: ObjectLayer): void {\n this._checkDestroyed();\n this._objectLayers.push(layer);\n this._revision++;\n }\n\n /**\n * Get an object layer by name (first match in insertion order), or undefined.\n *\n * Supply an {@link ObjectSchema} type argument `S` to obtain a typed view of\n * the layer - `getObjectLayer<LevelObjects>('Entities')` returns an\n * `ObjectLayer<LevelObjects>` whose {@link ObjectLayer.byType} / {@link\n * ObjectLayer.where} accessors narrow `properties`. The schema is a static\n * developer promise only; no runtime validation is performed and the call\n * remains fully back-compatible when omitted.\n */\n public getObjectLayer<S extends ObjectSchema = ObjectSchema>(name: string): ObjectLayer<S> | undefined {\n return this._objectLayers.find(layer => layer.name === name) as ObjectLayer<S> | undefined;\n }\n\n /**\n * Get an object layer by ID.\n *\n * Supply an {@link ObjectSchema} type argument `S` to obtain a typed view of\n * the layer, as with {@link getObjectLayer}.\n */\n public getObjectLayerById<S extends ObjectSchema = ObjectSchema>(id: number): ObjectLayer<S> | undefined {\n return this._objectLayers.find(layer => layer.id === id) as ObjectLayer<S> | undefined;\n }\n\n /**\n * Remove an object layer by ID.\n * @returns true if the layer was found and removed.\n */\n public removeObjectLayer(id: number): boolean {\n this._checkDestroyed();\n const index = this._objectLayers.findIndex(layer => layer.id === id);\n if (index === -1) return false;\n this._objectLayers.splice(index, 1);\n this._revision++;\n return true;\n }\n\n // ── Image layers (data-only) ──────────────────────────────────────────\n\n /** Immutable snapshot of image layers (insertion order). */\n public get imageLayers(): readonly ImageLayer[] {\n return this._imageLayers;\n }\n\n /**\n * Add an image layer after construction. Appended to both {@link\n * imageLayers} and the end of {@link renderableLayers}'s document order.\n * @throws If an image layer with the same ID already exists. An ID shared\n * with a *tile* layer is permitted - the two kinds keep separate ID\n * spaces, and all internal bookkeeping is instance-based.\n */\n public addImageLayer(layer: ImageLayer): void {\n this._checkDestroyed();\n this._addImageLayer(layer);\n this._documentOrder.push(layer);\n this._revision++;\n }\n\n /** Shared by the constructor and {@link addImageLayer}: enforce ID uniqueness within the image-layer kind. */\n private _addImageLayer(layer: ImageLayer): void {\n if (this._imageLayers.some(existing => existing.id === layer.id)) {\n throw new Error(`Image layer ID ${layer.id} already exists in map \"${this.name}\".`);\n }\n this._imageLayers.push(layer);\n }\n\n /**\n * Get an image layer by name (first match in insertion order), or undefined.\n */\n public getImageLayer(name: string): ImageLayer | undefined {\n return this._imageLayers.find(layer => layer.name === name);\n }\n\n /**\n * Get an image layer by ID.\n */\n public getImageLayerById(id: number): ImageLayer | undefined {\n return this._imageLayers.find(layer => layer.id === id);\n }\n\n /**\n * Remove an image layer by ID. Spliced out of {@link renderableLayers}'s\n * document order.\n * @returns true if the layer was found and removed.\n */\n public removeImageLayer(id: number): boolean {\n this._checkDestroyed();\n const layer = this._imageLayers.find(l => l.id === id);\n if (!layer) return false;\n this._imageLayers.splice(this._imageLayers.indexOf(layer), 1);\n const orderIndex = this._documentOrder.indexOf(layer);\n if (orderIndex !== -1) this._documentOrder.splice(orderIndex, 1);\n this._revision++;\n return true;\n }\n\n // ── Combined render order ─────────────────────────────────────────────\n\n /**\n * Tile and image layers combined into a single document order (see {@link\n * TileMapOptions.documentOrder}), maintained live as membership changes.\n * Reflects `addLayer` / `addImageLayer` / `removeLayer` /\n * `removeImageLayer` calls made after construction. Holds instance\n * references, so entries stay correct even when a tile layer and an image\n * layer share an id in a fallback-ordered map. Object layers are\n * data-only and never appear here.\n */\n public get renderableLayers(): ReadonlyArray<TileLayer | ImageLayer> {\n return this._documentOrder;\n }\n\n // ── Scene composition ─────────────────────────────────────────────────\n\n /**\n * Create a new {@link TileMapView} that groups this map's layers into\n * independently placeable band / layer scene nodes for interleaving\n * application actors between tile layers.\n *\n * Each call returns a fresh, independent view - the map does **not** cache a\n * single global view, so multiple coexisting views of the same map are\n * allowed. The view references this map but never owns it: destroying the\n * view frees only its generated layer/band nodes - never the map, its layers,\n * tileset textures, or any application actors.\n *\n * @advanced\n */\n public createView(options?: TileMapViewOptions): TileMapView {\n return new TileMapView(this, options);\n }\n\n // ── Queries ───────────────────────────────────────────────────────────\n\n /**\n * Get a resolved tile from a given layer at tile coordinates.\n * Convenience for `map.getTileLayerById(id)?.getTileAt(tx, ty)`.\n * Returns null for an empty cell, out-of-bounds, or missing layer.\n */\n public getTileAt(layerId: number, tx: number, ty: number): ResolvedTile | null {\n const layer = this._layerById.get(layerId);\n if (!layer) return null;\n return layer.getTileAt(tx, ty);\n }\n\n /**\n * Set a tile on a given layer at tile coordinates.\n * Convenience for `map.getTileLayerById(id)?.setTileAt(tx, ty, tile)`.\n * @throws If the layer does not exist, coordinates are out of bounds,\n * or the tile reference is invalid.\n */\n public setTileAt(layerId: number, tx: number, ty: number, tile: ResolvedTile): void {\n const layer = this._layerById.get(layerId);\n if (!layer) throw new Error(`Layer ${layerId} not found in map \"${this.name}\".`);\n layer.setTileAt(tx, ty, tile);\n }\n\n /**\n * Clear a tile on a given layer at tile coordinates.\n * Convenience for `map.getTileLayerById(id)?.clearTileAt(tx, ty)`.\n * @throws If the layer does not exist or coordinates are out of bounds.\n */\n public clearTileAt(layerId: number, tx: number, ty: number): void {\n const layer = this._layerById.get(layerId);\n if (!layer) throw new Error(`Layer ${layerId} not found in map \"${this.name}\".`);\n layer.clearTileAt(tx, ty);\n }\n\n // ── Coordinate conversion (base layer) ────────────────────────────────\n\n /**\n * Convert a grid vertex to display pixels (the top diamond vertex for isometric cells)\n * in map-local space (ignoring layer offsets).\n */\n public tileToPixel(tx: number, ty: number): { x: number; y: number } {\n return this.projection.tileToPixel(tx, ty);\n }\n\n /**\n * Convert a display position in map-local space to the tile coordinate\n * that contains it. Uses `floor`. May return coordinates outside map bounds.\n */\n public pixelToTile(px: number, py: number): { tx: number; ty: number } {\n return this.projection.pixelToTile(px, py);\n }\n\n // ── Revision / lifecycle ──────────────────────────────────────────────\n\n /**\n * Monotonic map revision counter. Increments on structural changes only\n * (add/remove layer, add tileset). Cell mutations are tracked per-chunk\n * and per-layer; the renderer reads chunk-level revisions directly.\n * @advanced\n */\n public get revision(): number {\n return this._revision;\n }\n\n /** Whether the map has been destroyed. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n private _checkDestroyed(): void {\n if (this._destroyed) {\n throw new Error(`TileMap \"${this.name}\" has been destroyed.`);\n }\n }\n\n /**\n * Destroy the map and all owned layers and chunk storage.\n *\n * Is idempotent. Does NOT destroy tileset textures (Loader-owned) or\n * any SceneNodes (those do not exist yet in this slice).\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n for (const layer of this._layers) {\n layer.destroy();\n }\n this._layers.length = 0;\n this._layerById.clear();\n this._objectLayers.length = 0;\n this._imageLayers.length = 0;\n this._documentOrder.length = 0;\n this._tilesets.length = 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmGA,IAAa,UAAb,MAAqB;CACnB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,IAAW,aAAiC;EAC1C,OAAO,KAAK,UAAU,UAAa,KAAK,WAAW,SAAY,SAAY,KAAK,WAAW,UAAU,GAAG,GAAG,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC;CACtI;;CAEA,IAAW,cAAkC;EAC3C,OAAO,KAAK,UAAU,UAAa,KAAK,WAAW,SAAY,SAAY,KAAK,WAAW,UAAU,GAAG,GAAG,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC;CACtI;;CAEA,IAAW,UAAmB;EAC5B,OAAO,KAAK,UAAU,UAAa,KAAK,WAAW;CACrD;;CAGA,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEh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AGG;IACI,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS;IAI/E,uDAAuD;IACvD,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;;OAKG;IACa,YAAY,IAAI,IAAI;IAsEpC;;;;;;;;OAQG;IACa,OAAO,IAAI,IAAI;CAmBhC"}
1
+ {"version":3,"file":"TileMapBand.d.ts","sourceRoot":"","sources":["../../src/TileMapBand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC;;;;OAIG;IACa,IAAI,SAAM;IAE1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwC;IACpE,OAAO,CAAC,UAAU,CAAS;IAmB3B;;;;;OAKG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,aAAa,GAAG,cAAc,CAAC,CAErE;IAED;;;OAGG;IACI,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS,CAE9E;IAED,uDAAuD;IACvD,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;;OAKG;IACa,YAAY,IAAI,IAAI,CAiBnC;IAqDD;;;;;;;;OAQG;IACa,OAAO,IAAI,IAAI,CAkB9B;CACF"}
@@ -54,7 +54,12 @@ export declare class TileMapNode extends Container {
54
54
  * unchanged. Setting the current value is a no-op; an invalid value throws and
55
55
  * leaves the prior mode unchanged.
56
56
  *
57
- * @default PixelSnapMode.None
57
+ * Defaults to `Geometry` because a tile grid is made of quads that share
58
+ * their edges: left unsnapped, a boundary landing between two device pixels
59
+ * is sampled across both, so the seams blur and shimmer as the view moves.
60
+ * Set `None` to opt out.
61
+ *
62
+ * @default PixelSnapMode.Geometry
58
63
  * @stable
59
64
  */
60
65
  get pixelSnapMode(): PixelSnapMode;
@@ -1 +1 @@
1
- {"version":3,"file":"TileMapNode.d.ts","sourceRoot":"","sources":["../../src/TileMapNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6C;IACzE,OAAO,CAAC,cAAc,CAAqC;gBAExC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAa7D,yCAAyC;IACzC,IAAW,GAAG,IAAI,OAAO,CAExB;IAED;;;;;;;;;;;OAWG;IACH,IAAW,aAAa,IAAI,aAAa,CAExC;IAED,IAAW,aAAa,CAAC,IAAI,EAAE,aAAa,EAW3C;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,aAAa,GAAG,cAAc,CAAC,CAErE;IAED;;;OAGG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS;I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E,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS,CAE5E;IAED;;;;OAIG;IACI,aAAa,IAAI,IAAI,CAa3B;IAED;;;;OAIG;IACa,cAAc,IAAI,iBAAiB,CAiBlD;IAEe,OAAO,IAAI,IAAI,CAU9B;IAED,OAAO,CAAC,gBAAgB;CAYzB"}
@@ -33,7 +33,7 @@ var TileMapNode = class extends Container {
33
33
  _map;
34
34
  _cullChunks;
35
35
  _layerNodes = [];
36
- _pixelSnapMode = PixelSnapMode.None;
36
+ _pixelSnapMode = PixelSnapMode.Geometry;
37
37
  constructor(map, options) {
38
38
  super();
39
39
  this._map = map;
@@ -54,7 +54,12 @@ var TileMapNode = class extends Container {
54
54
  * unchanged. Setting the current value is a no-op; an invalid value throws and
55
55
  * leaves the prior mode unchanged.
56
56
  *
57
- * @default PixelSnapMode.None
57
+ * Defaults to `Geometry` because a tile grid is made of quads that share
58
+ * their edges: left unsnapped, a boundary landing between two device pixels
59
+ * is sampled across both, so the seams blur and shimmer as the view moves.
60
+ * Set `None` to opt out.
61
+ *
62
+ * @default PixelSnapMode.Geometry
58
63
  * @stable
59
64
  */
60
65
  get pixelSnapMode() {
@@ -101,7 +106,10 @@ var TileMapNode = class extends Container {
101
106
  getLocalBounds() {
102
107
  const bounds = this._localBounds;
103
108
  const { pixelHeight, pixelWidth } = this._map;
104
- if (pixelWidth !== void 0 && pixelHeight !== void 0) bounds.set(0, 0, pixelWidth, pixelHeight);
109
+ if (this._map.projection.orientation === "isometric") {
110
+ bounds.set(0, 0, 0, 0);
111
+ aggregateChildLocalBounds(this._layerNodes, bounds);
112
+ } else if (pixelWidth !== void 0 && pixelHeight !== void 0) bounds.set(this._map.projection.originX, this._map.projection.originY, pixelWidth, pixelHeight);
105
113
  else if (this._layerNodes.length > 0) aggregateChildLocalBounds(this._layerNodes, bounds);
106
114
  return bounds;
107
115
  }
@@ -114,7 +122,7 @@ var TileMapNode = class extends Container {
114
122
  _buildLayerNodes() {
115
123
  for (const layer of this._map.renderableLayers) {
116
124
  const node = layer instanceof ImageLayer ? new ImageLayerNode(layer) : new TileLayerNode(layer, { cullable: this._cullChunks });
117
- if (this._pixelSnapMode !== PixelSnapMode.None) node.pixelSnapMode = this._pixelSnapMode;
125
+ node.pixelSnapMode = this._pixelSnapMode;
118
126
  this._layerNodes.push(node);
119
127
  this.addChild(node);
120
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TileMapNode.js","names":[],"sources":["../../src/TileMapNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Container } from '@codexo/exojs';\nimport { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\nimport { ImageLayer } from './ImageLayer';\nimport { ImageLayerNode } from './ImageLayerNode';\nimport { aggregateChildLocalBounds } from './nodeBounds';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport { TileLayerNode } from './TileLayerNode';\nimport type { TileMap } from './TileMap';\n\n/**\n * Options for a {@link TileMapNode}.\n * @advanced\n */\nexport interface TileMapNodeOptions {\n /**\n * Whether the map's chunk nodes participate in per-chunk view culling.\n * Forwarded to every {@link TileLayerNode}. Defaults to `true`.\n */\n readonly cullable?: boolean;\n}\n\n/**\n * A convenience scene node that renders a whole {@link TileMap} as a\n * {@link Container} of one node per renderable layer - a {@link TileLayerNode}\n * per tile layer and an {@link ImageLayerNode} per image layer, interleaved\n * back-to-front by the map's combined document order\n * ({@link import('./TileMap').TileMap.renderableLayers}).\n *\n * `TileMapNode` owns **only** its layer nodes - never application actors. Use\n * it for the simple, non-interleaved case (no actors between layers); for\n * actor interleaving, place individual `TileLayerNode`s / `ImageLayerNode`s\n * into your own scene graph instead (see `TileMapView`).\n *\n * The node references - but never owns - the {@link TileMap}: destroying the\n * node frees its layer/chunk nodes and their cached GPU geometry, while the\n * `TileMap` data and Loader-owned textures survive (free them via\n * `TileMap.destroy()` / `Loader.destroy()` respectively).\n *\n * Layers added to or removed from the map after construction are reflected only\n * after {@link TileMapNode.refreshLayers}.\n *\n * @advanced\n */\nexport class TileMapNode extends Container {\n private readonly _map: TileMap;\n private readonly _cullChunks: boolean;\n private readonly _layerNodes: Array<TileLayerNode | ImageLayerNode> = [];\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.None;\n\n public constructor(map: TileMap, options?: TileMapNodeOptions) {\n super();\n\n this._map = map;\n this._cullChunks = options?.cullable ?? true;\n\n this._buildLayerNodes();\n\n if (!this._map.bounded) {\n this.cullable = false;\n }\n }\n\n /** The runtime map this node renders. */\n public get map(): TileMap {\n return this._map;\n }\n\n /**\n * Render-only pixel-snap mode applied to every layer (and forwarded to every\n * chunk node, current and rebuilt). Snaps tile chunk origins to the active\n * render target's device-pixel grid for crisp tiles; with integer tile pitch\n * the grid stays exact and adjacent chunks/layers cannot drift apart. Purely\n * visual - tile data, layer offsets, chunk revisions, and culling are\n * unchanged. Setting the current value is a no-op; an invalid value throws and\n * 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 for (const node of this._layerNodes) {\n node.pixelSnapMode = mode;\n }\n }\n\n /**\n * The layer render nodes - tile and image alike - in the map's combined\n * document order.\n */\n public get layerNodes(): ReadonlyArray<TileLayerNode | ImageLayerNode> {\n return this._layerNodes;\n }\n\n /**\n * Find the layer node rendering the named layer (tile or image; first match\n * in document order), or `undefined`.\n */\n public getLayerNode(name: string): TileLayerNode | ImageLayerNode | undefined {\n return this._layerNodes.find(node => node.layer.name === name);\n }\n\n /**\n * Rebuild the layer-node children from the map's current renderable layers.\n * Call after tile or image layers are structurally added to or removed from\n * the map.\n */\n public refreshLayers(): this {\n const previous = [...this._layerNodes];\n\n this.removeChildren();\n this._layerNodes.length = 0;\n\n for (const node of previous) {\n node.destroy();\n }\n\n this._buildLayerNodes();\n\n return this;\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 const bounds = this._localBounds;\n\n // Reading the pixel extents directly (rather than gating on `bounded`)\n // is what narrows them to numbers - `bounded` is a plain boolean getter.\n const { pixelHeight, pixelWidth } = this._map;\n\n if (pixelWidth !== undefined && pixelHeight !== undefined) {\n bounds.set(0, 0, pixelWidth, pixelHeight);\n } else if (this._layerNodes.length > 0) {\n aggregateChildLocalBounds(this._layerNodes, bounds);\n }\n\n return bounds;\n }\n\n public override destroy(): void {\n const layerNodes = [...this._layerNodes];\n\n this._layerNodes.length = 0;\n\n super.destroy();\n\n for (const node of layerNodes) {\n node.destroy();\n }\n }\n\n private _buildLayerNodes(): void {\n for (const layer of this._map.renderableLayers) {\n const node = layer instanceof ImageLayer ? new ImageLayerNode(layer) : new TileLayerNode(layer, { cullable: this._cullChunks });\n\n if (this._pixelSnapMode !== PixelSnapMode.None) {\n node.pixelSnapMode = this._pixelSnapMode;\n }\n\n this._layerNodes.push(node);\n this.addChild(node);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,cAAb,cAAiC,UAAU;CACzC,AAAiB;CACjB,AAAiB;CACjB,AAAiB,cAAqD,CAAC;CACvE,AAAQ,iBAAgC,cAAc;CAEtD,AAAO,YAAY,KAAc,SAA8B;EAC7D,MAAM;EAEN,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS,YAAY;EAExC,KAAK,iBAAiB;EAEtB,IAAI,CAAC,KAAK,KAAK,SACb,KAAK,WAAW;CAEpB;;CAGA,IAAW,MAAe;EACxB,OAAO,KAAK;CACd;;;;;;;;;;;;;CAcA,IAAW,gBAA+B;EACxC,OAAO,KAAK;CACd;CAEA,IAAW,cAAc,MAAqB;EAC5C,IAAI,SAAS,KAAK,gBAChB;EAGF,o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ectangle } from '@codexo/exojs';\nimport { Container } from '@codexo/exojs';\nimport { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\nimport { ImageLayer } from './ImageLayer';\nimport { ImageLayerNode } from './ImageLayerNode';\nimport { aggregateChildLocalBounds } from './nodeBounds';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport { TileLayerNode } from './TileLayerNode';\nimport type { TileMap } from './TileMap';\n\n/**\n * Options for a {@link TileMapNode}.\n * @advanced\n */\nexport interface TileMapNodeOptions {\n /**\n * Whether the map's chunk nodes participate in per-chunk view culling.\n * Forwarded to every {@link TileLayerNode}. Defaults to `true`.\n */\n readonly cullable?: boolean;\n}\n\n/**\n * A convenience scene node that renders a whole {@link TileMap} as a\n * {@link Container} of one node per renderable layer - a {@link TileLayerNode}\n * per tile layer and an {@link ImageLayerNode} per image layer, interleaved\n * back-to-front by the map's combined document order\n * ({@link import('./TileMap').TileMap.renderableLayers}).\n *\n * `TileMapNode` owns **only** its layer nodes - never application actors. Use\n * it for the simple, non-interleaved case (no actors between layers); for\n * actor interleaving, place individual `TileLayerNode`s / `ImageLayerNode`s\n * into your own scene graph instead (see `TileMapView`).\n *\n * The node references - but never owns - the {@link TileMap}: destroying the\n * node frees its layer/chunk nodes and their cached GPU geometry, while the\n * `TileMap` data and Loader-owned textures survive (free them via\n * `TileMap.destroy()` / `Loader.destroy()` respectively).\n *\n * Layers added to or removed from the map after construction are reflected only\n * after {@link TileMapNode.refreshLayers}.\n *\n * @advanced\n */\nexport class TileMapNode extends Container {\n private readonly _map: TileMap;\n private readonly _cullChunks: boolean;\n private readonly _layerNodes: Array<TileLayerNode | ImageLayerNode> = [];\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.Geometry;\n\n public constructor(map: TileMap, options?: TileMapNodeOptions) {\n super();\n\n this._map = map;\n this._cullChunks = options?.cullable ?? true;\n\n this._buildLayerNodes();\n\n if (!this._map.bounded) {\n this.cullable = false;\n }\n }\n\n /** The runtime map this node renders. */\n public get map(): TileMap {\n return this._map;\n }\n\n /**\n * Render-only pixel-snap mode applied to every layer (and forwarded to every\n * chunk node, current and rebuilt). Snaps tile chunk origins to the active\n * render target's device-pixel grid for crisp tiles; with integer tile pitch\n * the grid stays exact and adjacent chunks/layers cannot drift apart. Purely\n * visual - tile data, layer offsets, chunk revisions, and culling are\n * unchanged. Setting the current value is a no-op; an invalid value throws and\n * leaves the prior mode unchanged.\n *\n * Defaults to `Geometry` because a tile grid is made of quads that share\n * their edges: left unsnapped, a boundary landing between two device pixels\n * is sampled across both, so the seams blur and shimmer as the view moves.\n * 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 for (const node of this._layerNodes) {\n node.pixelSnapMode = mode;\n }\n }\n\n /**\n * The layer render nodes - tile and image alike - in the map's combined\n * document order.\n */\n public get layerNodes(): ReadonlyArray<TileLayerNode | ImageLayerNode> {\n return this._layerNodes;\n }\n\n /**\n * Find the layer node rendering the named layer (tile or image; first match\n * in document order), or `undefined`.\n */\n public getLayerNode(name: string): TileLayerNode | ImageLayerNode | undefined {\n return this._layerNodes.find(node => node.layer.name === name);\n }\n\n /**\n * Rebuild the layer-node children from the map's current renderable layers.\n * Call after tile or image layers are structurally added to or removed from\n * the map.\n */\n public refreshLayers(): this {\n const previous = [...this._layerNodes];\n\n this.removeChildren();\n this._layerNodes.length = 0;\n\n for (const node of previous) {\n node.destroy();\n }\n\n this._buildLayerNodes();\n\n return this;\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 const bounds = this._localBounds;\n\n // Reading the pixel extents directly (rather than gating on `bounded`)\n // is what narrows them to numbers - `bounded` is a plain boolean getter.\n const { pixelHeight, pixelWidth } = this._map;\n\n if (this._map.projection.orientation === 'isometric') {\n bounds.set(0, 0, 0, 0);\n aggregateChildLocalBounds(this._layerNodes, bounds);\n } else if (pixelWidth !== undefined && pixelHeight !== undefined) {\n bounds.set(this._map.projection.originX, this._map.projection.originY, pixelWidth, pixelHeight);\n } else if (this._layerNodes.length > 0) {\n aggregateChildLocalBounds(this._layerNodes, bounds);\n }\n\n return bounds;\n }\n\n public override destroy(): void {\n const layerNodes = [...this._layerNodes];\n\n this._layerNodes.length = 0;\n\n super.destroy();\n\n for (const node of layerNodes) {\n node.destroy();\n }\n }\n\n private _buildLayerNodes(): void {\n for (const layer of this._map.renderableLayers) {\n const node = layer instanceof ImageLayer ? new ImageLayerNode(layer) : new TileLayerNode(layer, { cullable: this._cullChunks });\n\n // Unconditional: a node built after the map was set to `None` has to\n // inherit that too, not just a non-default mode.\n node.pixelSnapMode = this._pixelSnapMode;\n\n this._layerNodes.push(node);\n this.addChild(node);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,cAAb,cAAiC,UAAU;CACzC,AAAiB;CACjB,AAAiB;CACjB,AAAiB,cAAqD,CAAC;CACvE,AAAQ,iBAAgC,cAAc;CAEtD,AAAO,YAAY,KAAc,SAA8B;EAC7D,MAAM;EAEN,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS,YAAY;EAExC,KAAK,iBAAiB;EAEtB,IAAI,CAAC,KAAK,KAAK,SACb,KAAK,WAAW;CAEpB;;CAGA,IAAW,MAAe;EACxB,OAAO,KAAK;CACd;;;;;;;;;;;;;;;;;;CAmBA,IAAW,gBAA+B;EACxC,OAAO,KAAK;CACd;CAEA,IAAW,cAAc,MAAqB;EAC5C,IAAI,SAAS,KAAK,gBAChB;EAGF,oBAAoB,IAAI;EACxB,KAAK,iBAAiB;EAEtB,KAAK,MAAM,QAAQ,KAAK,aACtB,KAAK,gBA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
140
  * current value is a no-op; an invalid value throws and leaves the prior mode
141
141
  * unchanged.
142
142
  *
143
- * @default PixelSnapMode.None
143
+ * Defaults to `Geometry` because a tile grid is made of quads that share
144
+ * their edges: left unsnapped, a boundary landing between two device pixels
145
+ * is sampled across both, so the seams blur and shimmer as the view moves.
146
+ * Set `None` to opt out.
147
+ *
148
+ * @default PixelSnapMode.Geometry
144
149
  * @stable
145
150
  */
146
151
  get pixelSnapMode(): PixelSnapMode;
@@ -1 +1 @@
1
- {"version":3,"file":"TileMapView.d.ts","sourceRoot":"","sources":["../../src/TileMapView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG,SAAS,iBAAiB,EAAE,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACjE;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IAEpC,6DAA6D;IAC7D,OAAO,CAAC,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,OAAO,CAAC,iBAAiB;CAc1B"}
@@ -71,7 +71,7 @@ var TileMapView = class {
71
71
  /** Image layer id → its canonical image layer node. */
72
72
  _imageLayerNodeById = /* @__PURE__ */ new Map();
73
73
  _destroyed = false;
74
- _pixelSnapMode = PixelSnapMode.None;
74
+ _pixelSnapMode = PixelSnapMode.Geometry;
75
75
  /**
76
76
  * @param map The runtime map to compose. Referenced, never owned.
77
77
  * @param options Band definitions and culling.
@@ -120,7 +120,12 @@ var TileMapView = class {
120
120
  * current value is a no-op; an invalid value throws and leaves the prior mode
121
121
  * unchanged.
122
122
  *
123
- * @default PixelSnapMode.None
123
+ * Defaults to `Geometry` because a tile grid is made of quads that share
124
+ * their edges: left unsnapped, a boundary landing between two device pixels
125
+ * is sampled across both, so the seams blur and shimmer as the view moves.
126
+ * Set `None` to opt out.
127
+ *
128
+ * @default PixelSnapMode.Geometry
124
129
  * @stable
125
130
  */
126
131
  get pixelSnapMode() {
@@ -223,7 +228,7 @@ var TileMapView = class {
223
228
  let node = this._layerNodeById.get(layer.id);
224
229
  if (!node) {
225
230
  node = new TileLayerNode(layer, { cullable: this._cullable });
226
- if (this._pixelSnapMode !== PixelSnapMode.None) node.pixelSnapMode = this._pixelSnapMode;
231
+ node.pixelSnapMode = this._pixelSnapMode;
227
232
  this._layerNodeById.set(layer.id, node);
228
233
  this._assignNewNode(node, layer);
229
234
  }
@@ -236,7 +241,7 @@ var TileMapView = class {
236
241
  let node = this._imageLayerNodes.find((candidate) => candidate.layer === imageLayer);
237
242
  if (!node) {
238
243
  node = new ImageLayerNode(imageLayer);
239
- if (this._pixelSnapMode !== PixelSnapMode.None) node.pixelSnapMode = this._pixelSnapMode;
244
+ node.pixelSnapMode = this._pixelSnapMode;
240
245
  this._imageLayerNodeById.set(imageLayer.id, node);
241
246
  this._assignNewNode(node, imageLayer);
242
247
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TileMapView.js","names":[],"sources":["../../src/TileMapView.ts"],"sourcesContent":["import { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\nimport { ImageLayer } from './ImageLayer';\nimport { ImageLayerNode } from './ImageLayerNode';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport type { TileLayer } from './TileLayer';\nimport { TileLayerNode } from './TileLayerNode';\nimport type { TileMap } from './TileMap';\nimport { TileMapBand } from './TileMapBand';\n\n/**\n * A layer selector inside a {@link TileMapBandDefinition}: either a stable\n * layer **id** (`number`) or a **unique** layer **name** (`string`). Selectors\n * resolve across the map's tile **and** image layers. Names that are shared by\n * more than one layer (of either kind) are rejected as ambiguous - reference\n * such layers by id. An id shared by a tile layer and an image layer (possible\n * only in fallback-ordered maps, which never validated cross-kind uniqueness)\n * is equally ambiguous - reference such layers by a unique name.\n * @advanced\n */\nexport type TileLayerSelector = number | string;\n\n/**\n * The layers composing one band, by id or unique name, in any order. Tile and\n * image layers may be freely mixed. Rendering order always follows the map's\n * combined document order ({@link import('./TileMap').TileMap.renderableLayers})\n * regardless of the order listed here - a definition *selects* layers, it never\n * reorders them. The band's name is the key it is registered under in\n * {@link TileMapViewOptions.bands}.\n * @advanced\n */\nexport type TileMapBandDefinition = readonly TileLayerSelector[];\n\n/**\n * Options for a {@link TileMapView}.\n * @advanced\n */\nexport interface TileMapViewOptions {\n /**\n * Named bands, keyed by band name (keys are unique, so duplicate band names\n * cannot occur). Each value lists the layers that compose the band - tile\n * and image layers alike. Layers not listed in any band remain reachable\n * through {@link TileMapView.getLayerNodeById} and friends and are owned\n * directly by the view (no implicit fallback band). The definition is copied\n * and frozen; mutating the caller's object afterwards does not change band\n * assignments.\n *\n * @throws (at construction) on an unknown layer id, an unknown or ambiguous\n * layer name, a cross-kind ambiguous layer id, a layer listed twice within\n * one band, or a layer assigned to more than one band.\n */\n readonly bands?: Readonly<Record<string, TileMapBandDefinition>>;\n /**\n * Whether the generated {@link TileLayerNode}s' chunks participate in\n * per-chunk view culling. Forwarded to every layer node. Default `true`.\n */\n readonly cullable?: boolean;\n}\n\ninterface ResolvedBandDef {\n readonly name: string;\n readonly selectors: TileMapBandDefinition;\n}\n\n/**\n * Groups a {@link TileMap}'s layers into independently placeable scene nodes so\n * application actors can be interleaved **between** tile layers.\n *\n * A view produces exactly one canonical {@link TileLayerNode} per map layer\n * (stable identity, map document order) and, optionally, named {@link TileMapBand}s\n * grouping subsets of those nodes. The application parents the bands / layer\n * nodes wherever it wants - typically as siblings of its own actor containers:\n *\n * ```ts\n * const view = map.createView({ bands: { ground: ['background', 'ground'], roof: ['roofs'] } });\n * worldRoot.addChild(view.band('ground'), actors, view.band('roof'));\n * // or without bands:\n * worldRoot.addChild(view.getLayerNodeById(groundId)!, actors, view.getLayerNodeById(roofId)!);\n * ```\n *\n * **Actors are application-owned siblings.** A `TileMapView` never adopts or\n * destroys actors. The view is a helper, not a scene node - it does not own the\n * world container, the {@link TileMap}, the {@link TileLayer}s, or tileset\n * textures.\n *\n * **Ownership:** the view owns its generated layer nodes and bands. A layer\n * assigned to a band is owned by that band; an unbanded layer is owned by the\n * view directly. {@link TileMapView.destroy} destroys every band and layer node\n * (detaching them from their application parents) but leaves actors, the map,\n * its layers, and Loader-owned textures untouched. There is no map-replacement\n * mutation API: to swap maps, destroy the old view, construct a new one, and\n * re-parent its bands - the actor tree is never involved.\n *\n * **Image layers.** A view also produces exactly one canonical\n * {@link ImageLayerNode} per {@link TileMap.imageLayers} entry (stable identity,\n * map document order), reachable through {@link imageLayerNodes},\n * {@link getImageLayerNodeById}, and {@link getImageLayerNodeByName}. Image\n * layers are selectable in {@link TileMapViewOptions.bands} exactly like tile\n * layers: a band member list may mix both kinds, and the band stacks its\n * members by the map's combined document order\n * ({@link import('./TileMap').TileMap.renderableLayers}). A banded image node\n * is owned by its band; an unbanded one is owned by the view directly, and the\n * application parents it wherever the image belongs in draw order - the same\n * way actors are interleaved.\n *\n * @advanced\n */\nexport class TileMapView {\n private readonly _map: TileMap;\n private readonly _cullable: boolean;\n\n /** All canonical tile-layer nodes, in map document order. */\n private readonly _layerNodes: TileLayerNode[] = [];\n /** Tile layer id → its canonical layer node. */\n private readonly _layerNodeById = new Map<number, TileLayerNode>();\n\n /** Bands in definition (insertion) order. */\n private readonly _bands: TileMapBand[] = [];\n /** Band name → band. */\n private readonly _bandByName = new Map<string, TileMapBand>();\n /** Original band definitions (frozen) for re-resolution on refresh. */\n private readonly _bandDefs: ResolvedBandDef[] = [];\n /** Layer node → its owning band (absent = view-owned / unbanded). */\n private readonly _nodeBand = new Map<TileLayerNode | ImageLayerNode, TileMapBand>();\n /** Unbanded tile-layer nodes owned directly by the view, in map document order. */\n private readonly _directLayerNodes: TileLayerNode[] = [];\n\n /** All canonical image layer nodes, in map document order. */\n private readonly _imageLayerNodes: ImageLayerNode[] = [];\n /** Image layer id → its canonical image layer node. */\n private readonly _imageLayerNodeById = new Map<number, ImageLayerNode>();\n\n private _destroyed = false;\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.None;\n\n /**\n * @param map The runtime map to compose. Referenced, never owned.\n * @param options Band definitions and culling.\n * @throws When a band definition references an unknown/ambiguous layer or\n * assigns a layer twice / to multiple bands.\n */\n public constructor(map: TileMap, options?: TileMapViewOptions) {\n this._map = map;\n this._cullable = options?.cullable ?? true;\n\n for (const layer of map.layers) {\n const node = new TileLayerNode(layer, { cullable: this._cullable });\n\n this._layerNodes.push(node);\n this._layerNodeById.set(layer.id, node);\n }\n\n for (const imageLayer of map.imageLayers) {\n const imageNode = new ImageLayerNode(imageLayer);\n\n this._imageLayerNodes.push(imageNode);\n this._imageLayerNodeById.set(imageLayer.id, imageNode);\n }\n\n if (options?.bands) {\n for (const [name, selectors] of Object.entries(options.bands)) {\n this._defineBand(name, selectors);\n }\n }\n\n for (const node of this._layerNodes) {\n if (!this._nodeBand.has(node)) {\n this._directLayerNodes.push(node);\n }\n }\n }\n\n /** The runtime map this view composes. Referenced, never owned. */\n public get map(): TileMap {\n return this._map;\n }\n\n /** All canonical tile-layer nodes, one per map tile layer, in map document order. */\n public get layers(): readonly TileLayerNode[] {\n return this._layerNodes;\n }\n\n /** The bands, in definition (insertion) order. */\n public get bands(): readonly TileMapBand[] {\n return this._bands;\n }\n\n /** Whether this view has been destroyed. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n /**\n * Render-only pixel-snap mode applied to every layer node this view owns (and\n * forwarded to every chunk drawable, current and rebuilt by\n * {@link refreshLayers}). Snaps tile chunk origins to the active render\n * target's device-pixel grid for crisp tiles; with integer tile pitch the grid\n * stays exact and adjacent chunks cannot drift apart. Purely visual - tile\n * data, layer offsets, chunk revisions, and culling are unchanged. Setting the\n * current value is a no-op; an invalid value throws and leaves the prior mode\n * 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 for (const node of this._layerNodes) {\n node.pixelSnapMode = mode;\n }\n\n for (const node of this._imageLayerNodes) {\n node.pixelSnapMode = mode;\n }\n }\n\n /**\n * The canonical layer node for the **tile** layer with the given **id**, or\n * `undefined`. Tile ids are authoritative and unique - this is the\n * unambiguous lookup. The returned node may be reparented into the caller's\n * own containers; the view still tracks it for refresh and destruction.\n */\n public getLayerNodeById(id: number): TileLayerNode | undefined {\n return this._layerNodeById.get(id);\n }\n\n /**\n * Every canonical tile-layer node whose layer has the given **name**, in map\n * document order. Layer names are not guaranteed unique, so this returns an\n * array (empty when no layer matches). Prefer {@link getLayerNodeById} when\n * you have the id.\n */\n public getLayerNodesByName(name: string): readonly TileLayerNode[] {\n return this._layerNodes.filter(node => node.layer.name === name);\n }\n\n /** All canonical image layer nodes, one per map image layer, in map document order. */\n public get imageLayerNodes(): readonly ImageLayerNode[] {\n return this._imageLayerNodes;\n }\n\n /**\n * The canonical image layer node for the image layer with the given **id**,\n * or `undefined`. Ids are authoritative and unique - this is the unambiguous\n * lookup. The returned node may be reparented into the caller's own\n * containers; the view still tracks it for refresh and destruction.\n */\n public getImageLayerNodeById(id: number): ImageLayerNode | undefined {\n return this._imageLayerNodeById.get(id);\n }\n\n /**\n * The canonical image layer node for the image layer with the given\n * **name**, or `undefined` if no image layer has that name. Prefer\n * {@link getImageLayerNodeById} when you have the id.\n * @throws If more than one image layer shares that name (reference such\n * layers by id instead).\n */\n public getImageLayerNodeByName(name: string): ImageLayerNode | undefined {\n const matches = this._map.imageLayers.filter(layer => layer.name === name);\n\n if (matches.length === 0) {\n return undefined;\n }\n\n if (matches.length > 1) {\n throw new Error(`TileMapView image layer name \"${name}\" is ambiguous ` + `(${matches.length} image layers share it); reference it by id instead.`);\n }\n\n return this._imageLayerNodeById.get(matches[0]!.id);\n }\n\n /**\n * The band registered under `name`.\n * @throws If no band with that name was defined.\n */\n public band(name: string): TileMapBand {\n const band = this._bandByName.get(name);\n\n if (!band) {\n throw new Error(\n `TileMapView has no band named \"${name}\". Defined bands: ${this._bands.length > 0 ? this._bands.map(b => `\"${b.name}\"`).join(', ') : '(none)'}.`,\n );\n }\n\n return band;\n }\n\n /** Whether a band with the given name was defined. */\n public hasBand(name: string): boolean {\n return this._bandByName.has(name);\n }\n\n /**\n * Rebuild the view after **structural** map changes (tile or image layers\n * added to or removed from the map). Ordinary tile edits and chunk\n * creation/removal do NOT need this - those are handled by chunk revisions\n * and {@link TileLayerNode.refresh} respectively.\n *\n * - Removed layers (tile or image): their generated node is detached and\n * destroyed.\n * - Unchanged layers: keep their existing node (stable identity).\n * - Added layers (tile or image): a new node is created and assigned to the\n * first band whose definition selects it (by a currently-unambiguous id or\n * name), otherwise owned directly by the view.\n * - Every band's children are re-ordered to the map's combined document\n * order ({@link import('./TileMap').TileMap.renderableLayers}).\n *\n * Application actors are never touched, and bands keep their placement in the\n * application scene graph.\n *\n * @throws If the view has been destroyed.\n */\n public refreshLayers(): this {\n if (this._destroyed) {\n throw new Error('Cannot refresh a destroyed TileMapView.');\n }\n\n const currentLayers = this._map.layers;\n const currentIds = new Set<number>();\n\n for (const layer of currentLayers) {\n currentIds.add(layer.id);\n }\n\n // 1. Remove nodes whose layer no longer exists.\n for (const node of [...this._layerNodes]) {\n if (!currentIds.has(node.layer.id)) {\n this._removeTileNode(node);\n }\n }\n\n const currentImageLayers = new Set(this._map.imageLayers);\n\n for (const node of [...this._imageLayerNodes]) {\n if (!currentImageLayers.has(node.layer)) {\n this._removeImageNode(node);\n }\n }\n\n // 2. Re-derive the doc-ordered node lists, creating + assigning new nodes.\n const newOrder: TileLayerNode[] = [];\n\n for (const layer of currentLayers) {\n let node = this._layerNodeById.get(layer.id);\n\n if (!node) {\n node = new TileLayerNode(layer, { cullable: this._cullable });\n\n if (this._pixelSnapMode !== PixelSnapMode.None) {\n node.pixelSnapMode = this._pixelSnapMode;\n }\n\n this._layerNodeById.set(layer.id, node);\n this._assignNewNode(node, layer);\n }\n\n newOrder.push(node);\n }\n\n this._layerNodes.length = 0;\n this._layerNodes.push(...newOrder);\n\n const newImageOrder: ImageLayerNode[] = [];\n\n for (const imageLayer of this._map.imageLayers) {\n let node = this._imageLayerNodes.find(candidate => candidate.layer === imageLayer);\n\n if (!node) {\n node = new ImageLayerNode(imageLayer);\n\n if (this._pixelSnapMode !== PixelSnapMode.None) {\n node.pixelSnapMode = this._pixelSnapMode;\n }\n\n this._imageLayerNodeById.set(imageLayer.id, node);\n this._assignNewNode(node, imageLayer);\n }\n\n newImageOrder.push(node);\n }\n\n this._imageLayerNodes.length = 0;\n this._imageLayerNodes.push(...newImageOrder);\n\n // 3. Re-order each band's children to the combined document order. Keyed\n // by layer instance: fallback-ordered maps may share an id across kinds.\n const documentIndex = new Map<TileLayer | ImageLayer, number>();\n\n for (const [index, layer] of this._map.renderableLayers.entries()) {\n documentIndex.set(layer, index);\n }\n\n for (const band of this._bands) {\n band._reorder(documentIndex);\n }\n\n // 4. Rebuild the unbanded set in doc order.\n this._directLayerNodes.length = 0;\n\n for (const node of newOrder) {\n if (!this._nodeBand.has(node)) {\n this._directLayerNodes.push(node);\n }\n }\n\n return this;\n }\n\n /**\n * Destroy the view: every band, generated tile-layer node, and generated\n * {@link ImageLayerNode} is destroyed (and detached from its application\n * parent), freeing cached chunk geometry. Banded nodes are destroyed by\n * their band; unbanded ones by the view directly. Idempotent. Application\n * actors, sibling content, the {@link TileMap}, its {@link TileLayer}s and\n * image layers, and Loader-owned textures all survive.\n */\n public destroy(): void {\n if (this._destroyed) {\n return;\n }\n\n this._destroyed = true;\n\n for (const band of this._bands) {\n band.destroy();\n }\n\n for (const node of this._directLayerNodes) {\n node.parent?.removeChild(node);\n node.destroy();\n }\n\n for (const node of this._imageLayerNodes) {\n if (this._nodeBand.has(node)) {\n continue; // Owned and already destroyed by its band.\n }\n\n node.parent?.removeChild(node);\n node.destroy();\n }\n\n this._bands.length = 0;\n this._bandByName.clear();\n this._bandDefs.length = 0;\n this._directLayerNodes.length = 0;\n this._layerNodes.length = 0;\n this._layerNodeById.clear();\n this._nodeBand.clear();\n this._imageLayerNodes.length = 0;\n this._imageLayerNodeById.clear();\n }\n\n // ── Internals ──────────────────────────────────────────────────────────\n\n /** Resolve one band definition into a {@link TileMapBand} and record it. */\n private _defineBand(name: string, selectors: TileMapBandDefinition): void {\n const members = new Set<TileLayer | ImageLayer>();\n\n for (const selector of selectors) {\n const layer = this._resolveSelector(name, selector);\n\n if (members.has(layer)) {\n throw new Error(`TileMapView band \"${name}\" lists layer ${layer.id} more than once.`);\n }\n\n const existing = this._nodeFor(layer);\n\n if (existing && this._nodeBand.has(existing)) {\n throw new Error(`TileMapView layer ${layer.id} is assigned to multiple bands ` + `(\"${this._nodeBand.get(existing)!.name}\" and \"${name}\").`);\n }\n\n members.add(layer);\n }\n\n // Order members by combined document order (membership selects; doc order\n // renders - tile and image members interleave).\n const orderedNodes: Array<TileLayerNode | ImageLayerNode> = [];\n\n for (const layer of this._map.renderableLayers) {\n if (members.has(layer)) {\n orderedNodes.push(this._nodeFor(layer)!);\n }\n }\n\n const band = new TileMapBand(name, orderedNodes);\n\n for (const node of orderedNodes) {\n this._nodeBand.set(node, band);\n }\n\n this._bands.push(band);\n this._bandByName.set(name, band);\n this._bandDefs.push({ name, selectors: Object.freeze([...selectors]) });\n }\n\n /**\n * Resolve a single selector to a tile or image layer instance, throwing on\n * unknown/ambiguous. Instances (not ids) disambiguate fallback-ordered maps\n * in which a tile layer and an image layer share an id.\n */\n private _resolveSelector(bandName: string, selector: TileLayerSelector): TileLayer | ImageLayer {\n if (typeof selector === 'number') {\n const tileLayer = this._map.getTileLayerById(selector);\n const imageLayer = this._map.imageLayers.find(layer => layer.id === selector);\n\n if (tileLayer && imageLayer) {\n throw new Error(\n `TileMapView band \"${bandName}\": layer id ${selector} is ambiguous ` +\n `(a tile layer and an image layer share it); reference it by a unique name instead.`,\n );\n }\n\n const layer = tileLayer ?? imageLayer;\n\n if (!layer) {\n throw new Error(`TileMapView band \"${bandName}\": no layer with id ${selector} in map \"${this._map.name}\".`);\n }\n\n return layer;\n }\n\n const matches: Array<TileLayer | ImageLayer> = [\n ...this._map.layers.filter(layer => layer.name === selector),\n ...this._map.imageLayers.filter(layer => layer.name === selector),\n ];\n\n if (matches.length === 0) {\n throw new Error(`TileMapView band \"${bandName}\": no layer named \"${selector}\" in map \"${this._map.name}\".`);\n }\n\n if (matches.length > 1) {\n throw new Error(\n `TileMapView band \"${bandName}\": layer name \"${selector}\" is ambiguous ` + `(${matches.length} layers share it); reference it by id instead.`,\n );\n }\n\n return matches[0]!;\n }\n\n /** The canonical node for a tile or image layer instance, if one exists. */\n private _nodeFor(layer: TileLayer | ImageLayer): TileLayerNode | ImageLayerNode | undefined {\n if (layer instanceof ImageLayer) {\n // Instance scan rather than the id map: image ids are not validated\n // unique, and fallback maps may collide with tile ids anyway.\n return this._imageLayerNodes.find(node => node.layer === layer);\n }\n\n return this._layerNodeById.get(layer.id);\n }\n\n /** Assign a freshly created node to the first band that selects its layer. */\n private _assignNewNode(node: TileLayerNode | ImageLayerNode, layer: TileLayer | ImageLayer): void {\n for (const def of this._bandDefs) {\n if (this._definitionSelects(def, layer)) {\n const band = this._bandByName.get(def.name)!;\n\n band._adopt(node);\n this._nodeBand.set(node, band);\n\n return;\n }\n }\n }\n\n /**\n * Whether a band definition selects the given layer - only by a selector\n * that is currently unambiguous (a unique name, or an id not shared across\n * kinds), mirroring {@link _resolveSelector}'s construction-time rules.\n */\n private _definitionSelects(def: ResolvedBandDef, layer: TileLayer | ImageLayer): boolean {\n for (const selector of def.selectors) {\n if (typeof selector === 'number') {\n if (selector === layer.id && !this._isCrossKindId(selector)) {\n return true;\n }\n } else if (selector === layer.name) {\n const sameName =\n this._map.layers.filter(other => other.name === selector).length + this._map.imageLayers.filter(other => other.name === selector).length;\n\n if (sameName === 1) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /** Whether an id currently belongs to both a tile layer and an image layer. */\n private _isCrossKindId(id: number): boolean {\n return this._map.getTileLayerById(id) !== undefined && this._map.imageLayers.some(layer => layer.id === id);\n }\n\n /** Detach + destroy a tile node, dropping it from bands and registries. */\n private _removeTileNode(node: TileLayerNode): void {\n this._releaseFromOwner(node);\n\n node.parent?.removeChild(node);\n this._layerNodeById.delete(node.layer.id);\n\n const orderIndex = this._layerNodes.indexOf(node);\n\n if (orderIndex !== -1) {\n this._layerNodes.splice(orderIndex, 1);\n }\n\n node.destroy();\n }\n\n /** Detach + destroy an image node, dropping it from bands and registries. */\n private _removeImageNode(node: ImageLayerNode): void {\n this._releaseFromOwner(node);\n\n node.parent?.removeChild(node);\n\n if (this._imageLayerNodeById.get(node.layer.id) === node) {\n this._imageLayerNodeById.delete(node.layer.id);\n }\n\n const orderIndex = this._imageLayerNodes.indexOf(node);\n\n if (orderIndex !== -1) {\n this._imageLayerNodes.splice(orderIndex, 1);\n }\n\n node.destroy();\n }\n\n /** Release a node from its band, or from the view's direct-ownership list. */\n private _releaseFromOwner(node: TileLayerNode | ImageLayerNode): void {\n const band = this._nodeBand.get(node);\n\n if (band) {\n band._release(node);\n this._nodeBand.delete(node);\n } else if (node instanceof TileLayerNode) {\n const directIndex = this._directLayerNodes.indexOf(node);\n\n if (directIndex !== -1) {\n this._directLayerNodes.splice(directIndex, 1);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,IAAa,cAAb,MAAyB;CACvB,AAAiB;CACjB,AAAiB;;CAGjB,AAAiB,cAA+B,CAAC;;CAEjD,AAAiB,iCAAiB,IAAI,IAA2B;;CAGjE,AAAiB,SAAwB,CAAC;;CAE1C,AAAiB,8BAAc,IAAI,IAAyB;;CAE5D,AAAiB,YAA+B,CAAC;;CAEjD,AAAiB,4BAAY,IAAI,IAAiD;;CAElF,AAAiB,oBAAqC,CAAC;;CAGvD,AAAiB,mBAAqC,CAAC;;CAEvD,AAAiB,sCAAsB,IAAI,IAA4B;CAEvE,AAAQ,aAAa;CACrB,AAAQ,iBAAgC,cAAc;;;;;;;CAQtD,AAAO,YAAY,KAAc,SAA8B;EAC7D,KAAK,OAAO;EACZ,KAAK,YAAY,SAAS,YAAY;EAEtC,KAAK,MAAM,SAAS,IAAI,QAAQ;GAC9B,MAAM,OAAO,IAAI,cAAc,OAAO,EAAE,UAAU,KAAK,UAAU,CAAC;GAElE,KAAK,YAAY,KAAK,IAAI;GAC1B,KAAK,eAAe,IAAI,MAAM,IAAI,IAAI;EACxC;EAEA,KAAK,MAAM,cAAc,IAAI,aAAa;GACxC,MAAM,YAAY,IAAI,eAAe,UAAU;GAE/C,KAAK,iBAAiB,KAAK,SAAS;GACpC,KAAK,oBAAoB,IAAI,WAAW,IAAI,SAAS;EACvD;EAEA,IAAI,SAAS,OACX,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,QAAQ,KAAK,GAC1D,KAAK,YAAY,MAAM,SAAS;EAIpC,KAAK,MAAM,QAAQ,KAAK,aACtB,IAAI,CAAC,KAAK,UAAU,IAAI,IAAI,GAC1B,KAAK,kBA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,eAAe,IAAqB;EAC1C,OAAO,KAAK,KAAK,iBAAiB,EAAE,MAAM,UAAa,KAAK,KAAK,YAAY,MAAK,UAAS,MAAM,OAAO,EAAE;CAC5G;;CAGA,AAAQ,gBAAgB,MAA2B;EACjD,KAAK,kBAAkB,IAAI;EAE3B,KAAK,QAAQ,YAAY,IAAI;EAC7B,KAAK,eAAe,OAAO,KAAK,MAAM,EAAE;EAExC,MAAM,aAAa,KAAK,YAAY,QAAQ,IAAI;EAEhD,IAAI,eAAe,IACjB,KAAK,YAAY,OAAO,YAAY,CAAC;EAGvC,KAAK,QAAQ;CACf;;CAGA,AAAQ,iBAAiB,MAA4B;EACnD,KAAK,kBAAkB,IAAI;EAE3B,KAAK,QAAQ,YAAY,IAAI;EAE7B,IAAI,KAAK,oBAAoB,IAAI,KAAK,MAAM,EAAE,MAAM,MAClD,KAAK,oBAAoB,OAAO,KAAK,MAAM,EAAE;EAG/C,MAAM,aAAa,KAAK,iBAAiB,QAAQ,IAAI;EAErD,IAAI,eAAe,IACjB,KAAK,iBAAiB,OAAO,YAAY,CAAC;EAG5C,KAAK,QAAQ;CACf;;CAGA,AAAQ,kBAAkB,MAA4C;EACpE,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;EAEpC,IAAI,MAAM;GACR,KAAK,SAAS,IAAI;GAClB,KAAK,UAAU,OAAO,IAAI;EAC5B,OAAO,IAAI,gBAAgB,eAAe;GACxC,MAAM,cAAc,KAAK,kBAAkB,QAAQ,IAAI;GAEvD,IAAI,gBAAgB,IAClB,KAAK,kBAAkB,OAAO,aAAa,CAAC;EAEhD;CACF;AACF"}
1
+ {"version":3,"file":"TileMapView.js","names":[],"sources":["../../src/TileMapView.ts"],"sourcesContent":["import { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\nimport { ImageLayer } from './ImageLayer';\nimport { ImageLayerNode } from './ImageLayerNode';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport type { TileLayer } from './TileLayer';\nimport { TileLayerNode } from './TileLayerNode';\nimport type { TileMap } from './TileMap';\nimport { TileMapBand } from './TileMapBand';\n\n/**\n * A layer selector inside a {@link TileMapBandDefinition}: either a stable\n * layer **id** (`number`) or a **unique** layer **name** (`string`). Selectors\n * resolve across the map's tile **and** image layers. Names that are shared by\n * more than one layer (of either kind) are rejected as ambiguous - reference\n * such layers by id. An id shared by a tile layer and an image layer (possible\n * only in fallback-ordered maps, which never validated cross-kind uniqueness)\n * is equally ambiguous - reference such layers by a unique name.\n * @advanced\n */\nexport type TileLayerSelector = number | string;\n\n/**\n * The layers composing one band, by id or unique name, in any order. Tile and\n * image layers may be freely mixed. Rendering order always follows the map's\n * combined document order ({@link import('./TileMap').TileMap.renderableLayers})\n * regardless of the order listed here - a definition *selects* layers, it never\n * reorders them. The band's name is the key it is registered under in\n * {@link TileMapViewOptions.bands}.\n * @advanced\n */\nexport type TileMapBandDefinition = readonly TileLayerSelector[];\n\n/**\n * Options for a {@link TileMapView}.\n * @advanced\n */\nexport interface TileMapViewOptions {\n /**\n * Named bands, keyed by band name (keys are unique, so duplicate band names\n * cannot occur). Each value lists the layers that compose the band - tile\n * and image layers alike. Layers not listed in any band remain reachable\n * through {@link TileMapView.getLayerNodeById} and friends and are owned\n * directly by the view (no implicit fallback band). The definition is copied\n * and frozen; mutating the caller's object afterwards does not change band\n * assignments.\n *\n * @throws (at construction) on an unknown layer id, an unknown or ambiguous\n * layer name, a cross-kind ambiguous layer id, a layer listed twice within\n * one band, or a layer assigned to more than one band.\n */\n readonly bands?: Readonly<Record<string, TileMapBandDefinition>>;\n /**\n * Whether the generated {@link TileLayerNode}s' chunks participate in\n * per-chunk view culling. Forwarded to every layer node. Default `true`.\n */\n readonly cullable?: boolean;\n}\n\ninterface ResolvedBandDef {\n readonly name: string;\n readonly selectors: TileMapBandDefinition;\n}\n\n/**\n * Groups a {@link TileMap}'s layers into independently placeable scene nodes so\n * application actors can be interleaved **between** tile layers.\n *\n * A view produces exactly one canonical {@link TileLayerNode} per map layer\n * (stable identity, map document order) and, optionally, named {@link TileMapBand}s\n * grouping subsets of those nodes. The application parents the bands / layer\n * nodes wherever it wants - typically as siblings of its own actor containers:\n *\n * ```ts\n * const view = map.createView({ bands: { ground: ['background', 'ground'], roof: ['roofs'] } });\n * worldRoot.addChild(view.band('ground'), actors, view.band('roof'));\n * // or without bands:\n * worldRoot.addChild(view.getLayerNodeById(groundId)!, actors, view.getLayerNodeById(roofId)!);\n * ```\n *\n * **Actors are application-owned siblings.** A `TileMapView` never adopts or\n * destroys actors. The view is a helper, not a scene node - it does not own the\n * world container, the {@link TileMap}, the {@link TileLayer}s, or tileset\n * textures.\n *\n * **Ownership:** the view owns its generated layer nodes and bands. A layer\n * assigned to a band is owned by that band; an unbanded layer is owned by the\n * view directly. {@link TileMapView.destroy} destroys every band and layer node\n * (detaching them from their application parents) but leaves actors, the map,\n * its layers, and Loader-owned textures untouched. There is no map-replacement\n * mutation API: to swap maps, destroy the old view, construct a new one, and\n * re-parent its bands - the actor tree is never involved.\n *\n * **Image layers.** A view also produces exactly one canonical\n * {@link ImageLayerNode} per {@link TileMap.imageLayers} entry (stable identity,\n * map document order), reachable through {@link imageLayerNodes},\n * {@link getImageLayerNodeById}, and {@link getImageLayerNodeByName}. Image\n * layers are selectable in {@link TileMapViewOptions.bands} exactly like tile\n * layers: a band member list may mix both kinds, and the band stacks its\n * members by the map's combined document order\n * ({@link import('./TileMap').TileMap.renderableLayers}). A banded image node\n * is owned by its band; an unbanded one is owned by the view directly, and the\n * application parents it wherever the image belongs in draw order - the same\n * way actors are interleaved.\n *\n * @advanced\n */\nexport class TileMapView {\n private readonly _map: TileMap;\n private readonly _cullable: boolean;\n\n /** All canonical tile-layer nodes, in map document order. */\n private readonly _layerNodes: TileLayerNode[] = [];\n /** Tile layer id → its canonical layer node. */\n private readonly _layerNodeById = new Map<number, TileLayerNode>();\n\n /** Bands in definition (insertion) order. */\n private readonly _bands: TileMapBand[] = [];\n /** Band name → band. */\n private readonly _bandByName = new Map<string, TileMapBand>();\n /** Original band definitions (frozen) for re-resolution on refresh. */\n private readonly _bandDefs: ResolvedBandDef[] = [];\n /** Layer node → its owning band (absent = view-owned / unbanded). */\n private readonly _nodeBand = new Map<TileLayerNode | ImageLayerNode, TileMapBand>();\n /** Unbanded tile-layer nodes owned directly by the view, in map document order. */\n private readonly _directLayerNodes: TileLayerNode[] = [];\n\n /** All canonical image layer nodes, in map document order. */\n private readonly _imageLayerNodes: ImageLayerNode[] = [];\n /** Image layer id → its canonical image layer node. */\n private readonly _imageLayerNodeById = new Map<number, ImageLayerNode>();\n\n private _destroyed = false;\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.Geometry;\n\n /**\n * @param map The runtime map to compose. Referenced, never owned.\n * @param options Band definitions and culling.\n * @throws When a band definition references an unknown/ambiguous layer or\n * assigns a layer twice / to multiple bands.\n */\n public constructor(map: TileMap, options?: TileMapViewOptions) {\n this._map = map;\n this._cullable = options?.cullable ?? true;\n\n for (const layer of map.layers) {\n const node = new TileLayerNode(layer, { cullable: this._cullable });\n\n this._layerNodes.push(node);\n this._layerNodeById.set(layer.id, node);\n }\n\n for (const imageLayer of map.imageLayers) {\n const imageNode = new ImageLayerNode(imageLayer);\n\n this._imageLayerNodes.push(imageNode);\n this._imageLayerNodeById.set(imageLayer.id, imageNode);\n }\n\n if (options?.bands) {\n for (const [name, selectors] of Object.entries(options.bands)) {\n this._defineBand(name, selectors);\n }\n }\n\n for (const node of this._layerNodes) {\n if (!this._nodeBand.has(node)) {\n this._directLayerNodes.push(node);\n }\n }\n }\n\n /** The runtime map this view composes. Referenced, never owned. */\n public get map(): TileMap {\n return this._map;\n }\n\n /** All canonical tile-layer nodes, one per map tile layer, in map document order. */\n public get layers(): readonly TileLayerNode[] {\n return this._layerNodes;\n }\n\n /** The bands, in definition (insertion) order. */\n public get bands(): readonly TileMapBand[] {\n return this._bands;\n }\n\n /** Whether this view has been destroyed. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n /**\n * Render-only pixel-snap mode applied to every layer node this view owns (and\n * forwarded to every chunk drawable, current and rebuilt by\n * {@link refreshLayers}). Snaps tile chunk origins to the active render\n * target's device-pixel grid for crisp tiles; with integer tile pitch the grid\n * stays exact and adjacent chunks cannot drift apart. Purely visual - tile\n * data, layer offsets, chunk revisions, and culling are unchanged. Setting the\n * current value is a no-op; an invalid value throws and leaves the prior mode\n * unchanged.\n *\n * Defaults to `Geometry` because a tile grid is made of quads that share\n * their edges: left unsnapped, a boundary landing between two device pixels\n * is sampled across both, so the seams blur and shimmer as the view moves.\n * 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 for (const node of this._layerNodes) {\n node.pixelSnapMode = mode;\n }\n\n for (const node of this._imageLayerNodes) {\n node.pixelSnapMode = mode;\n }\n }\n\n /**\n * The canonical layer node for the **tile** layer with the given **id**, or\n * `undefined`. Tile ids are authoritative and unique - this is the\n * unambiguous lookup. The returned node may be reparented into the caller's\n * own containers; the view still tracks it for refresh and destruction.\n */\n public getLayerNodeById(id: number): TileLayerNode | undefined {\n return this._layerNodeById.get(id);\n }\n\n /**\n * Every canonical tile-layer node whose layer has the given **name**, in map\n * document order. Layer names are not guaranteed unique, so this returns an\n * array (empty when no layer matches). Prefer {@link getLayerNodeById} when\n * you have the id.\n */\n public getLayerNodesByName(name: string): readonly TileLayerNode[] {\n return this._layerNodes.filter(node => node.layer.name === name);\n }\n\n /** All canonical image layer nodes, one per map image layer, in map document order. */\n public get imageLayerNodes(): readonly ImageLayerNode[] {\n return this._imageLayerNodes;\n }\n\n /**\n * The canonical image layer node for the image layer with the given **id**,\n * or `undefined`. Ids are authoritative and unique - this is the unambiguous\n * lookup. The returned node may be reparented into the caller's own\n * containers; the view still tracks it for refresh and destruction.\n */\n public getImageLayerNodeById(id: number): ImageLayerNode | undefined {\n return this._imageLayerNodeById.get(id);\n }\n\n /**\n * The canonical image layer node for the image layer with the given\n * **name**, or `undefined` if no image layer has that name. Prefer\n * {@link getImageLayerNodeById} when you have the id.\n * @throws If more than one image layer shares that name (reference such\n * layers by id instead).\n */\n public getImageLayerNodeByName(name: string): ImageLayerNode | undefined {\n const matches = this._map.imageLayers.filter(layer => layer.name === name);\n\n if (matches.length === 0) {\n return undefined;\n }\n\n if (matches.length > 1) {\n throw new Error(`TileMapView image layer name \"${name}\" is ambiguous ` + `(${matches.length} image layers share it); reference it by id instead.`);\n }\n\n return this._imageLayerNodeById.get(matches[0]!.id);\n }\n\n /**\n * The band registered under `name`.\n * @throws If no band with that name was defined.\n */\n public band(name: string): TileMapBand {\n const band = this._bandByName.get(name);\n\n if (!band) {\n throw new Error(\n `TileMapView has no band named \"${name}\". Defined bands: ${this._bands.length > 0 ? this._bands.map(b => `\"${b.name}\"`).join(', ') : '(none)'}.`,\n );\n }\n\n return band;\n }\n\n /** Whether a band with the given name was defined. */\n public hasBand(name: string): boolean {\n return this._bandByName.has(name);\n }\n\n /**\n * Rebuild the view after **structural** map changes (tile or image layers\n * added to or removed from the map). Ordinary tile edits and chunk\n * creation/removal do NOT need this - those are handled by chunk revisions\n * and {@link TileLayerNode.refresh} respectively.\n *\n * - Removed layers (tile or image): their generated node is detached and\n * destroyed.\n * - Unchanged layers: keep their existing node (stable identity).\n * - Added layers (tile or image): a new node is created and assigned to the\n * first band whose definition selects it (by a currently-unambiguous id or\n * name), otherwise owned directly by the view.\n * - Every band's children are re-ordered to the map's combined document\n * order ({@link import('./TileMap').TileMap.renderableLayers}).\n *\n * Application actors are never touched, and bands keep their placement in the\n * application scene graph.\n *\n * @throws If the view has been destroyed.\n */\n public refreshLayers(): this {\n if (this._destroyed) {\n throw new Error('Cannot refresh a destroyed TileMapView.');\n }\n\n const currentLayers = this._map.layers;\n const currentIds = new Set<number>();\n\n for (const layer of currentLayers) {\n currentIds.add(layer.id);\n }\n\n // 1. Remove nodes whose layer no longer exists.\n for (const node of [...this._layerNodes]) {\n if (!currentIds.has(node.layer.id)) {\n this._removeTileNode(node);\n }\n }\n\n const currentImageLayers = new Set(this._map.imageLayers);\n\n for (const node of [...this._imageLayerNodes]) {\n if (!currentImageLayers.has(node.layer)) {\n this._removeImageNode(node);\n }\n }\n\n // 2. Re-derive the doc-ordered node lists, creating + assigning new nodes.\n const newOrder: TileLayerNode[] = [];\n\n for (const layer of currentLayers) {\n let node = this._layerNodeById.get(layer.id);\n\n if (!node) {\n node = new TileLayerNode(layer, { cullable: this._cullable });\n // Unconditional: a node built after the view was set to `None` has to\n // inherit that too, not just a non-default mode.\n node.pixelSnapMode = this._pixelSnapMode;\n\n this._layerNodeById.set(layer.id, node);\n this._assignNewNode(node, layer);\n }\n\n newOrder.push(node);\n }\n\n this._layerNodes.length = 0;\n this._layerNodes.push(...newOrder);\n\n const newImageOrder: ImageLayerNode[] = [];\n\n for (const imageLayer of this._map.imageLayers) {\n let node = this._imageLayerNodes.find(candidate => candidate.layer === imageLayer);\n\n if (!node) {\n node = new ImageLayerNode(imageLayer);\n // Unconditional: a node built after the view was set to `None` has to\n // inherit that too, not just a non-default mode.\n node.pixelSnapMode = this._pixelSnapMode;\n\n this._imageLayerNodeById.set(imageLayer.id, node);\n this._assignNewNode(node, imageLayer);\n }\n\n newImageOrder.push(node);\n }\n\n this._imageLayerNodes.length = 0;\n this._imageLayerNodes.push(...newImageOrder);\n\n // 3. Re-order each band's children to the combined document order. Keyed\n // by layer instance: fallback-ordered maps may share an id across kinds.\n const documentIndex = new Map<TileLayer | ImageLayer, number>();\n\n for (const [index, layer] of this._map.renderableLayers.entries()) {\n documentIndex.set(layer, index);\n }\n\n for (const band of this._bands) {\n band._reorder(documentIndex);\n }\n\n // 4. Rebuild the unbanded set in doc order.\n this._directLayerNodes.length = 0;\n\n for (const node of newOrder) {\n if (!this._nodeBand.has(node)) {\n this._directLayerNodes.push(node);\n }\n }\n\n return this;\n }\n\n /**\n * Destroy the view: every band, generated tile-layer node, and generated\n * {@link ImageLayerNode} is destroyed (and detached from its application\n * parent), freeing cached chunk geometry. Banded nodes are destroyed by\n * their band; unbanded ones by the view directly. Idempotent. Application\n * actors, sibling content, the {@link TileMap}, its {@link TileLayer}s and\n * image layers, and Loader-owned textures all survive.\n */\n public destroy(): void {\n if (this._destroyed) {\n return;\n }\n\n this._destroyed = true;\n\n for (const band of this._bands) {\n band.destroy();\n }\n\n for (const node of this._directLayerNodes) {\n node.parent?.removeChild(node);\n node.destroy();\n }\n\n for (const node of this._imageLayerNodes) {\n if (this._nodeBand.has(node)) {\n continue; // Owned and already destroyed by its band.\n }\n\n node.parent?.removeChild(node);\n node.destroy();\n }\n\n this._bands.length = 0;\n this._bandByName.clear();\n this._bandDefs.length = 0;\n this._directLayerNodes.length = 0;\n this._layerNodes.length = 0;\n this._layerNodeById.clear();\n this._nodeBand.clear();\n this._imageLayerNodes.length = 0;\n this._imageLayerNodeById.clear();\n }\n\n // ── Internals ──────────────────────────────────────────────────────────\n\n /** Resolve one band definition into a {@link TileMapBand} and record it. */\n private _defineBand(name: string, selectors: TileMapBandDefinition): void {\n const members = new Set<TileLayer | ImageLayer>();\n\n for (const selector of selectors) {\n const layer = this._resolveSelector(name, selector);\n\n if (members.has(layer)) {\n throw new Error(`TileMapView band \"${name}\" lists layer ${layer.id} more than once.`);\n }\n\n const existing = this._nodeFor(layer);\n\n if (existing && this._nodeBand.has(existing)) {\n throw new Error(`TileMapView layer ${layer.id} is assigned to multiple bands ` + `(\"${this._nodeBand.get(existing)!.name}\" and \"${name}\").`);\n }\n\n members.add(layer);\n }\n\n // Order members by combined document order (membership selects; doc order\n // renders - tile and image members interleave).\n const orderedNodes: Array<TileLayerNode | ImageLayerNode> = [];\n\n for (const layer of this._map.renderableLayers) {\n if (members.has(layer)) {\n orderedNodes.push(this._nodeFor(layer)!);\n }\n }\n\n const band = new TileMapBand(name, orderedNodes);\n\n for (const node of orderedNodes) {\n this._nodeBand.set(node, band);\n }\n\n this._bands.push(band);\n this._bandByName.set(name, band);\n this._bandDefs.push({ name, selectors: Object.freeze([...selectors]) });\n }\n\n /**\n * Resolve a single selector to a tile or image layer instance, throwing on\n * unknown/ambiguous. Instances (not ids) disambiguate fallback-ordered maps\n * in which a tile layer and an image layer share an id.\n */\n private _resolveSelector(bandName: string, selector: TileLayerSelector): TileLayer | ImageLayer {\n if (typeof selector === 'number') {\n const tileLayer = this._map.getTileLayerById(selector);\n const imageLayer = this._map.imageLayers.find(layer => layer.id === selector);\n\n if (tileLayer && imageLayer) {\n throw new Error(\n `TileMapView band \"${bandName}\": layer id ${selector} is ambiguous ` +\n `(a tile layer and an image layer share it); reference it by a unique name instead.`,\n );\n }\n\n const layer = tileLayer ?? imageLayer;\n\n if (!layer) {\n throw new Error(`TileMapView band \"${bandName}\": no layer with id ${selector} in map \"${this._map.name}\".`);\n }\n\n return layer;\n }\n\n const matches: Array<TileLayer | ImageLayer> = [\n ...this._map.layers.filter(layer => layer.name === selector),\n ...this._map.imageLayers.filter(layer => layer.name === selector),\n ];\n\n if (matches.length === 0) {\n throw new Error(`TileMapView band \"${bandName}\": no layer named \"${selector}\" in map \"${this._map.name}\".`);\n }\n\n if (matches.length > 1) {\n throw new Error(\n `TileMapView band \"${bandName}\": layer name \"${selector}\" is ambiguous ` + `(${matches.length} layers share it); reference it by id instead.`,\n );\n }\n\n return matches[0]!;\n }\n\n /** The canonical node for a tile or image layer instance, if one exists. */\n private _nodeFor(layer: TileLayer | ImageLayer): TileLayerNode | ImageLayerNode | undefined {\n if (layer instanceof ImageLayer) {\n // Instance scan rather than the id map: image ids are not validated\n // unique, and fallback maps may collide with tile ids anyway.\n return this._imageLayerNodes.find(node => node.layer === layer);\n }\n\n return this._layerNodeById.get(layer.id);\n }\n\n /** Assign a freshly created node to the first band that selects its layer. */\n private _assignNewNode(node: TileLayerNode | ImageLayerNode, layer: TileLayer | ImageLayer): void {\n for (const def of this._bandDefs) {\n if (this._definitionSelects(def, layer)) {\n const band = this._bandByName.get(def.name)!;\n\n band._adopt(node);\n this._nodeBand.set(node, band);\n\n return;\n }\n }\n }\n\n /**\n * Whether a band definition selects the given layer - only by a selector\n * that is currently unambiguous (a unique name, or an id not shared across\n * kinds), mirroring {@link _resolveSelector}'s construction-time rules.\n */\n private _definitionSelects(def: ResolvedBandDef, layer: TileLayer | ImageLayer): boolean {\n for (const selector of def.selectors) {\n if (typeof selector === 'number') {\n if (selector === layer.id && !this._isCrossKindId(selector)) {\n return true;\n }\n } else if (selector === layer.name) {\n const sameName =\n this._map.layers.filter(other => other.name === selector).length + this._map.imageLayers.filter(other => other.name === selector).length;\n\n if (sameName === 1) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /** Whether an id currently belongs to both a tile layer and an image layer. */\n private _isCrossKindId(id: number): boolean {\n return this._map.getTileLayerById(id) !== undefined && this._map.imageLayers.some(layer => layer.id === id);\n }\n\n /** Detach + destroy a tile node, dropping it from bands and registries. */\n private _removeTileNode(node: TileLayerNode): void {\n this._releaseFromOwner(node);\n\n node.parent?.removeChild(node);\n this._layerNodeById.delete(node.layer.id);\n\n const orderIndex = this._layerNodes.indexOf(node);\n\n if (orderIndex !== -1) {\n this._layerNodes.splice(orderIndex, 1);\n }\n\n node.destroy();\n }\n\n /** Detach + destroy an image node, dropping it from bands and registries. */\n private _removeImageNode(node: ImageLayerNode): void {\n this._releaseFromOwner(node);\n\n node.parent?.removeChild(node);\n\n if (this._imageLayerNodeById.get(node.layer.id) === node) {\n this._imageLayerNodeById.delete(node.layer.id);\n }\n\n const orderIndex = this._imageLayerNodes.indexOf(node);\n\n if (orderIndex !== -1) {\n this._imageLayerNodes.splice(orderIndex, 1);\n }\n\n node.destroy();\n }\n\n /** Release a node from its band, or from the view's direct-ownership list. */\n private _releaseFromOwner(node: TileLayerNode | ImageLayerNode): void {\n const band = this._nodeBand.get(node);\n\n if (band) {\n band._release(node);\n this._nodeBand.delete(node);\n } else if (node instanceof TileLayerNode) {\n const directIndex = this._directLayerNodes.indexOf(node);\n\n if (directIndex !== -1) {\n this._directLayerNodes.splice(directIndex, 1);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,IAAa,cAAb,MAAyB;CACvB,AAAiB;CACjB,AAAiB;;CAGjB,AAAiB,cAA+B,CAAC;;CAEjD,AAAiB,iCAAiB,IAAI,IAA2B;;CAGjE,AAAiB,SAAwB,CAAC;;CAE1C,AAAiB,8BAAc,IAAI,IAAyB;;CAE5D,AAAiB,YAA+B,CAAC;;CAEjD,AAAiB,4BAAY,IAAI,IAAiD;;CAElF,AAAiB,oBAAqC,CAAC;;CAGvD,AAAiB,mBAAqC,CAAC;;CAEvD,AAAiB,sCAAsB,IAAI,IAA4B;CAEvE,AAAQ,aAAa;CACrB,AAAQ,iBAAgC,cAAc;;;;;;;CAQtD,AAAO,YAAY,KAAc,SAA8B;EAC7D,KAAK,OAAO;EACZ,KAAK,YAAY,SAAS,YAAY;EAEtC,KAAK,MAAM,SAAS,IAAI,QAAQ;GAC9B,MAAM,OAAO,IAAI,cAAc,OAAO,EAAE,UAAU,KAAK,UAAU,CAAC;GAElE,KAAK,YAAY,KAAK,IAAI;GAC1B,KAAK,eAAe,IAAI,MAAM,IAAI,IAAI;EACxC;EAEA,KAAK,MAAM,cAAc,IAAI,aAAa;GACxC,MAAM,YAAY,IAAI,eAAe,UAAU;GAE/C,KAAK,iBAAiB,KAAK,SAAS;GACpC,KAAK,oBAAoB,IAAI,WAAW,IAAI,SAAS;EACvD;EAEA,IAAI,SAAS,OACX,KAAK,MAAM,CAAC,MAAM,cAAc,OAAO,QAAQ,QAAQ,KAAK,GAC1D,KAAK,YAAY,MAAM,SAAS;EAIpC,KAAK,MAAM,QAAQ,KAAK,aACtB,IAAI,CAAC,KAAK,UAAU,IAAI,IAAI,GAC1B,KAAK,kBAAkB,KAAK,IAAI;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