@codexo/exojs-tilemap 0.13.0 → 0.15.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/dist/esm/ImageLayer.d.ts +81 -0
- package/dist/esm/ImageLayer.js +67 -0
- package/dist/esm/ImageLayer.js.map +1 -0
- package/dist/esm/ObjectLayer.d.ts +277 -0
- package/dist/esm/ObjectLayer.js +176 -0
- package/dist/esm/ObjectLayer.js.map +1 -0
- package/dist/esm/TileAnimator.d.ts +62 -0
- package/dist/esm/TileAnimator.js +169 -0
- package/dist/esm/TileAnimator.js.map +1 -0
- package/dist/esm/TileChunk.js.map +1 -1
- package/dist/esm/TileChunkNode.d.ts +1 -1
- package/dist/esm/TileChunkNode.js +1 -1
- package/dist/esm/TileLayer.d.ts +33 -2
- package/dist/esm/TileLayer.js +26 -2
- package/dist/esm/TileLayer.js.map +1 -1
- package/dist/esm/TileLayerNode.d.ts +10 -3
- package/dist/esm/TileLayerNode.js +35 -7
- package/dist/esm/TileLayerNode.js.map +1 -1
- package/dist/esm/TileMap.d.ts +71 -1
- package/dist/esm/TileMap.js +100 -1
- package/dist/esm/TileMap.js.map +1 -1
- package/dist/esm/TileMapBand.d.ts +6 -3
- package/dist/esm/TileMapBand.js +7 -6
- package/dist/esm/TileMapBand.js.map +1 -1
- package/dist/esm/TileMapNode.d.ts +1 -1
- package/dist/esm/TileMapView.d.ts +1 -1
- package/dist/esm/TileMapView.js.map +1 -1
- package/dist/esm/TileSet.d.ts +12 -0
- package/dist/esm/TileSet.js +30 -2
- package/dist/esm/TileSet.js.map +1 -1
- package/dist/esm/WangSet.d.ts +79 -0
- package/dist/esm/WangSet.js +81 -0
- package/dist/esm/WangSet.js.map +1 -0
- package/dist/esm/autoTile.d.ts +83 -0
- package/dist/esm/autoTile.js +214 -0
- package/dist/esm/autoTile.js.map +1 -0
- package/dist/esm/chunkGeometry.js +4 -3
- package/dist/esm/chunkGeometry.js.map +1 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pixelSnap.d.ts +1 -1
- package/dist/esm/public.d.ts +11 -2
- package/dist/esm/register.js +6 -1
- package/dist/esm/register.js.map +1 -1
- package/dist/esm/tilemapExtension.d.ts +4 -3
- package/dist/esm/tilemapExtension.js +8 -4
- package/dist/esm/tilemapExtension.js.map +1 -1
- package/dist/esm/tilemapSerializers.d.ts +19 -0
- package/dist/esm/tilemapSerializers.js +47 -0
- package/dist/esm/tilemapSerializers.js.map +1 -0
- package/dist/esm/types.d.ts +86 -4
- package/dist/esm/types.js +18 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +2 -2
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +1 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +1 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +2 -2
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { TileLayer } from './TileLayer';
|
|
2
|
+
import type { WangSet } from './WangSet';
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link autoTile} and {@link refreshCell}.
|
|
5
|
+
*/
|
|
6
|
+
export interface AutoTileOptions {
|
|
7
|
+
/**
|
|
8
|
+
* When provided, only cells for which `matchFn` returns `true` are treated
|
|
9
|
+
* as part of the Wang group. The function receives the cell's `localTileId`,
|
|
10
|
+
* `tilesetIndex`, and tile coordinates `(x, y)`.
|
|
11
|
+
*
|
|
12
|
+
* If omitted, group membership defaults to {@link WangSet.isMember} on the
|
|
13
|
+
* cell's `localTileId` (and a matching `tilesetIndex`). That default is
|
|
14
|
+
* *variant-stable* — every autotiled variant counts as a member — which is
|
|
15
|
+
* what makes {@link refreshCell} correct. If you supply a `matchFn` for use
|
|
16
|
+
* with `refreshCell`, it MUST likewise be variant-stable (independent of the
|
|
17
|
+
* currently-rendered variant), e.g. keyed on a separate logical-terrain grid
|
|
18
|
+
* or a tile property.
|
|
19
|
+
*/
|
|
20
|
+
matchFn?: (localTileId: number, tilesetIndex: number, x: number, y: number) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* When `true` (default), out-of-bounds neighbors are treated as though
|
|
23
|
+
* they belong to the Wang group, so border tiles fill correctly to the
|
|
24
|
+
* layer edge. Set to `false` to leave border tiles visually open.
|
|
25
|
+
*/
|
|
26
|
+
wrapBorder?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Apply Wang autotiling to `layer` using `wangSet`.
|
|
30
|
+
*
|
|
31
|
+
* Iterates every cell in the layer. For each cell that belongs to the Wang
|
|
32
|
+
* group, computes a neighbor bitmask and looks up the correct local tile ID
|
|
33
|
+
* from {@link WangSet.blobMap}. The layer is mutated in place; cells whose
|
|
34
|
+
* computed bitmask has no mapping in the blobMap are left unchanged.
|
|
35
|
+
*
|
|
36
|
+
* The function performs two passes (snapshot then write) so neighbor tests
|
|
37
|
+
* always reflect the pre-call state regardless of processing order.
|
|
38
|
+
*
|
|
39
|
+
* **Group membership.** With no `matchFn`, a cell belongs to the group when its
|
|
40
|
+
* `tilesetIndex` matches {@link WangSet.tilesetIndex} and its `localTileId` is a
|
|
41
|
+
* {@link WangSet.isMember member} of the set. Membership covers every variant
|
|
42
|
+
* the set can produce, so re-running `autoTile` (or {@link refreshCell}) on
|
|
43
|
+
* already-autotiled data is stable. Paint with a tile ID that is a member (a
|
|
44
|
+
* blobMap value, or one listed in {@link WangSetOptions.members}).
|
|
45
|
+
*
|
|
46
|
+
* **Blob mode bitmask (bit positions):**
|
|
47
|
+
* ```
|
|
48
|
+
* 1 | 2 | 4
|
|
49
|
+
* 8 | -- | 16
|
|
50
|
+
* 32 | 64 | 128
|
|
51
|
+
* ```
|
|
52
|
+
* Diagonal bits (1, 4, 32, 128) are only set when both adjacent cardinals
|
|
53
|
+
* are also set (the "corner dependency" rule that reduces 256 raw
|
|
54
|
+
* combinations to 47 valid blob states).
|
|
55
|
+
*
|
|
56
|
+
* **Edge mode bitmask (bit positions):** Top=1, Right=2, Bottom=4, Left=8.
|
|
57
|
+
*/
|
|
58
|
+
export declare function autoTile(layer: TileLayer, wangSet: WangSet, options?: AutoTileOptions): void;
|
|
59
|
+
/**
|
|
60
|
+
* Incrementally re-autotile a single cell and its eight neighbours after an
|
|
61
|
+
* edit, instead of re-running {@link autoTile} over the whole layer.
|
|
62
|
+
*
|
|
63
|
+
* A cell's blob/edge mask depends only on its immediate neighbours, so painting
|
|
64
|
+
* or erasing cell `(x, y)` can change the variant of that cell and of the (up
|
|
65
|
+
* to) eight cells that have it as a neighbour — but nothing further out. This
|
|
66
|
+
* recomputes exactly that 3×3 neighbourhood, touching only the 1–4 chunks it
|
|
67
|
+
* spans (and rebuilding geometry only for chunks whose tiles actually change).
|
|
68
|
+
* For a paint operation this is O(1) work versus `autoTile`'s O(width·height).
|
|
69
|
+
*
|
|
70
|
+
* Membership is read live from the layer, so the membership test MUST be
|
|
71
|
+
* variant-stable: the default ({@link WangSet.isMember}) is, and any custom
|
|
72
|
+
* `matchFn` you pass must be too (see {@link AutoTileOptions.matchFn}).
|
|
73
|
+
*
|
|
74
|
+
* Typical editor use: write the painted tile with `layer.setTileAt(...)` using
|
|
75
|
+
* a member tile ID, then call `refreshCell(layer, x, y, wangSet)`.
|
|
76
|
+
*
|
|
77
|
+
* @param layer The layer to update in place.
|
|
78
|
+
* @param x Tile X of the edited cell.
|
|
79
|
+
* @param y Tile Y of the edited cell.
|
|
80
|
+
* @param wangSet The Wang set to resolve variants from.
|
|
81
|
+
* @param options Membership / border options (shared with {@link autoTile}).
|
|
82
|
+
*/
|
|
83
|
+
export declare function refreshCell(layer: TileLayer, x: number, y: number, wangSet: WangSet, options?: AutoTileOptions): void;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { unpackTile, TILE_TRANSFORM_IDENTITY } from './types.js';
|
|
2
|
+
|
|
3
|
+
// ── Module-level mask helpers ─────────────────────────────────────────────
|
|
4
|
+
/**
|
|
5
|
+
* Compute a 4-bit edge bitmask for the cell at `(tx, ty)`.
|
|
6
|
+
* Top=1, Right=2, Bottom=4, Left=8.
|
|
7
|
+
*/
|
|
8
|
+
function computeEdgeMask(tx, ty, inGroup) {
|
|
9
|
+
let mask = 0;
|
|
10
|
+
if (inGroup(tx, ty - 1))
|
|
11
|
+
mask |= 1;
|
|
12
|
+
if (inGroup(tx + 1, ty))
|
|
13
|
+
mask |= 2;
|
|
14
|
+
if (inGroup(tx, ty + 1))
|
|
15
|
+
mask |= 4;
|
|
16
|
+
if (inGroup(tx - 1, ty))
|
|
17
|
+
mask |= 8;
|
|
18
|
+
return mask;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Compute an 8-bit blob bitmask for the cell at `(tx, ty)` using the
|
|
22
|
+
* corner-dependency rule: diagonal bits are only set when both adjacent
|
|
23
|
+
* cardinal directions are also set.
|
|
24
|
+
*
|
|
25
|
+
* Bit layout:
|
|
26
|
+
* ```
|
|
27
|
+
* 1 | 2 | 4
|
|
28
|
+
* 8 | -- | 16
|
|
29
|
+
* 32 | 64 | 128
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function computeBlobMask(tx, ty, inGroup) {
|
|
33
|
+
const top = inGroup(tx, ty - 1);
|
|
34
|
+
const right = inGroup(tx + 1, ty);
|
|
35
|
+
const bottom = inGroup(tx, ty + 1);
|
|
36
|
+
const left = inGroup(tx - 1, ty);
|
|
37
|
+
let mask = 0;
|
|
38
|
+
if (top)
|
|
39
|
+
mask |= 2;
|
|
40
|
+
if (right)
|
|
41
|
+
mask |= 16;
|
|
42
|
+
if (bottom)
|
|
43
|
+
mask |= 64;
|
|
44
|
+
if (left)
|
|
45
|
+
mask |= 8;
|
|
46
|
+
// Corner bits: only when BOTH adjacent cardinals are set.
|
|
47
|
+
if (top && left && inGroup(tx - 1, ty - 1))
|
|
48
|
+
mask |= 1;
|
|
49
|
+
if (top && right && inGroup(tx + 1, ty - 1))
|
|
50
|
+
mask |= 4;
|
|
51
|
+
if (bottom && left && inGroup(tx - 1, ty + 1))
|
|
52
|
+
mask |= 32;
|
|
53
|
+
if (bottom && right && inGroup(tx + 1, ty + 1))
|
|
54
|
+
mask |= 128;
|
|
55
|
+
return mask;
|
|
56
|
+
}
|
|
57
|
+
/** Compute the mask for a cell given the Wang mode and a membership predicate. */
|
|
58
|
+
function computeMask(wangSet, tx, ty, inGroup) {
|
|
59
|
+
return wangSet.type === 'edge'
|
|
60
|
+
? computeEdgeMask(tx, ty, inGroup)
|
|
61
|
+
: computeBlobMask(tx, ty, inGroup);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Apply the variant computed for cell `(tx, ty)` to `layer`, preserving the
|
|
65
|
+
* cell's current orientation transform. No-op if the mask has no mapping or
|
|
66
|
+
* the target tileset is missing.
|
|
67
|
+
*/
|
|
68
|
+
function applyVariant(layer, wangSet, tx, ty, inGroup) {
|
|
69
|
+
const newLocalTileId = wangSet.getTileId(computeMask(wangSet, tx, ty, inGroup));
|
|
70
|
+
if (newLocalTileId === undefined)
|
|
71
|
+
return;
|
|
72
|
+
const tileset = layer.tilesets[wangSet.tilesetIndex];
|
|
73
|
+
if (!tileset)
|
|
74
|
+
return;
|
|
75
|
+
// Preserve the existing orientation transform if the cell already holds one.
|
|
76
|
+
const existing = layer.getTileAt(tx, ty);
|
|
77
|
+
layer.setTileAt(tx, ty, {
|
|
78
|
+
localTileId: newLocalTileId,
|
|
79
|
+
tileset,
|
|
80
|
+
transform: existing ? existing.transform : TILE_TRANSFORM_IDENTITY,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// ── Public API ────────────────────────────────────────────────────────────
|
|
84
|
+
/**
|
|
85
|
+
* Apply Wang autotiling to `layer` using `wangSet`.
|
|
86
|
+
*
|
|
87
|
+
* Iterates every cell in the layer. For each cell that belongs to the Wang
|
|
88
|
+
* group, computes a neighbor bitmask and looks up the correct local tile ID
|
|
89
|
+
* from {@link WangSet.blobMap}. The layer is mutated in place; cells whose
|
|
90
|
+
* computed bitmask has no mapping in the blobMap are left unchanged.
|
|
91
|
+
*
|
|
92
|
+
* The function performs two passes (snapshot then write) so neighbor tests
|
|
93
|
+
* always reflect the pre-call state regardless of processing order.
|
|
94
|
+
*
|
|
95
|
+
* **Group membership.** With no `matchFn`, a cell belongs to the group when its
|
|
96
|
+
* `tilesetIndex` matches {@link WangSet.tilesetIndex} and its `localTileId` is a
|
|
97
|
+
* {@link WangSet.isMember member} of the set. Membership covers every variant
|
|
98
|
+
* the set can produce, so re-running `autoTile` (or {@link refreshCell}) on
|
|
99
|
+
* already-autotiled data is stable. Paint with a tile ID that is a member (a
|
|
100
|
+
* blobMap value, or one listed in {@link WangSetOptions.members}).
|
|
101
|
+
*
|
|
102
|
+
* **Blob mode bitmask (bit positions):**
|
|
103
|
+
* ```
|
|
104
|
+
* 1 | 2 | 4
|
|
105
|
+
* 8 | -- | 16
|
|
106
|
+
* 32 | 64 | 128
|
|
107
|
+
* ```
|
|
108
|
+
* Diagonal bits (1, 4, 32, 128) are only set when both adjacent cardinals
|
|
109
|
+
* are also set (the "corner dependency" rule that reduces 256 raw
|
|
110
|
+
* combinations to 47 valid blob states).
|
|
111
|
+
*
|
|
112
|
+
* **Edge mode bitmask (bit positions):** Top=1, Right=2, Bottom=4, Left=8.
|
|
113
|
+
*/
|
|
114
|
+
function autoTile(layer, wangSet, options) {
|
|
115
|
+
const matchFn = options?.matchFn;
|
|
116
|
+
const wrapBorder = options?.wrapBorder ?? true;
|
|
117
|
+
const w = layer.width;
|
|
118
|
+
const h = layer.height;
|
|
119
|
+
const snapshot = new Map();
|
|
120
|
+
for (let ty = 0; ty < h; ty++) {
|
|
121
|
+
for (let tx = 0; tx < w; tx++) {
|
|
122
|
+
const packed = layer.getRawTileAt(tx, ty);
|
|
123
|
+
if (packed === 0)
|
|
124
|
+
continue;
|
|
125
|
+
const decoded = unpackTile(packed);
|
|
126
|
+
if (!decoded)
|
|
127
|
+
continue;
|
|
128
|
+
snapshot.set(ty * w + tx, decoded);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// ── Membership test (reads the snapshot) ─────────────────────────────
|
|
132
|
+
const isInGroup = (nx, ny) => {
|
|
133
|
+
if (nx < 0 || nx >= w || ny < 0 || ny >= h)
|
|
134
|
+
return wrapBorder;
|
|
135
|
+
const cell = snapshot.get(ny * w + nx);
|
|
136
|
+
if (!cell)
|
|
137
|
+
return false;
|
|
138
|
+
if (matchFn)
|
|
139
|
+
return matchFn(cell.localTileId, cell.tilesetIndex, nx, ny);
|
|
140
|
+
return cell.tilesetIndex === wangSet.tilesetIndex && wangSet.isMember(cell.localTileId);
|
|
141
|
+
};
|
|
142
|
+
// ── Pass 2: compute masks and write ──────────────────────────────────
|
|
143
|
+
for (let ty = 0; ty < h; ty++) {
|
|
144
|
+
for (let tx = 0; tx < w; tx++) {
|
|
145
|
+
const cellInfo = snapshot.get(ty * w + tx);
|
|
146
|
+
if (!cellInfo)
|
|
147
|
+
continue;
|
|
148
|
+
// Skip cells that are not part of the group.
|
|
149
|
+
const isMember = matchFn
|
|
150
|
+
? matchFn(cellInfo.localTileId, cellInfo.tilesetIndex, tx, ty)
|
|
151
|
+
: cellInfo.tilesetIndex === wangSet.tilesetIndex && wangSet.isMember(cellInfo.localTileId);
|
|
152
|
+
if (!isMember)
|
|
153
|
+
continue;
|
|
154
|
+
applyVariant(layer, wangSet, tx, ty, isInGroup);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Incrementally re-autotile a single cell and its eight neighbours after an
|
|
160
|
+
* edit, instead of re-running {@link autoTile} over the whole layer.
|
|
161
|
+
*
|
|
162
|
+
* A cell's blob/edge mask depends only on its immediate neighbours, so painting
|
|
163
|
+
* or erasing cell `(x, y)` can change the variant of that cell and of the (up
|
|
164
|
+
* to) eight cells that have it as a neighbour — but nothing further out. This
|
|
165
|
+
* recomputes exactly that 3×3 neighbourhood, touching only the 1–4 chunks it
|
|
166
|
+
* spans (and rebuilding geometry only for chunks whose tiles actually change).
|
|
167
|
+
* For a paint operation this is O(1) work versus `autoTile`'s O(width·height).
|
|
168
|
+
*
|
|
169
|
+
* Membership is read live from the layer, so the membership test MUST be
|
|
170
|
+
* variant-stable: the default ({@link WangSet.isMember}) is, and any custom
|
|
171
|
+
* `matchFn` you pass must be too (see {@link AutoTileOptions.matchFn}).
|
|
172
|
+
*
|
|
173
|
+
* Typical editor use: write the painted tile with `layer.setTileAt(...)` using
|
|
174
|
+
* a member tile ID, then call `refreshCell(layer, x, y, wangSet)`.
|
|
175
|
+
*
|
|
176
|
+
* @param layer The layer to update in place.
|
|
177
|
+
* @param x Tile X of the edited cell.
|
|
178
|
+
* @param y Tile Y of the edited cell.
|
|
179
|
+
* @param wangSet The Wang set to resolve variants from.
|
|
180
|
+
* @param options Membership / border options (shared with {@link autoTile}).
|
|
181
|
+
*/
|
|
182
|
+
function refreshCell(layer, x, y, wangSet, options) {
|
|
183
|
+
const matchFn = options?.matchFn;
|
|
184
|
+
const wrapBorder = options?.wrapBorder ?? true;
|
|
185
|
+
const w = layer.width;
|
|
186
|
+
const h = layer.height;
|
|
187
|
+
// Live membership test (reads the current layer; variant-stable by default).
|
|
188
|
+
const isInGroup = (nx, ny) => {
|
|
189
|
+
if (nx < 0 || nx >= w || ny < 0 || ny >= h)
|
|
190
|
+
return wrapBorder;
|
|
191
|
+
const tile = layer.getTileAt(nx, ny);
|
|
192
|
+
if (!tile)
|
|
193
|
+
return false;
|
|
194
|
+
const tsi = layer.tilesets.indexOf(tile.tileset);
|
|
195
|
+
if (matchFn)
|
|
196
|
+
return matchFn(tile.localTileId, tsi, nx, ny);
|
|
197
|
+
return tsi === wangSet.tilesetIndex && wangSet.isMember(tile.localTileId);
|
|
198
|
+
};
|
|
199
|
+
// Recompute the edited cell and its eight neighbours.
|
|
200
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
201
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
202
|
+
const tx = x + dx;
|
|
203
|
+
const ty = y + dy;
|
|
204
|
+
if (!layer.inBounds(tx, ty))
|
|
205
|
+
continue;
|
|
206
|
+
if (!isInGroup(tx, ty))
|
|
207
|
+
continue;
|
|
208
|
+
applyVariant(layer, wangSet, tx, ty, isInGroup);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export { autoTile, refreshCell };
|
|
214
|
+
//# sourceMappingURL=autoTile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoTile.js","sources":["../../../src/autoTile.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA8BA;AAEA;;;AAGG;AACH,SAAS,eAAe,CACtB,EAAU,EACV,EAAU,EACV,OAA4C,EAAA;IAE5C,IAAI,IAAI,GAAG,CAAC;AACZ,IAAA,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAAE,IAAI,IAAI,CAAC;AAClC,IAAA,IAAI,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;QAAE,IAAI,IAAI,CAAC;AAClC,IAAA,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAAE,IAAI,IAAI,CAAC;AAClC,IAAA,IAAI,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;QAAE,IAAI,IAAI,CAAC;AAClC,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;;;;;;AAWG;AACH,SAAS,eAAe,CACtB,EAAU,EACV,EAAU,EACV,OAA4C,EAAA;IAE5C,MAAM,GAAG,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,OAAO,C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E,EAAE;AAC/B,QAAA,KAAK,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE;AAC/B,YAAA,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;AACjB,YAAA,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;YACjB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;gBAAE;AAC7B,YAAA,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC;gBAAE;YACxB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC;QACjD;IACF;AACF;;;;"}
|
|
@@ -70,9 +70,10 @@ function buildChunkPages(chunk, tilesets, tileWidth, tileHeight) {
|
|
|
70
70
|
const u1 = (sx + rect.width) / textureWidth;
|
|
71
71
|
const v1 = (sy + rect.height) / textureHeight;
|
|
72
72
|
// Bottom-left aligned destination (Tiled orthogonal). Uniform tiles
|
|
73
|
-
// (rect.height === tileHeight) collapse to a plain cell rect.
|
|
74
|
-
|
|
75
|
-
const
|
|
73
|
+
// (rect.height === tileHeight) collapse to a plain cell rect. The
|
|
74
|
+
// tileset's visual draw offset (Tiled `tileoffset`) shifts every tile.
|
|
75
|
+
const x0 = lx * tileWidth + tileset.offsetX;
|
|
76
|
+
const y0 = ly * tileHeight + tileHeight - rect.height + tileset.offsetY;
|
|
76
77
|
const x1 = x0 + rect.width;
|
|
77
78
|
const y1 = y0 + rect.height;
|
|
78
79
|
let bucket = buckets.get(tileset);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunkGeometry.js","sources":["../../../src/chunkGeometry.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAgDA;AACM,SAAU,UAAU,CAAC,SAAwB,EAAA;AACjD,IAAA,OAAO,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,KAAK,GAA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
+
export { ObjectKind, ObjectLayer } from './ObjectLayer.js';
|
|
2
4
|
export { TileLayer } from './TileLayer.js';
|
|
3
5
|
export { TileMap } from './TileMap.js';
|
|
4
6
|
export { TileSet } from './TileSet.js';
|
|
@@ -6,5 +8,8 @@ export { TileLayerNode } from './TileLayerNode.js';
|
|
|
6
8
|
export { TileMapNode } from './TileMapNode.js';
|
|
7
9
|
export { TileMapBand } from './TileMapBand.js';
|
|
8
10
|
export { TileMapView } from './TileMapView.js';
|
|
9
|
-
export { TILE_TRANSFORM_IDENTITY, tileToChunkCoord, tileToLocalInChunk } from './types.js';
|
|
11
|
+
export { TILE_TRANSFORM_IDENTITY, TilePropertyKind, tileToChunkCoord, tileToLocalInChunk } from './types.js';
|
|
12
|
+
export { TileAnimator } from './TileAnimator.js';
|
|
13
|
+
export { autoTile, refreshCell } from './autoTile.js';
|
|
14
|
+
export { WangSet } from './WangSet.js';
|
|
10
15
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/dist/esm/pixelSnap.d.ts
CHANGED
package/dist/esm/public.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { tilemapExtension } from './tilemapExtension';
|
|
2
2
|
export type { Extension } from '@codexo/exojs/extensions';
|
|
3
|
+
export type { ImageLayerOptions } from './ImageLayer';
|
|
4
|
+
export { ImageLayer } from './ImageLayer';
|
|
5
|
+
export type { EllipseObject, ObjectLayerOptions, ObjectPoint, ObjectQuery, ObjectSchema, PointObject, PolygonObject, PolylineObject, RectangleObject, TextObject, TextStyle, TileMapObject, TileMapObjectKind, TileObject, TypedObject, } from './ObjectLayer';
|
|
6
|
+
export { ObjectKind, ObjectLayer } from './ObjectLayer';
|
|
3
7
|
export type { ReadonlyTileChunk } from './TileChunk';
|
|
4
8
|
export type { TileLayerOptions } from './TileLayer';
|
|
5
9
|
export { TileLayer } from './TileLayer';
|
|
@@ -14,5 +18,10 @@ export { TileMapNode } from './TileMapNode';
|
|
|
14
18
|
export { TileMapBand } from './TileMapBand';
|
|
15
19
|
export type { TileLayerSelector, TileMapBandDefinition, TileMapViewOptions, } from './TileMapView';
|
|
16
20
|
export { TileMapView } from './TileMapView';
|
|
17
|
-
export type { ChunkCoord, PackedTile, ResolvedTile, TileDefinition, TileProperties, TilePropertyValue, TileTransform, } from './types';
|
|
18
|
-
export { TILE_TRANSFORM_IDENTITY, tileToChunkCoord, tileToLocalInChunk, } from './types';
|
|
21
|
+
export type { ChunkCoord, PackedTile, ResolvedTile, TileAnimationFrame, TileDefinition, TileProperties, TilePropertyObjectRef, TilePropertyPoint, TilePropertyTileRef, TilePropertyValue, TileTransform, } from './types';
|
|
22
|
+
export { TILE_TRANSFORM_IDENTITY, TilePropertyKind, tileToChunkCoord, tileToLocalInChunk, } from './types';
|
|
23
|
+
export { TileAnimator } from './TileAnimator';
|
|
24
|
+
export type { AutoTileOptions } from './autoTile';
|
|
25
|
+
export { autoTile, refreshCell } from './autoTile';
|
|
26
|
+
export type { WangSetOptions } from './WangSet';
|
|
27
|
+
export { WangSet } from './WangSet';
|
package/dist/esm/register.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ExtensionRegistry } from '@codexo/exojs/extensions';
|
|
2
2
|
import { tilemapExtension } from './tilemapExtension.js';
|
|
3
|
+
export { ImageLayer } from './ImageLayer.js';
|
|
4
|
+
export { ObjectKind, ObjectLayer } from './ObjectLayer.js';
|
|
3
5
|
export { TileLayer } from './TileLayer.js';
|
|
4
6
|
export { TileMap } from './TileMap.js';
|
|
5
7
|
export { TileSet } from './TileSet.js';
|
|
@@ -7,7 +9,10 @@ export { TileLayerNode } from './TileLayerNode.js';
|
|
|
7
9
|
export { TileMapNode } from './TileMapNode.js';
|
|
8
10
|
export { TileMapBand } from './TileMapBand.js';
|
|
9
11
|
export { TileMapView } from './TileMapView.js';
|
|
10
|
-
export { TILE_TRANSFORM_IDENTITY, tileToChunkCoord, tileToLocalInChunk } from './types.js';
|
|
12
|
+
export { TILE_TRANSFORM_IDENTITY, TilePropertyKind, tileToChunkCoord, tileToLocalInChunk } from './types.js';
|
|
13
|
+
export { TileAnimator } from './TileAnimator.js';
|
|
14
|
+
export { autoTile, refreshCell } from './autoTile.js';
|
|
15
|
+
export { WangSet } from './WangSet.js';
|
|
11
16
|
|
|
12
17
|
// @codexo/exojs-tilemap/register — explicit registration entry.
|
|
13
18
|
// Importing this entry registers the default tilemapExtension descriptor
|
package/dist/esm/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sources":["../../../src/register.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register.js","sources":["../../../src/register.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAMA,iBAAiB,CAAC,QAAQ,CAAC,gBAAgB,CAAC;;;;"}
|
|
@@ -2,9 +2,10 @@ import type { Extension } from '@codexo/exojs/extensions';
|
|
|
2
2
|
/**
|
|
3
3
|
* Default immutable tilemap extension descriptor.
|
|
4
4
|
*
|
|
5
|
-
* Registers the WebGL2/WebGPU tile chunk renderers (`renderers`)
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Registers the WebGL2/WebGPU tile chunk renderers (`renderers`) and the
|
|
6
|
+
* {@link TileMapNode} scene serializer (`serializers`); it carries no asset
|
|
7
|
+
* bindings — there is no generic on-disk tilemap format in this slice, so format
|
|
8
|
+
* adapters (e.g. `@codexo/exojs-tiled`) own loading and depend on this
|
|
8
9
|
* descriptor to pull in rendering.
|
|
9
10
|
*
|
|
10
11
|
* Install + register directly for procedural / hand-built maps
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { RenderBackendType } from '@codexo/exojs/
|
|
1
|
+
import { RenderBackendType } from '@codexo/exojs/renderer-sdk';
|
|
2
2
|
import { TileChunkNode } from './TileChunkNode.js';
|
|
3
|
+
import { TileMapNode } from './TileMapNode.js';
|
|
4
|
+
import { tileMapNodeSerializer } from './tilemapSerializers.js';
|
|
3
5
|
import { WebGl2TileChunkRenderer } from './webgl2/WebGl2TileChunkRenderer.js';
|
|
4
6
|
import { WebGpuTileChunkRenderer } from './webgpu/WebGpuTileChunkRenderer.js';
|
|
5
7
|
|
|
@@ -30,9 +32,10 @@ function buildTileChunkRendererBinding(batchSize) {
|
|
|
30
32
|
/**
|
|
31
33
|
* Default immutable tilemap extension descriptor.
|
|
32
34
|
*
|
|
33
|
-
* Registers the WebGL2/WebGPU tile chunk renderers (`renderers`)
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* Registers the WebGL2/WebGPU tile chunk renderers (`renderers`) and the
|
|
36
|
+
* {@link TileMapNode} scene serializer (`serializers`); it carries no asset
|
|
37
|
+
* bindings — there is no generic on-disk tilemap format in this slice, so format
|
|
38
|
+
* adapters (e.g. `@codexo/exojs-tiled`) own loading and depend on this
|
|
36
39
|
* descriptor to pull in rendering.
|
|
37
40
|
*
|
|
38
41
|
* Install + register directly for procedural / hand-built maps
|
|
@@ -46,6 +49,7 @@ function buildTileChunkRendererBinding(batchSize) {
|
|
|
46
49
|
const tilemapExtension = Object.freeze({
|
|
47
50
|
id: '@codexo/exojs-tilemap',
|
|
48
51
|
renderers: [buildTileChunkRendererBinding(tileRendererBatchSize)],
|
|
52
|
+
serializers: [{ typeName: 'TileMapNode', target: TileMapNode, serializer: tileMapNodeSerializer }],
|
|
49
53
|
});
|
|
50
54
|
|
|
51
55
|
export { tilemapExtension };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tilemapExtension.js","sources":["../../../src/tilemapExtension.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tilemapExtension.js","sources":["../../../src/tilemapExtension.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAUA;AACA,MAAM,qBAAqB,GAAG,IAAI;AAElC;;;;;;;AAOG;AACH,SAAS,6BAA6B,CAAC,SAAiB,EAAA;IACtD,OAAO;QACL,OAAO,EAAE,CAAC,aAAa,CAAC;AACxB,QAAA,MAAM,CAAC,OAAsB,EAAA;YAC3B,IAAI,OAAO,CAAC,WAAW,KAAK,iBAAiB,CAAC,MAAM,EAAE;AACpD,gBAAA,OAAO,IAAI,uBAAuB,CAAC,SAAS,CAAC;YAC/C;YAEA,IAAI,OAAO,CAAC,WAAW,KAAK,iBAAiB,CAAC,MAAM,EAAE;gBACpD,OAAO,IAAI,uBAAuB,EAAE;YACtC;AAEA,YAAA,MAAM,IAAI,KAAK,CAAC,CAAA,4BAAA,EAA+B,MAAM,CAAC,OAAO,CAAC,WAA2B,CAAC,CAAA,CAAE,CAAC;QAC/F,CAAC;KACF;AACH;AAEA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,gBAAgB,GAAc,MAAM,CAAC,MAAM,CAAC;AACvD,IAAA,EAAE,EAAE,uBAAuB;AAC3B,IAAA,SAAS,EAAE,CAAC,6BAA6B,CAAC,qBAAqB,CAAC,CAAC;AACjE,IAAA,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;AACnG,CAAA;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NodeSerializer } from '@codexo/exojs';
|
|
2
|
+
import { TileMapNode } from './TileMapNode';
|
|
3
|
+
/**
|
|
4
|
+
* Scene serializer for {@link TileMapNode} — the convenience node that renders a
|
|
5
|
+
* whole {@link TileMap}.
|
|
6
|
+
*
|
|
7
|
+
* Captures the **map reference** (its Loader source key) plus the render-only
|
|
8
|
+
* `pixelSnapMode`; the per-layer / per-chunk nodes are derived from the map and
|
|
9
|
+
* rebuilt on construction, so they are never written. The referenced `TileMap`
|
|
10
|
+
* must be pre-loaded into the target Loader (e.g. `loader.load(TileMap, 'world.tmj')`)
|
|
11
|
+
* before deserialize — procedurally-built maps have no source key and cannot be
|
|
12
|
+
* referenced.
|
|
13
|
+
*
|
|
14
|
+
* Standalone `TileLayerNode` / `TileMapBand` placement (the actor-interleaving
|
|
15
|
+
* cases) is not yet covered.
|
|
16
|
+
*
|
|
17
|
+
* @internal — registered via {@link tilemapExtension}'s `serializers` binding.
|
|
18
|
+
*/
|
|
19
|
+
export declare const tileMapNodeSerializer: NodeSerializer<TileMapNode>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TileMap } from './TileMap.js';
|
|
2
|
+
import { TileMapNode } from './TileMapNode.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scene serializer for {@link TileMapNode} — the convenience node that renders a
|
|
6
|
+
* whole {@link TileMap}.
|
|
7
|
+
*
|
|
8
|
+
* Captures the **map reference** (its Loader source key) plus the render-only
|
|
9
|
+
* `pixelSnapMode`; the per-layer / per-chunk nodes are derived from the map and
|
|
10
|
+
* rebuilt on construction, so they are never written. The referenced `TileMap`
|
|
11
|
+
* must be pre-loaded into the target Loader (e.g. `loader.load(TileMap, 'world.tmj')`)
|
|
12
|
+
* before deserialize — procedurally-built maps have no source key and cannot be
|
|
13
|
+
* referenced.
|
|
14
|
+
*
|
|
15
|
+
* Standalone `TileLayerNode` / `TileMapBand` placement (the actor-interleaving
|
|
16
|
+
* cases) is not yet covered.
|
|
17
|
+
*
|
|
18
|
+
* @internal — registered via {@link tilemapExtension}'s `serializers` binding.
|
|
19
|
+
*/
|
|
20
|
+
const tileMapNodeSerializer = {
|
|
21
|
+
write(node, ctx) {
|
|
22
|
+
const out = {};
|
|
23
|
+
const source = ctx.keyFor(node.map);
|
|
24
|
+
if (source !== null) {
|
|
25
|
+
out.map = source;
|
|
26
|
+
}
|
|
27
|
+
if (node.pixelSnapMode !== 'none') {
|
|
28
|
+
out.pixelSnapMode = node.pixelSnapMode;
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
},
|
|
32
|
+
read(data, ctx) {
|
|
33
|
+
const map = ctx.resolveAsset(typeof data.map === 'string' ? data.map : null, TileMap);
|
|
34
|
+
if (map === null) {
|
|
35
|
+
throw new Error('TileMapNode deserialize requires its TileMap to be pre-loaded into the Loader (procedural maps have no source key).');
|
|
36
|
+
}
|
|
37
|
+
const node = new TileMapNode(map);
|
|
38
|
+
// The TileMapNode setter validates the value (throws on an invalid mode).
|
|
39
|
+
if (typeof data.pixelSnapMode === 'string') {
|
|
40
|
+
node.pixelSnapMode = data.pixelSnapMode;
|
|
41
|
+
}
|
|
42
|
+
return node;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { tileMapNodeSerializer };
|
|
47
|
+
//# sourceMappingURL=tilemapSerializers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tilemapSerializers.js","sources":["../../../src/tilemapSerializers.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAMA;;;;;;;;;;;;;;;AAeG;AACI,MAAM,qBAAqB,GAAgC;IAChE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAA;QACb,MAAM,GAAG,GAA4B,EAAE;QACvC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAEnC,QAAA,IAAI,MAAM,KAAK,IAAI,EAAE;AACnB,YAAA,GAAG,CAAC,GAAG,GAAG,MAAM;QAClB;AAEA,QAAA,IAAI,IAAI,CAAC,aAAa,KAAK,MAAM,EAAE;AACjC,YAAA,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa;QACxC;AAEA,QAAA,OAAO,GAAG;IACZ,CAAC;IACD,IAAI,CAAC,IAAI,EAAE,GAAG,EAAA;QACZ,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,EAAE,OAAO,CAAC;AAErF,QAAA,IAAI,GAAG,KAAK,IAAI,EAAE;AAChB,YAAA,MAAM,IAAI,KAAK,CAAC,qHAAqH,CAAC;QACxI;AAEA,QAAA,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;;AAGjC,QAAA,IAAI,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE;AAC1C,YAAA,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAA8B;QAC1D;AAEA,QAAA,OAAO,IAAI;IACb,CAAC;;;;;"}
|