@codexo/exojs-tilemap 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -163
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +12 -20
- package/dist/esm/ChunkSource.d.ts +0 -33
- package/dist/esm/ChunkSource.d.ts.map +0 -1
- package/dist/esm/ChunkStreamer.d.ts +0 -104
- package/dist/esm/ChunkStreamer.d.ts.map +0 -1
- package/dist/esm/ChunkStreamer.js +0 -229
- package/dist/esm/ChunkStreamer.js.map +0 -1
- package/dist/esm/ImageLayer.d.ts +0 -89
- package/dist/esm/ImageLayer.d.ts.map +0 -1
- package/dist/esm/ImageLayer.js +0 -74
- package/dist/esm/ImageLayer.js.map +0 -1
- package/dist/esm/ImageLayerNode.d.ts +0 -91
- package/dist/esm/ImageLayerNode.d.ts.map +0 -1
- package/dist/esm/ImageLayerNode.js +0 -210
- package/dist/esm/ImageLayerNode.js.map +0 -1
- package/dist/esm/MapObject.d.ts +0 -70
- package/dist/esm/MapObject.d.ts.map +0 -1
- package/dist/esm/MapObject.js +0 -34
- package/dist/esm/MapObject.js.map +0 -1
- package/dist/esm/MapObjectSpawner.d.ts +0 -133
- package/dist/esm/MapObjectSpawner.d.ts.map +0 -1
- package/dist/esm/MapObjectSpawner.js +0 -147
- package/dist/esm/MapObjectSpawner.js.map +0 -1
- package/dist/esm/MapSpawnSession.d.ts +0 -46
- package/dist/esm/MapSpawnSession.d.ts.map +0 -1
- package/dist/esm/MapSpawnSession.js +0 -88
- package/dist/esm/MapSpawnSession.js.map +0 -1
- package/dist/esm/MapWorld.d.ts +0 -134
- package/dist/esm/MapWorld.d.ts.map +0 -1
- package/dist/esm/MapWorld.js +0 -150
- package/dist/esm/MapWorld.js.map +0 -1
- package/dist/esm/MapWorldRuntime.d.ts +0 -180
- package/dist/esm/MapWorldRuntime.d.ts.map +0 -1
- package/dist/esm/MapWorldRuntime.js +0 -261
- package/dist/esm/MapWorldRuntime.js.map +0 -1
- package/dist/esm/ObjectLayer.d.ts +0 -379
- package/dist/esm/ObjectLayer.d.ts.map +0 -1
- package/dist/esm/ObjectLayer.js +0 -221
- package/dist/esm/ObjectLayer.js.map +0 -1
- package/dist/esm/SampledChunkSource.d.ts +0 -43
- package/dist/esm/SampledChunkSource.d.ts.map +0 -1
- package/dist/esm/SampledChunkSource.js +0 -48
- package/dist/esm/SampledChunkSource.js.map +0 -1
- package/dist/esm/TileAnimator.d.ts +0 -72
- package/dist/esm/TileAnimator.d.ts.map +0 -1
- package/dist/esm/TileAnimator.js +0 -158
- package/dist/esm/TileAnimator.js.map +0 -1
- package/dist/esm/TileChunk.d.ts +0 -103
- package/dist/esm/TileChunk.d.ts.map +0 -1
- package/dist/esm/TileChunk.js +0 -194
- package/dist/esm/TileChunk.js.map +0 -1
- package/dist/esm/TileChunkNode.d.ts +0 -2
- package/dist/esm/TileChunkNode.d.ts.map +0 -1
- package/dist/esm/TileChunkNode.js +0 -145
- package/dist/esm/TileChunkNode.js.map +0 -1
- package/dist/esm/TileLayer.d.ts +0 -286
- package/dist/esm/TileLayer.d.ts.map +0 -1
- package/dist/esm/TileLayer.js +0 -526
- package/dist/esm/TileLayer.js.map +0 -1
- package/dist/esm/TileLayerNode.d.ts +0 -129
- package/dist/esm/TileLayerNode.d.ts.map +0 -1
- package/dist/esm/TileLayerNode.js +0 -245
- package/dist/esm/TileLayerNode.js.map +0 -1
- package/dist/esm/TileMap.d.ts +0 -317
- package/dist/esm/TileMap.d.ts.map +0 -1
- package/dist/esm/TileMap.js +0 -406
- package/dist/esm/TileMap.js.map +0 -1
- package/dist/esm/TileMapBand.d.ts +0 -80
- package/dist/esm/TileMapBand.d.ts.map +0 -1
- package/dist/esm/TileMapBand.js +0 -155
- package/dist/esm/TileMapBand.js.map +0 -1
- package/dist/esm/TileMapNode.d.ts +0 -92
- package/dist/esm/TileMapNode.d.ts.map +0 -1
- package/dist/esm/TileMapNode.js +0 -134
- package/dist/esm/TileMapNode.js.map +0 -1
- package/dist/esm/TileMapView.d.ts +0 -248
- package/dist/esm/TileMapView.d.ts.map +0 -1
- package/dist/esm/TileMapView.js +0 -394
- package/dist/esm/TileMapView.js.map +0 -1
- package/dist/esm/TileProjection.d.ts +0 -59
- package/dist/esm/TileProjection.d.ts.map +0 -1
- package/dist/esm/TileProjection.js +0 -106
- package/dist/esm/TileProjection.js.map +0 -1
- package/dist/esm/TileSet.d.ts +0 -116
- package/dist/esm/TileSet.d.ts.map +0 -1
- package/dist/esm/TileSet.js +0 -168
- package/dist/esm/TileSet.js.map +0 -1
- package/dist/esm/WangSet.d.ts +0 -80
- package/dist/esm/WangSet.d.ts.map +0 -1
- package/dist/esm/WangSet.js +0 -73
- package/dist/esm/WangSet.js.map +0 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts +0 -94
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +0 -1
- package/dist/esm/WorkerSampledChunkSource.js +0 -113
- package/dist/esm/WorkerSampledChunkSource.js.map +0 -1
- package/dist/esm/autoTile.d.ts +0 -88
- package/dist/esm/autoTile.d.ts.map +0 -1
- package/dist/esm/autoTile.js +0 -173
- package/dist/esm/autoTile.js.map +0 -1
- package/dist/esm/chunkGeometry.d.ts +0 -2
- package/dist/esm/chunkGeometry.d.ts.map +0 -1
- package/dist/esm/chunkGeometry.js +0 -116
- package/dist/esm/chunkGeometry.js.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -27
- package/dist/esm/nodeBounds.d.ts +0 -2
- package/dist/esm/nodeBounds.d.ts.map +0 -1
- package/dist/esm/nodeBounds.js +0 -40
- package/dist/esm/nodeBounds.js.map +0 -1
- package/dist/esm/pixelSnap.d.ts +0 -2
- package/dist/esm/pixelSnap.d.ts.map +0 -1
- package/dist/esm/pixelSnap.js +0 -21
- package/dist/esm/pixelSnap.js.map +0 -1
- package/dist/esm/projectObject.d.ts +0 -4
- package/dist/esm/projectObject.d.ts.map +0 -1
- package/dist/esm/projectObject.js +0 -87
- package/dist/esm/projectObject.js.map +0 -1
- package/dist/esm/public.d.ts +0 -48
- package/dist/esm/public.d.ts.map +0 -1
- package/dist/esm/tileCollision.d.ts +0 -190
- package/dist/esm/tileCollision.d.ts.map +0 -1
- package/dist/esm/tileCollision.js +0 -399
- package/dist/esm/tileCollision.js.map +0 -1
- package/dist/esm/tileWord.d.ts +0 -2
- package/dist/esm/tileWord.d.ts.map +0 -1
- package/dist/esm/tileWord.js +0 -16
- package/dist/esm/tileWord.js.map +0 -1
- package/dist/esm/tilemapExtension.d.ts +0 -20
- package/dist/esm/tilemapExtension.d.ts.map +0 -1
- package/dist/esm/tilemapExtension.js +0 -53
- package/dist/esm/tilemapExtension.js.map +0 -1
- package/dist/esm/tilemapSerializers.d.ts +0 -2
- package/dist/esm/tilemapSerializers.d.ts.map +0 -1
- package/dist/esm/tilemapSerializers.js +0 -54
- package/dist/esm/tilemapSerializers.js.map +0 -1
- package/dist/esm/types.d.ts +0 -231
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -129
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +0 -2
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +0 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +0 -376
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +0 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js +0 -6
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +0 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js +0 -6
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +0 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +0 -2
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +0 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +0 -539
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +0 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +0 -6
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +0 -1
package/dist/esm/TileMap.js
DELETED
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
import { validatePairedDimensions, validatePositiveInteger } from "./types.js";
|
|
2
|
-
import { TileProjection } from "./TileProjection.js";
|
|
3
|
-
import { TileMapView } from "./TileMapView.js";
|
|
4
|
-
|
|
5
|
-
//#region src/TileMap.ts
|
|
6
|
-
/**
|
|
7
|
-
* A generic, format-independent tile map.
|
|
8
|
-
*
|
|
9
|
-
* Owns a finite grid of {@link TileLayer}s and a shared set of {@link TileSet}s.
|
|
10
|
-
* Tile data is stored in compact chunked arrays - no per-tile heap objects.
|
|
11
|
-
*
|
|
12
|
-
* The map does NOT own tileset textures (those are Loader-owned) and does
|
|
13
|
-
* NOT own SceneNode children - see {@link import('./TileMapNode').TileMapNode},
|
|
14
|
-
* which owns those.
|
|
15
|
-
*
|
|
16
|
-
* Multiple tilesets are supported: each cell stores a packed tileset index
|
|
17
|
-
* and local tile ID, so different tilesets may have different tile dimensions.
|
|
18
|
-
*
|
|
19
|
-
* @advanced
|
|
20
|
-
*/
|
|
21
|
-
var TileMap = class {
|
|
22
|
-
projection;
|
|
23
|
-
/** Map name (debug). */
|
|
24
|
-
name;
|
|
25
|
-
/** Map width in tiles, or `undefined` if unbounded. */
|
|
26
|
-
width;
|
|
27
|
-
/** Map height in tiles, or `undefined` if unbounded. */
|
|
28
|
-
height;
|
|
29
|
-
/** Tile width in pixels. */
|
|
30
|
-
tileWidth;
|
|
31
|
-
/** Tile height in pixels. */
|
|
32
|
-
tileHeight;
|
|
33
|
-
/** Pixel width, or `undefined` if unbounded. */
|
|
34
|
-
get pixelWidth() {
|
|
35
|
-
return this.width === void 0 || this.height === void 0 ? void 0 : this.projection.getBounds(0, 0, this.width, this.height).width;
|
|
36
|
-
}
|
|
37
|
-
/** Pixel height, or `undefined` if unbounded. */
|
|
38
|
-
get pixelHeight() {
|
|
39
|
-
return this.width === void 0 || this.height === void 0 ? void 0 : this.projection.getBounds(0, 0, this.width, this.height).height;
|
|
40
|
-
}
|
|
41
|
-
/** `true` if this map has a fixed width/height; `false` if unbounded. */
|
|
42
|
-
get bounded() {
|
|
43
|
-
return this.width !== void 0 && this.height !== void 0;
|
|
44
|
-
}
|
|
45
|
-
/** Default chunk width for layers. */
|
|
46
|
-
chunkWidth;
|
|
47
|
-
/** Default chunk height for layers. */
|
|
48
|
-
chunkHeight;
|
|
49
|
-
/** Map class/type string (Tiled `class`; may be empty). */
|
|
50
|
-
class;
|
|
51
|
-
/** Map background colour as `0xRRGGBB`, or `null`. Informational. */
|
|
52
|
-
backgroundColor;
|
|
53
|
-
/** Tile draw order (Tiled `renderorder`). Informational. */
|
|
54
|
-
renderOrder;
|
|
55
|
-
/** Map-level properties (immutable). */
|
|
56
|
-
properties;
|
|
57
|
-
_tilesets;
|
|
58
|
-
_layers = [];
|
|
59
|
-
_layerById = /* @__PURE__ */ new Map();
|
|
60
|
-
_objectLayers = [];
|
|
61
|
-
_imageLayers = [];
|
|
62
|
-
_documentOrder = [];
|
|
63
|
-
_revision = 0;
|
|
64
|
-
_destroyed = false;
|
|
65
|
-
/**
|
|
66
|
-
* @throws When dimensions or other options are invalid.
|
|
67
|
-
*/
|
|
68
|
-
constructor(options) {
|
|
69
|
-
validatePairedDimensions(options.width, options.height, "TileMap", "map");
|
|
70
|
-
validatePositiveInteger(options.tileWidth, "map.tileWidth");
|
|
71
|
-
validatePositiveInteger(options.tileHeight, "map.tileHeight");
|
|
72
|
-
const chunkWidth = options.chunkWidth ?? 32;
|
|
73
|
-
const chunkHeight = options.chunkHeight ?? 32;
|
|
74
|
-
validatePositiveInteger(chunkWidth, "chunkWidth");
|
|
75
|
-
validatePositiveInteger(chunkHeight, "chunkHeight");
|
|
76
|
-
this.name = options.name ?? "TileMap";
|
|
77
|
-
this.width = options.width;
|
|
78
|
-
this.height = options.height;
|
|
79
|
-
this.tileWidth = options.tileWidth;
|
|
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.");
|
|
86
|
-
this.chunkWidth = chunkWidth;
|
|
87
|
-
this.chunkHeight = chunkHeight;
|
|
88
|
-
this.class = options.class ?? "";
|
|
89
|
-
this.backgroundColor = options.backgroundColor ?? null;
|
|
90
|
-
this.renderOrder = options.renderOrder ?? "right-down";
|
|
91
|
-
this._tilesets = options.tilesets ? [...options.tilesets] : [];
|
|
92
|
-
this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});
|
|
93
|
-
if (options.layers) for (const layer of options.layers) this._addLayer(layer);
|
|
94
|
-
if (options.objectLayers) this._objectLayers.push(...options.objectLayers);
|
|
95
|
-
if (options.imageLayers) for (const layer of options.imageLayers) this._addImageLayer(layer);
|
|
96
|
-
this._documentOrder.push(...this._buildDocumentOrder(options.documentOrder));
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Validate an explicit `documentOrder` option against current tile/image
|
|
100
|
-
* layer membership and resolve it to layer instances, or compute the
|
|
101
|
-
* fallback order (tile layers in insertion order, then image layers) when
|
|
102
|
-
* omitted. The order stores instance references - not ids - so a
|
|
103
|
-
* cross-kind id collision in a fallback map can never resolve to the
|
|
104
|
-
* wrong layer.
|
|
105
|
-
* @throws Per the validation rules documented on {@link
|
|
106
|
-
* TileMapOptions.documentOrder}.
|
|
107
|
-
*/
|
|
108
|
-
_buildDocumentOrder(documentOrder) {
|
|
109
|
-
if (!documentOrder) return [...this._layers, ...this._imageLayers];
|
|
110
|
-
const tileIds = new Set(this._layers.map((l) => l.id));
|
|
111
|
-
const imageIds = new Set(this._imageLayers.map((l) => l.id));
|
|
112
|
-
for (const id of tileIds) if (imageIds.has(id)) throw new Error(`Layer ID ${id} exists as both a tile layer and an image layer in map "${this.name}"; documentOrder cannot disambiguate them.`);
|
|
113
|
-
const seen = /* @__PURE__ */ new Set();
|
|
114
|
-
for (const id of documentOrder) {
|
|
115
|
-
if (!tileIds.has(id) && !imageIds.has(id)) throw new Error(`documentOrder references unknown layer ID ${id} in map "${this.name}".`);
|
|
116
|
-
if (seen.has(id)) throw new Error(`documentOrder lists layer ID ${id} more than once in map "${this.name}".`);
|
|
117
|
-
seen.add(id);
|
|
118
|
-
}
|
|
119
|
-
const totalLayers = tileIds.size + imageIds.size;
|
|
120
|
-
if (seen.size !== totalLayers) {
|
|
121
|
-
for (const id of [...tileIds, ...imageIds]) if (!seen.has(id)) throw new Error(`documentOrder is missing layer ID ${id} in map "${this.name}".`);
|
|
122
|
-
}
|
|
123
|
-
const instanceCount = this._layers.length + this._imageLayers.length;
|
|
124
|
-
if (documentOrder.length !== instanceCount) throw new Error(`documentOrder has ${documentOrder.length} entries but map "${this.name}" has ${instanceCount} tile/image layer instances; check for a duplicate image-layer ID.`);
|
|
125
|
-
return documentOrder.map((id) => {
|
|
126
|
-
const layer = this._layerById.get(id) ?? this._imageLayers.find((imageLayer) => imageLayer.id === id);
|
|
127
|
-
if (!layer) throw new Error(`documentOrder references layer id ${id}, but map "${this.name}" has no tile or image layer with that id.`);
|
|
128
|
-
return layer;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
/** Immutable list of tilesets available to this map. */
|
|
132
|
-
get tilesets() {
|
|
133
|
-
return this._tilesets;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Add a tileset. Tilesets must have unique names.
|
|
137
|
-
* @throws If a tileset with the same name already exists, or the map is destroyed.
|
|
138
|
-
*/
|
|
139
|
-
addTileset(tileset) {
|
|
140
|
-
this._checkDestroyed();
|
|
141
|
-
if (this._tilesets.some((ts) => ts.name === tileset.name)) throw new Error(`Tileset "${tileset.name}" already exists in map "${this.name}".`);
|
|
142
|
-
this._tilesets.push(tileset);
|
|
143
|
-
this._revision++;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Get a tileset by name, or undefined.
|
|
147
|
-
*/
|
|
148
|
-
getTileset(name) {
|
|
149
|
-
return this._tilesets.find((ts) => ts.name === name);
|
|
150
|
-
}
|
|
151
|
-
/** Immutable snapshot of layers (ordered). */
|
|
152
|
-
get layers() {
|
|
153
|
-
return this._layers;
|
|
154
|
-
}
|
|
155
|
-
_addLayer(layer) {
|
|
156
|
-
if (this._layerById.has(layer.id)) throw new Error(`Layer ID ${layer.id} already exists in map "${this.name}".`);
|
|
157
|
-
this._layerById.set(layer.id, layer);
|
|
158
|
-
this._layers.push(layer);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Add a layer after construction. Appended to the end of {@link
|
|
162
|
-
* renderableLayers}'s document order.
|
|
163
|
-
* @throws If a layer with the same ID already exists.
|
|
164
|
-
*/
|
|
165
|
-
addLayer(layer) {
|
|
166
|
-
this._checkDestroyed();
|
|
167
|
-
this._addLayer(layer);
|
|
168
|
-
this._documentOrder.push(layer);
|
|
169
|
-
this._revision++;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get a tile layer by ID.
|
|
173
|
-
*/
|
|
174
|
-
getTileLayerById(id) {
|
|
175
|
-
return this._layerById.get(id);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get a tile layer by name. Returns the first match in insertion order.
|
|
179
|
-
*/
|
|
180
|
-
getTileLayer(name) {
|
|
181
|
-
return this._layers.find((l) => l.name === name);
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Remove a layer by ID. The layer is destroyed and spliced out of {@link
|
|
185
|
-
* renderableLayers}'s document order.
|
|
186
|
-
* @returns true if the layer was found and removed.
|
|
187
|
-
*/
|
|
188
|
-
removeLayer(id) {
|
|
189
|
-
this._checkDestroyed();
|
|
190
|
-
const layer = this._layerById.get(id);
|
|
191
|
-
if (!layer) return false;
|
|
192
|
-
this._layers.splice(this._layers.indexOf(layer), 1);
|
|
193
|
-
this._layerById.delete(id);
|
|
194
|
-
const orderIndex = this._documentOrder.indexOf(layer);
|
|
195
|
-
if (orderIndex !== -1) this._documentOrder.splice(orderIndex, 1);
|
|
196
|
-
layer.destroy();
|
|
197
|
-
this._revision++;
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
/** Immutable snapshot of object layers (insertion order). */
|
|
201
|
-
get objectLayers() {
|
|
202
|
-
return this._objectLayers;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Add an object layer after construction.
|
|
206
|
-
* @throws If the map is destroyed.
|
|
207
|
-
*/
|
|
208
|
-
addObjectLayer(layer) {
|
|
209
|
-
this._checkDestroyed();
|
|
210
|
-
this._objectLayers.push(layer);
|
|
211
|
-
this._revision++;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Get an object layer by name (first match in insertion order), or undefined.
|
|
215
|
-
*
|
|
216
|
-
* Supply an {@link ObjectSchema} type argument `S` to obtain a typed view of
|
|
217
|
-
* the layer - `getObjectLayer<LevelObjects>('Entities')` returns an
|
|
218
|
-
* `ObjectLayer<LevelObjects>` whose {@link ObjectLayer.byType} / {@link
|
|
219
|
-
* ObjectLayer.where} accessors narrow `properties`. The schema is a static
|
|
220
|
-
* developer promise only; no runtime validation is performed and the call
|
|
221
|
-
* remains fully back-compatible when omitted.
|
|
222
|
-
*/
|
|
223
|
-
getObjectLayer(name) {
|
|
224
|
-
return this._objectLayers.find((layer) => layer.name === name);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Get an object layer by ID.
|
|
228
|
-
*
|
|
229
|
-
* Supply an {@link ObjectSchema} type argument `S` to obtain a typed view of
|
|
230
|
-
* the layer, as with {@link getObjectLayer}.
|
|
231
|
-
*/
|
|
232
|
-
getObjectLayerById(id) {
|
|
233
|
-
return this._objectLayers.find((layer) => layer.id === id);
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Remove an object layer by ID.
|
|
237
|
-
* @returns true if the layer was found and removed.
|
|
238
|
-
*/
|
|
239
|
-
removeObjectLayer(id) {
|
|
240
|
-
this._checkDestroyed();
|
|
241
|
-
const index = this._objectLayers.findIndex((layer) => layer.id === id);
|
|
242
|
-
if (index === -1) return false;
|
|
243
|
-
this._objectLayers.splice(index, 1);
|
|
244
|
-
this._revision++;
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
/** Immutable snapshot of image layers (insertion order). */
|
|
248
|
-
get imageLayers() {
|
|
249
|
-
return this._imageLayers;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Add an image layer after construction. Appended to both {@link
|
|
253
|
-
* imageLayers} and the end of {@link renderableLayers}'s document order.
|
|
254
|
-
* @throws If an image layer with the same ID already exists. An ID shared
|
|
255
|
-
* with a *tile* layer is permitted - the two kinds keep separate ID
|
|
256
|
-
* spaces, and all internal bookkeeping is instance-based.
|
|
257
|
-
*/
|
|
258
|
-
addImageLayer(layer) {
|
|
259
|
-
this._checkDestroyed();
|
|
260
|
-
this._addImageLayer(layer);
|
|
261
|
-
this._documentOrder.push(layer);
|
|
262
|
-
this._revision++;
|
|
263
|
-
}
|
|
264
|
-
/** Shared by the constructor and {@link addImageLayer}: enforce ID uniqueness within the image-layer kind. */
|
|
265
|
-
_addImageLayer(layer) {
|
|
266
|
-
if (this._imageLayers.some((existing) => existing.id === layer.id)) throw new Error(`Image layer ID ${layer.id} already exists in map "${this.name}".`);
|
|
267
|
-
this._imageLayers.push(layer);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Get an image layer by name (first match in insertion order), or undefined.
|
|
271
|
-
*/
|
|
272
|
-
getImageLayer(name) {
|
|
273
|
-
return this._imageLayers.find((layer) => layer.name === name);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Get an image layer by ID.
|
|
277
|
-
*/
|
|
278
|
-
getImageLayerById(id) {
|
|
279
|
-
return this._imageLayers.find((layer) => layer.id === id);
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Remove an image layer by ID. Spliced out of {@link renderableLayers}'s
|
|
283
|
-
* document order.
|
|
284
|
-
* @returns true if the layer was found and removed.
|
|
285
|
-
*/
|
|
286
|
-
removeImageLayer(id) {
|
|
287
|
-
this._checkDestroyed();
|
|
288
|
-
const layer = this._imageLayers.find((l) => l.id === id);
|
|
289
|
-
if (!layer) return false;
|
|
290
|
-
this._imageLayers.splice(this._imageLayers.indexOf(layer), 1);
|
|
291
|
-
const orderIndex = this._documentOrder.indexOf(layer);
|
|
292
|
-
if (orderIndex !== -1) this._documentOrder.splice(orderIndex, 1);
|
|
293
|
-
this._revision++;
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Tile and image layers combined into a single document order (see {@link
|
|
298
|
-
* TileMapOptions.documentOrder}), maintained live as membership changes.
|
|
299
|
-
* Reflects `addLayer` / `addImageLayer` / `removeLayer` /
|
|
300
|
-
* `removeImageLayer` calls made after construction. Holds instance
|
|
301
|
-
* references, so entries stay correct even when a tile layer and an image
|
|
302
|
-
* layer share an id in a fallback-ordered map. Object layers are
|
|
303
|
-
* data-only and never appear here.
|
|
304
|
-
*/
|
|
305
|
-
get renderableLayers() {
|
|
306
|
-
return this._documentOrder;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Create a new {@link TileMapView} that groups this map's layers into
|
|
310
|
-
* independently placeable band / layer scene nodes for interleaving
|
|
311
|
-
* application actors between tile layers.
|
|
312
|
-
*
|
|
313
|
-
* Each call returns a fresh, independent view - the map does **not** cache a
|
|
314
|
-
* single global view, so multiple coexisting views of the same map are
|
|
315
|
-
* allowed. The view references this map but never owns it: destroying the
|
|
316
|
-
* view frees only its generated layer/band nodes - never the map, its layers,
|
|
317
|
-
* tileset textures, or any application actors.
|
|
318
|
-
*
|
|
319
|
-
* @advanced
|
|
320
|
-
*/
|
|
321
|
-
createView(options) {
|
|
322
|
-
return new TileMapView(this, options);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Get a resolved tile from a given layer at tile coordinates.
|
|
326
|
-
* Convenience for `map.getTileLayerById(id)?.getTileAt(tx, ty)`.
|
|
327
|
-
* Returns null for an empty cell, out-of-bounds, or missing layer.
|
|
328
|
-
*/
|
|
329
|
-
getTileAt(layerId, tx, ty) {
|
|
330
|
-
const layer = this._layerById.get(layerId);
|
|
331
|
-
if (!layer) return null;
|
|
332
|
-
return layer.getTileAt(tx, ty);
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Set a tile on a given layer at tile coordinates.
|
|
336
|
-
* Convenience for `map.getTileLayerById(id)?.setTileAt(tx, ty, tile)`.
|
|
337
|
-
* @throws If the layer does not exist, coordinates are out of bounds,
|
|
338
|
-
* or the tile reference is invalid.
|
|
339
|
-
*/
|
|
340
|
-
setTileAt(layerId, tx, ty, tile) {
|
|
341
|
-
const layer = this._layerById.get(layerId);
|
|
342
|
-
if (!layer) throw new Error(`Layer ${layerId} not found in map "${this.name}".`);
|
|
343
|
-
layer.setTileAt(tx, ty, tile);
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Clear a tile on a given layer at tile coordinates.
|
|
347
|
-
* Convenience for `map.getTileLayerById(id)?.clearTileAt(tx, ty)`.
|
|
348
|
-
* @throws If the layer does not exist or coordinates are out of bounds.
|
|
349
|
-
*/
|
|
350
|
-
clearTileAt(layerId, tx, ty) {
|
|
351
|
-
const layer = this._layerById.get(layerId);
|
|
352
|
-
if (!layer) throw new Error(`Layer ${layerId} not found in map "${this.name}".`);
|
|
353
|
-
layer.clearTileAt(tx, ty);
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Convert a grid vertex to display pixels (the top diamond vertex for isometric cells)
|
|
357
|
-
* in map-local space (ignoring layer offsets).
|
|
358
|
-
*/
|
|
359
|
-
tileToPixel(tx, ty) {
|
|
360
|
-
return this.projection.tileToPixel(tx, ty);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Convert a display position in map-local space to the tile coordinate
|
|
364
|
-
* that contains it. Uses `floor`. May return coordinates outside map bounds.
|
|
365
|
-
*/
|
|
366
|
-
pixelToTile(px, py) {
|
|
367
|
-
return this.projection.pixelToTile(px, py);
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Monotonic map revision counter. Increments on structural changes only
|
|
371
|
-
* (add/remove layer, add tileset). Cell mutations are tracked per-chunk
|
|
372
|
-
* and per-layer; the renderer reads chunk-level revisions directly.
|
|
373
|
-
* @advanced
|
|
374
|
-
*/
|
|
375
|
-
get revision() {
|
|
376
|
-
return this._revision;
|
|
377
|
-
}
|
|
378
|
-
/** Whether the map has been destroyed. */
|
|
379
|
-
get destroyed() {
|
|
380
|
-
return this._destroyed;
|
|
381
|
-
}
|
|
382
|
-
_checkDestroyed() {
|
|
383
|
-
if (this._destroyed) throw new Error(`TileMap "${this.name}" has been destroyed.`);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Destroy the map and all owned layers and chunk storage.
|
|
387
|
-
*
|
|
388
|
-
* Is idempotent. Does NOT destroy tileset textures (Loader-owned) or
|
|
389
|
-
* any SceneNodes (those do not exist yet in this slice).
|
|
390
|
-
*/
|
|
391
|
-
destroy() {
|
|
392
|
-
if (this._destroyed) return;
|
|
393
|
-
this._destroyed = true;
|
|
394
|
-
for (const layer of this._layers) layer.destroy();
|
|
395
|
-
this._layers.length = 0;
|
|
396
|
-
this._layerById.clear();
|
|
397
|
-
this._objectLayers.length = 0;
|
|
398
|
-
this._imageLayers.length = 0;
|
|
399
|
-
this._documentOrder.length = 0;
|
|
400
|
-
this._tilesets.length = 0;
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
//#endregion
|
|
405
|
-
export { TileMap };
|
|
406
|
-
//# sourceMappingURL=TileMap.js.map
|
package/dist/esm/TileMap.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;;CAEhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;CAEhB,AAAiB;CACjB,AAAiB,UAAuB,CAAC;CACzC,AAAiB,6BAAa,IAAI,IAAuB;CACzD,AAAiB,gBAA+B,CAAC;CACjD,AAAiB,eAA6B,CAAC;CAC/C,AAAiB,iBAAgD,CAAC;CAElE,AAAQ,YAAY;CACpB,AAAQ,aAAa;;;;CAKrB,AAAO,YAAY,SAAyB;EAC1C,yBAAyB,QAAQ,OAAO,QAAQ,QAAQ,WAAW,KAAK;EACxE,wBAAwB,QAAQ,WAAW,eAAe;EAC1D,wBAAwB,QAAQ,YAAY,gBAAgB;EAE5D,MAAM,aAAa,QAAQ,cAAc;EACzC,MAAM,cAAc,QAAQ,eAAe;EAC3C,wBAAwB,YAAY,YAAY;EAChD,wBAAwB,aAAa,aAAa;EAElD,KAAK,OAAO,QAAQ,QAAQ;EAC5B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AS;EACtB,KAAK,WAAW,MAAM;EACtB,KAAK,cAAc,SAAS;EAC5B,KAAK,aAAa,SAAS;EAC3B,KAAK,eAAe,SAAS;EAC7B,KAAK,UAAU,SAAS;CAC1B;AACF"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Container } from '@codexo/exojs';
|
|
2
|
-
import type { ImageLayerNode } from './ImageLayerNode';
|
|
3
|
-
import type { TileLayerNode } from './TileLayerNode';
|
|
4
|
-
/**
|
|
5
|
-
* A named, ordered group of layer nodes ({@link TileLayerNode}s and
|
|
6
|
-
* {@link ImageLayerNode}s) produced by a {@link TileMapView} for ergonomic
|
|
7
|
-
* actor interleaving.
|
|
8
|
-
*
|
|
9
|
-
* A band is a plain {@link Container} scene node that the application parents
|
|
10
|
-
* wherever it wants (typically directly under its own world root). Bands are
|
|
11
|
-
* composition units only: a band owns **its generated layer nodes** and
|
|
12
|
-
* never application actors. Placing actors *between* bands is done by parenting
|
|
13
|
-
* the bands and the actor containers as siblings in the desired document order:
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* worldRoot.addChild(view.band('ground'), actors, view.band('roof'));
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* **Rendering order within a band always follows map document order**
|
|
20
|
-
* ({@link import('./TileMap').TileMap.renderableLayers}), not the order layers
|
|
21
|
-
* were listed in the band definition - band membership *selects* layers; it
|
|
22
|
-
* never reorders them. Tile and image members interleave exactly as the map's
|
|
23
|
-
* combined document order dictates.
|
|
24
|
-
*
|
|
25
|
-
* **Ownership:** the band owns the layer nodes it was created with. Destroying
|
|
26
|
-
* the band destroys those layer nodes (and their cached chunk geometry) and
|
|
27
|
-
* detaches the band from its application parent - it never touches application
|
|
28
|
-
* actors, sibling bands, the {@link TileMap}, the {@link TileLayer}s /
|
|
29
|
-
* {@link ImageLayer}s, or Loader-owned textures.
|
|
30
|
-
*
|
|
31
|
-
* Bounds are the union of the band's layer-node bounds (an empty band
|
|
32
|
-
* collapses to a degenerate rect at the band's transformed origin).
|
|
33
|
-
*
|
|
34
|
-
* Bands are created by {@link TileMapView}; construct them through
|
|
35
|
-
* {@link TileMapView} rather than directly.
|
|
36
|
-
*
|
|
37
|
-
* @advanced
|
|
38
|
-
*/
|
|
39
|
-
export declare class TileMapBand extends Container {
|
|
40
|
-
/**
|
|
41
|
-
* The band name (unique within its owning {@link TileMapView}). Narrows the
|
|
42
|
-
* inherited {@link SceneNode.name} from `string | null` to a required string;
|
|
43
|
-
* assigned once at construction.
|
|
44
|
-
*/
|
|
45
|
-
name: string;
|
|
46
|
-
private readonly _layerNodes;
|
|
47
|
-
private _destroyed;
|
|
48
|
-
/**
|
|
49
|
-
* The layer nodes that compose this band, in map document order - tile and
|
|
50
|
-
* image members interleaved. This is the band's **membership** list (the
|
|
51
|
-
* nodes it owns and destroys); it may differ from {@link Container.children}
|
|
52
|
-
* if the caller reparents an individual layer node elsewhere.
|
|
53
|
-
*/
|
|
54
|
-
get layerNodes(): ReadonlyArray<TileLayerNode | ImageLayerNode>;
|
|
55
|
-
/**
|
|
56
|
-
* Find this band's layer node rendering the layer with the given id (tile or
|
|
57
|
-
* image member; first match in document order).
|
|
58
|
-
*/
|
|
59
|
-
getLayerNodeById(id: number): TileLayerNode | ImageLayerNode | undefined;
|
|
60
|
-
/** Whether this band currently owns no layer nodes. */
|
|
61
|
-
get isEmpty(): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Bounds are the union of the band's visible layer-node bounds. With no
|
|
64
|
-
* visible children the band collapses to a degenerate rect at its transformed
|
|
65
|
-
* origin (rather than the whole-subtree-plus-origin union a bare Container
|
|
66
|
-
* would report).
|
|
67
|
-
*/
|
|
68
|
-
updateBounds(): this;
|
|
69
|
-
/**
|
|
70
|
-
* Destroy the band: detach it from its application parent, then destroy the
|
|
71
|
-
* layer nodes it owns (freeing their chunk geometry / image sprites).
|
|
72
|
-
* Application actors, sibling bands, the map, layers, and Loader-owned
|
|
73
|
-
* textures are untouched.
|
|
74
|
-
*
|
|
75
|
-
* Idempotent: a second call (e.g. when {@link TileMapView.destroy} runs after
|
|
76
|
-
* the application already destroyed this band directly) is a safe no-op.
|
|
77
|
-
*/
|
|
78
|
-
destroy(): void;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=TileMapBand.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|