@margoengine/points 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 (52) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +794 -3
  4. package/dist/attributes-DNc-1pdr.js +256 -0
  5. package/dist/attributes.d.ts +48 -0
  6. package/dist/clip.d.ts +55 -0
  7. package/dist/clip.js +122 -0
  8. package/dist/cloud-B4O_G-Df.js +545 -0
  9. package/dist/cloud.d.ts +155 -0
  10. package/dist/color.d.ts +1 -0
  11. package/dist/copc.d.ts +55 -0
  12. package/dist/copc.js +130 -0
  13. package/dist/depth-video.d.ts +98 -0
  14. package/dist/depth-video.js +164 -0
  15. package/dist/e57.d.ts +163 -0
  16. package/dist/e57.js +624 -0
  17. package/dist/frame.d.ts +9 -0
  18. package/dist/index.d.ts +16 -0
  19. package/dist/index.js +1246 -0
  20. package/dist/las.d.ts +213 -0
  21. package/dist/las.js +500 -0
  22. package/dist/laz.d.ts +50 -0
  23. package/dist/laz.js +1025 -0
  24. package/dist/material.d.ts +167 -0
  25. package/dist/math.d.ts +103 -0
  26. package/dist/octree.d.ts +182 -0
  27. package/dist/octree.js +360 -0
  28. package/dist/pick.d.ts +76 -0
  29. package/dist/pick.js +192 -0
  30. package/dist/plugin.d.ts +235 -0
  31. package/dist/potree.d.ts +70 -0
  32. package/dist/potree.js +451 -0
  33. package/dist/range-BQuJAjUM.js +23 -0
  34. package/dist/range.d.ts +4 -0
  35. package/dist/screen-door-CALlYs39.js +7 -0
  36. package/dist/shaders-Deu8H36P.js +278 -0
  37. package/dist/shaders.d.ts +52 -0
  38. package/dist/shared/fog.d.ts +33 -0
  39. package/dist/shared/pass.d.ts +53 -0
  40. package/dist/shared/selection-mask.d.ts +52 -0
  41. package/dist/shared/style-expression.d.ts +18 -0
  42. package/dist/sprites.d.ts +78 -0
  43. package/dist/storage-limit.d.ts +6 -0
  44. package/dist/style.d.ts +124 -0
  45. package/dist/style.js +708 -0
  46. package/dist/surfels.d.ts +95 -0
  47. package/dist/surfels.js +538 -0
  48. package/dist/survey-DToZwkJv.js +46 -0
  49. package/dist/survey.d.ts +10 -0
  50. package/dist/tier-BcFbLPVT.js +91 -0
  51. package/dist/tier.d.ts +6 -0
  52. package/package.json +96 -6
