@margoengine/points 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 (62) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +876 -2
  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-write.d.ts +95 -0
  12. package/dist/copc-write.js +318 -0
  13. package/dist/copc.d.ts +55 -0
  14. package/dist/copc.js +127 -0
  15. package/dist/depth-video.d.ts +98 -0
  16. package/dist/depth-video.js +164 -0
  17. package/dist/e57.d.ts +163 -0
  18. package/dist/e57.js +624 -0
  19. package/dist/frame.d.ts +14 -0
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.js +1246 -0
  22. package/dist/las.d.ts +213 -0
  23. package/dist/las.js +500 -0
  24. package/dist/laz-encode-CHXgHra_.js +446 -0
  25. package/dist/laz-encode.d.ts +14 -0
  26. package/dist/laz-model-DCphHLqH.js +385 -0
  27. package/dist/laz-model.d.ts +47 -0
  28. package/dist/laz-write.d.ts +46 -0
  29. package/dist/laz-write.js +75 -0
  30. package/dist/laz.d.ts +50 -0
  31. package/dist/laz.js +645 -0
  32. package/dist/material.d.ts +167 -0
  33. package/dist/math.d.ts +103 -0
  34. package/dist/octree.d.ts +182 -0
  35. package/dist/octree.js +360 -0
  36. package/dist/pick.d.ts +76 -0
  37. package/dist/pick.js +192 -0
  38. package/dist/plugin.d.ts +235 -0
  39. package/dist/potree-las-RC8sjbYU.js +1 -0
  40. package/dist/potree-las.d.ts +1 -0
  41. package/dist/potree.d.ts +70 -0
  42. package/dist/potree.js +451 -0
  43. package/dist/range-BQuJAjUM.js +23 -0
  44. package/dist/range.d.ts +4 -0
  45. package/dist/screen-door-CALlYs39.js +7 -0
  46. package/dist/shaders-DCnbvb0-.js +282 -0
  47. package/dist/shaders.d.ts +52 -0
  48. package/dist/shared/fog.d.ts +33 -0
  49. package/dist/shared/pass.d.ts +53 -0
  50. package/dist/shared/selection-mask.d.ts +52 -0
  51. package/dist/shared/style-expression.d.ts +18 -0
  52. package/dist/sprites.d.ts +78 -0
  53. package/dist/storage-limit.d.ts +6 -0
  54. package/dist/style.d.ts +124 -0
  55. package/dist/style.js +709 -0
  56. package/dist/surfels.d.ts +95 -0
  57. package/dist/surfels.js +538 -0
  58. package/dist/survey-DToZwkJv.js +46 -0
  59. package/dist/survey.d.ts +10 -0
  60. package/dist/tier-BcFbLPVT.js +91 -0
  61. package/dist/tier.d.ts +6 -0
  62. package/package.json +102 -4
