@codexo/exojs-tilemap 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -34
- package/dist/esm/ChunkStreamer.d.ts.map +1 -1
- package/dist/esm/ChunkStreamer.js +28 -6
- package/dist/esm/ChunkStreamer.js.map +1 -1
- package/dist/esm/ImageLayer.d.ts +1 -1
- package/dist/esm/ImageLayer.d.ts.map +1 -1
- package/dist/esm/ImageLayerNode.d.ts.map +1 -1
- package/dist/esm/MapObject.d.ts +2 -2
- package/dist/esm/MapObject.d.ts.map +1 -1
- package/dist/esm/MapObject.js.map +1 -1
- package/dist/esm/MapObjectSpawner.d.ts.map +1 -1
- package/dist/esm/MapSpawnSession.d.ts.map +1 -1
- package/dist/esm/MapWorld.d.ts +8 -8
- package/dist/esm/MapWorld.d.ts.map +1 -1
- package/dist/esm/MapWorldRuntime.d.ts.map +1 -1
- package/dist/esm/ObjectLayer.d.ts +26 -10
- package/dist/esm/ObjectLayer.d.ts.map +1 -1
- package/dist/esm/ObjectLayer.js +28 -0
- package/dist/esm/ObjectLayer.js.map +1 -1
- package/dist/esm/SampledChunkSource.d.ts.map +1 -1
- package/dist/esm/TileAnimator.d.ts.map +1 -1
- package/dist/esm/TileChunk.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.js +47 -10
- package/dist/esm/TileChunkNode.js.map +1 -1
- package/dist/esm/TileLayer.d.ts +11 -2
- package/dist/esm/TileLayer.d.ts.map +1 -1
- package/dist/esm/TileLayer.js +20 -10
- package/dist/esm/TileLayer.js.map +1 -1
- package/dist/esm/TileLayerNode.d.ts +6 -4
- package/dist/esm/TileLayerNode.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.js +36 -21
- package/dist/esm/TileLayerNode.js.map +1 -1
- package/dist/esm/TileMap.d.ts +6 -2
- package/dist/esm/TileMap.d.ts.map +1 -1
- package/dist/esm/TileMap.js +13 -12
- package/dist/esm/TileMap.js.map +1 -1
- package/dist/esm/TileMapBand.d.ts.map +1 -1
- package/dist/esm/TileMapNode.d.ts.map +1 -1
- package/dist/esm/TileMapNode.js +4 -1
- package/dist/esm/TileMapNode.js.map +1 -1
- package/dist/esm/TileMapView.d.ts.map +1 -1
- package/dist/esm/TileProjection.d.ts +59 -0
- package/dist/esm/TileProjection.d.ts.map +1 -0
- package/dist/esm/TileProjection.js +106 -0
- package/dist/esm/TileProjection.js.map +1 -0
- package/dist/esm/TileSet.d.ts.map +1 -1
- package/dist/esm/WangSet.d.ts.map +1 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +1 -1
- package/dist/esm/autoTile.d.ts.map +1 -1
- package/dist/esm/chunkGeometry.js +78 -50
- package/dist/esm/chunkGeometry.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/projectObject.d.ts +4 -0
- package/dist/esm/projectObject.d.ts.map +1 -0
- package/dist/esm/projectObject.js +87 -0
- package/dist/esm/projectObject.js.map +1 -0
- package/dist/esm/public.d.ts +1 -0
- package/dist/esm/public.d.ts.map +1 -1
- package/dist/esm/tileCollision.d.ts +2 -2
- package/dist/esm/tileCollision.d.ts.map +1 -1
- package/dist/esm/tileCollision.js +48 -16
- package/dist/esm/tileCollision.js.map +1 -1
- package/dist/esm/tilemapSerializers.js +1 -1
- package/dist/esm/tilemapSerializers.js.map +1 -1
- package/dist/esm/types.d.ts +3 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +5 -4
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +63 -27
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +1 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +1 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -42,44 +42,56 @@ npm install @codexo/exojs @codexo/exojs-tilemap
|
|
|
42
42
|
## Usage — procedural map
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
-
import { Application, TextureRegion } from '@codexo/exojs';
|
|
45
|
+
import { Application, Scene, type Texture, TextureRegion } from '@codexo/exojs';
|
|
46
46
|
import { TileLayer, TileMap, TileMapNode, TileSet, tilemapExtension, TILE_TRANSFORM_IDENTITY } from '@codexo/exojs-tilemap';
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
class WorldScene extends Scene {
|
|
49
|
+
private atlas: Texture | null = null;
|
|
50
|
+
|
|
51
|
+
public override async load(): Promise<void> {
|
|
52
|
+
// A Loader-owned atlas texture: the tilemap runtime never destroys it.
|
|
53
|
+
this.atlas = await this.loader.load('tiles.png');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public override init(): void {
|
|
57
|
+
const atlas = this.atlas!;
|
|
58
|
+
const terrain = new TileSet({
|
|
59
|
+
name: 'terrain',
|
|
60
|
+
texture: new TextureRegion(atlas, { x: 0, y: 0, width: atlas.width, height: atlas.height }),
|
|
61
|
+
tileWidth: 16,
|
|
62
|
+
tileHeight: 16,
|
|
63
|
+
tileCount: 256,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const ground = new TileLayer({
|
|
67
|
+
id: 1,
|
|
68
|
+
name: 'ground',
|
|
69
|
+
width: 64,
|
|
70
|
+
height: 64,
|
|
71
|
+
tileWidth: 16,
|
|
72
|
+
tileHeight: 16,
|
|
73
|
+
tilesets: [terrain],
|
|
74
|
+
});
|
|
75
|
+
ground.setTileAt(0, 0, { tileset: terrain, localTileId: 5, transform: TILE_TRANSFORM_IDENTITY });
|
|
76
|
+
|
|
77
|
+
const map = new TileMap({
|
|
78
|
+
name: 'world',
|
|
79
|
+
width: 64,
|
|
80
|
+
height: 64,
|
|
81
|
+
tileWidth: 16,
|
|
82
|
+
tileHeight: 16,
|
|
83
|
+
tilesets: [terrain],
|
|
84
|
+
layers: [ground],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Render the whole map: a scene draws its root without a draw() override.
|
|
88
|
+
this.addChild(new TileMapNode(map));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
59
91
|
|
|
60
|
-
const
|
|
61
|
-
id: 1,
|
|
62
|
-
name: 'ground',
|
|
63
|
-
width: 64,
|
|
64
|
-
height: 64,
|
|
65
|
-
tileWidth: 16,
|
|
66
|
-
tileHeight: 16,
|
|
67
|
-
tilesets: [terrain],
|
|
68
|
-
});
|
|
69
|
-
ground.setTileAt(0, 0, { tileset: terrain, localTileId: 5, transform: TILE_TRANSFORM_IDENTITY });
|
|
70
|
-
|
|
71
|
-
const map = new TileMap({
|
|
72
|
-
name: 'world',
|
|
73
|
-
width: 64,
|
|
74
|
-
height: 64,
|
|
75
|
-
tileWidth: 16,
|
|
76
|
-
tileHeight: 16,
|
|
77
|
-
tilesets: [terrain],
|
|
78
|
-
layers: [ground],
|
|
79
|
-
});
|
|
92
|
+
const app = new Application({ extensions: [tilemapExtension] /* canvas, … */ });
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
app.scenes.root.addChild(new TileMapNode(map));
|
|
94
|
+
await app.start(WorldScene);
|
|
83
95
|
```
|
|
84
96
|
|
|
85
97
|
### Interleaving actors between layers — `TileMapView`
|
|
@@ -117,6 +129,16 @@ Actors are application-owned siblings. `TileMapView` never adopts or destroys ac
|
|
|
117
129
|
- There is no map-replacement API: to swap maps, destroy the old view and create a new view from the new map — the actor tree is untouched.
|
|
118
130
|
- After layers are structurally added to or removed from the map, call `view.refreshLayers()`: unchanged layer nodes keep their identity and bands keep their placement in your scene graph.
|
|
119
131
|
|
|
132
|
+
## Isometric grids
|
|
133
|
+
|
|
134
|
+
Supply a shared `TileProjection({ orientation: 'isometric', tileWidth, tileHeight, originX, originY })` to the map and each tile layer. Orthogonal is the default. `tileToPixel()` projects the cell's top diamond vertex; `pixelToTile()` inversely projects and floors both grid axes, including negative coordinates. Cell boundaries are half-open. `projection.logicalToPixel()` and `pixelToLogical()` preserve fractional coordinates. Isometric logical cells are squares of side `tileHeight`; display diamonds may have any positive integer width and height.
|
|
135
|
+
|
|
136
|
+
Layer offsets are display translations. `TileLayer.logicalOffset` exposes the corresponding logical vector for simulation. A map's pixel dimensions describe the projected grid AABB, while `projection.getBounds()` also supplies its possibly negative origin. Scene-node bounds include isometric artwork overhangs and tileset offsets. Picking describes cells, not opaque pixels of tall artwork; apply inverse scene and camera transforms before calling the map/layer helpers.
|
|
137
|
+
|
|
138
|
+
Isometric rendering splits resident storage chunks into diagonal draw sections, sorted across chunks by increasing `tx + ty`, then increasing `tx`. Only consecutive tiles with the same texture are batched, so tall tiles preserve painter order across texture and chunk boundaries. Geometry stays revision-cached. All sections share a layer-grid snap origin, including odd tile sizes. More draw sections and texture changes can cost more than orthogonal batching; no throughput improvement is promised.
|
|
139
|
+
|
|
140
|
+
Object layers remain data-only. With a projection their objects use logical coordinates; `layer.getDisplayObject(object)` returns display geometry with the layer offset applied. Rectangles may become polygons and ellipses retain their exact affine shape. Tile/text dimensions stay in display pixels. Actors remain application-owned; bands interleave them between layers, not automatically among individual terrain tiles.
|
|
141
|
+
|
|
120
142
|
## Renderer model
|
|
121
143
|
|
|
122
144
|
- **Chunk-first.** A `TileLayerNode` is a container of per-chunk `TileChunkNode` drawables (one per non-empty loaded chunk). The renderer batches tiles by `(shader, tileset texture)` and issues one instanced draw per batch — draw calls scale with _visible chunks × layers_, not total tile count.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChunkStreamer.d.ts","sourceRoot":"","sources":["../../src/ChunkStreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAA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= layer.parallaxScale;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
let layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;
|
|
130
|
+
let layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;
|
|
131
|
+
let layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;
|
|
132
|
+
let layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;
|
|
133
|
+
if (layer.projection.orientation === "isometric") {
|
|
134
|
+
let left = 0;
|
|
135
|
+
let top = 0;
|
|
136
|
+
let right = 0;
|
|
137
|
+
let bottom = 0;
|
|
138
|
+
for (const tileset of layer.tilesets) {
|
|
139
|
+
left = Math.max(left, tileset.tileWidth - layer.tileWidth / 2 + tileset.offsetX);
|
|
140
|
+
top = Math.max(top, layer.tileHeight + tileset.offsetY);
|
|
141
|
+
right = Math.max(right, layer.tileWidth / 2 - tileset.offsetX);
|
|
142
|
+
bottom = Math.max(bottom, tileset.tileHeight - layer.tileHeight - tileset.offsetY);
|
|
143
|
+
}
|
|
144
|
+
layerLeft -= left;
|
|
145
|
+
layerTop -= top;
|
|
146
|
+
layerRight += right;
|
|
147
|
+
layerBottom += bottom;
|
|
148
|
+
}
|
|
133
149
|
const topLeftTile = layer.pixelToTile(layerLeft, layerTop);
|
|
134
150
|
const bottomRightTile = layer.pixelToTile(layerRight, layerBottom);
|
|
135
|
-
const
|
|
136
|
-
const
|
|
151
|
+
const topRightTile = layer.pixelToTile(layerRight, layerTop);
|
|
152
|
+
const bottomLeftTile = layer.pixelToTile(layerLeft, layerBottom);
|
|
153
|
+
const minTx = Math.min(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);
|
|
154
|
+
const minTy = Math.min(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);
|
|
155
|
+
const maxTx = Math.max(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);
|
|
156
|
+
const maxTy = Math.max(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);
|
|
157
|
+
const topLeftChunk = tileToChunkCoord(minTx, minTy, layer.chunkWidth, layer.chunkHeight);
|
|
158
|
+
const bottomRightChunk = tileToChunkCoord(maxTx, maxTy, layer.chunkWidth, layer.chunkHeight);
|
|
137
159
|
return {
|
|
138
160
|
minCx: topLeftChunk.cx,
|
|
139
161
|
minCy: topLeftChunk.cy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChunkStreamer.js","names":[],"sources":["../../src/ChunkStreamer.ts"],"sourcesContent":["import { logger, type View } from '@codexo/exojs';\n\nimport type { ChunkPayload, ChunkSource } from './ChunkSource';\nimport type { ChunkRange, TileLayer } from './TileLayer';\nimport { tileToChunkCoord } from './types';\n\n/**\n * Options for a {@link ChunkStreamer}. All optional.\n * @advanced\n */\nexport interface ChunkStreamerOptions {\n /**\n * Chunks within this many chunk-units (Chebyshev distance to the visible\n * chunk range) of the view are loaded. Default `1`.\n */\n readonly loadRadius?: number;\n /**\n * Own-resident chunks beyond this many chunk-units of the view are\n * evicted. Must be `>= loadRadius` - the gap between the two is\n * deliberate hysteresis that prevents load/unload thrashing when the\n * view sits near a chunk boundary. Default `2`.\n */\n readonly unloadRadius?: number;\n /**\n * Maximum number of new chunk loads issued per {@link ChunkStreamer.update}\n * call, after the very first call (which loads the entire initial wanted\n * set unbudgeted, so the starting view never pops in). Default `8`.\n */\n readonly maxChunkLoadsPerFrame?: number;\n}\n\nconst DEFAULT_LOAD_RADIUS = 1;\nconst DEFAULT_UNLOAD_RADIUS = 2;\nconst DEFAULT_MAX_CHUNK_LOADS_PER_FRAME = 8;\n\nconst chunkKey = (cx: number, cy: number): string => `${cx},${cy}`;\n\nconst isThenable = (value: unknown): value is Promise<ChunkPayload | null> =>\n value !== null && typeof value === 'object' && typeof (value as { then?: unknown }).then === 'function';\n\n/**\n * Drives {@link TileLayer._adoptChunk}/{@link TileLayer._evictChunk} calls\n * from a {@link View}'s position: chunks near the view are requested from a\n * {@link ChunkSource} and installed; chunks that scroll far enough away are\n * evicted. Works on both unbounded and bounded layers (a bounded-but-large\n * layer still benefits from not keeping every chunk resident at once) - for\n * a bounded layer, the wanted range is clamped to {@link TileLayer.chunkRange}.\n *\n * Touches only the {@link TileLayer} data layer -\n * {@link import('./TileLayerNode').TileLayerNode} reacts to\n * `_adoptChunk`/`_evictChunk` on its own via a structural listener, so this\n * class has no rendering dependency and no reference to any scene node.\n *\n * Tracks its own resident set (chunks *this instance* has loaded), never\n * touching chunks that predate its attachment or were installed by another\n * source.\n *\n * Tick it from your update loop, like {@link import('./TileAnimator').TileAnimator}:\n *\n * ```ts\n * const streamer = new ChunkStreamer(layer, mySource, view);\n * scene.systems.add({ update: () => streamer.update() });\n * ```\n *\n * @advanced\n */\nexport class ChunkStreamer {\n private readonly _layer: TileLayer;\n private readonly _source: ChunkSource;\n private readonly _view: View;\n private readonly _loadRadius: number;\n private readonly _unloadRadius: number;\n private readonly _maxChunkLoadsPerFrame: number;\n\n private readonly _resident = new Map<string, { readonly cx: number; readonly cy: number }>();\n private readonly _inFlight = new Map<string, number>();\n private _requestCounter = 0;\n private _primed = false;\n private _destroyed = false;\n\n public constructor(layer: TileLayer, source: ChunkSource, view: View, options?: ChunkStreamerOptions) {\n this._layer = layer;\n this._source = source;\n this._view = view;\n this._loadRadius = options?.loadRadius ?? DEFAULT_LOAD_RADIUS;\n this._unloadRadius = options?.unloadRadius ?? DEFAULT_UNLOAD_RADIUS;\n this._maxChunkLoadsPerFrame = options?.maxChunkLoadsPerFrame ?? DEFAULT_MAX_CHUNK_LOADS_PER_FRAME;\n\n if (this._unloadRadius < this._loadRadius) {\n throw new Error(`ChunkStreamer unloadRadius (${this._unloadRadius}) must be >= loadRadius (${this._loadRadius}).`);\n }\n }\n\n /** Number of chunks this instance currently has resident in the layer. */\n public get residentCount(): number {\n return this._resident.size;\n }\n\n /**\n * Recompute the wanted chunk set from the view's current position; evict\n * own-resident chunks that fell outside `unloadRadius`, then request\n * chunks newly inside `loadRadius`. The very first call loads the entire\n * initial wanted set unbudgeted; every later call is capped at\n * {@link ChunkStreamerOptions.maxChunkLoadsPerFrame}. No-op once\n * {@link destroy}ed.\n */\n public update(): void {\n if (this._destroyed) return;\n\n const core = this._computeCoreRange();\n\n this._unload(core);\n\n const range = this._layer.chunkRange();\n let minCx = core.minCx - this._loadRadius;\n let minCy = core.minCy - this._loadRadius;\n let maxCx = core.maxCx + this._loadRadius;\n let maxCy = core.maxCy + this._loadRadius;\n if (range !== null) {\n minCx = Math.max(minCx, range.minCx);\n minCy = Math.max(minCy, range.minCy);\n maxCx = Math.min(maxCx, range.maxCx);\n maxCy = Math.min(maxCy, range.maxCy);\n }\n\n const toLoad: Array<{ cx: number; cy: number }> = [];\n for (let cy = minCy; cy <= maxCy; cy++) {\n for (let cx = minCx; cx <= maxCx; cx++) {\n const key = chunkKey(cx, cy);\n if (this._resident.has(key) || this._inFlight.has(key)) continue;\n toLoad.push({ cx, cy });\n }\n }\n\n if (!this._primed) {\n this._primed = true;\n for (const { cx, cy } of toLoad) {\n this._request(cx, cy);\n }\n return;\n }\n\n toLoad.sort((a, b) => this._rangeDistance(a.cx, a.cy, core) - this._rangeDistance(b.cx, b.cy, core));\n\n const budget = Math.min(this._maxChunkLoadsPerFrame, toLoad.length);\n for (const { cx, cy } of toLoad.slice(0, budget)) {\n this._request(cx, cy);\n }\n }\n\n /**\n * Evict every chunk this instance has loaded and stop responding to\n * {@link update}. Does not affect chunks predating attachment or\n * installed by another source. Idempotent.\n *\n * Does not destroy the {@link ChunkSource} passed to the constructor: this\n * class only reads from it and never took ownership. A source with its own\n * `destroy()` (e.g. {@link import('./WorkerSampledChunkSource').createWorkerSampledChunkSource}'s,\n * which tears down a real `Worker`) must be destroyed separately by\n * whoever created it.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n\n for (const { cx, cy } of this._resident.values()) {\n this._layer._evictChunk(cx, cy);\n }\n this._resident.clear();\n this._inFlight.clear();\n }\n\n private _computeCoreRange(): ChunkRange {\n const layer = this._layer;\n const view = this._view;\n const bounds = view.getBounds();\n const centerX = view.center.x;\n const centerY = view.center.y;\n\n const shiftX = centerX * (1 - layer.parallaxX);\n const shiftY = centerY * (1 - layer.parallaxY);\n const scale = layer.parallaxScale;\n\n const layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;\n const layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;\n const layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;\n const layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;\n const topLeftTile = layer.pixelToTile(layerLeft, layerTop);\n const bottomRightTile = layer.pixelToTile(layerRight, layerBottom);\n\n const topLeftChunk = tileToChunkCoord(topLeftTile.tx, topLeftTile.ty, layer.chunkWidth, layer.chunkHeight);\n const bottomRightChunk = tileToChunkCoord(bottomRightTile.tx, bottomRightTile.ty, layer.chunkWidth, layer.chunkHeight);\n\n return {\n minCx: topLeftChunk.cx,\n minCy: topLeftChunk.cy,\n maxCx: bottomRightChunk.cx,\n maxCy: bottomRightChunk.cy,\n };\n }\n\n private _rangeDistance(cx: number, cy: number, range: ChunkRange): number {\n const dx = Math.max(range.minCx - cx, 0, cx - range.maxCx);\n const dy = Math.max(range.minCy - cy, 0, cy - range.maxCy);\n return Math.max(dx, dy);\n }\n\n private _unload(core: ChunkRange): void {\n for (const [key, { cx, cy }] of this._resident) {\n if (this._rangeDistance(cx, cy, core) > this._unloadRadius) {\n this._layer._evictChunk(cx, cy);\n this._resident.delete(key);\n }\n }\n }\n\n private _request(cx: number, cy: number): void {\n const key = chunkKey(cx, cy);\n const token = ++this._requestCounter;\n this._inFlight.set(key, token);\n\n let result: ChunkPayload | null | Promise<ChunkPayload | null>;\n try {\n result = this._source.getChunk(cx, cy);\n } catch (error) {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) threw synchronously.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n\n return;\n }\n\n if (isThenable(result)) {\n result.then(\n payload => {\n this._onResolved(key, cx, cy, token, payload);\n },\n (error: unknown) => {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) rejected.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n },\n );\n return;\n }\n\n this._onResolved(key, cx, cy, token, result);\n }\n\n /**\n * Ignore-on-resolve: only the `_destroyed` and in-flight-token checks\n * guard installation - a chunk that scrolled out of the wanted set while\n * its request was in flight is still installed if it resolves (installing\n * it is cheap and self-correcting: the next {@link update} call's unload\n * pass evicts it again if it's genuinely no longer wanted). There is no\n * edit-persistence to protect, so discarding is never destructive.\n */\n private _onResolved(key: string, cx: number, cy: number, token: number, payload: ChunkPayload | null): void {\n if (this._destroyed) return;\n if (this._inFlight.get(key) !== token) return;\n this._inFlight.delete(key);\n\n if (payload === null) return;\n\n this._layer._adoptChunk(cx, cy, payload);\n this._resident.set(key, { cx, cy });\n }\n}\n"],"mappings":";;;;AA+BA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,oCAAoC;AAE1C,MAAM,YAAY,IAAY,OAAuB,GAAG,GAAG,GAAG;AAE9D,MAAM,cAAc,UAClB,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAQ,MAA6B,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/F,IAAa,gBAAb,MAA2B;CACzB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAiB,4BAAY,IAAI,IAA0D;CAC3F,AAAiB,4BAAY,IAAI,IAAoB;CACrD,AAAQ,kBAAkB;CAC1B,AAAQ,UAAU;CAClB,AAAQ,aAAa;CAErB,AAAO,YA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AAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;IACjE,CAAC;GACH,CACF;GACA;EACF;EAEA,KAAK,YAAY,KAAK,IAAI,IAAI,OAAO,MAAM;CAC7C;;;;;;;;;CAUA,AAAQ,YAAY,KAAa,IAAY,IAAY,OAAe,SAAoC;EAC1G,IAAI,KAAK,YAAY;EACrB,IAAI,KAAK,UAAU,IAAI,GAAG,MAAM,OAAO;EACvC,KAAK,UAAU,OAAO,GAAG;EAEzB,IAAI,YAAY,MAAM;EAEtB,KAAK,OAAO,YAAY,IAAI,IAAI,OAAO;EACvC,KAAK,UAAU,IAAI,KAAK;GAAE;GAAI;EAAG,CAAC;CACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"ChunkStreamer.js","names":[],"sources":["../../src/ChunkStreamer.ts"],"sourcesContent":["import { logger, type View } from '@codexo/exojs';\n\nimport type { ChunkPayload, ChunkSource } from './ChunkSource';\nimport type { ChunkRange, TileLayer } from './TileLayer';\nimport { tileToChunkCoord } from './types';\n\n/**\n * Options for a {@link ChunkStreamer}. All optional.\n * @advanced\n */\nexport interface ChunkStreamerOptions {\n /**\n * Chunks within this many chunk-units (Chebyshev distance to the visible\n * chunk range) of the view are loaded. Default `1`.\n */\n readonly loadRadius?: number;\n /**\n * Own-resident chunks beyond this many chunk-units of the view are\n * evicted. Must be `>= loadRadius` - the gap between the two is\n * deliberate hysteresis that prevents load/unload thrashing when the\n * view sits near a chunk boundary. Default `2`.\n */\n readonly unloadRadius?: number;\n /**\n * Maximum number of new chunk loads issued per {@link ChunkStreamer.update}\n * call, after the very first call (which loads the entire initial wanted\n * set unbudgeted, so the starting view never pops in). Default `8`.\n */\n readonly maxChunkLoadsPerFrame?: number;\n}\n\nconst DEFAULT_LOAD_RADIUS = 1;\nconst DEFAULT_UNLOAD_RADIUS = 2;\nconst DEFAULT_MAX_CHUNK_LOADS_PER_FRAME = 8;\n\nconst chunkKey = (cx: number, cy: number): string => `${cx},${cy}`;\n\nconst isThenable = (value: unknown): value is Promise<ChunkPayload | null> =>\n value !== null && typeof value === 'object' && typeof (value as { then?: unknown }).then === 'function';\n\n/**\n * Drives {@link TileLayer._adoptChunk}/{@link TileLayer._evictChunk} calls\n * from a {@link View}'s position: chunks near the view are requested from a\n * {@link ChunkSource} and installed; chunks that scroll far enough away are\n * evicted. Works on both unbounded and bounded layers (a bounded-but-large\n * layer still benefits from not keeping every chunk resident at once) - for\n * a bounded layer, the wanted range is clamped to {@link TileLayer.chunkRange}.\n *\n * Touches only the {@link TileLayer} data layer -\n * {@link import('./TileLayerNode').TileLayerNode} reacts to\n * `_adoptChunk`/`_evictChunk` on its own via a structural listener, so this\n * class has no rendering dependency and no reference to any scene node.\n *\n * Tracks its own resident set (chunks *this instance* has loaded), never\n * touching chunks that predate its attachment or were installed by another\n * source.\n *\n * Tick it from your update loop, like {@link import('./TileAnimator').TileAnimator}:\n *\n * ```ts\n * const streamer = new ChunkStreamer(layer, mySource, view);\n * scene.systems.add({ update: () => streamer.update() });\n * ```\n *\n * @advanced\n */\nexport class ChunkStreamer {\n private readonly _layer: TileLayer;\n private readonly _source: ChunkSource;\n private readonly _view: View;\n private readonly _loadRadius: number;\n private readonly _unloadRadius: number;\n private readonly _maxChunkLoadsPerFrame: number;\n\n private readonly _resident = new Map<string, { readonly cx: number; readonly cy: number }>();\n private readonly _inFlight = new Map<string, number>();\n private _requestCounter = 0;\n private _primed = false;\n private _destroyed = false;\n\n public constructor(layer: TileLayer, source: ChunkSource, view: View, options?: ChunkStreamerOptions) {\n this._layer = layer;\n this._source = source;\n this._view = view;\n this._loadRadius = options?.loadRadius ?? DEFAULT_LOAD_RADIUS;\n this._unloadRadius = options?.unloadRadius ?? DEFAULT_UNLOAD_RADIUS;\n this._maxChunkLoadsPerFrame = options?.maxChunkLoadsPerFrame ?? DEFAULT_MAX_CHUNK_LOADS_PER_FRAME;\n\n if (this._unloadRadius < this._loadRadius) {\n throw new Error(`ChunkStreamer unloadRadius (${this._unloadRadius}) must be >= loadRadius (${this._loadRadius}).`);\n }\n }\n\n /** Number of chunks this instance currently has resident in the layer. */\n public get residentCount(): number {\n return this._resident.size;\n }\n\n /**\n * Recompute the wanted chunk set from the view's current position; evict\n * own-resident chunks that fell outside `unloadRadius`, then request\n * chunks newly inside `loadRadius`. The very first call loads the entire\n * initial wanted set unbudgeted; every later call is capped at\n * {@link ChunkStreamerOptions.maxChunkLoadsPerFrame}. No-op once\n * {@link destroy}ed.\n */\n public update(): void {\n if (this._destroyed) return;\n\n const core = this._computeCoreRange();\n\n this._unload(core);\n\n const range = this._layer.chunkRange();\n let minCx = core.minCx - this._loadRadius;\n let minCy = core.minCy - this._loadRadius;\n let maxCx = core.maxCx + this._loadRadius;\n let maxCy = core.maxCy + this._loadRadius;\n if (range !== null) {\n minCx = Math.max(minCx, range.minCx);\n minCy = Math.max(minCy, range.minCy);\n maxCx = Math.min(maxCx, range.maxCx);\n maxCy = Math.min(maxCy, range.maxCy);\n }\n\n const toLoad: Array<{ cx: number; cy: number }> = [];\n for (let cy = minCy; cy <= maxCy; cy++) {\n for (let cx = minCx; cx <= maxCx; cx++) {\n const key = chunkKey(cx, cy);\n if (this._resident.has(key) || this._inFlight.has(key)) continue;\n toLoad.push({ cx, cy });\n }\n }\n\n if (!this._primed) {\n this._primed = true;\n for (const { cx, cy } of toLoad) {\n this._request(cx, cy);\n }\n return;\n }\n\n toLoad.sort((a, b) => this._rangeDistance(a.cx, a.cy, core) - this._rangeDistance(b.cx, b.cy, core));\n\n const budget = Math.min(this._maxChunkLoadsPerFrame, toLoad.length);\n for (const { cx, cy } of toLoad.slice(0, budget)) {\n this._request(cx, cy);\n }\n }\n\n /**\n * Evict every chunk this instance has loaded and stop responding to\n * {@link update}. Does not affect chunks predating attachment or\n * installed by another source. Idempotent.\n *\n * Does not destroy the {@link ChunkSource} passed to the constructor: this\n * class only reads from it and never took ownership. A source with its own\n * `destroy()` (e.g. {@link import('./WorkerSampledChunkSource').createWorkerSampledChunkSource}'s,\n * which tears down a real `Worker`) must be destroyed separately by\n * whoever created it.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n\n for (const { cx, cy } of this._resident.values()) {\n this._layer._evictChunk(cx, cy);\n }\n this._resident.clear();\n this._inFlight.clear();\n }\n\n private _computeCoreRange(): ChunkRange {\n const layer = this._layer;\n const view = this._view;\n const bounds = view.getBounds();\n const centerX = view.center.x;\n const centerY = view.center.y;\n\n const shiftX = centerX * (1 - layer.parallaxX);\n const shiftY = centerY * (1 - layer.parallaxY);\n const scale = layer.parallaxScale;\n\n let layerLeft = layer.offsetX + (bounds.left - shiftX - layer.offsetX) / scale;\n let layerTop = layer.offsetY + (bounds.top - shiftY - layer.offsetY) / scale;\n let layerRight = layer.offsetX + (bounds.right - shiftX - layer.offsetX) / scale;\n let layerBottom = layer.offsetY + (bounds.bottom - shiftY - layer.offsetY) / scale;\n if (layer.projection.orientation === 'isometric') {\n let left = 0;\n let top = 0;\n let right = 0;\n let bottom = 0;\n for (const tileset of layer.tilesets) {\n left = Math.max(left, tileset.tileWidth - layer.tileWidth / 2 + tileset.offsetX);\n top = Math.max(top, layer.tileHeight + tileset.offsetY);\n right = Math.max(right, layer.tileWidth / 2 - tileset.offsetX);\n bottom = Math.max(bottom, tileset.tileHeight - layer.tileHeight - tileset.offsetY);\n }\n layerLeft -= left;\n layerTop -= top;\n layerRight += right;\n layerBottom += bottom;\n }\n const topLeftTile = layer.pixelToTile(layerLeft, layerTop);\n const bottomRightTile = layer.pixelToTile(layerRight, layerBottom);\n\n const topRightTile = layer.pixelToTile(layerRight, layerTop);\n const bottomLeftTile = layer.pixelToTile(layerLeft, layerBottom);\n const minTx = Math.min(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);\n const minTy = Math.min(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);\n const maxTx = Math.max(topLeftTile.tx, topRightTile.tx, bottomLeftTile.tx, bottomRightTile.tx);\n const maxTy = Math.max(topLeftTile.ty, topRightTile.ty, bottomLeftTile.ty, bottomRightTile.ty);\n const topLeftChunk = tileToChunkCoord(minTx, minTy, layer.chunkWidth, layer.chunkHeight);\n const bottomRightChunk = tileToChunkCoord(maxTx, maxTy, layer.chunkWidth, layer.chunkHeight);\n\n return {\n minCx: topLeftChunk.cx,\n minCy: topLeftChunk.cy,\n maxCx: bottomRightChunk.cx,\n maxCy: bottomRightChunk.cy,\n };\n }\n\n private _rangeDistance(cx: number, cy: number, range: ChunkRange): number {\n const dx = Math.max(range.minCx - cx, 0, cx - range.maxCx);\n const dy = Math.max(range.minCy - cy, 0, cy - range.maxCy);\n return Math.max(dx, dy);\n }\n\n private _unload(core: ChunkRange): void {\n for (const [key, { cx, cy }] of this._resident) {\n if (this._rangeDistance(cx, cy, core) > this._unloadRadius) {\n this._layer._evictChunk(cx, cy);\n this._resident.delete(key);\n }\n }\n }\n\n private _request(cx: number, cy: number): void {\n const key = chunkKey(cx, cy);\n const token = ++this._requestCounter;\n this._inFlight.set(key, token);\n\n let result: ChunkPayload | null | Promise<ChunkPayload | null>;\n try {\n result = this._source.getChunk(cx, cy);\n } catch (error) {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) threw synchronously.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n\n return;\n }\n\n if (isThenable(result)) {\n result.then(\n payload => {\n this._onResolved(key, cx, cy, token, payload);\n },\n (error: unknown) => {\n this._inFlight.delete(key);\n logger.warn(`ChunkStreamer: source.getChunk(${cx}, ${cy}) rejected.`, {\n source: 'ChunkStreamer',\n error: error instanceof Error ? error : new Error(String(error)),\n });\n },\n );\n return;\n }\n\n this._onResolved(key, cx, cy, token, result);\n }\n\n /**\n * Ignore-on-resolve: only the `_destroyed` and in-flight-token checks\n * guard installation - a chunk that scrolled out of the wanted set while\n * its request was in flight is still installed if it resolves (installing\n * it is cheap and self-correcting: the next {@link update} call's unload\n * pass evicts it again if it's genuinely no longer wanted). There is no\n * edit-persistence to protect, so discarding is never destructive.\n */\n private _onResolved(key: string, cx: number, cy: number, token: number, payload: ChunkPayload | null): void {\n if (this._destroyed) return;\n if (this._inFlight.get(key) !== token) return;\n this._inFlight.delete(key);\n\n if (payload === null) return;\n\n this._layer._adoptChunk(cx, cy, payload);\n this._resident.set(key, { cx, cy });\n }\n}\n"],"mappings":";;;;AA+BA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,oCAAoC;AAE1C,MAAM,YAAY,IAAY,OAAuB,GAAG,GAAG,GAAG;AAE9D,MAAM,cAAc,UAClB,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAQ,MAA6B,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B/F,IAAa,gBAAb,MAA2B;CACzB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAiB,4BAAY,IAAI,IAA0D;CAC3F,AAAiB,4BAAY,IAAI,IAAoB;CACrD,AAAQ,kBAAkB;CAC1B,AAAQ,UAAU;CAClB,AAAQ,aAAa;CAErB,AAAO,YAAY,OAAkB,QAAqB,MAAY,SAAgC;EACpG,KAAK,SAAS;EACd,KAAK,UAAU;EACf,KAAK,QAAQ;EACb,KAAK,cAAc,SAAS,cAAc;EAC1C,KAAK,gBAAgB,SAAS,gBAAgB;EAC9C,KAAK,yBAAyB,SAAS,yBAAyB;EAEhE,IAAI,KAAK,gBAAgB,KAAK,aAC5B,MAAM,IAAI,MAAM,+BAA+B,KAAK,cAAc,2BAA2B,KAAK,YAAY,GAAG;CAErH;;CAGA,IAAW,gBAAwB;EACjC,OAAO,KAAK,UAAU;CACxB;;;;;;;;;CAUA,AAAO,SAAe;EACpB,IAAI,KAAK,YAAY;EAErB,MAAM,OAAO,KAAK,kBAAkB;EAEpC,KAAK,QAAQ,IAAI;EAEjB,MAAM,QAAQ,KAAK,OAAO,WA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apObject.d.ts
CHANGED
|
@@ -35,9 +35,9 @@ export interface MapObjectDescriptor {
|
|
|
35
35
|
readonly kind: string | null;
|
|
36
36
|
/** Object name; may be empty and is not unique. */
|
|
37
37
|
readonly name: string;
|
|
38
|
-
/** X of the object origin in
|
|
38
|
+
/** X of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */
|
|
39
39
|
readonly x: number;
|
|
40
|
-
/** Y of the object origin in
|
|
40
|
+
/** Y of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */
|
|
41
41
|
readonly y: number;
|
|
42
42
|
/** Bounding width in px (0 for points). */
|
|
43
43
|
readonly width: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapObject.d.ts","sourceRoot":"","sources":["../../src/MapObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,
|
|
1
|
+
{"version":3,"file":"MapObject.d.ts","sourceRoot":"","sources":["../../src/MapObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uGAAuG;IACvG,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,uGAAuG;IACvG,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,WAAY,aAAa,SAAS,WAAW,KAAG,mBAY9E,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAAmB,OAAO,KAAG,SAAS,CAAC,mBAAmB,CAM1F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapObject.js","names":[],"sources":["../../src/MapObject.ts"],"sourcesContent":["import type { ObjectLayer, TileMapObject } from './ObjectLayer';\nimport type { TileMap } from './TileMap';\nimport type { TileProperties } from './types';\n\n/**\n * A format-neutral view of one map object, as handed to a\n * {@link import('./MapObjectSpawner').MapObjectFactory}.\n *\n * The descriptor is what game code writes against: it resolves the two things\n * that differ between authoring formats - stable identity and the dispatch\n * key - and pairs the object with the layer it came from. The parsed object\n * itself stays reachable through {@link object}, and the untouched source\n * record through {@link TileMapObject.source}.\n */\nexport interface MapObjectDescriptor {\n /**\n * Stable identity for this object.\n *\n * Uniqueness domain is **one {@link TileMap}**: Tiled object ids are unique\n * within a map, and LDtk entity iids are unique globally, so an LDtk-sourced\n * id keeps that stronger guarantee. Combine with the owning level's id if a\n * world-wide key is needed.\n *\n * Derived from {@link TileMapObject.sourceId} when the format supplies one,\n * otherwise from the numeric {@link TileMapObject.id}.\n */\n readonly id: string;\n /**\n * Canonical dispatch key - the object's class/type string, or `null` when the\n * source declares none.\n *\n * LDtk fills it with the entity definition identifier, Tiled with the\n * object's class. A {@link import('./MapObjectSpawner').MapObjectSpawner}\n * uses it to pick a factory unless an `identify` strategy overrides that.\n */\n readonly kind: string | null;\n /** Object name; may be empty and is not unique. */\n readonly name: string;\n /** X of the object origin in
|
|
1
|
+
{"version":3,"file":"MapObject.js","names":[],"sources":["../../src/MapObject.ts"],"sourcesContent":["import type { ObjectLayer, TileMapObject } from './ObjectLayer';\nimport type { TileMap } from './TileMap';\nimport type { TileProperties } from './types';\n\n/**\n * A format-neutral view of one map object, as handed to a\n * {@link import('./MapObjectSpawner').MapObjectFactory}.\n *\n * The descriptor is what game code writes against: it resolves the two things\n * that differ between authoring formats - stable identity and the dispatch\n * key - and pairs the object with the layer it came from. The parsed object\n * itself stays reachable through {@link object}, and the untouched source\n * record through {@link TileMapObject.source}.\n */\nexport interface MapObjectDescriptor {\n /**\n * Stable identity for this object.\n *\n * Uniqueness domain is **one {@link TileMap}**: Tiled object ids are unique\n * within a map, and LDtk entity iids are unique globally, so an LDtk-sourced\n * id keeps that stronger guarantee. Combine with the owning level's id if a\n * world-wide key is needed.\n *\n * Derived from {@link TileMapObject.sourceId} when the format supplies one,\n * otherwise from the numeric {@link TileMapObject.id}.\n */\n readonly id: string;\n /**\n * Canonical dispatch key - the object's class/type string, or `null` when the\n * source declares none.\n *\n * LDtk fills it with the entity definition identifier, Tiled with the\n * object's class. A {@link import('./MapObjectSpawner').MapObjectSpawner}\n * uses it to pick a factory unless an `identify` strategy overrides that.\n */\n readonly kind: string | null;\n /** Object name; may be empty and is not unique. */\n readonly name: string;\n /** X of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */\n readonly x: number;\n /** Y of the object origin in layer coordinates; use layer.getDisplayObject for projected placement. */\n readonly y: number;\n /** Bounding width in px (0 for points). */\n readonly width: number;\n /** Bounding height in px (0 for points). */\n readonly height: number;\n /** Rotation in degrees, clockwise. See {@link TileMapObject} for the pivot. */\n readonly rotation: number;\n /** The object's immutable custom properties. */\n readonly properties: TileProperties;\n /** The object layer this object was authored on, with its placement metadata. */\n readonly layer: ObjectLayer;\n /** The parsed object itself - narrow on `object.kind` to read geometry. */\n readonly object: TileMapObject;\n}\n\n/**\n * Build the {@link MapObjectDescriptor} for one object of `layer`.\n *\n * Exposed for code that spawns from a hand-picked object rather than from a\n * whole map; {@link mapObjectDescriptors} covers the common case.\n */\nexport const mapObjectDescriptor = (object: TileMapObject, layer: ObjectLayer): MapObjectDescriptor => ({\n id: object.sourceId ?? String(object.id),\n kind: object.type === '' ? null : object.type,\n name: object.name,\n x: object.x,\n y: object.y,\n width: object.width,\n height: object.height,\n rotation: object.rotation,\n properties: object.properties,\n layer,\n object,\n});\n\n/**\n * Every object of `map`, in a defined order: object-layer order first, then\n * object order within each layer.\n *\n * This is the order a {@link import('./MapObjectSpawner').MapObjectSpawner}\n * spawns in, so the same map always produces the same sequence.\n */\nexport const mapObjectDescriptors = function* (map: TileMap): Generator<MapObjectDescriptor> {\n for (const layer of map.objectLayers) {\n for (const object of layer.objects) {\n yield mapObjectDescriptor(object, layer);\n }\n }\n};\n"],"mappings":";;;;;;;AA8DA,MAAa,uBAAuB,QAAuB,WAA6C;CACtG,IAAI,OAAO,YAAY,OAAO,OAAO,EAAE;CACvC,MAAM,OAAO,SAAS,KAAK,OAAO,OAAO;CACzC,MAAM,OAAO;CACb,GAAG,OAAO;CACV,GAAG,OAAO;CACV,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,YAAY,OAAO;CACnB;CACA;AACF;;;;;;;;AASA,MAAa,uBAAuB,WAAW,KAA8C;CAC3F,KAAK,MAAM,SAAS,IAAI,cACtB,KAAK,MAAM,UAAU,MAAM,SACzB,MAAM,oBAAoB,QAAQ,KAAK;AAG7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapObjectSpawner.d.ts","sourceRoot":"","sources":["../../src/MapObjectSpawner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,8CAA8C;AAC9C,MAAM,MAAM,mBAAmB;AAC7B,yFAAyF;AACvF,cAAc;AAChB,kEAAkE;GAChE,cAAc;AAChB,sEAAsE;GACpE,gBAAgB,CAAC;AAErB;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAyB,IAAI,mBAAmB;IAChD,SAAgB,MAAM,EAAE,mBAAmB,CAAC;IAC5C,gEAAgE;IAChE,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,kEAAkE;IAClE,SAAgB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"MapObjectSpawner.d.ts","sourceRoot":"","sources":["../../src/MapObjectSpawner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,8CAA8C;AAC9C,MAAM,MAA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;;;OAOG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"MapSpawnSession.d.ts","sourceRoot":"","sources":["../../src/MapSpawnSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe,CAAC,MAAM,SAAS,WAAW,CAAE,YAAW,WAAW;IAC7E;;;OAGG;IACH,SAAgB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAE3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,UAAU,CAAS;IAqB3B,uCAAuC;IACvC,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;;;;;OAOG;IACI,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/C;IAED,+DAA+D;IACxD,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpC;IAED;;;;;;;;OAQG;IACI,OAAO,IAAI,IAAI,CAoBrB;CACF"}
|
package/dist/esm/MapWorld.d.ts
CHANGED
|
@@ -16,14 +16,14 @@ export interface MapBounds {
|
|
|
16
16
|
* not interpretable.
|
|
17
17
|
*/
|
|
18
18
|
export declare const MapLevelSide: {
|
|
19
|
-
readonly North:
|
|
20
|
-
readonly South:
|
|
21
|
-
readonly West:
|
|
22
|
-
readonly East:
|
|
23
|
-
readonly Overlap:
|
|
24
|
-
readonly Below:
|
|
25
|
-
readonly Above:
|
|
26
|
-
readonly Unknown:
|
|
19
|
+
readonly North: 'north';
|
|
20
|
+
readonly South: 'south';
|
|
21
|
+
readonly West: 'west';
|
|
22
|
+
readonly East: 'east';
|
|
23
|
+
readonly Overlap: 'overlap';
|
|
24
|
+
readonly Below: 'below';
|
|
25
|
+
readonly Above: 'above';
|
|
26
|
+
readonly Unknown: 'unknown';
|
|
27
27
|
};
|
|
28
28
|
/** Side discriminant for a {@link MapLevelNeighbour}. */
|
|
29
29
|
export type MapLevelSide = (typeof MapLevelSide)[keyof typeof MapLevelSide];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapWorld.d.ts","sourceRoot":"","sources":["../../src/MapWorld.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"MapWorld.d.ts","sourceRoot":"","sources":["../../src/MapWorld.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,gEAAgE;AAChE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;aACvB,KAAK,EAAE,OAAO;aACd,KAAK,EAAE,OAAO;aACd,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,OAAO,EAAE,SAAS;aAClB,KAAK,EAAE,OAAO;aACd,KAAK,EAAE,OAAO;aACd,OAAO,EAAE,SAAS;CACV,CAAC;AAEX,yDAAyD;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,qFAAq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AED,0DAA0D;IACnD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpC;IAEM,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACjF,SAAS,CAAC,OAAO,EAAE,MAAM,SAAS,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAwEnJ;;;;;;;OAOG;IACI,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAoBtC;IAED;;;;;;OAMG;IACI,OAAO,IAAI,IAAI,CAoBrB;YAEa,QAAQ;CAqCvB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TileProjection } from './TileProjection';
|
|
1
2
|
import type { ResolvedTile, TileProperties, TilePropertyValue } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Geometry kinds for a {@link TileMapObject}, as an `as const` value object.
|
|
@@ -10,13 +11,13 @@ import type { ResolvedTile, TileProperties, TilePropertyValue } from './types';
|
|
|
10
11
|
* @stable
|
|
11
12
|
*/
|
|
12
13
|
export declare const ObjectKind: {
|
|
13
|
-
readonly Rectangle:
|
|
14
|
-
readonly Ellipse:
|
|
15
|
-
readonly Polygon:
|
|
16
|
-
readonly Polyline:
|
|
17
|
-
readonly Point:
|
|
18
|
-
readonly Tile:
|
|
19
|
-
readonly Text:
|
|
14
|
+
readonly Rectangle: 'rectangle';
|
|
15
|
+
readonly Ellipse: 'ellipse';
|
|
16
|
+
readonly Polygon: 'polygon';
|
|
17
|
+
readonly Polyline: 'polyline';
|
|
18
|
+
readonly Point: 'point';
|
|
19
|
+
readonly Tile: 'tile';
|
|
20
|
+
readonly Text: 'text';
|
|
20
21
|
};
|
|
21
22
|
/** Geometry discriminant for a {@link TileMapObject}. */
|
|
22
23
|
export type ObjectKind = (typeof ObjectKind)[keyof typeof ObjectKind];
|
|
@@ -48,9 +49,9 @@ interface TileMapObjectBase<P extends TileProperties = TileProperties> {
|
|
|
48
49
|
readonly name: string;
|
|
49
50
|
/** Object class/type string (Tiled `type`/`class`; may be empty). */
|
|
50
51
|
readonly type: string;
|
|
51
|
-
/** X of the object origin in
|
|
52
|
+
/** X of the object origin in layer coordinates; logical pixels when the layer has a projection. */
|
|
52
53
|
readonly x: number;
|
|
53
|
-
/** Y of the object origin in
|
|
54
|
+
/** Y of the object origin in layer coordinates; logical pixels when the layer has a projection. */
|
|
54
55
|
readonly y: number;
|
|
55
56
|
/** Bounding width in px (0 for points). */
|
|
56
57
|
readonly width: number;
|
|
@@ -108,6 +109,8 @@ export interface PolylineObject<P extends TileProperties = TileProperties> exten
|
|
|
108
109
|
* map, bottom-centre on an isometric one) and rotates the tile image about
|
|
109
110
|
* that point, so a non-zero {@link TileMapObjectBase.rotation} on a tile
|
|
110
111
|
* object still pivots about the source anchor rather than about `(x, y)`.
|
|
112
|
+
* Isometric Tiled objects expose this anchor as `rotationOrigin`;
|
|
113
|
+
* `getDisplayObject` projects both the unrotated corner and this pivot.
|
|
111
114
|
*
|
|
112
115
|
* The owning tileset's drawing offset (Tiled `tileoffset`, reachable as
|
|
113
116
|
* `tile.tileset.offsetX`/`offsetY`) is likewise **not** folded into `x`/`y`.
|
|
@@ -118,6 +121,8 @@ export interface PolylineObject<P extends TileProperties = TileProperties> exten
|
|
|
118
121
|
export interface TileObject<P extends TileProperties = TileProperties> extends TileMapObjectBase<P> {
|
|
119
122
|
readonly kind: typeof ObjectKind.Tile;
|
|
120
123
|
readonly tile: ResolvedTile;
|
|
124
|
+
/** Image rotation pivot in layer coordinates, logical when projected. Adapters may omit it when unavailable. */
|
|
125
|
+
readonly rotationOrigin?: ObjectPoint;
|
|
121
126
|
}
|
|
122
127
|
/** Text styling options carried by a {@link TextObject}. */
|
|
123
128
|
export interface TextStyle {
|
|
@@ -209,6 +214,8 @@ export interface ObjectQuery {
|
|
|
209
214
|
}
|
|
210
215
|
/** Construction options for an {@link ObjectLayer}. */
|
|
211
216
|
export interface ObjectLayerOptions {
|
|
217
|
+
/** Object geometry uses logical pixels when supplied; display placement is available through getDisplayObject. */
|
|
218
|
+
readonly projection?: TileProjection;
|
|
212
219
|
/** Layer id (unique within the map). */
|
|
213
220
|
readonly id: number;
|
|
214
221
|
/** Layer name. */
|
|
@@ -284,8 +291,10 @@ export interface ObjectLayerOptions {
|
|
|
284
291
|
* @advanced
|
|
285
292
|
*/
|
|
286
293
|
export declare class ObjectLayer<S extends ObjectSchema = ObjectSchema> {
|
|
294
|
+
/** Projection of the logical object geometry, or undefined for ordinary display-space objects. */
|
|
295
|
+
readonly projection: TileProjection | undefined;
|
|
287
296
|
/** Layer-kind discriminant (distinguishes object layers from tile layers). */
|
|
288
|
-
readonly kind:
|
|
297
|
+
readonly kind: 'object';
|
|
289
298
|
/** Layer id (unique within the map). */
|
|
290
299
|
readonly id: number;
|
|
291
300
|
/** Layer name. */
|
|
@@ -328,6 +337,13 @@ export declare class ObjectLayer<S extends ObjectSchema = ObjectSchema> {
|
|
|
328
337
|
/** The objects in this layer (insertion order). */
|
|
329
338
|
readonly objects: readonly TileMapObject[];
|
|
330
339
|
constructor(options: ObjectLayerOptions);
|
|
340
|
+
/**
|
|
341
|
+
* Returns display-space geometry including the layer offset. Isometric
|
|
342
|
+
* rectangles become polygons; ellipses retain their exact affine shape.
|
|
343
|
+
* Tile/text dimensions remain display pixels. Parallax and scene transforms
|
|
344
|
+
* are applied by the consumer, after this conversion.
|
|
345
|
+
*/
|
|
346
|
+
getDisplayObject(object: TileMapObject): TileMapObject;
|
|
331
347
|
/** Objects matching every specified criterion of `filter`. Returns a fresh array. */
|
|
332
348
|
query(filter?: ObjectQuery): TileMapObject[];
|
|
333
349
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectLayer.d.ts","sourceRoot":"","sources":["../../src/Ob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,EAAE,CAAC,CAAC,CAAC,CAE3E;IAED;;;;OAIG;IACI,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,CAEvF;IAED;;;;;OAKG;IACI,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAE7H;IAED,oDAAoD;IAC7C,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE1D;IAED,sDAAsD;IAC/C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE9D;CACF"}
|
package/dist/esm/ObjectLayer.js
CHANGED
|
@@ -76,6 +76,8 @@ const tilePropertyValueEquals = (a, b) => {
|
|
|
76
76
|
* @advanced
|
|
77
77
|
*/
|
|
78
78
|
var ObjectLayer = class {
|
|
79
|
+
/** Projection of the logical object geometry, or undefined for ordinary display-space objects. */
|
|
80
|
+
projection;
|
|
79
81
|
/** Layer-kind discriminant (distinguishes object layers from tile layers). */
|
|
80
82
|
kind = "object";
|
|
81
83
|
/** Layer id (unique within the map). */
|
|
@@ -121,6 +123,7 @@ var ObjectLayer = class {
|
|
|
121
123
|
objects;
|
|
122
124
|
constructor(options) {
|
|
123
125
|
this.id = options.id;
|
|
126
|
+
this.projection = options.projection;
|
|
124
127
|
this.name = options.name ?? "";
|
|
125
128
|
this.class = options.class ?? "";
|
|
126
129
|
this.visible = options.visible ?? true;
|
|
@@ -136,6 +139,31 @@ var ObjectLayer = class {
|
|
|
136
139
|
this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});
|
|
137
140
|
this.objects = options.objects ? Object.freeze([...options.objects]) : Object.freeze([]);
|
|
138
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Returns display-space geometry including the layer offset. Isometric
|
|
144
|
+
* rectangles become polygons; ellipses retain their exact affine shape.
|
|
145
|
+
* Tile/text dimensions remain display pixels. Parallax and scene transforms
|
|
146
|
+
* are applied by the consumer, after this conversion.
|
|
147
|
+
*/
|
|
148
|
+
getDisplayObject(object) {
|
|
149
|
+
const projected = this.projection?.projectObject(object) ?? object;
|
|
150
|
+
const position = {
|
|
151
|
+
x: projected.x + this.offsetX,
|
|
152
|
+
y: projected.y + this.offsetY
|
|
153
|
+
};
|
|
154
|
+
if (projected.kind === "tile" && projected.rotationOrigin) return {
|
|
155
|
+
...projected,
|
|
156
|
+
...position,
|
|
157
|
+
rotationOrigin: {
|
|
158
|
+
x: projected.rotationOrigin.x + this.offsetX,
|
|
159
|
+
y: projected.rotationOrigin.y + this.offsetY
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
...projected,
|
|
164
|
+
...position
|
|
165
|
+
};
|
|
166
|
+
}
|
|
139
167
|
/** Objects matching every specified criterion of `filter`. Returns a fresh array. */
|
|
140
168
|
query(filter = {}) {
|
|
141
169
|
return this.objects.filter((object) => {
|