@codexo/exojs-tilemap 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +7 -163
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +12 -20
  5. package/dist/esm/ChunkSource.d.ts +0 -33
  6. package/dist/esm/ChunkSource.d.ts.map +0 -1
  7. package/dist/esm/ChunkStreamer.d.ts +0 -104
  8. package/dist/esm/ChunkStreamer.d.ts.map +0 -1
  9. package/dist/esm/ChunkStreamer.js +0 -229
  10. package/dist/esm/ChunkStreamer.js.map +0 -1
  11. package/dist/esm/ImageLayer.d.ts +0 -89
  12. package/dist/esm/ImageLayer.d.ts.map +0 -1
  13. package/dist/esm/ImageLayer.js +0 -74
  14. package/dist/esm/ImageLayer.js.map +0 -1
  15. package/dist/esm/ImageLayerNode.d.ts +0 -91
  16. package/dist/esm/ImageLayerNode.d.ts.map +0 -1
  17. package/dist/esm/ImageLayerNode.js +0 -210
  18. package/dist/esm/ImageLayerNode.js.map +0 -1
  19. package/dist/esm/MapObject.d.ts +0 -70
  20. package/dist/esm/MapObject.d.ts.map +0 -1
  21. package/dist/esm/MapObject.js +0 -34
  22. package/dist/esm/MapObject.js.map +0 -1
  23. package/dist/esm/MapObjectSpawner.d.ts +0 -133
  24. package/dist/esm/MapObjectSpawner.d.ts.map +0 -1
  25. package/dist/esm/MapObjectSpawner.js +0 -147
  26. package/dist/esm/MapObjectSpawner.js.map +0 -1
  27. package/dist/esm/MapSpawnSession.d.ts +0 -46
  28. package/dist/esm/MapSpawnSession.d.ts.map +0 -1
  29. package/dist/esm/MapSpawnSession.js +0 -88
  30. package/dist/esm/MapSpawnSession.js.map +0 -1
  31. package/dist/esm/MapWorld.d.ts +0 -134
  32. package/dist/esm/MapWorld.d.ts.map +0 -1
  33. package/dist/esm/MapWorld.js +0 -150
  34. package/dist/esm/MapWorld.js.map +0 -1
  35. package/dist/esm/MapWorldRuntime.d.ts +0 -180
  36. package/dist/esm/MapWorldRuntime.d.ts.map +0 -1
  37. package/dist/esm/MapWorldRuntime.js +0 -261
  38. package/dist/esm/MapWorldRuntime.js.map +0 -1
  39. package/dist/esm/ObjectLayer.d.ts +0 -379
  40. package/dist/esm/ObjectLayer.d.ts.map +0 -1
  41. package/dist/esm/ObjectLayer.js +0 -221
  42. package/dist/esm/ObjectLayer.js.map +0 -1
  43. package/dist/esm/SampledChunkSource.d.ts +0 -43
  44. package/dist/esm/SampledChunkSource.d.ts.map +0 -1
  45. package/dist/esm/SampledChunkSource.js +0 -48
  46. package/dist/esm/SampledChunkSource.js.map +0 -1
  47. package/dist/esm/TileAnimator.d.ts +0 -72
  48. package/dist/esm/TileAnimator.d.ts.map +0 -1
  49. package/dist/esm/TileAnimator.js +0 -158
  50. package/dist/esm/TileAnimator.js.map +0 -1
  51. package/dist/esm/TileChunk.d.ts +0 -103
  52. package/dist/esm/TileChunk.d.ts.map +0 -1
  53. package/dist/esm/TileChunk.js +0 -194
  54. package/dist/esm/TileChunk.js.map +0 -1
  55. package/dist/esm/TileChunkNode.d.ts +0 -2
  56. package/dist/esm/TileChunkNode.d.ts.map +0 -1
  57. package/dist/esm/TileChunkNode.js +0 -145
  58. package/dist/esm/TileChunkNode.js.map +0 -1
  59. package/dist/esm/TileLayer.d.ts +0 -286
  60. package/dist/esm/TileLayer.d.ts.map +0 -1
  61. package/dist/esm/TileLayer.js +0 -526
  62. package/dist/esm/TileLayer.js.map +0 -1
  63. package/dist/esm/TileLayerNode.d.ts +0 -129
  64. package/dist/esm/TileLayerNode.d.ts.map +0 -1
  65. package/dist/esm/TileLayerNode.js +0 -245
  66. package/dist/esm/TileLayerNode.js.map +0 -1
  67. package/dist/esm/TileMap.d.ts +0 -317
  68. package/dist/esm/TileMap.d.ts.map +0 -1
  69. package/dist/esm/TileMap.js +0 -406
  70. package/dist/esm/TileMap.js.map +0 -1
  71. package/dist/esm/TileMapBand.d.ts +0 -80
  72. package/dist/esm/TileMapBand.d.ts.map +0 -1
  73. package/dist/esm/TileMapBand.js +0 -155
  74. package/dist/esm/TileMapBand.js.map +0 -1
  75. package/dist/esm/TileMapNode.d.ts +0 -92
  76. package/dist/esm/TileMapNode.d.ts.map +0 -1
  77. package/dist/esm/TileMapNode.js +0 -134
  78. package/dist/esm/TileMapNode.js.map +0 -1
  79. package/dist/esm/TileMapView.d.ts +0 -248
  80. package/dist/esm/TileMapView.d.ts.map +0 -1
  81. package/dist/esm/TileMapView.js +0 -394
  82. package/dist/esm/TileMapView.js.map +0 -1
  83. package/dist/esm/TileProjection.d.ts +0 -59
  84. package/dist/esm/TileProjection.d.ts.map +0 -1
  85. package/dist/esm/TileProjection.js +0 -106
  86. package/dist/esm/TileProjection.js.map +0 -1
  87. package/dist/esm/TileSet.d.ts +0 -116
  88. package/dist/esm/TileSet.d.ts.map +0 -1
  89. package/dist/esm/TileSet.js +0 -168
  90. package/dist/esm/TileSet.js.map +0 -1
  91. package/dist/esm/WangSet.d.ts +0 -80
  92. package/dist/esm/WangSet.d.ts.map +0 -1
  93. package/dist/esm/WangSet.js +0 -73
  94. package/dist/esm/WangSet.js.map +0 -1
  95. package/dist/esm/WorkerSampledChunkSource.d.ts +0 -94
  96. package/dist/esm/WorkerSampledChunkSource.d.ts.map +0 -1
  97. package/dist/esm/WorkerSampledChunkSource.js +0 -113
  98. package/dist/esm/WorkerSampledChunkSource.js.map +0 -1
  99. package/dist/esm/autoTile.d.ts +0 -88
  100. package/dist/esm/autoTile.d.ts.map +0 -1
  101. package/dist/esm/autoTile.js +0 -173
  102. package/dist/esm/autoTile.js.map +0 -1
  103. package/dist/esm/chunkGeometry.d.ts +0 -2
  104. package/dist/esm/chunkGeometry.d.ts.map +0 -1
  105. package/dist/esm/chunkGeometry.js +0 -116
  106. package/dist/esm/chunkGeometry.js.map +0 -1
  107. package/dist/esm/index.d.ts +0 -2
  108. package/dist/esm/index.d.ts.map +0 -1
  109. package/dist/esm/index.js +0 -27
  110. package/dist/esm/nodeBounds.d.ts +0 -2
  111. package/dist/esm/nodeBounds.d.ts.map +0 -1
  112. package/dist/esm/nodeBounds.js +0 -40
  113. package/dist/esm/nodeBounds.js.map +0 -1
  114. package/dist/esm/pixelSnap.d.ts +0 -2
  115. package/dist/esm/pixelSnap.d.ts.map +0 -1
  116. package/dist/esm/pixelSnap.js +0 -21
  117. package/dist/esm/pixelSnap.js.map +0 -1
  118. package/dist/esm/projectObject.d.ts +0 -4
  119. package/dist/esm/projectObject.d.ts.map +0 -1
  120. package/dist/esm/projectObject.js +0 -87
  121. package/dist/esm/projectObject.js.map +0 -1
  122. package/dist/esm/public.d.ts +0 -48
  123. package/dist/esm/public.d.ts.map +0 -1
  124. package/dist/esm/tileCollision.d.ts +0 -190
  125. package/dist/esm/tileCollision.d.ts.map +0 -1
  126. package/dist/esm/tileCollision.js +0 -399
  127. package/dist/esm/tileCollision.js.map +0 -1
  128. package/dist/esm/tileWord.d.ts +0 -2
  129. package/dist/esm/tileWord.d.ts.map +0 -1
  130. package/dist/esm/tileWord.js +0 -16
  131. package/dist/esm/tileWord.js.map +0 -1
  132. package/dist/esm/tilemapExtension.d.ts +0 -20
  133. package/dist/esm/tilemapExtension.d.ts.map +0 -1
  134. package/dist/esm/tilemapExtension.js +0 -53
  135. package/dist/esm/tilemapExtension.js.map +0 -1
  136. package/dist/esm/tilemapSerializers.d.ts +0 -2
  137. package/dist/esm/tilemapSerializers.d.ts.map +0 -1
  138. package/dist/esm/tilemapSerializers.js +0 -54
  139. package/dist/esm/tilemapSerializers.js.map +0 -1
  140. package/dist/esm/types.d.ts +0 -231
  141. package/dist/esm/types.d.ts.map +0 -1
  142. package/dist/esm/types.js +0 -129
  143. package/dist/esm/types.js.map +0 -1
  144. package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +0 -2
  145. package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +0 -1
  146. package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +0 -376
  147. package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +0 -1
  148. package/dist/esm/webgl2/shaders/tile-chunk.frag.js +0 -6
  149. package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +0 -1
  150. package/dist/esm/webgl2/shaders/tile-chunk.vert.js +0 -6
  151. package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +0 -1
  152. package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +0 -2
  153. package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +0 -1
  154. package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +0 -539
  155. package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +0 -1
  156. package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +0 -6
  157. package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +0 -1
