@margoengine/voxel-edit 0.0.0-stage → 1.0.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 (64) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +445 -2
  4. package/dist/animation.d.ts +50 -0
  5. package/dist/animation.js +88 -0
  6. package/dist/assist.d.ts +24 -0
  7. package/dist/assist.js +52 -0
  8. package/dist/brush-gpu.d.ts +62 -0
  9. package/dist/bytes.d.ts +55 -0
  10. package/dist/collab.d.ts +77 -0
  11. package/dist/collab.js +159 -0
  12. package/dist/edit.d.ts +30 -0
  13. package/dist/edit.js +361 -0
  14. package/dist/export.d.ts +58 -0
  15. package/dist/export.js +52 -0
  16. package/dist/file-colors-DHT5vrzW.js +55 -0
  17. package/dist/file-colors.d.ts +16 -0
  18. package/dist/format-plist.d.ts +4 -0
  19. package/dist/formats-extra.d.ts +20 -0
  20. package/dist/formats-extra.js +335 -0
  21. package/dist/formats.d.ts +96 -0
  22. package/dist/formats.js +924 -0
  23. package/dist/generate.d.ts +63 -0
  24. package/dist/generate.js +103 -0
  25. package/dist/gox.d.ts +60 -0
  26. package/dist/gpu.d.ts +74 -0
  27. package/dist/gpu.js +167 -0
  28. package/dist/grid-B2V0TGLV.js +120 -0
  29. package/dist/grid.d.ts +75 -0
  30. package/dist/history.d.ts +65 -0
  31. package/dist/history.js +75 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.js +631 -0
  34. package/dist/layout.d.ts +76 -0
  35. package/dist/library.d.ts +50 -0
  36. package/dist/library.js +89 -0
  37. package/dist/mesh.d.ts +128 -0
  38. package/dist/mesh.js +365 -0
  39. package/dist/model.d.ts +173 -0
  40. package/dist/pick.d.ts +34 -0
  41. package/dist/pick.js +122 -0
  42. package/dist/raster.d.ts +89 -0
  43. package/dist/rig.d.ts +88 -0
  44. package/dist/rig.js +216 -0
  45. package/dist/select.d.ts +50 -0
  46. package/dist/select.js +94 -0
  47. package/dist/shaders-BaY4gcm9.js +234 -0
  48. package/dist/shaders.d.ts +116 -0
  49. package/dist/shaders.js +1 -0
  50. package/dist/slices.d.ts +75 -0
  51. package/dist/smooth.d.ts +43 -0
  52. package/dist/smooth.js +212 -0
  53. package/dist/sparse.d.ts +239 -0
  54. package/dist/sparse.js +646 -0
  55. package/dist/stamp.d.ts +88 -0
  56. package/dist/vmax.d.ts +48 -0
  57. package/dist/vox-resolve.d.ts +64 -0
  58. package/dist/vox-scene.d.ts +51 -0
  59. package/dist/vox.d.ts +30 -0
  60. package/dist/vox.js +684 -0
  61. package/dist/voxelize.d.ts +70 -0
  62. package/dist/voxelize.js +249 -0
  63. package/dist/vxm.d.ts +54 -0
  64. package/package.json +130 -4
