@codexo/exojs-tilemap 0.16.2 → 0.18.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 +28 -75
- package/dist/esm/ImageLayerNode.d.ts +6 -4
- package/dist/esm/ImageLayerNode.d.ts.map +1 -1
- package/dist/esm/ImageLayerNode.js +7 -2
- package/dist/esm/ImageLayerNode.js.map +1 -1
- package/dist/esm/MapSpawnSession.d.ts +0 -7
- package/dist/esm/MapSpawnSession.d.ts.map +1 -1
- package/dist/esm/MapWorldRuntime.d.ts +0 -2
- package/dist/esm/MapWorldRuntime.d.ts.map +1 -1
- package/dist/esm/TileChunk.d.ts +0 -58
- package/dist/esm/TileChunk.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.d.ts +1 -73
- package/dist/esm/TileChunkNode.d.ts.map +1 -1
- package/dist/esm/TileChunkNode.js +1 -1
- package/dist/esm/TileChunkNode.js.map +1 -1
- package/dist/esm/TileLayer.d.ts +0 -63
- package/dist/esm/TileLayer.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.d.ts +8 -8
- package/dist/esm/TileLayerNode.d.ts.map +1 -1
- package/dist/esm/TileLayerNode.js +9 -4
- package/dist/esm/TileLayerNode.js.map +1 -1
- package/dist/esm/TileMapBand.d.ts +0 -33
- package/dist/esm/TileMapBand.d.ts.map +1 -1
- package/dist/esm/TileMapNode.d.ts +7 -2
- package/dist/esm/TileMapNode.d.ts.map +1 -1
- package/dist/esm/TileMapNode.js +9 -4
- package/dist/esm/TileMapNode.js.map +1 -1
- package/dist/esm/TileMapView.d.ts +6 -1
- package/dist/esm/TileMapView.d.ts.map +1 -1
- package/dist/esm/TileMapView.js +9 -4
- package/dist/esm/TileMapView.js.map +1 -1
- package/dist/esm/TileSet.d.ts +3 -9
- package/dist/esm/TileSet.d.ts.map +1 -1
- package/dist/esm/TileSet.js +3 -3
- package/dist/esm/TileSet.js.map +1 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts +4 -7
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +1 -1
- package/dist/esm/WorkerSampledChunkSource.js +12 -18
- package/dist/esm/WorkerSampledChunkSource.js.map +1 -1
- package/dist/esm/chunkGeometry.d.ts +1 -71
- package/dist/esm/chunkGeometry.d.ts.map +1 -1
- package/dist/esm/nodeBounds.d.ts +1 -19
- package/dist/esm/nodeBounds.d.ts.map +1 -1
- package/dist/esm/pixelSnap.d.ts +1 -12
- package/dist/esm/pixelSnap.d.ts.map +1 -1
- package/dist/esm/tileWord.d.ts +1 -11
- package/dist/esm/tileWord.d.ts.map +1 -1
- package/dist/esm/tilemapExtension.d.ts.map +1 -1
- package/dist/esm/tilemapExtension.js +5 -8
- package/dist/esm/tilemapExtension.js.map +1 -1
- package/dist/esm/tilemapSerializers.d.ts +1 -19
- package/dist/esm/tilemapSerializers.d.ts.map +1 -1
- package/dist/esm/types.d.ts +0 -6
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +1 -92
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +13 -13
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js +1 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.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.d.ts +1 -107
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +13 -13
- 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 +3 -3
package/dist/esm/TileLayer.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { ChunkPayload } from './ChunkSource';
|
|
2
1
|
import type { ReadonlyTileChunk } from './TileChunk';
|
|
3
|
-
import { TileChunk } from './TileChunk';
|
|
4
2
|
import type { TileSet } from './TileSet';
|
|
5
3
|
import type { TileProperties } from './types';
|
|
6
4
|
import type { PackedTile, ResolvedTile } from './types';
|
|
@@ -75,19 +73,6 @@ export interface ChunkRange {
|
|
|
75
73
|
readonly maxCx: number;
|
|
76
74
|
readonly maxCy: number;
|
|
77
75
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Fired via {@link TileLayer._addStructuralListener} whenever a chunk is
|
|
80
|
-
* installed ({@link TileLayer._adoptChunk}) or evicted
|
|
81
|
-
* ({@link TileLayer._evictChunk}) - structural changes only, not per-tile
|
|
82
|
-
* edits (see {@link import('./TileChunk').TileChunk._addDirtyListener} for
|
|
83
|
-
* those). `chunk` is `null` on eviction.
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
86
|
-
export interface ChunkStructuralEvent {
|
|
87
|
-
readonly cx: number;
|
|
88
|
-
readonly cy: number;
|
|
89
|
-
readonly chunk: ReadonlyTileChunk | null;
|
|
90
|
-
}
|
|
91
76
|
/**
|
|
92
77
|
* A generic, format-independent tile layer with chunk-first storage.
|
|
93
78
|
*
|
|
@@ -191,54 +176,6 @@ export declare class TileLayer {
|
|
|
191
176
|
* @advanced
|
|
192
177
|
*/
|
|
193
178
|
getChunk(cx: number, cy: number): ReadonlyTileChunk | undefined;
|
|
194
|
-
/**
|
|
195
|
-
* Get or create a chunk at the given coordinates.
|
|
196
|
-
* For a bounded layer, creation is only allowed within the valid chunk
|
|
197
|
-
* range and edge chunks are clamped to the layer's remaining size. For an
|
|
198
|
-
* unbounded layer, any signed chunk coordinate is accepted and every
|
|
199
|
-
* chunk is full-size ({@link chunkWidth} × {@link chunkHeight}).
|
|
200
|
-
*
|
|
201
|
-
* @internal Package-private: used by {@link setTileAt}, {@link fillRect},
|
|
202
|
-
* and future adapter ingest. External users should not allocate
|
|
203
|
-
* chunks - use {@link setTileAt} to populate tiles.
|
|
204
|
-
*/
|
|
205
|
-
_ensureChunk(cx: number, cy: number): TileChunk;
|
|
206
|
-
/**
|
|
207
|
-
* Install a chunk-provider-supplied payload directly, bypassing per-tile
|
|
208
|
-
* `setTileAt` cost. Overwrites any existing chunk at `(cx, cy)`. Always
|
|
209
|
-
* bumps the layer revision (installing a chunk is always a structural
|
|
210
|
-
* change, even if the payload happens to be all-zero).
|
|
211
|
-
*
|
|
212
|
-
* Does not validate `(cx, cy)` against {@link chunkRange} - callers
|
|
213
|
-
* (chunk-streaming controllers) are trusted to request coordinates within
|
|
214
|
-
* whatever range they intend to manage.
|
|
215
|
-
*
|
|
216
|
-
* @internal Package-private: for future chunk-provider/streaming use.
|
|
217
|
-
*/
|
|
218
|
-
_adoptChunk(cx: number, cy: number, payload: ChunkPayload): void;
|
|
219
|
-
/**
|
|
220
|
-
* Evict a chunk from storage, freeing it for garbage collection. No-op if
|
|
221
|
-
* no chunk is loaded at `(cx, cy)`.
|
|
222
|
-
*
|
|
223
|
-
* @returns `true` if a chunk was found and removed, `false` otherwise.
|
|
224
|
-
* @internal Package-private: for future chunk-streaming eviction use.
|
|
225
|
-
*/
|
|
226
|
-
_evictChunk(cx: number, cy: number): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Register a callback invoked synchronously whenever a chunk is installed
|
|
229
|
-
* ({@link _adoptChunk}) or evicted ({@link _evictChunk}). Package-internal:
|
|
230
|
-
* {@link import('./TileLayerNode').TileLayerNode} subscribes to keep its
|
|
231
|
-
* chunk-node children in sync with chunk-provider-driven adopt/evict calls
|
|
232
|
-
* (e.g. from {@link import('./ChunkStreamer').ChunkStreamer}) without
|
|
233
|
-
* needing a full {@link import('./TileLayerNode').TileLayerNode.refresh}.
|
|
234
|
-
* @internal
|
|
235
|
-
*/
|
|
236
|
-
_addStructuralListener(listener: (event: ChunkStructuralEvent) => void): void;
|
|
237
|
-
/**
|
|
238
|
-
* Unregister a listener added via {@link _addStructuralListener} (node destroy).
|
|
239
|
-
* @internal
|
|
240
|
-
*/
|
|
241
|
-
_removeStructuralListener(listener: (event: ChunkStructuralEvent) => void): void;
|
|
242
179
|
private _notifyStructural;
|
|
243
180
|
/**
|
|
244
181
|
* Iterate over all loaded chunks in deterministic (cy, cx) ascending order.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayer.d.ts","sourceRoot":"","sources":["../../src/TileLayer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TileLayer.d.ts","sourceRoot":"","sources":["../../src/TileLayer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIxD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IACtC,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MA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AM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC;IA4C1H;;;;OAIG;IACI,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;IAOpE;;;;;OAKG;IACI,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE;IAStE;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,4CAA4C;IAC5C,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,OAAO,CAAC,eAAe;IAMvB;;;;OAIG;IACI,OAAO,IAAI,IAAI;IAMtB;;;;OAIG;IACI,kBAAkB,IAAI,MAAM;CAWpC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ReadonlyRectangle } from '@codexo/exojs';
|
|
2
2
|
import { Container } from '@codexo/exojs';
|
|
3
|
-
import { PixelSnapMode
|
|
4
|
-
import { TileChunkNode } from './TileChunkNode';
|
|
3
|
+
import { PixelSnapMode } from '@codexo/exojs/renderer-sdk';
|
|
5
4
|
import type { TileLayer } from './TileLayer';
|
|
6
5
|
/**
|
|
7
6
|
* Options for a {@link TileLayerNode}. All optional; reserved for forward
|
|
@@ -78,7 +77,12 @@ export declare class TileLayerNode extends Container {
|
|
|
78
77
|
* integer pixel grid by construction). Setting the current value is a no-op;
|
|
79
78
|
* an invalid value throws and leaves the prior mode unchanged.
|
|
80
79
|
*
|
|
81
|
-
*
|
|
80
|
+
* Defaults to `Geometry` because a tile grid is made of quads that share
|
|
81
|
+
* their edges: left unsnapped, a boundary landing between two device pixels
|
|
82
|
+
* is sampled across both, so the seams blur and shimmer as the view moves.
|
|
83
|
+
* Set `None` to opt out.
|
|
84
|
+
*
|
|
85
|
+
* @default PixelSnapMode.Geometry
|
|
82
86
|
* @stable
|
|
83
87
|
*/
|
|
84
88
|
get pixelSnapMode(): PixelSnapMode;
|
|
@@ -89,16 +93,12 @@ export declare class TileLayerNode extends Container {
|
|
|
89
93
|
* tile edits to existing chunks do not need a refresh.
|
|
90
94
|
*/
|
|
91
95
|
refresh(): this;
|
|
92
|
-
/** The chunk render nodes owned by this layer node, in build order. @internal */
|
|
93
|
-
get chunkNodes(): readonly TileChunkNode[];
|
|
94
96
|
/**
|
|
95
97
|
* Recomputed lazily on read, so it writes `_localBounds` directly rather than
|
|
96
|
-
* going through `
|
|
98
|
+
* going through `setLocalBounds`: an invalidating write inside a getter
|
|
97
99
|
* would re-dirty the node on every read.
|
|
98
100
|
*/
|
|
99
101
|
getLocalBounds(): ReadonlyRectangle;
|
|
100
|
-
/** @internal */
|
|
101
|
-
protected _collectContent(builder: RenderPlanBuilder): void;
|
|
102
102
|
destroy(): void;
|
|
103
103
|
private _buildChunkNodes;
|
|
104
104
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayerNode.d.ts","sourceRoot":"","sources":["../../src/TileLayerNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"TileLayerNode.d.ts","sourceRoot":"","sources":["../../src/TileLayerNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAA0B,MAAM,4BAA4B,CAAC;AAMnF,OAAO,KAAK,EAAwB,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,cAAc,CAAyC;IAE/D;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAoBlC;gBAEiB,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,oBAAoB;IAgBnE,2CAA2C;IAC3C,IAAW,KAAK,IAAI,SAAS,CAE5B;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAW,aAAa,IAAI,aAAa,CAExC;IAED,IAAW,aAAa,CAAC,IAAI,EAAE,aAAa,EAW3C;IAED;;;;OAIG;IACI,OAAO,IAAI,IAAI;IAsBtB;;;;OAIG;IACa,cAAc,IAAI,iBAAiB;IAkEnC,OAAO,IAAI,IAAI;IAc/B,OAAO,CAAC,gBAAgB;IAiBxB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAQlB;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAelB"}
|
|
@@ -42,7 +42,7 @@ var TileLayerNode = class extends Container {
|
|
|
42
42
|
_chunkNodes = [];
|
|
43
43
|
_syncedOpacity = -1;
|
|
44
44
|
_syncedTint = void 0;
|
|
45
|
-
_pixelSnapMode = PixelSnapMode.
|
|
45
|
+
_pixelSnapMode = PixelSnapMode.Geometry;
|
|
46
46
|
/**
|
|
47
47
|
* Bound once so `TileLayer._addStructuralListener`/`_removeStructuralListener`
|
|
48
48
|
* add and remove the SAME function reference. Incrementally adds/removes
|
|
@@ -90,7 +90,12 @@ var TileLayerNode = class extends Container {
|
|
|
90
90
|
* integer pixel grid by construction). Setting the current value is a no-op;
|
|
91
91
|
* an invalid value throws and leaves the prior mode unchanged.
|
|
92
92
|
*
|
|
93
|
-
*
|
|
93
|
+
* Defaults to `Geometry` because a tile grid is made of quads that share
|
|
94
|
+
* their edges: left unsnapped, a boundary landing between two device pixels
|
|
95
|
+
* is sampled across both, so the seams blur and shimmer as the view moves.
|
|
96
|
+
* Set `None` to opt out.
|
|
97
|
+
*
|
|
98
|
+
* @default PixelSnapMode.Geometry
|
|
94
99
|
* @stable
|
|
95
100
|
*/
|
|
96
101
|
get pixelSnapMode() {
|
|
@@ -123,7 +128,7 @@ var TileLayerNode = class extends Container {
|
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
130
|
* Recomputed lazily on read, so it writes `_localBounds` directly rather than
|
|
126
|
-
* going through `
|
|
131
|
+
* going through `setLocalBounds`: an invalidating write inside a getter
|
|
127
132
|
* would re-dirty the node on every read.
|
|
128
133
|
*/
|
|
129
134
|
getLocalBounds() {
|
|
@@ -187,7 +192,7 @@ var TileLayerNode = class extends Container {
|
|
|
187
192
|
const layer = this._layer;
|
|
188
193
|
const node = new TileChunkNode(chunk, layer.tilesets, layer.tileWidth, layer.tileHeight, layer.chunkWidth, layer.chunkHeight);
|
|
189
194
|
node.cullable = this._cullChunks;
|
|
190
|
-
|
|
195
|
+
node.pixelSnapMode = this._pixelSnapMode;
|
|
191
196
|
return node;
|
|
192
197
|
}
|
|
193
198
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayerNode.js","names":[],"sources":["../../src/TileLayerNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Container } from '@codexo/exojs';\nimport { PixelSnapMode, type RenderPlanBuilder } from '@codexo/exojs/renderer-sdk';\n\nimport { aggregateChildLocalBounds } from './nodeBounds';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport type { ReadonlyTileChunk } from './TileChunk';\nimport { TileChunkNode } from './TileChunkNode';\nimport type { ChunkStructuralEvent, TileLayer } from './TileLayer';\n\n/**\n * Options for a {@link TileLayerNode}. All optional; reserved for forward\n * compatibility.\n * @advanced\n */\nexport interface TileLayerNodeOptions {\n /**\n * Whether the layer's chunk nodes participate in per-chunk view culling.\n * Defaults to `true`. Disable only for tiny, always-on-screen layers where\n * the per-chunk bounds test is pure overhead.\n */\n readonly cullable?: boolean;\n}\n\n/**\n * A scene node that renders one generic {@link TileLayer} as a\n * {@link Container} of per-chunk {@link TileChunkNode} drawables.\n *\n * Each non-empty loaded chunk becomes one child positioned at its pixel\n * origin, so the engine's existing per-node culling drops individual chunks and\n * the render-plan optimiser batches them by tileset texture. The layer's pixel\n * `offset`, `visible` and `opacity` are all read live from the runtime layer on\n * every frame (no rebuild required).\n *\n * A `parallax` factor other than `1` makes this node's rendered position\n * camera-dependent, resolved per frame in {@link _collectContent} by patching\n * the node position against the camera centre, then restoring it - the cull\n * test runs before that patch, so a bounded layer with parallax would be\n * culled at its static base-offset bounds while actually rendering elsewhere.\n * Such a layer therefore opts out of view culling (`cullable = false`), same\n * as an unbounded layer (exactly like {@link import('./ImageLayerNode').ImageLayerNode}).\n *\n * The node references - but never owns - the {@link TileLayer}: destroying it\n * frees its chunk nodes and their cached geometry but leaves the layer, map,\n * and Loader-owned textures intact.\n *\n * Structural changes made via `_adoptChunk`/`_evictChunk` (chunk streaming)\n * are picked up incrementally as they happen, without a full rebuild.\n * {@link TileLayerNode.refresh} remains available for callers that mutate\n * chunk structure by other means (e.g. a bulk edit that bypasses\n * `_adoptChunk`/`_evictChunk`) and need a full resync. In-place tile edits to\n * existing chunks are picked up automatically via chunk revisions.\n *\n * @advanced\n */\nexport class TileLayerNode extends Container {\n private readonly _layer: TileLayer;\n private readonly _cullChunks: boolean;\n private readonly _chunkNodes: TileChunkNode[] = [];\n private _syncedOpacity = -1;\n private _syncedTint: number | null | undefined = undefined;\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.None;\n\n /**\n * Bound once so `TileLayer._addStructuralListener`/`_removeStructuralListener`\n * add and remove the SAME function reference. Incrementally adds/removes\n * the `TileChunkNode` child for exactly the chunk that changed - never\n * triggers a full {@link refresh}, so every other chunk node's\n * revision-cached geometry survives untouched.\n */\n private readonly _onStructuralChange = (event: ChunkStructuralEvent): void => {\n const existingIndex = this._chunkNodes.findIndex(n => n.chunkX === event.cx && n.chunkY === event.cy);\n\n const existing = this._chunkNodes[existingIndex];\n\n if (existing) {\n this._chunkNodes.splice(existingIndex, 1);\n this.removeChild(existing);\n existing.destroy();\n }\n\n if (event.chunk === null || event.chunk.empty) {\n return;\n }\n\n const node = this._createChunkNode(event.chunk);\n\n this._chunkNodes.push(node);\n this.addChild(node);\n this._applyTint(node);\n };\n\n public constructor(layer: TileLayer, options?: TileLayerNodeOptions) {\n super();\n\n this._layer = layer;\n this._cullChunks = options?.cullable ?? true;\n\n this.setPosition(layer.offsetX, layer.offsetY);\n this._buildChunkNodes();\n\n if (!this._layer.bounded || layer.parallaxX !== 1 || layer.parallaxY !== 1 || layer.parallaxScale !== 1) {\n this.cullable = false;\n }\n\n this._layer._addStructuralListener(this._onStructuralChange);\n }\n\n /** The runtime layer this node renders. */\n public get layer(): TileLayer {\n return this._layer;\n }\n\n /**\n * Render-only pixel-snap mode applied to every chunk node in this layer (and\n * to chunks rebuilt later by {@link refresh}). Each chunk's rendered origin is\n * snapped to the active render target's device-pixel grid; because chunk\n * origins are integer multiples of the integer tile pitch from the same layer\n * origin, the whole grid stays exact and adjacent chunks cannot drift apart.\n *\n * Purely visual: tile data, the layer offset, chunk content revisions, and\n * culling bounds are never changed. `PixelSnapMode.Geometry` and `PixelSnapMode.Position` both resolve\n * to coherent origin snapping for tile chunks (chunk quads are already on the\n * integer pixel grid by construction). Setting the current value is a no-op;\n * an invalid value throws and leaves the prior mode unchanged.\n *\n * @default PixelSnapMode.None\n * @stable\n */\n public get pixelSnapMode(): PixelSnapMode {\n return this._pixelSnapMode;\n }\n\n public set pixelSnapMode(mode: PixelSnapMode) {\n if (mode === this._pixelSnapMode) {\n return;\n }\n\n assertPixelSnapMode(mode);\n this._pixelSnapMode = mode;\n\n for (const chunk of this._chunkNodes) {\n chunk.pixelSnapMode = mode;\n }\n }\n\n /**\n * Rebuild the chunk-node children from the layer's current loaded chunks.\n * Call after structural mutation that creates or empties chunks. In-place\n * tile edits to existing chunks do not need a refresh.\n */\n public refresh(): this {\n const previous = [...this._chunkNodes];\n\n this.removeChildren();\n this._chunkNodes.length = 0;\n\n for (const child of previous) {\n child.destroy();\n }\n\n this._syncedOpacity = -1;\n this._syncedTint = undefined;\n this._buildChunkNodes();\n\n return this;\n }\n\n /** The chunk render nodes owned by this layer node, in build order. @internal */\n public get chunkNodes(): readonly TileChunkNode[] {\n return this._chunkNodes;\n }\n\n /**\n * Recomputed lazily on read, so it writes `_localBounds` directly rather than\n * going through `_setLocalBounds`: an invalidating write inside a getter\n * would re-dirty the node on every read.\n */\n public override getLocalBounds(): ReadonlyRectangle {\n const bounds = this._localBounds;\n\n // Reading the pixel extents directly (rather than gating on `bounded`)\n // is what narrows them to numbers - `bounded` is a plain boolean getter.\n const { pixelHeight, pixelWidth } = this._layer;\n\n if (pixelWidth !== undefined && pixelHeight !== undefined) {\n bounds.set(0, 0, pixelWidth, pixelHeight);\n } else if (this._chunkNodes.length > 0) {\n aggregateChildLocalBounds(this._chunkNodes, bounds);\n }\n\n return bounds;\n }\n\n /** @internal */\n protected override _collectContent(builder: RenderPlanBuilder): void {\n if (!this._layer.visible) {\n return;\n }\n\n this._syncTint();\n\n const layer = this._layer;\n\n const patchesPosition = layer.parallaxX !== 1 || layer.parallaxY !== 1;\n const patchesScale = layer.parallaxScale !== 1;\n\n // `offsetX`/`offsetY` are live, mutable fields (`TileColliderStreamer` and\n // `pixelToTile` already read them per call) - re-read here every frame so a\n // runtime-moved layer's rendering follows its collision rather than freezing\n // at the position it had when this node was constructed.\n if (patchesPosition || patchesScale) {\n const camCenter = builder.view.center;\n const prevScaleX = this.scale.x;\n const prevScaleY = this.scale.y;\n\n if (patchesPosition) {\n this.x = layer.offsetX + camCenter.x * (1 - layer.parallaxX);\n this.y = layer.offsetY + camCenter.y * (1 - layer.parallaxY);\n } else {\n this.setPosition(layer.offsetX, layer.offsetY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX * layer.parallaxScale, prevScaleY * layer.parallaxScale);\n }\n\n try {\n super._collectContent(builder);\n } finally {\n if (patchesPosition) {\n this.setPosition(layer.offsetX, layer.offsetY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX, prevScaleY);\n }\n }\n } else {\n this.setPosition(layer.offsetX, layer.offsetY);\n super._collectContent(builder);\n }\n }\n\n public override destroy(): void {\n this._layer._removeStructuralListener(this._onStructuralChange);\n\n const children = [...this._chunkNodes];\n\n this._chunkNodes.length = 0;\n\n super.destroy();\n\n for (const child of children) {\n child.destroy();\n }\n }\n\n private _buildChunkNodes(): void {\n const layer = this._layer;\n\n for (const chunk of layer.loadedChunks()) {\n if (chunk.empty) {\n continue;\n }\n\n const node = this._createChunkNode(chunk);\n\n this._chunkNodes.push(node);\n this.addChild(node);\n }\n\n this._syncTint();\n }\n\n /**\n * Construct one configured {@link TileChunkNode} for `chunk` - shared by\n * the initial bulk build ({@link _buildChunkNodes}) and the incremental\n * structural-listener handler, so a future constructor argument or\n * per-node setting only needs to be added in one place.\n */\n private _createChunkNode(chunk: ReadonlyTileChunk): TileChunkNode {\n const layer = this._layer;\n const node = new TileChunkNode(chunk, layer.tilesets, layer.tileWidth, layer.tileHeight, layer.chunkWidth, layer.chunkHeight);\n\n node.cullable = this._cullChunks;\n\n if (this._pixelSnapMode !== PixelSnapMode.None) {\n node.pixelSnapMode = this._pixelSnapMode;\n }\n\n return node;\n }\n\n /**\n * Compute and apply this layer's live tint (opacity as alpha, `tintColor`\n * as RGB multiply) to a single chunk node. Used both by {@link _syncTint}'s\n * bulk pass and by the structural-listener handler for a freshly-added\n * node - a node added between two \"nothing changed\" full syncs must still\n * receive the current tint, which a change-detection-guarded bulk pass\n * alone would skip.\n */\n private _applyTint(node: TileChunkNode): void {\n const tintColor = this._layer.tintColor;\n const r = tintColor === null ? 255 : (tintColor >> 16) & 0xff;\n const g = tintColor === null ? 255 : (tintColor >> 8) & 0xff;\n const b = tintColor === null ? 255 : tintColor & 0xff;\n node.tint.set(r, g, b, this._layer.opacity);\n }\n\n /**\n * Propagate the layer's live opacity and tint colour onto every chunk\n * render tint if either changed since the last call. Opacity drives the\n * tint alpha; `tintColor` (`0xRRGGBB`) multiplies the RGB (white = no tint).\n */\n private _syncTint(): void {\n const opacity = this._layer.opacity;\n const tintColor = this._layer.tintColor;\n\n if (opacity === this._syncedOpacity && tintColor === this._syncedTint) {\n return;\n }\n\n for (const child of this._chunkNodes) {\n this._applyTint(child);\n }\n\n this._syncedOpacity = opacity;\n this._syncedTint = tintColor;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,AAAiB;CACjB,AAAiB;CACjB,AAAiB,cAA+B,CAAC;CACjD,AAAQ,iBAAiB;CACzB,AAAQ,cAAyC;CACjD,AAAQ,iBAAgC,cAAc;;;;;;;;CAStD,AAAiB,uBAAuB,UAAsC;EAC5E,MAAM,gBAAgB,KAAK,YAAY,WAAU,MAAK,EAAE,WAAW,MAAM,MAAM,EAAE,WAAW,MAAM,EAAE;EAEpG,MAAM,WAAW,KAAK,YAAY;EAElC,IAAI,UAAU;GACZ,KAAK,YAAY,OAAO,eAAe,CAAC;GACxC,KAAK,YAAY,QAAQ;GACzB,SAAS,QAAQ;EACnB;EAEA,IAAI,MAAM,UAAU,QAAQ,MAAM,MAAM,OACtC;EAGF,MAAM,OAAO,KAAK,iBAAiB,MAAM,KAAK;EAE9C,KAAK,YAAY,KAAK,IAAI;EAC1B,KAAK,SAAS,I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OAAO,MAAM,UAAU,MAAM,WAAW,MAAM,YAAY,MAAM,YAAY,MAAM,WAAW;EAE5H,KAAK,WAAW,KAAK;EAErB,IAAI,KAAK,mBAAmB,cAAc,MACxC,KAAK,gBAAgB,KAAK;EAG5B,OAAO;CACT;;;;;;;;;CAUA,AAAQ,WAAW,MAA2B;EAC5C,MAAM,YAAY,KAAK,OAAO;EAC9B,MAAM,IAAI,cAAc,OAAO,MAAO,aAAa,KAAM;EACzD,MAAM,IAAI,cAAc,OAAO,MAAO,aAAa,IAAK;EACxD,MAAM,IAAI,cAAc,OAAO,MAAM,YAAY;EACjD,KAAK,KAAK,IAAI,GAAG,GAAG,GAAG,KAAK,OAAO,OAAO;CAC5C;;;;;;CAOA,AAAQ,YAAkB;EACxB,MAAM,UAAU,KAAK,OAAO;EAC5B,MAAM,YAAY,KAAK,OAAO;EAE9B,IAAI,YAAY,KAAK,kBAAkB,cAAc,KAAK,aACxD;EAGF,KAAK,MAAM,SAAS,KAAK,aACvB,KAAK,WAAW,KAAK;EAGvB,KAAK,iBAAiB;EACtB,KAAK,cAAc;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"TileLayerNode.js","names":[],"sources":["../../src/TileLayerNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Container } from '@codexo/exojs';\nimport { PixelSnapMode, type RenderPlanBuilder } from '@codexo/exojs/renderer-sdk';\n\nimport { aggregateChildLocalBounds } from './nodeBounds';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport type { ReadonlyTileChunk } from './TileChunk';\nimport { TileChunkNode } from './TileChunkNode';\nimport type { ChunkStructuralEvent, TileLayer } from './TileLayer';\n\n/**\n * Options for a {@link TileLayerNode}. All optional; reserved for forward\n * compatibility.\n * @advanced\n */\nexport interface TileLayerNodeOptions {\n /**\n * Whether the layer's chunk nodes participate in per-chunk view culling.\n * Defaults to `true`. Disable only for tiny, always-on-screen layers where\n * the per-chunk bounds test is pure overhead.\n */\n readonly cullable?: boolean;\n}\n\n/**\n * A scene node that renders one generic {@link TileLayer} as a\n * {@link Container} of per-chunk {@link TileChunkNode} drawables.\n *\n * Each non-empty loaded chunk becomes one child positioned at its pixel\n * origin, so the engine's existing per-node culling drops individual chunks and\n * the render-plan optimiser batches them by tileset texture. The layer's pixel\n * `offset`, `visible` and `opacity` are all read live from the runtime layer on\n * every frame (no rebuild required).\n *\n * A `parallax` factor other than `1` makes this node's rendered position\n * camera-dependent, resolved per frame in {@link _collectContent} by patching\n * the node position against the camera centre, then restoring it - the cull\n * test runs before that patch, so a bounded layer with parallax would be\n * culled at its static base-offset bounds while actually rendering elsewhere.\n * Such a layer therefore opts out of view culling (`cullable = false`), same\n * as an unbounded layer (exactly like {@link import('./ImageLayerNode').ImageLayerNode}).\n *\n * The node references - but never owns - the {@link TileLayer}: destroying it\n * frees its chunk nodes and their cached geometry but leaves the layer, map,\n * and Loader-owned textures intact.\n *\n * Structural changes made via `_adoptChunk`/`_evictChunk` (chunk streaming)\n * are picked up incrementally as they happen, without a full rebuild.\n * {@link TileLayerNode.refresh} remains available for callers that mutate\n * chunk structure by other means (e.g. a bulk edit that bypasses\n * `_adoptChunk`/`_evictChunk`) and need a full resync. In-place tile edits to\n * existing chunks are picked up automatically via chunk revisions.\n *\n * @advanced\n */\nexport class TileLayerNode extends Container {\n private readonly _layer: TileLayer;\n private readonly _cullChunks: boolean;\n private readonly _chunkNodes: TileChunkNode[] = [];\n private _syncedOpacity = -1;\n private _syncedTint: number | null | undefined = undefined;\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.Geometry;\n\n /**\n * Bound once so `TileLayer._addStructuralListener`/`_removeStructuralListener`\n * add and remove the SAME function reference. Incrementally adds/removes\n * the `TileChunkNode` child for exactly the chunk that changed - never\n * triggers a full {@link refresh}, so every other chunk node's\n * revision-cached geometry survives untouched.\n */\n private readonly _onStructuralChange = (event: ChunkStructuralEvent): void => {\n const existingIndex = this._chunkNodes.findIndex(n => n.chunkX === event.cx && n.chunkY === event.cy);\n\n const existing = this._chunkNodes[existingIndex];\n\n if (existing) {\n this._chunkNodes.splice(existingIndex, 1);\n this.removeChild(existing);\n existing.destroy();\n }\n\n if (event.chunk === null || event.chunk.empty) {\n return;\n }\n\n const node = this._createChunkNode(event.chunk);\n\n this._chunkNodes.push(node);\n this.addChild(node);\n this._applyTint(node);\n };\n\n public constructor(layer: TileLayer, options?: TileLayerNodeOptions) {\n super();\n\n this._layer = layer;\n this._cullChunks = options?.cullable ?? true;\n\n this.setPosition(layer.offsetX, layer.offsetY);\n this._buildChunkNodes();\n\n if (!this._layer.bounded || layer.parallaxX !== 1 || layer.parallaxY !== 1 || layer.parallaxScale !== 1) {\n this.cullable = false;\n }\n\n this._layer._addStructuralListener(this._onStructuralChange);\n }\n\n /** The runtime layer this node renders. */\n public get layer(): TileLayer {\n return this._layer;\n }\n\n /**\n * Render-only pixel-snap mode applied to every chunk node in this layer (and\n * to chunks rebuilt later by {@link refresh}). Each chunk's rendered origin is\n * snapped to the active render target's device-pixel grid; because chunk\n * origins are integer multiples of the integer tile pitch from the same layer\n * origin, the whole grid stays exact and adjacent chunks cannot drift apart.\n *\n * Purely visual: tile data, the layer offset, chunk content revisions, and\n * culling bounds are never changed. `PixelSnapMode.Geometry` and `PixelSnapMode.Position` both resolve\n * to coherent origin snapping for tile chunks (chunk quads are already on the\n * integer pixel grid by construction). Setting the current value is a no-op;\n * an invalid value throws and leaves the prior mode unchanged.\n *\n * Defaults to `Geometry` because a tile grid is made of quads that share\n * their edges: left unsnapped, a boundary landing between two device pixels\n * is sampled across both, so the seams blur and shimmer as the view moves.\n * Set `None` to opt out.\n *\n * @default PixelSnapMode.Geometry\n * @stable\n */\n public get pixelSnapMode(): PixelSnapMode {\n return this._pixelSnapMode;\n }\n\n public set pixelSnapMode(mode: PixelSnapMode) {\n if (mode === this._pixelSnapMode) {\n return;\n }\n\n assertPixelSnapMode(mode);\n this._pixelSnapMode = mode;\n\n for (const chunk of this._chunkNodes) {\n chunk.pixelSnapMode = mode;\n }\n }\n\n /**\n * Rebuild the chunk-node children from the layer's current loaded chunks.\n * Call after structural mutation that creates or empties chunks. In-place\n * tile edits to existing chunks do not need a refresh.\n */\n public refresh(): this {\n const previous = [...this._chunkNodes];\n\n this.removeChildren();\n this._chunkNodes.length = 0;\n\n for (const child of previous) {\n child.destroy();\n }\n\n this._syncedOpacity = -1;\n this._syncedTint = undefined;\n this._buildChunkNodes();\n\n return this;\n }\n\n /** The chunk render nodes owned by this layer node, in build order. @internal */\n public get chunkNodes(): readonly TileChunkNode[] {\n return this._chunkNodes;\n }\n\n /**\n * Recomputed lazily on read, so it writes `_localBounds` directly rather than\n * going through `setLocalBounds`: an invalidating write inside a getter\n * would re-dirty the node on every read.\n */\n public override getLocalBounds(): ReadonlyRectangle {\n const bounds = this._localBounds;\n\n // Reading the pixel extents directly (rather than gating on `bounded`)\n // is what narrows them to numbers - `bounded` is a plain boolean getter.\n const { pixelHeight, pixelWidth } = this._layer;\n\n if (pixelWidth !== undefined && pixelHeight !== undefined) {\n bounds.set(0, 0, pixelWidth, pixelHeight);\n } else if (this._chunkNodes.length > 0) {\n aggregateChildLocalBounds(this._chunkNodes, bounds);\n }\n\n return bounds;\n }\n\n /** @internal */\n protected override _collectContent(builder: RenderPlanBuilder): void {\n if (!this._layer.visible) {\n return;\n }\n\n this._syncTint();\n\n const layer = this._layer;\n\n const patchesPosition = layer.parallaxX !== 1 || layer.parallaxY !== 1;\n const patchesScale = layer.parallaxScale !== 1;\n\n // `offsetX`/`offsetY` are live, mutable fields (`TileColliderStreamer` and\n // `pixelToTile` already read them per call) - re-read here every frame so a\n // runtime-moved layer's rendering follows its collision rather than freezing\n // at the position it had when this node was constructed.\n if (patchesPosition || patchesScale) {\n const camCenter = builder.view.center;\n const prevScaleX = this.scale.x;\n const prevScaleY = this.scale.y;\n\n if (patchesPosition) {\n this.x = layer.offsetX + camCenter.x * (1 - layer.parallaxX);\n this.y = layer.offsetY + camCenter.y * (1 - layer.parallaxY);\n } else {\n this.setPosition(layer.offsetX, layer.offsetY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX * layer.parallaxScale, prevScaleY * layer.parallaxScale);\n }\n\n try {\n super._collectContent(builder);\n } finally {\n if (patchesPosition) {\n this.setPosition(layer.offsetX, layer.offsetY);\n }\n\n if (patchesScale) {\n this.setScale(prevScaleX, prevScaleY);\n }\n }\n } else {\n this.setPosition(layer.offsetX, layer.offsetY);\n super._collectContent(builder);\n }\n }\n\n public override destroy(): void {\n this._layer._removeStructuralListener(this._onStructuralChange);\n\n const children = [...this._chunkNodes];\n\n this._chunkNodes.length = 0;\n\n super.destroy();\n\n for (const child of children) {\n child.destroy();\n }\n }\n\n private _buildChunkNodes(): void {\n const layer = this._layer;\n\n for (const chunk of layer.loadedChunks()) {\n if (chunk.empty) {\n continue;\n }\n\n const node = this._createChunkNode(chunk);\n\n this._chunkNodes.push(node);\n this.addChild(node);\n }\n\n this._syncTint();\n }\n\n /**\n * Construct one configured {@link TileChunkNode} for `chunk` - shared by\n * the initial bulk build ({@link _buildChunkNodes}) and the incremental\n * structural-listener handler, so a future constructor argument or\n * per-node setting only needs to be added in one place.\n */\n private _createChunkNode(chunk: ReadonlyTileChunk): TileChunkNode {\n const layer = this._layer;\n const node = new TileChunkNode(chunk, layer.tilesets, layer.tileWidth, layer.tileHeight, layer.chunkWidth, layer.chunkHeight);\n\n node.cullable = this._cullChunks;\n // Unconditional: a chunk built after the layer was set to `None` has to\n // inherit that too, not just a non-default mode.\n node.pixelSnapMode = this._pixelSnapMode;\n\n return node;\n }\n\n /**\n * Compute and apply this layer's live tint (opacity as alpha, `tintColor`\n * as RGB multiply) to a single chunk node. Used both by {@link _syncTint}'s\n * bulk pass and by the structural-listener handler for a freshly-added\n * node - a node added between two \"nothing changed\" full syncs must still\n * receive the current tint, which a change-detection-guarded bulk pass\n * alone would skip.\n */\n private _applyTint(node: TileChunkNode): void {\n const tintColor = this._layer.tintColor;\n const r = tintColor === null ? 255 : (tintColor >> 16) & 0xff;\n const g = tintColor === null ? 255 : (tintColor >> 8) & 0xff;\n const b = tintColor === null ? 255 : tintColor & 0xff;\n node.tint.set(r, g, b, this._layer.opacity);\n }\n\n /**\n * Propagate the layer's live opacity and tint colour onto every chunk\n * render tint if either changed since the last call. Opacity drives the\n * tint alpha; `tintColor` (`0xRRGGBB`) multiplies the RGB (white = no tint).\n */\n private _syncTint(): void {\n const opacity = this._layer.opacity;\n const tintColor = this._layer.tintColor;\n\n if (opacity === this._syncedOpacity && tintColor === this._syncedTint) {\n return;\n }\n\n for (const child of this._chunkNodes) {\n this._applyTint(child);\n }\n\n this._syncedOpacity = opacity;\n this._syncedTint = tintColor;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,AAAiB;CACjB,AAAiB;CACjB,AAAiB,cAA+B,CAAC;CACjD,AAAQ,iBAAiB;CACzB,AAAQ,cAAyC;CACjD,AAAQ,iBAAgC,cAAc;;;;;;;;CAStD,AAAiB,uBAAuB,UAAsC;EAC5E,MAAM,gBAAgB,KAAK,YAAY,WAAU,MAAK,EAAE,WAAW,MAAM,MAAM,EAAE,WAAW,MAAM,EAAE;EAEpG,MAAM,WAAW,KAAK,YAAY;EAElC,IAAI,UAAU;GACZ,KAAK,YAAY,OAAO,eAAe,CAAC;GACxC,KAAK,YAAY,QAAQ;GACzB,SAAS,QAAQ;EACnB;EAEA,IAAI,MAAM,UAAU,QAAQ,MAAM,MAAM,OACtC;EAGF,MAAM,OAAO,KAAK,iBAAiB,MAAM,KAAK;EAE9C,KAAK,YAAY,KAAK,IAAI;EAC1B,KAAK,SAAS,IAAI;EAClB,KAAK,WAAW,IAAI;CACtB;CAEA,AAAO,YAAY,OAAkB,SAAgC;EACnE,MAAM;EAEN,KAAK,SAAS;EACd,KAAK,cAAc,SAAS,YAAY;EAExC,KAAK,YAAY,MAAM,SAAS,MAAM,OAAO;EAC7C,K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B;EAC5C,MAAM,YAAY,KAAK,OAAO;EAC9B,MAAM,IAAI,cAAc,OAAO,MAAO,aAAa,KAAM;EACzD,MAAM,IAAI,cAAc,OAAO,MAAO,aAAa,IAAK;EACxD,MAAM,IAAI,cAAc,OAAO,MAAM,YAAY;EACjD,KAAK,KAAK,IAAI,GAAG,GAAG,GAAG,KAAK,OAAO,OAAO;CAC5C;;;;;;CAOA,AAAQ,YAAkB;EACxB,MAAM,UAAU,KAAK,OAAO;EAC5B,MAAM,YAAY,KAAK,OAAO;EAE9B,IAAI,YAAY,KAAK,kBAAkB,cAAc,KAAK,aACxD;EAGF,KAAK,MAAM,SAAS,KAAK,aACvB,KAAK,WAAW,KAAK;EAGvB,KAAK,iBAAiB;EACtB,KAAK,cAAc;CACrB;AACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Container } from '@codexo/exojs';
|
|
2
|
-
import type { ImageLayer } from './ImageLayer';
|
|
3
2
|
import type { ImageLayerNode } from './ImageLayerNode';
|
|
4
|
-
import type { TileLayer } from './TileLayer';
|
|
5
3
|
import type { TileLayerNode } from './TileLayerNode';
|
|
6
4
|
/**
|
|
7
5
|
* A named, ordered group of layer nodes ({@link TileLayerNode}s and
|
|
@@ -47,13 +45,6 @@ export declare class TileMapBand extends Container {
|
|
|
47
45
|
name: string;
|
|
48
46
|
private readonly _layerNodes;
|
|
49
47
|
private _destroyed;
|
|
50
|
-
/**
|
|
51
|
-
* @param name The band name (unique within its owning view).
|
|
52
|
-
* @param layerNodes The layer nodes composing this band, already ordered by
|
|
53
|
-
* map document order. Adopted as children.
|
|
54
|
-
* @internal Constructed by {@link TileMapView}.
|
|
55
|
-
*/
|
|
56
|
-
constructor(name: string, layerNodes: ReadonlyArray<TileLayerNode | ImageLayerNode>);
|
|
57
48
|
/**
|
|
58
49
|
* The layer nodes that compose this band, in map document order - tile and
|
|
59
50
|
* image members interleaved. This is the band's **membership** list (the
|
|
@@ -75,30 +66,6 @@ export declare class TileMapBand extends Container {
|
|
|
75
66
|
* would report).
|
|
76
67
|
*/
|
|
77
68
|
updateBounds(): this;
|
|
78
|
-
/**
|
|
79
|
-
* Adopt a freshly created layer node into this band (used by
|
|
80
|
-
* {@link TileMapView.refreshLayers} when a newly added map layer joins this
|
|
81
|
-
* band). Appended; call {@link TileMapBand._reorder} afterwards to restore
|
|
82
|
-
* map document order.
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
_adopt(node: TileLayerNode | ImageLayerNode): void;
|
|
86
|
-
/**
|
|
87
|
-
* Drop a layer node from this band's membership without destroying it (used
|
|
88
|
-
* when its map layer was removed; the view destroys the node separately).
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
_release(node: TileLayerNode | ImageLayerNode): void;
|
|
92
|
-
/**
|
|
93
|
-
* Reorder this band's membership and its still-parented children to map
|
|
94
|
-
* document order. `documentIndex` maps a layer **instance** to its index in
|
|
95
|
-
* the map's combined document order - keyed by instance rather than id
|
|
96
|
-
* because a tile layer and an image layer may share an id in fallback-ordered
|
|
97
|
-
* maps. Layer nodes the caller has reparented away from this band keep their
|
|
98
|
-
* membership (for ownership) but are not re-adopted.
|
|
99
|
-
* @internal
|
|
100
|
-
*/
|
|
101
|
-
_reorder(documentIndex: ReadonlyMap<TileLayer | ImageLayer, number>): void;
|
|
102
69
|
/**
|
|
103
70
|
* Destroy the band: detach it from its application parent, then destroy the
|
|
104
71
|
* layer nodes it owns (freeing their chunk geometry / image sprites).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMapBand.d.ts","sourceRoot":"","sources":["../../src/TileMapBand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"TileMapBand.d.ts","sourceRoot":"","sources":["../../src/TileMapBand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC;;;;OAIG;IACa,IAAI,SAAM;IAE1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwC;IACpE,OAAO,CAAC,UAAU,CAAS;IAmB3B;;;;;OAKG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,aAAa,GAAG,cAAc,CAAC,CAErE;IAED;;;OAGG;IACI,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS;IAI/E,uDAAuD;IACvD,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;;OAKG;IACa,YAAY,IAAI,IAAI;IAsEpC;;;;;;;;OAQG;IACa,OAAO,IAAI,IAAI;CAmBhC"}
|
|
@@ -54,7 +54,12 @@ export declare class TileMapNode extends Container {
|
|
|
54
54
|
* unchanged. Setting the current value is a no-op; an invalid value throws and
|
|
55
55
|
* leaves the prior mode unchanged.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
57
|
+
* Defaults to `Geometry` because a tile grid is made of quads that share
|
|
58
|
+
* their edges: left unsnapped, a boundary landing between two device pixels
|
|
59
|
+
* is sampled across both, so the seams blur and shimmer as the view moves.
|
|
60
|
+
* Set `None` to opt out.
|
|
61
|
+
*
|
|
62
|
+
* @default PixelSnapMode.Geometry
|
|
58
63
|
* @stable
|
|
59
64
|
*/
|
|
60
65
|
get pixelSnapMode(): PixelSnapMode;
|
|
@@ -77,7 +82,7 @@ export declare class TileMapNode extends Container {
|
|
|
77
82
|
refreshLayers(): this;
|
|
78
83
|
/**
|
|
79
84
|
* Recomputed lazily on read, so it writes `_localBounds` directly rather than
|
|
80
|
-
* going through `
|
|
85
|
+
* going through `setLocalBounds`: an invalidating write inside a getter
|
|
81
86
|
* would re-dirty the node on every read.
|
|
82
87
|
*/
|
|
83
88
|
getLocalBounds(): ReadonlyRectangle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMapNode.d.ts","sourceRoot":"","sources":["../../src/TileMapNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6C;IACzE,OAAO,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"TileMapNode.d.ts","sourceRoot":"","sources":["../../src/TileMapNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6C;IACzE,OAAO,CAAC,cAAc,CAAyC;gBAE5C,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAa7D,yCAAyC;IACzC,IAAW,GAAG,IAAI,OAAO,CAExB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,IAAW,aAAa,IAAI,aAAa,CAExC;IAED,IAAW,aAAa,CAAC,IAAI,EAAE,aAAa,EAW3C;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,aAAa,GAAG,cAAc,CAAC,CAErE;IAED;;;OAGG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS;IAI7E;;;;OAIG;IACI,aAAa,IAAI,IAAI;IAe5B;;;;OAIG;IACa,cAAc,IAAI,iBAAiB;IAgBnC,OAAO,IAAI,IAAI;IAY/B,OAAO,CAAC,gBAAgB;CAYzB"}
|
package/dist/esm/TileMapNode.js
CHANGED
|
@@ -33,7 +33,7 @@ var TileMapNode = class extends Container {
|
|
|
33
33
|
_map;
|
|
34
34
|
_cullChunks;
|
|
35
35
|
_layerNodes = [];
|
|
36
|
-
_pixelSnapMode = PixelSnapMode.
|
|
36
|
+
_pixelSnapMode = PixelSnapMode.Geometry;
|
|
37
37
|
constructor(map, options) {
|
|
38
38
|
super();
|
|
39
39
|
this._map = map;
|
|
@@ -54,7 +54,12 @@ var TileMapNode = class extends Container {
|
|
|
54
54
|
* unchanged. Setting the current value is a no-op; an invalid value throws and
|
|
55
55
|
* leaves the prior mode unchanged.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
57
|
+
* Defaults to `Geometry` because a tile grid is made of quads that share
|
|
58
|
+
* their edges: left unsnapped, a boundary landing between two device pixels
|
|
59
|
+
* is sampled across both, so the seams blur and shimmer as the view moves.
|
|
60
|
+
* Set `None` to opt out.
|
|
61
|
+
*
|
|
62
|
+
* @default PixelSnapMode.Geometry
|
|
58
63
|
* @stable
|
|
59
64
|
*/
|
|
60
65
|
get pixelSnapMode() {
|
|
@@ -95,7 +100,7 @@ var TileMapNode = class extends Container {
|
|
|
95
100
|
}
|
|
96
101
|
/**
|
|
97
102
|
* Recomputed lazily on read, so it writes `_localBounds` directly rather than
|
|
98
|
-
* going through `
|
|
103
|
+
* going through `setLocalBounds`: an invalidating write inside a getter
|
|
99
104
|
* would re-dirty the node on every read.
|
|
100
105
|
*/
|
|
101
106
|
getLocalBounds() {
|
|
@@ -114,7 +119,7 @@ var TileMapNode = class extends Container {
|
|
|
114
119
|
_buildLayerNodes() {
|
|
115
120
|
for (const layer of this._map.renderableLayers) {
|
|
116
121
|
const node = layer instanceof ImageLayer ? new ImageLayerNode(layer) : new TileLayerNode(layer, { cullable: this._cullChunks });
|
|
117
|
-
|
|
122
|
+
node.pixelSnapMode = this._pixelSnapMode;
|
|
118
123
|
this._layerNodes.push(node);
|
|
119
124
|
this.addChild(node);
|
|
120
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMapNode.js","names":[],"sources":["../../src/TileMapNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Container } from '@codexo/exojs';\nimport { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\nimport { ImageLayer } from './ImageLayer';\nimport { ImageLayerNode } from './ImageLayerNode';\nimport { aggregateChildLocalBounds } from './nodeBounds';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport { TileLayerNode } from './TileLayerNode';\nimport type { TileMap } from './TileMap';\n\n/**\n * Options for a {@link TileMapNode}.\n * @advanced\n */\nexport interface TileMapNodeOptions {\n /**\n * Whether the map's chunk nodes participate in per-chunk view culling.\n * Forwarded to every {@link TileLayerNode}. Defaults to `true`.\n */\n readonly cullable?: boolean;\n}\n\n/**\n * A convenience scene node that renders a whole {@link TileMap} as a\n * {@link Container} of one node per renderable layer - a {@link TileLayerNode}\n * per tile layer and an {@link ImageLayerNode} per image layer, interleaved\n * back-to-front by the map's combined document order\n * ({@link import('./TileMap').TileMap.renderableLayers}).\n *\n * `TileMapNode` owns **only** its layer nodes - never application actors. Use\n * it for the simple, non-interleaved case (no actors between layers); for\n * actor interleaving, place individual `TileLayerNode`s / `ImageLayerNode`s\n * into your own scene graph instead (see `TileMapView`).\n *\n * The node references - but never owns - the {@link TileMap}: destroying the\n * node frees its layer/chunk nodes and their cached GPU geometry, while the\n * `TileMap` data and Loader-owned textures survive (free them via\n * `TileMap.destroy()` / `Loader.destroy()` respectively).\n *\n * Layers added to or removed from the map after construction are reflected only\n * after {@link TileMapNode.refreshLayers}.\n *\n * @advanced\n */\nexport class TileMapNode extends Container {\n private readonly _map: TileMap;\n private readonly _cullChunks: boolean;\n private readonly _layerNodes: Array<TileLayerNode | ImageLayerNode> = [];\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.
|
|
1
|
+
{"version":3,"file":"TileMapNode.js","names":[],"sources":["../../src/TileMapNode.ts"],"sourcesContent":["import type { ReadonlyRectangle } from '@codexo/exojs';\nimport { Container } from '@codexo/exojs';\nimport { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\nimport { ImageLayer } from './ImageLayer';\nimport { ImageLayerNode } from './ImageLayerNode';\nimport { aggregateChildLocalBounds } from './nodeBounds';\nimport { assertPixelSnapMode } from './pixelSnap';\nimport { TileLayerNode } from './TileLayerNode';\nimport type { TileMap } from './TileMap';\n\n/**\n * Options for a {@link TileMapNode}.\n * @advanced\n */\nexport interface TileMapNodeOptions {\n /**\n * Whether the map's chunk nodes participate in per-chunk view culling.\n * Forwarded to every {@link TileLayerNode}. Defaults to `true`.\n */\n readonly cullable?: boolean;\n}\n\n/**\n * A convenience scene node that renders a whole {@link TileMap} as a\n * {@link Container} of one node per renderable layer - a {@link TileLayerNode}\n * per tile layer and an {@link ImageLayerNode} per image layer, interleaved\n * back-to-front by the map's combined document order\n * ({@link import('./TileMap').TileMap.renderableLayers}).\n *\n * `TileMapNode` owns **only** its layer nodes - never application actors. Use\n * it for the simple, non-interleaved case (no actors between layers); for\n * actor interleaving, place individual `TileLayerNode`s / `ImageLayerNode`s\n * into your own scene graph instead (see `TileMapView`).\n *\n * The node references - but never owns - the {@link TileMap}: destroying the\n * node frees its layer/chunk nodes and their cached GPU geometry, while the\n * `TileMap` data and Loader-owned textures survive (free them via\n * `TileMap.destroy()` / `Loader.destroy()` respectively).\n *\n * Layers added to or removed from the map after construction are reflected only\n * after {@link TileMapNode.refreshLayers}.\n *\n * @advanced\n */\nexport class TileMapNode extends Container {\n private readonly _map: TileMap;\n private readonly _cullChunks: boolean;\n private readonly _layerNodes: Array<TileLayerNode | ImageLayerNode> = [];\n private _pixelSnapMode: PixelSnapMode = PixelSnapMode.Geometry;\n\n public constructor(map: TileMap, options?: TileMapNodeOptions) {\n super();\n\n this._map = map;\n this._cullChunks = options?.cullable ?? true;\n\n this._buildLayerNodes();\n\n if (!this._map.bounded) {\n this.cullable = false;\n }\n }\n\n /** The runtime map this node renders. */\n public get map(): TileMap {\n return this._map;\n }\n\n /**\n * Render-only pixel-snap mode applied to every layer (and forwarded to every\n * chunk node, current and rebuilt). Snaps tile chunk origins to the active\n * render target's device-pixel grid for crisp tiles; with integer tile pitch\n * the grid stays exact and adjacent chunks/layers cannot drift apart. Purely\n * visual - tile data, layer offsets, chunk revisions, and culling are\n * unchanged. Setting the current value is a no-op; an invalid value throws and\n * leaves the prior mode unchanged.\n *\n * Defaults to `Geometry` because a tile grid is made of quads that share\n * their edges: left unsnapped, a boundary landing between two device pixels\n * is sampled across both, so the seams blur and shimmer as the view moves.\n * Set `None` to opt out.\n *\n * @default PixelSnapMode.Geometry\n * @stable\n */\n public get pixelSnapMode(): PixelSnapMode {\n return this._pixelSnapMode;\n }\n\n public set pixelSnapMode(mode: PixelSnapMode) {\n if (mode === this._pixelSnapMode) {\n return;\n }\n\n assertPixelSnapMode(mode);\n this._pixelSnapMode = mode;\n\n for (const node of this._layerNodes) {\n node.pixelSnapMode = mode;\n }\n }\n\n /**\n * The layer render nodes - tile and image alike - in the map's combined\n * document order.\n */\n public get layerNodes(): ReadonlyArray<TileLayerNode | ImageLayerNode> {\n return this._layerNodes;\n }\n\n /**\n * Find the layer node rendering the named layer (tile or image; first match\n * in document order), or `undefined`.\n */\n public getLayerNode(name: string): TileLayerNode | ImageLayerNode | undefined {\n return this._layerNodes.find(node => node.layer.name === name);\n }\n\n /**\n * Rebuild the layer-node children from the map's current renderable layers.\n * Call after tile or image layers are structurally added to or removed from\n * the map.\n */\n public refreshLayers(): this {\n const previous = [...this._layerNodes];\n\n this.removeChildren();\n this._layerNodes.length = 0;\n\n for (const node of previous) {\n node.destroy();\n }\n\n this._buildLayerNodes();\n\n return this;\n }\n\n /**\n * Recomputed lazily on read, so it writes `_localBounds` directly rather than\n * going through `setLocalBounds`: an invalidating write inside a getter\n * would re-dirty the node on every read.\n */\n public override getLocalBounds(): ReadonlyRectangle {\n const bounds = this._localBounds;\n\n // Reading the pixel extents directly (rather than gating on `bounded`)\n // is what narrows them to numbers - `bounded` is a plain boolean getter.\n const { pixelHeight, pixelWidth } = this._map;\n\n if (pixelWidth !== undefined && pixelHeight !== undefined) {\n bounds.set(0, 0, pixelWidth, pixelHeight);\n } else if (this._layerNodes.length > 0) {\n aggregateChildLocalBounds(this._layerNodes, bounds);\n }\n\n return bounds;\n }\n\n public override destroy(): void {\n const layerNodes = [...this._layerNodes];\n\n this._layerNodes.length = 0;\n\n super.destroy();\n\n for (const node of layerNodes) {\n node.destroy();\n }\n }\n\n private _buildLayerNodes(): void {\n for (const layer of this._map.renderableLayers) {\n const node = layer instanceof ImageLayer ? new ImageLayerNode(layer) : new TileLayerNode(layer, { cullable: this._cullChunks });\n\n // Unconditional: a node built after the map was set to `None` has to\n // inherit that too, not just a non-default mode.\n node.pixelSnapMode = this._pixelSnapMode;\n\n this._layerNodes.push(node);\n this.addChild(node);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,cAAb,cAAiC,UAAU;CACzC,AAAiB;CACjB,AAAiB;CACjB,AAAiB,cAAqD,CAAC;CACvE,AAAQ,iBAAgC,cAAc;CAEtD,AAAO,YAAY,KAAc,SAA8B;EAC7D,MAAM;EAEN,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS,YAAY;EAExC,KAAK,iBAAiB;EAEtB,IAAI,CAAC,KAAK,KAAK,SACb,KAAK,WAAW;CAEpB;;CAGA,IAAW,MAAe;EACxB,OAAO,KAAK;CACd;;;;;;;;;;;;;;;;;;CAmBA,IAAW,gBAA+B;EACxC,OAAO,KAAK;CACd;CAEA,IAAW,cAAc,MAAqB;EAC5C,IAAI,SAAS,KAAK,gBAChB;EAGF,oBAAoB,IAAI;EACxB,KAAK,iBAAiB;EAEtB,KAAK,MAAM,QAAQ,KAAK,aACtB,KAAK,gBAAgB;CAEzB;;;;;CAMA,IAAW,aAA4D;EACrE,OAAO,KAAK;CACd;;;;;CAMA,AAAO,aAAa,MAA0D;EAC5E,OAAO,KAAK,YAAY,MAAK,SAAQ,KAAK,MAAM,SAAS,IAAI;CAC/D;;;;;;CAOA,AAAO,gBAAsB;EAC3B,MAAM,WAAW,CAAC,GAAG,KAAK,WAAW;EAErC,KAAK,eAAe;EACpB,KAAK,YAAY,SAAS;EAE1B,KAAK,MAAM,QAAQ,UACjB,KAAK,QAAQ;EAGf,KAAK,iBAAiB;EAEtB,OAAO;CACT;;;;;;CAOA,AAAgB,iBAAoC;EAClD,MAAM,SAAS,KAAK;EAIpB,MAAM,EAAE,aAAa,eAAe,KAAK;EAEzC,IAAI,eAAe,UAAa,gBAAgB,QAC9C,OAAO,IAAI,GAAG,GAAG,YAAY,WAAW;OACnC,IAAI,KAAK,YAAY,SAAS,GACnC,0BAA0B,KAAK,aAAa,MAAM;EAGpD,OAAO;CACT;CAEA,AAAgB,UAAgB;EAC9B,MAAM,aAAa,CAAC,GAAG,KAAK,WAAW;EAEvC,KAAK,YAAY,SAAS;EAE1B,MAAM,QAAQ;EAEd,KAAK,MAAM,QAAQ,YACjB,KAAK,QAAQ;CAEjB;CAEA,AAAQ,mBAAyB;EAC/B,KAAK,MAAM,SAAS,KAAK,KAAK,kBAAkB;GAC9C,MAAM,OAAO,iBAAiB,aAAa,IAAI,eAAe,KAAK,IAAI,IAAI,cAAc,OAAO,EAAE,UAAU,KAAK,YAAY,CAAC;GAI9H,KAAK,gBAAgB,KAAK;GAE1B,KAAK,YAAY,KAAK,IAAI;GAC1B,KAAK,SAAS,IAAI;EACpB;CACF;AACF"}
|
|
@@ -140,7 +140,12 @@ export declare class TileMapView {
|
|
|
140
140
|
* current value is a no-op; an invalid value throws and leaves the prior mode
|
|
141
141
|
* unchanged.
|
|
142
142
|
*
|
|
143
|
-
*
|
|
143
|
+
* Defaults to `Geometry` because a tile grid is made of quads that share
|
|
144
|
+
* their edges: left unsnapped, a boundary landing between two device pixels
|
|
145
|
+
* is sampled across both, so the seams blur and shimmer as the view moves.
|
|
146
|
+
* Set `None` to opt out.
|
|
147
|
+
*
|
|
148
|
+
* @default PixelSnapMode.Geometry
|
|
144
149
|
* @stable
|
|
145
150
|
*/
|
|
146
151
|
get pixelSnapMode(): PixelSnapMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileMapView.d.ts","sourceRoot":"","sources":["../../src/TileMapView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,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C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC;;;;;;;;;;;;;;;;;;;OAmBG;IACI,aAAa,IAAI,IAAI;IA8F5B;;;;;;;OAOG;IACI,OAAO,IAAI,IAAI;IAsCtB,4EAA4E;IAC5E,OAAO,CAAC,WAAW;IAwCnB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAuCxB,4EAA4E;IAC5E,OAAO,CAAC,QAAQ;IAUhB,8EAA8E;IAC9E,OAAO,CAAC,cAAc;IAatB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAmB1B,+EAA+E;IAC/E,OAAO,CAAC,cAAc;IAItB,2EAA2E;IAC3E,OAAO,CAAC,eAAe;IAevB,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAkBxB,8EAA8E;IAC9E,OAAO,CAAC,iBAAiB;CAc1B"}
|
package/dist/esm/TileMapView.js
CHANGED
|
@@ -71,7 +71,7 @@ var TileMapView = class {
|
|
|
71
71
|
/** Image layer id → its canonical image layer node. */
|
|
72
72
|
_imageLayerNodeById = /* @__PURE__ */ new Map();
|
|
73
73
|
_destroyed = false;
|
|
74
|
-
_pixelSnapMode = PixelSnapMode.
|
|
74
|
+
_pixelSnapMode = PixelSnapMode.Geometry;
|
|
75
75
|
/**
|
|
76
76
|
* @param map The runtime map to compose. Referenced, never owned.
|
|
77
77
|
* @param options Band definitions and culling.
|
|
@@ -120,7 +120,12 @@ var TileMapView = class {
|
|
|
120
120
|
* current value is a no-op; an invalid value throws and leaves the prior mode
|
|
121
121
|
* unchanged.
|
|
122
122
|
*
|
|
123
|
-
*
|
|
123
|
+
* Defaults to `Geometry` because a tile grid is made of quads that share
|
|
124
|
+
* their edges: left unsnapped, a boundary landing between two device pixels
|
|
125
|
+
* is sampled across both, so the seams blur and shimmer as the view moves.
|
|
126
|
+
* Set `None` to opt out.
|
|
127
|
+
*
|
|
128
|
+
* @default PixelSnapMode.Geometry
|
|
124
129
|
* @stable
|
|
125
130
|
*/
|
|
126
131
|
get pixelSnapMode() {
|
|
@@ -223,7 +228,7 @@ var TileMapView = class {
|
|
|
223
228
|
let node = this._layerNodeById.get(layer.id);
|
|
224
229
|
if (!node) {
|
|
225
230
|
node = new TileLayerNode(layer, { cullable: this._cullable });
|
|
226
|
-
|
|
231
|
+
node.pixelSnapMode = this._pixelSnapMode;
|
|
227
232
|
this._layerNodeById.set(layer.id, node);
|
|
228
233
|
this._assignNewNode(node, layer);
|
|
229
234
|
}
|
|
@@ -236,7 +241,7 @@ var TileMapView = class {
|
|
|
236
241
|
let node = this._imageLayerNodes.find((candidate) => candidate.layer === imageLayer);
|
|
237
242
|
if (!node) {
|
|
238
243
|
node = new ImageLayerNode(imageLayer);
|
|
239
|
-
|
|
244
|
+
node.pixelSnapMode = this._pixelSnapMode;
|
|
240
245
|
this._imageLayerNodeById.set(imageLayer.id, node);
|
|
241
246
|
this._assignNewNode(node, imageLayer);
|
|
242
247
|
}
|