@speridlabs/visus 2.4.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.es.js CHANGED
@@ -1,9 +1,9 @@
1
- var Qe = Object.defineProperty;
2
- var Ke = (a, e, t) => e in a ? Qe(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var w = (a, e, t) => Ke(a, typeof e != "symbol" ? e + "" : e, t);
4
- import et, { useState as tt, useRef as st, useEffect as rt } from "react";
1
+ var st = Object.defineProperty;
2
+ var nt = (n, e, t) => e in n ? st(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var g = (n, e, t) => nt(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import rt, { useState as at, useRef as ot, useEffect as it } from "react";
5
5
  import * as u from "three";
6
- var Se = { exports: {} }, ge = {};
6
+ var Se = { exports: {} }, xe = {};
7
7
  /**
8
8
  * @license React
9
9
  * react-jsx-runtime.production.js
@@ -13,27 +13,27 @@ var Se = { exports: {} }, ge = {};
13
13
  * This source code is licensed under the MIT license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
- var Oe;
17
- function nt() {
18
- if (Oe) return ge;
19
- Oe = 1;
20
- var a = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
21
- function t(s, r, n) {
16
+ var Fe;
17
+ function ct() {
18
+ if (Fe) return xe;
19
+ Fe = 1;
20
+ var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
21
+ function t(s, r, a) {
22
22
  var o = null;
23
- if (n !== void 0 && (o = "" + n), r.key !== void 0 && (o = "" + r.key), "key" in r) {
24
- n = {};
25
- for (var c in r)
26
- c !== "key" && (n[c] = r[c]);
27
- } else n = r;
28
- return r = n.ref, {
29
- $$typeof: a,
23
+ if (a !== void 0 && (o = "" + a), r.key !== void 0 && (o = "" + r.key), "key" in r) {
24
+ a = {};
25
+ for (var i in r)
26
+ i !== "key" && (a[i] = r[i]);
27
+ } else a = r;
28
+ return r = a.ref, {
29
+ $$typeof: n,
30
30
  type: s,
31
31
  key: o,
32
32
  ref: r !== void 0 ? r : null,
33
- props: n
33
+ props: a
34
34
  };
35
35
  }
36
- return ge.Fragment = e, ge.jsx = t, ge.jsxs = t, ge;
36
+ return xe.Fragment = e, xe.jsx = t, xe.jsxs = t, xe;
37
37
  }
38
38
  var ye = {};
39
39
  /**
@@ -45,251 +45,251 @@ var ye = {};
45
45
  * This source code is licensed under the MIT license found in the
46
46
  * LICENSE file in the root directory of this source tree.
47
47
  */
48
- var Ue;
49
- function at() {
50
- return Ue || (Ue = 1, process.env.NODE_ENV !== "production" && function() {
51
- function a(i) {
52
- if (i == null) return null;
53
- if (typeof i == "function")
54
- return i.$$typeof === y ? null : i.displayName || i.name || null;
55
- if (typeof i == "string") return i;
56
- switch (i) {
57
- case C:
48
+ var Ve;
49
+ function lt() {
50
+ return Ve || (Ve = 1, process.env.NODE_ENV !== "production" && function() {
51
+ function n(c) {
52
+ if (c == null) return null;
53
+ if (typeof c == "function")
54
+ return c.$$typeof === w ? null : c.displayName || c.name || null;
55
+ if (typeof c == "string") return c;
56
+ switch (c) {
57
+ case k:
58
58
  return "Fragment";
59
- case B:
59
+ case z:
60
60
  return "Profiler";
61
- case k:
61
+ case _:
62
62
  return "StrictMode";
63
63
  case W:
64
64
  return "Suspense";
65
65
  case T:
66
66
  return "SuspenseList";
67
- case E:
67
+ case C:
68
68
  return "Activity";
69
69
  }
70
- if (typeof i == "object")
71
- switch (typeof i.tag == "number" && console.error(
70
+ if (typeof c == "object")
71
+ switch (typeof c.tag == "number" && console.error(
72
72
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
73
- ), i.$$typeof) {
73
+ ), c.$$typeof) {
74
74
  case v:
75
75
  return "Portal";
76
- case F:
77
- return (i.displayName || "Context") + ".Provider";
78
- case U:
79
- return (i._context.displayName || "Context") + ".Consumer";
80
- case N:
81
- var A = i.render;
82
- return i = i.displayName, i || (i = A.displayName || A.name || "", i = i !== "" ? "ForwardRef(" + i + ")" : "ForwardRef"), i;
76
+ case q:
77
+ return (c.displayName || "Context") + ".Provider";
78
+ case V:
79
+ return (c._context.displayName || "Context") + ".Consumer";
80
+ case j:
81
+ var A = c.render;
82
+ return c = c.displayName, c || (c = A.displayName || A.name || "", c = c !== "" ? "ForwardRef(" + c + ")" : "ForwardRef"), c;
83
83
  case S:
84
- return A = i.displayName || null, A !== null ? A : a(i.type) || "Memo";
85
- case z:
86
- A = i._payload, i = i._init;
84
+ return A = c.displayName || null, A !== null ? A : n(c.type) || "Memo";
85
+ case R:
86
+ A = c._payload, c = c._init;
87
87
  try {
88
- return a(i(A));
88
+ return n(c(A));
89
89
  } catch {
90
90
  }
91
91
  }
92
92
  return null;
93
93
  }
94
- function e(i) {
95
- return "" + i;
94
+ function e(c) {
95
+ return "" + c;
96
96
  }
97
- function t(i) {
97
+ function t(c) {
98
98
  try {
99
- e(i);
99
+ e(c);
100
100
  var A = !1;
101
101
  } catch {
102
102
  A = !0;
103
103
  }
104
104
  if (A) {
105
105
  A = console;
106
- var q = A.error, O = typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object";
107
- return q.call(
106
+ var O = A.error, F = typeof Symbol == "function" && Symbol.toStringTag && c[Symbol.toStringTag] || c.constructor.name || "Object";
107
+ return O.call(
108
108
  A,
109
109
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
110
- O
111
- ), e(i);
110
+ F
111
+ ), e(c);
112
112
  }
113
113
  }
114
- function s(i) {
115
- if (i === C) return "<>";
116
- if (typeof i == "object" && i !== null && i.$$typeof === z)
114
+ function s(c) {
115
+ if (c === k) return "<>";
116
+ if (typeof c == "object" && c !== null && c.$$typeof === R)
117
117
  return "<...>";
118
118
  try {
119
- var A = a(i);
119
+ var A = n(c);
120
120
  return A ? "<" + A + ">" : "<...>";
121
121
  } catch {
122
122
  return "<...>";
123
123
  }
124
124
  }
125
125
  function r() {
126
- var i = b.A;
127
- return i === null ? null : i.getOwner();
126
+ var c = b.A;
127
+ return c === null ? null : c.getOwner();
128
128
  }
129
- function n() {
129
+ function a() {
130
130
  return Error("react-stack-top-frame");
131
131
  }
132
- function o(i) {
133
- if (j.call(i, "key")) {
134
- var A = Object.getOwnPropertyDescriptor(i, "key").get;
132
+ function o(c) {
133
+ if (N.call(c, "key")) {
134
+ var A = Object.getOwnPropertyDescriptor(c, "key").get;
135
135
  if (A && A.isReactWarning) return !1;
136
136
  }
137
- return i.key !== void 0;
137
+ return c.key !== void 0;
138
138
  }
139
- function c(i, A) {
140
- function q() {
141
- D || (D = !0, console.error(
139
+ function i(c, A) {
140
+ function O() {
141
+ B || (B = !0, console.error(
142
142
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
143
143
  A
144
144
  ));
145
145
  }
146
- q.isReactWarning = !0, Object.defineProperty(i, "key", {
147
- get: q,
146
+ O.isReactWarning = !0, Object.defineProperty(c, "key", {
147
+ get: O,
148
148
  configurable: !0
149
149
  });
150
150
  }
151
- function f() {
152
- var i = a(this.type);
153
- return x[i] || (x[i] = !0, console.error(
151
+ function m() {
152
+ var c = n(this.type);
153
+ return x[c] || (x[c] = !0, console.error(
154
154
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
155
- )), i = this.props.ref, i !== void 0 ? i : null;
155
+ )), c = this.props.ref, c !== void 0 ? c : null;
156
156
  }
157
- function g(i, A, q, O, R, d, P, G) {
158
- return q = d.ref, i = {
157
+ function y(c, A, O, F, I, d, D, G) {
158
+ return O = d.ref, c = {
159
159
  $$typeof: p,
160
- type: i,
160
+ type: c,
161
161
  key: A,
162
162
  props: d,
163
- _owner: R
164
- }, (q !== void 0 ? q : null) !== null ? Object.defineProperty(i, "ref", {
163
+ _owner: I
164
+ }, (O !== void 0 ? O : null) !== null ? Object.defineProperty(c, "ref", {
165
165
  enumerable: !1,
166
- get: f
167
- }) : Object.defineProperty(i, "ref", { enumerable: !1, value: null }), i._store = {}, Object.defineProperty(i._store, "validated", {
166
+ get: m
167
+ }) : Object.defineProperty(c, "ref", { enumerable: !1, value: null }), c._store = {}, Object.defineProperty(c._store, "validated", {
168
168
  configurable: !1,
169
169
  enumerable: !1,
170
170
  writable: !0,
171
171
  value: 0
172
- }), Object.defineProperty(i, "_debugInfo", {
172
+ }), Object.defineProperty(c, "_debugInfo", {
173
173
  configurable: !1,
174
174
  enumerable: !1,
175
175
  writable: !0,
176
176
  value: null
177
- }), Object.defineProperty(i, "_debugStack", {
177
+ }), Object.defineProperty(c, "_debugStack", {
178
178
  configurable: !1,
179
179
  enumerable: !1,
180
180
  writable: !0,
181
- value: P
182
- }), Object.defineProperty(i, "_debugTask", {
181
+ value: D
182
+ }), Object.defineProperty(c, "_debugTask", {
183
183
  configurable: !1,
184
184
  enumerable: !1,
185
185
  writable: !0,
186
186
  value: G
187
- }), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
187
+ }), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c;
188
188
  }
189
- function m(i, A, q, O, R, d, P, G) {
189
+ function f(c, A, O, F, I, d, D, G) {
190
190
  var M = A.children;
191
191
  if (M !== void 0)
192
- if (O)
192
+ if (F)
193
193
  if (L(M)) {
194
- for (O = 0; O < M.length; O++)
195
- l(M[O]);
194
+ for (F = 0; F < M.length; F++)
195
+ l(M[F]);
196
196
  Object.freeze && Object.freeze(M);
197
197
  } else
198
198
  console.error(
199
199
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
200
200
  );
201
201
  else l(M);
202
- if (j.call(A, "key")) {
203
- M = a(i);
204
- var V = Object.keys(A).filter(function(Z) {
202
+ if (N.call(A, "key")) {
203
+ M = n(c);
204
+ var U = Object.keys(A).filter(function(Z) {
205
205
  return Z !== "key";
206
206
  });
207
- O = 0 < V.length ? "{key: someKey, " + V.join(": ..., ") + ": ...}" : "{key: someKey}", $[M + O] || (V = 0 < V.length ? "{" + V.join(": ..., ") + ": ...}" : "{}", console.error(
207
+ F = 0 < U.length ? "{key: someKey, " + U.join(": ..., ") + ": ...}" : "{key: someKey}", $[M + F] || (U = 0 < U.length ? "{" + U.join(": ..., ") + ": ...}" : "{}", console.error(
208
208
  `A props object containing a "key" prop is being spread into JSX:
209
209
  let props = %s;
210
210
  <%s {...props} />
211
211
  React keys must be passed directly to JSX without using spread:
212
212
  let props = %s;
213
213
  <%s key={someKey} {...props} />`,
214
- O,
214
+ F,
215
215
  M,
216
- V,
216
+ U,
217
217
  M
218
- ), $[M + O] = !0);
218
+ ), $[M + F] = !0);
219
219
  }
220
- if (M = null, q !== void 0 && (t(q), M = "" + q), o(A) && (t(A.key), M = "" + A.key), "key" in A) {
221
- q = {};
222
- for (var H in A)
223
- H !== "key" && (q[H] = A[H]);
224
- } else q = A;
225
- return M && c(
226
- q,
227
- typeof i == "function" ? i.displayName || i.name || "Unknown" : i
228
- ), g(
229
- i,
220
+ if (M = null, O !== void 0 && (t(O), M = "" + O), o(A) && (t(A.key), M = "" + A.key), "key" in A) {
221
+ O = {};
222
+ for (var X in A)
223
+ X !== "key" && (O[X] = A[X]);
224
+ } else O = A;
225
+ return M && i(
226
+ O,
227
+ typeof c == "function" ? c.displayName || c.name || "Unknown" : c
228
+ ), y(
229
+ c,
230
230
  M,
231
231
  d,
232
- R,
232
+ I,
233
233
  r(),
234
- q,
235
- P,
234
+ O,
235
+ D,
236
236
  G
237
237
  );
238
238
  }
239
- function l(i) {
240
- typeof i == "object" && i !== null && i.$$typeof === p && i._store && (i._store.validated = 1);
239
+ function l(c) {
240
+ typeof c == "object" && c !== null && c.$$typeof === p && c._store && (c._store.validated = 1);
241
241
  }
242
- var h = et, p = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), B = Symbol.for("react.profiler"), U = Symbol.for("react.consumer"), F = Symbol.for("react.context"), N = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), z = Symbol.for("react.lazy"), E = Symbol.for("react.activity"), y = Symbol.for("react.client.reference"), b = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, L = Array.isArray, I = console.createTask ? console.createTask : function() {
242
+ var h = rt, p = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), k = Symbol.for("react.fragment"), _ = Symbol.for("react.strict_mode"), z = Symbol.for("react.profiler"), V = Symbol.for("react.consumer"), q = Symbol.for("react.context"), j = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), C = Symbol.for("react.activity"), w = Symbol.for("react.client.reference"), b = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, L = Array.isArray, E = console.createTask ? console.createTask : function() {
243
243
  return null;
244
244
  };
245
245
  h = {
246
- "react-stack-bottom-frame": function(i) {
247
- return i();
246
+ "react-stack-bottom-frame": function(c) {
247
+ return c();
248
248
  }
249
249
  };
250
- var D, x = {}, _ = h["react-stack-bottom-frame"].bind(
250
+ var B, x = {}, P = h["react-stack-bottom-frame"].bind(
251
251
  h,
252
- n
253
- )(), X = I(s(n)), $ = {};
254
- ye.Fragment = C, ye.jsx = function(i, A, q, O, R) {
252
+ a
253
+ )(), H = E(s(a)), $ = {};
254
+ ye.Fragment = k, ye.jsx = function(c, A, O, F, I) {
255
255
  var d = 1e4 > b.recentlyCreatedOwnerStacks++;
256
- return m(
257
- i,
256
+ return f(
257
+ c,
258
258
  A,
259
- q,
260
- !1,
261
259
  O,
262
- R,
263
- d ? Error("react-stack-top-frame") : _,
264
- d ? I(s(i)) : X
260
+ !1,
261
+ F,
262
+ I,
263
+ d ? Error("react-stack-top-frame") : P,
264
+ d ? E(s(c)) : H
265
265
  );
266
- }, ye.jsxs = function(i, A, q, O, R) {
266
+ }, ye.jsxs = function(c, A, O, F, I) {
267
267
  var d = 1e4 > b.recentlyCreatedOwnerStacks++;
268
- return m(
269
- i,
268
+ return f(
269
+ c,
270
270
  A,
271
- q,
272
- !0,
273
271
  O,
274
- R,
275
- d ? Error("react-stack-top-frame") : _,
276
- d ? I(s(i)) : X
272
+ !0,
273
+ F,
274
+ I,
275
+ d ? Error("react-stack-top-frame") : P,
276
+ d ? E(s(c)) : H
277
277
  );
278
278
  };
279
279
  }()), ye;
280
280
  }
281
- var Ve;
282
- function ot() {
283
- return Ve || (Ve = 1, process.env.NODE_ENV === "production" ? Se.exports = nt() : Se.exports = at()), Se.exports;
281
+ var Ue;
282
+ function ht() {
283
+ return Ue || (Ue = 1, process.env.NODE_ENV === "production" ? Se.exports = ct() : Se.exports = lt()), Se.exports;
284
284
  }
285
- var it = ot();
285
+ var ut = ht();
286
286
  class be {
287
287
  constructor() {
288
- w(this, "min", new u.Vector3(1 / 0, 1 / 0, 1 / 0));
289
- w(this, "max", new u.Vector3(-1 / 0, -1 / 0, -1 / 0));
290
- w(this, "center", new u.Vector3());
288
+ g(this, "min", new u.Vector3(1 / 0, 1 / 0, 1 / 0));
289
+ g(this, "max", new u.Vector3(-1 / 0, -1 / 0, -1 / 0));
290
+ g(this, "center", new u.Vector3());
291
291
  /** Half extents (size/2) */
292
- w(this, "halfExtents", new u.Vector3());
292
+ g(this, "halfExtents", new u.Vector3());
293
293
  }
294
294
  /**
295
295
  * Reset the bounding box to its initial state
@@ -341,15 +341,15 @@ class be {
341
341
  return e.min.copy(this.min), e.max.copy(this.max), e.center.copy(this.center), e.halfExtents.copy(this.halfExtents), e;
342
342
  }
343
343
  }
344
- class ct {
344
+ class mt {
345
345
  constructor(e = 0) {
346
- w(this, "numSplats", 0);
347
- w(this, "positions");
348
- w(this, "rotations");
349
- w(this, "scales");
350
- w(this, "colors");
351
- w(this, "opacities");
352
- w(this, "boundingBox", new be());
346
+ g(this, "numSplats", 0);
347
+ g(this, "positions");
348
+ g(this, "rotations");
349
+ g(this, "scales");
350
+ g(this, "colors");
351
+ g(this, "opacities");
352
+ g(this, "boundingBox", new be());
353
353
  this.numSplats = e, this.allocateBuffers(e);
354
354
  }
355
355
  allocateBuffers(e) {
@@ -364,13 +364,13 @@ class ct {
364
364
  * @param color Color
365
365
  * @param opacity Opacity value
366
366
  */
367
- setSplat(e, t, s, r, n, o) {
367
+ setSplat(e, t, s, r, a, o) {
368
368
  if (e >= this.numSplats)
369
369
  throw new Error(
370
370
  `Splat index out of bounds: ${e} >= ${this.numSplats}`
371
371
  );
372
- const c = e * 3, f = e * 4, g = e * 3, m = e * 3;
373
- this.positions[c] = t.x, this.positions[c + 1] = t.y, this.positions[c + 2] = t.z, this.rotations[f] = s.x, this.rotations[f + 1] = s.y, this.rotations[f + 2] = s.z, this.rotations[f + 3] = s.w, this.scales[g] = r.x, this.scales[g + 1] = r.y, this.scales[g + 2] = r.z, this.colors[m] = n.r, this.colors[m + 1] = n.g, this.colors[m + 2] = n.b, this.opacities[e] = o;
372
+ const i = e * 3, m = e * 4, y = e * 3, f = e * 3;
373
+ this.positions[i] = t.x, this.positions[i + 1] = t.y, this.positions[i + 2] = t.z, this.rotations[m] = s.x, this.rotations[m + 1] = s.y, this.rotations[m + 2] = s.z, this.rotations[m + 3] = s.w, this.scales[y] = r.x, this.scales[y + 1] = r.y, this.scales[y + 2] = r.z, this.colors[f] = a.r, this.colors[f + 1] = a.g, this.colors[f + 2] = a.b, this.opacities[e] = o;
374
374
  }
375
375
  /**
376
376
  * Get a splat's data
@@ -382,7 +382,7 @@ class ct {
382
382
  throw new Error(
383
383
  `Splat index out of bounds: ${e} >= ${this.numSplats}`
384
384
  );
385
- const t = e * 3, s = e * 4, r = e * 3, n = e * 3;
385
+ const t = e * 3, s = e * 4, r = e * 3, a = e * 3;
386
386
  return {
387
387
  position: new u.Vector3(
388
388
  this.positions[t],
@@ -402,9 +402,9 @@ class ct {
402
402
  Math.exp(this.scales[r + 2])
403
403
  ),
404
404
  color: new u.Color(
405
- this.colors[n],
406
- this.colors[n + 1],
407
- this.colors[n + 2]
405
+ this.colors[a],
406
+ this.colors[a + 1],
407
+ this.colors[a + 2]
408
408
  ),
409
409
  opacity: this.opacities[e]
410
410
  };
@@ -437,14 +437,14 @@ class ct {
437
437
  new u.BufferAttribute(this.positions, 3)
438
438
  );
439
439
  const t = new Float32Array(this.numSplats * 3), s = new u.Quaternion(), r = new u.Euler();
440
- for (let n = 0; n < this.numSplats; n++) {
441
- const o = n * 4, c = n * 3;
440
+ for (let a = 0; a < this.numSplats; a++) {
441
+ const o = a * 4, i = a * 3;
442
442
  s.set(
443
443
  this.rotations[o],
444
444
  this.rotations[o + 1],
445
445
  this.rotations[o + 2],
446
446
  this.rotations[o + 3]
447
- ), r.setFromQuaternion(s), t[c] = r.x, t[c + 1] = r.y, t[c + 2] = r.z;
447
+ ), r.setFromQuaternion(s), t[i] = r.x, t[i + 1] = r.y, t[i + 2] = r.z;
448
448
  }
449
449
  return e.setAttribute(
450
450
  "rotation",
@@ -467,20 +467,20 @@ class ct {
467
467
  class Le {
468
468
  // Upper 8 bits of 16-bit means
469
469
  constructor(e, t, s) {
470
- w(this, "ranges");
471
- w(this, "version", 1);
472
- w(this, "numSplats", 0);
473
- w(this, "boundingBox", new be());
470
+ g(this, "ranges");
471
+ g(this, "version", 1);
472
+ g(this, "numSplats", 0);
473
+ g(this, "boundingBox", new be());
474
474
  // Original SOGS textures
475
- w(this, "sh0");
475
+ g(this, "sh0");
476
476
  // SH DC coefficients + alpha
477
- w(this, "quats");
477
+ g(this, "quats");
478
478
  // Quaternion components + mode
479
- w(this, "scales");
479
+ g(this, "scales");
480
480
  // Scale values (8-bit)
481
- w(this, "means_l");
481
+ g(this, "means_l");
482
482
  // Lower 8 bits of 16-bit means
483
- w(this, "means_u");
483
+ g(this, "means_u");
484
484
  this.ranges = t, this.numSplats = e, this.sh0 = s.sh0, this.quats = s.quats, this.scales = s.scales, this.means_l = s.means_l, this.means_u = s.means_u, this.boundingBox = this.calculateBoundingBox();
485
485
  }
486
486
  calculateBoundingBox() {
@@ -503,20 +503,20 @@ class Le {
503
503
  class We {
504
504
  // Upper 8 bits of 16-bit means
505
505
  constructor(e, t, s) {
506
- w(this, "ranges");
507
- w(this, "version", 2);
508
- w(this, "numSplats", 0);
509
- w(this, "boundingBox", new be());
506
+ g(this, "ranges");
507
+ g(this, "version", 2);
508
+ g(this, "numSplats", 0);
509
+ g(this, "boundingBox", new be());
510
510
  // Original SOGS textures
511
- w(this, "sh0");
511
+ g(this, "sh0");
512
512
  // SH DC coefficients + alpha
513
- w(this, "quats");
513
+ g(this, "quats");
514
514
  // Quaternion components + mode
515
- w(this, "scales");
515
+ g(this, "scales");
516
516
  // Scale values (8-bit)
517
- w(this, "means_l");
517
+ g(this, "means_l");
518
518
  // Lower 8 bits of 16-bit means
519
- w(this, "means_u");
519
+ g(this, "means_u");
520
520
  this.ranges = t, this.numSplats = e, this.sh0 = s.sh0, this.quats = s.quats, this.scales = s.scales, this.means_l = s.means_l, this.means_u = s.means_u, this.boundingBox = this.calculateBoundingBox();
521
521
  }
522
522
  calculateBoundingBox() {
@@ -536,29 +536,29 @@ class We {
536
536
  this.sh0.dispose(), this.quats.dispose(), this.scales.dispose(), this.means_l.dispose(), this.means_u.dispose();
537
537
  }
538
538
  }
539
- class Ie {
539
+ class Ee {
540
540
  // RGBA32UI - (Position + Rotation + Scale)
541
541
  // RGBA32UI Texture Content:
542
542
  // .r = Means Lower (RGB)
543
543
  // .g = Means Upper (RGB)
544
544
  // .b = Rotation (RGBA)
545
545
  // .a = Scale (RGB)
546
- constructor(e, t, s, r, n, o, c, f) {
546
+ constructor(e, t, s, r, a, o, i, m) {
547
547
  // Info data - cpu
548
- w(this, "numSplats");
549
- w(this, "textureWidth");
550
- w(this, "textureHeight");
551
- w(this, "ranges");
552
- w(this, "centers");
548
+ g(this, "numSplats");
549
+ g(this, "textureWidth");
550
+ g(this, "textureHeight");
551
+ g(this, "ranges");
552
+ g(this, "centers");
553
553
  // TODO: see if necesary or can be compressed somehow
554
- w(this, "boundingBox");
554
+ g(this, "boundingBox");
555
555
  // GPU Textures
556
- w(this, "packedColor");
556
+ g(this, "packedColor");
557
557
  // RGBA8 - (Color + Opacity)
558
558
  // RGBA8 Texture Content:
559
559
  // .rgb = Color, .a = Opacity
560
- w(this, "packedGeometry");
561
- this.numSplats = e, this.textureWidth = t, this.textureHeight = s, this.boundingBox = f, this.ranges = c, this.centers = r, this.packedColor = o, this.packedGeometry = n;
560
+ g(this, "packedGeometry");
561
+ this.numSplats = e, this.textureWidth = t, this.textureHeight = s, this.boundingBox = m, this.ranges = i, this.centers = r, this.packedColor = o, this.packedGeometry = a;
562
562
  }
563
563
  /**
564
564
  * Optional: Reconstruct a full JS object for a specific splat.
@@ -580,24 +580,24 @@ class we {
580
580
  */
581
581
  // prettier-ignore
582
582
  static packPly(e) {
583
- const t = e.numSplats, s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s), n = s * r, { ranges: o, colorScale: c } = this.calculatePlyRanges(e), f = new Uint32Array(n * 4), g = new Uint8Array(n * 4), m = new u.Quaternion();
583
+ const t = e.numSplats, s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s), a = s * r, { ranges: o, colorScale: i } = this.calculatePlyRanges(e), m = new Uint32Array(a * 4), y = new Uint8Array(a * 4), f = new u.Quaternion();
584
584
  for (let l = 0; l < t; l++) {
585
- const h = l * 4, p = l * 3, v = l * 4, C = e.positions[p + 0], k = e.positions[p + 1], B = e.positions[p + 2], U = this.clamp01(this.norm(C, o.means.min.x, o.means.max.x)), F = this.clamp01(this.norm(k, o.means.min.y, o.means.max.y)), N = this.clamp01(this.norm(B, o.means.min.z, o.means.max.z)), W = U * 65535 | 0, T = F * 65535 | 0, S = N * 65535 | 0;
586
- f[h + 0] = this.pack4Bytes(W & 255, T & 255, S & 255, 0), f[h + 1] = this.pack4Bytes(W >> 8, T >> 8, S >> 8, 0), m.set(e.rotations[v], e.rotations[v + 1], e.rotations[v + 2], e.rotations[v + 3]).normalize();
587
- let z = m.w, E = m.x, y = m.y, b = m.z;
588
- const j = Math.abs(z), L = Math.abs(E), I = Math.abs(y), D = Math.abs(b);
589
- let x = 0, _ = j;
590
- L > _ && (_ = L, x = 1), I > _ && (_ = I, x = 2), D > _ && (_ = D, x = 3), (x === 0 ? z : x === 1 ? E : x === 2 ? y : b) < 0 && (z = -z, E = -E, y = -y, b = -b);
591
- let $ = 0, i = 0, A = 0;
592
- x === 0 && ($ = E, i = y, A = b), x === 1 && ($ = z, i = y, A = b), x === 2 && ($ = z, i = E, A = b), x === 3 && ($ = z, i = E, A = y);
593
- const q = (te) => Math.min(255, Math.max(0, Math.round((0.5 + te / Math.SQRT2) * 255)));
594
- f[h + 2] = this.pack4Bytes(q($), q(i), q(A), x);
595
- const O = this.norm(e.scales[p + 0], o.scales.min.x, o.scales.max.x), R = this.norm(e.scales[p + 1], o.scales.min.y, o.scales.max.y), d = this.norm(e.scales[p + 2], o.scales.min.z, o.scales.max.z);
596
- f[h + 3] = this.pack4Bytes(Math.floor(O * 255), Math.floor(R * 255), Math.floor(d * 255), 0);
597
- const P = this.clamp01(e.colors[p + 0] * c), G = this.clamp01(e.colors[p + 1] * c), M = this.clamp01(e.colors[p + 2] * c), V = (P - 0.5) / de, H = (G - 0.5) / de, Z = (M - 0.5) / de, Q = this.clamp01(this.norm(V, o.sh0.min.x, o.sh0.max.x)), J = this.clamp01(this.norm(H, o.sh0.min.y, o.sh0.max.y)), K = this.clamp01(this.norm(Z, o.sh0.min.z, o.sh0.max.z)), ee = this.clamp01(e.opacities[l]);
598
- g[h + 0] = Math.round(Q * 255), g[h + 1] = Math.round(J * 255), g[h + 2] = Math.round(K * 255), g[h + 3] = Math.round(ee * 255);
585
+ const h = l * 4, p = l * 3, v = l * 4, k = e.positions[p + 0], _ = e.positions[p + 1], z = e.positions[p + 2], V = this.clamp01(this.norm(k, o.means.min.x, o.means.max.x)), q = this.clamp01(this.norm(_, o.means.min.y, o.means.max.y)), j = this.clamp01(this.norm(z, o.means.min.z, o.means.max.z)), W = V * 65535 | 0, T = q * 65535 | 0, S = j * 65535 | 0;
586
+ m[h + 0] = this.pack4Bytes(W & 255, T & 255, S & 255, 0), m[h + 1] = this.pack4Bytes(W >> 8, T >> 8, S >> 8, 0), f.set(e.rotations[v], e.rotations[v + 1], e.rotations[v + 2], e.rotations[v + 3]).normalize();
587
+ let R = f.w, C = f.x, w = f.y, b = f.z;
588
+ const N = Math.abs(R), L = Math.abs(C), E = Math.abs(w), B = Math.abs(b);
589
+ let x = 0, P = N;
590
+ L > P && (P = L, x = 1), E > P && (P = E, x = 2), B > P && (P = B, x = 3), (x === 0 ? R : x === 1 ? C : x === 2 ? w : b) < 0 && (R = -R, C = -C, w = -w, b = -b);
591
+ let $ = 0, c = 0, A = 0;
592
+ x === 0 && ($ = C, c = w, A = b), x === 1 && ($ = R, c = w, A = b), x === 2 && ($ = R, c = C, A = b), x === 3 && ($ = R, c = C, A = w);
593
+ const O = (te) => Math.min(255, Math.max(0, Math.round((0.5 + te / Math.SQRT2) * 255)));
594
+ m[h + 2] = this.pack4Bytes(O($), O(c), O(A), x);
595
+ const F = this.norm(e.scales[p + 0], o.scales.min.x, o.scales.max.x), I = this.norm(e.scales[p + 1], o.scales.min.y, o.scales.max.y), d = this.norm(e.scales[p + 2], o.scales.min.z, o.scales.max.z);
596
+ m[h + 3] = this.pack4Bytes(Math.floor(F * 255), Math.floor(I * 255), Math.floor(d * 255), 0);
597
+ const D = this.clamp01(e.colors[p + 0] * i), G = this.clamp01(e.colors[p + 1] * i), M = this.clamp01(e.colors[p + 2] * i), U = (D - 0.5) / de, X = (G - 0.5) / de, Z = (M - 0.5) / de, Q = this.clamp01(this.norm(U, o.sh0.min.x, o.sh0.max.x)), J = this.clamp01(this.norm(X, o.sh0.min.y, o.sh0.max.y)), K = this.clamp01(this.norm(Z, o.sh0.min.z, o.sh0.max.z)), ee = this.clamp01(e.opacities[l]);
598
+ y[h + 0] = Math.round(Q * 255), y[h + 1] = Math.round(J * 255), y[h + 2] = Math.round(K * 255), y[h + 3] = Math.round(ee * 255);
599
599
  }
600
- return new Ie(t, s, r, e.positions, f, g, o, e.boundingBox);
600
+ return new Ee(t, s, r, e.positions, m, y, o, e.boundingBox);
601
601
  }
602
602
  /**
603
603
  * Packs SOGS data.
@@ -606,104 +606,104 @@ class we {
606
606
  */
607
607
  // prettier-ignore
608
608
  static packSogs(e) {
609
- var y, b, j;
609
+ var w, b, N;
610
610
  const t = e.numSplats;
611
611
  let s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s);
612
- const n = ((y = e.means_l) == null ? void 0 : y.image) ?? ((b = e.sh0) == null ? void 0 : b.image) ?? ((j = e.quats) == null ? void 0 : j.image);
613
- n && typeof n.width == "number" && typeof n.height == "number" && (s = n.width, r = n.height);
612
+ const a = ((w = e.means_l) == null ? void 0 : w.image) ?? ((b = e.sh0) == null ? void 0 : b.image) ?? ((N = e.quats) == null ? void 0 : N.image);
613
+ a && typeof a.width == "number" && typeof a.height == "number" && (s = a.width, r = a.height);
614
614
  const o = s * r;
615
615
  if (o < t) throw new Error(`SOG v1 texture too small: ${s}x${r}=${o} < count=${t}`);
616
- const c = this.convertSogsRanges(e.ranges), f = e.ranges.means.mins[0], g = e.ranges.means.mins[1], m = e.ranges.means.mins[2], l = e.ranges.means.maxs[0], h = e.ranges.means.maxs[1], p = e.ranges.means.maxs[2], v = (L) => Math.sign(L) * (Math.exp(Math.abs(L)) - 1), C = new u.Vector3(
617
- v(f),
618
- v(g),
619
- v(m)
620
- ), k = new u.Vector3(
616
+ const i = this.convertSogsRanges(e.ranges), m = e.ranges.means.mins[0], y = e.ranges.means.mins[1], f = e.ranges.means.mins[2], l = e.ranges.means.maxs[0], h = e.ranges.means.maxs[1], p = e.ranges.means.maxs[2], v = (L) => Math.sign(L) * (Math.exp(Math.abs(L)) - 1), k = new u.Vector3(
617
+ v(m),
618
+ v(y),
619
+ v(f)
620
+ ), _ = new u.Vector3(
621
621
  v(l),
622
622
  v(h),
623
623
  v(p)
624
624
  );
625
- c.means.min.copy(C), c.means.max.copy(k);
626
- const B = e, U = this.getPixels(B.means_l), F = this.getPixels(B.means_u), N = this.getPixels(B.quats), W = this.getPixels(B.scales), T = this.getPixels(B.sh0), S = new Uint32Array(o * 4), z = new Uint8Array(o * 4), E = new Float32Array(t * 3);
625
+ i.means.min.copy(k), i.means.max.copy(_);
626
+ const z = e, V = this.getPixels(z.means_l), q = this.getPixels(z.means_u), j = this.getPixels(z.quats), W = this.getPixels(z.scales), T = this.getPixels(z.sh0), S = new Uint32Array(o * 4), R = new Uint8Array(o * 4), C = new Float32Array(t * 3);
627
627
  for (let L = 0; L < t; L++) {
628
- const I = L * 4, D = F[I + 0], x = U[I + 0], _ = F[I + 1], X = U[I + 1], $ = F[I + 2], i = U[I + 2], A = (D << 8 | x) / 65535, q = (_ << 8 | X) / 65535, O = ($ << 8 | i) / 65535, R = this.sogsDecode(A, f, l), d = this.sogsDecode(q, g, h), P = this.sogsDecode(O, m, p);
629
- E[L * 3 + 0] = R, E[L * 3 + 1] = d, E[L * 3 + 2] = P;
630
- const G = this.clamp01(this.norm(R, C.x, k.x)) * 65535 | 0, M = this.clamp01(this.norm(d, C.y, k.y)) * 65535 | 0, V = this.clamp01(this.norm(P, C.z, k.z)) * 65535 | 0;
631
- S[I + 0] = this.pack4Bytes(G & 255, M & 255, V & 255, 0), S[I + 1] = this.pack4Bytes(G >> 8, M >> 8, V >> 8, 0), S[I + 3] = this.pack4Bytes(W[I], W[I + 1], W[I + 2], 0);
632
- const Z = N[I + 3] - 252;
633
- S[I + 2] = this.pack4Bytes(N[I + 0], N[I + 1], N[I + 2], Z), z[I + 0] = T[I], z[I + 1] = T[I + 1], z[I + 2] = T[I + 2];
634
- const Q = T[I + 3] / 255, J = e.ranges.sh0.mins[3] + (e.ranges.sh0.maxs[3] - e.ranges.sh0.mins[3]) * Q, K = 1 / (1 + Math.exp(-J));
635
- z[I + 3] = Math.round(Math.max(0, Math.min(1, K)) * 255);
628
+ const E = L * 4, B = q[E + 0], x = V[E + 0], P = q[E + 1], H = V[E + 1], $ = q[E + 2], c = V[E + 2], A = (B << 8 | x) / 65535, O = (P << 8 | H) / 65535, F = ($ << 8 | c) / 65535, I = this.sogsDecode(A, m, l), d = this.sogsDecode(O, y, h), D = this.sogsDecode(F, f, p);
629
+ C[L * 3 + 0] = I, C[L * 3 + 1] = d, C[L * 3 + 2] = D;
630
+ const G = this.clamp01(this.norm(I, k.x, _.x)) * 65535 | 0, M = this.clamp01(this.norm(d, k.y, _.y)) * 65535 | 0, U = this.clamp01(this.norm(D, k.z, _.z)) * 65535 | 0;
631
+ S[E + 0] = this.pack4Bytes(G & 255, M & 255, U & 255, 0), S[E + 1] = this.pack4Bytes(G >> 8, M >> 8, U >> 8, 0), S[E + 3] = this.pack4Bytes(W[E], W[E + 1], W[E + 2], 0);
632
+ const Z = j[E + 3] - 252;
633
+ S[E + 2] = this.pack4Bytes(j[E + 0], j[E + 1], j[E + 2], Z), R[E + 0] = T[E], R[E + 1] = T[E + 1], R[E + 2] = T[E + 2];
634
+ const Q = T[E + 3] / 255, J = e.ranges.sh0.mins[3] + (e.ranges.sh0.maxs[3] - e.ranges.sh0.mins[3]) * Q, K = 1 / (1 + Math.exp(-J));
635
+ R[E + 3] = Math.round(Math.max(0, Math.min(1, K)) * 255);
636
636
  }
637
- return new Ie(t, s, r, E, S, z, c, e.boundingBox);
637
+ return new Ee(t, s, r, C, S, R, i, e.boundingBox);
638
638
  }
639
639
  /**
640
640
  * Packs SOG V2 data.
641
641
  */
642
642
  static packSog2(e) {
643
- var j, L, I;
643
+ var N, L, E;
644
644
  const t = e.numSplats;
645
645
  let s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s);
646
- const n = ((j = e.means_l) == null ? void 0 : j.image) ?? ((L = e.sh0) == null ? void 0 : L.image) ?? ((I = e.quats) == null ? void 0 : I.image);
647
- n && typeof n.width == "number" && typeof n.height == "number" && (s = n.width, r = n.height);
646
+ const a = ((N = e.means_l) == null ? void 0 : N.image) ?? ((L = e.sh0) == null ? void 0 : L.image) ?? ((E = e.quats) == null ? void 0 : E.image);
647
+ a && typeof a.width == "number" && typeof a.height == "number" && (s = a.width, r = a.height);
648
648
  const o = s * r;
649
649
  if (o < t) throw new Error(`SOG v2 texture too small: ${s}x${r}=${o} < count=${t}`);
650
- const c = e.ranges.means.mins[0], f = e.ranges.means.mins[1], g = e.ranges.means.mins[2], m = e.ranges.means.maxs[0], l = e.ranges.means.maxs[1], h = e.ranges.means.maxs[2], p = (D) => Math.sign(D) * (Math.exp(Math.abs(D)) - 1), v = new u.Vector3(
651
- p(c),
652
- p(f),
653
- p(g)
654
- ), C = new u.Vector3(
650
+ const i = e.ranges.means.mins[0], m = e.ranges.means.mins[1], y = e.ranges.means.mins[2], f = e.ranges.means.maxs[0], l = e.ranges.means.maxs[1], h = e.ranges.means.maxs[2], p = (B) => Math.sign(B) * (Math.exp(Math.abs(B)) - 1), v = new u.Vector3(
651
+ p(i),
655
652
  p(m),
653
+ p(y)
654
+ ), k = new u.Vector3(
655
+ p(f),
656
656
  p(l),
657
657
  p(h)
658
- ), k = (D) => {
659
- let x = 1 / 0, _ = -1 / 0;
660
- for (const i of D)
661
- Number.isFinite(i) && (x = Math.min(x, i), _ = Math.max(_, i));
662
- (!Number.isFinite(x) || !Number.isFinite(_)) && (x = 0, _ = 1);
663
- const X = _ - x || 1, $ = new Uint8Array(256);
664
- for (let i = 0; i < 256; i++) {
665
- const q = ((i < D.length && Number.isFinite(D[i]) ? D[i] : x + (_ - x) * (i / 255)) - x) / X, O = Math.max(0, Math.min(255, Math.round(q * 255)));
666
- $[i] = O;
658
+ ), _ = (B) => {
659
+ let x = 1 / 0, P = -1 / 0;
660
+ for (const c of B)
661
+ Number.isFinite(c) && (x = Math.min(x, c), P = Math.max(P, c));
662
+ (!Number.isFinite(x) || !Number.isFinite(P)) && (x = 0, P = 1);
663
+ const H = P - x || 1, $ = new Uint8Array(256);
664
+ for (let c = 0; c < 256; c++) {
665
+ const O = ((c < B.length && Number.isFinite(B[c]) ? B[c] : x + (P - x) * (c / 255)) - x) / H, F = Math.max(0, Math.min(255, Math.round(O * 255)));
666
+ $[c] = F;
667
667
  }
668
- return { cbMin: x, cbMax: _, lut: $ };
669
- }, B = k(e.ranges.scales.codebook), U = k(e.ranges.sh0.codebook), F = {
670
- means: { min: v.clone(), max: C.clone() },
668
+ return { cbMin: x, cbMax: P, lut: $ };
669
+ }, z = _(e.ranges.scales.codebook), V = _(e.ranges.sh0.codebook), q = {
670
+ means: { min: v.clone(), max: k.clone() },
671
671
  scales: {
672
672
  min: new u.Vector3(
673
- B.cbMin,
674
- B.cbMin,
675
- B.cbMin
673
+ z.cbMin,
674
+ z.cbMin,
675
+ z.cbMin
676
676
  ),
677
677
  max: new u.Vector3(
678
- B.cbMax,
679
- B.cbMax,
680
- B.cbMax
678
+ z.cbMax,
679
+ z.cbMax,
680
+ z.cbMax
681
681
  )
682
682
  },
683
683
  sh0: {
684
684
  min: new u.Vector3(
685
- U.cbMin,
686
- U.cbMin,
687
- U.cbMin
685
+ V.cbMin,
686
+ V.cbMin,
687
+ V.cbMin
688
688
  ),
689
689
  max: new u.Vector3(
690
- U.cbMax,
691
- U.cbMax,
692
- U.cbMax
690
+ V.cbMax,
691
+ V.cbMax,
692
+ V.cbMax
693
693
  )
694
694
  }
695
- }, N = this.getPixels(e.means_l), W = this.getPixels(e.means_u), T = this.getPixels(e.quats), S = this.getPixels(e.scales), z = this.getPixels(e.sh0), E = new Uint32Array(o * 4), y = new Uint8Array(o * 4), b = new Float32Array(t * 3);
696
- for (let D = 0; D < t; D++) {
697
- const x = D * 4, _ = W[x + 0], X = N[x + 0], $ = W[x + 1], i = N[x + 1], A = W[x + 2], q = N[x + 2], O = (_ << 8 | X) / 65535, R = ($ << 8 | i) / 65535, d = (A << 8 | q) / 65535, P = this.sogsDecode(O, c, m), G = this.sogsDecode(R, f, l), M = this.sogsDecode(d, g, h);
698
- b[D * 3 + 0] = P, b[D * 3 + 1] = G, b[D * 3 + 2] = M;
699
- const V = this.clamp01(this.norm(P, v.x, C.x)) * 65535 | 0, H = this.clamp01(this.norm(G, v.y, C.y)) * 65535 | 0, Z = this.clamp01(this.norm(M, v.z, C.z)) * 65535 | 0;
700
- E[x + 0] = this.pack4Bytes(V & 255, H & 255, Z & 255, 0), E[x + 1] = this.pack4Bytes(V >> 8, H >> 8, Z >> 8, 0);
695
+ }, j = this.getPixels(e.means_l), W = this.getPixels(e.means_u), T = this.getPixels(e.quats), S = this.getPixels(e.scales), R = this.getPixels(e.sh0), C = new Uint32Array(o * 4), w = new Uint8Array(o * 4), b = new Float32Array(t * 3);
696
+ for (let B = 0; B < t; B++) {
697
+ const x = B * 4, P = W[x + 0], H = j[x + 0], $ = W[x + 1], c = j[x + 1], A = W[x + 2], O = j[x + 2], F = (P << 8 | H) / 65535, I = ($ << 8 | c) / 65535, d = (A << 8 | O) / 65535, D = this.sogsDecode(F, i, f), G = this.sogsDecode(I, m, l), M = this.sogsDecode(d, y, h);
698
+ b[B * 3 + 0] = D, b[B * 3 + 1] = G, b[B * 3 + 2] = M;
699
+ const U = this.clamp01(this.norm(D, v.x, k.x)) * 65535 | 0, X = this.clamp01(this.norm(G, v.y, k.y)) * 65535 | 0, Z = this.clamp01(this.norm(M, v.z, k.z)) * 65535 | 0;
700
+ C[x + 0] = this.pack4Bytes(U & 255, X & 255, Z & 255, 0), C[x + 1] = this.pack4Bytes(U >> 8, X >> 8, Z >> 8, 0);
701
701
  const J = T[x + 3] - 252 & 3;
702
- E[x + 2] = this.pack4Bytes(T[x + 0], T[x + 1], T[x + 2], J);
703
- const K = B.lut[S[x + 0]], ee = B.lut[S[x + 1]], te = B.lut[S[x + 2]];
704
- E[x + 3] = this.pack4Bytes(K, ee, te, 0), y[x + 0] = U.lut[z[x + 0]], y[x + 1] = U.lut[z[x + 1]], y[x + 2] = U.lut[z[x + 2]], y[x + 3] = z[x + 3];
702
+ C[x + 2] = this.pack4Bytes(T[x + 0], T[x + 1], T[x + 2], J);
703
+ const K = z.lut[S[x + 0]], ee = z.lut[S[x + 1]], te = z.lut[S[x + 2]];
704
+ C[x + 3] = this.pack4Bytes(K, ee, te, 0), w[x + 0] = V.lut[R[x + 0]], w[x + 1] = V.lut[R[x + 1]], w[x + 2] = V.lut[R[x + 2]], w[x + 3] = R[x + 3];
705
705
  }
706
- return new Ie(t, s, r, b, E, y, F, e.boundingBox);
706
+ return new Ee(t, s, r, b, C, w, q, e.boundingBox);
707
707
  }
708
708
  // --- Helpers ---
709
709
  // prettier-ignore
@@ -714,9 +714,9 @@ class we {
714
714
  static getPixels(e) {
715
715
  const t = e.image, s = t.width, r = t.height;
716
716
  if (t.data && (t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray)) return new Uint8Array(t.data);
717
- const n = document.createElement("canvas");
718
- n.width = s, n.height = r;
719
- const o = n.getContext("2d", { willReadFrequently: !0 });
717
+ const a = document.createElement("canvas");
718
+ a.width = s, a.height = r;
719
+ const o = a.getContext("2d", { willReadFrequently: !0 });
720
720
  if (!o) throw new Error("Canvas init failed");
721
721
  return o.drawImage(t, 0, 0), new Uint8Array(o.getImageData(0, 0, s, r).data);
722
722
  }
@@ -729,28 +729,28 @@ class we {
729
729
  };
730
730
  }
731
731
  static calculatePlyRanges(e) {
732
- const t = new u.Vector3(1 / 0, 1 / 0, 1 / 0), s = new u.Vector3(-1 / 0, -1 / 0, -1 / 0), r = new u.Vector3(1 / 0, 1 / 0, 1 / 0), n = new u.Vector3(-1 / 0, -1 / 0, -1 / 0), o = new u.Vector3(1 / 0, 1 / 0, 1 / 0), c = new u.Vector3(-1 / 0, -1 / 0, -1 / 0);
733
- let f = 0;
734
- for (let m = 0; m < e.numSplats; m++) {
735
- const l = m * 3, h = e.positions[l + 0], p = e.positions[l + 1], v = e.positions[l + 2];
736
- t.x = Math.min(t.x, h), s.x = Math.max(s.x, h), t.y = Math.min(t.y, p), s.y = Math.max(s.y, p), t.z = Math.min(t.z, v), s.z = Math.max(s.z, v), r.x = Math.min(r.x, e.scales[l]), n.x = Math.max(n.x, e.scales[l]), r.y = Math.min(r.y, e.scales[l + 1]), n.y = Math.max(n.y, e.scales[l + 1]), r.z = Math.min(r.z, e.scales[l + 2]), n.z = Math.max(n.z, e.scales[l + 2]), f = Math.max(
737
- f,
732
+ const t = new u.Vector3(1 / 0, 1 / 0, 1 / 0), s = new u.Vector3(-1 / 0, -1 / 0, -1 / 0), r = new u.Vector3(1 / 0, 1 / 0, 1 / 0), a = new u.Vector3(-1 / 0, -1 / 0, -1 / 0), o = new u.Vector3(1 / 0, 1 / 0, 1 / 0), i = new u.Vector3(-1 / 0, -1 / 0, -1 / 0);
733
+ let m = 0;
734
+ for (let f = 0; f < e.numSplats; f++) {
735
+ const l = f * 3, h = e.positions[l + 0], p = e.positions[l + 1], v = e.positions[l + 2];
736
+ t.x = Math.min(t.x, h), s.x = Math.max(s.x, h), t.y = Math.min(t.y, p), s.y = Math.max(s.y, p), t.z = Math.min(t.z, v), s.z = Math.max(s.z, v), r.x = Math.min(r.x, e.scales[l]), a.x = Math.max(a.x, e.scales[l]), r.y = Math.min(r.y, e.scales[l + 1]), a.y = Math.max(a.y, e.scales[l + 1]), r.z = Math.min(r.z, e.scales[l + 2]), a.z = Math.max(a.z, e.scales[l + 2]), m = Math.max(
737
+ m,
738
738
  e.colors[l],
739
739
  e.colors[l + 1],
740
740
  e.colors[l + 2]
741
741
  );
742
742
  }
743
- const g = f > 1.5 ? 1 / 255 : 1;
744
- for (let m = 0; m < e.numSplats; m++) {
745
- const l = m * 3, h = this.clamp01(e.colors[l + 0] * g), p = this.clamp01(e.colors[l + 1] * g), v = this.clamp01(e.colors[l + 2] * g), C = (h - 0.5) / de, k = (p - 0.5) / de, B = (v - 0.5) / de;
746
- o.x = Math.min(o.x, C), c.x = Math.max(c.x, C), o.y = Math.min(o.y, k), c.y = Math.max(c.y, k), o.z = Math.min(o.z, B), c.z = Math.max(c.z, B);
743
+ const y = m > 1.5 ? 1 / 255 : 1;
744
+ for (let f = 0; f < e.numSplats; f++) {
745
+ const l = f * 3, h = this.clamp01(e.colors[l + 0] * y), p = this.clamp01(e.colors[l + 1] * y), v = this.clamp01(e.colors[l + 2] * y), k = (h - 0.5) / de, _ = (p - 0.5) / de, z = (v - 0.5) / de;
746
+ o.x = Math.min(o.x, k), i.x = Math.max(i.x, k), o.y = Math.min(o.y, _), i.y = Math.max(i.y, _), o.z = Math.min(o.z, z), i.z = Math.max(i.z, z);
747
747
  }
748
748
  return {
749
- colorScale: g,
749
+ colorScale: y,
750
750
  ranges: {
751
- sh0: { min: o, max: c },
751
+ sh0: { min: o, max: i },
752
752
  means: { min: t, max: s },
753
- scales: { min: r, max: n }
753
+ scales: { min: r, max: a }
754
754
  }
755
755
  };
756
756
  }
@@ -769,40 +769,40 @@ class we {
769
769
  return Math.sign(r) * (Math.exp(Math.abs(r)) - 1);
770
770
  }
771
771
  }
772
- class lt extends u.Loader {
773
- constructor(t) {
772
+ class ft extends u.Loader {
773
+ constructor(t, s) {
774
774
  super(t);
775
- w(this, "requestId", 0);
776
- w(this, "worker");
777
- w(this, "pendingCallbacks", /* @__PURE__ */ new Map());
778
- this.withCredentials = !0;
779
- const s = this.createWorkerCode(), r = new Blob([s], { type: "application/javascript" });
780
- this.worker = new Worker(URL.createObjectURL(r)), this.worker.onmessage = this.onWorkerMessage.bind(this);
775
+ g(this, "requestId", 0);
776
+ g(this, "worker");
777
+ g(this, "pendingCallbacks", /* @__PURE__ */ new Map());
778
+ this.withCredentials = (s == null ? void 0 : s.withCredentials) ?? !1;
779
+ const r = this.createWorkerCode(), a = new Blob([r], { type: "application/javascript" });
780
+ this.worker = new Worker(URL.createObjectURL(a)), this.worker.onmessage = this.onWorkerMessage.bind(this);
781
781
  }
782
782
  /**
783
783
  * Handles messages received from the parsing worker
784
784
  * @param event The message event from the worker
785
785
  */
786
786
  onWorkerMessage(t) {
787
- const { requestId: s, error: r, result: n } = t.data, o = this.pendingCallbacks.get(s);
787
+ const { requestId: s, error: r, result: a } = t.data, o = this.pendingCallbacks.get(s);
788
788
  if (!o) return console.warn(`PlyLoader: Received response for unknown request ${s}`);
789
789
  if (this.pendingCallbacks.delete(s), r) return o.reject(new Error(r));
790
- if (!n) return o.reject(new Error("Worker returned no result"));
790
+ if (!a) return o.reject(new Error("Worker returned no result"));
791
791
  try {
792
- const c = new ct(0);
793
- c.numSplats = n.numSplats, c.positions = new Float32Array(n.positions), c.rotations = new Float32Array(n.rotations), c.scales = new Float32Array(n.scales), c.colors = new Float32Array(n.colors), c.opacities = new Float32Array(n.opacities), c.boundingBox.min.set(
794
- n.boundingBox.minX,
795
- n.boundingBox.minY,
796
- n.boundingBox.minZ
797
- ), c.boundingBox.max.set(
798
- n.boundingBox.maxX,
799
- n.boundingBox.maxY,
800
- n.boundingBox.maxZ
792
+ const i = new mt(0);
793
+ i.numSplats = a.numSplats, i.positions = new Float32Array(a.positions), i.rotations = new Float32Array(a.rotations), i.scales = new Float32Array(a.scales), i.colors = new Float32Array(a.colors), i.opacities = new Float32Array(a.opacities), i.boundingBox.min.set(
794
+ a.boundingBox.minX,
795
+ a.boundingBox.minY,
796
+ a.boundingBox.minZ
797
+ ), i.boundingBox.max.set(
798
+ a.boundingBox.maxX,
799
+ a.boundingBox.maxY,
800
+ a.boundingBox.maxZ
801
801
  ), this.worker.terminate();
802
- const f = we.packPly(c);
803
- c.dispose(), o.resolve(f);
804
- } catch (c) {
805
- o.reject(c);
802
+ const m = we.packPly(i);
803
+ i.dispose(), o.resolve(m);
804
+ } catch (i) {
805
+ o.reject(i);
806
806
  }
807
807
  }
808
808
  /**
@@ -812,19 +812,19 @@ class lt extends u.Loader {
812
812
  * @param onProgress Optional progress callback
813
813
  * @param onError Optional error callback
814
814
  */
815
- load(t, s, r, n) {
815
+ load(t, s, r, a) {
816
816
  const o = new u.FileLoader(this.manager);
817
817
  o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
818
818
  t,
819
- (c) => {
820
- this.parseAsync(c).then((f) => {
821
- s && s(f);
822
- }).catch((f) => {
823
- n ? n(f) : console.error(f), this.manager.itemError(t);
819
+ (i) => {
820
+ this.parseAsync(i).then((m) => {
821
+ s && s(m);
822
+ }).catch((m) => {
823
+ a ? a(m) : console.error(m), this.manager.itemError(t);
824
824
  });
825
825
  },
826
826
  r,
827
- n
827
+ a
828
828
  );
829
829
  }
830
830
  /**
@@ -834,18 +834,18 @@ class lt extends u.Loader {
834
834
  * @returns A Promise that resolves with the parsed SplatData
835
835
  */
836
836
  loadAsync(t, s) {
837
- return new Promise((r, n) => {
837
+ return new Promise((r, a) => {
838
838
  const o = new u.FileLoader(this.manager);
839
839
  o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
840
840
  t,
841
- (c) => {
842
- this.parseAsync(c).then(r).catch((f) => {
843
- n(f), this.manager.itemError(t);
841
+ (i) => {
842
+ this.parseAsync(i).then(r).catch((m) => {
843
+ a(m), this.manager.itemError(t);
844
844
  });
845
845
  },
846
846
  s,
847
- (c) => {
848
- n(c), this.manager.itemError(t);
847
+ (i) => {
848
+ a(i), this.manager.itemError(t);
849
849
  }
850
850
  );
851
851
  });
@@ -857,10 +857,10 @@ class lt extends u.Loader {
857
857
  */
858
858
  parseAsync(t) {
859
859
  return new Promise((s, r) => {
860
- const n = this.requestId++;
861
- this.pendingCallbacks.set(n, { resolve: s, reject: r });
860
+ const a = this.requestId++;
861
+ this.pendingCallbacks.set(a, { resolve: s, reject: r });
862
862
  const o = {
863
- requestId: n,
863
+ requestId: a,
864
864
  buffer: t
865
865
  };
866
866
  this.worker.postMessage(o, [t]);
@@ -879,70 +879,70 @@ class lt extends u.Loader {
879
879
  createWorkerCode() {
880
880
  return `(${(function() {
881
881
  self.onmessage = (r) => {
882
- const { requestId: n, buffer: o } = r.data;
882
+ const { requestId: a, buffer: o } = r.data;
883
883
  try {
884
- const c = s(o), f = {
885
- requestId: n,
886
- result: c
884
+ const i = s(o), m = {
885
+ requestId: a,
886
+ result: i
887
887
  };
888
- self.postMessage(f, [
889
- c.positions,
890
- c.rotations,
891
- c.scales,
892
- c.colors,
893
- c.opacities
888
+ self.postMessage(m, [
889
+ i.positions,
890
+ i.rotations,
891
+ i.scales,
892
+ i.colors,
893
+ i.opacities
894
894
  ]);
895
- } catch (c) {
896
- const f = {
897
- requestId: n,
898
- error: c instanceof Error ? c.message : String(c)
895
+ } catch (i) {
896
+ const m = {
897
+ requestId: a,
898
+ error: i instanceof Error ? i.message : String(i)
899
899
  };
900
- self.postMessage(f);
900
+ self.postMessage(m);
901
901
  }
902
902
  };
903
903
  function s(r) {
904
- const n = new TextDecoder(), o = new Uint8Array(r), c = [112, 108, 121, 10], f = `
904
+ const a = new TextDecoder(), o = new Uint8Array(r), i = [112, 108, 121, 10], m = `
905
905
  end_header
906
906
  `;
907
- for (let R = 0; R < c.length; R++)
908
- if (o[R] !== c[R])
907
+ for (let I = 0; I < i.length; I++)
908
+ if (o[I] !== i[I])
909
909
  throw new Error(
910
910
  "Invalid PLY file: Missing magic bytes"
911
911
  );
912
- let g = 0;
913
- for (let R = 0; R < o.length - f.length; R++) {
912
+ let y = 0;
913
+ for (let I = 0; I < o.length - m.length; I++) {
914
914
  let d = !0;
915
- for (let P = 0; P < f.length; P++)
916
- if (o[R + P] !== f.charCodeAt(P)) {
915
+ for (let D = 0; D < m.length; D++)
916
+ if (o[I + D] !== m.charCodeAt(D)) {
917
917
  d = !1;
918
918
  break;
919
919
  }
920
920
  if (d) {
921
- g = R + f.length;
921
+ y = I + m.length;
922
922
  break;
923
923
  }
924
924
  }
925
- if (g === 0)
925
+ if (y === 0)
926
926
  throw new Error(
927
927
  "Invalid PLY file: Could not find end of header"
928
928
  );
929
- const l = n.decode(
930
- o.subarray(0, g)
929
+ const l = a.decode(
930
+ o.subarray(0, y)
931
931
  ).split(`
932
932
  `), h = [];
933
933
  let p = null;
934
- for (let R = 1; R < l.length; R++) {
935
- const d = l[R].trim();
934
+ for (let I = 1; I < l.length; I++) {
935
+ const d = l[I].trim();
936
936
  if (d === "" || d === "end_header") continue;
937
- const P = d.split(" ");
938
- switch (P[0]) {
937
+ const D = d.split(" ");
938
+ switch (D[0]) {
939
939
  case "format":
940
- p = P[1];
940
+ p = D[1];
941
941
  break;
942
942
  case "element":
943
943
  h.push({
944
- name: P[1],
945
- count: parseInt(P[2], 10),
944
+ name: D[1],
945
+ count: parseInt(D[2], 10),
946
946
  properties: []
947
947
  });
948
948
  break;
@@ -952,29 +952,29 @@ end_header
952
952
  "Invalid PLY file: Property without element"
953
953
  );
954
954
  h[h.length - 1].properties.push({
955
- type: P[1],
956
- name: P[2]
955
+ type: D[1],
956
+ name: D[2]
957
957
  });
958
958
  break;
959
959
  }
960
960
  }
961
961
  if (p !== "binary_little_endian")
962
962
  throw new Error(`Unsupported PLY format: ${p}`);
963
- const v = h.find((R) => R.name === "vertex");
963
+ const v = h.find((I) => I.name === "vertex");
964
964
  if (!v)
965
965
  throw new Error(
966
966
  "Invalid PLY file: No vertex element found"
967
967
  );
968
- const C = v.count, k = new Float32Array(C * 3), B = new Float32Array(C * 4), U = new Float32Array(C * 3), F = new Float32Array(C * 3), N = new Float32Array(C), W = new DataView(r);
969
- let T = g;
970
- const S = (R) => v.properties.findIndex(
971
- (d) => d.name === R
972
- ), z = S("x"), E = S("y"), y = S("z"), b = [
968
+ const k = v.count, _ = new Float32Array(k * 3), z = new Float32Array(k * 4), V = new Float32Array(k * 3), q = new Float32Array(k * 3), j = new Float32Array(k), W = new DataView(r);
969
+ let T = y;
970
+ const S = (I) => v.properties.findIndex(
971
+ (d) => d.name === I
972
+ ), R = S("x"), C = S("y"), w = S("z"), b = [
973
973
  S("rot_0"),
974
974
  S("rot_1"),
975
975
  S("rot_2"),
976
976
  S("rot_3")
977
- ], j = [
977
+ ], N = [
978
978
  S("scale_0"),
979
979
  S("scale_1"),
980
980
  S("scale_2")
@@ -982,31 +982,31 @@ end_header
982
982
  S("f_dc_0"),
983
983
  S("f_dc_1"),
984
984
  S("f_dc_2")
985
- ], I = S("opacity");
985
+ ], E = S("opacity");
986
986
  if ([
987
- z,
988
- E,
989
- y,
987
+ R,
988
+ C,
989
+ w,
990
990
  ...b,
991
- ...j,
991
+ ...N,
992
992
  ...L,
993
- I
994
- ].some((R) => R === -1))
993
+ E
994
+ ].some((I) => I === -1))
995
995
  throw new Error(
996
996
  "Invalid PLY file: Missing required properties"
997
997
  );
998
- const x = 0.28209479177387814, _ = (R) => {
999
- if (R > 0) return 1 / (1 + Math.exp(-R));
1000
- const d = Math.exp(R);
998
+ const x = 0.28209479177387814, P = (I) => {
999
+ if (I > 0) return 1 / (1 + Math.exp(-I));
1000
+ const d = Math.exp(I);
1001
1001
  return d / (1 + d);
1002
1002
  };
1003
- let X = 1 / 0, $ = 1 / 0, i = 1 / 0, A = -1 / 0, q = -1 / 0, O = -1 / 0;
1004
- for (let R = 0; R < C; R++) {
1003
+ let H = 1 / 0, $ = 1 / 0, c = 1 / 0, A = -1 / 0, O = -1 / 0, F = -1 / 0;
1004
+ for (let I = 0; I < k; I++) {
1005
1005
  const d = [];
1006
- for (let Ce = 0; Ce < v.properties.length; Ce++) {
1007
- const Fe = v.properties[Ce].type;
1006
+ for (let ke = 0; ke < v.properties.length; ke++) {
1007
+ const qe = v.properties[ke].type;
1008
1008
  let ce;
1009
- switch (Fe) {
1009
+ switch (qe) {
1010
1010
  case "char":
1011
1011
  ce = W.getInt8(T), T += 1;
1012
1012
  break;
@@ -1033,48 +1033,48 @@ end_header
1033
1033
  break;
1034
1034
  default:
1035
1035
  throw new Error(
1036
- `Unsupported property type: ${Fe}`
1036
+ `Unsupported property type: ${qe}`
1037
1037
  );
1038
1038
  }
1039
1039
  d.push(ce);
1040
1040
  }
1041
- const P = d[z], G = d[E], M = d[y], V = R * 3;
1042
- k[V] = P, k[V + 1] = G, k[V + 2] = M, X = Math.min(X, P), $ = Math.min($, G), i = Math.min(i, M), A = Math.max(A, P), q = Math.max(q, G), O = Math.max(O, M);
1043
- let H = d[b[1]], Z = d[b[2]], Q = d[b[3]], J = d[b[0]];
1041
+ const D = d[R], G = d[C], M = d[w], U = I * 3;
1042
+ _[U] = D, _[U + 1] = G, _[U + 2] = M, H = Math.min(H, D), $ = Math.min($, G), c = Math.min(c, M), A = Math.max(A, D), O = Math.max(O, G), F = Math.max(F, M);
1043
+ let X = d[b[1]], Z = d[b[2]], Q = d[b[3]], J = d[b[0]];
1044
1044
  const K = Math.sqrt(
1045
- H * H + Z * Z + Q * Q + J * J
1045
+ X * X + Z * Z + Q * Q + J * J
1046
1046
  );
1047
- K > 0 && (H /= K, Z /= K, Q /= K, J /= K), J < 0 && (H = -H, Z = -Z, Q = -Q, J = -J);
1048
- const ee = R * 4;
1049
- B[ee] = H, B[ee + 1] = Z, B[ee + 2] = Q, B[ee + 3] = J;
1050
- const te = R * 3;
1051
- U[te] = d[j[0]], U[te + 1] = d[j[1]], U[te + 2] = d[j[2]];
1047
+ K > 0 && (X /= K, Z /= K, Q /= K, J /= K), J < 0 && (X = -X, Z = -Z, Q = -Q, J = -J);
1048
+ const ee = I * 4;
1049
+ z[ee] = X, z[ee + 1] = Z, z[ee + 2] = Q, z[ee + 3] = J;
1050
+ const te = I * 3;
1051
+ V[te] = d[N[0]], V[te + 1] = d[N[1]], V[te + 2] = d[N[2]];
1052
1052
  let me = 0.5 + d[L[0]] * x, fe = 0.5 + d[L[1]] * x, oe = 0.5 + d[L[2]] * x;
1053
1053
  me = Math.max(0, Math.min(1, me)), fe = Math.max(0, Math.min(1, fe)), oe = Math.max(0, Math.min(1, oe));
1054
- const Ee = R * 3;
1055
- F[Ee] = me, F[Ee + 1] = fe, F[Ee + 2] = oe, N[R] = _(d[I]);
1054
+ const Ce = I * 3;
1055
+ q[Ce] = me, q[Ce + 1] = fe, q[Ce + 2] = oe, j[I] = P(d[E]);
1056
1056
  }
1057
1057
  return {
1058
- numSplats: C,
1059
- positions: k.buffer,
1060
- rotations: B.buffer,
1061
- scales: U.buffer,
1062
- colors: F.buffer,
1063
- opacities: N.buffer,
1058
+ numSplats: k,
1059
+ positions: _.buffer,
1060
+ rotations: z.buffer,
1061
+ scales: V.buffer,
1062
+ colors: q.buffer,
1063
+ opacities: j.buffer,
1064
1064
  boundingBox: {
1065
- minX: X,
1065
+ minX: H,
1066
1066
  minY: $,
1067
- minZ: i,
1067
+ minZ: c,
1068
1068
  maxX: A,
1069
- maxY: q,
1070
- maxZ: O
1069
+ maxY: O,
1070
+ maxZ: F
1071
1071
  }
1072
1072
  };
1073
1073
  }
1074
1074
  }).toString()})();`;
1075
1075
  }
1076
1076
  }
1077
- var se = Uint8Array, pe = Uint16Array, ht = Int32Array, Ne = new se([
1077
+ var se = Uint8Array, pe = Uint16Array, dt = Int32Array, He = new se([
1078
1078
  0,
1079
1079
  0,
1080
1080
  0,
@@ -1109,7 +1109,7 @@ var se = Uint8Array, pe = Uint16Array, ht = Int32Array, Ne = new se([
1109
1109
  0,
1110
1110
  /* impossible */
1111
1111
  0
1112
- ]), $e = new se([
1112
+ ]), Xe = new se([
1113
1113
  0,
1114
1114
  0,
1115
1115
  0,
@@ -1143,38 +1143,38 @@ var se = Uint8Array, pe = Uint16Array, ht = Int32Array, Ne = new se([
1143
1143
  /* unused */
1144
1144
  0,
1145
1145
  0
1146
- ]), ut = new se([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Ye = function(a, e) {
1146
+ ]), pt = new se([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Ze = function(n, e) {
1147
1147
  for (var t = new pe(31), s = 0; s < 31; ++s)
1148
- t[s] = e += 1 << a[s - 1];
1149
- for (var r = new ht(t[30]), s = 1; s < 30; ++s)
1150
- for (var n = t[s]; n < t[s + 1]; ++n)
1151
- r[n] = n - t[s] << 5 | s;
1148
+ t[s] = e += 1 << n[s - 1];
1149
+ for (var r = new dt(t[30]), s = 1; s < 30; ++s)
1150
+ for (var a = t[s]; a < t[s + 1]; ++a)
1151
+ r[a] = a - t[s] << 5 | s;
1152
1152
  return { b: t, r };
1153
- }, Xe = Ye(Ne, 2), He = Xe.b, mt = Xe.r;
1154
- He[28] = 258, mt[258] = 28;
1155
- var ft = Ye($e, 0), dt = ft.b, Be = new pe(32768);
1153
+ }, Je = Ze(He, 2), Qe = Je.b, gt = Je.r;
1154
+ Qe[28] = 258, gt[258] = 28;
1155
+ var xt = Ze(Xe, 0), yt = xt.b, ze = new pe(32768);
1156
1156
  for (var Y = 0; Y < 32768; ++Y) {
1157
1157
  var le = (Y & 43690) >> 1 | (Y & 21845) << 1;
1158
- le = (le & 52428) >> 2 | (le & 13107) << 2, le = (le & 61680) >> 4 | (le & 3855) << 4, Be[Y] = ((le & 65280) >> 8 | (le & 255) << 8) >> 1;
1158
+ le = (le & 52428) >> 2 | (le & 13107) << 2, le = (le & 61680) >> 4 | (le & 3855) << 4, ze[Y] = ((le & 65280) >> 8 | (le & 255) << 8) >> 1;
1159
1159
  }
1160
- var ve = function(a, e, t) {
1161
- for (var s = a.length, r = 0, n = new pe(e); r < s; ++r)
1162
- a[r] && ++n[a[r] - 1];
1160
+ var ve = function(n, e, t) {
1161
+ for (var s = n.length, r = 0, a = new pe(e); r < s; ++r)
1162
+ n[r] && ++a[n[r] - 1];
1163
1163
  var o = new pe(e);
1164
1164
  for (r = 1; r < e; ++r)
1165
- o[r] = o[r - 1] + n[r - 1] << 1;
1166
- var c;
1165
+ o[r] = o[r - 1] + a[r - 1] << 1;
1166
+ var i;
1167
1167
  if (t) {
1168
- c = new pe(1 << e);
1169
- var f = 15 - e;
1168
+ i = new pe(1 << e);
1169
+ var m = 15 - e;
1170
1170
  for (r = 0; r < s; ++r)
1171
- if (a[r])
1172
- for (var g = r << 4 | a[r], m = e - a[r], l = o[a[r] - 1]++ << m, h = l | (1 << m) - 1; l <= h; ++l)
1173
- c[Be[l] >> f] = g;
1171
+ if (n[r])
1172
+ for (var y = r << 4 | n[r], f = e - n[r], l = o[n[r] - 1]++ << f, h = l | (1 << f) - 1; l <= h; ++l)
1173
+ i[ze[l] >> m] = y;
1174
1174
  } else
1175
- for (c = new pe(s), r = 0; r < s; ++r)
1176
- a[r] && (c[r] = Be[o[a[r] - 1]++] >> 15 - a[r]);
1177
- return c;
1175
+ for (i = new pe(s), r = 0; r < s; ++r)
1176
+ n[r] && (i[r] = ze[o[n[r] - 1]++] >> 15 - n[r]);
1177
+ return i;
1178
1178
  }, Me = new se(288);
1179
1179
  for (var Y = 0; Y < 144; ++Y)
1180
1180
  Me[Y] = 8;
@@ -1184,24 +1184,24 @@ for (var Y = 256; Y < 280; ++Y)
1184
1184
  Me[Y] = 7;
1185
1185
  for (var Y = 280; Y < 288; ++Y)
1186
1186
  Me[Y] = 8;
1187
- var Ze = new se(32);
1187
+ var Ke = new se(32);
1188
1188
  for (var Y = 0; Y < 32; ++Y)
1189
- Ze[Y] = 5;
1190
- var pt = /* @__PURE__ */ ve(Me, 9, 1), xt = /* @__PURE__ */ ve(Ze, 5, 1), Re = function(a) {
1191
- for (var e = a[0], t = 1; t < a.length; ++t)
1192
- a[t] > e && (e = a[t]);
1189
+ Ke[Y] = 5;
1190
+ var wt = /* @__PURE__ */ ve(Me, 9, 1), vt = /* @__PURE__ */ ve(Ke, 5, 1), Ie = function(n) {
1191
+ for (var e = n[0], t = 1; t < n.length; ++t)
1192
+ n[t] > e && (e = n[t]);
1193
1193
  return e;
1194
- }, ne = function(a, e, t) {
1194
+ }, re = function(n, e, t) {
1195
1195
  var s = e / 8 | 0;
1196
- return (a[s] | a[s + 1] << 8) >> (e & 7) & t;
1197
- }, _e = function(a, e) {
1196
+ return (n[s] | n[s + 1] << 8) >> (e & 7) & t;
1197
+ }, Pe = function(n, e) {
1198
1198
  var t = e / 8 | 0;
1199
- return (a[t] | a[t + 1] << 8 | a[t + 2] << 16) >> (e & 7);
1200
- }, gt = function(a) {
1201
- return (a + 7) / 8 | 0;
1202
- }, qe = function(a, e, t) {
1203
- return (e == null || e < 0) && (e = 0), (t == null || t > a.length) && (t = a.length), new se(a.subarray(e, t));
1204
- }, yt = [
1199
+ return (n[t] | n[t + 1] << 8 | n[t + 2] << 16) >> (e & 7);
1200
+ }, bt = function(n) {
1201
+ return (n + 7) / 8 | 0;
1202
+ }, Oe = function(n, e, t) {
1203
+ return (e == null || e < 0) && (e = 0), (t == null || t > n.length) && (t = n.length), new se(n.subarray(e, t));
1204
+ }, Mt = [
1205
1205
  "unexpected EOF",
1206
1206
  "invalid block type",
1207
1207
  "invalid length/literal",
@@ -1217,263 +1217,263 @@ var pt = /* @__PURE__ */ ve(Me, 9, 1), xt = /* @__PURE__ */ ve(Ze, 5, 1), Re = f
1217
1217
  "stream finishing",
1218
1218
  "invalid zip data"
1219
1219
  // determined by unknown compression method
1220
- ], re = function(a, e, t) {
1221
- var s = new Error(e || yt[a]);
1222
- if (s.code = a, Error.captureStackTrace && Error.captureStackTrace(s, re), !t)
1220
+ ], ne = function(n, e, t) {
1221
+ var s = new Error(e || Mt[n]);
1222
+ if (s.code = n, Error.captureStackTrace && Error.captureStackTrace(s, ne), !t)
1223
1223
  throw s;
1224
1224
  return s;
1225
- }, wt = function(a, e, t, s) {
1226
- var r = a.length, n = s ? s.length : 0;
1225
+ }, St = function(n, e, t, s) {
1226
+ var r = n.length, a = s ? s.length : 0;
1227
1227
  if (!r || e.f && !e.l)
1228
1228
  return t || new se(0);
1229
- var o = !t, c = o || e.i != 2, f = e.i;
1229
+ var o = !t, i = o || e.i != 2, m = e.i;
1230
1230
  o && (t = new se(r * 3));
1231
- var g = function(Z) {
1231
+ var y = function(Z) {
1232
1232
  var Q = t.length;
1233
1233
  if (Z > Q) {
1234
1234
  var J = new se(Math.max(Q * 2, Z));
1235
1235
  J.set(t), t = J;
1236
1236
  }
1237
- }, m = e.f || 0, l = e.p || 0, h = e.b || 0, p = e.l, v = e.d, C = e.m, k = e.n, B = r * 8;
1237
+ }, f = e.f || 0, l = e.p || 0, h = e.b || 0, p = e.l, v = e.d, k = e.m, _ = e.n, z = r * 8;
1238
1238
  do {
1239
1239
  if (!p) {
1240
- m = ne(a, l, 1);
1241
- var U = ne(a, l + 1, 3);
1242
- if (l += 3, U)
1243
- if (U == 1)
1244
- p = pt, v = xt, C = 9, k = 5;
1245
- else if (U == 2) {
1246
- var T = ne(a, l, 31) + 257, S = ne(a, l + 10, 15) + 4, z = T + ne(a, l + 5, 31) + 1;
1240
+ f = re(n, l, 1);
1241
+ var V = re(n, l + 1, 3);
1242
+ if (l += 3, V)
1243
+ if (V == 1)
1244
+ p = wt, v = vt, k = 9, _ = 5;
1245
+ else if (V == 2) {
1246
+ var T = re(n, l, 31) + 257, S = re(n, l + 10, 15) + 4, R = T + re(n, l + 5, 31) + 1;
1247
1247
  l += 14;
1248
- for (var E = new se(z), y = new se(19), b = 0; b < S; ++b)
1249
- y[ut[b]] = ne(a, l + b * 3, 7);
1248
+ for (var C = new se(R), w = new se(19), b = 0; b < S; ++b)
1249
+ w[pt[b]] = re(n, l + b * 3, 7);
1250
1250
  l += S * 3;
1251
- for (var j = Re(y), L = (1 << j) - 1, I = ve(y, j, 1), b = 0; b < z; ) {
1252
- var D = I[ne(a, l, L)];
1253
- l += D & 15;
1254
- var F = D >> 4;
1255
- if (F < 16)
1256
- E[b++] = F;
1251
+ for (var N = Ie(w), L = (1 << N) - 1, E = ve(w, N, 1), b = 0; b < R; ) {
1252
+ var B = E[re(n, l, L)];
1253
+ l += B & 15;
1254
+ var q = B >> 4;
1255
+ if (q < 16)
1256
+ C[b++] = q;
1257
1257
  else {
1258
- var x = 0, _ = 0;
1259
- for (F == 16 ? (_ = 3 + ne(a, l, 3), l += 2, x = E[b - 1]) : F == 17 ? (_ = 3 + ne(a, l, 7), l += 3) : F == 18 && (_ = 11 + ne(a, l, 127), l += 7); _--; )
1260
- E[b++] = x;
1258
+ var x = 0, P = 0;
1259
+ for (q == 16 ? (P = 3 + re(n, l, 3), l += 2, x = C[b - 1]) : q == 17 ? (P = 3 + re(n, l, 7), l += 3) : q == 18 && (P = 11 + re(n, l, 127), l += 7); P--; )
1260
+ C[b++] = x;
1261
1261
  }
1262
1262
  }
1263
- var X = E.subarray(0, T), $ = E.subarray(T);
1264
- C = Re(X), k = Re($), p = ve(X, C, 1), v = ve($, k, 1);
1263
+ var H = C.subarray(0, T), $ = C.subarray(T);
1264
+ k = Ie(H), _ = Ie($), p = ve(H, k, 1), v = ve($, _, 1);
1265
1265
  } else
1266
- re(1);
1266
+ ne(1);
1267
1267
  else {
1268
- var F = gt(l) + 4, N = a[F - 4] | a[F - 3] << 8, W = F + N;
1268
+ var q = bt(l) + 4, j = n[q - 4] | n[q - 3] << 8, W = q + j;
1269
1269
  if (W > r) {
1270
- f && re(0);
1270
+ m && ne(0);
1271
1271
  break;
1272
1272
  }
1273
- c && g(h + N), t.set(a.subarray(F, W), h), e.b = h += N, e.p = l = W * 8, e.f = m;
1273
+ i && y(h + j), t.set(n.subarray(q, W), h), e.b = h += j, e.p = l = W * 8, e.f = f;
1274
1274
  continue;
1275
1275
  }
1276
- if (l > B) {
1277
- f && re(0);
1276
+ if (l > z) {
1277
+ m && ne(0);
1278
1278
  break;
1279
1279
  }
1280
1280
  }
1281
- c && g(h + 131072);
1282
- for (var i = (1 << C) - 1, A = (1 << k) - 1, q = l; ; q = l) {
1283
- var x = p[_e(a, l) & i], O = x >> 4;
1284
- if (l += x & 15, l > B) {
1285
- f && re(0);
1281
+ i && y(h + 131072);
1282
+ for (var c = (1 << k) - 1, A = (1 << _) - 1, O = l; ; O = l) {
1283
+ var x = p[Pe(n, l) & c], F = x >> 4;
1284
+ if (l += x & 15, l > z) {
1285
+ m && ne(0);
1286
1286
  break;
1287
1287
  }
1288
- if (x || re(2), O < 256)
1289
- t[h++] = O;
1290
- else if (O == 256) {
1291
- q = l, p = null;
1288
+ if (x || ne(2), F < 256)
1289
+ t[h++] = F;
1290
+ else if (F == 256) {
1291
+ O = l, p = null;
1292
1292
  break;
1293
1293
  } else {
1294
- var R = O - 254;
1295
- if (O > 264) {
1296
- var b = O - 257, d = Ne[b];
1297
- R = ne(a, l, (1 << d) - 1) + He[b], l += d;
1294
+ var I = F - 254;
1295
+ if (F > 264) {
1296
+ var b = F - 257, d = He[b];
1297
+ I = re(n, l, (1 << d) - 1) + Qe[b], l += d;
1298
1298
  }
1299
- var P = v[_e(a, l) & A], G = P >> 4;
1300
- P || re(3), l += P & 15;
1301
- var $ = dt[G];
1299
+ var D = v[Pe(n, l) & A], G = D >> 4;
1300
+ D || ne(3), l += D & 15;
1301
+ var $ = yt[G];
1302
1302
  if (G > 3) {
1303
- var d = $e[G];
1304
- $ += _e(a, l) & (1 << d) - 1, l += d;
1303
+ var d = Xe[G];
1304
+ $ += Pe(n, l) & (1 << d) - 1, l += d;
1305
1305
  }
1306
- if (l > B) {
1307
- f && re(0);
1306
+ if (l > z) {
1307
+ m && ne(0);
1308
1308
  break;
1309
1309
  }
1310
- c && g(h + 131072);
1311
- var M = h + R;
1310
+ i && y(h + 131072);
1311
+ var M = h + I;
1312
1312
  if (h < $) {
1313
- var V = n - $, H = Math.min($, M);
1314
- for (V + h < 0 && re(3); h < H; ++h)
1315
- t[h] = s[V + h];
1313
+ var U = a - $, X = Math.min($, M);
1314
+ for (U + h < 0 && ne(3); h < X; ++h)
1315
+ t[h] = s[U + h];
1316
1316
  }
1317
1317
  for (; h < M; ++h)
1318
1318
  t[h] = t[h - $];
1319
1319
  }
1320
1320
  }
1321
- e.l = p, e.p = q, e.b = h, e.f = m, p && (m = 1, e.m = C, e.d = v, e.n = k);
1322
- } while (!m);
1323
- return h != t.length && o ? qe(t, 0, h) : t.subarray(0, h);
1324
- }, vt = /* @__PURE__ */ new se(0), ie = function(a, e) {
1325
- return a[e] | a[e + 1] << 8;
1326
- }, ae = function(a, e) {
1327
- return (a[e] | a[e + 1] << 8 | a[e + 2] << 16 | a[e + 3] << 24) >>> 0;
1328
- }, Te = function(a, e) {
1329
- return ae(a, e) + ae(a, e + 4) * 4294967296;
1321
+ e.l = p, e.p = O, e.b = h, e.f = f, p && (f = 1, e.m = k, e.d = v, e.n = _);
1322
+ } while (!f);
1323
+ return h != t.length && o ? Oe(t, 0, h) : t.subarray(0, h);
1324
+ }, At = /* @__PURE__ */ new se(0), ie = function(n, e) {
1325
+ return n[e] | n[e + 1] << 8;
1326
+ }, ae = function(n, e) {
1327
+ return (n[e] | n[e + 1] << 8 | n[e + 2] << 16 | n[e + 3] << 24) >>> 0;
1328
+ }, Te = function(n, e) {
1329
+ return ae(n, e) + ae(n, e + 4) * 4294967296;
1330
1330
  };
1331
- function bt(a, e) {
1332
- return wt(a, { i: 2 }, e && e.out, e && e.dictionary);
1331
+ function _t(n, e) {
1332
+ return St(n, { i: 2 }, e && e.out, e && e.dictionary);
1333
1333
  }
1334
- var Pe = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Mt = 0;
1334
+ var De = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Ct = 0;
1335
1335
  try {
1336
- Pe.decode(vt, { stream: !0 }), Mt = 1;
1336
+ De.decode(At, { stream: !0 }), Ct = 1;
1337
1337
  } catch {
1338
1338
  }
1339
- var St = function(a) {
1339
+ var kt = function(n) {
1340
1340
  for (var e = "", t = 0; ; ) {
1341
- var s = a[t++], r = (s > 127) + (s > 223) + (s > 239);
1342
- if (t + r > a.length)
1343
- return { s: e, r: qe(a, t - 1) };
1344
- r ? r == 3 ? (s = ((s & 15) << 18 | (a[t++] & 63) << 12 | (a[t++] & 63) << 6 | a[t++] & 63) - 65536, e += String.fromCharCode(55296 | s >> 10, 56320 | s & 1023)) : r & 1 ? e += String.fromCharCode((s & 31) << 6 | a[t++] & 63) : e += String.fromCharCode((s & 15) << 12 | (a[t++] & 63) << 6 | a[t++] & 63) : e += String.fromCharCode(s);
1341
+ var s = n[t++], r = (s > 127) + (s > 223) + (s > 239);
1342
+ if (t + r > n.length)
1343
+ return { s: e, r: Oe(n, t - 1) };
1344
+ r ? r == 3 ? (s = ((s & 15) << 18 | (n[t++] & 63) << 12 | (n[t++] & 63) << 6 | n[t++] & 63) - 65536, e += String.fromCharCode(55296 | s >> 10, 56320 | s & 1023)) : r & 1 ? e += String.fromCharCode((s & 31) << 6 | n[t++] & 63) : e += String.fromCharCode((s & 15) << 12 | (n[t++] & 63) << 6 | n[t++] & 63) : e += String.fromCharCode(s);
1345
1345
  }
1346
1346
  };
1347
- function At(a, e) {
1347
+ function Et(n, e) {
1348
1348
  if (e) {
1349
- for (var t = "", s = 0; s < a.length; s += 16384)
1350
- t += String.fromCharCode.apply(null, a.subarray(s, s + 16384));
1349
+ for (var t = "", s = 0; s < n.length; s += 16384)
1350
+ t += String.fromCharCode.apply(null, n.subarray(s, s + 16384));
1351
1351
  return t;
1352
1352
  } else {
1353
- if (Pe)
1354
- return Pe.decode(a);
1355
- var r = St(a), n = r.s, t = r.r;
1356
- return t.length && re(8), n;
1353
+ if (De)
1354
+ return De.decode(n);
1355
+ var r = kt(n), a = r.s, t = r.r;
1356
+ return t.length && ne(8), a;
1357
1357
  }
1358
1358
  }
1359
- var kt = function(a, e) {
1360
- return e + 30 + ie(a, e + 26) + ie(a, e + 28);
1361
- }, Et = function(a, e, t) {
1362
- var s = ie(a, e + 28), r = At(a.subarray(e + 46, e + 46 + s), !(ie(a, e + 8) & 2048)), n = e + 46 + s, o = ae(a, e + 20), c = t && o == 4294967295 ? Ct(a, n) : [o, ae(a, e + 24), ae(a, e + 42)], f = c[0], g = c[1], m = c[2];
1363
- return [ie(a, e + 10), f, g, r, n + ie(a, e + 30) + ie(a, e + 32), m];
1364
- }, Ct = function(a, e) {
1365
- for (; ie(a, e) != 1; e += 4 + ie(a, e + 2))
1359
+ var It = function(n, e) {
1360
+ return e + 30 + ie(n, e + 26) + ie(n, e + 28);
1361
+ }, Pt = function(n, e, t) {
1362
+ var s = ie(n, e + 28), r = Et(n.subarray(e + 46, e + 46 + s), !(ie(n, e + 8) & 2048)), a = e + 46 + s, o = ae(n, e + 20), i = t && o == 4294967295 ? Tt(n, a) : [o, ae(n, e + 24), ae(n, e + 42)], m = i[0], y = i[1], f = i[2];
1363
+ return [ie(n, e + 10), m, y, r, a + ie(n, e + 30) + ie(n, e + 32), f];
1364
+ }, Tt = function(n, e) {
1365
+ for (; ie(n, e) != 1; e += 4 + ie(n, e + 2))
1366
1366
  ;
1367
- return [Te(a, e + 12), Te(a, e + 4), Te(a, e + 20)];
1367
+ return [Te(n, e + 12), Te(n, e + 4), Te(n, e + 20)];
1368
1368
  };
1369
- function It(a, e) {
1370
- for (var t = {}, s = a.length - 22; ae(a, s) != 101010256; --s)
1371
- (!s || a.length - s > 65558) && re(13);
1372
- var r = ie(a, s + 8);
1369
+ function Rt(n, e) {
1370
+ for (var t = {}, s = n.length - 22; ae(n, s) != 101010256; --s)
1371
+ (!s || n.length - s > 65558) && ne(13);
1372
+ var r = ie(n, s + 8);
1373
1373
  if (!r)
1374
1374
  return {};
1375
- var n = ae(a, s + 16), o = n == 4294967295 || r == 65535;
1375
+ var a = ae(n, s + 16), o = a == 4294967295 || r == 65535;
1376
1376
  if (o) {
1377
- var c = ae(a, s - 12);
1378
- o = ae(a, c) == 101075792, o && (r = ae(a, c + 32), n = ae(a, c + 48));
1377
+ var i = ae(n, s - 12);
1378
+ o = ae(n, i) == 101075792, o && (r = ae(n, i + 32), a = ae(n, i + 48));
1379
1379
  }
1380
- for (var f = 0; f < r; ++f) {
1381
- var g = Et(a, n, o), m = g[0], l = g[1], h = g[2], p = g[3], v = g[4], C = g[5], k = kt(a, C);
1382
- n = v, m ? m == 8 ? t[p] = bt(a.subarray(k, k + l), { out: new se(h) }) : re(14, "unknown compression type " + m) : t[p] = qe(a, k, k + l);
1380
+ for (var m = 0; m < r; ++m) {
1381
+ var y = Pt(n, a, o), f = y[0], l = y[1], h = y[2], p = y[3], v = y[4], k = y[5], _ = It(n, k);
1382
+ a = v, f ? f == 8 ? t[p] = _t(n.subarray(_, _ + l), { out: new se(h) }) : ne(14, "unknown compression type " + f) : t[p] = Oe(n, _, _ + l);
1383
1383
  }
1384
1384
  return t;
1385
1385
  }
1386
- const ke = (a) => typeof a == "number" && Number.isFinite(a), he = (a, e) => {
1387
- const t = a[e];
1386
+ const _e = (n) => typeof n == "number" && Number.isFinite(n), he = (n, e) => {
1387
+ const t = n[e];
1388
1388
  if (typeof t != "object" || t === null)
1389
1389
  throw new Error(`Invalid SOG metadata section: ${e}`);
1390
1390
  return t;
1391
- }, ue = (a, e) => {
1392
- const t = a.files;
1391
+ }, ue = (n, e) => {
1392
+ const t = n.files;
1393
1393
  if (!Array.isArray(t))
1394
1394
  throw new Error(`${e}.files is not an array`);
1395
1395
  if (!t.every((s) => typeof s == "string"))
1396
1396
  throw new Error(`${e}.files contains non-strings`);
1397
1397
  return t;
1398
- }, ze = (a, e) => {
1399
- const t = a.mins, s = a.maxs;
1398
+ }, Re = (n, e) => {
1399
+ const t = n.mins, s = n.maxs;
1400
1400
  if (!Array.isArray(t) || t.length !== 3)
1401
1401
  throw new Error(`${e}.mins must be length-3`);
1402
1402
  if (!Array.isArray(s) || s.length !== 3)
1403
1403
  throw new Error(`${e}.maxs must be length-3`);
1404
- if (![...t, ...s].every(ke))
1404
+ if (![...t, ...s].every(_e))
1405
1405
  throw new Error(`${e}.mins/maxs must be finite numbers`);
1406
1406
  return {
1407
1407
  mins: [t[0], t[1], t[2]],
1408
1408
  maxs: [s[0], s[1], s[2]]
1409
1409
  };
1410
- }, Rt = (a, e) => {
1411
- const t = a.mins, s = a.maxs;
1410
+ }, zt = (n, e) => {
1411
+ const t = n.mins, s = n.maxs;
1412
1412
  if (!Array.isArray(t) || t.length !== 4)
1413
1413
  throw new Error(`${e}.mins must be length-4`);
1414
1414
  if (!Array.isArray(s) || s.length !== 4)
1415
1415
  throw new Error(`${e}.maxs must be length-4`);
1416
- if (![...t, ...s].every(ke))
1416
+ if (![...t, ...s].every(_e))
1417
1417
  throw new Error(`${e}.mins/maxs must be finite numbers`);
1418
1418
  return {
1419
1419
  mins: [t[0], t[1], t[2], t[3]],
1420
1420
  maxs: [s[0], s[1], s[2], s[3]]
1421
1421
  };
1422
- }, je = (a, e) => {
1423
- const t = a.codebook;
1422
+ }, Ne = (n, e) => {
1423
+ const t = n.codebook;
1424
1424
  if (!Array.isArray(t))
1425
1425
  throw new Error(`${e}.codebook is not an array`);
1426
- if (!t.every(ke))
1426
+ if (!t.every(_e))
1427
1427
  throw new Error(`${e}.codebook contains non-finite numbers`);
1428
1428
  return t;
1429
- }, Ge = (a) => {
1430
- if (typeof a != "object" || a === null) throw new Error("Invalid SOG metadata: not an object");
1431
- const e = a, t = e.version ?? 1;
1429
+ }, Ge = (n) => {
1430
+ if (typeof n != "object" || n === null) throw new Error("Invalid SOG metadata: not an object");
1431
+ const e = n, t = e.version ?? 1;
1432
1432
  if (t !== 1 && t !== 2) throw new Error(`Unsupported SOG version: ${String(t)}`);
1433
1433
  if (t === 1) {
1434
- const m = he(e, "means"), l = he(e, "sh0"), h = he(e, "quats"), p = he(e, "scales"), v = typeof e.count == "number" && Number.isFinite(e.count) ? e.count : void 0, C = Array.isArray(m.shape) ? m.shape : void 0, k = C && typeof C[0] == "number" ? C[0] : void 0;
1435
- if (v === void 0 && k === void 0) throw new Error("Invalid SOGS metadata: unable to determine splat count");
1436
- if (v !== void 0 && k !== void 0 && v !== k) throw new Error("Inconsistent SOGS metadata: count does not match means.shape[0]");
1434
+ const f = he(e, "means"), l = he(e, "sh0"), h = he(e, "quats"), p = he(e, "scales"), v = typeof e.count == "number" && Number.isFinite(e.count) ? e.count : void 0, k = Array.isArray(f.shape) ? f.shape : void 0, _ = k && typeof k[0] == "number" ? k[0] : void 0;
1435
+ if (v === void 0 && _ === void 0) throw new Error("Invalid SOGS metadata: unable to determine splat count");
1436
+ if (v !== void 0 && _ !== void 0 && v !== _) throw new Error("Inconsistent SOGS metadata: count does not match means.shape[0]");
1437
1437
  return {
1438
1438
  version: 1,
1439
- numSplats: (v ?? k) | 0,
1439
+ numSplats: (v ?? _) | 0,
1440
1440
  files: {
1441
1441
  sh0: ue(l, "sh0"),
1442
- means: ue(m, "means"),
1442
+ means: ue(f, "means"),
1443
1443
  quats: ue(h, "quats"),
1444
1444
  scales: ue(p, "scales")
1445
1445
  },
1446
1446
  ranges: {
1447
- sh0: Rt(l, "sh0"),
1448
- means: ze(m, "means"),
1449
- scales: ze(p, "scales")
1447
+ sh0: zt(l, "sh0"),
1448
+ means: Re(f, "means"),
1449
+ scales: Re(p, "scales")
1450
1450
  }
1451
1451
  };
1452
1452
  }
1453
1453
  const s = e.count;
1454
- if (!ke(s)) throw new Error('Invalid SOG v2 metadata: missing/invalid "count"');
1455
- const r = s | 0, n = he(e, "means"), o = he(e, "sh0"), c = he(e, "quats"), f = he(e, "scales");
1454
+ if (!_e(s)) throw new Error('Invalid SOG v2 metadata: missing/invalid "count"');
1455
+ const r = s | 0, a = he(e, "means"), o = he(e, "sh0"), i = he(e, "quats"), m = he(e, "scales");
1456
1456
  return {
1457
1457
  version: 2,
1458
1458
  numSplats: r,
1459
1459
  files: {
1460
1460
  sh0: ue(o, "sh0"),
1461
- means: ue(n, "means"),
1462
- quats: ue(c, "quats"),
1463
- scales: ue(f, "scales")
1461
+ means: ue(a, "means"),
1462
+ quats: ue(i, "quats"),
1463
+ scales: ue(m, "scales")
1464
1464
  },
1465
1465
  ranges: {
1466
- means: ze(n, "means"),
1467
- sh0: { codebook: je(o, "sh0") },
1468
- scales: { codebook: je(f, "scales") }
1466
+ means: Re(a, "means"),
1467
+ sh0: { codebook: Ne(o, "sh0") },
1468
+ scales: { codebook: Ne(m, "scales") }
1469
1469
  },
1470
1470
  antialias: typeof e.antialias == "boolean" ? e.antialias : void 0
1471
1471
  // prettier-ignore
1472
1472
  };
1473
1473
  };
1474
- class _t extends u.Loader {
1475
- constructor(e) {
1476
- super(e), this.withCredentials = !0;
1474
+ class Dt extends u.Loader {
1475
+ constructor(e, t) {
1476
+ super(e), this.withCredentials = (t == null ? void 0 : t.withCredentials) ?? !1;
1477
1477
  }
1478
1478
  /**
1479
1479
  * Detect if a buffer is a ZIP file by checking magic bytes
@@ -1492,14 +1492,14 @@ class _t extends u.Loader {
1492
1492
  * @param onError Optional error callback
1493
1493
  */
1494
1494
  load(e, t, s, r) {
1495
- const n = new u.FileLoader(this.manager);
1496
- n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
1495
+ const a = new u.FileLoader(this.manager);
1496
+ a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
1497
1497
  e,
1498
1498
  (o) => {
1499
- this.parseAsync(e, o).then((c) => {
1500
- t && t(c);
1501
- }).catch((c) => {
1502
- this.manager.itemError(e), r && r(c), console.error("Error loading SOGS meta:", c);
1499
+ this.parseAsync(e, o).then((i) => {
1500
+ t && t(i);
1501
+ }).catch((i) => {
1502
+ this.manager.itemError(e), r && r(i), console.error("Error loading SOGS meta:", i);
1503
1503
  });
1504
1504
  },
1505
1505
  s,
@@ -1514,12 +1514,12 @@ class _t extends u.Loader {
1514
1514
  */
1515
1515
  loadAsync(e, t) {
1516
1516
  return new Promise((s, r) => {
1517
- const n = new u.FileLoader(this.manager);
1518
- n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
1517
+ const a = new u.FileLoader(this.manager);
1518
+ a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
1519
1519
  e,
1520
1520
  (o) => {
1521
- this.parseAsync(e, o).then(s).catch((c) => {
1522
- r(c), this.manager.itemError(e);
1521
+ this.parseAsync(e, o).then(s).catch((i) => {
1522
+ r(i), this.manager.itemError(e);
1523
1523
  });
1524
1524
  },
1525
1525
  t,
@@ -1532,125 +1532,275 @@ class _t extends u.Loader {
1532
1532
  async parseAsync(e, t) {
1533
1533
  if (!(t instanceof ArrayBuffer)) throw new Error("SOGS loader: expected ArrayBuffer payload");
1534
1534
  if (this.isZipBuffer(t)) return this.parseZipAsync(t);
1535
- const r = new TextDecoder("utf-8").decode(t), n = JSON.parse(r);
1536
- return this.parseMetaAsync(e, n);
1535
+ const r = new TextDecoder("utf-8").decode(t), a = JSON.parse(r);
1536
+ return this.parseMetaAsync(e, a);
1537
1537
  }
1538
1538
  async parseMetaAsync(e, t) {
1539
- const s = Ge(t), { numSplats: r, files: n, ranges: o, version: c } = s, f = new u.TextureLoader(this.manager);
1540
- f.setPath(this.path), f.setRequestHeader(this.requestHeader), f.setWithCredentials(this.withCredentials);
1541
- const g = (F, N) => {
1539
+ const s = Ge(t), { numSplats: r, files: a, ranges: o, version: i } = s, m = new u.TextureLoader(this.manager);
1540
+ m.setPath(this.path), m.setRequestHeader(this.requestHeader), m.setWithCredentials(this.withCredentials);
1541
+ const y = (q, j) => {
1542
1542
  try {
1543
- return new URL(N, F).toString();
1543
+ return new URL(j, q).toString();
1544
1544
  } catch {
1545
- return F.substring(0, F.lastIndexOf("/") + 1) + N;
1545
+ return q.substring(0, q.lastIndexOf("/") + 1) + j;
1546
1546
  }
1547
- }, m = (F, N) => {
1548
- const W = g(e, F);
1547
+ }, f = (q, j) => {
1548
+ const W = y(e, q);
1549
1549
  return new Promise((T, S) => {
1550
- f.load(
1550
+ m.load(
1551
1551
  W,
1552
- (z) => {
1553
- z.generateMipmaps = !1, z.magFilter = u.NearestFilter, z.minFilter = u.NearestFilter, z.flipY = !1, T(z);
1552
+ (R) => {
1553
+ R.generateMipmaps = !1, R.magFilter = u.NearestFilter, R.minFilter = u.NearestFilter, R.flipY = !1, T(R);
1554
1554
  },
1555
1555
  void 0,
1556
- (z) => {
1557
- const E = z instanceof Error ? z.message : String(z);
1556
+ (R) => {
1557
+ const C = R instanceof Error ? R.message : String(R);
1558
1558
  S(
1559
1559
  new Error(
1560
- `SOGS loader: failed to load ${N} (${F}): ${E}`
1560
+ `SOGS loader: failed to load ${j} (${q}): ${C}`
1561
1561
  )
1562
1562
  );
1563
1563
  }
1564
1564
  );
1565
1565
  });
1566
1566
  };
1567
- if (!Array.isArray(n.sh0) || n.sh0.length < 1) throw new Error("SOGS loader: files.sh0 must have at least 1 entry (sh0)");
1568
- if (!Array.isArray(n.means) || n.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
1569
- if (!Array.isArray(n.quats) || n.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
1570
- if (!Array.isArray(n.scales) || n.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
1571
- const [l, h, p, v, C] = await Promise.all([
1572
- m(n.means[0], "means_l"),
1573
- m(n.means[1], "means_u"),
1574
- m(n.quats[0], "quats"),
1575
- m(n.scales[0], "scales"),
1576
- m(n.sh0[0], "sh0")
1577
- ]), k = { means_l: l, means_u: h, quats: p, scales: v, sh0: C };
1578
- if (c === 1) {
1579
- const F = new Le(r, o, k), N = we.packSogs(F);
1580
- return F.dispose(), N;
1567
+ if (!Array.isArray(a.sh0) || a.sh0.length < 1) throw new Error("SOGS loader: files.sh0 must have at least 1 entry (sh0)");
1568
+ if (!Array.isArray(a.means) || a.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
1569
+ if (!Array.isArray(a.quats) || a.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
1570
+ if (!Array.isArray(a.scales) || a.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
1571
+ const [l, h, p, v, k] = await Promise.all([
1572
+ f(a.means[0], "means_l"),
1573
+ f(a.means[1], "means_u"),
1574
+ f(a.quats[0], "quats"),
1575
+ f(a.scales[0], "scales"),
1576
+ f(a.sh0[0], "sh0")
1577
+ ]), _ = { means_l: l, means_u: h, quats: p, scales: v, sh0: k };
1578
+ if (i === 1) {
1579
+ const q = new Le(r, o, _), j = we.packSogs(q);
1580
+ return q.dispose(), j;
1581
1581
  }
1582
- const B = new We(r, o, k), U = we.packSog2(B);
1583
- return B.dispose(), U;
1582
+ const z = new We(r, o, _), V = we.packSog2(z);
1583
+ return z.dispose(), V;
1584
1584
  }
1585
1585
  async parseZipAsync(e) {
1586
- const t = It(new Uint8Array(e)), s = Object.keys(t), r = s.find((y) => y.toLowerCase().endsWith("meta.json")) ?? null;
1586
+ const t = Rt(new Uint8Array(e)), s = Object.keys(t), r = s.find((w) => w.toLowerCase().endsWith("meta.json")) ?? null;
1587
1587
  if (!r) throw new Error("SOGS loader: zip missing meta.json");
1588
- const n = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "", o = new TextDecoder(), c = JSON.parse(o.decode(t[r])), f = Ge(c), { numSplats: g, files: m, ranges: l, version: h } = f, p = (y) => y.replace(/\\/g, "/").replace(/^\.?\//, ""), v = (y) => {
1589
- const b = p(y), j = [p(n + b), b];
1590
- for (const D of j) {
1591
- const x = t[D];
1588
+ const a = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "", o = new TextDecoder(), i = JSON.parse(o.decode(t[r])), m = Ge(i), { numSplats: y, files: f, ranges: l, version: h } = m, p = (w) => w.replace(/\\/g, "/").replace(/^\.?\//, ""), v = (w) => {
1589
+ const b = p(w), N = [p(a + b), b];
1590
+ for (const B of N) {
1591
+ const x = t[B];
1592
1592
  if (x) return x;
1593
1593
  }
1594
- const L = b.split("/").pop(), I = s.find((D) => p(D).endsWith("/" + b)) ?? s.find((D) => p(D).endsWith("/" + L)) ?? s.find((D) => p(D) === L) ?? null;
1595
- if (I) return t[I];
1596
- throw new Error(`SOGS loader: zip missing file "${y}"`);
1597
- }, C = (y) => {
1598
- const b = y.toLowerCase();
1594
+ const L = b.split("/").pop(), E = s.find((B) => p(B).endsWith("/" + b)) ?? s.find((B) => p(B).endsWith("/" + L)) ?? s.find((B) => p(B) === L) ?? null;
1595
+ if (E) return t[E];
1596
+ throw new Error(`SOGS loader: zip missing file "${w}"`);
1597
+ }, k = (w) => {
1598
+ const b = w.toLowerCase();
1599
1599
  return b.endsWith(".png") ? "image/png" : b.endsWith(".jpg") || b.endsWith(".jpeg") ? "image/jpeg" : b.endsWith(".webp") ? "image/webp" : "application/octet-stream";
1600
- }, k = new u.TextureLoader(this.manager);
1601
- k.setRequestHeader(this.requestHeader), k.setWithCredentials(this.withCredentials);
1602
- const B = (y, b) => {
1603
- const j = v(y), L = new Blob([j], {
1604
- type: C(y)
1605
- }), I = URL.createObjectURL(L);
1606
- return new Promise((D, x) => {
1607
- k.load(
1608
- I,
1609
- (_) => {
1610
- URL.revokeObjectURL(I), _.generateMipmaps = !1, _.magFilter = u.NearestFilter, _.minFilter = u.NearestFilter, _.flipY = !1, D(_);
1600
+ }, _ = new u.TextureLoader(this.manager);
1601
+ _.setRequestHeader(this.requestHeader), _.setWithCredentials(this.withCredentials);
1602
+ const z = (w, b) => {
1603
+ const N = v(w), L = new Blob([N], {
1604
+ type: k(w)
1605
+ }), E = URL.createObjectURL(L);
1606
+ return new Promise((B, x) => {
1607
+ _.load(
1608
+ E,
1609
+ (P) => {
1610
+ URL.revokeObjectURL(E), P.generateMipmaps = !1, P.magFilter = u.NearestFilter, P.minFilter = u.NearestFilter, P.flipY = !1, B(P);
1611
1611
  },
1612
1612
  void 0,
1613
- (_) => {
1614
- URL.revokeObjectURL(I);
1615
- const X = _ instanceof Error ? _.message : String(_);
1613
+ (P) => {
1614
+ URL.revokeObjectURL(E);
1615
+ const H = P instanceof Error ? P.message : String(P);
1616
1616
  x(
1617
1617
  new Error(
1618
- `SOGS loader: failed to load ${b} from zip (${y}): ${X}`
1618
+ `SOGS loader: failed to load ${b} from zip (${w}): ${H}`
1619
1619
  )
1620
1620
  );
1621
1621
  }
1622
1622
  );
1623
1623
  });
1624
1624
  };
1625
- if (!Array.isArray(m.sh0) || m.sh0.length < 1) throw new Error("SOGS loader: files.sh0 must have at least 1 entry (sh0)");
1626
- if (!Array.isArray(m.means) || m.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
1627
- if (!Array.isArray(m.quats) || m.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
1628
- if (!Array.isArray(m.scales) || m.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
1629
- const [U, F, N, W, T] = await Promise.all([
1630
- B(m.means[0], "means_l"),
1631
- B(m.means[1], "means_u"),
1632
- B(m.quats[0], "quats"),
1633
- B(m.scales[0], "scales"),
1634
- B(m.sh0[0], "sh0")
1635
- ]), S = { means_l: U, means_u: F, quats: N, scales: W, sh0: T };
1625
+ if (!Array.isArray(f.sh0) || f.sh0.length < 1) throw new Error("SOGS loader: files.sh0 must have at least 1 entry (sh0)");
1626
+ if (!Array.isArray(f.means) || f.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
1627
+ if (!Array.isArray(f.quats) || f.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
1628
+ if (!Array.isArray(f.scales) || f.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
1629
+ const [V, q, j, W, T] = await Promise.all([
1630
+ z(f.means[0], "means_l"),
1631
+ z(f.means[1], "means_u"),
1632
+ z(f.quats[0], "quats"),
1633
+ z(f.scales[0], "scales"),
1634
+ z(f.sh0[0], "sh0")
1635
+ ]), S = { means_l: V, means_u: q, quats: j, scales: W, sh0: T };
1636
1636
  if (h === 1) {
1637
- const y = new Le(g, l, S), b = we.packSogs(y);
1638
- return y.dispose(), b;
1637
+ const w = new Le(y, l, S), b = we.packSogs(w);
1638
+ return w.dispose(), b;
1639
1639
  }
1640
- const z = new We(g, l, S), E = we.packSog2(z);
1641
- return z.dispose(), E;
1640
+ const R = new We(y, l, S), C = we.packSog2(R);
1641
+ return R.dispose(), C;
1642
1642
  }
1643
1643
  }
1644
- class Tt extends u.EventDispatcher {
1644
+ const Bt = {
1645
+ type: "wave",
1646
+ defaultDuration: 3,
1647
+ shaderCode: (
1648
+ /* glsl */
1649
+ `
1650
+ void applyAnimation(
1651
+ inout vec3 position,
1652
+ inout vec3 scale,
1653
+ inout vec4 color,
1654
+ float progress,
1655
+ vec3 center
1656
+ ) {
1657
+ const float DIST_K = 0.3;
1658
+ const float WAVE_GAIN = 1.2;
1659
+ const float INV_WAVE_W = 20.0;
1660
+ const vec3 GLOW = vec3(1.0, 1.0, 1.0);
1661
+
1662
+ float dist = length(position - center);
1663
+ float normalizedDist = 1.0 - exp(-dist * DIST_K);
1664
+ float waveProgress = progress * WAVE_GAIN;
1665
+
1666
+ float glowIntensity = clamp(1.0 - abs(normalizedDist - waveProgress) * INV_WAVE_W, 0.0, 1.0);
1667
+ color.rgb = mix(color.rgb, GLOW, glowIntensity);
1668
+ }
1669
+ `
1670
+ )
1671
+ }, Ot = {
1672
+ type: "spread",
1673
+ defaultDuration: 3,
1674
+ shaderCode: (
1675
+ /* glsl */
1676
+ `
1677
+ void applyAnimation(
1678
+ inout vec3 position,
1679
+ inout vec3 scale,
1680
+ inout vec4 color,
1681
+ float progress,
1682
+ vec3 center
1683
+ ) {
1684
+ const float DIST_K = 0.3;
1685
+ const float WAVE_GAIN = 1.2;
1686
+ const float SPHERE_LOG = -6.0;
1687
+ const float INV_WAVE_W = 20.0; // 1.0 / 0.05 wave width, precomputed
1688
+ const vec3 GOLD = vec3(1.0, 1.0, 1.0); // pure white
1689
+
1690
+ float dist = length(position - center);
1691
+ float normalizedDist = 1.0 - exp(-dist * DIST_K);
1692
+ float waveProgress = progress * WAVE_GAIN;
1693
+
1694
+ float revealed = step(normalizedDist, waveProgress);
1695
+ scale = mix(vec3(SPHERE_LOG), scale, revealed);
1696
+
1697
+ float glowIntensity = clamp(1.0 - abs(normalizedDist - waveProgress) * INV_WAVE_W, 0.0, 1.0);
1698
+ color.rgb = mix(color.rgb, GOLD, glowIntensity);
1699
+ }
1700
+ `
1701
+ )
1702
+ }, qt = {
1703
+ type: "none",
1704
+ defaultDuration: 0,
1705
+ shaderCode: (
1706
+ /* glsl */
1707
+ `
1708
+ void applyAnimation(
1709
+ inout vec3 position,
1710
+ inout vec3 scale,
1711
+ inout vec4 color,
1712
+ float progress,
1713
+ vec3 center
1714
+ ) {}
1715
+ `
1716
+ )
1717
+ }, je = {
1718
+ spread: Ot,
1719
+ wave: Bt,
1720
+ none: qt
1721
+ }, et = (n) => je[n] ?? je.none, $e = {
1722
+ linear: (n) => n,
1723
+ easeInQuad: (n) => n * n,
1724
+ easeOutQuad: (n) => n * (2 - n),
1725
+ easeInOutQuad: (n) => n < 0.5 ? 2 * n * n : -1 + (4 - 2 * n) * n,
1726
+ easeInCubic: (n) => n * n * n,
1727
+ easeOutCubic: (n) => 1 - Math.pow(1 - n, 3),
1728
+ easeInOutCubic: (n) => n < 0.5 ? 4 * n * n * n : 1 - Math.pow(-2 * n + 2, 3) / 2,
1729
+ easeOutExpo: (n) => n === 1 ? 1 : 1 - Math.pow(2, -10 * n)
1730
+ }, Ft = (n) => $e[n] ?? $e.linear;
1731
+ class Vt {
1732
+ constructor(e) {
1733
+ g(this, "_progress", 0);
1734
+ g(this, "_isPlaying", !1);
1735
+ g(this, "_isComplete", !1);
1736
+ g(this, "_startTime", 0);
1737
+ g(this, "_duration");
1738
+ g(this, "_delay");
1739
+ g(this, "_easing");
1740
+ g(this, "_type");
1741
+ g(this, "_autoPlay");
1742
+ // Animation center (set from bounding box)
1743
+ g(this, "_center", new u.Vector3());
1744
+ const t = et(e.type);
1745
+ this._type = e.type, this._duration = e.duration ?? t.defaultDuration, this._delay = e.delay ?? 0, this._easing = Ft(e.easing ?? "easeOutCubic"), this._autoPlay = e.autoPlay ?? !0;
1746
+ }
1747
+ /** Current progress 0-1 (eased) */
1748
+ get progress() {
1749
+ return this._progress;
1750
+ }
1751
+ get isPlaying() {
1752
+ return this._isPlaying;
1753
+ }
1754
+ get isComplete() {
1755
+ return this._isComplete;
1756
+ }
1757
+ get type() {
1758
+ return this._type;
1759
+ }
1760
+ get center() {
1761
+ return this._center;
1762
+ }
1763
+ /** Set the animation center point (typically bounding box center) */
1764
+ setCenter(e) {
1765
+ this._center.copy(e);
1766
+ }
1767
+ play() {
1768
+ this._startTime = -1, this._isPlaying = !0, this._isComplete = !1, this._progress = 0;
1769
+ }
1770
+ stop() {
1771
+ this._isPlaying = !1;
1772
+ }
1773
+ reset() {
1774
+ this._progress = 0, this._isPlaying = !1, this._isComplete = !1, this._startTime = 0;
1775
+ }
1776
+ /** Skip to end state */
1777
+ complete() {
1778
+ this._progress = 1, this._isPlaying = !1, this._isComplete = !0;
1779
+ }
1780
+ /** Called from onBeforeRender - returns true if uniforms need update */
1781
+ update(e) {
1782
+ if (!this._isPlaying) return !1;
1783
+ this._startTime < 0 && (this._startTime = e + this._delay);
1784
+ const t = e - this._startTime;
1785
+ if (t < 0) return !1;
1786
+ const s = Math.min(t / this._duration, 1);
1787
+ return this._progress = this._easing(s), s >= 1 && (this._isPlaying = !1, this._isComplete = !0, this._progress = 1), !0;
1788
+ }
1789
+ /** Should auto-play be triggered on load? */
1790
+ shouldAutoPlay() {
1791
+ return this._autoPlay && !this._isComplete;
1792
+ }
1793
+ }
1794
+ class Ut extends u.EventDispatcher {
1645
1795
  constructor() {
1646
1796
  super();
1647
- w(this, "worker");
1648
- w(this, "centers", null);
1649
- w(this, "orderTexture", null);
1797
+ g(this, "worker");
1798
+ g(this, "centers", null);
1799
+ g(this, "orderTexture", null);
1650
1800
  /** Bounding box data for optimization */
1651
- w(this, "chunks", null);
1652
- w(this, "lastCameraPosition", new u.Vector3());
1653
- w(this, "lastCameraDirection", new u.Vector3());
1801
+ g(this, "chunks", null);
1802
+ g(this, "lastCameraPosition", new u.Vector3());
1803
+ g(this, "lastCameraDirection", new u.Vector3());
1654
1804
  const t = this.createWorkerCode(), s = new Blob([t], { type: "application/javascript" });
1655
1805
  this.worker = new Worker(URL.createObjectURL(s)), this.worker.onmessage = this.onWorkerMessage.bind(this);
1656
1806
  }
@@ -1661,14 +1811,14 @@ class Tt extends u.EventDispatcher {
1661
1811
  onWorkerMessage(t) {
1662
1812
  if (!this.orderTexture || !this.orderTexture.image)
1663
1813
  return console.error("SplatSorter: Order texture not initialized!");
1664
- const { order: s, count: r } = t.data, n = this.orderTexture.image.data;
1665
- if (!(n instanceof Uint32Array))
1814
+ const { order: s, count: r } = t.data, a = this.orderTexture.image.data;
1815
+ if (!(a instanceof Uint32Array))
1666
1816
  return console.error(
1667
1817
  "SplatSorter: Order texture data is not a Uint32Array!"
1668
1818
  );
1669
- n.set(new Uint32Array(s)), this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
1670
- const o = n.buffer.slice(0), c = { order: o };
1671
- this.worker.postMessage(c, [o]), this.dispatchEvent({ type: "updated", count: r });
1819
+ a.set(new Uint32Array(s)), this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
1820
+ const o = a.buffer.slice(0), i = { order: o };
1821
+ this.worker.postMessage(i, [o]), this.dispatchEvent({ type: "updated", count: r });
1672
1822
  }
1673
1823
  /**
1674
1824
  * Initializes the sorter with necessary data and textures.
@@ -1677,7 +1827,7 @@ class Tt extends u.EventDispatcher {
1677
1827
  * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
1678
1828
  * @param transferOwnership Optional: If true, transfers ownership of centers buffer to worker (saves memory, main thread loses access). Default: false.
1679
1829
  */
1680
- init(t, s, r, n = !1) {
1830
+ init(t, s, r, a = !1) {
1681
1831
  if (!t || !(t.image.data instanceof Uint32Array))
1682
1832
  throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
1683
1833
  if (!s || s.length % 3 !== 0)
@@ -1689,23 +1839,23 @@ class Tt extends u.EventDispatcher {
1689
1839
  "SplatSorter: positions buffer is detached (likely React StrictMode + cached asset). "
1690
1840
  );
1691
1841
  const o = s.length / 3;
1692
- this.orderTexture = t, n ? this.centers = null : this.centers = s.slice();
1693
- const c = this.orderTexture.image.data;
1694
- for (let h = 0; h < o; h++) c[h] = h;
1842
+ this.orderTexture = t, a ? this.centers = null : this.centers = s.slice();
1843
+ const i = this.orderTexture.image.data;
1844
+ for (let h = 0; h < o; h++) i[h] = h;
1695
1845
  this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
1696
- const f = c.buffer.slice(0), g = n ? s.buffer : s.buffer.slice(0), m = {
1697
- order: f,
1698
- centers: g
1846
+ const m = i.buffer.slice(0), y = a ? s.buffer : s.buffer.slice(0), f = {
1847
+ order: m,
1848
+ centers: y
1699
1849
  }, l = [
1700
- f,
1701
- g
1850
+ m,
1851
+ y
1702
1852
  ];
1703
1853
  if (r) {
1704
1854
  this.chunks = r.slice();
1705
1855
  const h = this.chunks.buffer.slice(0);
1706
- m.chunks = h, l.push(h);
1856
+ f.chunks = h, l.push(h);
1707
1857
  }
1708
- this.worker.postMessage(m, l), queueMicrotask(() => {
1858
+ this.worker.postMessage(f, l), queueMicrotask(() => {
1709
1859
  this.dispatchEvent({
1710
1860
  type: "updated",
1711
1861
  count: o
@@ -1725,29 +1875,29 @@ class Tt extends u.EventDispatcher {
1725
1875
  let s;
1726
1876
  const r = [];
1727
1877
  if (!t) {
1728
- const f = this.centers.buffer.slice(0);
1878
+ const m = this.centers.buffer.slice(0);
1729
1879
  return s = {
1730
- centers: f,
1880
+ centers: m,
1731
1881
  mapping: null
1732
- }, r.push(f), this.worker.postMessage(s, r);
1882
+ }, r.push(m), this.worker.postMessage(s, r);
1733
1883
  }
1734
- const n = new Float32Array(t.length * 3);
1735
- for (let f = 0; f < t.length; f++) {
1736
- const g = t[f];
1737
- if (g * 3 + 2 >= this.centers.length) {
1884
+ const a = new Float32Array(t.length * 3);
1885
+ for (let m = 0; m < t.length; m++) {
1886
+ const y = t[m];
1887
+ if (y * 3 + 2 >= this.centers.length) {
1738
1888
  console.warn(
1739
- `SplatSorter: Mapping index ${g} out of bounds.`
1889
+ `SplatSorter: Mapping index ${y} out of bounds.`
1740
1890
  );
1741
1891
  continue;
1742
1892
  }
1743
- const m = g * 3, l = f * 3;
1744
- n[l + 0] = this.centers[m + 0], n[l + 1] = this.centers[m + 1], n[l + 2] = this.centers[m + 2];
1893
+ const f = y * 3, l = m * 3;
1894
+ a[l + 0] = this.centers[f + 0], a[l + 1] = this.centers[f + 1], a[l + 2] = this.centers[f + 2];
1745
1895
  }
1746
- const o = n.buffer.slice(0), c = t.buffer.slice(0);
1896
+ const o = a.buffer.slice(0), i = t.buffer.slice(0);
1747
1897
  s = {
1748
1898
  centers: o,
1749
- mapping: c
1750
- }, r.push(o, c), this.worker.postMessage(s, r);
1899
+ mapping: i
1900
+ }, r.push(o, i), this.worker.postMessage(s, r);
1751
1901
  }
1752
1902
  /**
1753
1903
  * Updates the camera parameters used for sorting.
@@ -1755,8 +1905,8 @@ class Tt extends u.EventDispatcher {
1755
1905
  * @param direction The camera's forward direction in the sorter's local coordinate space.
1756
1906
  */
1757
1907
  setCamera(t, s) {
1758
- const r = this.lastCameraPosition.distanceToSquared(t) > 1e-7, n = this.lastCameraDirection.dot(s) < 0.9999;
1759
- if (!r && !n)
1908
+ const r = this.lastCameraPosition.distanceToSquared(t) > 1e-7, a = this.lastCameraDirection.dot(s) < 0.9999;
1909
+ if (!r && !a)
1760
1910
  return;
1761
1911
  this.lastCameraPosition.copy(t), this.lastCameraDirection.copy(s);
1762
1912
  const o = {
@@ -1777,19 +1927,19 @@ class Tt extends u.EventDispatcher {
1777
1927
  */
1778
1928
  createWorkerCode() {
1779
1929
  return `(${(function() {
1780
- let s = null, r = null, n = null, o = null, c = null, f = null, g = !1;
1781
- const m = { x: 0, y: 0, z: 0 }, l = { x: 0, y: 0, z: 0 }, h = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 };
1782
- let v = null, C = null;
1783
- const k = 32, B = new Array(k).fill(0), U = new Array(k).fill(0), F = new Array(k).fill(0), N = (T, S, z) => {
1930
+ let s = null, r = null, a = null, o = null, i = null, m = null, y = !1;
1931
+ const f = { x: 0, y: 0, z: 0 }, l = { x: 0, y: 0, z: 0 }, h = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 };
1932
+ let v = null, k = null;
1933
+ const _ = 32, z = new Array(_).fill(0), V = new Array(_).fill(0), q = new Array(_).fill(0), j = (T, S, R) => {
1784
1934
  for (; T <= S; ) {
1785
- const E = S + T >> 1, y = z(E);
1786
- if (y > 0) T = E + 1;
1787
- else if (y < 0) S = E - 1;
1788
- else return E;
1935
+ const C = S + T >> 1, w = R(C);
1936
+ if (w > 0) T = C + 1;
1937
+ else if (w < 0) S = C - 1;
1938
+ else return C;
1789
1939
  }
1790
1940
  return ~T;
1791
1941
  }, W = () => {
1792
- if (!s || !r || !c || !f)
1942
+ if (!s || !r || !i || !m)
1793
1943
  return;
1794
1944
  if (r.length === 0) {
1795
1945
  const d = {
@@ -1799,125 +1949,125 @@ class Tt extends u.EventDispatcher {
1799
1949
  self.postMessage(d, [s.buffer]), s = null;
1800
1950
  return;
1801
1951
  }
1802
- const T = c.x, S = c.y, z = c.z, E = f.x, y = f.y, b = f.z, j = 1e-4, L = Math.abs(T - m.x) > j || Math.abs(S - m.y) > j || Math.abs(z - m.z) > j, I = Math.abs(E - l.x) > j || Math.abs(y - l.y) > j || Math.abs(b - l.z) > j;
1803
- if (!g && !L && !I)
1952
+ const T = i.x, S = i.y, R = i.z, C = m.x, w = m.y, b = m.z, N = 1e-4, L = Math.abs(T - f.x) > N || Math.abs(S - f.y) > N || Math.abs(R - f.z) > N, E = Math.abs(C - l.x) > N || Math.abs(w - l.y) > N || Math.abs(b - l.z) > N;
1953
+ if (!y && !L && !E)
1804
1954
  return;
1805
- g = !1, m.x = T, m.y = S, m.z = z, l.x = E, l.y = y, l.z = b;
1806
- let D = 1 / 0, x = -1 / 0;
1955
+ y = !1, f.x = T, f.y = S, f.z = R, l.x = C, l.y = w, l.z = b;
1956
+ let B = 1 / 0, x = -1 / 0;
1807
1957
  for (let d = 0; d < 8; ++d) {
1808
- const P = d & 1 ? h.x : p.x, G = d & 2 ? h.y : p.y, M = d & 4 ? h.z : p.z, V = P * E + G * y + M * b;
1809
- D = Math.min(D, V), x = Math.max(x, V);
1958
+ const D = d & 1 ? h.x : p.x, G = d & 2 ? h.y : p.y, M = d & 4 ? h.z : p.z, U = D * C + G * w + M * b;
1959
+ B = Math.min(B, U), x = Math.max(x, U);
1810
1960
  }
1811
- const _ = r.length / 3, X = x - D, i = (1 << Math.max(
1961
+ const P = r.length / 3, H = x - B, c = (1 << Math.max(
1812
1962
  10,
1813
- Math.min(20, Math.ceil(Math.log2(_ / 4)))
1963
+ Math.min(20, Math.ceil(Math.log2(P / 4)))
1814
1964
  )) + 1;
1815
- if ((!v || v.length !== _) && (v = new Uint32Array(_)), !C || C.length !== i ? C = new Uint32Array(i) : C.fill(0), X < 1e-7) {
1816
- for (let d = 0; d < _; ++d) v[d] = 0;
1817
- C[0] = _;
1818
- } else if (n && n.length > 0) {
1819
- const d = n.length / 6;
1820
- B.fill(0);
1965
+ if ((!v || v.length !== P) && (v = new Uint32Array(P)), !k || k.length !== c ? k = new Uint32Array(c) : k.fill(0), H < 1e-7) {
1966
+ for (let d = 0; d < P; ++d) v[d] = 0;
1967
+ k[0] = P;
1968
+ } else if (a && a.length > 0) {
1969
+ const d = a.length / 6;
1970
+ z.fill(0);
1821
1971
  for (let M = 0; M < d; ++M) {
1822
- const V = M * 6, H = n[V + 0], Z = n[V + 1], Q = n[V + 2], J = n[V + 3], K = H * E + Z * y + Q * b - D, ee = K - J, te = K + J, me = Math.max(
1972
+ const U = M * 6, X = a[U + 0], Z = a[U + 1], Q = a[U + 2], J = a[U + 3], K = X * C + Z * w + Q * b - B, ee = K - J, te = K + J, me = Math.max(
1823
1973
  0,
1824
- Math.floor(ee * k / X)
1974
+ Math.floor(ee * _ / H)
1825
1975
  ), fe = Math.min(
1826
- k,
1827
- Math.ceil(te * k / X)
1976
+ _,
1977
+ Math.ceil(te * _ / H)
1828
1978
  );
1829
1979
  for (let oe = me; oe < fe; ++oe)
1830
- B[oe]++;
1980
+ z[oe]++;
1831
1981
  }
1832
- let P = 0;
1833
- for (let M = 0; M < k; ++M) P += B[M];
1834
- F[0] = 0, U[0] = 0;
1835
- for (let M = 1; M < k; ++M)
1836
- F[M - 1] = B[M - 1] / P * i >>> 0, U[M] = U[M - 1] + F[M - 1];
1837
- F[k - 1] = B[k - 1] / P * i >>> 0;
1838
- const G = X / k;
1839
- for (let M = 0; M < _; ++M) {
1840
- const V = M * 3, H = r[V + 0], Z = r[V + 1], Q = r[V + 2], J = H * E + Z * y + Q * b, ee = (x - J) / G, te = Math.max(
1982
+ let D = 0;
1983
+ for (let M = 0; M < _; ++M) D += z[M];
1984
+ q[0] = 0, V[0] = 0;
1985
+ for (let M = 1; M < _; ++M)
1986
+ q[M - 1] = z[M - 1] / D * c >>> 0, V[M] = V[M - 1] + q[M - 1];
1987
+ q[_ - 1] = z[_ - 1] / D * c >>> 0;
1988
+ const G = H / _;
1989
+ for (let M = 0; M < P; ++M) {
1990
+ const U = M * 3, X = r[U + 0], Z = r[U + 1], Q = r[U + 2], J = X * C + Z * w + Q * b, ee = (x - J) / G, te = Math.max(
1841
1991
  0,
1842
1992
  Math.min(
1843
- k - 1,
1993
+ _ - 1,
1844
1994
  Math.floor(ee)
1845
1995
  )
1846
- ), me = ee - te, fe = U[te] + F[te] * me >>> 0, oe = Math.min(fe, i - 1);
1847
- v[M] = oe, C[oe]++;
1996
+ ), me = ee - te, fe = V[te] + q[te] * me >>> 0, oe = Math.min(fe, c - 1);
1997
+ v[M] = oe, k[oe]++;
1848
1998
  }
1849
1999
  } else {
1850
- const d = (i - 1) / X;
1851
- for (let P = 0; P < _; ++P) {
1852
- const G = P * 3, M = r[G + 0], V = r[G + 1], H = r[G + 2], Z = M * E + V * y + H * b, J = (x - Z) * d >>> 0, K = Math.min(J, i - 1);
1853
- v[P] = K, C[K]++;
2000
+ const d = (c - 1) / H;
2001
+ for (let D = 0; D < P; ++D) {
2002
+ const G = D * 3, M = r[G + 0], U = r[G + 1], X = r[G + 2], Z = M * C + U * w + X * b, J = (x - Z) * d >>> 0, K = Math.min(J, c - 1);
2003
+ v[D] = K, k[K]++;
1854
2004
  }
1855
2005
  }
1856
- for (let d = 1; d < i; d++)
1857
- C[d] += C[d - 1];
1858
- for (let d = _ - 1; d >= 0; d--) {
1859
- const P = v[d], G = --C[P];
2006
+ for (let d = 1; d < c; d++)
2007
+ k[d] += k[d - 1];
2008
+ for (let d = P - 1; d >= 0; d--) {
2009
+ const D = v[d], G = --k[D];
1860
2010
  s[G] = o ? o[d] : d;
1861
2011
  }
1862
- const A = T * E + S * y + z * b, q = (d) => {
2012
+ const A = T * C + S * w + R * b, O = (d) => {
1863
2013
  if (!s) return -1 / 0;
1864
- const P = s[d], G = P;
2014
+ const D = s[d], G = D;
1865
2015
  if (!r || G * 3 + 2 >= r.length)
1866
2016
  return -1 / 0;
1867
2017
  const M = G * 3;
1868
- return r[M] * E + r[M + 1] * y + r[M + 2] * b - A;
2018
+ return r[M] * C + r[M + 1] * w + r[M + 2] * b - A;
1869
2019
  };
1870
- let O = _;
1871
- if (_ > 0 && q(_ - 1) < 0) {
1872
- const d = N(
2020
+ let F = P;
2021
+ if (P > 0 && O(P - 1) < 0) {
2022
+ const d = j(
1873
2023
  0,
1874
- _ - 1,
1875
- q
2024
+ P - 1,
2025
+ O
1876
2026
  );
1877
- O = d < 0 ? ~d : d;
2027
+ F = d < 0 ? ~d : d;
1878
2028
  }
1879
- const R = {
2029
+ const I = {
1880
2030
  order: s.buffer,
1881
- count: O
2031
+ count: F
1882
2032
  };
1883
- self.postMessage(R, [s.buffer]), s = null;
2033
+ self.postMessage(I, [s.buffer]), s = null;
1884
2034
  };
1885
2035
  self.onmessage = (T) => {
1886
2036
  const S = T.data;
1887
2037
  S.order && (s = new Uint32Array(S.order));
1888
- let z = !1;
1889
- if (S.centers && (r = new Float32Array(S.centers), z = !0, g = !0), Object.prototype.hasOwnProperty.call(S, "mapping") && (o = S.mapping ? new Uint32Array(S.mapping) : null, g = !0), S.chunks) {
1890
- if (n = new Float32Array(S.chunks), n.length > 0 && n[3] > 0)
1891
- for (let E = 0; E < n.length / 6; ++E) {
1892
- const y = E * 6, b = n[y + 0], j = n[y + 1], L = n[y + 2], I = n[y + 3], D = n[y + 4], x = n[y + 5];
1893
- n[y + 0] = (b + I) * 0.5, n[y + 1] = (j + D) * 0.5, n[y + 2] = (L + x) * 0.5, n[y + 3] = Math.sqrt(
1894
- (I - b) ** 2 + (D - j) ** 2 + (x - L) ** 2
2038
+ let R = !1;
2039
+ if (S.centers && (r = new Float32Array(S.centers), R = !0, y = !0), Object.prototype.hasOwnProperty.call(S, "mapping") && (o = S.mapping ? new Uint32Array(S.mapping) : null, y = !0), S.chunks) {
2040
+ if (a = new Float32Array(S.chunks), a.length > 0 && a[3] > 0)
2041
+ for (let C = 0; C < a.length / 6; ++C) {
2042
+ const w = C * 6, b = a[w + 0], N = a[w + 1], L = a[w + 2], E = a[w + 3], B = a[w + 4], x = a[w + 5];
2043
+ a[w + 0] = (b + E) * 0.5, a[w + 1] = (N + B) * 0.5, a[w + 2] = (L + x) * 0.5, a[w + 3] = Math.sqrt(
2044
+ (E - b) ** 2 + (B - N) ** 2 + (x - L) ** 2
1895
2045
  ) * 0.5;
1896
2046
  }
1897
- g = !0;
2047
+ y = !0;
1898
2048
  }
1899
- if (z && r && r.length > 0) {
2049
+ if (R && r && r.length > 0) {
1900
2050
  h.x = p.x = r[0], h.y = p.y = r[1], h.z = p.z = r[2];
1901
- for (let E = 1; E < r.length / 3; E++) {
1902
- const y = E * 3;
1903
- h.x = Math.min(h.x, r[y + 0]), p.x = Math.max(p.x, r[y + 0]), h.y = Math.min(h.y, r[y + 1]), p.y = Math.max(p.y, r[y + 1]), h.z = Math.min(h.z, r[y + 2]), p.z = Math.max(p.z, r[y + 2]);
2051
+ for (let C = 1; C < r.length / 3; C++) {
2052
+ const w = C * 3;
2053
+ h.x = Math.min(h.x, r[w + 0]), p.x = Math.max(p.x, r[w + 0]), h.y = Math.min(h.y, r[w + 1]), p.y = Math.max(p.y, r[w + 1]), h.z = Math.min(h.z, r[w + 2]), p.z = Math.max(p.z, r[w + 2]);
1904
2054
  }
1905
- } else z && r && r.length === 0 && (h.x = p.x = h.y = p.y = h.z = p.z = 0);
1906
- S.cameraPosition && (c = S.cameraPosition), S.cameraDirection && (f = S.cameraDirection), W();
2055
+ } else R && r && r.length === 0 && (h.x = p.x = h.y = p.y = h.z = p.z = 0);
2056
+ S.cameraPosition && (i = S.cameraPosition), S.cameraDirection && (m = S.cameraDirection), W();
1907
2057
  };
1908
2058
  }).toString()})();`;
1909
2059
  }
1910
2060
  }
1911
- class zt {
2061
+ class Lt {
1912
2062
  constructor(e) {
1913
- w(this, "packedGeometry");
2063
+ g(this, "packedGeometry");
1914
2064
  // RGBA32UI
1915
- w(this, "packedColor");
2065
+ g(this, "packedColor");
1916
2066
  // RGBA8
1917
- w(this, "orderTexture");
2067
+ g(this, "orderTexture");
1918
2068
  // RB32UI
1919
- w(this, "width");
1920
- w(this, "height");
2069
+ g(this, "width");
2070
+ g(this, "height");
1921
2071
  this.width = e.textureWidth, this.height = e.textureHeight, this.packedColor = this.createColorTexture(e), this.packedGeometry = this.createGeometryTexture(e), this.orderTexture = this.createOrderTexture(e.numSplats);
1922
2072
  }
1923
2073
  createGeometryTexture(e) {
@@ -1956,7 +2106,7 @@ class zt {
1956
2106
  this.packedGeometry.dispose(), this.packedColor.dispose(), this.orderTexture.dispose();
1957
2107
  }
1958
2108
  }
1959
- const Bt = (
2109
+ const Ye = (
1960
2110
  /* glsl */
1961
2111
  `
1962
2112
  precision highp float;
@@ -1981,6 +2131,12 @@ uniform vec3 scalesMax;
1981
2131
  uniform vec3 sh0Min;
1982
2132
  uniform vec3 sh0Max;
1983
2133
 
2134
+ // --- Animation Uniforms ---
2135
+ uniform float animationProgress; // 0 = start, 1 = complete
2136
+ uniform vec3 animationCenter; // Center point for animation
2137
+
2138
+ /* @ANIMATION_CODE */
2139
+
1984
2140
  // --- Attributes ---
1985
2141
  in uint splatInstanceIndex;
1986
2142
 
@@ -2079,11 +2235,10 @@ void main() {
2079
2235
  else if (mode == 2u) quat = vec4(abc.xy, d, abc.z); // stored (w,x,z)
2080
2236
  else quat = vec4(abc, d); // stored (w,x,y)
2081
2237
 
2082
- // Decompress Scale
2238
+ // Decompress Scale (log-space)
2083
2239
  uvec3 sB = unpackBytes(geom.w).xyz;
2084
2240
  vec3 sNorm = vec3(sB) * (1.0 / 255.0);
2085
- vec3 sLerp = mix(scalesMin, scalesMax, sNorm);
2086
- vec3 scale = exp(sLerp); // log scale stored
2241
+ vec3 scale = mix(scalesMin, scalesMax, sNorm); // log-space scale
2087
2242
 
2088
2243
  // Decompress Color & Opacity
2089
2244
  vec4 clr;
@@ -2091,6 +2246,12 @@ void main() {
2091
2246
  clr.rgb = vec3(0.5) + sh * SH_C0;
2092
2247
  clr.a = colorRaw.a; // Opacity passed directly (linear or sigmoid handled by loader)
2093
2248
 
2249
+ // --- Apply Animation (modifies position, scale, color in place) ---
2250
+ /* @ANIMATION_CALL */
2251
+
2252
+ // Convert log-space scale to linear scale
2253
+ scale = exp(scale);
2254
+
2094
2255
  // --- Standard Gaussian Splat Projection ---
2095
2256
 
2096
2257
  // View Space Setup
@@ -2144,9 +2305,12 @@ void main() {
2144
2305
  float l2 = 2.0 * min(sqrt(2.0 * lambda2), vmin);
2145
2306
 
2146
2307
  // Discard tiny splats
2147
- if (l1 < 2.0 && l2 < 2.0) {
2148
- gl_Position = DISCARD_VERTEX;
2149
- return;
2308
+ // TODO: this branch might create some performance issues - check
2309
+ if (animationProgress >= 1.0) {
2310
+ if (l1 < 2.0 && l2 < 2.0) {
2311
+ gl_Position = DISCARD_VERTEX;
2312
+ return;
2313
+ }
2150
2314
  }
2151
2315
 
2152
2316
  vec2 diagVec = normalize(vec2(offDiagonal, lambda1 - diagonal1));
@@ -2181,7 +2345,7 @@ void main() {
2181
2345
  vColor = vec4(max(clr.rgb, vec3(0.0)), clr.a);
2182
2346
  }
2183
2347
  `
2184
- ), Pt = (
2348
+ ), Wt = (
2185
2349
  /* glsl */
2186
2350
  `
2187
2351
  precision highp float;
@@ -2217,9 +2381,9 @@ void main(void) {
2217
2381
  }
2218
2382
  `
2219
2383
  );
2220
- class Dt extends u.ShaderMaterial {
2221
- constructor(e = {}) {
2222
- const t = {
2384
+ class Nt extends u.ShaderMaterial {
2385
+ constructor(t = {}) {
2386
+ const s = {
2223
2387
  // Packed Textures
2224
2388
  packedGeometry: { value: null },
2225
2389
  // RGBA32UI: .r=MeansLow, .g=MeansHigh, .b=Quats, .a=Scales
@@ -2237,12 +2401,16 @@ class Dt extends u.ShaderMaterial {
2237
2401
  // Render State
2238
2402
  texWidth: { value: 0 },
2239
2403
  viewport: { value: new u.Vector2(1, 1) },
2240
- numSplats: { value: 0 }
2404
+ numSplats: { value: 0 },
2405
+ // Animation State
2406
+ animationProgress: { value: 1 },
2407
+ // 1 = no animation active
2408
+ animationCenter: { value: new u.Vector3() }
2241
2409
  };
2242
2410
  super({
2243
- uniforms: t,
2244
- vertexShader: Bt,
2245
- fragmentShader: Pt,
2411
+ uniforms: s,
2412
+ vertexShader: Ye,
2413
+ fragmentShader: Wt,
2246
2414
  transparent: !0,
2247
2415
  glslVersion: u.GLSL3,
2248
2416
  blendSrc: u.OneFactor,
@@ -2255,54 +2423,84 @@ class Dt extends u.ShaderMaterial {
2255
2423
  depthTest: !0,
2256
2424
  depthWrite: !1,
2257
2425
  side: u.DoubleSide,
2258
- alphaTest: e.alphaTest ?? 0,
2259
- toneMapped: e.toneMapped ?? !1
2260
- }), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = u.NoBlending);
2426
+ alphaTest: t.alphaTest ?? 0,
2427
+ toneMapped: t.toneMapped ?? !1
2428
+ });
2429
+ g(this, "_shaderTemplate");
2430
+ t.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = u.NoBlending), this._shaderTemplate = Ye;
2261
2431
  }
2262
- setTexWidth(e) {
2263
- this.uniforms.texWidth.value = e | 0;
2432
+ setTexWidth(t) {
2433
+ this.uniforms.texWidth.value = t | 0;
2264
2434
  }
2265
2435
  /**
2266
2436
  * Update the viewport size
2267
2437
  * @param width Viewport width
2268
2438
  * @param height Viewport height
2269
2439
  */
2270
- updateViewport(e, t) {
2271
- this.uniforms.viewport.value.set(e, t);
2440
+ updateViewport(t, s) {
2441
+ this.uniforms.viewport.value.set(t, s);
2272
2442
  }
2273
2443
  /**
2274
2444
  * Set the main packed geometry texture (RGBA32UI)
2275
2445
  */
2276
- setPackedGeometry(e) {
2277
- this.uniforms.packedGeometry.value = e;
2446
+ setPackedGeometry(t) {
2447
+ this.uniforms.packedGeometry.value = t;
2278
2448
  }
2279
2449
  /**
2280
2450
  * Set the packed color texture (RGBA8)
2281
2451
  */
2282
- setPackedColor(e) {
2283
- this.uniforms.packedColor.value = e;
2452
+ setPackedColor(t) {
2453
+ this.uniforms.packedColor.value = t;
2284
2454
  }
2285
2455
  /**
2286
2456
  * Set order texture for sorting
2287
2457
  */
2288
- setOrderTexture(e) {
2289
- this.uniforms.splatOrder.value = e;
2458
+ setOrderTexture(t) {
2459
+ this.uniforms.splatOrder.value = t;
2290
2460
  }
2291
2461
  /**
2292
2462
  * Set the ranges needed to decompress the packed floats
2293
2463
  */
2294
- setRanges(e) {
2295
- this.uniforms.meansMin.value.copy(e.means.min), this.uniforms.meansMax.value.copy(e.means.max), this.uniforms.scalesMin.value.copy(e.scales.min), this.uniforms.scalesMax.value.copy(e.scales.max), this.uniforms.sh0Min.value.copy(e.sh0.min), this.uniforms.sh0Max.value.copy(e.sh0.max);
2464
+ setRanges(t) {
2465
+ this.uniforms.meansMin.value.copy(t.means.min), this.uniforms.meansMax.value.copy(t.means.max), this.uniforms.scalesMin.value.copy(t.scales.min), this.uniforms.scalesMax.value.copy(t.scales.max), this.uniforms.sh0Min.value.copy(t.sh0.min), this.uniforms.sh0Max.value.copy(t.sh0.max);
2296
2466
  }
2297
2467
  /**
2298
2468
  * Set number of splats to render
2299
2469
  * @param count Number of splats
2300
2470
  */
2301
- setNumSplats(e) {
2302
- this.uniforms.numSplats.value = e;
2471
+ setNumSplats(t) {
2472
+ this.uniforms.numSplats.value = t;
2473
+ }
2474
+ /**
2475
+ * Configure animation effect. Rebuilds shader with effect's GLSL code.
2476
+ * @param effect - Animation effect to use (null to disable)
2477
+ */
2478
+ setAnimation(t) {
2479
+ let s = this._shaderTemplate;
2480
+ t && t.type !== "none" ? (s = s.replace(
2481
+ "/* @ANIMATION_CODE */",
2482
+ t.shaderCode
2483
+ ), s = s.replace(
2484
+ "/* @ANIMATION_CALL */",
2485
+ `if (animationProgress < 1.0) {
2486
+ applyAnimation(modelCenter, scale, clr, animationProgress, animationCenter);
2487
+ }`
2488
+ )) : (s = s.replace("/* @ANIMATION_CODE */", ""), s = s.replace("/* @ANIMATION_CALL */", "")), this.vertexShader = s, this.needsUpdate = !0;
2489
+ }
2490
+ /**
2491
+ * Set animation progress (0 = start, 1 = complete/no animation)
2492
+ */
2493
+ setAnimationProgress(t) {
2494
+ this.uniforms.animationProgress.value = t;
2495
+ }
2496
+ /**
2497
+ * Set animation center point
2498
+ */
2499
+ setAnimationCenter(t) {
2500
+ this.uniforms.animationCenter.value.copy(t);
2303
2501
  }
2304
2502
  }
2305
- const xe = class xe extends u.Mesh {
2503
+ const ge = class ge extends u.Mesh {
2306
2504
  // Match shader constant
2307
2505
  /**
2308
2506
  * Create a new SplatMesh for rendering Gaussian splats
@@ -2310,32 +2508,41 @@ const xe = class xe extends u.Mesh {
2310
2508
  * @param options Rendering options
2311
2509
  */
2312
2510
  constructor(t, s = {}) {
2313
- const r = new Dt(s), n = xe.createInstancedGeometry(t.numSplats, xe.INSTANCE_SIZE);
2314
- super(n, r);
2315
- w(this, "sorter");
2316
- w(this, "options");
2317
- w(this, "splatData");
2318
- w(this, "textureManager");
2319
- w(this, "material");
2320
- w(this, "geometry");
2321
- w(this, "lastCameraPositionLocal", new u.Vector3());
2322
- w(this, "lastCameraDirectionLocal", new u.Vector3());
2323
- w(this, "invModelMatrix", new u.Matrix4());
2511
+ const r = new Nt(s), a = ge.createInstancedGeometry(t.numSplats, ge.INSTANCE_SIZE);
2512
+ super(a, r);
2513
+ g(this, "sorter");
2514
+ g(this, "options");
2515
+ g(this, "splatData");
2516
+ g(this, "textureManager");
2517
+ /** Animation controller (null if no animation configured) */
2518
+ g(this, "animation", null);
2519
+ g(this, "material");
2520
+ g(this, "geometry");
2521
+ g(this, "lastCameraPositionLocal", new u.Vector3());
2522
+ g(this, "lastCameraDirectionLocal", new u.Vector3());
2523
+ g(this, "invModelMatrix", new u.Matrix4());
2324
2524
  // Cached inverse matrix
2325
- w(this, "_vpW", -1);
2326
- w(this, "_vpH", -1);
2327
- w(this, "_size", new u.Vector2());
2328
- w(this, "_camPosW", new u.Vector3());
2329
- w(this, "_camDirW", new u.Vector3());
2330
- w(this, "_camPosL", new u.Vector3());
2331
- w(this, "_camDirL", new u.Vector3());
2332
- w(this, "onSorterUpdated", (t) => {
2525
+ g(this, "_vpW", -1);
2526
+ g(this, "_vpH", -1);
2527
+ g(this, "_size", new u.Vector2());
2528
+ g(this, "_camPosW", new u.Vector3());
2529
+ g(this, "_camDirW", new u.Vector3());
2530
+ g(this, "_camPosL", new u.Vector3());
2531
+ g(this, "_camDirL", new u.Vector3());
2532
+ g(this, "onSorterUpdated", (t) => {
2333
2533
  const s = t.count;
2334
- this.geometry.instanceCount = Math.ceil(s / xe.INSTANCE_SIZE), this.material.setNumSplats(s);
2534
+ this.geometry.instanceCount = Math.ceil(s / ge.INSTANCE_SIZE), this.material.setNumSplats(s);
2335
2535
  });
2336
- this.geometry = n, this.material = r, this.options = { autoSort: !0, ...s }, this.splatData = t, this.frustumCulled = !1, this.sorter = new Tt(), this.textureManager = new zt(t);
2536
+ this.geometry = a, this.material = r, this.options = { autoSort: !0, ...s }, this.splatData = t, this.frustumCulled = !1, this.sorter = new Ut(), this.textureManager = new Lt(t);
2337
2537
  let o = this.createChunks() || void 0;
2338
- o === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), o = void 0, this.sorter.addEventListener("updated", this.onSorterUpdated), this.sorter.init(this.textureManager.orderTexture, this.splatData.centers, o ?? void 0, !this.options.keepSplatData), this.material.setRanges(t.ranges), this.material.setTexWidth(t.textureWidth), this.material.setPackedColor(this.textureManager.packedColor), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setPackedGeometry(this.textureManager.packedGeometry), this.material.setNumSplats(0), this.geometry.boundingBox = t.boundingBox.toBox3(), this.geometry.boundingSphere = new u.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), this.options.keepSplatData || (this.splatData = null);
2538
+ if (o === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), o = void 0, this.sorter.addEventListener("updated", this.onSorterUpdated), this.sorter.init(this.textureManager.orderTexture, this.splatData.centers, o ?? void 0, !this.options.keepSplatData), this.material.setRanges(t.ranges), this.material.setTexWidth(t.textureWidth), this.material.setPackedColor(this.textureManager.packedColor), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setPackedGeometry(this.textureManager.packedGeometry), this.material.setNumSplats(0), s.animation && s.animation.type !== "none") {
2539
+ this.animation = new Vt(s.animation);
2540
+ const i = new u.Vector3();
2541
+ t.boundingBox.toBox3().getCenter(i), this.animation.setCenter(i);
2542
+ const m = et(s.animation.type);
2543
+ this.material.setAnimation(m), this.material.setAnimationCenter(i), this.material.setAnimationProgress(0);
2544
+ }
2545
+ this.geometry.boundingBox = t.boundingBox.toBox3(), this.geometry.boundingSphere = new u.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), this.options.keepSplatData || (this.splatData = null);
2339
2546
  }
2340
2547
  /**
2341
2548
  * Creates the instanced geometry for rendering splats.
@@ -2344,7 +2551,7 @@ const xe = class xe extends u.Mesh {
2344
2551
  * @returns InstancedBufferGeometry
2345
2552
  */
2346
2553
  static createInstancedGeometry(t, s) {
2347
- const r = Math.ceil(t / s), n = new u.BufferGeometry(), o = new Float32Array([
2554
+ const r = Math.ceil(t / s), a = new u.BufferGeometry(), o = new Float32Array([
2348
2555
  // x, y, splat_index_in_instance
2349
2556
  -1,
2350
2557
  -1,
@@ -2358,24 +2565,24 @@ const xe = class xe extends u.Mesh {
2358
2565
  -1,
2359
2566
  1,
2360
2567
  0
2361
- ]), c = new Uint16Array([0, 1, 2, 0, 2, 3]), f = new Float32Array(4 * 3 * s);
2568
+ ]), i = new Uint16Array([0, 1, 2, 0, 2, 3]), m = new Float32Array(4 * 3 * s);
2362
2569
  for (let h = 0; h < s; h++) {
2363
2570
  const p = h * 4 * 3;
2364
2571
  for (let v = 0; v < 4; v++)
2365
- f[p + v * 3 + 0] = o[v * 3 + 0], f[p + v * 3 + 1] = o[v * 3 + 1], f[p + v * 3 + 2] = h;
2572
+ m[p + v * 3 + 0] = o[v * 3 + 0], m[p + v * 3 + 1] = o[v * 3 + 1], m[p + v * 3 + 2] = h;
2366
2573
  }
2367
- const g = new Uint32Array(6 * s);
2574
+ const y = new Uint32Array(6 * s);
2368
2575
  for (let h = 0; h < s; h++) {
2369
2576
  const p = h * 6, v = h * 4;
2370
- g[p + 0] = c[0] + v, g[p + 1] = c[1] + v, g[p + 2] = c[2] + v, g[p + 3] = c[3] + v, g[p + 4] = c[4] + v, g[p + 5] = c[5] + v;
2577
+ y[p + 0] = i[0] + v, y[p + 1] = i[1] + v, y[p + 2] = i[2] + v, y[p + 3] = i[3] + v, y[p + 4] = i[4] + v, y[p + 5] = i[5] + v;
2371
2578
  }
2372
- n.setAttribute("position", new u.BufferAttribute(f, 3)), n.setIndex(new u.BufferAttribute(g, 1));
2373
- const m = new u.InstancedBufferGeometry();
2374
- m.index = n.index, m.setAttribute("position", n.getAttribute("position"));
2579
+ a.setAttribute("position", new u.BufferAttribute(m, 3)), a.setIndex(new u.BufferAttribute(y, 1));
2580
+ const f = new u.InstancedBufferGeometry();
2581
+ f.index = a.index, f.setAttribute("position", a.getAttribute("position"));
2375
2582
  const l = new Uint32Array(r);
2376
2583
  for (let h = 0; h < r; h++)
2377
2584
  l[h] = h * s;
2378
- return m.setAttribute("splatInstanceIndex", new u.InstancedBufferAttribute(l, 1, !1)), m.instanceCount = 0, m;
2585
+ return f.setAttribute("splatInstanceIndex", new u.InstancedBufferAttribute(l, 1, !1)), f.instanceCount = 0, f;
2379
2586
  }
2380
2587
  /**
2381
2588
  * Create chunks data (bounding box min/max) for the sorter.
@@ -2421,7 +2628,12 @@ const xe = class xe extends u.Mesh {
2421
2628
  // prettier-ignore
2422
2629
  // @ts-expect-error scene is not used
2423
2630
  onBeforeRender(t, s, r) {
2424
- this.sort(r), t.getSize(this._size), this.updateViewport(this._size.x, this._size.y);
2631
+ if (this.sort(r), t.getSize(this._size), this.updateViewport(this._size.x, this._size.y), this.animation) {
2632
+ if (!this.animation.isPlaying && this.animation.shouldAutoPlay()) return this.animation.play();
2633
+ if (!this.animation.isPlaying || this.animation.isComplete) return;
2634
+ const a = performance.now() / 1e3;
2635
+ this.animation.update(a) && this.material.setAnimationProgress(this.animation.progress);
2636
+ }
2425
2637
  }
2426
2638
  /**
2427
2639
  * Dispose of resources
@@ -2431,51 +2643,56 @@ const xe = class xe extends u.Mesh {
2431
2643
  }
2432
2644
  };
2433
2645
  /** Number of splats combined into a single instanced draw call. */
2434
- w(xe, "INSTANCE_SIZE", 128);
2435
- let De = xe;
2436
- const Ae = /* @__PURE__ */ new Map(), jt = ({
2437
- url: a,
2646
+ g(ge, "INSTANCE_SIZE", 128);
2647
+ let Be = ge;
2648
+ const Ae = /* @__PURE__ */ new Map(), Jt = ({
2649
+ url: n,
2438
2650
  type: e,
2439
2651
  debug: t = !1,
2440
- splatOptions: s = {},
2441
- ...r
2652
+ withCredentials: s = !1,
2653
+ splatOptions: r = {},
2654
+ animation: a,
2655
+ ...o
2442
2656
  }) => {
2443
- if (!a) throw new Error('Splat component requires either "url" or "plyUrl" prop');
2444
- const n = Ft(a, e);
2445
- t && console.debug("SPLAT: rendering", { url: a, type: n, splatOptions: s, meshProps: r });
2446
- const [o, c] = tt(null), f = st(null);
2447
- return rt(() => {
2448
- const g = Je(a, n, s);
2449
- return Ot(a, n, s).then(
2450
- (m) => {
2451
- c(m);
2657
+ if (!n) throw new Error('Splat component requires either "url" or "plyUrl" prop');
2658
+ const i = jt(n, e);
2659
+ t && console.debug("SPLAT: rendering", { url: n, type: i, splatOptions: r, meshProps: o });
2660
+ const [m, y] = at(null), f = ot(null);
2661
+ return it(() => {
2662
+ const l = {
2663
+ ...r,
2664
+ ...a && { animation: a }
2665
+ }, h = tt(n, i, l, s);
2666
+ return $t(n, i, l, s).then(
2667
+ (p) => {
2668
+ y(p);
2452
2669
  }
2453
2670
  ), () => {
2454
- t && console.debug("SPLAT: releasing mesh for", a), Ut(g);
2671
+ t && console.debug("SPLAT: releasing mesh for", n), Yt(h);
2455
2672
  };
2456
- }, [a, n, s, t]), o ? /* @__PURE__ */ it.jsx("primitive", { ref: f, object: o, ...r }) : null;
2457
- }, qt = (a) => {
2458
- const e = a.toLowerCase();
2673
+ }, [n, i, r, a, s, t]), m ? /* @__PURE__ */ ut.jsx("primitive", { ref: f, object: m, ...o }) : null;
2674
+ }, Gt = (n) => {
2675
+ const e = n.toLowerCase();
2459
2676
  return e.endsWith(".ply") ? "ply" : e.endsWith(".sogs") || e.endsWith(".zip") || e.endsWith(".json") || e.endsWith(".sog") || e.endsWith(".sogs") || e.endsWith(".zip") ? "sogs" : null;
2460
- }, Ft = (a, e) => {
2677
+ }, jt = (n, e) => {
2461
2678
  if (e) return e;
2462
- const t = qt(a);
2679
+ const t = Gt(n);
2463
2680
  if (t) return t;
2464
- throw new Error(`Cannot determine file type from URL: "${a}". `);
2465
- }, Je = (a, e, t) => `${a}:${e}:${JSON.stringify(t)}`, Ot = async (a, e, t) => {
2466
- const s = Je(a, e, t), r = Ae.get(s);
2467
- if (r)
2468
- return r.refCount++, r.mesh;
2469
- const o = await (e === "ply" ? new lt() : new _t()).loadAsync(a), c = new De(o, t);
2470
- return Ae.set(s, { mesh: c, refCount: 1 }), c;
2681
+ throw new Error(`Cannot determine file type from URL: "${n}". `);
2682
+ }, tt = (n, e, t, s) => `${n}:${e}:${JSON.stringify(t)}:${s}`, $t = async (n, e, t, s) => {
2683
+ const r = tt(n, e, t, s), a = Ae.get(r);
2684
+ if (a)
2685
+ return a.refCount++, a.mesh;
2686
+ const i = await (e === "ply" ? new ft(void 0, { withCredentials: s }) : new Dt(void 0, { withCredentials: s })).loadAsync(n), m = new Be(i, t);
2687
+ return Ae.set(r, { mesh: m, refCount: 1 }), m;
2471
2688
  };
2472
- function Ut(a) {
2473
- const e = Ae.get(a);
2474
- e && (e.refCount--, e.refCount <= 0 && (e.mesh.dispose(), Ae.delete(a)));
2689
+ function Yt(n) {
2690
+ const e = Ae.get(n);
2691
+ e && (e.refCount--, e.refCount <= 0 && (e.mesh.dispose(), Ae.delete(n)));
2475
2692
  }
2476
2693
  export {
2477
- lt as PlyLoader,
2478
- _t as SogsLoader,
2479
- jt as Splat,
2480
- De as SplatMesh
2694
+ ft as PlyLoader,
2695
+ Dt as SogsLoader,
2696
+ Jt as Splat,
2697
+ Be as SplatMesh
2481
2698
  };