@@ -0,0 +1,335 @@
1
+ import { a as e, o as t } from "./grid-B2V0TGLV.js";
2
+ import { a as n, i as r, n as i, r as a, t as o } from "./file-colors-DHT5vrzW.js";
3
+ import { composeMatrix as s, multiplyMatrices as c } from "@margoengine/math/mat4";
4
+ import { decodePNG as l } from "@margoengine/decoders/png";
5
+ import { decodeLZFSE as u } from "@margoengine/decoders/lzfse";
6
+ import { readZipDirectory as d, readZipEntry as f } from "@margoengine/loaders/common";
7
+ //#region src/format-plist.ts
8
+ function p(e) {
9
+ let t = () => {
10
+ throw RangeError("VMAX binary plist is malformed; save the document again");
11
+ }, n = new TextDecoder(), r = new DataView(e.buffer, e.byteOffset, e.byteLength), i = e.length - 32;
12
+ (i < 8 || n.decode(e.subarray(0, 8)) !== "bplist00") && t();
13
+ let a = (n, r, i = e.length) => {
14
+ if (![
15
+ 1,
16
+ 2,
17
+ 4,
18
+ 8
19
+ ].includes(r) || n < 8 || n + r > i) return t();
20
+ let a = 0;
21
+ for (let t = 0; t < r; t++) a = a * 256 + e[n + t];
22
+ return Number.isSafeInteger(a) || t(), a;
23
+ }, o = e[i + 6], s = e[i + 7], c = a(i + 8, 8), l = a(i + 16, 8), u = a(i + 24, 8);
24
+ (!c || l >= c || u < 8 || u + c * o > i || c > e.length || ![
25
+ 1,
26
+ 2,
27
+ 4,
28
+ 8
29
+ ].includes(s)) && t();
30
+ let d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), p = (l, m) => {
31
+ if (l >= c || m > 64 || f.has(l)) return t();
32
+ if (d.has(l)) return d.get(l);
33
+ let h = a(u + l * o, o, i);
34
+ if (h < 8 || h >= u) return t();
35
+ let g = e[h++], _ = g >>> 4, v = g & 15, y, b = (e) => {
36
+ h + e > u && t();
37
+ let n = h;
38
+ return h += e, n;
39
+ }, x = () => {
40
+ if (v < 15) return v;
41
+ let n = e[b(1)];
42
+ if (n >>> 4 != 1 || (n & 15) > 3) return t();
43
+ let r = 2 ** (n & 15);
44
+ return a(b(r), r, u);
45
+ };
46
+ if (f.add(l), _ === 0) {
47
+ if (v === 0) y = null;
48
+ else if (v === 8 || v === 9) y = v === 9;
49
+ else return t();
50
+ } else if (_ === 1 || _ === 8) {
51
+ let n = _ === 8 ? v + 1 : 2 ** v, i = b(n);
52
+ if (_ === 1 && n === 8 && e[i] & 128) {
53
+ let e = r.getBigInt64(i);
54
+ if (y = Number(e), !Number.isSafeInteger(y)) return t();
55
+ } else y = a(i, n, u);
56
+ } else if (_ === 2 || _ === 3) {
57
+ let e = _ === 3 ? 8 : 2 ** v, n = b(e);
58
+ if (e !== 4 && e !== 8 || (y = e === 4 ? r.getFloat32(n) : r.getFloat64(n), !Number.isFinite(y))) return t();
59
+ } else if (_ === 4 || _ === 5 || _ === 6) {
60
+ let t = x() * (_ === 6 ? 2 : 1), r = b(t), i = e.subarray(r, r + t);
61
+ y = _ === 4 ? i : _ === 6 ? new TextDecoder("utf-16be", { fatal: !0 }).decode(i) : n.decode(i);
62
+ } else if (_ === 10 || _ === 12 || _ === 13) {
63
+ let e = x(), n = b(e * s * (_ === 13 ? 2 : 1));
64
+ if (_ === 13) {
65
+ let r = Object.create(null);
66
+ for (let i = 0; i < e; i++) {
67
+ let o = p(a(n + i * s, s, u), m + 1);
68
+ if (typeof o != "string") return t();
69
+ r[o] = p(a(n + (e + i) * s, s, u), m + 1);
70
+ }
71
+ y = r;
72
+ } else y = Array.from({ length: e }, (e, t) => p(a(n + t * s, s, u), m + 1));
73
+ } else return t();
74
+ return f.delete(l), d.set(l, y), y;
75
+ };
76
+ return p(l, 0);
77
+ }
78
+ //#endregion
79
+ //#region src/vmax.ts
80
+ var m = (e) => {
81
+ throw RangeError(`VMAX ${e}; save the complete document again`);
82
+ }, h = (e) => !e || typeof e != "object" || Array.isArray(e) || e instanceof Uint8Array ? m("expected a dictionary") : e, g = (e) => Array.isArray(e) ? e : m("expected an array"), _ = (e, t, n) => typeof e != "number" || !Number.isSafeInteger(e) || e < t || e > n ? m("integer outside its range") : e, v = (e, t) => {
83
+ if (e === void 0) return t;
84
+ let n = g(e);
85
+ return n.length !== t.length || n.some((e) => typeof e != "number" || !Number.isFinite(e)) ? m("invalid transform vector") : n;
86
+ }, y = (e) => e instanceof Uint8Array ? e : Uint8Array.from(g(e).map((e) => _(e, 0, 255))), b = (e) => {
87
+ let t = [
88
+ 0,
89
+ 0,
90
+ 0
91
+ ];
92
+ for (let n = 0; n < 10; n++) for (let r = 0; r < 3; r++) t[r] |= (e >>> 3 * n + r & 1) << n;
93
+ return t;
94
+ };
95
+ async function x(r, x = {}) {
96
+ let S = n(r, "parseVMAX"), C = x.maxBytes ?? 268435456, w = t(x), T = new o(w), E = x.signal;
97
+ if (!Number.isSafeInteger(C) || C < 1 || C > 2147483647) throw RangeError("maxBytes must be 1..2147483647; set a finite document budget");
98
+ E?.throwIfAborted();
99
+ let D = d(S, {
100
+ maxEntries: x.maxEntries,
101
+ signal: E
102
+ }), O = D.filter((e) => /(^|\/)scene\.json$/.test(e.name));
103
+ if (O.length !== 1) return m("archive must contain exactly one scene.json");
104
+ let k = O[0].name.slice(0, -10), A = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
105
+ for (let e of D) {
106
+ if (A.has(e.name)) return m("archive contains duplicate paths");
107
+ A.set(e.name, e);
108
+ }
109
+ let M = 0, N = async (e, t = !1) => {
110
+ if (E?.throwIfAborted(), !e || e.startsWith("/") || e.split(/[\\/]/).includes("..")) return m("invalid payload path");
111
+ let n = k + e;
112
+ if (j.has(n)) return j.get(n);
113
+ let r = A.get(n);
114
+ if (!r) return t ? void 0 : m(`missing payload ${e}`);
115
+ if (M + r.size > C) return m("extracted data exceeds maxBytes");
116
+ M += r.size;
117
+ let i = await f(S, r, {
118
+ maxEntryBytes: C - M + r.size,
119
+ signal: E
120
+ });
121
+ return j.set(n, i), i;
122
+ }, P = (e) => (e[0] === 98 && e[1] === 118 && (e = u(e, {
123
+ maxBytes: C - M,
124
+ signal: E
125
+ }), M += e.length), h(p(e))), F = h(JSON.parse(new TextDecoder().decode(await N("scene.json")))), I = g(F.groups ?? []), L = g(F.objects), R = /* @__PURE__ */ new Map();
126
+ if (I.length + L.length > 4096) return m(`scene exceeds ${i} nodes`);
127
+ let z = (e) => {
128
+ let t = h(e), n = t.id, r = t.pid;
129
+ if (typeof n != "string" || !n || R.has(n) || r !== void 0 && typeof r != "string") return m("invalid or duplicate node id");
130
+ let i = v(t.t_p, [
131
+ 0,
132
+ 0,
133
+ 0
134
+ ]), a = v(t.t_r, [
135
+ 0,
136
+ 1,
137
+ 0,
138
+ 0
139
+ ]), o = v(t.t_s, [
140
+ 1,
141
+ 1,
142
+ 1
143
+ ]), c = Math.hypot(a[0], a[1], a[2]), l = a[3] * .5;
144
+ if (!c && a[3] || o.some((e) => e === 0)) return m("singular node transform");
145
+ let u = c ? Math.sin(l) / c : 0, d = s(i, [
146
+ a[0] * u,
147
+ a[1] * u,
148
+ a[2] * u,
149
+ Math.cos(l)
150
+ ], o, /* @__PURE__ */ new Float64Array(16)), f = {
151
+ id: n,
152
+ ...r ? { parentId: r } : {},
153
+ name: String(t.n ?? ""),
154
+ hidden: t.hidden === !0,
155
+ matrix: d,
156
+ worldMatrix: d.slice(),
157
+ metadata: t
158
+ };
159
+ return R.set(n, f), f;
160
+ }, B = I.map(z), V = L.map(z), H = /* @__PURE__ */ new Set(), U = /* @__PURE__ */ new Set(), W = (e, t = 0) => {
161
+ if (!U.has(e.id)) {
162
+ if (H.has(e.id) || t > 64) return m("cyclic or deeply nested hierarchy");
163
+ if (H.add(e.id), e.parentId) {
164
+ let n = R.get(e.parentId);
165
+ if (!n || !B.includes(n)) return m("node parent is not a group");
166
+ W(n, t + 1), c(n.worldMatrix, e.matrix, e.worldMatrix);
167
+ }
168
+ H.delete(e.id), U.add(e.id);
169
+ }
170
+ };
171
+ for (let e of R.values()) W(e);
172
+ let G = [], K = 0;
173
+ for (let t of V) {
174
+ E?.throwIfAborted();
175
+ let n = t.metadata, r = P(await N(String(n.data))), i = _(r.v ?? 0, 0, 100), o = String(n.pal ?? "palette.png"), u = await N(o, !0), d = await N(o.replace(/\.png$/i, "") + ".settings.vmaxpsb", !0), f = d ? P(d) : void 0, p;
176
+ if (u) {
177
+ let e = l(u, { maxPixels: 256 });
178
+ if (e.width * e.height !== 256) return m("palette must contain 256 RGBA colours");
179
+ p = e.data;
180
+ } else if (f?.colors !== void 0) p = y(f.colors);
181
+ else return m(`missing colour palette ${o}`);
182
+ if (p.length !== 1024) return m("palette must contain 1024 RGBA bytes");
183
+ let x = /* @__PURE__ */ new Map(), S = (e, t, n, r) => {
184
+ let i = b(t).map((t, n) => e[n] + t);
185
+ if (i.some((e) => !Number.isInteger(e) || e < 0 || e >= 512)) return m("voxel outside supported extent");
186
+ if (!r) return;
187
+ let o = 4 * (r - 1), s = p[o + 3];
188
+ s && x.set(i[0] + 512 * (i[1] + 512 * i[2]), [
189
+ i[0],
190
+ i[1],
191
+ i[2],
192
+ a(p[o], p[o + 1], p[o + 2], s),
193
+ n
194
+ ]);
195
+ };
196
+ if (i >= 4) {
197
+ let e = /* @__PURE__ */ new Map();
198
+ for (let t of g(r.snapshots ?? [])) {
199
+ let n = h(h(t).s), r = _(h(n.id).c, 0, 4095);
200
+ e.set(r, n);
201
+ }
202
+ for (let [t, n] of e) {
203
+ let e = y(n.ds);
204
+ if (!e.length) continue;
205
+ let r = _(g(h(n.st).min)[3], 0, 32767), i = b(t).map((e) => e * 32);
206
+ if (e.length % 2 || r + e.length / 2 > 32768) return m("snapshot exceeds its chunk");
207
+ if (K += e.length / 2, K > w) return m("voxel decoding exceeds maxCells");
208
+ for (let t = 0; t < e.length; t += 2) S(i, r + t / 2, e[t], e[t + 1]);
209
+ }
210
+ } else {
211
+ let e = y(r.chunks), t = g(r.voxels), n = i === 0 ? 12 : 16, a = new DataView(e.buffer, e.byteOffset, e.byteLength);
212
+ if (e.length % n || e.length / n !== t.length) return m("legacy chunk count mismatch");
213
+ for (let e = 0; e < t.length; e++) {
214
+ let r = e * n, o = [
215
+ 0,
216
+ 4,
217
+ 8
218
+ ].map((e) => a.getInt32(r + e, !0)), s = y(t[e]), c = i > 0 && a.getInt32(r + 12, !0) === 1 ? 2 : 1;
219
+ if (s.length !== 32768 * c) return m("legacy chunk has an invalid byte count");
220
+ if (K += 32768, K > w) return m("voxel decoding exceeds maxCells");
221
+ for (let e = 0; e < 32768; e++) S(o, e, c === 2 ? s[2 * e] : 0, s[c * e + c - 1]);
222
+ }
223
+ }
224
+ let C = [
225
+ Infinity,
226
+ Infinity,
227
+ Infinity
228
+ ], D = [
229
+ -Infinity,
230
+ -Infinity,
231
+ -Infinity
232
+ ];
233
+ for (let e of x.values()) for (let t = 0; t < 3; t++) C[t] = Math.min(C[t], e[t]), D[t] = Math.max(D[t], e[t]);
234
+ x.size || (C.fill(0), D.fill(0));
235
+ let O = D.map((e, t) => e - C[t] + 1), k = v(n.center, [
236
+ 0,
237
+ 0,
238
+ 0
239
+ ]), A = C.map((e, t) => e - k[t]), j = s(A, [
240
+ 0,
241
+ 0,
242
+ 0,
243
+ 1
244
+ ], [
245
+ 1,
246
+ 1,
247
+ 1
248
+ ], /* @__PURE__ */ new Float64Array(16)), M = c(t.worldMatrix, j, /* @__PURE__ */ new Float64Array(16)), F = [
249
+ M[12],
250
+ M[13],
251
+ M[14]
252
+ ], I = T.add(O, F, t.name, "VMAX"), L = new Uint8Array(I.length);
253
+ for (let t of x.values()) {
254
+ let n = e(O, t[0] - C[0], t[1] - C[1], t[2] - C[2]);
255
+ I[n] = t[3], L[n] = t[4];
256
+ }
257
+ G.push({
258
+ node: t,
259
+ gridToWorld: M,
260
+ materialSlots: L,
261
+ ...f ? { settings: f } : {}
262
+ });
263
+ }
264
+ let q = T.finish();
265
+ return {
266
+ ...q,
267
+ models: q.models.map((e, t) => ({
268
+ ...e,
269
+ ...G[t]
270
+ })),
271
+ groups: B,
272
+ scene: F
273
+ };
274
+ }
275
+ //#endregion
276
+ //#region src/formats-extra.ts
277
+ function S(i, s = {}) {
278
+ let c = n(i, "parseKV6"), l = new DataView(c.buffer, c.byteOffset, c.byteLength);
279
+ if (c.length < 32 && r("KV6 header"), l.getUint32(0, !0) !== 1819833931) throw TypeError("parseKV6 needs a Kvxl file; pass a KV6 document");
280
+ let u = l.getUint32(4, !0), d = l.getUint32(8, !0), f = l.getUint32(12, !0), p = l.getUint32(28, !0), m = 32 + 8 * p, h = m + u * 4, g = [
281
+ u,
282
+ f,
283
+ d
284
+ ], _ = [
285
+ l.getFloat32(16, !0),
286
+ f - l.getFloat32(24, !0),
287
+ l.getFloat32(20, !0)
288
+ ];
289
+ if (h + u * d * 2 > c.length && r("KV6 columns"), _.some((e) => !Number.isFinite(e)) || f > 65536) throw RangeError("KV6 pivot or height is invalid; save the file again");
290
+ let v = new o(t(s)), y = v.add(g, _.map((e) => -e), void 0, "KV6"), b = 0;
291
+ for (let t = 0; t < u; t++) {
292
+ let n = 0;
293
+ for (let i = 0; i < d; i++) {
294
+ let o = l.getUint16(h + (t * d + i) * 2, !0);
295
+ b + o > p && r("KV6 voxel records"), n += o;
296
+ let s = -1, u = 0, m = !0;
297
+ for (let n = 0; n < o; n++, b++) {
298
+ let n = 32 + 8 * b, r = l.getUint16(n + 4, !0), o = c[n + 6], d = a(c[n + 2], c[n + 1], c[n], 255);
299
+ if (r <= s || r >= f) throw RangeError("KV6 heights are unsorted or outside the model; save the file again");
300
+ if (!m) for (let n = s + 1; n < r; n++) y[e(g, t, f - 1 - n, i)] = u;
301
+ y[e(g, t, f - 1 - r, i)] = d, s = r, u = d, m = !!(o & 32);
302
+ }
303
+ }
304
+ if (n !== l.getUint32(m + t * 4, !0)) throw RangeError("KV6 plane and column counts disagree; save the file again");
305
+ }
306
+ if (b !== p) throw RangeError("KV6 voxel count disagrees with columns; save the file again");
307
+ let x = h + u * d * 2;
308
+ if (x !== c.length && (c.length !== x + 772 || l.getUint32(x, !0) !== 1818316883)) throw RangeError("KV6 trailer is damaged; save the file again");
309
+ return {
310
+ ...v.finish(),
311
+ pivot: _
312
+ };
313
+ }
314
+ function C(i, s = {}) {
315
+ let c = n(i, "parseCUB"), l = new DataView(c.buffer, c.byteOffset, c.byteLength);
316
+ c.length < 12 && r("CUB header");
317
+ let u = l.getUint32(0, !0), d = l.getUint32(4, !0), f = l.getUint32(8, !0), p = [
318
+ u,
319
+ d,
320
+ f
321
+ ], m = new o(t(s));
322
+ if (12 + u * d * f * 3 !== c.length) throw RangeError("CUB size does not match its RGB data; pass the complete file");
323
+ let h = m.add(p, [
324
+ 0,
325
+ 0,
326
+ 0
327
+ ], void 0, "CUB");
328
+ for (let t = 0; t < f; t++) for (let n = 0; n < d; n++) for (let r = 0; r < u; r++) {
329
+ let i = 12 + 3 * (r + u * (n + d * t)), o = c[i], s = c[i + 1], l = c[i + 2];
330
+ (o || s || l) && (h[e(p, r, n, t)] = a(o, s, l, 255));
331
+ }
332
+ return m.finish();
333
+ }
334
+ //#endregion
335
+ export { C as parseCUB, S as parseKV6, x as parseVMAX };
@@ -0,0 +1,96 @@
1
+ import type { Vec3 } from '@margoengine/math';
2
+ import { type GridLimits, type VoxelGrid } from './grid.js';
3
+ export { type GOXFile, type GOXLayer, type GOXMaterial, type GOXWriteModel, type GOXWriteOptions, parseGOX, writeGOX, } from './gox.js';
4
+ export { parseVXM, type VXMFile, type VXMModel, type VXMWriteModel, type VXMWriteOptions, writeVXM } from './vxm.js';
5
+ /** One model of a voxel file. */
6
+ export interface VoxelFileModel {
7
+ /** The matrix name, when the format has one. */
8
+ name?: string;
9
+ /** Where the model's cell (0, 0, 0) sits, in cells, Y up. [0, 0, 0] where the format has no positions. */
10
+ position: Vec3;
11
+ /** The cells; values index {@link VoxelFile.palette}. */
12
+ grid: VoxelGrid;
13
+ }
14
+ /** What the readers return. */
15
+ export interface VoxelFile {
16
+ /** Models in file order. */
17
+ models: VoxelFileModel[];
18
+ /** 256 RGBA8 colours, index i at `4 * i` as in `parseVox`; index 0 is air and stays 0. */
19
+ palette: Uint8Array;
20
+ /** True when a true-colour file held over 255 colours, so each channel lost low bits until 255 were left. */
21
+ colorsReduced: boolean;
22
+ }
23
+ /** A binvox file: one model, with the placement its header records. */
24
+ export interface BinvoxFile extends VoxelFile {
25
+ /** Header `translate`: where the voxel cube starts in the source mesh's space. */
26
+ translate: Vec3;
27
+ /** Header `scale`: the voxel cube's side in the source mesh's space. */
28
+ scale: number;
29
+ }
30
+ /** A KVX file: one model (the largest mip), with its pivot. */
31
+ export interface KVXFile extends VoxelFile {
32
+ /** The pivot in grid cells, Y up; fractional cells are kept. */
33
+ pivot: Vec3;
34
+ }
35
+ /** Options of {@link parseVXL}. */
36
+ export interface VXLOptions extends GridLimits {
37
+ /** Cells along x, y and z (z pointing down in the file) of a VXL without a header. Default [512, 512, 64]. */
38
+ size?: Vec3;
39
+ }
40
+ /** Options of {@link writeQB}. */
41
+ export interface QBWriteOptions {
42
+ /** Byte order of each colour. Default 'rgba'. */
43
+ colorFormat?: 'rgba' | 'bgra';
44
+ /** How the file's z runs. 'right' keeps z as the grid has it; 'left' mirrors it. Default 'right'. */
45
+ zAxis?: 'left' | 'right';
46
+ /** Run-length encode the cells. Default false. */
47
+ compressed?: boolean;
48
+ }
49
+ /**
50
+ * Reads a Qubicle `.qb`: every matrix, RGBA or BGRA, compressed or not, in either z orientation, with the file's
51
+ * mirror undone so the grids are right-handed. A cell with alpha 0 is air.
52
+ *
53
+ * @throws RangeError on a cut-off or malformed file, or past `maxCells` across all matrices.
54
+ */
55
+ export declare function parseQB(bytes: Uint8Array | ArrayBuffer, limits?: GridLimits): VoxelFile;
56
+ /**
57
+ * Writes a Qubicle `.qb` of version 1.1 with a plain alpha (no visibility mask): filled cells opaque or at their
58
+ * palette alpha, air 0. Takes the shape {@link parseQB} returns.
59
+ *
60
+ * @throws RangeError when a palette colour has alpha 0 or a name is over 255 bytes.
61
+ */
62
+ export declare function writeQB(models: VoxelFileModel | readonly VoxelFileModel[], palette: Uint8Array, options?: QBWriteOptions): Uint8Array;
63
+ /**
64
+ * Reads a Qubicle Exchange `.qef` text file: one model; a voxel with mask 0 is hidden and left out.
65
+ *
66
+ * @throws RangeError on a damaged file or past `maxCells`; TypeError when it is not a QEF.
67
+ */
68
+ export declare function parseQEF(input: string | Uint8Array | ArrayBuffer, limits?: GridLimits): VoxelFile;
69
+ /**
70
+ * Writes one grid as a Qubicle Exchange `.qef`: the colours the grid uses and one line per filled cell, every side
71
+ * marked visible. The format holds no alpha.
72
+ */
73
+ export declare function writeQEF(grid: VoxelGrid, palette: Uint8Array): string;
74
+ /**
75
+ * Reads a `binvox` file (Patrick Min's format): one model with its header placement, each voxel's byte value as its
76
+ * palette index, white: 1 in a version 1 file, 1 to 255 in a version 2 file (binvox_merge). The file's y is vertical,
77
+ * as the grid's.
78
+ *
79
+ * @throws TypeError when it is not a binvox; RangeError on a damaged file or past `maxCells`.
80
+ */
81
+ export declare function parseBinvox(bytes: Uint8Array | ArrayBuffer, limits?: GridLimits): BinvoxFile;
82
+ /**
83
+ * Reads a KVX (Ken Silverman's slab format; the first, largest mip): x stays x, the file's y becomes z, and its
84
+ * downward z becomes Y up. File colour k is grid index k + 1; colour 255, the format's transparent one, is air.
85
+ *
86
+ * @throws RangeError on a damaged file or past `maxCells`.
87
+ */
88
+ export declare function parseKVX(bytes: Uint8Array | ArrayBuffer, limits?: GridLimits): KVXFile;
89
+ /**
90
+ * Reads a VXL map (the Voxlap slab format, with its header or as a bare 512 x 512 x 64 column list): x stays x, the
91
+ * file's y becomes z, and its downward z becomes Y up. Solid cells the file gives no colour, deep inside, take the
92
+ * last colour above them in their column.
93
+ *
94
+ * @throws RangeError on a damaged file, on data that does not fit `size`, or past `maxCells`.
95
+ */
96
+ export declare function parseVXL(bytes: Uint8Array | ArrayBuffer, options?: VXLOptions): VoxelFile;