@@ -1,194 +0,0 @@
1
- import { validateInteger } from "./types.js";
2
-
3
- //#region src/TileChunk.ts
4
- /**
5
- * A compact, fixed-size chunk of tile data within a layer.
6
- *
7
- * Storage is a single {@link Uint32Array} of length `width * height`,
8
- * laid out row-major. Each cell is a packed tile word (0 = empty).
9
- * Chunk coordinates are signed to support future infinite maps.
10
- *
11
- * The backing array is **private** - external code cannot mutate storage
12
- * directly. All mutation must flow through {@link TileLayer} public APIs,
13
- * which call the package-internal `_setRawAt` method.
14
- *
15
- * The chunk tracks a revision counter that increments on every mutation
16
- * so the future renderer can detect which chunks need GPU rebuilds.
17
- *
18
- * @advanced
19
- */
20
- var TileChunk = class {
21
- /** Signed chunk X coordinate. */
22
- cx;
23
- /** Signed chunk Y coordinate. */
24
- cy;
25
- /** Width of this chunk in tiles. */
26
- width;
27
- /** Height of this chunk in tiles. */
28
- height;
29
- /** Packed tile storage (row-major). Private - never exposed directly. */
30
- _tiles;
31
- /** Whether every cell in this chunk is empty (0). Lazy-computed. */
32
- _empty = null;
33
- /** Monotonic revision counter - incremented on every mutation. */
34
- _revision = 0;
35
- /**
36
- * Render-node-owned callbacks notified whenever `_revision` advances.
37
- * `TileChunkNode.pages` caches geometry against `revision`, but that cache
38
- * is only consulted from `render()` - a call the engine skips entirely for
39
- * a content-clean subtree under a `RetainedContainer`. Without
40
- * this push, an in-place tile edit after capture would replay stale cached
41
- * geometry forever. Package-internal; not part of {@link ReadonlyTileChunk}.
42
- */
43
- _dirtyListeners = null;
44
- /**
45
- * @param cx Signed chunk X coordinate (must be finite safe integer).
46
- * @param cy Signed chunk Y coordinate (must be finite safe integer).
47
- * @param width Chunk width in tiles (positive safe integer).
48
- * @param height Chunk height in tiles (positive safe integer).
49
- * @param source Optional source data to copy (must match length).
50
- */
51
- constructor(cx, cy, width, height, source) {
52
- if (!Number.isFinite(cx) || !Number.isInteger(cx) || !Number.isSafeInteger(cx)) throw new Error(`TileChunk cx must be a finite safe integer (got ${cx}).`);
53
- if (!Number.isFinite(cy) || !Number.isInteger(cy) || !Number.isSafeInteger(cy)) throw new Error(`TileChunk cy must be a finite safe integer (got ${cy}).`);
54
- if (width <= 0 || height <= 0) throw new Error(`TileChunk dimensions must be positive (got ${width}x${height}).`);
55
- if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height)) throw new Error(`TileChunk dimensions must be safe integers (got ${width}x${height}).`);
56
- const size = width * height;
57
- if (!Number.isSafeInteger(size)) throw new Error(`TileChunk size overflow: ${width} * ${height} is not safe.`);
58
- if (size > 4294967295) throw new Error(`TileChunk size ${size} exceeds TypedArray maximum length.`);
59
- this.cx = cx;
60
- this.cy = cy;
61
- this.width = width;
62
- this.height = height;
63
- if (source) {
64
- if (source.length !== size) throw new Error(`TileChunk source length ${source.length} != ${size}.`);
65
- this._tiles = new Uint32Array(source);
66
- } else this._tiles = new Uint32Array(size);
67
- }
68
- /** Row-major index for cell (lx, ly) within this chunk. */
69
- _index(lx, ly) {
70
- return ly * this.width + lx;
71
- }
72
- /**
73
- * Validate local-in-chunk coordinates before access.
74
- * @throws If lx or ly is not a finite integer or out of [0, dimension).
75
- */
76
- _validateLocalCoord(lx, ly) {
77
- validateInteger(lx, "lx");
78
- validateInteger(ly, "ly");
79
- if (lx < 0 || lx >= this.width) throw new Error(`lx ${lx} out of chunk bounds [0, ${this.width - 1}].`);
80
- if (ly < 0 || ly >= this.height) throw new Error(`ly ${ly} out of chunk bounds [0, ${this.height - 1}].`);
81
- }
82
- /** @inheritdoc */
83
- getRawAt(lx, ly) {
84
- this._validateLocalCoord(lx, ly);
85
- return this._tiles[this._index(lx, ly)];
86
- }
87
- /** @inheritdoc */
88
- get empty() {
89
- if (this._empty === null) this._empty = this._tiles.every((v) => v === 0);
90
- return this._empty;
91
- }
92
- /** @inheritdoc */
93
- get revision() {
94
- return this._revision;
95
- }
96
- /** @inheritdoc */
97
- cloneTiles() {
98
- return new Uint32Array(this._tiles);
99
- }
100
- /**
101
- * Package-internal access to the underlying tile storage.
102
- * Returns the actual mutable `Uint32Array` - DO NOT USE publicly.
103
- *
104
- * Provided for the future tilemap renderer (same package) so it can
105
- * read chunk data efficiently without a full `cloneTiles()` copy per frame.
106
- *
107
- * External consumers and other packages MUST NOT call this.
108
- * @internal
109
- */
110
- _getRawStorage() {
111
- return this._tiles;
112
- }
113
- /**
114
- * Validate a packed tile value before storing.
115
- * Accepts any finite integer - `Uint32Array` stores via unsigned 32-bit
116
- * truncation (`ToUint32`). Negative values produced by JavaScript's
117
- * signed bitwise ops (e.g. when the transform bits set bit 31) are valid.
118
- * @throws If the value is NaN, Infinity, or non-integer.
119
- * @internal
120
- */
121
- _validatePacked(packed) {
122
- if (typeof packed !== "number" || !Number.isFinite(packed) || !Number.isInteger(packed)) throw new Error(`Packed tile must be a finite integer (got ${packed}).`);
123
- }
124
- /**
125
- * Write a packed tile word at local-in-chunk coordinates.
126
- * Returns true if the stored value actually changed.
127
- *
128
- * Package-internal: only {@link TileLayer} may call this.
129
- * @internal
130
- */
131
- _setRawAt(lx, ly, packed) {
132
- this._validateLocalCoord(lx, ly);
133
- this._validatePacked(packed);
134
- const i = this._index(lx, ly);
135
- if (this._tiles[i] === packed) return false;
136
- this._tiles[i] = packed;
137
- this._revision++;
138
- this._empty = null;
139
- this._notifyDirty();
140
- return true;
141
- }
142
- /**
143
- * Mark the chunk as needing a GPU rebuild.
144
- * Invalidates the empty cache and increments revision.
145
- *
146
- * Package-internal: for future renderer use only.
147
- * @internal
148
- */
149
- _markDirty() {
150
- this._empty = null;
151
- this._revision++;
152
- this._notifyDirty();
153
- }
154
- /**
155
- * Clear every cell in this chunk. Does not re-allocate storage.
156
- * Increments revision if any cell was non-zero.
157
- *
158
- * Package-internal: only {@link TileLayer} may call this.
159
- * @internal
160
- */
161
- _clear() {
162
- if (!this._tiles.some((v) => v !== 0)) return;
163
- this._tiles.fill(0);
164
- this._revision++;
165
- this._empty = true;
166
- this._notifyDirty();
167
- }
168
- /**
169
- * Register a callback invoked synchronously whenever this chunk's revision
170
- * advances. Multiple listeners are supported (a chunk may back more than one
171
- * `TileChunkNode` - e.g. two `TileLayerNode`s over the same `TileLayer`).
172
- * Package-internal: called by `TileChunkNode` to push mutations onto the
173
- * scene-node content-revision chain (see the `_dirtyListeners` field).
174
- * @internal
175
- */
176
- _addDirtyListener(listener) {
177
- (this._dirtyListeners ??= /* @__PURE__ */ new Set()).add(listener);
178
- }
179
- /**
180
- * Unregister a listener added via {@link _addDirtyListener} (node destroy).
181
- * @internal
182
- */
183
- _removeDirtyListener(listener) {
184
- this._dirtyListeners?.delete(listener);
185
- }
186
- _notifyDirty() {
187
- if (this._dirtyListeners === null) return;
188
- for (const listener of this._dirtyListeners) listener();
189
- }
190
- };
191
-
192
- //#endregion
193
- export { TileChunk };
194
- //# sourceMappingURL=TileChunk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TileChunk.js","names":[],"sources":["../../src/TileChunk.ts"],"sourcesContent":["import type { PackedTile } from './types';\nimport { validateInteger } from './types';\n\n/**\n * Public readonly view of a tile chunk.\n *\n * Provides read-only inspection access for iteration, queries, and the\n * future renderer. The underlying storage is never exposed directly.\n *\n * @advanced\n */\nexport interface ReadonlyTileChunk {\n /** Signed chunk X coordinate. */\n readonly cx: number;\n /** Signed chunk Y coordinate. */\n readonly cy: number;\n /** Width of this chunk in tiles. */\n readonly width: number;\n /** Height of this chunk in tiles. */\n readonly height: number;\n /** Whether every cell is empty (all-zero). */\n readonly empty: boolean;\n /**\n * Monotonic revision counter. Increments on every cell mutation\n * within this chunk. No-ops (writing same value) do NOT increment.\n */\n readonly revision: number;\n\n /**\n * Read the raw packed tile word at local-in-chunk coordinates.\n * Returns 0 for empty.\n * @throws If coordinates are invalid.\n */\n getRawAt(lx: number, ly: number): PackedTile;\n\n /**\n * Create a defensive copy of the tile data. The caller owns the copy;\n * mutation of the returned array cannot affect the chunk.\n */\n cloneTiles(): Uint32Array;\n}\n\n/**\n * A compact, fixed-size chunk of tile data within a layer.\n *\n * Storage is a single {@link Uint32Array} of length `width * height`,\n * laid out row-major. Each cell is a packed tile word (0 = empty).\n * Chunk coordinates are signed to support future infinite maps.\n *\n * The backing array is **private** - external code cannot mutate storage\n * directly. All mutation must flow through {@link TileLayer} public APIs,\n * which call the package-internal `_setRawAt` method.\n *\n * The chunk tracks a revision counter that increments on every mutation\n * so the future renderer can detect which chunks need GPU rebuilds.\n *\n * @advanced\n */\nexport class TileChunk implements ReadonlyTileChunk {\n /** Signed chunk X coordinate. */\n public readonly cx: number;\n /** Signed chunk Y coordinate. */\n public readonly cy: number;\n\n /** Width of this chunk in tiles. */\n public readonly width: number;\n /** Height of this chunk in tiles. */\n public readonly height: number;\n\n /** Packed tile storage (row-major). Private - never exposed directly. */\n private readonly _tiles: Uint32Array;\n\n /** Whether every cell in this chunk is empty (0). Lazy-computed. */\n private _empty: boolean | null = null;\n\n /** Monotonic revision counter - incremented on every mutation. */\n private _revision = 0;\n\n /**\n * Render-node-owned callbacks notified whenever `_revision` advances.\n * `TileChunkNode.pages` caches geometry against `revision`, but that cache\n * is only consulted from `render()` - a call the engine skips entirely for\n * a content-clean subtree under a `RetainedContainer`. Without\n * this push, an in-place tile edit after capture would replay stale cached\n * geometry forever. Package-internal; not part of {@link ReadonlyTileChunk}.\n */\n private _dirtyListeners: Set<() => void> | null = null;\n\n /**\n * @param cx Signed chunk X coordinate (must be finite safe integer).\n * @param cy Signed chunk Y coordinate (must be finite safe integer).\n * @param width Chunk width in tiles (positive safe integer).\n * @param height Chunk height in tiles (positive safe integer).\n * @param source Optional source data to copy (must match length).\n */\n public constructor(cx: number, cy: number, width: number, height: number, source?: Uint32Array) {\n // Validate chunk coordinates as finite safe integers (negative OK).\n if (!Number.isFinite(cx) || !Number.isInteger(cx) || !Number.isSafeInteger(cx)) {\n throw new Error(`TileChunk cx must be a finite safe integer (got ${cx}).`);\n }\n if (!Number.isFinite(cy) || !Number.isInteger(cy) || !Number.isSafeInteger(cy)) {\n throw new Error(`TileChunk cy must be a finite safe integer (got ${cy}).`);\n }\n\n if (width <= 0 || height <= 0) {\n throw new Error(`TileChunk dimensions must be positive (got ${width}x${height}).`);\n }\n if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height)) {\n throw new Error(`TileChunk dimensions must be safe integers (got ${width}x${height}).`);\n }\n\n const size = width * height;\n if (!Number.isSafeInteger(size)) {\n throw new Error(`TileChunk size overflow: ${width} * ${height} is not safe.`);\n }\n\n // Guard against TypedArray length limits.\n if (size > 0xffffffff) {\n throw new Error(`TileChunk size ${size} exceeds TypedArray maximum length.`);\n }\n\n this.cx = cx;\n this.cy = cy;\n this.width = width;\n this.height = height;\n\n if (source) {\n if (source.length !== size) {\n throw new Error(`TileChunk source length ${source.length} != ${size}.`);\n }\n // Defensive copy - caller mutation of source array will not affect storage.\n this._tiles = new Uint32Array(source);\n } else {\n this._tiles = new Uint32Array(size);\n }\n }\n\n /** Row-major index for cell (lx, ly) within this chunk. */\n private _index(lx: number, ly: number): number {\n return ly * this.width + lx;\n }\n\n /**\n * Validate local-in-chunk coordinates before access.\n * @throws If lx or ly is not a finite integer or out of [0, dimension).\n */\n private _validateLocalCoord(lx: number, ly: number): void {\n validateInteger(lx, 'lx');\n validateInteger(ly, 'ly');\n if (lx < 0 || lx >= this.width) {\n throw new Error(`lx ${lx} out of chunk bounds [0, ${this.width - 1}].`);\n }\n if (ly < 0 || ly >= this.height) {\n throw new Error(`ly ${ly} out of chunk bounds [0, ${this.height - 1}].`);\n }\n }\n\n // ── Readonly public API (ReadonlyTileChunk) ──────────────────────────\n\n /** @inheritdoc */\n public getRawAt(lx: number, ly: number): PackedTile {\n this._validateLocalCoord(lx, ly);\n return this._tiles[this._index(lx, ly)]!;\n }\n\n /** @inheritdoc */\n public get empty(): boolean {\n if (this._empty === null) {\n this._empty = this._tiles.every(v => v === 0);\n }\n return this._empty;\n }\n\n /** @inheritdoc */\n public get revision(): number {\n return this._revision;\n }\n\n /** @inheritdoc */\n public cloneTiles(): Uint32Array {\n return new Uint32Array(this._tiles);\n }\n\n // ── Internal mutation (package-private, NOT public API) ──────────────\n\n /**\n * Package-internal access to the underlying tile storage.\n * Returns the actual mutable `Uint32Array` - DO NOT USE publicly.\n *\n * Provided for the future tilemap renderer (same package) so it can\n * read chunk data efficiently without a full `cloneTiles()` copy per frame.\n *\n * External consumers and other packages MUST NOT call this.\n * @internal\n */\n public _getRawStorage(): Uint32Array {\n return this._tiles;\n }\n\n /**\n * Validate a packed tile value before storing.\n * Accepts any finite integer - `Uint32Array` stores via unsigned 32-bit\n * truncation (`ToUint32`). Negative values produced by JavaScript's\n * signed bitwise ops (e.g. when the transform bits set bit 31) are valid.\n * @throws If the value is NaN, Infinity, or non-integer.\n * @internal\n */\n private _validatePacked(packed: PackedTile): void {\n if (typeof packed !== 'number' || !Number.isFinite(packed) || !Number.isInteger(packed)) {\n throw new Error(`Packed tile must be a finite integer (got ${packed}).`);\n }\n }\n\n /**\n * Write a packed tile word at local-in-chunk coordinates.\n * Returns true if the stored value actually changed.\n *\n * Package-internal: only {@link TileLayer} may call this.\n * @internal\n */\n public _setRawAt(lx: number, ly: number, packed: PackedTile): boolean {\n this._validateLocalCoord(lx, ly);\n this._validatePacked(packed);\n const i = this._index(lx, ly);\n const prev = this._tiles[i];\n if (prev === packed) return false;\n this._tiles[i] = packed;\n this._revision++;\n this._empty = null; // invalidate cache\n this._notifyDirty();\n return true;\n }\n\n /**\n * Mark the chunk as needing a GPU rebuild.\n * Invalidates the empty cache and increments revision.\n *\n * Package-internal: for future renderer use only.\n * @internal\n */\n public _markDirty(): void {\n this._empty = null;\n this._revision++;\n this._notifyDirty();\n }\n\n /**\n * Clear every cell in this chunk. Does not re-allocate storage.\n * Increments revision if any cell was non-zero.\n *\n * Package-internal: only {@link TileLayer} may call this.\n * @internal\n */\n public _clear(): void {\n const hadContent = this._tiles.some(v => v !== 0);\n if (!hadContent) return;\n this._tiles.fill(0);\n this._revision++;\n this._empty = true;\n this._notifyDirty();\n }\n\n /**\n * Register a callback invoked synchronously whenever this chunk's revision\n * advances. Multiple listeners are supported (a chunk may back more than one\n * `TileChunkNode` - e.g. two `TileLayerNode`s over the same `TileLayer`).\n * Package-internal: called by `TileChunkNode` to push mutations onto the\n * scene-node content-revision chain (see the `_dirtyListeners` field).\n * @internal\n */\n public _addDirtyListener(listener: () => void): void {\n (this._dirtyListeners ??= new Set()).add(listener);\n }\n\n /**\n * Unregister a listener added via {@link _addDirtyListener} (node destroy).\n * @internal\n */\n public _removeDirtyListener(listener: () => void): void {\n this._dirtyListeners?.delete(listener);\n }\n\n private _notifyDirty(): void {\n if (this._dirtyListeners === null) return;\n for (const listener of this._dirtyListeners) {\n listener();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0DA,IAAa,YAAb,MAAoD;;CAElD,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAgB;;CAEhB,AAAgB;;CAGhB,AAAiB;;CAGjB,AAAQ,SAAyB;;CAGjC,AAAQ,YAAY;;;;;;;;;CAUpB,AAAQ,kBAA0C;;;;;;;;CASlD,AAAO,YAAY,IAAY,IAAY,OAAe,QAAgB,QAAsB;EAE9F,IAAI,CAAC,OAAO,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AK,oCAAoB,IAAI,IAAI,EAAC,CAAE,IAAI,QAAQ;CACnD;;;;;CAMA,AAAO,qBAAqB,UAA4B;EACtD,KAAK,iBAAiB,OAAO,QAAQ;CACvC;CAEA,AAAQ,eAAqB;EAC3B,IAAI,KAAK,oBAAoB,MAAM;EACnC,KAAK,MAAM,YAAY,KAAK,iBAC1B,SAAS;CAEb;AACF"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TileChunkNode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TileChunkNode.d.ts","sourceRoot":"","sources":["../../src/TileChunkNode.ts"],"names":[],"mappings":""}
@@ -1,145 +0,0 @@
1
- import { buildChunkPages } from "./chunkGeometry.js";
2
- import { TileChunk } from "./TileChunk.js";
3
- import { TileProjection } from "./TileProjection.js";
4
- import { Drawable } from "@codexo/exojs/renderer-sdk";
5
-
6
- //#region src/TileChunkNode.ts
7
- /**
8
- * A single renderable tile chunk. One `TileChunkNode` is a {@link Drawable}
9
- * that owns the batched quad geometry for exactly one {@link ReadonlyTileChunk}
10
- * of one {@link import('./TileLayer').TileLayer}. Orthogonal nodes use the
11
- * chunk's pixel origin; isometric nodes draw one diagonal slice and share
12
- * the projection origin to keep pixel snapping independent of chunk layout.
13
- *
14
- * Geometry is built lazily and cached against the source chunk's `revision`:
15
- * the renderer reads {@link TileChunkNode.pages} on each visible frame, but a
16
- * rebuild only happens when the underlying chunk actually changed. Off-screen
17
- * chunks are culled by their accurate {@link getLocalBounds} before `render`
18
- * is ever called, so a camera pan rebuilds nothing.
19
- *
20
- * The node references - but never owns - the runtime chunk, tilesets, and
21
- * tileset textures. Destroying it releases only its cached CPU geometry; the
22
- * `TileMap`/`TileLayer` data and Loader-owned textures are untouched.
23
- *
24
- * @internal Package-internal render node; the renderer is registered for this
25
- * class. Applications use {@link TileMapNode} / {@link TileLayerNode}.
26
- */
27
- var TileChunkNode = class extends Drawable {
28
- _chunk;
29
- _tilesets;
30
- _tileWidth;
31
- _tileHeight;
32
- _projection;
33
- _geometryX;
34
- _geometryY;
35
- diagonal;
36
- depth;
37
- firstColumn;
38
- _pages = [];
39
- _builtRevision = -1;
40
- /**
41
- * Bound once so `TileChunk._addDirtyListener`/`_removeDirtyListener` add and
42
- * remove the SAME function reference. Pushes the chunk's revision bump onto
43
- * this node's own content revision (see `TileChunk._dirtyListeners`) so a
44
- * `RetainedContainer` ancestor - which skips walking a content-clean
45
- * subtree entirely - observes the mutation and re-collects instead of
46
- * replaying stale cached geometry.
47
- */
48
- _onChunkDirty = () => {
49
- this.invalidateContent();
50
- };
51
- /**
52
- * @param chunk The readonly chunk this node renders.
53
- * @param tilesets The owning layer's tileset array.
54
- * @param tileWidth Map/layer tile cell width in pixels.
55
- * @param tileHeight Map/layer tile cell height in pixels.
56
- * @param chunkWidthTiles The layer's (unclamped) chunk width in tiles, used
57
- * to compute the chunk's pixel origin. Edge chunks
58
- * report a smaller `chunk.width`, but always start at
59
- * `cx * chunkWidthTiles`.
60
- * @param chunkHeightTiles The layer's (unclamped) chunk height in tiles.
61
- */
62
- constructor(chunk, tilesets, tileWidth, tileHeight, chunkWidthTiles, chunkHeightTiles, projection = new TileProjection({
63
- tileWidth,
64
- tileHeight
65
- }), diagonal) {
66
- super();
67
- this._chunk = chunk;
68
- this._tilesets = tilesets;
69
- this._tileWidth = tileWidth;
70
- this._tileHeight = tileHeight;
71
- this._projection = projection;
72
- this.diagonal = diagonal;
73
- const tx = chunk.cx * chunkWidthTiles;
74
- const ty = chunk.cy * chunkHeightTiles;
75
- this.depth = tx + ty + (diagonal ?? 0);
76
- this.firstColumn = tx + Math.max(0, (diagonal ?? 0) - chunk.height + 1);
77
- const position = projection.tileToPixel(tx, ty);
78
- const iso = projection.orientation === "isometric";
79
- this._geometryX = iso ? position.x - projection.originX : 0;
80
- this._geometryY = iso ? position.y - projection.originY : 0;
81
- this.setPosition(iso ? projection.originX : position.x, iso ? projection.originY : position.y);
82
- if (chunk instanceof TileChunk) chunk._addDirtyListener(this._onChunkDirty);
83
- }
84
- /** The signed chunk coordinates this node renders. */
85
- get chunkX() {
86
- return this._chunk.cx;
87
- }
88
- get chunkY() {
89
- return this._chunk.cy;
90
- }
91
- /**
92
- * The revision-cached per-tileset page geometry. Rebuilt only when the source
93
- * chunk's `revision` advances; otherwise the same arrays are returned.
94
- * @internal Read by the per-backend tile chunk renderer.
95
- */
96
- get pages() {
97
- if (this._builtRevision !== this._chunk.revision) {
98
- this._pages = buildChunkPages(this._chunk, this._tilesets, this._tileWidth, this._tileHeight, this._projection, this.diagonal, this._geometryX, this._geometryY);
99
- this._builtRevision = this._chunk.revision;
100
- }
101
- return this._pages;
102
- }
103
- /** `true` when the chunk has no drawable tiles (no geometry, no draw calls). */
104
- get isEmpty() {
105
- return this.pages.length === 0;
106
- }
107
- /**
108
- * Recomputed lazily on read, so it writes `_localBounds` directly rather than
109
- * going through `setLocalBounds`: an invalidating write inside a getter
110
- * would re-dirty the node on every read.
111
- */
112
- getLocalBounds() {
113
- if (!(this._projection.orientation === "isometric")) return this._localBounds.set(0, 0, this._chunk.width * this._tileWidth, this._chunk.height * this._tileHeight);
114
- const d = this.diagonal;
115
- const minX = d === void 0 ? 0 : Math.max(0, d - this._chunk.height + 1);
116
- const maxX = d === void 0 ? this._chunk.width - 1 : Math.min(this._chunk.width - 1, d);
117
- const minY = d === void 0 ? 0 : d - maxX;
118
- const maxY = d === void 0 ? this._chunk.height - 1 : d - minX;
119
- let left = (minX - maxY - 1) * this._tileWidth / 2;
120
- let top = (minX + maxY) * this._tileHeight / 2;
121
- let right = (maxX - minY + 1) * this._tileWidth / 2;
122
- let bottom = (maxX + minY) * this._tileHeight / 2 + this._tileHeight;
123
- const baseLeft = left;
124
- const baseTop = top;
125
- const baseRight = right;
126
- const baseBottom = bottom;
127
- for (const tileset of this._tilesets) {
128
- left = Math.min(left, baseLeft + tileset.offsetX);
129
- top = Math.min(top, baseTop + this._tileHeight - tileset.tileHeight + tileset.offsetY);
130
- right = Math.max(right, baseRight + tileset.tileWidth - this._tileWidth + tileset.offsetX);
131
- bottom = Math.max(bottom, baseBottom + tileset.offsetY);
132
- }
133
- return this._localBounds.set(left + this._geometryX, top + this._geometryY, right - left, bottom - top);
134
- }
135
- destroy() {
136
- if (this._chunk instanceof TileChunk) this._chunk._removeDirtyListener(this._onChunkDirty);
137
- this._pages = [];
138
- this._builtRevision = -1;
139
- super.destroy();
140
- }
141
- };
142
-
143
- //#endregion
144
- export { TileChunkNode };
145
- //# sourceMappingURL=TileChunkNode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TileChunkNode.js","names":[],"sources":["../../src/TileChunkNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Drawable } from '@codexo/exojs/renderer-sdk';\n\nimport type { ChunkPage } from './chunkGeometry';\nimport { buildChunkPages } from './chunkGeometry';\nimport type { ReadonlyTileChunk } from './TileChunk';\nimport { TileChunk } from './TileChunk';\nimport { TileProjection } from './TileProjection';\nimport type { TileSet } from './TileSet';\n\n/**\n * A single renderable tile chunk. One `TileChunkNode` is a {@link Drawable}\n * that owns the batched quad geometry for exactly one {@link ReadonlyTileChunk}\n * of one {@link import('./TileLayer').TileLayer}. Orthogonal nodes use the\n * chunk's pixel origin; isometric nodes draw one diagonal slice and share\n * the projection origin to keep pixel snapping independent of chunk layout.\n *\n * Geometry is built lazily and cached against the source chunk's `revision`:\n * the renderer reads {@link TileChunkNode.pages} on each visible frame, but a\n * rebuild only happens when the underlying chunk actually changed. Off-screen\n * chunks are culled by their accurate {@link getLocalBounds} before `render`\n * is ever called, so a camera pan rebuilds nothing.\n *\n * The node references - but never owns - the runtime chunk, tilesets, and\n * tileset textures. Destroying it releases only its cached CPU geometry; the\n * `TileMap`/`TileLayer` data and Loader-owned textures are untouched.\n *\n * @internal Package-internal render node; the renderer is registered for this\n * class. Applications use {@link TileMapNode} / {@link TileLayerNode}.\n */\nexport class TileChunkNode extends Drawable {\n private readonly _chunk: ReadonlyTileChunk;\n private readonly _tilesets: readonly TileSet[];\n private readonly _tileWidth: number;\n private readonly _tileHeight: number;\n private readonly _projection: TileProjection;\n private readonly _geometryX: number;\n private readonly _geometryY: number;\n public readonly diagonal: number | undefined;\n public readonly depth: number;\n public readonly firstColumn: number;\n\n private _pages: ChunkPage[] = [];\n private _builtRevision = -1;\n\n /**\n * Bound once so `TileChunk._addDirtyListener`/`_removeDirtyListener` add and\n * remove the SAME function reference. Pushes the chunk's revision bump onto\n * this node's own content revision (see `TileChunk._dirtyListeners`) so a\n * `RetainedContainer` ancestor - which skips walking a content-clean\n * subtree entirely - observes the mutation and re-collects instead of\n * replaying stale cached geometry.\n */\n private readonly _onChunkDirty = (): void => {\n this.invalidateContent();\n };\n\n /**\n * @param chunk The readonly chunk this node renders.\n * @param tilesets The owning layer's tileset array.\n * @param tileWidth Map/layer tile cell width in pixels.\n * @param tileHeight Map/layer tile cell height in pixels.\n * @param chunkWidthTiles The layer's (unclamped) chunk width in tiles, used\n * to compute the chunk's pixel origin. Edge chunks\n * report a smaller `chunk.width`, but always start at\n * `cx * chunkWidthTiles`.\n * @param chunkHeightTiles The layer's (unclamped) chunk height in tiles.\n */\n public constructor(\n chunk: ReadonlyTileChunk,\n tilesets: readonly TileSet[],\n tileWidth: number,\n tileHeight: number,\n chunkWidthTiles: number,\n chunkHeightTiles: number,\n projection = new TileProjection({ tileWidth, tileHeight }),\n diagonal?: number,\n ) {\n super();\n\n this._chunk = chunk;\n this._tilesets = tilesets;\n this._tileWidth = tileWidth;\n this._tileHeight = tileHeight;\n this._projection = projection;\n this.diagonal = diagonal;\n const tx = chunk.cx * chunkWidthTiles;\n const ty = chunk.cy * chunkHeightTiles;\n this.depth = tx + ty + (diagonal ?? 0);\n this.firstColumn = tx + Math.max(0, (diagonal ?? 0) - chunk.height + 1);\n const position = projection.tileToPixel(tx, ty);\n const iso = projection.orientation === 'isometric';\n this._geometryX = iso ? position.x - projection.originX : 0;\n this._geometryY = iso ? position.y - projection.originY : 0;\n // Shared origin keeps pixel snapping coherent when projected pitches are fractional.\n this.setPosition(iso ? projection.originX : position.x, iso ? projection.originY : position.y);\n\n // `loadedChunks()` always yields the concrete `TileChunk` behind the\n // readonly view (see TileLayer); the guard is defensive only.\n if (chunk instanceof TileChunk) {\n chunk._addDirtyListener(this._onChunkDirty);\n }\n }\n\n /** The signed chunk coordinates this node renders. */\n public get chunkX(): number {\n return this._chunk.cx;\n }\n\n public get chunkY(): number {\n return this._chunk.cy;\n }\n\n /**\n * The revision-cached per-tileset page geometry. Rebuilt only when the source\n * chunk's `revision` advances; otherwise the same arrays are returned.\n * @internal Read by the per-backend tile chunk renderer.\n */\n public get pages(): readonly ChunkPage[] {\n if (this._builtRevision !== this._chunk.revision) {\n this._pages = buildChunkPages(\n this._chunk,\n this._tilesets,\n this._tileWidth,\n this._tileHeight,\n this._projection,\n this.diagonal,\n this._geometryX,\n this._geometryY,\n );\n this._builtRevision = this._chunk.revision;\n }\n\n return this._pages;\n }\n\n /** `true` when the chunk has no drawable tiles (no geometry, no draw calls). */\n public get isEmpty(): boolean {\n return this.pages.length === 0;\n }\n\n /**\n * Recomputed lazily on read, so it writes `_localBounds` directly rather than\n * going through `setLocalBounds`: an invalidating write inside a getter\n * would re-dirty the node on every read.\n */\n public override getLocalBounds(): ReadonlyRectangle {\n const iso = this._projection.orientation === 'isometric';\n if (!iso) return this._localBounds.set(0, 0, this._chunk.width * this._tileWidth, this._chunk.height * this._tileHeight);\n const d = this.diagonal;\n const minX = d === undefined ? 0 : Math.max(0, d - this._chunk.height + 1);\n const maxX = d === undefined ? this._chunk.width - 1 : Math.min(this._chunk.width - 1, d);\n const minY = d === undefined ? 0 : d - maxX;\n const maxY = d === undefined ? this._chunk.height - 1 : d - minX;\n let left = ((minX - maxY - 1) * this._tileWidth) / 2;\n let top = ((minX + maxY) * this._tileHeight) / 2;\n let right = ((maxX - minY + 1) * this._tileWidth) / 2;\n let bottom = ((maxX + minY) * this._tileHeight) / 2 + this._tileHeight;\n const baseLeft = left;\n const baseTop = top;\n const baseRight = right;\n const baseBottom = bottom;\n for (const tileset of this._tilesets) {\n left = Math.min(left, baseLeft + tileset.offsetX);\n top = Math.min(top, baseTop + this._tileHeight - tileset.tileHeight + tileset.offsetY);\n right = Math.max(right, baseRight + tileset.tileWidth - this._tileWidth + tileset.offsetX);\n bottom = Math.max(bottom, baseBottom + tileset.offsetY);\n }\n return this._localBounds.set(left + this._geometryX, top + this._geometryY, right - left, bottom - top);\n }\n\n public override destroy(): void {\n if (this._chunk instanceof TileChunk) {\n this._chunk._removeDirtyListener(this._onChunkDirty);\n }\n\n this._pages = [];\n this._builtRevision = -1;\n\n super.destroy();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,gBAAb,cAAmC,SAAS;CAC1C,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAEhB,AAAQ,SAAsB,CAAC;CAC/B,AAAQ,iBAAiB;;;;;;;;;CAUzB,AAAiB,sBAA4B;EAC3C,KAAK,kBAAkB;CACzB;;;;;;;;;;;;CAaA,AAAO,YACL,OACA,UACA,WACA,YACA,iBACA,kBACA,aAAa,IAAI,eAAe;EAAE;EAAW;CAAW,CAAC,GACzD,UACA;EACA,MAAM;EAEN,KAAK,SAAS;EACd,KAAK,YAAY;EACjB,KAAK,aAAa;EAClB,KAAK,cAAc;EACnB,KAAK,cAAc;EACnB,KAAK,WAAW;EAChB,MAAM,KAAK,MAAM,KAAK;EACtB,MAAM,KAAK,MAAM,KAAK;EACtB,KAAK,QAAQ,KAAK,MAAM,YAAY;EACpC,KAAK,cAAc,KAAK,KAAK,IAAI,IAAI,YAAY,KAAK,MAAM,SAAS,CAAC;EACtE,MAAM,WAAW,WAAW,YAAY,IAAI,EAAE;EAC9C,MAAM,MAAM,WAAW,gBAAgB;EACvC,KAAK,aAA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