@@ -0,0 +1,446 @@
1
+ import { LAS_RECORD_SIZES as e } from "./las.js";
2
+ import { a as t, c as n, i as r, n as i, o as a, r as o, s, t as c, u as l } from "./laz-model-DCphHLqH.js";
3
+ //#region src/laz-encode.ts
4
+ var u = (e) => new s(e, !1), d = (e, t) => Array.from({ length: e }, () => u(t)), f = (e, t, n) => e[t] ??= u(n), p = class {
5
+ constructor() {
6
+ this.out = /* @__PURE__ */ new Uint8Array(1024), this.n = 0, this.base = 0, this.length = 4294967295;
7
+ }
8
+ add(e) {
9
+ let t = this.base + e;
10
+ if (t >= 4294967296) {
11
+ t -= 4294967296;
12
+ let e = this.out, n = this.n - 1;
13
+ for (; e[n] === 255;) e[n--] = 0;
14
+ e[n]++;
15
+ }
16
+ this.base = t;
17
+ }
18
+ put(e) {
19
+ if (this.n === this.out.length) {
20
+ let e = new Uint8Array(this.n * 2);
21
+ e.set(this.out), this.out = e;
22
+ }
23
+ this.out[this.n++] = e;
24
+ }
25
+ renorm() {
26
+ for (; this.length < a;) this.put(this.base >>> 24), this.base = this.base << 8 >>> 0, this.length = this.length << 8 >>> 0;
27
+ }
28
+ bit(e, t) {
29
+ let n = e.prob * (this.length >>> 13);
30
+ t ? (this.add(n), this.length -= n) : (this.length = n, e.zeros++), this.length < 16777216 && this.renorm(), --e.until === 0 && e.update();
31
+ }
32
+ symbol(e, t) {
33
+ let n = this.length >>> 15, r = e.dist[t] * n;
34
+ this.add(r), this.length = t === e.last ? this.length - r : e.dist[t + 1] * n - r, this.length < 16777216 && this.renorm(), e.counts[t]++, --e.until === 0 && e.update();
35
+ }
36
+ bits(e, t) {
37
+ if (e > 19) {
38
+ this.bits(16, t & 65535), this.bits(e - 16, t >>> 16);
39
+ return;
40
+ }
41
+ let n = this.length >>> e;
42
+ this.add(t * n), this.length = n, this.renorm();
43
+ }
44
+ int(e) {
45
+ this.bits(32, e >>> 0);
46
+ }
47
+ done() {
48
+ let e = 3;
49
+ this.length > 33554432 ? (this.add(a), this.length = a >>> 1) : (this.add(a >>> 1), this.length = a >>> 9, e = 2), this.renorm();
50
+ for (let t = 0; t < e; t++) this.put(0);
51
+ return this.out.subarray(0, this.n);
52
+ }
53
+ }, m = class {
54
+ constructor(e, t, n = 1) {
55
+ this.encoder = e, this.zero = new c(), this.correctors = [], this.k = 0, this.range = t < 32 ? 2 ** t : 0, this.kModels = d(n, t + 1);
56
+ }
57
+ compress(e, t, n = 0) {
58
+ let r = t - e, i = this.range;
59
+ i ? r < -i / 2 ? r += i : r > i / 2 - 1 && (r -= i) : r |= 0;
60
+ let a = r <= 0 ? -r : r - 1, o = a === 0 ? 0 : 32 - Math.clz32(a), s = this.encoder;
61
+ if (this.k = o, s.symbol(this.kModels[n], o), o === 0) s.bit(this.zero, r);
62
+ else if (o < 32) {
63
+ let e = r < 0 ? r + 2 ** o - 1 : r - 1, t = f(this.correctors, o, 1 << Math.min(o, 8));
64
+ if (o <= 8) s.symbol(t, e);
65
+ else {
66
+ let n = o - 8;
67
+ s.symbol(t, e >>> n), s.bits(n, e & (1 << n) - 1);
68
+ }
69
+ }
70
+ }
71
+ }, h = class {
72
+ constructor(e) {
73
+ this.encoder = e, this.size = 20, this.x = 0, this.y = 0, this.bits = 0, this.classification = 0, this.angle = 0, this.user = 0, this.source = 0, this.lastIntensity = /* @__PURE__ */ new Uint16Array(16), this.lastHeight = /* @__PURE__ */ new Int32Array(8), this.medianX = l(16), this.medianY = l(16), this.changed = u(64), this.angles = d(2, 256), this.bitBytes = [], this.classes = [], this.users = [], this.intensities = new m(e, 16, 4), this.sources = new m(e, 16), this.dx = new m(e, 32, 2), this.dy = new m(e, 32, 22), this.z = new m(e, 32, 20);
74
+ }
75
+ init(e, t) {
76
+ this.x = e.getInt32(t, !0), this.y = e.getInt32(t + 4, !0), this.bits = e.getUint8(t + 14), this.classification = e.getUint8(t + 15), this.angle = e.getUint8(t + 16), this.user = e.getUint8(t + 17), this.source = e.getUint16(t + 18, !0);
77
+ }
78
+ write(e, t) {
79
+ let n = this.encoder, a = e.getInt32(t, !0), o = e.getInt32(t + 4, !0), s = e.getInt32(t + 8, !0), c = e.getUint16(t + 12, !0), l = e.getUint8(t + 14), u = e.getUint8(t + 15), d = e.getUint8(t + 16), p = e.getUint8(t + 17), m = e.getUint16(t + 18, !0), h = l >> 3 & 7, g = h << 3 | l & 7, _ = r[g], v = i[g], y = +(h === 1), b = (l === this.bits ? 0 : 32) | (c === this.lastIntensity[_] ? 0 : 16) | (u === this.classification ? 0 : 8) | (d === this.angle ? 0 : 4) | (p === this.user ? 0 : 2) | (m === this.source ? 0 : 1);
80
+ n.symbol(this.changed, b), b & 32 && n.symbol(f(this.bitBytes, this.bits, 256), l), b & 16 && (this.intensities.compress(this.lastIntensity[_], c, Math.min(_, 3)), this.lastIntensity[_] = c), b & 8 && n.symbol(f(this.classes, this.classification, 256), u), b & 4 && n.symbol(this.angles[l >> 6 & 1], d - this.angle & 255), b & 2 && n.symbol(f(this.users, this.user, 256), p), b & 1 && this.sources.compress(this.source, m);
81
+ let x = a - this.x | 0, S = o - this.y | 0;
82
+ this.dx.compress(this.medianX[_].get(), x, y), this.medianX[_].add(x);
83
+ let C = this.dx.k;
84
+ this.dy.compress(this.medianY[_].get(), S, y + (C < 20 ? C & -2 : 20)), this.medianY[_].add(S), C = this.dx.k + this.dy.k >> 1, this.z.compress(this.lastHeight[v], s, y + (C < 18 ? C & -2 : 18)), this.lastHeight[v] = s, this.x = a, this.y = o, this.bits = l, this.classification = u, this.angle = d, this.user = p, this.source = m;
85
+ }
86
+ };
87
+ function g(e, t, n, r, i) {
88
+ let a = t - r;
89
+ return i.lo = a >>> 0, i.hi = e - n - +(a < 0) | 0, i;
90
+ }
91
+ var _ = ({ hi: e, lo: t }) => e === 0 && t < 2147483648 || e === -1 && t >= 2147483648, v = 500, y = -10, b = 511, x = 512, S = (e) => Math.trunc(Math.fround(e >= 0 ? e + .5 : e - .5)), C = class {
92
+ constructor(e, t, n, r) {
93
+ this.encoder = e, this.layered = t, this.hi = /* @__PURE__ */ new Int32Array(4), this.lo = /* @__PURE__ */ new Uint32Array(4), this.diff = /* @__PURE__ */ new Int32Array(4), this.extreme = /* @__PURE__ */ new Int32Array(4), this.last = 0, this.next = 0, this.delta = {
94
+ hi: 0,
95
+ lo: 0
96
+ }, this.probe = {
97
+ hi: 0,
98
+ lo: 0
99
+ }, this.fullCode = t ? b : x, this.multi = u(this.fullCode + 4), this.zero = u(t ? 5 : 6), this.integers = new m(e, 32, 9), this.hi[0] = n, this.lo[0] = r;
100
+ }
101
+ full(e, t) {
102
+ this.next = this.next + 1 & 3, this.integers.compress(this.hi[this.last], e, 8), this.encoder.int(t), this.last = this.next, this.diff[this.last] = 0, this.extreme[this.last] = 0, this.hi[this.last] = e, this.lo[this.last] = t;
103
+ }
104
+ other(e, t) {
105
+ for (let n = 1; n < 4; n++) {
106
+ let r = this.last + n & 3;
107
+ if (_(g(e, t, this.hi[r], this.lo[r], this.probe))) return n;
108
+ }
109
+ return 0;
110
+ }
111
+ bump(e) {
112
+ ++this.extreme[this.last] > 3 && (this.diff[this.last] = e, this.extreme[this.last] = 0);
113
+ }
114
+ write(e, t) {
115
+ let { encoder: n, integers: r, layered: i } = this, a = +!i;
116
+ for (;;) {
117
+ let o = this.last, s = g(e, t, this.hi[o], this.lo[o], this.delta), c = s.hi === 0 && s.lo === 0, l = this.diff[o], u = _(s), d = s.lo | 0;
118
+ if (l === 0) {
119
+ if (!i && c) return n.symbol(this.zero, 0);
120
+ if (u) {
121
+ n.symbol(this.zero, a), r.compress(0, d, 0), this.diff[o] = d, this.extreme[o] = 0;
122
+ break;
123
+ }
124
+ let s = this.other(e, t);
125
+ if (s) {
126
+ n.symbol(this.zero, a + 1 + s), this.last = o + s & 3;
127
+ continue;
128
+ }
129
+ return n.symbol(this.zero, a + 1), this.full(e, t);
130
+ }
131
+ if (!i && c) return n.symbol(this.multi, b);
132
+ if (!u) {
133
+ let r = this.other(e, t);
134
+ if (r) {
135
+ n.symbol(this.multi, this.fullCode + r), this.last = o + r & 3;
136
+ continue;
137
+ }
138
+ return n.symbol(this.multi, this.fullCode), this.full(e, t);
139
+ }
140
+ let f = S(Math.fround(Math.fround(d) / Math.fround(l)));
141
+ f === 1 ? (n.symbol(this.multi, 1), r.compress(l, d, 1), this.extreme[o] = 0) : f > 1 && f < v ? (n.symbol(this.multi, f), r.compress(Math.imul(f, l), d, f < 10 ? 2 : 3)) : f >= v ? (n.symbol(this.multi, v), r.compress(Math.imul(v, l), d, 4), this.bump(d)) : f < 0 && f > y ? (n.symbol(this.multi, v - f), r.compress(Math.imul(f, l), d, 5)) : f < 0 ? (n.symbol(this.multi, 510), r.compress(Math.imul(y, l), d, 6), this.bump(d)) : (n.symbol(this.multi, 0), r.compress(0, d, 7), this.bump(d));
142
+ break;
143
+ }
144
+ this.hi[this.last] = e, this.lo[this.last] = t;
145
+ }
146
+ }, w = class {
147
+ constructor(e) {
148
+ this.encoder = e, this.size = 8;
149
+ }
150
+ init(e, t) {
151
+ this.gps = new C(this.encoder, !1, e.getInt32(t + 4, !0), e.getUint32(t, !0));
152
+ }
153
+ write(e, t) {
154
+ this.gps.write(e.getInt32(t + 4, !0), e.getUint32(t, !0));
155
+ }
156
+ }, T = class {
157
+ constructor() {
158
+ this.used = u(128), this.diff = d(6, 256), this.last = /* @__PURE__ */ new Uint16Array(3);
159
+ }
160
+ read(e, t) {
161
+ for (let n = 0; n < 3; n++) this.last[n] = e.getUint16(t + n * 2, !0);
162
+ }
163
+ write(e, t, r, i = this.last) {
164
+ let a = i[0], o = i[1], s = i[2], c = t.getUint16(r, !0), l = t.getUint16(r + 2, !0), u = t.getUint16(r + 4, !0), d = this.diff, f = ((a & 255) == (c & 255) ? 0 : 1) | (a >> 8 == c >> 8 ? 0 : 2) | ((o & 255) == (l & 255) ? 0 : 4) | (o >> 8 == l >> 8 ? 0 : 8) | ((s & 255) == (u & 255) ? 0 : 16) | (s >> 8 == u >> 8 ? 0 : 32) | (c !== l || c !== u ? 64 : 0);
165
+ if (e.symbol(this.used, f), f & 1 && e.symbol(d[0], (c & 255) - (a & 255) & 255), f & 2 && e.symbol(d[1], (c >> 8) - (a >> 8) & 255), f & 64) {
166
+ let t = (c & 255) - (a & 255);
167
+ f & 4 && e.symbol(d[2], (l & 255) - n(t + (o & 255)) & 255), f & 16 && (t = Math.trunc((t + (l & 255) - (o & 255)) / 2), e.symbol(d[4], (u & 255) - n(t + (s & 255)) & 255)), t = (c >> 8) - (a >> 8), f & 8 && e.symbol(d[3], (l >> 8) - n(t + (o >> 8)) & 255), f & 32 && (t = Math.trunc((t + (l >> 8) - (o >> 8)) / 2), e.symbol(d[5], (u >> 8) - n(t + (s >> 8)) & 255));
168
+ }
169
+ return i[0] = c, i[1] = l, i[2] = u, a !== c || o !== l || s !== u;
170
+ }
171
+ }, E = class {
172
+ constructor(e) {
173
+ this.encoder = e, this.size = 6, this.rgb = new T();
174
+ }
175
+ init(e, t) {
176
+ this.rgb.read(e, t);
177
+ }
178
+ write(e, t) {
179
+ this.rgb.write(this.encoder, e, t);
180
+ }
181
+ }, D = class {
182
+ constructor(e, t) {
183
+ this.encoder = e, this.size = t, this.last = new Uint8Array(t), this.models = d(t, 256);
184
+ }
185
+ init(e, t) {
186
+ for (let n = 0; n < this.size; n++) this.last[n] = e.getUint8(t + n);
187
+ }
188
+ write(e, t) {
189
+ for (let n = 0; n < this.size; n++) {
190
+ let r = e.getUint8(t + n);
191
+ this.encoder.symbol(this.models[n], r - this.last[n] & 255), this.last[n] = r;
192
+ }
193
+ }
194
+ }, O = class {
195
+ constructor() {
196
+ this.index = 0, this.hi = 0, this.lo = 0, this.packetSize = 0, this.location = 0, this.direction = /* @__PURE__ */ new Int32Array(3);
197
+ }
198
+ copy(e) {
199
+ this.index = e.index, this.hi = e.hi, this.lo = e.lo, this.packetSize = e.packetSize, this.location = e.location, this.direction.set(e.direction);
200
+ }
201
+ read(e, t) {
202
+ this.index = e.getUint8(t), this.lo = e.getUint32(t + 1, !0), this.hi = e.getInt32(t + 5, !0), this.packetSize = e.getInt32(t + 9, !0), this.location = e.getInt32(t + 13, !0);
203
+ for (let n = 0; n < 3; n++) this.direction[n] = e.getInt32(t + 17 + n * 4, !0);
204
+ }
205
+ }, k = class {
206
+ constructor(e) {
207
+ this.encoder = e, this.index = u(256), this.types = d(4, 4), this.type = 0, this.step = 0, this.next = new O(), this.delta = {
208
+ hi: 0,
209
+ lo: 0
210
+ }, this.offsets = new m(e, 32), this.sizes = new m(e, 32), this.locations = new m(e, 32), this.directions = new m(e, 32, 3);
211
+ }
212
+ write(e, t, n) {
213
+ let r = this.next, i = this.encoder;
214
+ r.read(e, t), i.symbol(this.index, r.index);
215
+ let a = g(r.hi, r.lo, n.hi, n.lo, this.delta), o = a.hi === 0 && a.lo === 0, s = n.lo + (n.packetSize >>> 0), c = r.lo === s >>> 0 && r.hi === (n.hi + +(s >= 4294967296) | 0), l = o ? 0 : c ? 1 : _(a) ? 2 : 3;
216
+ i.symbol(this.types[this.type], l), this.type = l, l === 2 ? (this.offsets.compress(this.step, a.lo | 0), this.step = a.lo | 0) : l === 3 && (i.int(r.lo), i.int(r.hi)), this.sizes.compress(n.packetSize, r.packetSize), this.locations.compress(n.location, r.location);
217
+ let u = !1;
218
+ for (let e = 0; e < 3; e++) this.directions.compress(n.direction[e], r.direction[e], e), r.direction[e] !== n.direction[e] && (u = !0);
219
+ let d = u || !o || r.index !== n.index || r.packetSize !== n.packetSize || r.location !== n.location;
220
+ return n.copy(r), d;
221
+ }
222
+ }, A = class {
223
+ constructor(e) {
224
+ this.size = 29, this.last = new O(), this.models = new k(e);
225
+ }
226
+ init(e, t) {
227
+ this.last.read(e, t);
228
+ }
229
+ write(e, t) {
230
+ this.models.write(e, t, this.last);
231
+ }
232
+ }, j = class {
233
+ constructor() {
234
+ this.encoder = new p(), this.changed = !1;
235
+ }
236
+ }, M = /* @__PURE__ */ new Uint8Array(), N = (e) => e.changed ? e.encoder.done() : M, P = class {
237
+ constructor() {
238
+ this.x = 0, this.y = 0, this.z = 0, this.intensity = 0, this.returnNumber = 0, this.returns = 0, this.flags = 0, this.channel = 0, this.classification = 0, this.user = 0, this.angle = 0, this.source = 0, this.hi = 0, this.lo = 0, this.timeChanged = !1;
239
+ }
240
+ read(e, t) {
241
+ let n = e.getUint8(t + 14), r = e.getUint8(t + 15);
242
+ this.x = e.getInt32(t, !0), this.y = e.getInt32(t + 4, !0), this.z = e.getInt32(t + 8, !0), this.intensity = e.getUint16(t + 12, !0), this.returnNumber = n & 15, this.returns = n >> 4, this.flags = r >> 2 & 48 | r & 15, this.channel = r >> 4 & 3, this.classification = e.getUint8(t + 16), this.user = e.getUint8(t + 17), this.angle = e.getInt16(t + 18, !0), this.source = e.getUint16(t + 20, !0), this.lo = e.getUint32(t + 22, !0), this.hi = e.getInt32(t + 26, !0);
243
+ }
244
+ copy(e) {
245
+ this.x = e.x, this.y = e.y, this.z = e.z, this.intensity = e.intensity, this.returnNumber = e.returnNumber, this.returns = e.returns, this.flags = e.flags, this.channel = e.channel, this.classification = e.classification, this.user = e.user, this.angle = e.angle, this.source = e.source, this.lo = e.lo, this.hi = e.hi;
246
+ }
247
+ }, F = class {
248
+ constructor(e, t) {
249
+ this.last = new P(), this.medianX = l(12), this.medianY = l(12), this.changed = d(8, 128), this.channel = u(3), this.returns = [], this.returnNumbers = [], this.returnStep = u(13), this.classes = [], this.flags = [], this.users = [];
250
+ let [n, r, , , i, a, , o, s] = e;
251
+ this.last.copy(t), this.lastIntensity = (/* @__PURE__ */ new Uint16Array(8)).fill(t.intensity), this.lastZ = (/* @__PURE__ */ new Int32Array(8)).fill(t.z), this.dx = new m(n.encoder, 32, 2), this.dy = new m(n.encoder, 32, 22), this.z = new m(r.encoder, 32, 20), this.intensities = new m(i.encoder, 16, 4), this.angles = new m(a.encoder, 16, 2), this.sources = new m(o.encoder, 16), this.gps = new C(s.encoder, !0, t.hi, t.lo);
252
+ }
253
+ }, I = class {
254
+ constructor(e) {
255
+ this.channel = e, this.size = 30, this.streams = Array.from({ length: 9 }, () => new j()), this.contexts = [], this.point = new P();
256
+ }
257
+ init(e, t) {
258
+ let n = this.point;
259
+ n.read(e, t), this.channel.current = this.channel.item = n.channel, this.contexts[n.channel] = new F(this.streams, n), this.streams[0].changed = !0;
260
+ }
261
+ write(e, n) {
262
+ let r = this.streams, i = r[0].encoder, a = this.point, s = this.channel.current;
263
+ a.read(e, n);
264
+ let c = this.contexts[s], l = c.last, u = +(l.returnNumber === 1) + (l.returnNumber >= l.returns ? 2 : 0) + (l.timeChanged ? 4 : 0), d = a.channel !== s, p = d ? this.contexts[a.channel] : c, m = p ? p.last : l, h = a.returnNumber - m.returnNumber & 15, g = h === 0 ? 0 : h === 1 ? 1 : h === 15 ? 2 : 3, _ = a.source !== m.source, v = a.hi !== m.hi || a.lo !== m.lo, y = a.angle !== m.angle, b = +!!v, x = (d ? 64 : 0) | (_ ? 32 : 0) | (v ? 16 : 0) | (y ? 8 : 0) | (a.returns === m.returns ? 0 : 4) | g;
265
+ i.symbol(c.changed[u], x), this.channel.item = 0, d && (i.symbol(c.channel, (a.channel - s + 4 & 3) - 1), c = p ?? (this.contexts[a.channel] = new F(r, l)), this.channel.current = this.channel.item = a.channel, l = c.last, l.channel = a.channel), x & 4 && i.symbol(f(c.returns, l.returns, 16), a.returns), g === 3 && (v ? i.symbol(f(c.returnNumbers, l.returnNumber, 16), a.returnNumber) : i.symbol(c.returnStep, (a.returnNumber - l.returnNumber + 16 & 15) - 2));
266
+ let S = a.returns, C = a.returnNumber, w = S << 4 | C, T = t[w] << 1 | b, E = o[w], D = +(S === 1), O = (C === 1 ? 2 : 0) + +(C >= S), k = a.x - l.x | 0, A = a.y - l.y | 0, j = c.medianX[T], M = c.medianY[T];
267
+ c.dx.compress(j.get(), k, D), j.add(k);
268
+ let N = c.dx.k;
269
+ c.dy.compress(M.get(), A, D + (N < 20 ? N & -2 : 20)), M.add(A), N = c.dx.k + c.dy.k >> 1, c.z.compress(c.lastZ[E], a.z, D + (N < 18 ? N & -2 : 18)), c.lastZ[E] = a.z, a.z !== l.z && (r[1].changed = !0), r[2].encoder.symbol(f(c.classes, ((l.classification & 31) << 1) + +(O === 3), 256), a.classification), a.classification !== l.classification && (r[2].changed = !0), r[3].encoder.symbol(f(c.flags, l.flags, 64), a.flags), a.flags !== l.flags && (r[3].changed = !0);
270
+ let P = O << 1 | b;
271
+ c.intensities.compress(c.lastIntensity[P], a.intensity, O), c.lastIntensity[P] = a.intensity, a.intensity !== l.intensity && (r[4].changed = !0), y && (c.angles.compress(l.angle, a.angle, b), r[5].changed = !0), r[6].encoder.symbol(f(c.users, l.user >> 2, 256), a.user), a.user !== l.user && (r[6].changed = !0), _ && (c.sources.compress(l.source, a.source), r[7].changed = !0), v && (c.gps.write(a.hi, a.lo), r[8].changed = !0), l.copy(a), l.timeChanged = v;
272
+ }
273
+ layers() {
274
+ return this.streams.map(N);
275
+ }
276
+ }, L = class {
277
+ constructor(e) {
278
+ this.channel = e, this.contexts = [], this.current = 0;
279
+ }
280
+ init(e, t) {
281
+ this.current = this.channel.current, this.contexts[this.current] = this.first(e, t);
282
+ }
283
+ pick() {
284
+ let e = this.channel.item, t = this.contexts[this.current];
285
+ return this.current !== e && (this.current = e, this.contexts[e] || (t = this.contexts[e] = this.make(t))), this.held = t, this.contexts[e];
286
+ }
287
+ }, R = class extends L {
288
+ constructor(e, t) {
289
+ super(e), this.size = t, this.color = new j(), this.infrared = new j();
290
+ }
291
+ context() {
292
+ return {
293
+ rgb: new T(),
294
+ nirUsed: u(4),
295
+ nirDiff: d(2, 256),
296
+ nir: 0
297
+ };
298
+ }
299
+ first(e, t) {
300
+ let n = this.context();
301
+ return n.rgb.read(e, t), this.size === 8 && (n.nir = e.getUint16(t + 6, !0)), n;
302
+ }
303
+ make(e) {
304
+ let t = this.context();
305
+ return t.rgb.last.set(e.rgb.last), t.nir = e.nir, t;
306
+ }
307
+ write(e, t) {
308
+ let n = this.pick(), r = this.held;
309
+ if (n.rgb.write(this.color.encoder, e, t, r.rgb.last) && (this.color.changed = !0), this.size !== 8) return;
310
+ let i = r.nir, a = e.getUint16(t + 6, !0), o = ((i & 255) == (a & 255) ? 0 : 1) | (i >> 8 == a >> 8 ? 0 : 2), s = this.infrared.encoder;
311
+ s.symbol(n.nirUsed, o), o & 1 && s.symbol(n.nirDiff[0], (a & 255) - (i & 255) & 255), o & 2 && s.symbol(n.nirDiff[1], (a >> 8) - (i >> 8) & 255), o && (this.infrared.changed = !0), r.nir = a;
312
+ }
313
+ layers() {
314
+ return this.size === 8 ? [N(this.color), N(this.infrared)] : [N(this.color)];
315
+ }
316
+ }, z = class extends L {
317
+ constructor(e, t) {
318
+ super(e), this.size = t, this.streams = Array.from({ length: t }, () => new j());
319
+ }
320
+ first(e, t) {
321
+ let n = new Uint8Array(this.size);
322
+ for (let r = 0; r < this.size; r++) n[r] = e.getUint8(t + r);
323
+ return {
324
+ last: n,
325
+ models: d(this.size, 256)
326
+ };
327
+ }
328
+ make(e) {
329
+ return {
330
+ last: e.last.slice(),
331
+ models: d(this.size, 256)
332
+ };
333
+ }
334
+ write(e, t) {
335
+ let n = this.pick(), r = this.held.last;
336
+ for (let i = 0; i < this.size; i++) {
337
+ let a = e.getUint8(t + i), o = this.streams[i];
338
+ o.encoder.symbol(n.models[i], a - r[i] & 255), a !== r[i] && (o.changed = !0), r[i] = a;
339
+ }
340
+ }
341
+ layers() {
342
+ return this.streams.map(N);
343
+ }
344
+ }, B = class extends L {
345
+ constructor(...e) {
346
+ super(...e), this.size = 29, this.stream = new j();
347
+ }
348
+ context() {
349
+ return {
350
+ last: new O(),
351
+ models: new k(this.stream.encoder)
352
+ };
353
+ }
354
+ first(e, t) {
355
+ let n = this.context();
356
+ return n.last.read(e, t), n;
357
+ }
358
+ make(e) {
359
+ let t = this.context();
360
+ return t.last.copy(e.last), t;
361
+ }
362
+ write(e, t) {
363
+ this.pick().models.write(e, t, this.held.last) && (this.stream.changed = !0);
364
+ }
365
+ layers() {
366
+ return [N(this.stream)];
367
+ }
368
+ }, V = 0, H = 6, U = 7, W = 8, G = 9, K = 10, q = 11, J = 12, Y = 13, X = 14;
369
+ function Z(t, n) {
370
+ let r = n - e[t], i = [];
371
+ return t >= 6 ? (i.push([
372
+ K,
373
+ 30,
374
+ 3
375
+ ]), t === 7 ? i.push([
376
+ q,
377
+ 6,
378
+ 3
379
+ ]) : (t === 8 || t === 10) && i.push([
380
+ J,
381
+ 8,
382
+ 3
383
+ ]), t >= 9 && i.push([
384
+ Y,
385
+ 29,
386
+ 3
387
+ ]), r && i.push([
388
+ X,
389
+ r,
390
+ 3
391
+ ])) : (i.push([
392
+ H,
393
+ 20,
394
+ 2
395
+ ]), (t === 1 || t >= 3) && i.push([
396
+ U,
397
+ 8,
398
+ 2
399
+ ]), (t === 2 || t === 3 || t === 5) && i.push([
400
+ W,
401
+ 6,
402
+ 2
403
+ ]), t >= 4 && i.push([
404
+ G,
405
+ 29,
406
+ 1
407
+ ]), r && i.push([
408
+ V,
409
+ r,
410
+ 2
411
+ ])), i;
412
+ }
413
+ function Q(e, t, n, r, i, a) {
414
+ let o = e.subarray(n, n + i), s = a[0][0] === K, c = {
415
+ current: 0,
416
+ item: 0
417
+ }, l = new p(), u = [], d = a.map(([e, t]) => {
418
+ if (!s) return e === H ? new h(l) : e === U ? new w(l) : e === W ? new E(l) : e === G ? new A(l) : new D(l, t);
419
+ let n = e === K ? new I(c) : e === Y ? new B(c) : e === X ? new z(c, t) : new R(c, t);
420
+ return u.push(n), n;
421
+ }), f = n;
422
+ for (let e of d) e.init(t, f), f += e.size;
423
+ let m = n + r * i;
424
+ for (; f < m;) for (let e of d) e.write(t, f), f += e.size;
425
+ if (!s) return [o, l.done()];
426
+ let g = u.flatMap((e) => e.layers()), _ = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4 + g.length * 4));
427
+ return _.setUint32(0, r, !0), g.forEach((e, t) => _.setUint32(4 + t * 4, e.length, !0)), [
428
+ o,
429
+ new Uint8Array(_.buffer),
430
+ ...g
431
+ ];
432
+ }
433
+ function $(e, t) {
434
+ let n = new Uint8Array(88 + e.length * 6), r = new DataView(n.buffer);
435
+ return n.set(new TextEncoder().encode("laszip encoded"), 2), n.set(new TextEncoder().encode("Margo Engine LAZ"), 22), r.setUint16(18, 22204, !0), r.setUint16(20, n.length - 54, !0), r.setUint16(54, e[0][0] === K ? 3 : 2, !0), r.setUint8(58, 3), r.setUint8(59, 4), r.setUint32(66, t, !0), r.setBigInt64(70, -1n, !0), r.setBigInt64(78, -1n, !0), r.setUint16(86, e.length, !0), e.forEach(([e, t, n], i) => {
436
+ r.setUint16(88 + i * 6, e, !0), r.setUint16(90 + i * 6, t, !0), r.setUint16(92 + i * 6, n, !0);
437
+ }), n;
438
+ }
439
+ function ee(e, t) {
440
+ let n = new p(), r = new m(n, 32, 2), i = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
441
+ return i.setUint32(4, e.length, !0), e.forEach((n, i) => {
442
+ t && r.compress(i ? t[i - 1] : 0, t[i], 0), r.compress(i ? e[i - 1] : 0, n, 1);
443
+ }), [new Uint8Array(i.buffer), ...e.length ? [n.done()] : []];
444
+ }
445
+ //#endregion
446
+ export { $ as i, ee as n, Z as r, Q as t };
@@ -0,0 +1,14 @@
1
+ /** The items of a record: `[type, size, version]`. */
2
+ export declare function itemsOf(format: number, recordLength: number): [number, number, number][];
3
+ /** One chunk of `count` points from `start`: its first record raw, then the coded rest. */
4
+ export declare function chunk(points: Uint8Array, view: DataView, start: number, count: number, length: number, items: readonly [number, number, number][]): Uint8Array[];
5
+ /**
6
+ * The `laszip encoded` record that describes the items: compressor 2 pointwise chunked or 3 layered chunked, coder 0,
7
+ * and the version of LASzip whose coding this is. A chunk size of 0xffffffff marks variable chunks.
8
+ */
9
+ export declare function lazRecord(items: readonly [number, number, number][], chunkSize: number): Uint8Array;
10
+ /**
11
+ * The chunk table: each chunk's byte size, predicted from the one before, and with `counts` (variable chunks) its point
12
+ * count.
13
+ */
14
+ export declare function chunkTable(sizes: readonly number[], counts?: readonly number[]): Uint8Array[];