@flare-engine/tilemap 0.1.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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/index.d.mts +182 -0
- package/dist/index.d.ts +182 -0
- package/dist/index.js +415 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +381 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
TilemapRenderer: () => TilemapRenderer,
|
|
24
|
+
createTilemapData: () => createTilemapData,
|
|
25
|
+
extractColliders: () => extractColliders,
|
|
26
|
+
getTileAt: () => getTileAt,
|
|
27
|
+
getTileSourceRect: () => getTileSourceRect,
|
|
28
|
+
getTilesetForGid: () => getTilesetForGid,
|
|
29
|
+
parseLDtk: () => parseLDtk,
|
|
30
|
+
parseTiled: () => parseTiled
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// src/tilemap-data.ts
|
|
35
|
+
function createTilemapData(width, height, tileWidth, tileHeight) {
|
|
36
|
+
return {
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
tileWidth,
|
|
40
|
+
tileHeight,
|
|
41
|
+
layers: [],
|
|
42
|
+
tilesets: [],
|
|
43
|
+
properties: {}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function getTileAt(layer, col, row) {
|
|
47
|
+
if (col < 0 || col >= layer.width || row < 0 || row >= layer.height) return 0;
|
|
48
|
+
return layer.tiles[row * layer.width + col] ?? 0;
|
|
49
|
+
}
|
|
50
|
+
function getTilesetForGid(tilesets, gid) {
|
|
51
|
+
let result;
|
|
52
|
+
for (const ts of tilesets) {
|
|
53
|
+
if (ts.firstGid <= gid) {
|
|
54
|
+
result = ts;
|
|
55
|
+
} else {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
function getTileSourceRect(tileset, gid) {
|
|
62
|
+
const localId = gid - tileset.firstGid;
|
|
63
|
+
const col = localId % tileset.columns;
|
|
64
|
+
const row = Math.floor(localId / tileset.columns);
|
|
65
|
+
return {
|
|
66
|
+
x: col * tileset.tileWidth,
|
|
67
|
+
y: row * tileset.tileHeight,
|
|
68
|
+
width: tileset.tileWidth,
|
|
69
|
+
height: tileset.tileHeight
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/tiled-parser.ts
|
|
74
|
+
function parseProperties(props) {
|
|
75
|
+
if (!props || props.length === 0) return {};
|
|
76
|
+
const result = {};
|
|
77
|
+
for (const p of props) {
|
|
78
|
+
result[p.name] = p.value;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
function parseTiled(json) {
|
|
83
|
+
const data = json;
|
|
84
|
+
const map = createTilemapData(data.width, data.height, data.tilewidth, data.tileheight);
|
|
85
|
+
map.properties = parseProperties(data.properties);
|
|
86
|
+
for (const ts of data.tilesets) {
|
|
87
|
+
const tileProperties = /* @__PURE__ */ new Map();
|
|
88
|
+
const solidTiles = /* @__PURE__ */ new Set();
|
|
89
|
+
if (ts.tiles) {
|
|
90
|
+
for (const tile of ts.tiles) {
|
|
91
|
+
const props = parseProperties(tile.properties);
|
|
92
|
+
if (Object.keys(props).length > 0) {
|
|
93
|
+
tileProperties.set(tile.id, props);
|
|
94
|
+
}
|
|
95
|
+
const tileType = tile.type ?? tile.class ?? "";
|
|
96
|
+
if (tileType === "solid" || props.solid === true || props.collision === true) {
|
|
97
|
+
solidTiles.add(tile.id);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const ref = {
|
|
102
|
+
firstGid: ts.firstgid,
|
|
103
|
+
name: ts.name,
|
|
104
|
+
tileWidth: ts.tilewidth,
|
|
105
|
+
tileHeight: ts.tileheight,
|
|
106
|
+
columns: ts.columns,
|
|
107
|
+
tileCount: ts.tilecount,
|
|
108
|
+
image: ts.image,
|
|
109
|
+
imageWidth: ts.imagewidth,
|
|
110
|
+
imageHeight: ts.imageheight,
|
|
111
|
+
tileProperties,
|
|
112
|
+
solidTiles
|
|
113
|
+
};
|
|
114
|
+
map.tilesets.push(ref);
|
|
115
|
+
}
|
|
116
|
+
map.tilesets.sort((a, b) => a.firstGid - b.firstGid);
|
|
117
|
+
for (const layer of data.layers) {
|
|
118
|
+
map.layers.push(parseLayer(layer));
|
|
119
|
+
}
|
|
120
|
+
return map;
|
|
121
|
+
}
|
|
122
|
+
function parseLayer(layer) {
|
|
123
|
+
if (layer.type === "tilelayer") {
|
|
124
|
+
return parseTileLayer(layer);
|
|
125
|
+
}
|
|
126
|
+
return parseObjectLayer(layer);
|
|
127
|
+
}
|
|
128
|
+
function parseTileLayer(layer) {
|
|
129
|
+
return {
|
|
130
|
+
type: "tile",
|
|
131
|
+
name: layer.name,
|
|
132
|
+
width: layer.width,
|
|
133
|
+
height: layer.height,
|
|
134
|
+
tiles: layer.data.slice(),
|
|
135
|
+
visible: layer.visible,
|
|
136
|
+
opacity: layer.opacity,
|
|
137
|
+
offsetX: layer.offsetx ?? 0,
|
|
138
|
+
offsetY: layer.offsety ?? 0,
|
|
139
|
+
properties: parseProperties(layer.properties)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function parseObjectLayer(layer) {
|
|
143
|
+
const objects = layer.objects.map((obj) => ({
|
|
144
|
+
id: obj.id,
|
|
145
|
+
name: obj.name,
|
|
146
|
+
type: obj.type ?? obj.class ?? "",
|
|
147
|
+
x: obj.x,
|
|
148
|
+
y: obj.y,
|
|
149
|
+
width: obj.width,
|
|
150
|
+
height: obj.height,
|
|
151
|
+
rotation: obj.rotation,
|
|
152
|
+
properties: parseProperties(obj.properties)
|
|
153
|
+
}));
|
|
154
|
+
return {
|
|
155
|
+
type: "object",
|
|
156
|
+
name: layer.name,
|
|
157
|
+
objects,
|
|
158
|
+
visible: layer.visible,
|
|
159
|
+
opacity: layer.opacity,
|
|
160
|
+
properties: parseProperties(layer.properties)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/ldtk-parser.ts
|
|
165
|
+
function parseLDtk(json) {
|
|
166
|
+
const data = json;
|
|
167
|
+
const results = [];
|
|
168
|
+
const tilesetDefs = /* @__PURE__ */ new Map();
|
|
169
|
+
for (const ts of data.defs.tilesets) {
|
|
170
|
+
tilesetDefs.set(ts.uid, ts);
|
|
171
|
+
}
|
|
172
|
+
for (const level of data.levels) {
|
|
173
|
+
const gridSize = data.defaultGridSize;
|
|
174
|
+
const mapWidth = Math.ceil(level.pxWid / gridSize);
|
|
175
|
+
const mapHeight = Math.ceil(level.pxHei / gridSize);
|
|
176
|
+
const map = createTilemapData(mapWidth, mapHeight, gridSize, gridSize);
|
|
177
|
+
if (level.fieldInstances) {
|
|
178
|
+
for (const field of level.fieldInstances) {
|
|
179
|
+
map.properties[field.__identifier] = field.__value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const usedTilesets = /* @__PURE__ */ new Set();
|
|
183
|
+
if (level.layerInstances) {
|
|
184
|
+
for (let i = level.layerInstances.length - 1; i >= 0; i--) {
|
|
185
|
+
const layerInst = level.layerInstances[i];
|
|
186
|
+
const layer = parseLayerInstance(layerInst, mapWidth, mapHeight, gridSize);
|
|
187
|
+
if (layer) {
|
|
188
|
+
map.layers.push(layer);
|
|
189
|
+
}
|
|
190
|
+
if (layerInst.__tilesetDefUid !== void 0) {
|
|
191
|
+
usedTilesets.add(layerInst.__tilesetDefUid);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
let firstGid = 1;
|
|
196
|
+
for (const uid of usedTilesets) {
|
|
197
|
+
const def = tilesetDefs.get(uid);
|
|
198
|
+
if (!def) continue;
|
|
199
|
+
const columns = def.__cWid;
|
|
200
|
+
const tileCount = def.__cWid * def.__cHei;
|
|
201
|
+
const ref = {
|
|
202
|
+
firstGid,
|
|
203
|
+
name: def.identifier,
|
|
204
|
+
tileWidth: def.tileGridSize,
|
|
205
|
+
tileHeight: def.tileGridSize,
|
|
206
|
+
columns,
|
|
207
|
+
tileCount,
|
|
208
|
+
image: def.relPath,
|
|
209
|
+
imageWidth: def.pxWid,
|
|
210
|
+
imageHeight: def.pxHei,
|
|
211
|
+
tileProperties: /* @__PURE__ */ new Map(),
|
|
212
|
+
solidTiles: /* @__PURE__ */ new Set()
|
|
213
|
+
};
|
|
214
|
+
map.tilesets.push(ref);
|
|
215
|
+
firstGid += tileCount;
|
|
216
|
+
}
|
|
217
|
+
results.push(map);
|
|
218
|
+
}
|
|
219
|
+
return results;
|
|
220
|
+
}
|
|
221
|
+
function parseLayerInstance(layer, mapWidth, mapHeight, gridSize) {
|
|
222
|
+
switch (layer.__type) {
|
|
223
|
+
case "IntGrid":
|
|
224
|
+
return parseIntGridLayer(layer, mapWidth, mapHeight);
|
|
225
|
+
case "Tiles":
|
|
226
|
+
case "AutoLayer":
|
|
227
|
+
return parseTilesLayer(layer, mapWidth, mapHeight, gridSize);
|
|
228
|
+
case "Entities":
|
|
229
|
+
return parseEntitiesLayer(layer);
|
|
230
|
+
default:
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function parseIntGridLayer(layer, mapWidth, mapHeight) {
|
|
235
|
+
const tiles = layer.intGridCsv ? layer.intGridCsv.slice() : new Array(mapWidth * mapHeight).fill(0);
|
|
236
|
+
return {
|
|
237
|
+
type: "tile",
|
|
238
|
+
name: layer.__identifier,
|
|
239
|
+
width: layer.__cWid,
|
|
240
|
+
height: layer.__cHei,
|
|
241
|
+
tiles,
|
|
242
|
+
visible: layer.visible,
|
|
243
|
+
opacity: layer.__opacity,
|
|
244
|
+
offsetX: 0,
|
|
245
|
+
offsetY: 0,
|
|
246
|
+
properties: {}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function parseTilesLayer(layer, mapWidth, mapHeight, gridSize) {
|
|
250
|
+
const tiles = new Array(mapWidth * mapHeight).fill(0);
|
|
251
|
+
const tileInstances = layer.gridTiles ?? layer.autoLayerTiles ?? [];
|
|
252
|
+
for (const ti of tileInstances) {
|
|
253
|
+
const col = Math.floor(ti.px[0] / gridSize);
|
|
254
|
+
const row = Math.floor(ti.px[1] / gridSize);
|
|
255
|
+
if (col >= 0 && col < mapWidth && row >= 0 && row < mapHeight) {
|
|
256
|
+
tiles[row * mapWidth + col] = ti.t + 1;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
type: "tile",
|
|
261
|
+
name: layer.__identifier,
|
|
262
|
+
width: mapWidth,
|
|
263
|
+
height: mapHeight,
|
|
264
|
+
tiles,
|
|
265
|
+
visible: layer.visible,
|
|
266
|
+
opacity: layer.__opacity,
|
|
267
|
+
offsetX: 0,
|
|
268
|
+
offsetY: 0,
|
|
269
|
+
properties: {}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function parseEntitiesLayer(layer) {
|
|
273
|
+
const objects = (layer.entityInstances ?? []).map((ent, idx) => {
|
|
274
|
+
const props = {};
|
|
275
|
+
for (const field of ent.fieldInstances) {
|
|
276
|
+
props[field.__identifier] = field.__value;
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
id: idx + 1,
|
|
280
|
+
name: ent.__identifier,
|
|
281
|
+
type: ent.__identifier,
|
|
282
|
+
x: ent.px[0],
|
|
283
|
+
y: ent.px[1],
|
|
284
|
+
width: ent.width,
|
|
285
|
+
height: ent.height,
|
|
286
|
+
rotation: 0,
|
|
287
|
+
properties: props
|
|
288
|
+
};
|
|
289
|
+
});
|
|
290
|
+
return {
|
|
291
|
+
type: "object",
|
|
292
|
+
name: layer.__identifier,
|
|
293
|
+
objects,
|
|
294
|
+
visible: layer.visible,
|
|
295
|
+
opacity: layer.__opacity,
|
|
296
|
+
properties: {}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/tilemap-renderer.ts
|
|
301
|
+
var import_render = require("@flare-engine/render");
|
|
302
|
+
var TilemapRenderer = class {
|
|
303
|
+
/** The tilemap data to render. */
|
|
304
|
+
map;
|
|
305
|
+
/** SpriteBatch used for batched tile rendering. */
|
|
306
|
+
batch;
|
|
307
|
+
/** Map from tileset name → SkImage. Set via setTilesetImage(). */
|
|
308
|
+
_images = /* @__PURE__ */ new Map();
|
|
309
|
+
/** Reusable bounds rect — avoids per-frame allocation from camera.getBounds(). */
|
|
310
|
+
_boundsBuf = { x: 0, y: 0, width: 0, height: 0 };
|
|
311
|
+
constructor(map) {
|
|
312
|
+
this.map = map;
|
|
313
|
+
this.batch = new import_render.SpriteBatch();
|
|
314
|
+
}
|
|
315
|
+
/** Associate a loaded image with a tileset by name. */
|
|
316
|
+
setTilesetImage(tilesetName, image) {
|
|
317
|
+
this._images.set(tilesetName, image);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Draw visible tile layers using the camera for culling.
|
|
321
|
+
* Call `flush` on a callback to issue the actual draw calls.
|
|
322
|
+
*/
|
|
323
|
+
draw(camera, flush) {
|
|
324
|
+
const bounds = camera.getBoundsInto(this._boundsBuf);
|
|
325
|
+
const tw = this.map.tileWidth;
|
|
326
|
+
const th = this.map.tileHeight;
|
|
327
|
+
for (const layer of this.map.layers) {
|
|
328
|
+
if (layer.type !== "tile" || !layer.visible) continue;
|
|
329
|
+
this._drawTileLayer(layer, bounds.x, bounds.y, bounds.width, bounds.height, tw, th);
|
|
330
|
+
}
|
|
331
|
+
flush(this.batch);
|
|
332
|
+
}
|
|
333
|
+
_drawTileLayer(layer, viewX, viewY, viewW, viewH, tw, th) {
|
|
334
|
+
const offsetX = layer.offsetX;
|
|
335
|
+
const offsetY = layer.offsetY;
|
|
336
|
+
const startCol = Math.max(0, Math.floor((viewX - offsetX) / tw));
|
|
337
|
+
const startRow = Math.max(0, Math.floor((viewY - offsetY) / th));
|
|
338
|
+
const endCol = Math.min(layer.width - 1, Math.floor((viewX - offsetX + viewW) / tw));
|
|
339
|
+
const endRow = Math.min(layer.height - 1, Math.floor((viewY - offsetY + viewH) / th));
|
|
340
|
+
for (let row = startRow; row <= endRow; row++) {
|
|
341
|
+
for (let col = startCol; col <= endCol; col++) {
|
|
342
|
+
const gid = getTileAt(layer, col, row);
|
|
343
|
+
if (gid === 0) continue;
|
|
344
|
+
const tileset = getTilesetForGid(this.map.tilesets, gid);
|
|
345
|
+
if (!tileset) continue;
|
|
346
|
+
const image = this._images.get(tileset.name);
|
|
347
|
+
if (!image) continue;
|
|
348
|
+
const localId = gid - tileset.firstGid;
|
|
349
|
+
const srcCol = localId % tileset.columns;
|
|
350
|
+
const srcRow = (localId - srcCol) / tileset.columns;
|
|
351
|
+
const srcX = srcCol * tileset.tileWidth;
|
|
352
|
+
const srcY = srcRow * tileset.tileHeight;
|
|
353
|
+
const dstX = col * tw + offsetX;
|
|
354
|
+
const dstY = row * th + offsetY;
|
|
355
|
+
this.batch.drawRaw(
|
|
356
|
+
image,
|
|
357
|
+
srcX,
|
|
358
|
+
srcY,
|
|
359
|
+
tileset.tileWidth,
|
|
360
|
+
tileset.tileHeight,
|
|
361
|
+
dstX,
|
|
362
|
+
dstY,
|
|
363
|
+
tw,
|
|
364
|
+
th
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// src/tilemap-collider.ts
|
|
372
|
+
var import_physics = require("@flare-engine/physics");
|
|
373
|
+
function extractColliders(map, layerName) {
|
|
374
|
+
const colliders = [];
|
|
375
|
+
const tw = map.tileWidth;
|
|
376
|
+
const th = map.tileHeight;
|
|
377
|
+
for (const layer of map.layers) {
|
|
378
|
+
if (layer.type !== "tile") continue;
|
|
379
|
+
if (layerName !== void 0 && layer.name !== layerName) continue;
|
|
380
|
+
extractFromLayer(layer, map.tilesets, tw, th, colliders);
|
|
381
|
+
}
|
|
382
|
+
return colliders;
|
|
383
|
+
}
|
|
384
|
+
function extractFromLayer(layer, tilesets, tw, th, out) {
|
|
385
|
+
for (let row = 0; row < layer.height; row++) {
|
|
386
|
+
for (let col = 0; col < layer.width; col++) {
|
|
387
|
+
const gid = layer.tiles[row * layer.width + col] ?? 0;
|
|
388
|
+
if (gid === 0) continue;
|
|
389
|
+
const tileset = getTilesetForGid(tilesets, gid);
|
|
390
|
+
if (!tileset) continue;
|
|
391
|
+
const localId = gid - tileset.firstGid;
|
|
392
|
+
if (!tileset.solidTiles.has(localId)) continue;
|
|
393
|
+
out.push({
|
|
394
|
+
x: col * tw + tw * 0.5 + layer.offsetX,
|
|
395
|
+
y: row * th + th * 0.5 + layer.offsetY,
|
|
396
|
+
shape: (0, import_physics.AABB)(tw, th),
|
|
397
|
+
col,
|
|
398
|
+
row,
|
|
399
|
+
gid
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
405
|
+
0 && (module.exports = {
|
|
406
|
+
TilemapRenderer,
|
|
407
|
+
createTilemapData,
|
|
408
|
+
extractColliders,
|
|
409
|
+
getTileAt,
|
|
410
|
+
getTileSourceRect,
|
|
411
|
+
getTilesetForGid,
|
|
412
|
+
parseLDtk,
|
|
413
|
+
parseTiled
|
|
414
|
+
});
|
|
415
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/tilemap-data.ts","../src/tiled-parser.ts","../src/ldtk-parser.ts","../src/tilemap-renderer.ts","../src/tilemap-collider.ts"],"sourcesContent":["export {\n type TileData,\n type TileLayer,\n type MapObject,\n type ObjectLayer,\n type MapLayer,\n type TilesetRef,\n type TilemapData,\n createTilemapData,\n getTileAt,\n getTilesetForGid,\n getTileSourceRect,\n} from './tilemap-data.js';\n\nexport { parseTiled } from './tiled-parser.js';\n\nexport { parseLDtk } from './ldtk-parser.js';\n\nexport { TilemapRenderer } from './tilemap-renderer.js';\n\nexport {\n type TileCollider,\n extractColliders,\n} from './tilemap-collider.js';\n","import type { Rect } from '@flare-engine/math';\n\n/** A single tile in a tilemap grid. */\nexport interface TileData {\n /** Global tile ID (0 = empty). */\n gid: number;\n /** Whether this tile is flagged as solid (for collision). */\n solid: boolean;\n /** Custom properties on the tile. */\n properties: Record<string, unknown>;\n}\n\n/** A layer of tiles in a grid. */\nexport interface TileLayer {\n readonly type: 'tile';\n /** Layer name. */\n name: string;\n /** Grid width in tiles. */\n width: number;\n /** Grid height in tiles. */\n height: number;\n /** Flat array of tile GIDs (row-major, length = width * height). */\n tiles: number[];\n /** Visibility flag. */\n visible: boolean;\n /** Opacity (0–1). */\n opacity: number;\n /** Layer offset in pixels. */\n offsetX: number;\n offsetY: number;\n /** Custom properties. */\n properties: Record<string, unknown>;\n}\n\n/** An object in an object layer. */\nexport interface MapObject {\n /** Object ID. */\n id: number;\n /** Object name. */\n name: string;\n /** Object type/class. */\n type: string;\n /** Position in pixels. */\n x: number;\n y: number;\n /** Size in pixels. */\n width: number;\n height: number;\n /** Rotation in degrees. */\n rotation: number;\n /** Custom properties. */\n properties: Record<string, unknown>;\n}\n\n/** A layer of objects. */\nexport interface ObjectLayer {\n readonly type: 'object';\n /** Layer name. */\n name: string;\n /** Objects in the layer. */\n objects: MapObject[];\n /** Visibility flag. */\n visible: boolean;\n /** Opacity (0–1). */\n opacity: number;\n /** Custom properties. */\n properties: Record<string, unknown>;\n}\n\n/** Union of layer types. */\nexport type MapLayer = TileLayer | ObjectLayer;\n\n/** Information about a tileset used in the map. */\nexport interface TilesetRef {\n /** First GID in this tileset. */\n firstGid: number;\n /** Tileset name. */\n name: string;\n /** Tile width in pixels. */\n tileWidth: number;\n /** Tile height in pixels. */\n tileHeight: number;\n /** Number of columns in the tileset image. */\n columns: number;\n /** Total tile count. */\n tileCount: number;\n /** Image source path (may need resolving). */\n image: string;\n /** Image width in pixels. */\n imageWidth: number;\n /** Image height in pixels. */\n imageHeight: number;\n /** Per-tile properties (indexed by local tile ID). */\n tileProperties: Map<number, Record<string, unknown>>;\n /** Tile IDs marked as solid/collision. */\n solidTiles: Set<number>;\n}\n\n/** Complete parsed tilemap data — format-independent. */\nexport interface TilemapData {\n /** Map width in tiles. */\n width: number;\n /** Map height in tiles. */\n height: number;\n /** Tile width in pixels. */\n tileWidth: number;\n /** Tile height in pixels. */\n tileHeight: number;\n /** All layers in order. */\n layers: MapLayer[];\n /** Tilesets referenced by this map. */\n tilesets: TilesetRef[];\n /** Custom map properties. */\n properties: Record<string, unknown>;\n}\n\n/** Create an empty TilemapData. */\nexport function createTilemapData(\n width: number,\n height: number,\n tileWidth: number,\n tileHeight: number,\n): TilemapData {\n return {\n width,\n height,\n tileWidth,\n tileHeight,\n layers: [],\n tilesets: [],\n properties: {},\n };\n}\n\n/** Get a tile GID at a grid position from a tile layer. Returns 0 if out of bounds. */\nexport function getTileAt(layer: TileLayer, col: number, row: number): number {\n if (col < 0 || col >= layer.width || row < 0 || row >= layer.height) return 0;\n return layer.tiles[row * layer.width + col] ?? 0;\n}\n\n/** Get the tileset that owns a given GID. */\nexport function getTilesetForGid(tilesets: TilesetRef[], gid: number): TilesetRef | undefined {\n // Tilesets are ordered by firstGid; find the last one where firstGid <= gid\n let result: TilesetRef | undefined;\n for (const ts of tilesets) {\n if (ts.firstGid <= gid) {\n result = ts;\n } else {\n break;\n }\n }\n return result;\n}\n\n/** Compute the source rect in a tileset image for a given GID. */\nexport function getTileSourceRect(tileset: TilesetRef, gid: number): Rect {\n const localId = gid - tileset.firstGid;\n const col = localId % tileset.columns;\n const row = Math.floor(localId / tileset.columns);\n return {\n x: col * tileset.tileWidth,\n y: row * tileset.tileHeight,\n width: tileset.tileWidth,\n height: tileset.tileHeight,\n };\n}\n","import type {\n MapLayer,\n MapObject,\n ObjectLayer,\n TileLayer,\n TilemapData,\n TilesetRef,\n} from './tilemap-data.js';\nimport { createTilemapData } from './tilemap-data.js';\n\n// ----- Tiled JSON types (.tmj format) -----\n\ninterface TiledProperty {\n name: string;\n type: string;\n value: unknown;\n}\n\ninterface TiledTileLayer {\n type: 'tilelayer';\n name: string;\n width: number;\n height: number;\n data: number[];\n visible: boolean;\n opacity: number;\n offsetx?: number;\n offsety?: number;\n properties?: TiledProperty[];\n}\n\ninterface TiledObject {\n id: number;\n name: string;\n type?: string;\n class?: string;\n x: number;\n y: number;\n width: number;\n height: number;\n rotation: number;\n properties?: TiledProperty[];\n}\n\ninterface TiledObjectLayer {\n type: 'objectgroup';\n name: string;\n objects: TiledObject[];\n visible: boolean;\n opacity: number;\n properties?: TiledProperty[];\n}\n\ntype TiledLayer = TiledTileLayer | TiledObjectLayer;\n\ninterface TiledTile {\n id: number;\n properties?: TiledProperty[];\n type?: string;\n class?: string;\n}\n\ninterface TiledTileset {\n firstgid: number;\n name: string;\n tilewidth: number;\n tileheight: number;\n columns: number;\n tilecount: number;\n image: string;\n imagewidth: number;\n imageheight: number;\n tiles?: TiledTile[];\n properties?: TiledProperty[];\n}\n\ninterface TiledMapJSON {\n width: number;\n height: number;\n tilewidth: number;\n tileheight: number;\n orientation: string;\n layers: TiledLayer[];\n tilesets: TiledTileset[];\n properties?: TiledProperty[];\n}\n\n/** Convert Tiled properties array to a Record. */\nfunction parseProperties(props?: TiledProperty[]): Record<string, unknown> {\n if (!props || props.length === 0) return {};\n const result: Record<string, unknown> = {};\n for (const p of props) {\n result[p.name] = p.value;\n }\n return result;\n}\n\n/**\n * Parse a Tiled .tmj (JSON) map into TilemapData.\n * Supports orthogonal maps with tile layers and object layers.\n */\nexport function parseTiled(json: unknown): TilemapData {\n const data = json as TiledMapJSON;\n const map = createTilemapData(data.width, data.height, data.tilewidth, data.tileheight);\n map.properties = parseProperties(data.properties);\n\n // Parse tilesets\n for (const ts of data.tilesets) {\n const tileProperties = new Map<number, Record<string, unknown>>();\n const solidTiles = new Set<number>();\n\n if (ts.tiles) {\n for (const tile of ts.tiles) {\n const props = parseProperties(tile.properties);\n if (Object.keys(props).length > 0) {\n tileProperties.set(tile.id, props);\n }\n // Mark as solid if it has a \"collision\" or \"solid\" property, or type/class is \"solid\"\n const tileType = tile.type ?? tile.class ?? '';\n if (tileType === 'solid' || props.solid === true || props.collision === true) {\n solidTiles.add(tile.id);\n }\n }\n }\n\n const ref: TilesetRef = {\n firstGid: ts.firstgid,\n name: ts.name,\n tileWidth: ts.tilewidth,\n tileHeight: ts.tileheight,\n columns: ts.columns,\n tileCount: ts.tilecount,\n image: ts.image,\n imageWidth: ts.imagewidth,\n imageHeight: ts.imageheight,\n tileProperties,\n solidTiles,\n };\n map.tilesets.push(ref);\n }\n\n // Sort tilesets by firstGid\n map.tilesets.sort((a, b) => a.firstGid - b.firstGid);\n\n // Parse layers\n for (const layer of data.layers) {\n map.layers.push(parseLayer(layer));\n }\n\n return map;\n}\n\nfunction parseLayer(layer: TiledLayer): MapLayer {\n if (layer.type === 'tilelayer') {\n return parseTileLayer(layer);\n }\n return parseObjectLayer(layer);\n}\n\nfunction parseTileLayer(layer: TiledTileLayer): TileLayer {\n return {\n type: 'tile',\n name: layer.name,\n width: layer.width,\n height: layer.height,\n tiles: layer.data.slice(),\n visible: layer.visible,\n opacity: layer.opacity,\n offsetX: layer.offsetx ?? 0,\n offsetY: layer.offsety ?? 0,\n properties: parseProperties(layer.properties),\n };\n}\n\nfunction parseObjectLayer(layer: TiledObjectLayer): ObjectLayer {\n const objects: MapObject[] = layer.objects.map((obj) => ({\n id: obj.id,\n name: obj.name,\n type: obj.type ?? obj.class ?? '',\n x: obj.x,\n y: obj.y,\n width: obj.width,\n height: obj.height,\n rotation: obj.rotation,\n properties: parseProperties(obj.properties),\n }));\n\n return {\n type: 'object',\n name: layer.name,\n objects,\n visible: layer.visible,\n opacity: layer.opacity,\n properties: parseProperties(layer.properties),\n };\n}\n","import type {\n MapLayer,\n MapObject,\n ObjectLayer,\n TileLayer,\n TilemapData,\n TilesetRef,\n} from './tilemap-data.js';\nimport { createTilemapData } from './tilemap-data.js';\n\n// ----- LDtk JSON types -----\n\ninterface LDtkFieldInstance {\n __identifier: string;\n __value: unknown;\n __type: string;\n}\n\ninterface LDtkEntityInstance {\n __identifier: string;\n __grid: [number, number];\n __pivot: [number, number];\n __tile?: { x: number; y: number; w: number; h: number };\n iid: string;\n width: number;\n height: number;\n px: [number, number];\n fieldInstances: LDtkFieldInstance[];\n}\n\ninterface LDtkTileInstance {\n px: [number, number];\n src: [number, number];\n f: number; // flip flags\n t: number; // tile ID\n}\n\ninterface LDtkLayerInstance {\n __identifier: string;\n __type: string;\n __cWid: number;\n __cHei: number;\n __gridSize: number;\n __tilesetDefUid?: number;\n __tilesetRelPath?: string;\n visible: boolean;\n __opacity: number;\n intGridCsv?: number[];\n gridTiles?: LDtkTileInstance[];\n autoLayerTiles?: LDtkTileInstance[];\n entityInstances?: LDtkEntityInstance[];\n}\n\ninterface LDtkTilesetDef {\n uid: number;\n identifier: string;\n relPath: string;\n pxWid: number;\n pxHei: number;\n tileGridSize: number;\n __cWid: number;\n __cHei: number;\n}\n\ninterface LDtkLevel {\n identifier: string;\n uid: number;\n pxWid: number;\n pxHei: number;\n worldX: number;\n worldY: number;\n layerInstances?: LDtkLayerInstance[];\n fieldInstances?: LDtkFieldInstance[];\n}\n\ninterface LDtkJSON {\n defaultGridSize: number;\n defs: {\n tilesets: LDtkTilesetDef[];\n };\n levels: LDtkLevel[];\n}\n\n/**\n * Parse an LDtk JSON project into an array of TilemapData (one per level).\n * Returns all levels with their tile and entity layers.\n */\nexport function parseLDtk(json: unknown): TilemapData[] {\n const data = json as LDtkJSON;\n const results: TilemapData[] = [];\n\n // Build tileset lookup\n const tilesetDefs = new Map<number, LDtkTilesetDef>();\n for (const ts of data.defs.tilesets) {\n tilesetDefs.set(ts.uid, ts);\n }\n\n for (const level of data.levels) {\n const gridSize = data.defaultGridSize;\n const mapWidth = Math.ceil(level.pxWid / gridSize);\n const mapHeight = Math.ceil(level.pxHei / gridSize);\n const map = createTilemapData(mapWidth, mapHeight, gridSize, gridSize);\n\n // Parse level properties\n if (level.fieldInstances) {\n for (const field of level.fieldInstances) {\n map.properties[field.__identifier] = field.__value;\n }\n }\n\n const usedTilesets = new Set<number>();\n\n if (level.layerInstances) {\n // LDtk layers are in reverse order (first = top)\n for (let i = level.layerInstances.length - 1; i >= 0; i--) {\n const layerInst = level.layerInstances[i]!;\n const layer = parseLayerInstance(layerInst, mapWidth, mapHeight, gridSize);\n if (layer) {\n map.layers.push(layer);\n }\n\n // Track tileset usage\n if (layerInst.__tilesetDefUid !== undefined) {\n usedTilesets.add(layerInst.__tilesetDefUid);\n }\n }\n }\n\n // Add tileset refs\n let firstGid = 1;\n for (const uid of usedTilesets) {\n const def = tilesetDefs.get(uid);\n if (!def) continue;\n\n const columns = def.__cWid;\n const tileCount = def.__cWid * def.__cHei;\n\n const ref: TilesetRef = {\n firstGid: firstGid,\n name: def.identifier,\n tileWidth: def.tileGridSize,\n tileHeight: def.tileGridSize,\n columns,\n tileCount,\n image: def.relPath,\n imageWidth: def.pxWid,\n imageHeight: def.pxHei,\n tileProperties: new Map(),\n solidTiles: new Set(),\n };\n map.tilesets.push(ref);\n firstGid += tileCount;\n }\n\n results.push(map);\n }\n\n return results;\n}\n\nfunction parseLayerInstance(\n layer: LDtkLayerInstance,\n mapWidth: number,\n mapHeight: number,\n gridSize: number,\n): MapLayer | null {\n switch (layer.__type) {\n case 'IntGrid':\n return parseIntGridLayer(layer, mapWidth, mapHeight);\n case 'Tiles':\n case 'AutoLayer':\n return parseTilesLayer(layer, mapWidth, mapHeight, gridSize);\n case 'Entities':\n return parseEntitiesLayer(layer);\n default:\n return null;\n }\n}\n\nfunction parseIntGridLayer(\n layer: LDtkLayerInstance,\n mapWidth: number,\n mapHeight: number,\n): TileLayer {\n const tiles = layer.intGridCsv\n ? layer.intGridCsv.slice()\n : (new Array(mapWidth * mapHeight).fill(0) as number[]);\n return {\n type: 'tile',\n name: layer.__identifier,\n width: layer.__cWid,\n height: layer.__cHei,\n tiles,\n visible: layer.visible,\n opacity: layer.__opacity,\n offsetX: 0,\n offsetY: 0,\n properties: {},\n };\n}\n\nfunction parseTilesLayer(\n layer: LDtkLayerInstance,\n mapWidth: number,\n mapHeight: number,\n gridSize: number,\n): TileLayer {\n const tiles = new Array(mapWidth * mapHeight).fill(0) as number[];\n const tileInstances = layer.gridTiles ?? layer.autoLayerTiles ?? [];\n\n for (const ti of tileInstances) {\n const col = Math.floor(ti.px[0] / gridSize);\n const row = Math.floor(ti.px[1] / gridSize);\n if (col >= 0 && col < mapWidth && row >= 0 && row < mapHeight) {\n // Store tile ID + 1 (to match GID convention where 0 = empty)\n tiles[row * mapWidth + col] = ti.t + 1;\n }\n }\n\n return {\n type: 'tile',\n name: layer.__identifier,\n width: mapWidth,\n height: mapHeight,\n tiles,\n visible: layer.visible,\n opacity: layer.__opacity,\n offsetX: 0,\n offsetY: 0,\n properties: {},\n };\n}\n\nfunction parseEntitiesLayer(layer: LDtkLayerInstance): ObjectLayer {\n const objects: MapObject[] = (layer.entityInstances ?? []).map((ent, idx) => {\n const props: Record<string, unknown> = {};\n for (const field of ent.fieldInstances) {\n props[field.__identifier] = field.__value;\n }\n return {\n id: idx + 1,\n name: ent.__identifier,\n type: ent.__identifier,\n x: ent.px[0],\n y: ent.px[1],\n width: ent.width,\n height: ent.height,\n rotation: 0,\n properties: props,\n };\n });\n\n return {\n type: 'object',\n name: layer.__identifier,\n objects,\n visible: layer.visible,\n opacity: layer.__opacity,\n properties: {},\n };\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport type { Rect } from '@flare-engine/math';\nimport type { Camera2D } from '@flare-engine/render';\nimport { SpriteBatch } from '@flare-engine/render';\nimport type { TileLayer, TilemapData } from './tilemap-data.js';\nimport { getTileAt, getTilesetForGid } from './tilemap-data.js';\n\n/**\n * TilemapRenderer — draws a tilemap with viewport culling.\n * Only tiles visible to the camera are submitted to the SpriteBatch.\n */\nexport class TilemapRenderer {\n /** The tilemap data to render. */\n readonly map: TilemapData;\n\n /** SpriteBatch used for batched tile rendering. */\n readonly batch: SpriteBatch;\n\n /** Map from tileset name → SkImage. Set via setTilesetImage(). */\n private _images = new Map<string, SkImageLike>();\n\n /** Reusable bounds rect — avoids per-frame allocation from camera.getBounds(). */\n private _boundsBuf: Rect = { x: 0, y: 0, width: 0, height: 0 };\n\n constructor(map: TilemapData) {\n this.map = map;\n this.batch = new SpriteBatch();\n }\n\n /** Associate a loaded image with a tileset by name. */\n setTilesetImage(tilesetName: string, image: SkImageLike): void {\n this._images.set(tilesetName, image);\n }\n\n /**\n * Draw visible tile layers using the camera for culling.\n * Call `flush` on a callback to issue the actual draw calls.\n */\n draw(camera: Camera2D, flush: (batch: SpriteBatch) => void): void {\n const bounds = camera.getBoundsInto(this._boundsBuf);\n const tw = this.map.tileWidth;\n const th = this.map.tileHeight;\n\n for (const layer of this.map.layers) {\n if (layer.type !== 'tile' || !layer.visible) continue;\n this._drawTileLayer(layer, bounds.x, bounds.y, bounds.width, bounds.height, tw, th);\n }\n\n flush(this.batch);\n }\n\n private _drawTileLayer(\n layer: TileLayer,\n viewX: number,\n viewY: number,\n viewW: number,\n viewH: number,\n tw: number,\n th: number,\n ): void {\n const offsetX = layer.offsetX;\n const offsetY = layer.offsetY;\n\n // Calculate visible tile range (clamped to layer bounds)\n const startCol = Math.max(0, Math.floor((viewX - offsetX) / tw));\n const startRow = Math.max(0, Math.floor((viewY - offsetY) / th));\n const endCol = Math.min(layer.width - 1, Math.floor((viewX - offsetX + viewW) / tw));\n const endRow = Math.min(layer.height - 1, Math.floor((viewY - offsetY + viewH) / th));\n\n for (let row = startRow; row <= endRow; row++) {\n for (let col = startCol; col <= endCol; col++) {\n const gid = getTileAt(layer, col, row);\n if (gid === 0) continue;\n\n const tileset = getTilesetForGid(this.map.tilesets, gid);\n if (!tileset) continue;\n\n const image = this._images.get(tileset.name);\n if (!image) continue;\n\n // Inlined source-rect math — avoids allocating a Rect per tile.\n const localId = gid - tileset.firstGid;\n const srcCol = localId % tileset.columns;\n const srcRow = (localId - srcCol) / tileset.columns;\n const srcX = srcCol * tileset.tileWidth;\n const srcY = srcRow * tileset.tileHeight;\n const dstX = col * tw + offsetX;\n const dstY = row * th + offsetY;\n\n this.batch.drawRaw(\n image,\n srcX,\n srcY,\n tileset.tileWidth,\n tileset.tileHeight,\n dstX,\n dstY,\n tw,\n th,\n );\n }\n }\n }\n}\n","import { AABB } from '@flare-engine/physics';\nimport type { AABBShape } from '@flare-engine/physics';\nimport type { TileLayer, TilemapData, TilesetRef } from './tilemap-data.js';\nimport { getTilesetForGid } from './tilemap-data.js';\n\n/** A collision body extracted from a solid tile. */\nexport interface TileCollider {\n /** World position of the tile center. */\n x: number;\n y: number;\n /** AABB collision shape. */\n shape: AABBShape;\n /** Grid column. */\n col: number;\n /** Grid row. */\n row: number;\n /** The tile GID. */\n gid: number;\n}\n\n/**\n * Extract collision shapes from solid tiles in a tilemap.\n * A tile is considered solid if its tileset marks the local tile ID as solid.\n *\n * @param map The parsed tilemap data.\n * @param layerName Optional: only extract from this layer. If omitted, extracts from all tile layers.\n * @returns Array of TileCollider bodies.\n */\nexport function extractColliders(map: TilemapData, layerName?: string): TileCollider[] {\n const colliders: TileCollider[] = [];\n const tw = map.tileWidth;\n const th = map.tileHeight;\n\n for (const layer of map.layers) {\n if (layer.type !== 'tile') continue;\n if (layerName !== undefined && layer.name !== layerName) continue;\n\n extractFromLayer(layer, map.tilesets, tw, th, colliders);\n }\n\n return colliders;\n}\n\nfunction extractFromLayer(\n layer: TileLayer,\n tilesets: TilesetRef[],\n tw: number,\n th: number,\n out: TileCollider[],\n): void {\n for (let row = 0; row < layer.height; row++) {\n for (let col = 0; col < layer.width; col++) {\n const gid = layer.tiles[row * layer.width + col] ?? 0;\n if (gid === 0) continue;\n\n const tileset = getTilesetForGid(tilesets, gid);\n if (!tileset) continue;\n\n const localId = gid - tileset.firstGid;\n if (!tileset.solidTiles.has(localId)) continue;\n\n out.push({\n x: col * tw + tw * 0.5 + layer.offsetX,\n y: row * th + th * 0.5 + layer.offsetY,\n shape: AABB(tw, th),\n col,\n row,\n gid,\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqHO,SAAS,kBACd,OACA,QACA,WACA,YACa;AACb,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,UAAU,CAAC;AAAA,IACX,YAAY,CAAC;AAAA,EACf;AACF;AAGO,SAAS,UAAU,OAAkB,KAAa,KAAqB;AAC5E,MAAI,MAAM,KAAK,OAAO,MAAM,SAAS,MAAM,KAAK,OAAO,MAAM,OAAQ,QAAO;AAC5E,SAAO,MAAM,MAAM,MAAM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