@margoengine/loaders 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.
Files changed (184) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +1198 -3
  4. package/dist/3dm.d.ts +161 -0
  5. package/dist/3dm.js +289 -0
  6. package/dist/3ds.d.ts +124 -0
  7. package/dist/3ds.js +392 -0
  8. package/dist/acclaim.d.ts +90 -0
  9. package/dist/acclaim.js +312 -0
  10. package/dist/amf.d.ts +45 -0
  11. package/dist/amf.js +256 -0
  12. package/dist/babylon.d.ts +197 -0
  13. package/dist/babylon.js +701 -0
  14. package/dist/common.d.ts +7 -0
  15. package/dist/common.js +6 -0
  16. package/dist/dae-animation.d.ts +66 -0
  17. package/dist/dae-animation.js +266 -0
  18. package/dist/dae-common.d.ts +95 -0
  19. package/dist/dae-common.js +226 -0
  20. package/dist/dae-controllers.d.ts +57 -0
  21. package/dist/dae-controllers.js +164 -0
  22. package/dist/dae-pose.d.ts +131 -0
  23. package/dist/dae-pose.js +381 -0
  24. package/dist/dae-scene.d.ts +203 -0
  25. package/dist/dae-scene.js +279 -0
  26. package/dist/dae.d.ts +161 -0
  27. package/dist/dae.js +633 -0
  28. package/dist/detect.d.ts +20 -0
  29. package/dist/detect.js +72 -0
  30. package/dist/dxf.d.ts +81 -0
  31. package/dist/dxf.js +774 -0
  32. package/dist/engine.d.ts +36 -0
  33. package/dist/engine.js +117 -0
  34. package/dist/font-opentype.d.ts +14 -0
  35. package/dist/font-opentype.js +33 -0
  36. package/dist/font-woff.d.ts +23 -0
  37. package/dist/font-woff.js +293 -0
  38. package/dist/font.d.ts +41 -0
  39. package/dist/font.js +26 -0
  40. package/dist/gcode.d.ts +55 -0
  41. package/dist/gcode.js +278 -0
  42. package/dist/geo-model.d.ts +84 -0
  43. package/dist/geo-model.js +220 -0
  44. package/dist/geo-mvt.d.ts +15 -0
  45. package/dist/geo-mvt.js +302 -0
  46. package/dist/geo-shp.d.ts +15 -0
  47. package/dist/geo-shp.js +234 -0
  48. package/dist/geo-xml.d.ts +6 -0
  49. package/dist/geo-xml.js +165 -0
  50. package/dist/geo.d.ts +8 -0
  51. package/dist/geo.js +59 -0
  52. package/dist/geometry.d.ts +60 -0
  53. package/dist/geometry.js +273 -0
  54. package/dist/index.d.ts +54 -0
  55. package/dist/index.js +28 -0
  56. package/dist/kmz.d.ts +78 -0
  57. package/dist/kmz.js +173 -0
  58. package/dist/las.d.ts +92 -0
  59. package/dist/las.js +110 -0
  60. package/dist/ldraw.d.ts +118 -0
  61. package/dist/ldraw.js +474 -0
  62. package/dist/load.d.ts +72 -0
  63. package/dist/load.js +205 -0
  64. package/dist/lottie.d.ts +154 -0
  65. package/dist/lottie.js +893 -0
  66. package/dist/lwo.d.ts +81 -0
  67. package/dist/lwo.js +454 -0
  68. package/dist/lzf.d.ts +13 -0
  69. package/dist/lzf.js +56 -0
  70. package/dist/materialx.d.ts +120 -0
  71. package/dist/materialx.js +563 -0
  72. package/dist/md2.d.ts +52 -0
  73. package/dist/md2.js +112 -0
  74. package/dist/mmcif.d.ts +14 -0
  75. package/dist/mmcif.js +246 -0
  76. package/dist/mmd.d.ts +244 -0
  77. package/dist/mmd.js +958 -0
  78. package/dist/mocap.d.ts +71 -0
  79. package/dist/mocap.js +178 -0
  80. package/dist/molecule-common.d.ts +4 -0
  81. package/dist/molecule-common.js +54 -0
  82. package/dist/mtl.d.ts +120 -0
  83. package/dist/mtl.js +469 -0
  84. package/dist/normals.d.ts +7 -0
  85. package/dist/normals.js +31 -0
  86. package/dist/nrrd.d.ts +63 -0
  87. package/dist/nrrd.js +743 -0
  88. package/dist/nurbs.d.ts +118 -0
  89. package/dist/nurbs.js +265 -0
  90. package/dist/obj.d.ts +143 -0
  91. package/dist/obj.js +456 -0
  92. package/dist/off.d.ts +10 -0
  93. package/dist/off.js +155 -0
  94. package/dist/outline-font.d.ts +87 -0
  95. package/dist/outline-font.js +110 -0
  96. package/dist/outline.d.ts +20 -0
  97. package/dist/outline.js +215 -0
  98. package/dist/pcd.d.ts +34 -0
  99. package/dist/pcd.js +258 -0
  100. package/dist/pdb.d.ts +67 -0
  101. package/dist/pdb.js +126 -0
  102. package/dist/ply.d.ts +35 -0
  103. package/dist/ply.js +392 -0
  104. package/dist/polygon.d.ts +9 -0
  105. package/dist/polygon.js +49 -0
  106. package/dist/prwm.d.ts +24 -0
  107. package/dist/prwm.js +114 -0
  108. package/dist/render.d.ts +27 -0
  109. package/dist/render.js +153 -0
  110. package/dist/sfnt-cff.d.ts +37 -0
  111. package/dist/sfnt-cff.js +749 -0
  112. package/dist/sfnt-layout.d.ts +24 -0
  113. package/dist/sfnt-layout.js +266 -0
  114. package/dist/sfnt-reader.d.ts +28 -0
  115. package/dist/sfnt-reader.js +87 -0
  116. package/dist/sfnt-variation.d.ts +40 -0
  117. package/dist/sfnt-variation.js +318 -0
  118. package/dist/shared/asset-url.js +82 -0
  119. package/dist/shared/crc32.d.ts +2 -0
  120. package/dist/shared/crc32.js +47 -0
  121. package/dist/shared/errors.js +36 -0
  122. package/dist/shared/inflate.js +284 -0
  123. package/dist/shared/normals.js +26 -0
  124. package/dist/shared/scene-scope.js +56 -0
  125. package/dist/shared/trailing-data.js +42 -0
  126. package/dist/stl.d.ts +64 -0
  127. package/dist/stl.js +309 -0
  128. package/dist/svg.d.ts +90 -0
  129. package/dist/svg.js +1007 -0
  130. package/dist/tds.d.ts +2 -0
  131. package/dist/tds.js +2 -0
  132. package/dist/textures.d.ts +42 -0
  133. package/dist/textures.js +53 -0
  134. package/dist/threemf-lattice.d.ts +139 -0
  135. package/dist/threemf-lattice.js +514 -0
  136. package/dist/threemf-materials.d.ts +75 -0
  137. package/dist/threemf-materials.js +314 -0
  138. package/dist/threemf-mesh.d.ts +60 -0
  139. package/dist/threemf-mesh.js +201 -0
  140. package/dist/threemf.d.ts +101 -0
  141. package/dist/threemf.js +415 -0
  142. package/dist/tilt.d.ts +62 -0
  143. package/dist/tilt.js +186 -0
  144. package/dist/tmx.d.ts +151 -0
  145. package/dist/tmx.js +394 -0
  146. package/dist/ttf.d.ts +78 -0
  147. package/dist/ttf.js +568 -0
  148. package/dist/types.d.ts +90 -0
  149. package/dist/types.js +35 -0
  150. package/dist/usd.d.ts +2 -0
  151. package/dist/usd.js +2 -0
  152. package/dist/usd.worker.d.ts +1 -0
  153. package/dist/usdz.d.ts +50 -0
  154. package/dist/usdz.js +646 -0
  155. package/dist/util.d.ts +75 -0
  156. package/dist/util.js +241 -0
  157. package/dist/vdb.d.ts +111 -0
  158. package/dist/vdb.js +663 -0
  159. package/dist/vrml.d.ts +53 -0
  160. package/dist/vrml.js +532 -0
  161. package/dist/vtk-cells.d.ts +29 -0
  162. package/dist/vtk-cells.js +211 -0
  163. package/dist/vtk-legacy.d.ts +57 -0
  164. package/dist/vtk-legacy.js +439 -0
  165. package/dist/vtk-reader.d.ts +19 -0
  166. package/dist/vtk-reader.js +134 -0
  167. package/dist/vtk-xml.d.ts +96 -0
  168. package/dist/vtk-xml.js +578 -0
  169. package/dist/vtk.d.ts +13 -0
  170. package/dist/vtk.js +234 -0
  171. package/dist/woff-glyf.d.ts +17 -0
  172. package/dist/woff-glyf.js +215 -0
  173. package/dist/worker.d.ts +10 -0
  174. package/dist/worker.js +93 -0
  175. package/dist/workers/usd.js +3 -0
  176. package/dist/xfile.d.ts +99 -0
  177. package/dist/xfile.js +706 -0
  178. package/dist/xml.d.ts +107 -0
  179. package/dist/xml.js +843 -0
  180. package/dist/xyz.d.ts +16 -0
  181. package/dist/xyz.js +110 -0
  182. package/dist/zip.d.ts +38 -0
  183. package/dist/zip.js +150 -0
  184. package/package.json +246 -6