package/dist/potree.js ADDED
@@ -0,0 +1,451 @@
1
+ import { i as e, u as t } from "./attributes-DNc-1pdr.js";
2
+ import { n, t as r } from "./range-BQuJAjUM.js";
3
+ import { MargoError as i } from "@margoengine/math/errors";
4
+ //#region src/potree.ts
5
+ var a = 22, o = {
6
+ POSITION_CARTESIAN: 12,
7
+ COLOR_PACKED: 4,
8
+ RGBA_PACKED: 4,
9
+ INTENSITY: 2,
10
+ CLASSIFICATION: 1,
11
+ RETURN_NUMBER: 1,
12
+ NUMBER_OF_RETURNS: 1,
13
+ SOURCE_ID: 2,
14
+ GPS_TIME: 8,
15
+ NORMAL: 12,
16
+ NORMAL_FLOATS: 12,
17
+ NORMAL_SPHEREMAPPED: 2,
18
+ NORMAL_OCT16: 2
19
+ }, s = {
20
+ INTENSITY: ["uint16", 1],
21
+ CLASSIFICATION: ["uint8", 1],
22
+ RETURN_NUMBER: ["uint8", 1],
23
+ NUMBER_OF_RETURNS: ["uint8", 1],
24
+ SOURCE_ID: ["uint16", 1],
25
+ GPS_TIME: ["double", 1],
26
+ NORMAL: ["float", 3],
27
+ NORMAL_FLOATS: ["float", 3]
28
+ }, c = {
29
+ int8: Int8Array,
30
+ uint8: Uint8Array,
31
+ int16: Int16Array,
32
+ uint16: Uint16Array,
33
+ int32: Int32Array,
34
+ uint32: Uint32Array,
35
+ float: Float32Array,
36
+ double: Float64Array
37
+ }, l = (e) => e.toLowerCase().replace(/[^a-z0-9]+/g, "_"), u = (e) => e >> 2 & 1 | e & 2 | (e & 1) << 2;
38
+ function d(e, t) {
39
+ let n = u(t), r = e.bounds, i = /* @__PURE__ */ new Float64Array(6);
40
+ for (let e = 0; e < 3; e++) {
41
+ let t = (r[e + 3] - r[e]) / 2, a = n >> e & 1;
42
+ i[e] = r[e] + a * t, i[e + 3] = i[e] + t;
43
+ }
44
+ let a = {
45
+ id: e.id + n,
46
+ level: e.level + 1,
47
+ bounds: i,
48
+ spacing: e.spacing / 2,
49
+ count: 0,
50
+ parent: e,
51
+ children: Array(8).fill(null),
52
+ name: e.name + t,
53
+ offset: 0,
54
+ bytes: 0
55
+ };
56
+ return e.children[n] = a, a;
57
+ }
58
+ function f(e, t, n) {
59
+ return {
60
+ id: "r",
61
+ level: 0,
62
+ bounds: Float64Array.of(e[0], e[1], e[2], t[0], t[1], t[2]),
63
+ spacing: n,
64
+ count: 0,
65
+ parent: null,
66
+ children: Array(8).fill(null),
67
+ name: "r",
68
+ offset: 0,
69
+ bytes: 0
70
+ };
71
+ }
72
+ var p = (e, t) => {
73
+ e.count = t;
74
+ };
75
+ function m(e) {
76
+ for (let t = 0; t < 8; t++) {
77
+ let n = e.children[t];
78
+ n && (m(n), !n.count && !n.page && !n.unsized && !n.children.some(Boolean) && (e.children[t] = null));
79
+ }
80
+ }
81
+ async function h(e, t, n, r, i) {
82
+ let o = await r(t, n, i);
83
+ if (!o.byteLength || o.byteLength % a) throw RangeError("Potree hierarchy chunk is not whole records; the file is corrupt");
84
+ let s = new DataView(o.buffer, o.byteOffset, o.byteLength), c = [e];
85
+ for (let e = 0, t = 0; t < o.byteLength; e++, t += a) {
86
+ let n = c[e];
87
+ if (!n) throw RangeError("Potree hierarchy chunk holds more records than nodes; the file is corrupt");
88
+ let i = s.getUint8(t), a = s.getUint8(t + 1), o = Number(s.getBigUint64(t + 6, !0)), l = Number(s.getBigUint64(t + 14, !0));
89
+ if (p(n, s.getUint32(t + 2, !0)), i === 2) {
90
+ if (!e) throw RangeError("Potree hierarchy chunk starts with a proxy record; the file is corrupt");
91
+ n.page = (e) => h(n, o, l, r, e);
92
+ } else {
93
+ if (i > 2) throw RangeError(`Potree hierarchy holds node type ${i}; the file is corrupt`);
94
+ n.offset = o, n.bytes = l;
95
+ for (let e = 0; e < 8; e++) a & 1 << e && c.push(d(n, e));
96
+ }
97
+ }
98
+ }
99
+ async function g(e, t, n, r) {
100
+ let i = await n(e, r), a = new DataView(i.buffer, i.byteOffset, i.byteLength), o = [e];
101
+ if (!i.byteLength || i.byteLength % 5) throw RangeError("Potree .hrc file is not whole records; the file is corrupt");
102
+ let s = 0;
103
+ for (let r = 0; r < i.byteLength; s++, r += 5) {
104
+ let i = o[s];
105
+ if (!i) throw RangeError("Potree .hrc file holds more records than nodes; the file is corrupt");
106
+ let c = a.getUint8(r);
107
+ if (p(i, a.getUint32(r + 1, !0)), !c) i.unsized = !i.count;
108
+ else if (i.level - e.level >= t) i.page = (e) => g(i, t, n, e);
109
+ else for (let e = 0; e < 8; e++) c & 1 << e && o.push(d(i, e));
110
+ }
111
+ if (s !== o.length) throw RangeError("Potree .hrc file is cut short; the file is corrupt");
112
+ }
113
+ async function _(e, t) {
114
+ let { page: n } = e;
115
+ n && (await n(t), e.page === n && (e.page = void 0), m(e));
116
+ }
117
+ async function v(e, t) {
118
+ for (;;) {
119
+ let n = [], r = [e];
120
+ for (; r.length;) {
121
+ let e = r.pop();
122
+ e.page && n.push(e);
123
+ for (let t of e.children) t && r.push(t);
124
+ }
125
+ if (!n.length) return;
126
+ await Promise.all(n.map((e) => _(e, t)));
127
+ }
128
+ }
129
+ var y = (e, t, n) => {
130
+ if (!Array.isArray(e) || e.length < t || !e.every(Number.isFinite)) throw TypeError(`Potree ${n} is missing or not ${t} numbers; the metadata is corrupt`);
131
+ return e;
132
+ };
133
+ function b(e, t, n) {
134
+ let r = {
135
+ stride: 0,
136
+ position: -1,
137
+ color: -1,
138
+ colorSize: 0,
139
+ scale: t,
140
+ fields: []
141
+ };
142
+ for (let { name: t, size: i, type: a, numElements: o } of e) t === "position" || t === "POSITION_CARTESIAN" ? r.position = r.stride : t === "rgb" || t === "rgba" || t === "COLOR_PACKED" || t === "RGBA_PACKED" ? (r.color = r.stride, r.colorSize = i) : a && c[a] && n(l(t)) && r.fields.push({
143
+ key: l(t),
144
+ at: r.stride,
145
+ type: a,
146
+ count: o ?? 1
147
+ }), r.stride += i;
148
+ if (r.position < 0) throw TypeError("Potree attributes hold no position; the metadata is corrupt");
149
+ return r;
150
+ }
151
+ function x(n, r) {
152
+ let i = n.colorBy ?? "rgb";
153
+ return i === "rgb" ? (e) => e : (n) => {
154
+ let a = n.attributes?.[i];
155
+ if (!a) return n;
156
+ let o = i === "classification" ? e(a) : t(a, r ? {
157
+ min: r[0],
158
+ max: r[1]
159
+ } : {});
160
+ return {
161
+ ...n,
162
+ colors: o,
163
+ colorComponents: 4
164
+ };
165
+ };
166
+ }
167
+ var S = class e {
168
+ constructor(e) {
169
+ this.root = e.root, this.version = e.version, this.points = e.points, this.origin = e.origin, this.fetchNode = e.fetchNode;
170
+ }
171
+ static async open(t, r = {}) {
172
+ let i = r.fetch ?? globalThis.fetch, { signal: a } = r, o = String(t), s = /(metadata\.json|cloud\.js)(\?.*)?$/.exec(o), c = s ? o.slice(0, s.index) : o.endsWith("/") ? o : `${o}/`, l = (e, t) => {
173
+ try {
174
+ return JSON.parse(new TextDecoder().decode(e));
175
+ } catch {
176
+ throw TypeError(`${c + t} is not JSON; pass a Potree folder, metadata.json or cloud.js`);
177
+ }
178
+ }, u = async (e) => l(await n(i, c + e, a), e), d = async (t) => (r.hierarchy === "eager" && await v(t.root, a), new e(t));
179
+ if (s?.[1] === "cloud.js") return d(await D(c, await u("cloud.js"), i, r));
180
+ if (s) return d(await T(c, await u("metadata.json"), i, r));
181
+ let f = await i(`${c}metadata.json`, { signal: a });
182
+ return f.ok ? d(await T(c, l(new Uint8Array(await f.arrayBuffer()), "metadata.json"), i, r)) : d(await D(c, await u("cloud.js"), i, r));
183
+ }
184
+ async expand(e, t) {
185
+ await _(e, t);
186
+ }
187
+ async load(e, t) {
188
+ return await _(e, t), !e.count && !e.unsized ? { positions: /* @__PURE__ */ new Float32Array() } : this.fetchNode(e, t);
189
+ }
190
+ };
191
+ function C(e, t) {
192
+ let n = [
193
+ 0,
194
+ 1,
195
+ 2
196
+ ].map((n) => (e[n] + t[n]) / 2);
197
+ return {
198
+ origin: n,
199
+ min: [
200
+ 0,
201
+ 1,
202
+ 2
203
+ ].map((t) => e[t] - n[t]),
204
+ max: [
205
+ 0,
206
+ 1,
207
+ 2
208
+ ].map((e) => t[e] - n[e])
209
+ };
210
+ }
211
+ var w = (e) => {
212
+ let t = e.attributes ?? ["intensity", "classification"], n = e.colorBy;
213
+ return (e) => t === "all" || t.includes(e) || e === n;
214
+ };
215
+ async function T(e, t, n, a) {
216
+ let o = String(t.version), { signal: s } = a;
217
+ if (!o.startsWith("2.")) throw new i("unsupported", `Potree version ${o} in metadata.json; this reader takes 2.x`);
218
+ let c = t.encoding ?? "DEFAULT";
219
+ if (c !== "DEFAULT" && c !== "BROTLI") throw new i("unsupported", `Potree encoding ${String(c)} is not read; it takes DEFAULT and BROTLI`);
220
+ let u = t.boundingBox, { origin: d, min: p, max: g } = C(y(u?.min, 3, "boundingBox.min"), y(u?.max, 3, "boundingBox.max")), _ = y(typeof t.scale == "number" ? [
221
+ t.scale,
222
+ t.scale,
223
+ t.scale
224
+ ] : t.scale, 3, "scale"), v = y(t.offset, 3, "offset"), S = t.hierarchy, T = t.attributes, E = S?.firstChunkSize;
225
+ if (typeof E != "number" || !Array.isArray(T)) throw TypeError("Potree metadata.json has no hierarchy or attributes; pass a Potree 2.0 metadata.json");
226
+ let D = w(a), O = b(T, _, D), k = T.find((e) => e.name === "rgb" || e.name === "rgba"), A = k?.max ? Math.max(...k.max) > 255 : void 0, j = f(p, g, Number(t.spacing) || 1), M = [
227
+ v[0] - d[0],
228
+ v[1] - d[1],
229
+ v[2] - d[2]
230
+ ], I = T.find((e) => l(e.name) === "intensity"), L = x(a, I?.min && I.max && I.max[0] > I.min[0] ? [I.min[0], I.max[0]] : void 0);
231
+ await h(j, 0, E, (t, i, a) => r(n, `${e}hierarchy.bin`, t, i, a ?? s), s), m(j);
232
+ let R = {
233
+ root: j,
234
+ version: o,
235
+ points: Number(t.points) || 0,
236
+ origin: d
237
+ };
238
+ if (c === "BROTLI") {
239
+ let t = a.brotli ?? (await import("@margoengine/decoders/brotli")).decodeBrotli, i = N(T, D);
240
+ return {
241
+ ...R,
242
+ fetchNode: async (a, o) => {
243
+ let s = await r(n, `${e}octree.bin`, a.offset, a.bytes, o);
244
+ return L(P(t(s), a, i, O.scale, M, A));
245
+ }
246
+ };
247
+ }
248
+ return {
249
+ ...R,
250
+ fetchNode: async (t, i) => {
251
+ let a = await r(n, `${e}octree.bin`, t.offset, t.bytes, i);
252
+ return L(F(a, t, O, M, A));
253
+ }
254
+ };
255
+ }
256
+ function E(e, t) {
257
+ let n = /* @__PURE__ */ new Map([["r", e]]);
258
+ for (let r of t) {
259
+ let [t, i] = r;
260
+ if (typeof t != "string" || !/^r[0-7]*$/.test(t) || typeof i != "number") throw TypeError("Potree cloud.js hierarchy holds an entry that is not a node name and count; it is corrupt");
261
+ if (t === "r") {
262
+ p(e, i);
263
+ continue;
264
+ }
265
+ let a = n.get(t.slice(0, -1));
266
+ if (!a) throw RangeError(`Potree cloud.js hierarchy lists ${t} before its parent; it is corrupt`);
267
+ let o = d(a, Number(t.at(-1)));
268
+ p(o, i), n.set(t, o);
269
+ }
270
+ }
271
+ async function D(e, t, r, a) {
272
+ let { signal: c, parseLAS: l, laz: u } = a, d = String(t.version), [p, h] = d.split(".").map(Number);
273
+ if (p !== 1 || !(h >= 4)) throw new i("unsupported", `Potree version ${d} in cloud.js; this reader takes 1.4 to 1.8 and 2.x`);
274
+ let _ = t.boundingBox, { origin: v, min: S, max: T } = C(y([
275
+ _?.lx,
276
+ _?.ly,
277
+ _?.lz
278
+ ], 3, "boundingBox"), y([
279
+ _?.ux,
280
+ _?.uy,
281
+ _?.uz
282
+ ], 3, "boundingBox")), D = Array.isArray(t.hierarchy) ? t.hierarchy : void 0, A = Number(t.hierarchyStepSize), j = `${e}${String(t.octreeDir ?? "data")}/`, M = t.pointAttributes, N = Number(t.scale);
283
+ if (!D && !(A >= 1) || !(N > 0)) throw TypeError("Potree cloud.js has no hierarchy, hierarchyStepSize or scale; it is corrupt");
284
+ let P = (e) => {
285
+ if (D) return j + e.name;
286
+ let t = e.name.slice(1), n = `${j}r/`;
287
+ for (let e = 0; e + A <= t.length; e += A) n += `${t.slice(e, e + A)}/`;
288
+ return n + e.name;
289
+ }, I = f(S, T, Number(t.spacing) || 1), L = x(a);
290
+ D ? E(I, D) : await g(I, A, (e, t) => n(r, `${P(e)}.hrc`, t ?? c), c), m(I);
291
+ let R = {
292
+ root: I,
293
+ version: d,
294
+ points: Number(t.points) || 0,
295
+ origin: v
296
+ }, z = w(a);
297
+ if (M === "LAS" || M === "LAZ") {
298
+ let e = M === "LAZ";
299
+ return {
300
+ ...R,
301
+ fetchNode: async (t, i) => {
302
+ let a = await n(r, `${P(t)}.${e ? "laz" : "las"}`, i), o = await (l ?? (await import("./las.js")).parseLAS)(a, {
303
+ origin: v,
304
+ laz: u,
305
+ signal: i
306
+ }), s = {};
307
+ return O(t, o.positions.length / 3), z("intensity") && (s.intensity = o.intensity), z("classification") && (s.classification = o.classification), L({
308
+ positions: o.positions,
309
+ ...k(o.rgb),
310
+ attributes: s
311
+ });
312
+ }
313
+ };
314
+ }
315
+ if (!Array.isArray(M)) throw TypeError("Potree cloud.js has no pointAttributes; it is corrupt");
316
+ let B = b(M.map((e) => {
317
+ let t = o[e];
318
+ if (!t) throw new i("unsupported", `Potree point attribute ${e} is not read; convert the folder without it`);
319
+ let [n, r] = s[e] ?? [];
320
+ return {
321
+ name: e,
322
+ size: t,
323
+ type: n,
324
+ numElements: r
325
+ };
326
+ }), [
327
+ N,
328
+ N,
329
+ N
330
+ ], z);
331
+ return {
332
+ ...R,
333
+ fetchNode: async (e, t) => {
334
+ let i = await n(r, `${P(e)}.bin`, t);
335
+ return e.unsized && O(e, Math.floor(i.byteLength / B.stride)), L(F(i, e, B, [
336
+ e.bounds[0],
337
+ e.bounds[1],
338
+ e.bounds[2]
339
+ ], void 0, !0));
340
+ }
341
+ };
342
+ }
343
+ function O(e, t) {
344
+ e.unsized &&= (p(e, t), !1);
345
+ }
346
+ function k(e) {
347
+ if (!e) return {};
348
+ let t = new Uint8Array(e.length), n = !1;
349
+ for (let t = 0; t < e.length && !n; t++) n = e[t] > 255;
350
+ for (let r = 0; r < e.length; r++) t[r] = n ? e[r] >> 8 : e[r];
351
+ return {
352
+ colors: t,
353
+ colorComponents: 3
354
+ };
355
+ }
356
+ function A(e, t, n, r) {
357
+ let { at: i, type: a, count: o } = r, s = new c[a](t * o), l = s.BYTES_PER_ELEMENT, u = a === "int8" ? (t) => e.getInt8(t) : a === "uint8" ? (t) => e.getUint8(t) : a === "int16" ? (t) => e.getInt16(t, !0) : a === "uint16" ? (t) => e.getUint16(t, !0) : a === "int32" ? (t) => e.getInt32(t, !0) : a === "uint32" ? (t) => e.getUint32(t, !0) : a === "float" ? (t) => e.getFloat32(t, !0) : (t) => e.getFloat64(t, !0);
358
+ for (let e = 0; e < t; e++) for (let t = 0; t < o; t++) s[e * o + t] = u(i + e * n + t * l);
359
+ return s;
360
+ }
361
+ function j(e) {
362
+ let t = e & 2396745;
363
+ return t = (t | t >>> 2) & 798915, t = (t | t >>> 4) & 61455, (t | t >>> 8) & 255;
364
+ }
365
+ function M(e, t, n) {
366
+ let r = e & 16777215, i = e >>> 24 | (t & 65535) << 8;
367
+ return j(r >>> n) | j(i >>> n) << 8;
368
+ }
369
+ function N(e, t) {
370
+ let n = {
371
+ perPoint: 0,
372
+ color: -1,
373
+ fields: []
374
+ };
375
+ for (let { name: r, size: i, type: a, numElements: o } of e) {
376
+ let e = l(r);
377
+ r === "position" ? n.perPoint += 16 : r === "rgb" ? (n.color = n.perPoint, n.perPoint += 8) : (a && c[a] && t(e) && n.fields.push({
378
+ field: {
379
+ key: e,
380
+ at: 0,
381
+ type: a,
382
+ count: o ?? 1
383
+ },
384
+ size: i,
385
+ before: n.perPoint
386
+ }), n.perPoint += i);
387
+ }
388
+ return n;
389
+ }
390
+ function P(e, t, n, r, i, a) {
391
+ let o = t.count;
392
+ if (e.byteLength !== o * n.perPoint) throw RangeError(`Potree node ${t.id} holds ${e.byteLength} bytes for ${o} points; the file is corrupt`);
393
+ let s = new DataView(e.buffer, e.byteOffset, e.byteLength), c = new Float32Array(o * 3);
394
+ for (let e = 0, t = 0; e < o; e++, t += 16) {
395
+ let n = s.getUint32(t, !0), a = s.getUint32(t + 4, !0), o = s.getUint32(t + 8, !0), l = s.getUint32(t + 12, !0);
396
+ for (let t = 0; t < 3; t++) {
397
+ let s = M(n, a, t) << 16 | M(o, l, t);
398
+ c[e * 3 + t] = s * r[t] + i[t];
399
+ }
400
+ }
401
+ let l = { positions: c };
402
+ if (n.color >= 0) {
403
+ let e = new Uint8Array(o * 3), t = new Uint16Array(o * 3), r = n.color * o, i = a;
404
+ for (let e = 0; e < o; e++) {
405
+ let n = s.getUint32(r + e * 8, !0), a = s.getUint32(r + e * 8 + 4, !0);
406
+ for (let r = 0; r < 3; r++) t[e * 3 + r] = M(n, a, r), i === void 0 && t[e * 3 + r] > 255 && (i = !0);
407
+ }
408
+ for (let n = 0; n < o * 3; n++) e[n] = i ? t[n] >> 8 : t[n];
409
+ l.colors = e, l.colorComponents = 3;
410
+ }
411
+ if (n.fields.length) {
412
+ l.attributes = {};
413
+ for (let { field: e, size: t, before: r } of n.fields) l.attributes[e.key] = A(s, o, t, {
414
+ ...e,
415
+ at: r * o
416
+ });
417
+ }
418
+ return l;
419
+ }
420
+ function F(e, t, n, r, i, a = !1) {
421
+ let o = t.count, { stride: s, position: c, color: l, colorSize: u, scale: d, fields: f } = n;
422
+ if (e.byteLength < o * s) throw RangeError(`Potree node ${t.id} holds ${e.byteLength} bytes for ${o} points; the file is cut short`);
423
+ let p = new DataView(e.buffer, e.byteOffset, e.byteLength), m = new Float32Array(o * 3);
424
+ for (let e = 0; e < o; e++) for (let t = 0; t < 3; t++) {
425
+ let n = e * s + c + t * 4, i = a ? p.getUint32(n, !0) : p.getInt32(n, !0);
426
+ m[e * 3 + t] = i * d[t] + r[t];
427
+ }
428
+ let h = {};
429
+ for (let e of f) h[e.key] = A(p, o, s, e);
430
+ if (l < 0) return {
431
+ positions: m,
432
+ attributes: h
433
+ };
434
+ let g = new Uint8Array(o * 3);
435
+ if (u >= 6) {
436
+ let e = i;
437
+ for (let t = 0; t < o && e === void 0; t++) for (let n = 0; n < 3; n++) p.getUint16(t * s + l + n * 2, !0) > 255 && (e = !0);
438
+ for (let t = 0; t < o; t++) for (let n = 0; n < 3; n++) {
439
+ let r = p.getUint16(t * s + l + n * 2, !0);
440
+ g[t * 3 + n] = e ? r >> 8 : r;
441
+ }
442
+ } else for (let e = 0; e < o; e++) for (let t = 0; t < 3; t++) g[e * 3 + t] = p.getUint8(e * s + l + t);
443
+ return {
444
+ positions: m,
445
+ colors: g,
446
+ colorComponents: 3,
447
+ attributes: h
448
+ };
449
+ }
450
+ //#endregion
451
+ export { S as PotreeSource, l as attributeKey };
@@ -0,0 +1,23 @@
1
+ import { MargoError as e } from "@margoengine/math/errors";
2
+ //#region src/range.ts
3
+ async function t(t, n, r) {
4
+ r.signal?.throwIfAborted();
5
+ let i = await t(n, r);
6
+ if (!i.ok) throw new e("failed", `GET ${n} answered ${i.status}; check the URL and that the server allows it`);
7
+ return {
8
+ body: new Uint8Array(await i.arrayBuffer()),
9
+ status: i.status
10
+ };
11
+ }
12
+ async function n(e, n, r, i, a) {
13
+ let { body: o, status: s } = await t(e, n, {
14
+ signal: a,
15
+ headers: { Range: `bytes=${r}-${r + i - 1}` }
16
+ });
17
+ return s === 206 ? o : o.subarray(r, r + i);
18
+ }
19
+ async function r(e, n, r) {
20
+ return (await t(e, n, { signal: r })).body;
21
+ }
22
+ //#endregion
23
+ export { r as n, n as t };
@@ -0,0 +1,4 @@
1
+ /** `bytes` bytes from `at`: the answered part, or the part cut out of a whole file when the server ignored `Range`. */
2
+ export declare function readRange(fetcher: typeof fetch, url: string | URL, at: number, bytes: number, signal?: AbortSignal): Promise<Uint8Array>;
3
+ /** A whole file. */
4
+ export declare function readWhole(fetcher: typeof fetch, url: string | URL, signal?: AbortSignal): Promise<Uint8Array>;
@@ -0,0 +1,7 @@
1
+ //#region ../shared/screen-door.js
2
+ function e(e) {
3
+ if (e.length !== 2 || !e.every(Number.isFinite) || e[0] < 0 || e[1] > 1 || e[0] > e[1]) throw RangeError("Dither fade needs 0 <= lower <= upper <= 1; correct the coverage interval");
4
+ }
5
+ var t = "fn margoDitherRank(p:vec2f)->u32 {\n let x=u32(p.x)&3u;let y=u32(p.y)&3u;\n return 4u*(2u*((x&1u)^(y&1u))+(y&1u))+2u*(((x>>1u)&1u)^((y>>1u)&1u))+((y>>1u)&1u);\n}";
6
+ //#endregion
7
+ export { t as n, e as t };