@codexo/exojs-tilemap 0.15.3 → 0.16.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 +33 -26
- package/dist/esm/ChunkSource.d.ts +33 -0
- package/dist/esm/ChunkSource.d.ts.map +1 -0
- package/dist/esm/ChunkStreamer.d.ts +98 -0
- package/dist/esm/ChunkStreamer.d.ts.map +1 -0
- package/dist/esm/ChunkStreamer.js +201 -0
- package/dist/esm/ChunkStreamer.js.map +1 -0
- package/dist/esm/ImageLayer.d.ts +11 -3
- package/dist/esm/ImageLayer.d.ts.map +1 -0
- package/dist/esm/ImageLayer.js +71 -64
- package/dist/esm/ImageLayer.js.map +1 -1
- package/dist/esm/ImageLayerNode.d.ts +89 -0
- package/dist/esm/ImageLayerNode.d.ts.map +1 -0
- package/dist/esm/ImageLayerNode.js +205 -0
- package/dist/esm/ImageLayerNode.js.map +1 -0
- package/dist/esm/MapObject.d.ts +70 -0
- package/dist/esm/MapObject.d.ts.map +1 -0
- package/dist/esm/MapObject.js +34 -0
- package/dist/esm/MapObject.js.map +1 -0
- package/dist/esm/MapObjectSpawner.d.ts +133 -0
- package/dist/esm/MapObjectSpawner.d.ts.map +1 -0
- package/dist/esm/MapObjectSpawner.js +147 -0
- package/dist/esm/MapObjectSpawner.js.map +1 -0
- package/dist/esm/MapSpawnSession.d.ts +53 -0
- package/dist/esm/MapSpawnSession.d.ts.map +1 -0
- package/dist/esm/MapSpawnSession.js +88 -0
- package/dist/esm/MapSpawnSession.js.map +1 -0
- package/dist/esm/MapWorld.d.ts +134 -0
- package/dist/esm/MapWorld.d.ts.map +1 -0
- package/dist/esm/MapWorld.js +150 -0
- package/dist/esm/MapWorld.js.map +1 -0
- package/dist/esm/MapWorldRuntime.d.ts +182 -0
- package/dist/esm/MapWorldRuntime.d.ts.map +1 -0
- package/dist/esm/MapWorldRuntime.js +261 -0
- package/dist/esm/MapWorldRuntime.js.map +1 -0
- package/dist/esm/ObjectLayer.d.ts +93 -7
- package/dist/esm/ObjectLayer.d.ts.map +1 -0
- package/dist/esm/ObjectLayer.js +184 -167
- package/dist/esm/ObjectLayer.js.map +1 -1
- package/dist/esm/SampledChunkSource.d.ts +43 -0
- package/dist/esm/SampledChunkSource.d.ts.map +1 -0
- package/dist/esm/SampledChunkSource.js +48 -0
- package/dist/esm/SampledChunkSource.js.map +1 -0
- package/dist/esm/TileAnimator.d.ts +12 -2
- package/dist/esm/TileAnimator.d.ts.map +1 -0
- package/dist/esm/TileAnimator.js +154 -165
- package/dist/esm/TileAnimator.js.map +1 -1
- package/dist/esm/TileChunk.d.ts +30 -5
- package/dist/esm/TileChunk.d.ts.map +1 -0
- package/dist/esm/TileChunk.js +190 -188
- package/dist/esm/TileChunk.js.map +1 -1
- package/dist/esm/TileChunkNode.d.ts +18 -3
- package/dist/esm/TileChunkNode.d.ts.map +1 -0
- package/dist/esm/TileChunkNode.js +104 -85
- package/dist/esm/TileChunkNode.js.map +1 -1
- package/dist/esm/TileLayer.d.ts +104 -24
- package/dist/esm/TileLayer.d.ts.map +1 -0
- package/dist/esm/TileLayer.js +511 -469
- package/dist/esm/TileLayer.js.map +1 -1
- package/dist/esm/TileLayerNode.d.ts +52 -11
- package/dist/esm/TileLayerNode.d.ts.map +1 -0
- package/dist/esm/TileLayerNode.js +224 -166
- package/dist/esm/TileLayerNode.js.map +1 -1
- package/dist/esm/TileMap.d.ts +96 -31
- package/dist/esm/TileMap.d.ts.map +1 -0
- package/dist/esm/TileMap.js +401 -357
- package/dist/esm/TileMap.js.map +1 -1
- package/dist/esm/TileMapBand.d.ts +42 -29
- package/dist/esm/TileMapBand.d.ts.map +1 -0
- package/dist/esm/TileMapBand.js +151 -158
- package/dist/esm/TileMapBand.js.map +1 -1
- package/dist/esm/TileMapNode.d.ts +34 -18
- package/dist/esm/TileMapNode.d.ts.map +1 -0
- package/dist/esm/TileMapNode.js +122 -109
- package/dist/esm/TileMapNode.js.map +1 -1
- package/dist/esm/TileMapView.d.ts +108 -47
- package/dist/esm/TileMapView.d.ts.map +1 -0
- package/dist/esm/TileMapView.js +385 -338
- package/dist/esm/TileMapView.js.map +1 -1
- package/dist/esm/TileSet.d.ts +15 -6
- package/dist/esm/TileSet.d.ts.map +1 -0
- package/dist/esm/TileSet.js +161 -181
- package/dist/esm/TileSet.js.map +1 -1
- package/dist/esm/WangSet.d.ts +5 -4
- package/dist/esm/WangSet.d.ts.map +1 -0
- package/dist/esm/WangSet.js +70 -78
- package/dist/esm/WangSet.js.map +1 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts +95 -0
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +1 -0
- package/dist/esm/WorkerSampledChunkSource.js +117 -0
- package/dist/esm/WorkerSampledChunkSource.js.map +1 -0
- package/dist/esm/autoTile.d.ts +10 -5
- package/dist/esm/autoTile.d.ts.map +1 -0
- package/dist/esm/autoTile.js +164 -205
- package/dist/esm/autoTile.js.map +1 -1
- package/dist/esm/chunkGeometry.d.ts +8 -7
- package/dist/esm/chunkGeometry.d.ts.map +1 -0
- package/dist/esm/chunkGeometry.js +83 -94
- package/dist/esm/chunkGeometry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +26 -15
- package/dist/esm/nodeBounds.d.ts +20 -0
- package/dist/esm/nodeBounds.d.ts.map +1 -0
- package/dist/esm/nodeBounds.js +40 -0
- package/dist/esm/nodeBounds.js.map +1 -0
- package/dist/esm/pixelSnap.d.ts +4 -3
- package/dist/esm/pixelSnap.d.ts.map +1 -0
- package/dist/esm/pixelSnap.js +18 -16
- package/dist/esm/pixelSnap.js.map +1 -1
- package/dist/esm/public.d.ts +23 -3
- package/dist/esm/public.d.ts.map +1 -0
- package/dist/esm/tileCollision.d.ts +190 -0
- package/dist/esm/tileCollision.d.ts.map +1 -0
- package/dist/esm/tileCollision.js +367 -0
- package/dist/esm/tileCollision.js.map +1 -0
- package/dist/esm/tileWord.d.ts +12 -0
- package/dist/esm/tileWord.d.ts.map +1 -0
- package/dist/esm/tileWord.js +16 -0
- package/dist/esm/tileWord.js.map +1 -0
- package/dist/esm/tilemapExtension.d.ts +4 -3
- package/dist/esm/tilemapExtension.d.ts.map +1 -0
- package/dist/esm/tilemapExtension.js +47 -47
- package/dist/esm/tilemapExtension.js.map +1 -1
- package/dist/esm/tilemapSerializers.d.ts +5 -4
- package/dist/esm/tilemapSerializers.d.ts.map +1 -0
- package/dist/esm/tilemapSerializers.js +48 -41
- package/dist/esm/tilemapSerializers.js.map +1 -1
- package/dist/esm/types.d.ts +34 -18
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +111 -120
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +50 -2
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +1 -0
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +366 -332
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js +6 -0
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +1 -0
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js +6 -0
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +1 -0
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +70 -4
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +1 -0
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +496 -383
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +1 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +6 -0
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +1 -0
- package/package.json +8 -15
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/register.d.ts +0 -1
- package/dist/esm/register.js +0 -25
- package/dist/esm/register.js.map +0 -1
package/dist/esm/TileMap.js.map
CHANGED
|
@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QAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;AAC5B,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;IAC3B;AACD;;;;"}
|
|
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,AA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AY,IAAkB;EAChE,MAAM,QAAQ,KAAK,WAAW,IAAI,OAAO;EACzC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,SAAS,QAAQ,qBAAqB,KAAK,KAAK,GAAG;EAC/E,MAAM,YAAY,IAAI,EAAE;CAC1B;;;;;CAQA,AAAO,YAAY,IAAY,IAAsC;EACnE,OAAO;GACL,GAAG,KAAK,KAAK;GACb,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,12 +1,16 @@
|
|
|
1
1
|
import { Container } from '@codexo/exojs';
|
|
2
|
+
import type { ImageLayer } from './ImageLayer';
|
|
3
|
+
import type { ImageLayerNode } from './ImageLayerNode';
|
|
4
|
+
import type { TileLayer } from './TileLayer';
|
|
2
5
|
import type { TileLayerNode } from './TileLayerNode';
|
|
3
6
|
/**
|
|
4
|
-
* A named, ordered group of {@link TileLayerNode}s
|
|
5
|
-
* {@link TileMapView} for ergonomic
|
|
7
|
+
* A named, ordered group of layer nodes ({@link TileLayerNode}s and
|
|
8
|
+
* {@link ImageLayerNode}s) produced by a {@link TileMapView} for ergonomic
|
|
9
|
+
* actor interleaving.
|
|
6
10
|
*
|
|
7
11
|
* A band is a plain {@link Container} scene node that the application parents
|
|
8
12
|
* wherever it wants (typically directly under its own world root). Bands are
|
|
9
|
-
* composition units only: a band owns **its generated
|
|
13
|
+
* composition units only: a band owns **its generated layer nodes** and
|
|
10
14
|
* never application actors. Placing actors *between* bands is done by parenting
|
|
11
15
|
* the bands and the actor containers as siblings in the desired document order:
|
|
12
16
|
*
|
|
@@ -14,17 +18,19 @@ import type { TileLayerNode } from './TileLayerNode';
|
|
|
14
18
|
* worldRoot.addChild(view.band('ground'), actors, view.band('roof'));
|
|
15
19
|
* ```
|
|
16
20
|
*
|
|
17
|
-
* **Rendering order within a band always follows map document order
|
|
18
|
-
*
|
|
19
|
-
* layers; it
|
|
21
|
+
* **Rendering order within a band always follows map document order**
|
|
22
|
+
* ({@link import('./TileMap').TileMap.renderableLayers}), not the order layers
|
|
23
|
+
* were listed in the band definition - band membership *selects* layers; it
|
|
24
|
+
* never reorders them. Tile and image members interleave exactly as the map's
|
|
25
|
+
* combined document order dictates.
|
|
20
26
|
*
|
|
21
|
-
* **Ownership:** the band owns the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* {@link
|
|
27
|
+
* **Ownership:** the band owns the layer nodes it was created with. Destroying
|
|
28
|
+
* the band destroys those layer nodes (and their cached chunk geometry) and
|
|
29
|
+
* detaches the band from its application parent - it never touches application
|
|
30
|
+
* actors, sibling bands, the {@link TileMap}, the {@link TileLayer}s /
|
|
31
|
+
* {@link ImageLayer}s, or Loader-owned textures.
|
|
26
32
|
*
|
|
27
|
-
* Bounds are the union of the band's
|
|
33
|
+
* Bounds are the union of the band's layer-node bounds (an empty band
|
|
28
34
|
* collapses to a degenerate rect at the band's transformed origin).
|
|
29
35
|
*
|
|
30
36
|
* Bands are created by {@link TileMapView}; construct them through
|
|
@@ -47,20 +53,23 @@ export declare class TileMapBand extends Container {
|
|
|
47
53
|
* map document order. Adopted as children.
|
|
48
54
|
* @internal Constructed by {@link TileMapView}.
|
|
49
55
|
*/
|
|
50
|
-
constructor(name: string, layerNodes:
|
|
56
|
+
constructor(name: string, layerNodes: ReadonlyArray<TileLayerNode | ImageLayerNode>);
|
|
51
57
|
/**
|
|
52
|
-
* The
|
|
53
|
-
* is the band's **membership** list (the
|
|
54
|
-
* differ from {@link Container.children}
|
|
55
|
-
* individual layer node elsewhere.
|
|
58
|
+
* The layer nodes that compose this band, in map document order - tile and
|
|
59
|
+
* image members interleaved. This is the band's **membership** list (the
|
|
60
|
+
* nodes it owns and destroys); it may differ from {@link Container.children}
|
|
61
|
+
* if the caller reparents an individual layer node elsewhere.
|
|
56
62
|
*/
|
|
57
|
-
get layerNodes():
|
|
58
|
-
/**
|
|
59
|
-
|
|
63
|
+
get layerNodes(): ReadonlyArray<TileLayerNode | ImageLayerNode>;
|
|
64
|
+
/**
|
|
65
|
+
* Find this band's layer node rendering the layer with the given id (tile or
|
|
66
|
+
* image member; first match in document order).
|
|
67
|
+
*/
|
|
68
|
+
getLayerNodeById(id: number): TileLayerNode | ImageLayerNode | undefined;
|
|
60
69
|
/** Whether this band currently owns no layer nodes. */
|
|
61
70
|
get isEmpty(): boolean;
|
|
62
71
|
/**
|
|
63
|
-
* Bounds are the union of the band's visible
|
|
72
|
+
* Bounds are the union of the band's visible layer-node bounds. With no
|
|
64
73
|
* visible children the band collapses to a degenerate rect at its transformed
|
|
65
74
|
* origin (rather than the whole-subtree-plus-origin union a bare Container
|
|
66
75
|
* would report).
|
|
@@ -73,28 +82,32 @@ export declare class TileMapBand extends Container {
|
|
|
73
82
|
* map document order.
|
|
74
83
|
* @internal
|
|
75
84
|
*/
|
|
76
|
-
_adopt(node: TileLayerNode): void;
|
|
85
|
+
_adopt(node: TileLayerNode | ImageLayerNode): void;
|
|
77
86
|
/**
|
|
78
87
|
* Drop a layer node from this band's membership without destroying it (used
|
|
79
88
|
* when its map layer was removed; the view destroys the node separately).
|
|
80
89
|
* @internal
|
|
81
90
|
*/
|
|
82
|
-
_release(node: TileLayerNode): void;
|
|
91
|
+
_release(node: TileLayerNode | ImageLayerNode): void;
|
|
83
92
|
/**
|
|
84
93
|
* Reorder this band's membership and its still-parented children to map
|
|
85
|
-
* document order. `
|
|
86
|
-
* map's
|
|
87
|
-
*
|
|
94
|
+
* document order. `documentIndex` maps a layer **instance** to its index in
|
|
95
|
+
* the map's combined document order - keyed by instance rather than id
|
|
96
|
+
* because a tile layer and an image layer may share an id in fallback-ordered
|
|
97
|
+
* maps. Layer nodes the caller has reparented away from this band keep their
|
|
98
|
+
* membership (for ownership) but are not re-adopted.
|
|
88
99
|
* @internal
|
|
89
100
|
*/
|
|
90
|
-
_reorder(
|
|
101
|
+
_reorder(documentIndex: ReadonlyMap<TileLayer | ImageLayer, number>): void;
|
|
91
102
|
/**
|
|
92
103
|
* Destroy the band: detach it from its application parent, then destroy the
|
|
93
|
-
*
|
|
94
|
-
* sibling bands, the map, layers, and
|
|
104
|
+
* layer nodes it owns (freeing their chunk geometry / image sprites).
|
|
105
|
+
* Application actors, sibling bands, the map, layers, and Loader-owned
|
|
106
|
+
* textures are untouched.
|
|
95
107
|
*
|
|
96
108
|
* Idempotent: a second call (e.g. when {@link TileMapView.destroy} runs after
|
|
97
109
|
* the application already destroyed this band directly) is a safe no-op.
|
|
98
110
|
*/
|
|
99
111
|
destroy(): void;
|
|
100
112
|
}
|
|
113
|
+
//# sourceMappingURL=TileMapBand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TileMapBand.d.ts","sourceRoot":"","sources":["../../src/TileMapBand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,C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
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const owned = [...this._layerNodes];
|
|
152
|
-
this._layerNodes.length = 0;
|
|
153
|
-
super.destroy();
|
|
154
|
-
for (const node of owned) {
|
|
155
|
-
node.parent?.removeChild(node);
|
|
156
|
-
node.destroy();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
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
|
+
var TileMapBand = class 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 = "";
|
|
46
|
+
_layerNodes;
|
|
47
|
+
_destroyed = false;
|
|
48
|
+
/**
|
|
49
|
+
* @param name The band name (unique within its owning view).
|
|
50
|
+
* @param layerNodes The layer nodes composing this band, already ordered by
|
|
51
|
+
* map document order. Adopted as children.
|
|
52
|
+
* @internal Constructed by {@link TileMapView}.
|
|
53
|
+
*/
|
|
54
|
+
constructor(name, layerNodes) {
|
|
55
|
+
super();
|
|
56
|
+
this.name = name;
|
|
57
|
+
this._layerNodes = [...layerNodes];
|
|
58
|
+
for (const node of this._layerNodes) this.addChild(node);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The layer nodes that compose this band, in map document order - tile and
|
|
62
|
+
* image members interleaved. This is the band's **membership** list (the
|
|
63
|
+
* nodes it owns and destroys); it may differ from {@link Container.children}
|
|
64
|
+
* if the caller reparents an individual layer node elsewhere.
|
|
65
|
+
*/
|
|
66
|
+
get layerNodes() {
|
|
67
|
+
return this._layerNodes;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Find this band's layer node rendering the layer with the given id (tile or
|
|
71
|
+
* image member; first match in document order).
|
|
72
|
+
*/
|
|
73
|
+
getLayerNodeById(id) {
|
|
74
|
+
return this._layerNodes.find((node) => node.layer.id === id);
|
|
75
|
+
}
|
|
76
|
+
/** Whether this band currently owns no layer nodes. */
|
|
77
|
+
get isEmpty() {
|
|
78
|
+
return this._layerNodes.length === 0;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Bounds are the union of the band's visible layer-node bounds. With no
|
|
82
|
+
* visible children the band collapses to a degenerate rect at its transformed
|
|
83
|
+
* origin (rather than the whole-subtree-plus-origin union a bare Container
|
|
84
|
+
* would report).
|
|
85
|
+
*/
|
|
86
|
+
updateBounds() {
|
|
87
|
+
this._bounds.reset();
|
|
88
|
+
let hasVisibleChild = false;
|
|
89
|
+
for (const child of this.children) if (child.visible) {
|
|
90
|
+
this._bounds.addRect(child.getBounds());
|
|
91
|
+
hasVisibleChild = true;
|
|
92
|
+
}
|
|
93
|
+
if (!hasVisibleChild) this._bounds.addRect(this.getLocalBounds(), this.getGlobalTransform());
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Adopt a freshly created layer node into this band (used by
|
|
98
|
+
* {@link TileMapView.refreshLayers} when a newly added map layer joins this
|
|
99
|
+
* band). Appended; call {@link TileMapBand._reorder} afterwards to restore
|
|
100
|
+
* map document order.
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
_adopt(node) {
|
|
104
|
+
if (!this._layerNodes.includes(node)) this._layerNodes.push(node);
|
|
105
|
+
this.addChild(node);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Drop a layer node from this band's membership without destroying it (used
|
|
109
|
+
* when its map layer was removed; the view destroys the node separately).
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
_release(node) {
|
|
113
|
+
const index = this._layerNodes.indexOf(node);
|
|
114
|
+
if (index !== -1) this._layerNodes.splice(index, 1);
|
|
115
|
+
if (node.parent === this) this.removeChild(node);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Reorder this band's membership and its still-parented children to map
|
|
119
|
+
* document order. `documentIndex` maps a layer **instance** to its index in
|
|
120
|
+
* the map's combined document order - keyed by instance rather than id
|
|
121
|
+
* because a tile layer and an image layer may share an id in fallback-ordered
|
|
122
|
+
* maps. Layer nodes the caller has reparented away from this band keep their
|
|
123
|
+
* membership (for ownership) but are not re-adopted.
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
_reorder(documentIndex) {
|
|
127
|
+
this._layerNodes.sort((a, b) => (documentIndex.get(a.layer) ?? 0) - (documentIndex.get(b.layer) ?? 0));
|
|
128
|
+
for (const node of this._layerNodes) if (node.parent === this) this.addChild(node);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Destroy the band: detach it from its application parent, then destroy the
|
|
132
|
+
* layer nodes it owns (freeing their chunk geometry / image sprites).
|
|
133
|
+
* Application actors, sibling bands, the map, layers, and Loader-owned
|
|
134
|
+
* textures are untouched.
|
|
135
|
+
*
|
|
136
|
+
* Idempotent: a second call (e.g. when {@link TileMapView.destroy} runs after
|
|
137
|
+
* the application already destroyed this band directly) is a safe no-op.
|
|
138
|
+
*/
|
|
139
|
+
destroy() {
|
|
140
|
+
if (this._destroyed) return;
|
|
141
|
+
this._destroyed = true;
|
|
142
|
+
this.parent?.removeChild(this);
|
|
143
|
+
const owned = [...this._layerNodes];
|
|
144
|
+
this._layerNodes.length = 0;
|
|
145
|
+
super.destroy();
|
|
146
|
+
for (const node of owned) {
|
|
147
|
+
node.parent?.removeChild(node);
|
|
148
|
+
node.destroy();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
160
152
|
|
|
153
|
+
//#endregion
|
|
161
154
|
export { TileMapBand };
|
|
162
|
-
//# sourceMappingURL=TileMapBand.js.map
|
|
155
|
+
//# sourceMappingURL=TileMapBand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMapBand.js","sources":["
|
|
1
|
+
{"version":3,"file":"TileMapBand.js","names":[],"sources":["../../src/TileMapBand.ts"],"sourcesContent":["import { Container } from '@codexo/exojs';\n\nimport type { ImageLayer } from './ImageLayer';\nimport type { ImageLayerNode } from './ImageLayerNode';\nimport type { TileLayer } from './TileLayer';\nimport type { TileLayerNode } from './TileLayerNode';\n\n/**\n * A named, ordered group of layer nodes ({@link TileLayerNode}s and\n * {@link ImageLayerNode}s) produced by a {@link TileMapView} for ergonomic\n * actor interleaving.\n *\n * A band is a plain {@link Container} scene node that the application parents\n * wherever it wants (typically directly under its own world root). Bands are\n * composition units only: a band owns **its generated layer nodes** and\n * never application actors. Placing actors *between* bands is done by parenting\n * the bands and the actor containers as siblings in the desired document order:\n *\n * ```ts\n * worldRoot.addChild(view.band('ground'), actors, view.band('roof'));\n * ```\n *\n * **Rendering order within a band always follows map document order**\n * ({@link import('./TileMap').TileMap.renderableLayers}), not the order layers\n * were listed in the band definition - band membership *selects* layers; it\n * never reorders them. Tile and image members interleave exactly as the map's\n * combined document order dictates.\n *\n * **Ownership:** the band owns the layer nodes it was created with. Destroying\n * the band destroys those layer nodes (and their cached chunk geometry) and\n * detaches the band from its application parent - it never touches application\n * actors, sibling bands, the {@link TileMap}, the {@link TileLayer}s /\n * {@link ImageLayer}s, or Loader-owned textures.\n *\n * Bounds are the union of the band's layer-node bounds (an empty band\n * collapses to a degenerate rect at the band's transformed origin).\n *\n * Bands are created by {@link TileMapView}; construct them through\n * {@link TileMapView} rather than directly.\n *\n * @advanced\n */\nexport class TileMapBand extends Container {\n /**\n * The band name (unique within its owning {@link TileMapView}). Narrows the\n * inherited {@link SceneNode.name} from `string | null` to a required string;\n * assigned once at construction.\n */\n public override name = '';\n\n private readonly _layerNodes: Array<TileLayerNode | ImageLayerNode>;\n private _destroyed = false;\n\n /**\n * @param name The band name (unique within its owning view).\n * @param layerNodes The layer nodes composing this band, already ordered by\n * map document order. Adopted as children.\n * @internal Constructed by {@link TileMapView}.\n */\n public constructor(name: string, layerNodes: ReadonlyArray<TileLayerNode | ImageLayerNode>) {\n super();\n\n this.name = name;\n this._layerNodes = [...layerNodes];\n\n for (const node of this._layerNodes) {\n this.addChild(node);\n }\n }\n\n /**\n * The layer nodes that compose this band, in map document order - tile and\n * image members interleaved. This is the band's **membership** list (the\n * nodes it owns and destroys); it may differ from {@link Container.children}\n * if the caller reparents an individual layer node elsewhere.\n */\n public get layerNodes(): ReadonlyArray<TileLayerNode | ImageLayerNode> {\n return this._layerNodes;\n }\n\n /**\n * Find this band's layer node rendering the layer with the given id (tile or\n * image member; first match in document order).\n */\n public getLayerNodeById(id: number): TileLayerNode | ImageLayerNode | undefined {\n return this._layerNodes.find(node => node.layer.id === id);\n }\n\n /** Whether this band currently owns no layer nodes. */\n public get isEmpty(): boolean {\n return this._layerNodes.length === 0;\n }\n\n /**\n * Bounds are the union of the band's visible layer-node bounds. With no\n * visible children the band collapses to a degenerate rect at its transformed\n * origin (rather than the whole-subtree-plus-origin union a bare Container\n * would report).\n */\n public override updateBounds(): this {\n this._bounds.reset();\n\n let hasVisibleChild = false;\n\n for (const child of this.children) {\n if (child.visible) {\n this._bounds.addRect(child.getBounds());\n hasVisibleChild = true;\n }\n }\n\n if (!hasVisibleChild) {\n this._bounds.addRect(this.getLocalBounds(), this.getGlobalTransform());\n }\n\n return this;\n }\n\n /**\n * Adopt a freshly created layer node into this band (used by\n * {@link TileMapView.refreshLayers} when a newly added map layer joins this\n * band). Appended; call {@link TileMapBand._reorder} afterwards to restore\n * map document order.\n * @internal\n */\n public _adopt(node: TileLayerNode | ImageLayerNode): void {\n if (!this._layerNodes.includes(node)) {\n this._layerNodes.push(node);\n }\n\n this.addChild(node);\n }\n\n /**\n * Drop a layer node from this band's membership without destroying it (used\n * when its map layer was removed; the view destroys the node separately).\n * @internal\n */\n public _release(node: TileLayerNode | ImageLayerNode): void {\n const index = this._layerNodes.indexOf(node);\n\n if (index !== -1) {\n this._layerNodes.splice(index, 1);\n }\n\n if (node.parent === this) {\n this.removeChild(node);\n }\n }\n\n /**\n * Reorder this band's membership and its still-parented children to map\n * document order. `documentIndex` maps a layer **instance** to its index in\n * the map's combined document order - keyed by instance rather than id\n * because a tile layer and an image layer may share an id in fallback-ordered\n * maps. Layer nodes the caller has reparented away from this band keep their\n * membership (for ownership) but are not re-adopted.\n * @internal\n */\n public _reorder(documentIndex: ReadonlyMap<TileLayer | ImageLayer, number>): void {\n this._layerNodes.sort((a, b) => (documentIndex.get(a.layer) ?? 0) - (documentIndex.get(b.layer) ?? 0));\n\n for (const node of this._layerNodes) {\n if (node.parent === this) {\n this.addChild(node);\n }\n }\n }\n\n /**\n * Destroy the band: detach it from its application parent, then destroy the\n * layer nodes it owns (freeing their chunk geometry / image sprites).\n * Application actors, sibling bands, the map, layers, and Loader-owned\n * textures are untouched.\n *\n * Idempotent: a second call (e.g. when {@link TileMapView.destroy} runs after\n * the application already destroyed this band directly) is a safe no-op.\n */\n public override destroy(): void {\n if (this._destroyed) {\n return;\n }\n this._destroyed = true;\n\n this.parent?.removeChild(this);\n\n const owned = [...this._layerNodes];\n\n this._layerNodes.length = 0;\n\n super.destroy();\n\n for (const node of owned) {\n node.parent?.removeChild(node);\n node.destroy();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,cAAb,cAAiC,UAAU;;;;;;CAMzC,AAAgB,OAAO;CAEvB,AAAiB;CACjB,AAAQ,aAAa;;;;;;;CAQrB,AAAO,YAAY,MAAc,YAA2D;EAC1F,MAAM;EAEN,KAAK,OAAO;EACZ,KAAK,cAAc,CAAC,GAAG,UAAU;EAEjC,KAAK,MAAM,QAAQ,KAAK,aACtB,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