package/dist/tilt.js ADDED
@@ -0,0 +1,186 @@
1
+ // Tilt Brush / Open Brush .tilt sketches: the brush strokes as flat ribbons. Written from the public Open Brush file
2
+ // format notes (docs.openbrush.app/developer-notes/open-brush-file-format) and the Tilt Brush 23 release notes.
3
+ import { LoaderError } from './types.js';
4
+ import { checkCount, floats, limits, throwIfAborted, toBytes, uints } from './util.js';
5
+ import { readZipDirectory, readZipEntry } from './zip.js';
6
+ const F = 'TILT';
7
+ const rotate = (q, v) => {
8
+ // v + 2w(q x v) + 2 q x (q x v)
9
+ const [x, y, z, w] = q, tx = 2 * (y * v[2] - z * v[1]), ty = 2 * (z * v[0] - x * v[2]), tz = 2 * (x * v[1] - y * v[0]);
10
+ return [
11
+ v[0] + w * tx + (y * tz - z * ty),
12
+ v[1] + w * ty + (z * tx - x * tz),
13
+ v[2] + w * tz + (x * ty - y * tx),
14
+ ];
15
+ };
16
+ /** Reads `data.sketch` itself (the stroke stream), for callers that already unzipped the `.tilt`. */
17
+ export function parseTiltSketch(input, options = {}) {
18
+ const bytes = toBytes(input, F), limit = limits(options, F), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
19
+ let p = 0;
20
+ const need = (n, what) => {
21
+ if (n < 0 || p + n > bytes.length)
22
+ throw new LoaderError(F, 'truncated', `data.sketch ends inside ${what}`);
23
+ };
24
+ const u32 = (what) => (need(4, what), (p += 4), view.getUint32(p - 4, true));
25
+ const i32 = (what) => (need(4, what), (p += 4), view.getInt32(p - 4, true));
26
+ const f32 = (what) => (need(4, what), (p += 4), view.getFloat32(p - 4, true));
27
+ u32('the sentinel');
28
+ const version = u32('the version');
29
+ u32('the reserved word');
30
+ const extra = u32('the additional header size');
31
+ need(extra, 'the additional header');
32
+ p += extra;
33
+ const strokeCount = checkCount(i32('the stroke count'), 4_000_000, F, 'stroke');
34
+ const strokes = [];
35
+ let totalPoints = 0;
36
+ for (let s = 0; s < strokeCount; s++) {
37
+ throwIfAborted(options.signal, F);
38
+ const brushIndex = i32('a stroke'), color = [f32('a colour'), f32('a colour'), f32('a colour'), f32('a colour')], size = f32('a brush size'), strokeMask = u32('a stroke mask'), pointMask = u32('a control point mask');
39
+ // Stroke extensions: a 4-byte value per low bit, a size-prefixed blob per high bit. None is needed for ribbons.
40
+ for (let bit = 0; bit < 32; bit++) {
41
+ if (!(strokeMask >>> bit & 1))
42
+ continue;
43
+ if (bit < 16)
44
+ (need(4, 'a stroke extension'), (p += 4));
45
+ else {
46
+ const n = u32('a stroke extension size');
47
+ need(n, 'a stroke extension');
48
+ p += n;
49
+ }
50
+ }
51
+ const count = checkCount(i32('a control point count'), limit.maxVertices, F, 'control point');
52
+ totalPoints += count;
53
+ if (totalPoints > limit.maxVertices)
54
+ throw new LoaderError(F, 'limit', `control points exceed the limit of ${limit.maxVertices}`);
55
+ // Control point extensions: bit 0 pressure (float), bit 1 timestamp (uint32); any other low bit is one 4-byte value
56
+ // and a high bit a size-prefixed blob, skipped.
57
+ let stride = 28;
58
+ for (let bit = 0; bit < 16; bit++)
59
+ if (pointMask >>> bit & 1)
60
+ stride += 4;
61
+ if (pointMask >>> 16 !== 0)
62
+ throw new LoaderError(F, 'unsupported', 'control point extensions with a size prefix are not supported');
63
+ need(count * stride, 'control points');
64
+ const points = [];
65
+ for (let i = 0; i < count; i++) {
66
+ const position = [f32(''), f32(''), f32('')], orientation = [f32(''), f32(''), f32(''), f32('')];
67
+ let pressure = 1, timestamp = 0;
68
+ for (let bit = 0; bit < 16; bit++) {
69
+ if (!(pointMask >>> bit & 1))
70
+ continue;
71
+ if (bit === 0)
72
+ pressure = f32('');
73
+ else if (bit === 1)
74
+ timestamp = u32('');
75
+ else
76
+ p += 4;
77
+ }
78
+ points.push({ position, orientation, pressure, timestamp });
79
+ }
80
+ strokes.push({ brushIndex, color, size, points });
81
+ }
82
+ return { strokes, version };
83
+ }
84
+ /**
85
+ * Parses a `.tilt` file (a zip with a 16-byte header in front: `data.sketch` and `metadata.json`) into ribbons.
86
+ * A ribbon runs along a stroke's control points; its width is `size * pressure * widthScale` along the controller's
87
+ * local X axis, its normal is across it, and every vertex carries the stroke colour.
88
+ */
89
+ export async function parseTilt(input, options = {}) {
90
+ throwIfAborted(options.signal, F);
91
+ const bytes = toBytes(input, F), scale = options.scale ?? 0.1, widthScale = options.widthScale ?? 1, minPoints = options.minControlPoints ?? 2, right = options.rightHanded ?? true;
92
+ if (!(scale > 0) || !(widthScale >= 0) || !Number.isFinite(scale))
93
+ throw new LoaderError(F, 'range', 'scale must be positive and widthScale not negative');
94
+ const limit = limits(options, F);
95
+ // The archive follows the 16-byte header. Zip offsets are relative to the zip's own start in most writers and to the
96
+ // file's in some, so try the stripped bytes first and the whole file second.
97
+ const hasHeader = bytes.length >= 16 && bytes[0] === 0x74 && bytes[1] === 0x69 && bytes[2] === 0x6c && bytes[3] === 0x54;
98
+ const attempts = hasHeader
99
+ ? [bytes.subarray(new DataView(bytes.buffer, bytes.byteOffset).getUint16(4, true) || 16), bytes]
100
+ : [bytes];
101
+ let sketch, meta, lastError;
102
+ for (const archive of attempts) {
103
+ try {
104
+ const entries = readZipDirectory(archive, options), find = (name) => entries.find((e) => e.name === name || e.name.endsWith(`/${name}`));
105
+ const dataEntry = find('data.sketch');
106
+ if (!dataEntry)
107
+ throw new LoaderError(F, 'zip', 'the archive has no data.sketch');
108
+ sketch = await readZipEntry(archive, dataEntry, options);
109
+ const metaEntry = find('metadata.json');
110
+ meta = metaEntry ? await readZipEntry(archive, metaEntry, options) : undefined;
111
+ break;
112
+ }
113
+ catch (error) {
114
+ lastError = error;
115
+ if (error instanceof LoaderError && error.code === 'aborted')
116
+ throw error;
117
+ }
118
+ }
119
+ if (!sketch)
120
+ throw lastError;
121
+ let metadata;
122
+ if (meta) {
123
+ try {
124
+ metadata = JSON.parse(new TextDecoder().decode(meta));
125
+ }
126
+ catch {
127
+ throw new LoaderError(F, 'syntax', 'metadata.json is not valid JSON');
128
+ }
129
+ }
130
+ const brushes = Array.isArray(metadata?.BrushIndex) ? metadata.BrushIndex.map(String) : [];
131
+ const { strokes, version } = parseTiltSketch(sketch, options);
132
+ const positions = floats(), normals = floats(), colors = floats(), indices = uints(), groups = [];
133
+ let vertex = 0;
134
+ for (const stroke of strokes) {
135
+ stroke.brush = brushes[stroke.brushIndex];
136
+ const pts = stroke.points;
137
+ if (pts.length < minPoints || pts.length < 2)
138
+ continue;
139
+ if (vertex + pts.length * 2 > limit.maxVertices)
140
+ throw new LoaderError(F, 'limit', `ribbon vertices exceed the limit of ${limit.maxVertices}`);
141
+ const start = indices.length;
142
+ for (let i = 0; i < pts.length; i++) {
143
+ const a = pts[Math.max(i - 1, 0)].position, b = pts[Math.min(i + 1, pts.length - 1)].position, tangent = [b[0] - a[0], b[1] - a[1], b[2] - a[2]], side = rotate(pts[i].orientation, [1, 0, 0]), half = (stroke.size * pts[i].pressure * widthScale * scale) / 2;
144
+ // Normal across the ribbon: right x tangent, or the controller's up when the stroke stands still.
145
+ let n = [
146
+ side[1] * tangent[2] - side[2] * tangent[1],
147
+ side[2] * tangent[0] - side[0] * tangent[2],
148
+ side[0] * tangent[1] - side[1] * tangent[0],
149
+ ];
150
+ const length = Math.hypot(n[0], n[1], n[2]);
151
+ n = length > 1e-12 ? n.map((c) => c / length) : rotate(pts[i].orientation, [0, 1, 0]);
152
+ const p = pts[i].position;
153
+ for (const sign of [-1, 1]) {
154
+ positions.push3(p[0] * scale + side[0] * half * sign, p[1] * scale + side[1] * half * sign, (p[2] * scale + side[2] * half * sign) * (right ? -1 : 1));
155
+ normals.push3(n[0], n[1], n[2] * (right ? -1 : 1));
156
+ colors.push3(stroke.color[0], stroke.color[1], stroke.color[2]);
157
+ }
158
+ }
159
+ for (let i = 0; i + 1 < pts.length; i++) {
160
+ const a = vertex + i * 2;
161
+ if (right)
162
+ indices.push3(a, a + 3, a + 1), indices.push3(a, a + 2, a + 3);
163
+ else
164
+ indices.push3(a, a + 1, a + 3), indices.push3(a, a + 3, a + 2);
165
+ }
166
+ vertex += pts.length * 2;
167
+ groups.push({
168
+ start,
169
+ count: indices.length - start,
170
+ ...(stroke.brush ? { name: stroke.brush } : {}),
171
+ color: stroke.color,
172
+ properties: { brushIndex: stroke.brushIndex },
173
+ });
174
+ }
175
+ const geometry = {
176
+ kind: indices.length ? 'mesh' : 'points',
177
+ positions: positions.result(),
178
+ normals: normals.result(),
179
+ colors: colors.result(),
180
+ };
181
+ if (indices.length)
182
+ geometry.indices = indices.result();
183
+ if (groups.length)
184
+ geometry.groups = groups;
185
+ return { geometry, strokes, brushes, ...(metadata ? { metadata } : {}), version };
186
+ }
package/dist/tmx.d.ts ADDED
@@ -0,0 +1,151 @@
1
+ import { type AssetResolver, type LoadedGeometry, type LoadedGroup } from './types.js';
2
+ import { type BinaryInput } from './util.js';
3
+ import { type XMLExternalOptions } from './xml.js';
4
+ /** Custom properties by name, in a null-prototype object: `int` and `float` become numbers, `bool` booleans. */
5
+ export type TMXProperties = Record<string, string | number | boolean>;
6
+ /** A tileset. Tilesets whose atlas image and grid are the same are merged into one. */
7
+ export interface TMXTileset {
8
+ name?: string;
9
+ /** TSX path relative to the TMX folder, for an external tileset. */
10
+ source?: string;
11
+ tilewidth: number;
12
+ tileheight: number;
13
+ spacing: number;
14
+ margin: number;
15
+ /** Tiles per atlas row, from the file or computed from the image width. */
16
+ columns: number;
17
+ tilecount: number;
18
+ /** `<tileoffset>` in pixels, y down: where this tileset's tiles are drawn relative to their cell. Default 0, 0. */
19
+ tileoffset: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ /** The atlas: path relative to the TMX folder (for the resolver) and size in pixels. Absent for image collections. */
24
+ image?: {
25
+ path: string;
26
+ width: number;
27
+ height: number;
28
+ };
29
+ properties: TMXProperties;
30
+ }
31
+ /** Where a tileset's global tile ids start. A gid belongs to the reference with the largest `firstgid` <= gid. */
32
+ export interface TMXTilesetRef {
33
+ firstgid: number;
34
+ /** Index into `LoadedTMX.tilesets`. */
35
+ tileset: number;
36
+ }
37
+ /** Fields every layer has. Group layers are flattened: these already include the enclosing groups. */
38
+ export interface TMXLayerCommon {
39
+ id?: number;
40
+ name: string;
41
+ visible: boolean;
42
+ opacity: number;
43
+ /** Pixel offset. */
44
+ offsetx: number;
45
+ offsety: number;
46
+ properties: TMXProperties;
47
+ }
48
+ /** A tile layer as a dense grid of cells, row by row. */
49
+ export interface TMXTileLayer extends TMXLayerCommon {
50
+ type: 'tile';
51
+ /** Cell of the grid's top-left corner: 0 for fixed maps, the smallest chunk position for infinite ones. */
52
+ x: number;
53
+ y: number;
54
+ width: number;
55
+ height: number;
56
+ /** Global tile id per cell with the flip bits cleared; 0 is empty. */
57
+ gids: Uint32Array;
58
+ /** Flip bits per cell: 1 horizontal, 2 vertical, 4 diagonal (applied first, as in Tiled). */
59
+ flips: Uint8Array;
60
+ }
61
+ /** An object of an object layer, in pixels. */
62
+ export interface TMXObject {
63
+ id?: number;
64
+ name: string;
65
+ /** `type` (or `class` in Tiled 1.9+). */
66
+ type: string;
67
+ x: number;
68
+ y: number;
69
+ width: number;
70
+ height: number;
71
+ rotation: number;
72
+ visible: boolean;
73
+ /** Tile objects: global tile id with the flip bits cleared, and the flip bits as in `TMXTileLayer.flips`. */
74
+ gid?: number;
75
+ flips?: number;
76
+ properties: TMXProperties;
77
+ }
78
+ /** An object layer (`<objectgroup>`). */
79
+ export interface TMXObjectLayer extends TMXLayerCommon {
80
+ type: 'object';
81
+ objects: TMXObject[];
82
+ }
83
+ /** A tile or object layer. */
84
+ export type TMXLayer = TMXTileLayer | TMXObjectLayer;
85
+ /** A parsed Tiled map. */
86
+ export interface LoadedTMX {
87
+ orientation: 'orthogonal';
88
+ renderorder: string;
89
+ /** Size in tiles (for infinite maps, as saved). */
90
+ width: number;
91
+ height: number;
92
+ /** Grid cell size in pixels. */
93
+ tilewidth: number;
94
+ tileheight: number;
95
+ infinite: boolean;
96
+ tilesets: TMXTileset[];
97
+ /** Sorted by `firstgid`. */
98
+ tilesetRefs: TMXTilesetRef[];
99
+ /** Tile and object layers in drawing order, groups flattened. */
100
+ layers: TMXLayer[];
101
+ properties: TMXProperties;
102
+ /** What was skipped: image layers, image-collection tilesets. */
103
+ warnings: string[];
104
+ }
105
+ /** Options of `parseTMX`. */
106
+ export interface TMXParseOptions extends XMLExternalOptions {
107
+ /** Reads external tilesets (`<tileset source>`), given their path relative to the TMX folder. */
108
+ resolve?: AssetResolver;
109
+ signal?: AbortSignal;
110
+ }
111
+ /**
112
+ * Parses a Tiled TMX map (orthogonal; other orientations throw `unsupported`): map attributes, embedded and external
113
+ * (TSX, through `resolve`) tilesets merged when their image and grid match, tile layers in csv, base64 (plain, zlib or
114
+ * gzip; zstd throws `unsupported`) or legacy `<tile>` data and infinite-map chunks, GID flip bits split into `flips`,
115
+ * object layers, custom properties, and group layers flattened with their offsets, visibility and opacity combined.
116
+ * Turn a tile layer into geometry with `tmxLayerQuads`.
117
+ */
118
+ export declare function parseTMX(input: BinaryInput | string, options?: TMXParseOptions): Promise<LoadedTMX>;
119
+ /** Options of `tmxLayerQuads`. */
120
+ export interface TileQuadsOptions {
121
+ /** World size of one map cell along X and Z. Default 1. */
122
+ tileSize?: number;
123
+ }
124
+ /** A tileset's quads of one tile layer. */
125
+ export interface TileQuadsGroup extends LoadedGroup {
126
+ /** Index into `LoadedTMX.tilesets`. */
127
+ tileset: number;
128
+ }
129
+ /**
130
+ * One quad per non-empty cell of a tile layer: four vertices each (top-left, bottom-left, bottom-right, top-right as
131
+ * seen from +Y), triangles (0, 1, 2) and (0, 2, 3), so `faceSizes` is all 4.
132
+ */
133
+ export interface TileQuads extends LoadedGeometry {
134
+ kind: 'mesh';
135
+ normals: Float32Array;
136
+ uvs: Float32Array;
137
+ indices: Uint32Array;
138
+ faceSizes: Uint32Array;
139
+ /** One group per tileset, in tileset order. */
140
+ groups: TileQuadsGroup[];
141
+ /** Layer cell (row * width + column) of each quad. */
142
+ cells: Uint32Array;
143
+ }
144
+ /**
145
+ * Turns a tile layer into quads on the XZ plane, facing +Y: map column x runs along +X and row y along +Z, one cell
146
+ * `tileSize` wide, layer pixel offsets scaled by the map's tile size. Tiles larger than a cell grow from its
147
+ * bottom-left corner, as Tiled draws them, moved by the tileset's `<tileoffset>`. UVs (Margo's convention, v = 0 at the top of the image) cover each tile's
148
+ * atlas rectangle, honoring spacing and margin, with the diagonal, horizontal and vertical flips applied in Tiled's
149
+ * order.
150
+ */
151
+ export declare function tmxLayerQuads(map: LoadedTMX, layer: TMXTileLayer, options?: TileQuadsOptions): TileQuads;