@margoengine/tilemap 0.0.0-stage → 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 +201 -0
- package/NOTICE +4 -0
- package/README.md +294 -3
- package/dist/autotile.d.ts +105 -0
- package/dist/autotile.js +116 -0
- package/dist/chunks.d.ts +45 -0
- package/dist/fov.d.ts +73 -0
- package/dist/fov.js +107 -0
- package/dist/hex.d.ts +21 -0
- package/dist/hex.js +101 -0
- package/dist/import-DsL40A38.js +33 -0
- package/dist/import.d.ts +29 -0
- package/dist/index.d.ts +240 -0
- package/dist/index.js +1 -0
- package/dist/iso-C2Hwh5Gr.js +300 -0
- package/dist/iso.d.ts +114 -0
- package/dist/iso.js +3 -0
- package/dist/layout-CLx3KdGC.js +124 -0
- package/dist/layout.d.ts +37 -0
- package/dist/ldtk.d.ts +72 -0
- package/dist/ldtk.js +187 -0
- package/dist/object-quads.d.ts +31 -0
- package/dist/objects-BK2mewd1.js +444 -0
- package/dist/objects.d.ts +88 -0
- package/dist/objects.js +1 -0
- package/dist/path.d.ts +68 -0
- package/dist/path.js +178 -0
- package/dist/plane.d.ts +37 -0
- package/dist/plane.js +76 -0
- package/dist/renderer.d.ts +177 -0
- package/dist/src-CJvCfCkX.js +602 -0
- package/dist/tiled-xml-Dp4Ez81m.js +89 -0
- package/dist/tiled-xml.d.ts +3 -0
- package/dist/tiled.d.ts +86 -0
- package/dist/tiled.js +541 -0
- package/package.json +90 -6
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { Vec2 } from '@margoengine/math';
|
|
2
|
+
import type { WangRuleSet } from './autotile.js';
|
|
3
|
+
export { TileMap, type TileAtlas, type TileCamera, type TileMapOptions, type TileMapStats, type TilePixels, type TileTarget, } from './renderer.js';
|
|
4
|
+
export { animatedTile, TILE_CHUNK_SIZE, chunkGrid, fillChunk, mapColor, tileReach, visibleChunks, type ChunkRange, type TileReach, } from './chunks.js';
|
|
5
|
+
/** A property value as Tiled and LDtk store it: text, numbers, booleans, lists, or nested objects (Tiled "class"). */
|
|
6
|
+
export type PropertyValue = string | number | boolean | null | readonly PropertyValue[] | {
|
|
7
|
+
readonly [key: string]: PropertyValue;
|
|
8
|
+
};
|
|
9
|
+
/** Custom properties by name. */
|
|
10
|
+
export type Properties = {
|
|
11
|
+
readonly [name: string]: PropertyValue;
|
|
12
|
+
};
|
|
13
|
+
/** Tiled's flip bit in a tile layer value: mirrored left to right. */
|
|
14
|
+
export declare const FLIP_H = 2147483648;
|
|
15
|
+
/** Tiled's flip bit: mirrored top to bottom. */
|
|
16
|
+
export declare const FLIP_V = 1073741824;
|
|
17
|
+
/** Tiled's flip bit: mirrored across the main diagonal (applied first; with `FLIP_H` it is a 90 degree turn). */
|
|
18
|
+
export declare const FLIP_D = 536870912;
|
|
19
|
+
/** All flip bits that carry meaning for orthogonal maps. */
|
|
20
|
+
export declare const FLIP_MASK = 3758096384;
|
|
21
|
+
/** Bits of a layer value that hold the global tile id (Tiled also reserves bit 28 for hex maps; it is cleared here). */
|
|
22
|
+
export declare const GID_MASK = 268435455;
|
|
23
|
+
/** Collision or object shape in pixels. `x`/`y` are from the tile's top left (collision) or the owning object's origin. */
|
|
24
|
+
export type MapShape = {
|
|
25
|
+
readonly kind: 'rect';
|
|
26
|
+
readonly x: number;
|
|
27
|
+
readonly y: number;
|
|
28
|
+
readonly width: number;
|
|
29
|
+
readonly height: number;
|
|
30
|
+
readonly rotation?: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: 'ellipse';
|
|
33
|
+
readonly x: number;
|
|
34
|
+
readonly y: number;
|
|
35
|
+
readonly width: number;
|
|
36
|
+
readonly height: number;
|
|
37
|
+
readonly rotation?: number;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'point';
|
|
40
|
+
readonly x: number;
|
|
41
|
+
readonly y: number;
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: 'polygon';
|
|
44
|
+
readonly x: number;
|
|
45
|
+
readonly y: number;
|
|
46
|
+
readonly points: readonly Vec2[];
|
|
47
|
+
readonly rotation?: number;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'polyline';
|
|
50
|
+
readonly x: number;
|
|
51
|
+
readonly y: number;
|
|
52
|
+
readonly points: readonly Vec2[];
|
|
53
|
+
readonly rotation?: number;
|
|
54
|
+
};
|
|
55
|
+
/** One frame of a tile animation: show `tileId` (local to the tileset) for `duration` milliseconds. */
|
|
56
|
+
export interface TileAnimationStep {
|
|
57
|
+
readonly tileId: number;
|
|
58
|
+
readonly duration: number;
|
|
59
|
+
}
|
|
60
|
+
/** Per-tile data. Only tiles with something to say need an entry. */
|
|
61
|
+
export interface TileDef {
|
|
62
|
+
/** Local id, 0-based within the tileset. */
|
|
63
|
+
readonly id: number;
|
|
64
|
+
/** Free-form class or type name. */
|
|
65
|
+
readonly type?: string;
|
|
66
|
+
readonly properties?: Properties;
|
|
67
|
+
/** Animation frames in order; the tile loops through them. */
|
|
68
|
+
readonly animation?: readonly TileAnimationStep[];
|
|
69
|
+
/** Collision shapes in tile pixels, consumed by physics. Empty or missing means no collision. */
|
|
70
|
+
readonly collision?: readonly MapShape[];
|
|
71
|
+
/** Image collection tilesets only: this tile's own image. */
|
|
72
|
+
readonly image?: {
|
|
73
|
+
readonly source: string;
|
|
74
|
+
readonly width: number;
|
|
75
|
+
readonly height: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** A tileset: one atlas image cut into a grid, or a collection of per-tile images. */
|
|
79
|
+
export interface MapTileset {
|
|
80
|
+
readonly name: string;
|
|
81
|
+
/** Global id of the first tile. Layer values from `firstGid` up to `firstGid + tileCount - 1` belong here. */
|
|
82
|
+
readonly firstGid: number;
|
|
83
|
+
readonly tileWidth: number;
|
|
84
|
+
readonly tileHeight: number;
|
|
85
|
+
readonly tileCount: number;
|
|
86
|
+
/** Tiles per row of the atlas; 0 for image collections. */
|
|
87
|
+
readonly columns: number;
|
|
88
|
+
/** Tile-object anchor. Default bottom left, or bottom on isometric maps. */
|
|
89
|
+
readonly objectAlignment?: 'unspecified' | 'topleft' | 'top' | 'topright' | 'left' | 'center' | 'right' | 'bottomleft' | 'bottom' | 'bottomright';
|
|
90
|
+
/** Pixels between tiles in the atlas. Default 0. */
|
|
91
|
+
readonly spacing?: number;
|
|
92
|
+
/** Pixels around the atlas edge. Default 0. */
|
|
93
|
+
readonly margin?: number;
|
|
94
|
+
/** Pixel shift applied when drawing these tiles. Default [0, 0]. */
|
|
95
|
+
readonly tileOffset?: Vec2;
|
|
96
|
+
/** The atlas image. Missing for image collections. */
|
|
97
|
+
readonly image?: {
|
|
98
|
+
readonly source: string;
|
|
99
|
+
readonly width: number;
|
|
100
|
+
readonly height: number;
|
|
101
|
+
};
|
|
102
|
+
readonly tiles?: readonly TileDef[];
|
|
103
|
+
readonly properties?: Properties;
|
|
104
|
+
/** Imported edge, corner or mixed Wang rules, consumed by resolveWang of the autotile entry. */
|
|
105
|
+
readonly wangSets?: readonly WangRuleSet[];
|
|
106
|
+
}
|
|
107
|
+
/** Fields every layer shares. */
|
|
108
|
+
export interface LayerBase {
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly id?: number;
|
|
111
|
+
/** 0 to 1. Default 1. */
|
|
112
|
+
readonly opacity?: number;
|
|
113
|
+
/** Default true. */
|
|
114
|
+
readonly visible?: boolean;
|
|
115
|
+
/** Pixel shift of the whole layer. Default [0, 0]. */
|
|
116
|
+
readonly offset?: Vec2;
|
|
117
|
+
/** Scroll factor against the camera: 1 moves with the world, 0 stays on screen. Default [1, 1]. */
|
|
118
|
+
readonly parallax?: Vec2;
|
|
119
|
+
/** Multiplies the layer's colour, CSS `#rrggbb` or `#aarrggbb`. */
|
|
120
|
+
readonly tint?: string;
|
|
121
|
+
readonly properties?: Properties;
|
|
122
|
+
}
|
|
123
|
+
/** A grid of tile ids. */
|
|
124
|
+
export interface TileLayer extends LayerBase {
|
|
125
|
+
readonly type: 'tile';
|
|
126
|
+
/** Size in tiles. */
|
|
127
|
+
readonly width: number;
|
|
128
|
+
readonly height: number;
|
|
129
|
+
/** `width * height` values, row by row from the top left. Low 28 bits: global tile id (0 is empty). High bits: `FLIP_H`, `FLIP_V`, `FLIP_D`. */
|
|
130
|
+
readonly data: Uint32Array;
|
|
131
|
+
}
|
|
132
|
+
/** A placed object: a marker, region, spawn point or tile sprite. */
|
|
133
|
+
export interface MapObject {
|
|
134
|
+
readonly id: number;
|
|
135
|
+
readonly name?: string;
|
|
136
|
+
readonly type?: string;
|
|
137
|
+
/** Pixel position in the map. For a tile object it is the bottom left of the tile. */
|
|
138
|
+
readonly x: number;
|
|
139
|
+
readonly y: number;
|
|
140
|
+
readonly rotation?: number;
|
|
141
|
+
readonly visible?: boolean;
|
|
142
|
+
/** Global tile id (with flip bits) for a tile object. */
|
|
143
|
+
readonly gid?: number;
|
|
144
|
+
/** Tile-object display size in map pixels. Default the tile image's size. */
|
|
145
|
+
readonly width?: number;
|
|
146
|
+
readonly height?: number;
|
|
147
|
+
/** Tiled text and complete style data, for a text renderer. */
|
|
148
|
+
readonly text?: MapText;
|
|
149
|
+
/** Outline for non-tile objects. Its own `x`/`y` are 0 here: the object carries the position. */
|
|
150
|
+
readonly shape?: MapShape;
|
|
151
|
+
readonly properties?: Properties;
|
|
152
|
+
}
|
|
153
|
+
/** Tiled text-object content and style, with editor defaults applied during import. */
|
|
154
|
+
export interface MapText {
|
|
155
|
+
readonly text: string;
|
|
156
|
+
readonly fontFamily: string;
|
|
157
|
+
readonly pixelSize: number;
|
|
158
|
+
readonly color: string;
|
|
159
|
+
readonly bold: boolean;
|
|
160
|
+
readonly italic: boolean;
|
|
161
|
+
readonly underline: boolean;
|
|
162
|
+
readonly strikeout: boolean;
|
|
163
|
+
readonly kerning: boolean;
|
|
164
|
+
readonly wrap: boolean;
|
|
165
|
+
readonly horizontalAlign: 'left' | 'center' | 'right' | 'justify';
|
|
166
|
+
readonly verticalAlign: 'top' | 'center' | 'bottom';
|
|
167
|
+
}
|
|
168
|
+
/** A layer of objects. */
|
|
169
|
+
export interface ObjectLayer extends LayerBase {
|
|
170
|
+
readonly type: 'object';
|
|
171
|
+
/** Default topdown: stable ascending object y. Index keeps the stored order. */
|
|
172
|
+
readonly drawOrder?: 'topdown' | 'index';
|
|
173
|
+
readonly objects: readonly MapObject[];
|
|
174
|
+
}
|
|
175
|
+
/** An image placed in map pixels, optionally repeated along either axis. */
|
|
176
|
+
export interface ImageLayer extends LayerBase {
|
|
177
|
+
readonly type: 'image';
|
|
178
|
+
readonly image: {
|
|
179
|
+
readonly source: string;
|
|
180
|
+
readonly width?: number;
|
|
181
|
+
readonly height?: number;
|
|
182
|
+
};
|
|
183
|
+
/** Default false for each axis. */
|
|
184
|
+
readonly repeatX?: boolean;
|
|
185
|
+
readonly repeatY?: boolean;
|
|
186
|
+
}
|
|
187
|
+
/** Layers in painter order. */
|
|
188
|
+
export type MapLayer = TileLayer | ObjectLayer | ImageLayer;
|
|
189
|
+
/** How cells sit on screen, as Tiled names it. */
|
|
190
|
+
export type MapOrientation = 'orthogonal' | 'isometric' | 'staggered' | 'hexagonal';
|
|
191
|
+
/** A whole map. `TileMap` draws orthogonal ones; `GridTileMap` of `margoengine/tilemap/iso` draws any orientation. */
|
|
192
|
+
export interface TileMapData {
|
|
193
|
+
/** Size in tiles. */
|
|
194
|
+
readonly width: number;
|
|
195
|
+
readonly height: number;
|
|
196
|
+
/** Default `'orthogonal'`. */
|
|
197
|
+
readonly orientation?: MapOrientation;
|
|
198
|
+
/** Orthogonal cell order. Default right-down. */
|
|
199
|
+
readonly renderOrder?: 'right-down' | 'right-up' | 'left-down' | 'left-up';
|
|
200
|
+
/** Staggered and hexagonal maps: rows (`'y'`, default) or columns (`'x'`) are pushed half a cell. */
|
|
201
|
+
readonly staggerAxis?: 'x' | 'y';
|
|
202
|
+
/** Staggered and hexagonal maps: which rows or columns are pushed. Default `'odd'`. */
|
|
203
|
+
readonly staggerIndex?: 'odd' | 'even';
|
|
204
|
+
/** Hexagonal maps: pixel length of the flat sides along the stagger axis. Default 0. */
|
|
205
|
+
readonly hexSideLength?: number;
|
|
206
|
+
/** Tile size in pixels. */
|
|
207
|
+
readonly tileWidth: number;
|
|
208
|
+
readonly tileHeight: number;
|
|
209
|
+
readonly tilesets: readonly MapTileset[];
|
|
210
|
+
/** Drawn in order, first at the back. */
|
|
211
|
+
readonly layers: readonly MapLayer[];
|
|
212
|
+
/** CSS `#rrggbb` or `#aarrggbb`. */
|
|
213
|
+
readonly backgroundColor?: string;
|
|
214
|
+
readonly properties?: Properties;
|
|
215
|
+
}
|
|
216
|
+
/** A decoded layer value. */
|
|
217
|
+
export interface DecodedTile {
|
|
218
|
+
/** Global tile id; 0 is empty. */
|
|
219
|
+
readonly gid: number;
|
|
220
|
+
readonly flipH: boolean;
|
|
221
|
+
readonly flipV: boolean;
|
|
222
|
+
readonly flipD: boolean;
|
|
223
|
+
}
|
|
224
|
+
/** Split a layer value into its global id and flip flags. */
|
|
225
|
+
export declare function decodeTile(value: number): DecodedTile;
|
|
226
|
+
/** Build a layer value from a global id and flip flags (`FLIP_H | FLIP_V | FLIP_D`). Throws a RangeError for an id outside 0..268435455. */
|
|
227
|
+
export declare function encodeTile(gid: number, flags?: number): number;
|
|
228
|
+
/** A tile layer of `width x height` tiles, empty unless `data` is given. */
|
|
229
|
+
export declare function createTileLayer(name: string, width: number, height: number, data?: Uint32Array): TileLayer;
|
|
230
|
+
/** The tileset that owns a layer value (flip bits ignored), or undefined for 0 and ids past every tileset. */
|
|
231
|
+
export declare function tilesetForGid(map: TileMapData, value: number): MapTileset | undefined;
|
|
232
|
+
/** The per-tile definition (animation, collision, properties) for a layer value, or undefined. */
|
|
233
|
+
export declare function tileDefForGid(map: TileMapData, value: number): TileDef | undefined;
|
|
234
|
+
/** The raw layer value at tile `(x, y)`, or 0 outside the layer. */
|
|
235
|
+
export declare function tileAt(layer: TileLayer, x: number, y: number): number;
|
|
236
|
+
/**
|
|
237
|
+
* Check a map's structure and throw on the first problem: a TypeError for a wrong shape, a RangeError for a bad
|
|
238
|
+
* number. The message names the field and what to change.
|
|
239
|
+
*/
|
|
240
|
+
export declare function validateTileMap(map: TileMapData): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as FLIP_D, n as FLIP_H, r as FLIP_MASK, i as FLIP_V, a as GID_MASK, m as TILE_CHUNK_SIZE, p as TileMap, h as animatedTile, g as chunkGrid, o as createTileLayer, s as decodeTile, c as encodeTile, _ as fillChunk, v as mapColor, l as tileAt, u as tileDefForGid, y as tileReach, d as tilesetForGid, f as validateTileMap, b as visibleChunks } from "./src-CJvCfCkX.js";
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
// @margo/core-built 0.1.0
|
|
2
|
+
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
+
const m=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
|
+
import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, a as s, h as c, k as l, v as u, w as d, x as f } from "./src-CJvCfCkX.js";
|
|
5
|
+
import { t as p } from "./layout-CLx3KdGC.js";
|
|
6
|
+
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
7
|
+
//#region ../shared/texel-varying.js
|
|
8
|
+
var h = "struct Varying{\n @builtin(position) position:vec4f,\n @location(0) texel:vec2f,\n @location(1) @interpolate(flat) low:vec2f,\n @location(2) @interpolate(flat) high:vec2f,\n @location(3) @interpolate(flat) tint:vec4f,\n}", g = 268435456, _ = 12, v = `
|
|
9
|
+
struct Tile{p:vec2f,s:vec2f,texel:vec2f,size:vec2f,flags:u32,tint:u32,pad0:u32,pad1:u32}
|
|
10
|
+
@group(0) @binding(0) var<uniform> view:vec4f;
|
|
11
|
+
@group(0) @binding(1) var<storage,read> tiles:array<Tile>;
|
|
12
|
+
@group(1) @binding(0) var atlas:texture_2d<f32>;
|
|
13
|
+
${h}
|
|
14
|
+
@vertex fn vertexMain(@builtin(vertex_index) corner:u32,@builtin(instance_index) index:u32)->Varying{
|
|
15
|
+
let t=tiles[index];
|
|
16
|
+
let c=vec2f(f32(corner&1u),f32(corner>>1u));
|
|
17
|
+
let hex=(t.flags&8u)!=0u;
|
|
18
|
+
|
|
19
|
+
let turns=select(0.0,f32(select(0u,1u,(t.flags&4u)!=0u)+select(0u,2u,(t.flags&16u)!=0u)),hex);
|
|
20
|
+
let a=turns*1.0471975511965976;
|
|
21
|
+
let q=(c-0.5)*t.s;
|
|
22
|
+
let p=t.p+t.s*0.5+vec2f(q.x*cos(a)-q.y*sin(a),q.x*sin(a)+q.y*cos(a));
|
|
23
|
+
var v:Varying;
|
|
24
|
+
v.position=vec4f(p/view.xy*vec2f(2,-2)+vec2f(-1,1),0,1);
|
|
25
|
+
|
|
26
|
+
var s=c;
|
|
27
|
+
if((t.flags&1u)!=0u){s.x=1-s.x;}
|
|
28
|
+
if((t.flags&2u)!=0u){s.y=1-s.y;}
|
|
29
|
+
if(!hex&&(t.flags&4u)!=0u){s=s.yx;}
|
|
30
|
+
v.texel=t.texel+s*t.size;
|
|
31
|
+
v.low=t.texel;
|
|
32
|
+
v.high=t.texel+t.size-1;
|
|
33
|
+
v.tint=unpack4x8unorm(t.tint);
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
@fragment fn fragmentMain(v:Varying)->@location(0) vec4f{
|
|
37
|
+
let color=textureLoad(atlas,vec2i(clamp(floor(v.texel),v.low,v.high)),0)*v.tint;
|
|
38
|
+
if(color.a==0){discard;}
|
|
39
|
+
return color;
|
|
40
|
+
}`, y = 0;
|
|
41
|
+
function b(e, t, n, r = []) {
|
|
42
|
+
r.length = 0;
|
|
43
|
+
let { width: i, height: a } = t, o = e.tileWidth, s = e.tileHeight, [c, l, u, d] = n, f = e.orientation ?? "orthogonal";
|
|
44
|
+
if (!i || !a || !(u > c && d > l)) return r;
|
|
45
|
+
let p = (e, t) => Math.min(Math.max(e, 0), t - 1);
|
|
46
|
+
if (f === "isometric") {
|
|
47
|
+
let t = e.height, n = Math.floor(2 * c / o) - t - 1, f = Math.ceil(2 * u / o) - t + 1, p = Math.max(Math.floor(2 * l / s) - 2, 0), m = Math.min(Math.ceil(2 * d / s) + 1, i + a - 2);
|
|
48
|
+
for (let e = p; e <= m; e++) for (let t = Math.max(0, e - a + 1); t <= Math.min(e, i - 1); t++) {
|
|
49
|
+
let a = 2 * t - e;
|
|
50
|
+
a >= n && a <= f && r.push((e - t) * i + t);
|
|
51
|
+
}
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
let m = (e.staggerAxis ?? "y") === "y" || f === "orthogonal", h = f === "hexagonal" ? e.hexSideLength ?? 0 : 0, g = f === "orthogonal" ? m ? s : o : ((m ? s : o) + h) / 2, _ = Math.floor((m ? l : c) / g) - 2, v = Math.ceil((m ? d : u) / g) + 1, y = Math.floor((m ? c : l) / (m ? o : s)) - 1, b = Math.ceil((m ? u : d) / (m ? o : s)) + 1, x = p(m ? _ : y, a), S = p(m ? v : b, a), C = p(m ? y : _, i), w = p(m ? b : v, i);
|
|
55
|
+
if (m) {
|
|
56
|
+
for (let e = x; e <= S; e++) for (let t = C; t <= w; t++) r.push(e * i + t);
|
|
57
|
+
return r;
|
|
58
|
+
}
|
|
59
|
+
let T = (e.staggerIndex ?? "odd") === "odd";
|
|
60
|
+
for (let e = x; e <= S; e++) for (let t of [!1, !0]) for (let n = C; n <= w; n++) (n & 1) == 1 === T === t && r.push(e * i + n);
|
|
61
|
+
return r;
|
|
62
|
+
}
|
|
63
|
+
var x = class h {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
|
|
64
|
+
constructor(n) {
|
|
65
|
+
if (this.time = 0, this.stats = {
|
|
66
|
+
draws: 0,
|
|
67
|
+
uploadedBytes: 0
|
|
68
|
+
}, this.slots = /* @__PURE__ */ new Map(), this.sets = [], this.pipelines = /* @__PURE__ */ new Map(), this.words = /* @__PURE__ */ new Uint32Array(), this.floats = () => new Float32Array(this.words.buffer), this.cells = [], this.disposed = !1, this.states = new f(() => ({
|
|
69
|
+
uniform: this.device.createBuffer({
|
|
70
|
+
size: 16,
|
|
71
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
72
|
+
}),
|
|
73
|
+
values: /* @__PURE__ */ new Float32Array(4)
|
|
74
|
+
}), (e) => {
|
|
75
|
+
e.uniform.destroy(), e.buffer?.destroy();
|
|
76
|
+
}), !n?.map) throw e("GridTileMap needs a map", "tilemap-options");
|
|
77
|
+
if (!n.atlases) throw e("GridTileMap needs atlases", "tilemap-options");
|
|
78
|
+
let r = n.order ?? 10;
|
|
79
|
+
if (!Number.isFinite(r)) throw l("Invalid tile map order", "tilemap-options");
|
|
80
|
+
if (n.clear && (n.clear.length !== 4 || !n.clear.every(Number.isFinite))) throw l("Invalid tile map clear", "tilemap-options");
|
|
81
|
+
this.atlases = { ...n.atlases }, this.names = n.mapLayers, this.camera = n.camera ?? {
|
|
82
|
+
x: 0,
|
|
83
|
+
y: 0,
|
|
84
|
+
zoom: 1
|
|
85
|
+
}, this.snap = n.snap ?? !0, this.parallax = n.parallax ?? !0, this.setTarget(n.target), this.clear = n.clear, this.order = r, this.layerMask = t(n.layers ?? 1, "GridTileMap layers"), this.name = n.name ?? `grid-tilemap-${++y}`, this.setMap(n.map);
|
|
86
|
+
}
|
|
87
|
+
static attach(e, t) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
|
|
88
|
+
let n = new h(t);
|
|
89
|
+
return m(e).use(n), n;
|
|
90
|
+
}
|
|
91
|
+
get map() {
|
|
92
|
+
return this.data;
|
|
93
|
+
}
|
|
94
|
+
setMap(e) {
|
|
95
|
+
p(e, 0, 0), this.releaseSets(), this.data = e, this.sets = [...e.tilesets].sort((e, t) => e.firstGid - t.firstGid).map((e) => ({
|
|
96
|
+
set: e,
|
|
97
|
+
frames: new Map((e.tiles ?? []).filter((e) => e.animation?.length).map((e) => [e.id, e.animation]))
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
setTarget(e) {
|
|
101
|
+
this.target = e, this.targetSlot = o(typeof e == "function" ? void 0 : e, "GridTileMap target", "setTarget", this.engine?.gpu);
|
|
102
|
+
}
|
|
103
|
+
setAtlas(e, t) {
|
|
104
|
+
this.atlases[e] = t, this.slots.set(e, o(t, "GridTileMap atlas", "setAtlas", this.engine?.gpu));
|
|
105
|
+
for (let t of this.sets) t.set.name === e && (t.atlas?.owned && t.atlas.texture.destroy(), t.atlas = t.group = void 0);
|
|
106
|
+
}
|
|
107
|
+
setup(e) {
|
|
108
|
+
if (this.disposed || e.backend !== "webgpu") throw i(this.disposed ? "disposed" : "unsupported", this.disposed ? "GridTileMap disposed" : "GridTileMap needs WebGPU", this.disposed ? "disposed" : "webgpu");
|
|
109
|
+
this.engine = e, r(this.targetSlot, e.gpu);
|
|
110
|
+
for (let t of this.slots.values()) r(t, e.gpu);
|
|
111
|
+
e.frameGraph.add({
|
|
112
|
+
name: this.name,
|
|
113
|
+
order: this.order,
|
|
114
|
+
execute: (e) => {
|
|
115
|
+
e.backend === "webgpu" && this.draw(e);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
advanceTime(e) {
|
|
120
|
+
e > 0 && (this.time += e * 1e3);
|
|
121
|
+
}
|
|
122
|
+
onPreUpdate(e) {
|
|
123
|
+
this.advanceTime(e), e > 0 && this.states.prune();
|
|
124
|
+
}
|
|
125
|
+
onDeviceRestored() {
|
|
126
|
+
this.releaseDevice();
|
|
127
|
+
}
|
|
128
|
+
dispose() {
|
|
129
|
+
this.disposed || (this.disposed = !0, this.engine?.sceneOf(this)?.removePlugin(this.name), this.releaseDevice(), this.engine = void 0);
|
|
130
|
+
}
|
|
131
|
+
[Symbol.dispose ?? Symbol()]() {
|
|
132
|
+
this.dispose();
|
|
133
|
+
}
|
|
134
|
+
releaseSets() {
|
|
135
|
+
for (let e of this.sets) e.atlas?.owned && e.atlas.texture.destroy();
|
|
136
|
+
this.sets = [];
|
|
137
|
+
}
|
|
138
|
+
releaseDevice() {
|
|
139
|
+
this.states.clear();
|
|
140
|
+
for (let e of this.sets) e.atlas?.owned && e.atlas.texture.destroy(), e.atlas = e.group = void 0;
|
|
141
|
+
this.pipelines.clear(), this.module = this.frameLayout = this.atlasLayout = this.device = void 0;
|
|
142
|
+
}
|
|
143
|
+
setFor(e) {
|
|
144
|
+
let t = this.sets;
|
|
145
|
+
for (let n = t.length - 1; n >= 0; n--) {
|
|
146
|
+
let r = t[n].set;
|
|
147
|
+
if (e >= r.firstGid) return e < r.firstGid + r.tileCount ? n : -1;
|
|
148
|
+
}
|
|
149
|
+
return -1;
|
|
150
|
+
}
|
|
151
|
+
build(e, t) {
|
|
152
|
+
let n = this.data, r = this.camera, a = n.orientation === "hexagonal", o = [], l = 0, d = n.layers.filter((e) => e.type === "tile" && (!this.names || this.names.includes(e.name)) && e.visible !== !1 && e.opacity !== 0), f = 0, m = 0;
|
|
153
|
+
for (let { set: e } of this.sets) f = Math.max(f, e.tileWidth - n.tileWidth + Math.abs(e.tileOffset?.[0] ?? 0)), m = Math.max(m, e.tileHeight - n.tileHeight + Math.abs(e.tileOffset?.[1] ?? 0));
|
|
154
|
+
for (let h of d) {
|
|
155
|
+
let d = this.parallax ? h.parallax?.[0] ?? 1 : 1, g = this.parallax ? h.parallax?.[1] ?? 1 : 1, v = (h.offset?.[0] ?? 0) - r.x * d, y = (h.offset?.[1] ?? 0) - r.y * g, x = u(h.tint) ?? [
|
|
156
|
+
1,
|
|
157
|
+
1,
|
|
158
|
+
1,
|
|
159
|
+
1
|
|
160
|
+
], S = (h.opacity ?? 1) * x[3], C = (Math.round(x[0] * 255) | Math.round(x[1] * 255) << 8 | Math.round(x[2] * 255) << 16 | Math.round(S * 255) << 24) >>> 0;
|
|
161
|
+
if (b(n, h, [
|
|
162
|
+
-v - f,
|
|
163
|
+
-y,
|
|
164
|
+
e / r.zoom - v,
|
|
165
|
+
t / r.zoom - y + m
|
|
166
|
+
], this.cells), this.words.length < (l + this.cells.length) * _) {
|
|
167
|
+
let e = new Uint32Array(Math.max((l + this.cells.length) * _, this.words.length * 2));
|
|
168
|
+
e.set(this.words), this.words = e;
|
|
169
|
+
}
|
|
170
|
+
let w = this.words, T = this.floats();
|
|
171
|
+
for (let e of this.cells) {
|
|
172
|
+
let t = h.data[e], u = t & s;
|
|
173
|
+
if (!u) continue;
|
|
174
|
+
let d = this.setFor(u);
|
|
175
|
+
if (d < 0) continue;
|
|
176
|
+
let { set: f, frames: m } = this.sets[d], g = u - f.firstGid, b = m.get(g), x = b ? c(b, this.time) : g, S = f.columns, E = !a && !!(t & 536870912), D = E ? f.tileHeight : f.tileWidth, O = E ? f.tileWidth : f.tileHeight;
|
|
177
|
+
if (!(S > 0)) throw i("state", `Tileset ${f.name} has no atlas columns`, "tilemap-options");
|
|
178
|
+
let k = e % h.width, A = (e - k) / h.width, j = p(n, k, A), M = (v + j.x + (f.tileOffset?.[0] ?? 0)) * r.zoom, N = (y + j.y + j.height - O + (f.tileOffset?.[1] ?? 0)) * r.zoom;
|
|
179
|
+
this.snap && (M = Math.round(M), N = Math.round(N));
|
|
180
|
+
let P = l * _, F = f.margin ?? 0, I = f.spacing ?? 0;
|
|
181
|
+
T[P] = M, T[P + 1] = N, T[P + 2] = D * r.zoom, T[P + 3] = O * r.zoom, T[P + 4] = F + x % S * (f.tileWidth + I), T[P + 5] = F + Math.floor(x / S) * (f.tileHeight + I), T[P + 6] = f.tileWidth, T[P + 7] = f.tileHeight, w[P + 8] = (t & 2147483648 ? 1 : 0) | (t & 1073741824 ? 2 : 0) | (t & 536870912 ? 4 : 0) | (a ? 8 : 0) | (a && t & 268435456 ? 16 : 0), w[P + 9] = C, o.length && o[o.length - 3] === d && o[o.length - 2] + o[o.length - 1] === l ? o[o.length - 1]++ : o.push(d, l, 1), l++;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return o;
|
|
185
|
+
}
|
|
186
|
+
group(e, t) {
|
|
187
|
+
if (t.group) return t.group;
|
|
188
|
+
let n = t.set.name, r = this.atlases[n];
|
|
189
|
+
if (!r) throw i("state", `No atlas for tileset ${n}`, "tilemap-options");
|
|
190
|
+
let a = this.slots.get(n);
|
|
191
|
+
if (a || this.slots.set(n, a = o(r, "GridTileMap atlas", "setAtlas", this.engine?.gpu)), t.atlas ??= d(a, e, this.engine, () => l("Invalid tile pixels", "tilemap-options")), t.atlas) return t.group = e.createBindGroup({
|
|
192
|
+
layout: this.atlasLayout,
|
|
193
|
+
entries: [{
|
|
194
|
+
binding: 0,
|
|
195
|
+
resource: t.atlas.texture.createView()
|
|
196
|
+
}]
|
|
197
|
+
}), t.group;
|
|
198
|
+
}
|
|
199
|
+
draw(e) {
|
|
200
|
+
let t = e.view;
|
|
201
|
+
if (t?.layers !== void 0 && !(t.layers & this.layerMask)) return;
|
|
202
|
+
let r = this.target, i = typeof r == "function" ? r() : r && n(this.targetSlot, e.device, this.engine);
|
|
203
|
+
if (r && typeof r != "function" && !i || i && t?.index) return;
|
|
204
|
+
let o = e.device, s = this.camera;
|
|
205
|
+
if (!(s.zoom > 0) || !Number.isFinite(s.x + s.y + s.zoom)) throw l("Invalid tile map camera", "tilemap-options");
|
|
206
|
+
this.device !== o && (this.device && this.releaseDevice(), this.device = o), this.module || (this.module = o.createShaderModule({
|
|
207
|
+
label: "grid tilemap",
|
|
208
|
+
code: v
|
|
209
|
+
}), this.frameLayout = o.createBindGroupLayout({ entries: [{
|
|
210
|
+
binding: 0,
|
|
211
|
+
visibility: GPUShaderStage.VERTEX,
|
|
212
|
+
buffer: { type: "uniform" }
|
|
213
|
+
}, {
|
|
214
|
+
binding: 1,
|
|
215
|
+
visibility: GPUShaderStage.VERTEX,
|
|
216
|
+
buffer: { type: "read-only-storage" }
|
|
217
|
+
}] }), this.atlasLayout = o.createBindGroupLayout({ entries: [{
|
|
218
|
+
binding: 0,
|
|
219
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
220
|
+
texture: { sampleType: "unfilterable-float" }
|
|
221
|
+
}] }));
|
|
222
|
+
let c = i ? i.width : t ? t.viewport[2] : e.width, d = i ? i.height : t ? t.viewport[3] : e.height, f = i ? i.format : e.format, p = i ? i.sampleCount : e.descriptor.multisample?.count ?? 1, m = this.build(c, d), h = m.length ? m[m.length - 2] + m[m.length - 1] : 0;
|
|
223
|
+
for (let e = 0; e < m.length; e += 3) this.group(o, this.sets[m[e]]);
|
|
224
|
+
let g = this.states.get(e);
|
|
225
|
+
h * _ * 4 > (g.buffer?.size ?? 0) && (g.buffer?.destroy(), g.buffer = o.createBuffer({
|
|
226
|
+
label: "grid tilemap tiles",
|
|
227
|
+
size: Math.max(h * _ * 4 * 2, 1024),
|
|
228
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
229
|
+
}), g.group = void 0), (g.values[0] !== c || g.values[1] !== d) && (g.values[0] = c, g.values[1] = d, o.queue.writeBuffer(g.uniform, 0, g.values)), g.group ??= o.createBindGroup({
|
|
230
|
+
layout: this.frameLayout,
|
|
231
|
+
entries: [{
|
|
232
|
+
binding: 0,
|
|
233
|
+
resource: { buffer: g.uniform }
|
|
234
|
+
}, {
|
|
235
|
+
binding: 1,
|
|
236
|
+
resource: { buffer: g.buffer }
|
|
237
|
+
}]
|
|
238
|
+
}), h && o.queue.writeBuffer(g.buffer, 0, this.words, 0, h * _), this.stats.draws = 0, this.stats.uploadedBytes = h * _ * 4;
|
|
239
|
+
let y = {
|
|
240
|
+
view: e.color,
|
|
241
|
+
loadOp: "load",
|
|
242
|
+
storeOp: "store"
|
|
243
|
+
};
|
|
244
|
+
if (i && (y.view = i.createView(), this.clear !== !1)) {
|
|
245
|
+
let e = this.clear ?? u(this.data.backgroundColor) ?? [
|
|
246
|
+
0,
|
|
247
|
+
0,
|
|
248
|
+
0,
|
|
249
|
+
0
|
|
250
|
+
], t = e[3];
|
|
251
|
+
y.loadOp = "clear", y.clearValue = this.clear ? [...e] : [
|
|
252
|
+
e[0] * t,
|
|
253
|
+
e[1] * t,
|
|
254
|
+
e[2] * t,
|
|
255
|
+
t
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
let b = e.encoder.beginRenderPass({ colorAttachments: [y] });
|
|
259
|
+
if (i || a(b, e), h) {
|
|
260
|
+
b.setPipeline(this.pipeline(o, f, p)), b.setBindGroup(0, g.group);
|
|
261
|
+
for (let e = 0; e < m.length; e += 3) {
|
|
262
|
+
let t = this.sets[m[e]].group;
|
|
263
|
+
t && (b.setBindGroup(1, t), b.draw(4, m[e + 2], 0, m[e + 1]), this.stats.draws++);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
b.end();
|
|
267
|
+
}
|
|
268
|
+
pipeline(e, t, n) {
|
|
269
|
+
let r = `${t}/${n}`, i = this.pipelines.get(r);
|
|
270
|
+
return i || (i = e.createRenderPipeline({
|
|
271
|
+
label: "grid tilemap",
|
|
272
|
+
layout: e.createPipelineLayout({ bindGroupLayouts: [this.frameLayout, this.atlasLayout] }),
|
|
273
|
+
vertex: {
|
|
274
|
+
module: this.module,
|
|
275
|
+
entryPoint: "vertexMain"
|
|
276
|
+
},
|
|
277
|
+
fragment: {
|
|
278
|
+
module: this.module,
|
|
279
|
+
entryPoint: "fragmentMain",
|
|
280
|
+
targets: [{
|
|
281
|
+
format: t,
|
|
282
|
+
blend: {
|
|
283
|
+
color: {
|
|
284
|
+
srcFactor: "src-alpha",
|
|
285
|
+
dstFactor: "one-minus-src-alpha"
|
|
286
|
+
},
|
|
287
|
+
alpha: {
|
|
288
|
+
srcFactor: "one",
|
|
289
|
+
dstFactor: "one-minus-src-alpha"
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}]
|
|
293
|
+
},
|
|
294
|
+
primitive: { topology: "triangle-strip" },
|
|
295
|
+
multisample: { count: n }
|
|
296
|
+
}), this.pipelines.set(r, i)), i;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
//#endregion
|
|
300
|
+
export { h as i, g as n, b as r, x as t };
|
package/dist/iso.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
3
|
+
import { type Engine, type EnginePlugin } from '@margoengine/core/extension';
|
|
4
|
+
import { type TileLayer, type TileMapData } from './index.js';
|
|
5
|
+
import { type MapGrid } from './layout.js';
|
|
6
|
+
import type { TileAtlas, TileCamera, TileMapStats, TileTarget } from './renderer.js';
|
|
7
|
+
export { cellBox, cellCenter, cellNeighbors, cellPolygon, mapPixelSize, paintOrder, pixelToCell, type CellBox, type MapGrid, } from './layout.js';
|
|
8
|
+
/** Tiled's bit 28 on hexagonal maps: the tile turned 120 degrees clockwise. Bit 29 (`FLIP_D`) turns it 60 degrees. */
|
|
9
|
+
export declare const HEX_ROTATE_120 = 268435456;
|
|
10
|
+
/** Settings of {@link GridTileMap}: those of a `TileMap`, for maps of any orientation. */
|
|
11
|
+
export interface GridTileMapOptions {
|
|
12
|
+
/** The map to draw. Required. Any `orientation`. */
|
|
13
|
+
map: TileMapData;
|
|
14
|
+
/** The texels of each tileset by its name; a tileset no drawn tile uses can be left out. Required. */
|
|
15
|
+
atlases: {
|
|
16
|
+
readonly [tileset: string]: TileAtlas;
|
|
17
|
+
};
|
|
18
|
+
/** Map pixels to target pixels, read each frame. Default `{x: 0, y: 0, zoom: 1}`. */
|
|
19
|
+
camera?: TileCamera;
|
|
20
|
+
/** Rounds each tile's corner to a whole target pixel, read each frame. Default true. */
|
|
21
|
+
snap?: boolean;
|
|
22
|
+
/** Names of the tile layers to draw, in map order. Default every tile layer. */
|
|
23
|
+
mapLayers?: readonly string[];
|
|
24
|
+
/** Scrolls each map layer by its own `parallax`, read each frame. Default true. */
|
|
25
|
+
parallax?: boolean;
|
|
26
|
+
/** Draw here instead of the canvas or the view's target. Default the frame's colour target. */
|
|
27
|
+
target?: TileTarget;
|
|
28
|
+
/** With `target`: the colour to clear it to first, or false. Default the map's `backgroundColor`, else transparent. */
|
|
29
|
+
clear?: readonly [number, number, number, number] | false;
|
|
30
|
+
/** Frame-graph order. Default 10. */
|
|
31
|
+
order?: number;
|
|
32
|
+
/** Render-layer bits. Default 1. */
|
|
33
|
+
layers?: number;
|
|
34
|
+
/** Plugin name, unique per scene. Default `grid-tilemap-1`, ... */
|
|
35
|
+
name?: string;
|
|
36
|
+
}
|
|
37
|
+
/** The visible cells of a layer in paint order, `y * width + x`, for a view of map pixels `[left, top, right, bottom]`. */
|
|
38
|
+
export declare function visibleCells(map: MapGrid, layer: Pick<TileLayer, 'width' | 'height'>, view: readonly [number, number, number, number], out?: number[]): number[];
|
|
39
|
+
/**
|
|
40
|
+
* Draws a {@link TileMapData} of any orientation (orthogonal, isometric, staggered or hexagonal), the cells in view
|
|
41
|
+
* back to front, one draw per run of tiles from the same tileset. Tiles bigger than the cell sit on its bottom left, as
|
|
42
|
+
* Tiled draws them. WebGPU only.
|
|
43
|
+
* @throws MargoError `'unsupported'` on WebGL, `'disposed'` after `dispose()`, `'state'` for a missing atlas. A plain
|
|
44
|
+
* `GPUTexture` atlas or target held at a device restore is reported once through `engine.onError` (`'state'`, help
|
|
45
|
+
* `borrowed-lost`) and the frame goes on without it until {@link GridTileMap.setAtlas} or {@link GridTileMap.setTarget}
|
|
46
|
+
* gives a new one.
|
|
47
|
+
*/
|
|
48
|
+
export declare class GridTileMap implements EnginePlugin {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/** Map pixels to target pixels, read each frame. */
|
|
51
|
+
camera: TileCamera;
|
|
52
|
+
/** Rounds each tile's corner to a whole target pixel, read each frame. */
|
|
53
|
+
snap: boolean;
|
|
54
|
+
/** Scrolls each map layer by its own `parallax`, read each frame. */
|
|
55
|
+
parallax: boolean;
|
|
56
|
+
/** The animation clock in milliseconds. Each frame adds its delta. */
|
|
57
|
+
time: number;
|
|
58
|
+
/** What the last frame cost: draws and bytes of tiles written. */
|
|
59
|
+
readonly stats: TileMapStats;
|
|
60
|
+
private readonly order;
|
|
61
|
+
private readonly layerMask;
|
|
62
|
+
private target?;
|
|
63
|
+
private targetSlot;
|
|
64
|
+
private readonly clear?;
|
|
65
|
+
private readonly names?;
|
|
66
|
+
private atlases;
|
|
67
|
+
private readonly slots;
|
|
68
|
+
private data;
|
|
69
|
+
private sets;
|
|
70
|
+
private engine?;
|
|
71
|
+
private device?;
|
|
72
|
+
private module?;
|
|
73
|
+
private frameLayout?;
|
|
74
|
+
private atlasLayout?;
|
|
75
|
+
private readonly pipelines;
|
|
76
|
+
private words;
|
|
77
|
+
private readonly floats;
|
|
78
|
+
private readonly cells;
|
|
79
|
+
private disposed;
|
|
80
|
+
private readonly states;
|
|
81
|
+
constructor(options: GridTileMapOptions);
|
|
82
|
+
/** Creates a renderer and attaches it to `instance`. */
|
|
83
|
+
static attach(instance: EngineKernel, options: GridTileMapOptions): GridTileMap;
|
|
84
|
+
/** The map being drawn. Cells are read every frame, so writes into `layer.data` show on the next one. */
|
|
85
|
+
get map(): TileMapData;
|
|
86
|
+
/** Draws another map from the next frame. */
|
|
87
|
+
setMap(map: TileMapData): void;
|
|
88
|
+
/**
|
|
89
|
+
* Replaces the map's own target: a texture, a function read each frame, or undefined for the frame's colour target.
|
|
90
|
+
* After a device restore, hand in a texture made on `engine.gpu` here.
|
|
91
|
+
*/
|
|
92
|
+
setTarget(target: TileTarget | undefined): void;
|
|
93
|
+
/** Swaps one tileset's atlas from the next frame. */
|
|
94
|
+
setAtlas(tileset: string, atlas: TileAtlas): void;
|
|
95
|
+
setup(engine: Engine): void;
|
|
96
|
+
/**
|
|
97
|
+
* Moves the tile animation clock (`time`, in milliseconds) by `delta` seconds without drawing (a delta of 0 or less
|
|
98
|
+
* moves nothing). Each frame update runs it, so `seek` from `@margoengine/cutscene/seek` replays it exactly.
|
|
99
|
+
*/
|
|
100
|
+
advanceTime(delta: number): void;
|
|
101
|
+
onPreUpdate(delta: number): void;
|
|
102
|
+
onDeviceRestored(): void;
|
|
103
|
+
dispose(): void;
|
|
104
|
+
[Symbol.dispose]: () => void;
|
|
105
|
+
private releaseSets;
|
|
106
|
+
private releaseDevice;
|
|
107
|
+
private setFor;
|
|
108
|
+
/** Writes every visible tile of the drawn layers in paint order; returns runs `[set, first, count]`. */
|
|
109
|
+
private build;
|
|
110
|
+
/** The bind group of a tileset's atlas; undefined while a caller's atlas is lost with the device. */
|
|
111
|
+
private group;
|
|
112
|
+
private draw;
|
|
113
|
+
private pipeline;
|
|
114
|
+
}
|
package/dist/iso.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./iso-C2Hwh5Gr.js";
|
|
2
|
+
import { a as r, i, n as a, o, r as s, s as c, t as l } from "./layout-CLx3KdGC.js";
|
|
3
|
+
export { n as GridTileMap, e as HEX_ROTATE_120, l as cellBox, a as cellCenter, s as cellNeighbors, i as cellPolygon, r as mapPixelSize, o as paintOrder, c as pixelToCell, t as visibleCells };
|