@speridlabs/visus 1.0.0 → 1.0.2

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,10 +1,10 @@
1
- var xe = Object.defineProperty;
2
- var ye = (C, e, s) => e in C ? xe(C, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : C[e] = s;
3
- var v = (C, e, s) => ye(C, typeof e != "symbol" ? e + "" : e, s);
4
- import ge, { useRef as ve, useMemo as we, useEffect as be } from "react";
5
- import { extend as Se, useLoader as Te } from "@react-three/fiber";
6
- import * as i from "three";
7
- var se = { exports: {} }, te = {};
1
+ var me = Object.defineProperty;
2
+ var xe = (M, e, r) => e in M ? me(M, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : M[e] = r;
3
+ var w = (M, e, r) => xe(M, typeof e != "symbol" ? e + "" : e, r);
4
+ import ge, { useRef as ye, useMemo as ve, useEffect as we } from "react";
5
+ import { useLoader as be } from "@react-three/fiber";
6
+ import * as c from "three";
7
+ var se = { exports: {} }, ee = {};
8
8
  /**
9
9
  * @license React
10
10
  * react-jsx-runtime.production.js
@@ -15,28 +15,28 @@ var se = { exports: {} }, te = {};
15
15
  * LICENSE file in the root directory of this source tree.
16
16
  */
17
17
  var ue;
18
- function Me() {
19
- if (ue) return te;
18
+ function Se() {
19
+ if (ue) return ee;
20
20
  ue = 1;
21
- var C = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
22
- function s(n, t, r) {
21
+ var M = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
22
+ function r(o, t, n) {
23
23
  var a = null;
24
- if (r !== void 0 && (a = "" + r), t.key !== void 0 && (a = "" + t.key), "key" in t) {
25
- r = {};
26
- for (var c in t)
27
- c !== "key" && (r[c] = t[c]);
28
- } else r = t;
29
- return t = r.ref, {
30
- $$typeof: C,
31
- type: n,
24
+ if (n !== void 0 && (a = "" + n), t.key !== void 0 && (a = "" + t.key), "key" in t) {
25
+ n = {};
26
+ for (var i in t)
27
+ i !== "key" && (n[i] = t[i]);
28
+ } else n = t;
29
+ return t = n.ref, {
30
+ $$typeof: M,
31
+ type: o,
32
32
  key: a,
33
33
  ref: t !== void 0 ? t : null,
34
- props: r
34
+ props: n
35
35
  };
36
36
  }
37
- return te.Fragment = e, te.jsx = s, te.jsxs = s, te;
37
+ return ee.Fragment = e, ee.jsx = r, ee.jsxs = r, ee;
38
38
  }
39
- var re = {};
39
+ var te = {};
40
40
  /**
41
41
  * @license React
42
42
  * react-jsx-runtime.development.js
@@ -46,251 +46,251 @@ var re = {};
46
46
  * This source code is licensed under the MIT license found in the
47
47
  * LICENSE file in the root directory of this source tree.
48
48
  */
49
- var he;
50
- function Ce() {
51
- return he || (he = 1, process.env.NODE_ENV !== "production" && function() {
52
- function C(o) {
53
- if (o == null) return null;
54
- if (typeof o == "function")
55
- return o.$$typeof === w ? null : o.displayName || o.name || null;
56
- if (typeof o == "string") return o;
57
- switch (o) {
58
- case T:
49
+ var de;
50
+ function _e() {
51
+ return de || (de = 1, process.env.NODE_ENV !== "production" && function() {
52
+ function M(s) {
53
+ if (s == null) return null;
54
+ if (typeof s == "function")
55
+ return s.$$typeof === _ ? null : s.displayName || s.name || null;
56
+ if (typeof s == "string") return s;
57
+ switch (s) {
58
+ case d:
59
59
  return "Fragment";
60
- case j:
60
+ case q:
61
61
  return "Profiler";
62
- case O:
62
+ case A:
63
63
  return "StrictMode";
64
- case $:
64
+ case Y:
65
65
  return "Suspense";
66
- case D:
66
+ case B:
67
67
  return "SuspenseList";
68
- case E:
68
+ case C:
69
69
  return "Activity";
70
70
  }
71
- if (typeof o == "object")
72
- switch (typeof o.tag == "number" && console.error(
71
+ if (typeof s == "object")
72
+ switch (typeof s.tag == "number" && console.error(
73
73
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
74
- ), o.$$typeof) {
75
- case f:
74
+ ), s.$$typeof) {
75
+ case E:
76
76
  return "Portal";
77
- case q:
78
- return (o.displayName || "Context") + ".Provider";
77
+ case N:
78
+ return (s.displayName || "Context") + ".Provider";
79
79
  case W:
80
- return (o._context.displayName || "Context") + ".Consumer";
81
- case H:
82
- var d = o.render;
83
- return o = o.displayName, o || (o = d.displayName || d.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
84
- case k:
85
- return d = o.displayName || null, d !== null ? d : C(o.type) || "Memo";
86
- case B:
87
- d = o._payload, o = o._init;
80
+ return (s._context.displayName || "Context") + ".Consumer";
81
+ case F:
82
+ var u = s.render;
83
+ return s = s.displayName, s || (s = u.displayName || u.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
84
+ case T:
85
+ return u = s.displayName || null, u !== null ? u : M(s.type) || "Memo";
86
+ case U:
87
+ u = s._payload, s = s._init;
88
88
  try {
89
- return C(o(d));
89
+ return M(s(u));
90
90
  } catch {
91
91
  }
92
92
  }
93
93
  return null;
94
94
  }
95
- function e(o) {
96
- return "" + o;
95
+ function e(s) {
96
+ return "" + s;
97
97
  }
98
- function s(o) {
98
+ function r(s) {
99
99
  try {
100
- e(o);
101
- var d = !1;
100
+ e(s);
101
+ var u = !1;
102
102
  } catch {
103
- d = !0;
103
+ u = !0;
104
104
  }
105
- if (d) {
106
- d = console;
107
- var A = d.error, z = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
108
- return A.call(
109
- d,
105
+ if (u) {
106
+ u = console;
107
+ var R = u.error, D = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
108
+ return R.call(
109
+ u,
110
110
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
111
- z
112
- ), e(o);
111
+ D
112
+ ), e(s);
113
113
  }
114
114
  }
115
- function n(o) {
116
- if (o === T) return "<>";
117
- if (typeof o == "object" && o !== null && o.$$typeof === B)
115
+ function o(s) {
116
+ if (s === d) return "<>";
117
+ if (typeof s == "object" && s !== null && s.$$typeof === U)
118
118
  return "<...>";
119
119
  try {
120
- var d = C(o);
121
- return d ? "<" + d + ">" : "<...>";
120
+ var u = M(s);
121
+ return u ? "<" + u + ">" : "<...>";
122
122
  } catch {
123
123
  return "<...>";
124
124
  }
125
125
  }
126
126
  function t() {
127
- var o = M.A;
128
- return o === null ? null : o.getOwner();
127
+ var s = I.A;
128
+ return s === null ? null : s.getOwner();
129
129
  }
130
- function r() {
130
+ function n() {
131
131
  return Error("react-stack-top-frame");
132
132
  }
133
- function a(o) {
134
- if (U.call(o, "key")) {
135
- var d = Object.getOwnPropertyDescriptor(o, "key").get;
136
- if (d && d.isReactWarning) return !1;
133
+ function a(s) {
134
+ if (P.call(s, "key")) {
135
+ var u = Object.getOwnPropertyDescriptor(s, "key").get;
136
+ if (u && u.isReactWarning) return !1;
137
137
  }
138
- return o.key !== void 0;
138
+ return s.key !== void 0;
139
139
  }
140
- function c(o, d) {
141
- function A() {
142
- y || (y = !0, console.error(
140
+ function i(s, u) {
141
+ function R() {
142
+ f || (f = !0, console.error(
143
143
  "%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)",
144
- d
144
+ u
145
145
  ));
146
146
  }
147
- A.isReactWarning = !0, Object.defineProperty(o, "key", {
148
- get: A,
147
+ R.isReactWarning = !0, Object.defineProperty(s, "key", {
148
+ get: R,
149
149
  configurable: !0
150
150
  });
151
151
  }
152
152
  function l() {
153
- var o = C(this.type);
154
- return _[o] || (_[o] = !0, console.error(
153
+ var s = M(this.type);
154
+ return m[s] || (m[s] = !0, console.error(
155
155
  "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."
156
- )), o = this.props.ref, o !== void 0 ? o : null;
156
+ )), s = this.props.ref, s !== void 0 ? s : null;
157
157
  }
158
- function m(o, d, A, z, N, h, P, F) {
159
- return A = h.ref, o = {
160
- $$typeof: x,
161
- type: o,
162
- key: d,
163
- props: h,
164
- _owner: N
165
- }, (A !== void 0 ? A : null) !== null ? Object.defineProperty(o, "ref", {
158
+ function g(s, u, R, D, H, x, O, L) {
159
+ return R = x.ref, s = {
160
+ $$typeof: p,
161
+ type: s,
162
+ key: u,
163
+ props: x,
164
+ _owner: H
165
+ }, (R !== void 0 ? R : null) !== null ? Object.defineProperty(s, "ref", {
166
166
  enumerable: !1,
167
167
  get: l
168
- }) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
168
+ }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
169
169
  configurable: !1,
170
170
  enumerable: !1,
171
171
  writable: !0,
172
172
  value: 0
173
- }), Object.defineProperty(o, "_debugInfo", {
173
+ }), Object.defineProperty(s, "_debugInfo", {
174
174
  configurable: !1,
175
175
  enumerable: !1,
176
176
  writable: !0,
177
177
  value: null
178
- }), Object.defineProperty(o, "_debugStack", {
178
+ }), Object.defineProperty(s, "_debugStack", {
179
179
  configurable: !1,
180
180
  enumerable: !1,
181
181
  writable: !0,
182
- value: P
183
- }), Object.defineProperty(o, "_debugTask", {
182
+ value: O
183
+ }), Object.defineProperty(s, "_debugTask", {
184
184
  configurable: !1,
185
185
  enumerable: !1,
186
186
  writable: !0,
187
- value: F
188
- }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
187
+ value: L
188
+ }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
189
189
  }
190
- function S(o, d, A, z, N, h, P, F) {
191
- var u = d.children;
192
- if (u !== void 0)
193
- if (z)
194
- if (V(u)) {
195
- for (z = 0; z < u.length; z++)
196
- b(u[z]);
197
- Object.freeze && Object.freeze(u);
190
+ function y(s, u, R, D, H, x, O, L) {
191
+ var h = u.children;
192
+ if (h !== void 0)
193
+ if (D)
194
+ if (V(h)) {
195
+ for (D = 0; D < h.length; D++)
196
+ v(h[D]);
197
+ Object.freeze && Object.freeze(h);
198
198
  } else
199
199
  console.error(
200
200
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
201
201
  );
202
- else b(u);
203
- if (U.call(d, "key")) {
204
- u = C(o);
205
- var I = Object.keys(d).filter(function(G) {
206
- return G !== "key";
202
+ else v(h);
203
+ if (P.call(u, "key")) {
204
+ h = M(s);
205
+ var z = Object.keys(u).filter(function($) {
206
+ return $ !== "key";
207
207
  });
208
- z = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", Z[u + z] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
208
+ D = 0 < z.length ? "{key: someKey, " + z.join(": ..., ") + ": ...}" : "{key: someKey}", re[h + D] || (z = 0 < z.length ? "{" + z.join(": ..., ") + ": ...}" : "{}", console.error(
209
209
  `A props object containing a "key" prop is being spread into JSX:
210
210
  let props = %s;
211
211
  <%s {...props} />
212
212
  React keys must be passed directly to JSX without using spread:
213
213
  let props = %s;
214
214
  <%s key={someKey} {...props} />`,
215
+ D,
216
+ h,
215
217
  z,
216
- u,
217
- I,
218
- u
219
- ), Z[u + z] = !0);
218
+ h
219
+ ), re[h + D] = !0);
220
220
  }
221
- if (u = null, A !== void 0 && (s(A), u = "" + A), a(d) && (s(d.key), u = "" + d.key), "key" in d) {
222
- A = {};
223
- for (var Y in d)
224
- Y !== "key" && (A[Y] = d[Y]);
225
- } else A = d;
226
- return u && c(
227
- A,
228
- typeof o == "function" ? o.displayName || o.name || "Unknown" : o
229
- ), m(
230
- o,
231
- u,
221
+ if (h = null, R !== void 0 && (r(R), h = "" + R), a(u) && (r(u.key), h = "" + u.key), "key" in u) {
222
+ R = {};
223
+ for (var G in u)
224
+ G !== "key" && (R[G] = u[G]);
225
+ } else R = u;
226
+ return h && i(
227
+ R,
228
+ typeof s == "function" ? s.displayName || s.name || "Unknown" : s
229
+ ), g(
230
+ s,
232
231
  h,
233
- N,
232
+ x,
233
+ H,
234
234
  t(),
235
- A,
236
- P,
237
- F
235
+ R,
236
+ O,
237
+ L
238
238
  );
239
239
  }
240
- function b(o) {
241
- typeof o == "object" && o !== null && o.$$typeof === x && o._store && (o._store.validated = 1);
240
+ function v(s) {
241
+ typeof s == "object" && s !== null && s.$$typeof === p && s._store && (s._store.validated = 1);
242
242
  }
243
- var p = ge, x = Symbol.for("react.transitional.element"), f = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), q = Symbol.for("react.context"), H = Symbol.for("react.forward_ref"), $ = Symbol.for("react.suspense"), D = Symbol.for("react.suspense_list"), k = Symbol.for("react.memo"), B = Symbol.for("react.lazy"), E = Symbol.for("react.activity"), w = Symbol.for("react.client.reference"), M = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, V = Array.isArray, g = console.createTask ? console.createTask : function() {
243
+ var b = ge, p = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), A = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), N = Symbol.for("react.context"), F = Symbol.for("react.forward_ref"), Y = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), U = Symbol.for("react.lazy"), C = Symbol.for("react.activity"), _ = Symbol.for("react.client.reference"), I = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, V = Array.isArray, k = console.createTask ? console.createTask : function() {
244
244
  return null;
245
245
  };
246
- p = {
247
- "react-stack-bottom-frame": function(o) {
248
- return o();
246
+ b = {
247
+ "react-stack-bottom-frame": function(s) {
248
+ return s();
249
249
  }
250
250
  };
251
- var y, _ = {}, R = p["react-stack-bottom-frame"].bind(
252
- p,
253
- r
254
- )(), L = g(n(r)), Z = {};
255
- re.Fragment = T, re.jsx = function(o, d, A, z, N) {
256
- var h = 1e4 > M.recentlyCreatedOwnerStacks++;
257
- return S(
258
- o,
259
- d,
260
- A,
251
+ var f, m = {}, S = b["react-stack-bottom-frame"].bind(
252
+ b,
253
+ n
254
+ )(), j = k(o(n)), re = {};
255
+ te.Fragment = d, te.jsx = function(s, u, R, D, H) {
256
+ var x = 1e4 > I.recentlyCreatedOwnerStacks++;
257
+ return y(
258
+ s,
259
+ u,
260
+ R,
261
261
  !1,
262
- z,
263
- N,
264
- h ? Error("react-stack-top-frame") : R,
265
- h ? g(n(o)) : L
262
+ D,
263
+ H,
264
+ x ? Error("react-stack-top-frame") : S,
265
+ x ? k(o(s)) : j
266
266
  );
267
- }, re.jsxs = function(o, d, A, z, N) {
268
- var h = 1e4 > M.recentlyCreatedOwnerStacks++;
269
- return S(
270
- o,
271
- d,
272
- A,
267
+ }, te.jsxs = function(s, u, R, D, H) {
268
+ var x = 1e4 > I.recentlyCreatedOwnerStacks++;
269
+ return y(
270
+ s,
271
+ u,
272
+ R,
273
273
  !0,
274
- z,
275
- N,
276
- h ? Error("react-stack-top-frame") : R,
277
- h ? g(n(o)) : L
274
+ D,
275
+ H,
276
+ x ? Error("react-stack-top-frame") : S,
277
+ x ? k(o(s)) : j
278
278
  );
279
279
  };
280
- }()), re;
280
+ }()), te;
281
281
  }
282
282
  var fe;
283
- function Ae() {
284
- return fe || (fe = 1, process.env.NODE_ENV === "production" ? se.exports = Me() : se.exports = Ce()), se.exports;
283
+ function Ee() {
284
+ return fe || (fe = 1, process.env.NODE_ENV === "production" ? se.exports = Se() : se.exports = _e()), se.exports;
285
285
  }
286
- var Ee = Ae();
286
+ var Ae = Ee();
287
287
  class le {
288
288
  constructor() {
289
- v(this, "min", new i.Vector3(1 / 0, 1 / 0, 1 / 0));
290
- v(this, "max", new i.Vector3(-1 / 0, -1 / 0, -1 / 0));
291
- v(this, "center", new i.Vector3());
289
+ w(this, "min", new c.Vector3(1 / 0, 1 / 0, 1 / 0));
290
+ w(this, "max", new c.Vector3(-1 / 0, -1 / 0, -1 / 0));
291
+ w(this, "center", new c.Vector3());
292
292
  /** Half extents (size/2) */
293
- v(this, "halfExtents", new i.Vector3());
293
+ w(this, "halfExtents", new c.Vector3());
294
294
  }
295
295
  /**
296
296
  * Reset the bounding box to its initial state
@@ -331,7 +331,7 @@ class le {
331
331
  * @returns THREE.Box3 representation
332
332
  */
333
333
  toBox3() {
334
- return new i.Box3().set(this.min, this.max);
334
+ return new c.Box3().set(this.min, this.max);
335
335
  }
336
336
  /**
337
337
  * Create a clone of this bounding box
@@ -342,17 +342,17 @@ class le {
342
342
  return e.min.copy(this.min), e.max.copy(this.max), e.center.copy(this.center), e.halfExtents.copy(this.halfExtents), e;
343
343
  }
344
344
  }
345
- class _e {
345
+ class Me {
346
346
  // TODO: there is no sh spherical harmonics
347
347
  constructor(e = 0) {
348
- v(this, "numSplats", 0);
349
- v(this, "positions");
350
- v(this, "rotations");
351
- v(this, "scales");
352
- v(this, "colors");
353
- v(this, "opacities");
354
- v(this, "centers");
355
- v(this, "boundingBox", new le());
348
+ w(this, "numSplats", 0);
349
+ w(this, "positions");
350
+ w(this, "rotations");
351
+ w(this, "scales");
352
+ w(this, "colors");
353
+ w(this, "opacities");
354
+ w(this, "centers");
355
+ w(this, "boundingBox", new le());
356
356
  this.numSplats = e, this.allocateBuffers(e);
357
357
  }
358
358
  allocateBuffers(e) {
@@ -367,13 +367,13 @@ class _e {
367
367
  * @param color Color
368
368
  * @param opacity Opacity value
369
369
  */
370
- setSplat(e, s, n, t, r, a) {
370
+ setSplat(e, r, o, t, n, a) {
371
371
  if (e >= this.numSplats)
372
372
  throw new Error(
373
373
  `Splat index out of bounds: ${e} >= ${this.numSplats}`
374
374
  );
375
- const c = e * 3, l = e * 4, m = e * 3, S = e * 3;
376
- this.positions[c] = s.x, this.positions[c + 1] = s.y, this.positions[c + 2] = s.z, this.rotations[l] = n.x, this.rotations[l + 1] = n.y, this.rotations[l + 2] = n.z, this.rotations[l + 3] = n.w, this.scales[m] = t.x, this.scales[m + 1] = t.y, this.scales[m + 2] = t.z, this.colors[S] = r.r, this.colors[S + 1] = r.g, this.colors[S + 2] = r.b, this.opacities[e] = a, this.centers[c] = s.x, this.centers[c + 1] = s.y, this.centers[c + 2] = s.z;
375
+ const i = e * 3, l = e * 4, g = e * 3, y = e * 3;
376
+ this.positions[i] = r.x, this.positions[i + 1] = r.y, this.positions[i + 2] = r.z, this.rotations[l] = o.x, this.rotations[l + 1] = o.y, this.rotations[l + 2] = o.z, this.rotations[l + 3] = o.w, this.scales[g] = t.x, this.scales[g + 1] = t.y, this.scales[g + 2] = t.z, this.colors[y] = n.r, this.colors[y + 1] = n.g, this.colors[y + 2] = n.b, this.opacities[e] = a, this.centers[i] = r.x, this.centers[i + 1] = r.y, this.centers[i + 2] = r.z;
377
377
  }
378
378
  /**
379
379
  * Get a splat's data
@@ -385,29 +385,29 @@ class _e {
385
385
  throw new Error(
386
386
  `Splat index out of bounds: ${e} >= ${this.numSplats}`
387
387
  );
388
- const s = e * 3, n = e * 4, t = e * 3, r = e * 3;
388
+ const r = e * 3, o = e * 4, t = e * 3, n = e * 3;
389
389
  return {
390
- position: new i.Vector3(
391
- this.positions[s],
392
- this.positions[s + 1],
393
- this.positions[s + 2]
390
+ position: new c.Vector3(
391
+ this.positions[r],
392
+ this.positions[r + 1],
393
+ this.positions[r + 2]
394
394
  ),
395
- rotation: new i.Quaternion(
396
- this.rotations[n],
397
- this.rotations[n + 1],
398
- this.rotations[n + 2],
399
- this.rotations[n + 3]
395
+ rotation: new c.Quaternion(
396
+ this.rotations[o],
397
+ this.rotations[o + 1],
398
+ this.rotations[o + 2],
399
+ this.rotations[o + 3]
400
400
  ),
401
401
  // Convert log scale back to linear scale for external use
402
- scale: new i.Vector3(
402
+ scale: new c.Vector3(
403
403
  Math.exp(this.scales[t]),
404
404
  Math.exp(this.scales[t + 1]),
405
405
  Math.exp(this.scales[t + 2])
406
406
  ),
407
- color: new i.Color(
408
- this.colors[r],
409
- this.colors[r + 1],
410
- this.colors[r + 2]
407
+ color: new c.Color(
408
+ this.colors[n],
409
+ this.colors[n + 1],
410
+ this.colors[n + 2]
411
411
  ),
412
412
  opacity: this.opacities[e]
413
413
  };
@@ -418,13 +418,13 @@ class _e {
418
418
  */
419
419
  calculateBoundingBox() {
420
420
  this.boundingBox.reset();
421
- const e = new i.Vector3();
422
- for (let s = 0; s < this.numSplats; s++) {
423
- const n = s * 3;
421
+ const e = new c.Vector3();
422
+ for (let r = 0; r < this.numSplats; r++) {
423
+ const o = r * 3;
424
424
  e.set(
425
- this.positions[n],
426
- this.positions[n + 1],
427
- this.positions[n + 2]
425
+ this.positions[o],
426
+ this.positions[o + 1],
427
+ this.positions[o + 2]
428
428
  ), this.boundingBox.expandByPoint(e);
429
429
  }
430
430
  return this.boundingBox;
@@ -434,37 +434,37 @@ class _e {
434
434
  * This is for visualization/debugging purposes only, not for rendering
435
435
  */
436
436
  createDebugGeometry() {
437
- const e = new i.BufferGeometry();
437
+ const e = new c.BufferGeometry();
438
438
  e.setAttribute(
439
439
  "position",
440
- new i.BufferAttribute(this.positions, 3)
440
+ new c.BufferAttribute(this.positions, 3)
441
441
  );
442
- const s = new Float32Array(this.numSplats * 3), n = new i.Quaternion(), t = new i.Euler();
443
- for (let r = 0; r < this.numSplats; r++) {
444
- const a = r * 4, c = r * 3;
445
- n.set(
442
+ const r = new Float32Array(this.numSplats * 3), o = new c.Quaternion(), t = new c.Euler();
443
+ for (let n = 0; n < this.numSplats; n++) {
444
+ const a = n * 4, i = n * 3;
445
+ o.set(
446
446
  this.rotations[a],
447
447
  this.rotations[a + 1],
448
448
  this.rotations[a + 2],
449
449
  this.rotations[a + 3]
450
- ), t.setFromQuaternion(n), s[c] = t.x, s[c + 1] = t.y, s[c + 2] = t.z;
450
+ ), t.setFromQuaternion(o), r[i] = t.x, r[i + 1] = t.y, r[i + 2] = t.z;
451
451
  }
452
452
  return e.setAttribute(
453
453
  "rotation",
454
- new i.BufferAttribute(s, 3)
454
+ new c.BufferAttribute(r, 3)
455
455
  ), e.setAttribute(
456
456
  "scale",
457
- new i.BufferAttribute(this.scales, 3)
457
+ new c.BufferAttribute(this.scales, 3)
458
458
  ), e.setAttribute(
459
459
  "color",
460
- new i.BufferAttribute(this.colors, 3)
460
+ new c.BufferAttribute(this.colors, 3)
461
461
  ), e.setAttribute(
462
462
  "opacity",
463
- new i.BufferAttribute(this.opacities, 1)
463
+ new c.BufferAttribute(this.opacities, 1)
464
464
  ), e;
465
465
  }
466
466
  }
467
- class ke extends i.Loader {
467
+ class Te extends c.Loader {
468
468
  /**
469
469
  * Load a PLY file with Gaussian Splat data
470
470
  * @param url URL of the PLY file
@@ -472,21 +472,22 @@ class ke extends i.Loader {
472
472
  * @param onProgress Optional progress callback
473
473
  * @param onError Optional error callback
474
474
  */
475
- load(e, s, n, t) {
476
- const r = new i.FileLoader(this.manager);
477
- r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
475
+ load(e, r, o, t) {
476
+ (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0 && console.debug("[1/12] LOADER PlyLoader: loading", e);
477
+ const a = new c.FileLoader(this.manager);
478
+ a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
478
479
  e,
479
- (a) => {
480
+ (i) => {
480
481
  try {
481
- if (s) {
482
- const c = this.parse(a);
483
- s(c);
482
+ if (r) {
483
+ const l = this.parse(i);
484
+ r(l);
484
485
  }
485
- } catch (c) {
486
- t ? t(c) : console.error(c), this.manager.itemError(e);
486
+ } catch (l) {
487
+ t ? t(l) : console.error(l), this.manager.itemError(e);
487
488
  }
488
489
  },
489
- n,
490
+ o,
490
491
  t
491
492
  );
492
493
  }
@@ -496,20 +497,20 @@ class ke extends i.Loader {
496
497
  * @param onProgress Optional progress callback
497
498
  * @returns A Promise that resolves with the parsed SplatData
498
499
  */
499
- loadAsync(e, s) {
500
- return new Promise((n, t) => {
501
- const r = new i.FileLoader(this.manager);
502
- r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
500
+ loadAsync(e, r) {
501
+ return new Promise((o, t) => {
502
+ const n = new c.FileLoader(this.manager);
503
+ n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
503
504
  e,
504
505
  (a) => {
505
506
  try {
506
- const c = this.parse(a);
507
- n(c);
508
- } catch (c) {
509
- t(c), this.manager.itemError(e);
507
+ const i = this.parse(a);
508
+ o(i);
509
+ } catch (i) {
510
+ t(i), this.manager.itemError(e);
510
511
  }
511
512
  },
512
- s,
513
+ r,
513
514
  (a) => {
514
515
  t(a), this.manager.itemError(e);
515
516
  }
@@ -522,193 +523,283 @@ class ke extends i.Loader {
522
523
  * @returns Parsed SplatData
523
524
  */
524
525
  parse(e) {
525
- const s = new TextDecoder(), n = new Uint8Array(e), t = [112, 108, 121, 10], r = `
526
+ const r = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0;
527
+ r && console.debug(
528
+ "[2/12] LOADER PlyLoader: starting parse, buffer size:",
529
+ e.byteLength
530
+ );
531
+ const o = new TextDecoder(), t = new Uint8Array(e), n = [112, 108, 121, 10], a = `
526
532
  end_header
527
533
  `;
528
- for (let g = 0; g < t.length; g++)
529
- if (n[g] !== t[g])
534
+ for (let f = 0; f < n.length; f++)
535
+ if (t[f] !== n[f])
530
536
  throw new Error("Invalid PLY file: Missing magic bytes");
531
- let a = 0;
532
- for (let g = 0; g < n.length - r.length; g++) {
533
- let y = !0;
534
- for (let _ = 0; _ < r.length; _++)
535
- if (n[g + _] !== r.charCodeAt(_)) {
536
- y = !1;
537
+ r && console.debug("[3/12] LOADER PlyLoader: PLY magic bytes verified");
538
+ let i = 0;
539
+ for (let f = 0; f < t.length - a.length; f++) {
540
+ let m = !0;
541
+ for (let S = 0; S < a.length; S++)
542
+ if (t[f + S] !== a.charCodeAt(S)) {
543
+ m = !1;
537
544
  break;
538
545
  }
539
- if (y) {
540
- a = g + r.length;
546
+ if (m) {
547
+ i = f + a.length;
541
548
  break;
542
549
  }
543
550
  }
544
- if (a === 0)
551
+ if (i === 0)
545
552
  throw new Error("Invalid PLY file: Could not find end of header");
546
- const l = s.decode(
547
- n.slice(0, a)
548
- ).split(`
549
- `), m = [];
550
- let S = null;
551
- for (let g = 1; g < l.length; g++) {
552
- const y = l[g].trim();
553
- if (y === "" || y === "end_header") continue;
554
- const _ = y.split(" ");
555
- switch (_[0]) {
553
+ r && console.debug(
554
+ "[4/12] LOADER PlyLoader: header length:",
555
+ i
556
+ );
557
+ const l = o.decode(t.subarray(0, i));
558
+ r && console.debug("[5/12] LOADER PlyLoader: header text:", l);
559
+ const g = l.split(`
560
+ `), y = [];
561
+ let v = null;
562
+ for (let f = 1; f < g.length; f++) {
563
+ const m = g[f].trim();
564
+ if (m === "" || m === "end_header") continue;
565
+ const S = m.split(" ");
566
+ switch (S[0]) {
556
567
  case "format":
557
- S = _[1];
568
+ v = S[1], r && console.debug(
569
+ "[6/12] LOADER PlyLoader: format detected:",
570
+ v
571
+ );
558
572
  break;
559
573
  case "element":
560
- m.push({
561
- name: _[1],
562
- count: parseInt(_[2], 10),
574
+ y.push({
575
+ name: S[1],
576
+ count: parseInt(S[2], 10),
563
577
  properties: []
564
- });
578
+ }), r && console.debug(
579
+ "[6/12] LOADER PlyLoader: element found:",
580
+ S[1],
581
+ "count:",
582
+ S[2]
583
+ );
565
584
  break;
566
585
  case "property":
567
- if (m.length === 0)
586
+ if (y.length === 0)
568
587
  throw new Error(
569
588
  "Invalid PLY file: Property without element"
570
589
  );
571
- m[m.length - 1].properties.push({
572
- type: _[1],
573
- name: _[2],
590
+ y[y.length - 1].properties.push({
591
+ type: S[1],
592
+ name: S[2],
574
593
  storage: null
575
- });
594
+ }), r && console.debug(
595
+ "[6/12] LOADER PlyLoader: property found:",
596
+ S[2],
597
+ "type:",
598
+ S[1]
599
+ );
576
600
  break;
577
601
  }
578
602
  }
579
- if (S !== "binary_little_endian")
580
- throw new Error(`Unsupported PLY format: ${S}`);
581
- const b = m.find((g) => g.name === "vertex");
603
+ if (v !== "binary_little_endian")
604
+ throw new Error(`Unsupported PLY format: ${v}`);
605
+ const b = y.find((f) => f.name === "vertex");
582
606
  if (!b)
583
607
  throw new Error("Invalid PLY file: No vertex element found");
584
- const p = new _e(b.count), x = new DataView(e);
585
- let f = a;
586
- const T = (g) => b.properties.findIndex((y) => y.name === g), O = T("x"), j = T("y"), W = T("z"), q = [
587
- T("rot_0"),
588
- T("rot_1"),
589
- T("rot_2"),
590
- T("rot_3")
591
- ], H = [
592
- T("scale_0"),
593
- T("scale_1"),
594
- T("scale_2")
595
- ], $ = [
596
- T("f_dc_0"),
597
- T("f_dc_1"),
598
- T("f_dc_2")
599
- ], D = T("opacity");
600
- if ([
601
- O,
602
- j,
608
+ r && console.debug(
609
+ "[7/12] LOADER PlyLoader: vertex element properties:",
610
+ b.properties.map((f) => f.name)
611
+ );
612
+ const p = new Me(b.count);
613
+ r && console.debug(
614
+ "[8/12] LOADER PlyLoader: created SplatData for",
615
+ b.count,
616
+ "splats"
617
+ );
618
+ const E = new DataView(e);
619
+ let d = i;
620
+ const A = (f) => b.properties.findIndex((m) => m.name === f), q = A("x"), W = A("y"), N = A("z"), F = [
621
+ A("rot_0"),
622
+ A("rot_1"),
623
+ A("rot_2"),
624
+ A("rot_3")
625
+ ], Y = [
626
+ A("scale_0"),
627
+ A("scale_1"),
628
+ A("scale_2")
629
+ ], B = [
630
+ A("f_dc_0"),
631
+ A("f_dc_1"),
632
+ A("f_dc_2")
633
+ ], T = A("opacity");
634
+ if (r && console.debug("[9/12] LOADER PlyLoader: property indices:", {
635
+ position: [q, W, N],
636
+ rotation: F,
637
+ scale: Y,
638
+ color: B,
639
+ opacity: T
640
+ }), [
641
+ q,
603
642
  W,
604
- ...q,
605
- ...H,
606
- ...$,
607
- D
608
- ].some((g) => g === -1))
643
+ N,
644
+ ...F,
645
+ ...Y,
646
+ ...B,
647
+ T
648
+ ].some((f) => f === -1))
609
649
  throw new Error("Invalid PLY file: Missing required properties");
610
- const B = 0.28209479177387814, E = (g) => {
611
- if (g > 0) return 1 / (1 + Math.exp(-g));
612
- const y = Math.exp(g);
613
- return y / (1 + y);
614
- }, w = new i.Vector3(), M = new i.Quaternion(), U = new i.Vector3(), V = new i.Color();
615
- for (let g = 0; g < b.count; g++) {
616
- const y = [];
617
- for (let R = 0; R < b.properties.length; R++) {
618
- const Z = b.properties[R].type;
619
- let o;
620
- switch (Z) {
650
+ const C = 0.28209479177387814, _ = (f) => {
651
+ if (f > 0) return 1 / (1 + Math.exp(-f));
652
+ const m = Math.exp(f);
653
+ return m / (1 + m);
654
+ };
655
+ r && console.debug(
656
+ "[10/12] LOADER PlyLoader: starting binary data parsing, offset:",
657
+ d
658
+ );
659
+ const I = new c.Vector3(), P = new c.Quaternion(), V = new c.Vector3(), k = new c.Color();
660
+ for (let f = 0; f < b.count; f++) {
661
+ r && f % 1e4 === 0 && console.debug(
662
+ `[10/12] LOADER PlyLoader: processing splat ${f}/${b.count} (${(f / b.count * 100).toFixed(1)}%)`
663
+ );
664
+ const m = [];
665
+ for (let j = 0; j < b.properties.length; j++) {
666
+ const s = b.properties[j].type;
667
+ let u;
668
+ switch (s) {
621
669
  case "char":
622
- o = x.getInt8(f), f += 1;
670
+ u = E.getInt8(d), d += 1;
623
671
  break;
624
672
  case "uchar":
625
- o = x.getUint8(f), f += 1;
673
+ u = E.getUint8(d), d += 1;
626
674
  break;
627
675
  case "short":
628
- o = x.getInt16(f, !0), f += 2;
676
+ u = E.getInt16(d, !0), d += 2;
629
677
  break;
630
678
  case "ushort":
631
- o = x.getUint16(f, !0), f += 2;
679
+ u = E.getUint16(d, !0), d += 2;
632
680
  break;
633
681
  case "int":
634
- o = x.getInt32(f, !0), f += 4;
682
+ u = E.getInt32(d, !0), d += 4;
635
683
  break;
636
684
  case "uint":
637
- o = x.getUint32(f, !0), f += 4;
685
+ u = E.getUint32(d, !0), d += 4;
638
686
  break;
639
687
  case "float":
640
- o = x.getFloat32(f, !0), f += 4;
688
+ u = E.getFloat32(d, !0), d += 4;
641
689
  break;
642
690
  case "double":
643
- o = x.getFloat64(f, !0), f += 8;
691
+ u = E.getFloat64(d, !0), d += 8;
644
692
  break;
645
693
  default:
646
- throw new Error(`Unsupported property type: ${Z}`);
694
+ throw new Error(`Unsupported property type: ${s}`);
647
695
  }
648
- y.push(o);
696
+ m.push(u);
649
697
  }
650
- w.set(
651
- y[O],
652
- y[j],
653
- y[W]
654
- ), M.set(
655
- y[q[1]],
698
+ I.set(
699
+ m[q],
700
+ m[W],
701
+ m[N]
702
+ ), P.set(
703
+ m[F[1]],
656
704
  // PLY stores rot 1,2,3,0 (x,y,z,w)
657
- y[q[2]],
658
- y[q[3]],
659
- y[q[0]]
660
- ).normalize(), M.w < 0 && (M.x = -M.x, M.y = -M.y, M.z = -M.z, M.w = -M.w), U.set(
661
- y[H[0]],
662
- // Read directly assuming it's log scale
663
- y[H[1]],
664
- y[H[2]]
705
+ m[F[2]],
706
+ m[F[3]],
707
+ m[F[0]]
708
+ ).normalize(), r && f < 5 && console.debug(
709
+ `[10/12] LOADER PlyLoader: splat ${f} rotation:`,
710
+ {
711
+ original: [
712
+ m[F[0]],
713
+ m[F[1]],
714
+ m[F[2]],
715
+ m[F[3]]
716
+ ],
717
+ processed: [
718
+ P.x,
719
+ P.y,
720
+ P.z,
721
+ P.w
722
+ ]
723
+ }
665
724
  ), V.set(
666
- 0.5 + y[$[0]] * B,
667
- 0.5 + y[$[1]] * B,
668
- 0.5 + y[$[2]] * B
669
- ), V.r = Math.max(0, Math.min(1, V.r)), V.g = Math.max(0, Math.min(1, V.g)), V.b = Math.max(0, Math.min(1, V.b));
670
- const _ = E(y[D]);
671
- p.setSplat(
672
- g,
673
- w,
674
- M,
675
- U,
676
- // Pass log scale directly
725
+ m[Y[0]],
726
+ // Read directly assuming it's log scale
727
+ m[Y[1]],
728
+ m[Y[2]]
729
+ ), k.set(
730
+ 0.5 + m[B[0]] * C,
731
+ 0.5 + m[B[1]] * C,
732
+ 0.5 + m[B[2]] * C
733
+ ), k.r = Math.max(0, Math.min(1, k.r)), k.g = Math.max(0, Math.min(1, k.g)), k.b = Math.max(0, Math.min(1, k.b));
734
+ const S = _(m[T]);
735
+ r && f < 3 && console.debug(`[10/12] LOADER PlyLoader: splat ${f} data:`, {
736
+ position: [I.x, I.y, I.z],
737
+ rotation: [
738
+ P.x,
739
+ P.y,
740
+ P.z,
741
+ P.w
742
+ ],
743
+ scale: [V.x, V.y, V.z],
744
+ color: [k.r, k.g, k.b],
745
+ opacity: S
746
+ }), p.setSplat(
747
+ f,
748
+ I,
749
+ P,
677
750
  V,
678
- _
751
+ // Pass log scale directly
752
+ k,
753
+ S
679
754
  );
680
755
  }
681
- return p.calculateBoundingBox(), p;
756
+ return r && console.debug(
757
+ "[11/12] LOADER PlyLoader: finished parsing all splats, calculating bounding box"
758
+ ), p.calculateBoundingBox(), r && console.debug(
759
+ "[12/12] LOADER PlyLoader: parsing complete, bounding box:",
760
+ {
761
+ min: [
762
+ p.boundingBox.min.x,
763
+ p.boundingBox.min.y,
764
+ p.boundingBox.min.z
765
+ ],
766
+ max: [
767
+ p.boundingBox.max.x,
768
+ p.boundingBox.max.y,
769
+ p.boundingBox.max.z
770
+ ]
771
+ }
772
+ ), p;
682
773
  }
683
774
  }
684
- class Ie extends i.EventDispatcher {
775
+ class Ce extends c.EventDispatcher {
685
776
  constructor() {
686
777
  super();
687
- v(this, "worker");
688
- v(this, "centers", null);
689
- v(this, "orderTexture", null);
778
+ w(this, "worker");
779
+ w(this, "centers", null);
780
+ w(this, "orderTexture", null);
690
781
  /** Bounding box data for optimization */
691
- v(this, "chunks", null);
692
- v(this, "lastCameraPosition", new i.Vector3());
693
- v(this, "lastCameraDirection", new i.Vector3());
694
- const s = this.createWorkerCode(), n = new Blob([s], { type: "application/javascript" });
695
- this.worker = new Worker(URL.createObjectURL(n)), this.worker.onmessage = this.onWorkerMessage.bind(this);
782
+ w(this, "chunks", null);
783
+ w(this, "lastCameraPosition", new c.Vector3());
784
+ w(this, "lastCameraDirection", new c.Vector3());
785
+ const r = this.createWorkerCode(), o = new Blob([r], { type: "application/javascript" });
786
+ this.worker = new Worker(URL.createObjectURL(o)), this.worker.onmessage = this.onWorkerMessage.bind(this);
696
787
  }
697
788
  /**
698
789
  * Handles messages received from the sorting worker.
699
790
  * @param event The message event from the worker.
700
791
  */
701
- onWorkerMessage(s) {
792
+ onWorkerMessage(r) {
702
793
  if (!this.orderTexture || !this.orderTexture.image)
703
794
  return console.error("SplatSorter: Order texture not initialized!");
704
- const { order: n, count: t } = s.data, r = this.orderTexture.image.data;
705
- if (!(r instanceof Uint32Array))
795
+ const { order: o, count: t } = r.data, n = this.orderTexture.image.data;
796
+ if (!(n instanceof Uint32Array))
706
797
  return console.error(
707
798
  "SplatSorter: Order texture data is not a Uint32Array!"
708
799
  );
709
- r.set(new Uint32Array(n)), this.orderTexture.needsUpdate = !0;
710
- const a = r.buffer.slice(0), c = { order: a };
711
- this.worker.postMessage(c, [a]), this.dispatchEvent({ type: "updated", count: t });
800
+ n.set(new Uint32Array(o)), this.orderTexture.needsUpdate = !0;
801
+ const a = n.buffer.slice(0), i = { order: a };
802
+ this.worker.postMessage(i, [a]), this.dispatchEvent({ type: "updated", count: t });
712
803
  }
713
804
  /**
714
805
  * Initializes the sorter with necessary data and textures.
@@ -716,82 +807,82 @@ class Ie extends i.EventDispatcher {
716
807
  * @param centers A Float32Array containing the center position (x, y, z) for each splat.
717
808
  * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
718
809
  */
719
- init(s, n, t) {
720
- if (!s || !(s.image.data instanceof Uint32Array))
810
+ init(r, o, t) {
811
+ if (!r || !(r.image.data instanceof Uint32Array))
721
812
  throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
722
- if (!n || n.length % 3 !== 0)
813
+ if (!o || o.length % 3 !== 0)
723
814
  throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
724
- if (s.image.data.length < n.length / 3)
815
+ if (r.image.data.length < o.length / 3)
725
816
  throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
726
- const r = n.length / 3;
727
- this.orderTexture = s, this.centers = n.slice();
817
+ const n = o.length / 3;
818
+ this.orderTexture = r, this.centers = o.slice();
728
819
  const a = this.orderTexture.image.data;
729
- for (let b = 0; b < r; b++) a[b] = b;
820
+ for (let v = 0; v < n; v++) a[v] = v;
730
821
  this.orderTexture.needsUpdate = !0;
731
- const c = a.buffer.slice(0), l = this.centers.buffer.slice(0), m = {
732
- order: c,
822
+ const i = a.buffer.slice(0), l = this.centers.buffer.slice(0), g = {
823
+ order: i,
733
824
  centers: l
734
- }, S = [
735
- c,
825
+ }, y = [
826
+ i,
736
827
  l
737
828
  ];
738
829
  if (t) {
739
830
  this.chunks = t.slice();
740
- const b = this.chunks.buffer.slice(0);
741
- m.chunks = b, S.push(b);
831
+ const v = this.chunks.buffer.slice(0);
832
+ g.chunks = v, y.push(v);
742
833
  }
743
- this.worker.postMessage(m, S);
834
+ this.worker.postMessage(g, y);
744
835
  }
745
836
  /**
746
837
  * Applies an optional mapping to filter or reorder splats before sorting.
747
838
  * The sorter will only consider splats whose original indices are present in the mapping.
748
839
  * @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
749
840
  */
750
- setMapping(s) {
841
+ setMapping(r) {
751
842
  if (!this.centers)
752
843
  return console.warn(
753
844
  "SplatSorter: Cannot set mapping before initialization."
754
845
  );
755
- let n;
846
+ let o;
756
847
  const t = [];
757
- if (!s) {
848
+ if (!r) {
758
849
  const l = this.centers.buffer.slice(0);
759
- return n = {
850
+ return o = {
760
851
  centers: l,
761
852
  mapping: null
762
- }, t.push(l), this.worker.postMessage(n, t);
853
+ }, t.push(l), this.worker.postMessage(o, t);
763
854
  }
764
- const r = new Float32Array(s.length * 3);
765
- for (let l = 0; l < s.length; l++) {
766
- const m = s[l];
767
- if (m * 3 + 2 >= this.centers.length) {
855
+ const n = new Float32Array(r.length * 3);
856
+ for (let l = 0; l < r.length; l++) {
857
+ const g = r[l];
858
+ if (g * 3 + 2 >= this.centers.length) {
768
859
  console.warn(
769
- `SplatSorter: Mapping index ${m} out of bounds.`
860
+ `SplatSorter: Mapping index ${g} out of bounds.`
770
861
  );
771
862
  continue;
772
863
  }
773
- const S = m * 3, b = l * 3;
774
- r[b + 0] = this.centers[S + 0], r[b + 1] = this.centers[S + 1], r[b + 2] = this.centers[S + 2];
864
+ const y = g * 3, v = l * 3;
865
+ n[v + 0] = this.centers[y + 0], n[v + 1] = this.centers[y + 1], n[v + 2] = this.centers[y + 2];
775
866
  }
776
- const a = r.buffer.slice(0), c = s.buffer.slice(0);
777
- n = {
867
+ const a = n.buffer.slice(0), i = r.buffer.slice(0);
868
+ o = {
778
869
  centers: a,
779
- mapping: c
780
- }, t.push(a, c), this.worker.postMessage(n, t);
870
+ mapping: i
871
+ }, t.push(a, i), this.worker.postMessage(o, t);
781
872
  }
782
873
  /**
783
874
  * Updates the camera parameters used for sorting.
784
875
  * @param position The camera's position in the sorter's local coordinate space.
785
876
  * @param direction The camera's forward direction in the sorter's local coordinate space.
786
877
  */
787
- setCamera(s, n) {
788
- const t = this.lastCameraPosition.distanceToSquared(s) > 1e-7, r = this.lastCameraDirection.dot(n) < 0.9999;
789
- if (!t && !r)
878
+ setCamera(r, o) {
879
+ const t = this.lastCameraPosition.distanceToSquared(r) > 1e-7, n = this.lastCameraDirection.dot(o) < 0.9999;
880
+ if (!t && !n)
790
881
  return;
791
- this.lastCameraPosition.copy(s), this.lastCameraDirection.copy(n);
882
+ this.lastCameraPosition.copy(r), this.lastCameraDirection.copy(o);
792
883
  const a = {
793
- cameraPosition: { x: s.x, y: s.y, z: s.z },
794
- cameraDirection: { x: n.x, y: n.y, z: n.z }
884
+ cameraPosition: { x: r.x, y: r.y, z: r.z },
885
+ cameraDirection: { x: o.x, y: o.y, z: o.z }
795
886
  };
796
887
  this.worker.postMessage(a);
797
888
  }
@@ -807,165 +898,165 @@ class Ie extends i.EventDispatcher {
807
898
  */
808
899
  createWorkerCode() {
809
900
  return `(${(function() {
810
- let n = null, t = null, r = null, a = null, c = null, l = null, m = !1;
811
- const S = { x: 0, y: 0, z: 0 }, b = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 }, x = { x: 0, y: 0, z: 0 };
812
- let f = null, T = null;
813
- const O = 32, j = new Array(O).fill(0), W = new Array(O).fill(0), q = new Array(O).fill(0), H = (D, k, B) => {
814
- for (; D <= k; ) {
815
- const E = k + D >> 1, w = B(E);
816
- if (w > 0) D = E + 1;
817
- else if (w < 0) k = E - 1;
818
- else return E;
901
+ let o = null, t = null, n = null, a = null, i = null, l = null, g = !1;
902
+ const y = { x: 0, y: 0, z: 0 }, v = { x: 0, y: 0, z: 0 }, b = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 };
903
+ let E = null, d = null;
904
+ const A = 32, q = new Array(A).fill(0), W = new Array(A).fill(0), N = new Array(A).fill(0), F = (B, T, U) => {
905
+ for (; B <= T; ) {
906
+ const C = T + B >> 1, _ = U(C);
907
+ if (_ > 0) B = C + 1;
908
+ else if (_ < 0) T = C - 1;
909
+ else return C;
819
910
  }
820
- return ~D;
821
- }, $ = () => {
822
- if (!n || !t || !c || !l)
911
+ return ~B;
912
+ }, Y = () => {
913
+ if (!o || !t || !i || !l)
823
914
  return;
824
915
  if (t.length === 0) {
825
- const h = {
826
- order: n.buffer,
916
+ const x = {
917
+ order: o.buffer,
827
918
  count: 0
828
919
  };
829
- self.postMessage(h, [n.buffer]), n = null;
920
+ self.postMessage(x, [o.buffer]), o = null;
830
921
  return;
831
922
  }
832
- const D = c.x, k = c.y, B = c.z, E = l.x, w = l.y, M = l.z, U = 1e-4, V = Math.abs(D - S.x) > U || Math.abs(k - S.y) > U || Math.abs(B - S.z) > U, g = Math.abs(E - b.x) > U || Math.abs(w - b.y) > U || Math.abs(M - b.z) > U;
833
- if (!m && !V && !g)
923
+ const B = i.x, T = i.y, U = i.z, C = l.x, _ = l.y, I = l.z, P = 1e-4, V = Math.abs(B - y.x) > P || Math.abs(T - y.y) > P || Math.abs(U - y.z) > P, k = Math.abs(C - v.x) > P || Math.abs(_ - v.y) > P || Math.abs(I - v.z) > P;
924
+ if (!g && !V && !k)
834
925
  return;
835
- m = !1, S.x = D, S.y = k, S.z = B, b.x = E, b.y = w, b.z = M;
836
- let y = 1 / 0, _ = -1 / 0;
837
- for (let h = 0; h < 8; ++h) {
838
- const P = h & 1 ? p.x : x.x, F = h & 2 ? p.y : x.y, u = h & 4 ? p.z : x.z, I = P * E + F * w + u * M;
839
- y = Math.min(y, I), _ = Math.max(_, I);
926
+ g = !1, y.x = B, y.y = T, y.z = U, v.x = C, v.y = _, v.z = I;
927
+ let f = 1 / 0, m = -1 / 0;
928
+ for (let x = 0; x < 8; ++x) {
929
+ const O = x & 1 ? b.x : p.x, L = x & 2 ? b.y : p.y, h = x & 4 ? b.z : p.z, z = O * C + L * _ + h * I;
930
+ f = Math.min(f, z), m = Math.max(m, z);
840
931
  }
841
- const R = t.length / 3, L = _ - y, o = (1 << Math.max(
932
+ const S = t.length / 3, j = m - f, s = (1 << Math.max(
842
933
  10,
843
- Math.min(20, Math.ceil(Math.log2(R / 4)))
934
+ Math.min(20, Math.ceil(Math.log2(S / 4)))
844
935
  )) + 1;
845
- if ((!f || f.length !== R) && (f = new Uint32Array(R)), !T || T.length !== o ? T = new Uint32Array(o) : T.fill(0), L < 1e-7) {
846
- for (let h = 0; h < R; ++h) f[h] = 0;
847
- T[0] = R;
848
- } else if (r && r.length > 0) {
849
- const h = r.length / 6;
850
- j.fill(0);
851
- for (let u = 0; u < h; ++u) {
852
- const I = u * 6, Y = r[I + 0], G = r[I + 1], ne = r[I + 2], X = r[I + 3], J = Y * E + G * w + ne * M - y, oe = J - X, ee = J + X, ie = Math.max(
936
+ if ((!E || E.length !== S) && (E = new Uint32Array(S)), !d || d.length !== s ? d = new Uint32Array(s) : d.fill(0), j < 1e-7) {
937
+ for (let x = 0; x < S; ++x) E[x] = 0;
938
+ d[0] = S;
939
+ } else if (n && n.length > 0) {
940
+ const x = n.length / 6;
941
+ q.fill(0);
942
+ for (let h = 0; h < x; ++h) {
943
+ const z = h * 6, G = n[z + 0], $ = n[z + 1], oe = n[z + 2], Z = n[z + 3], J = G * C + $ * _ + oe * I - f, ne = J - Z, K = J + Z, ie = Math.max(
853
944
  0,
854
- Math.floor(oe * O / L)
945
+ Math.floor(ne * A / j)
855
946
  ), ce = Math.min(
856
- O,
857
- Math.ceil(ee * O / L)
947
+ A,
948
+ Math.ceil(K * A / j)
858
949
  );
859
950
  for (let Q = ie; Q < ce; ++Q)
860
- j[Q]++;
951
+ q[Q]++;
861
952
  }
862
- let P = 0;
863
- for (let u = 0; u < O; ++u) P += j[u];
864
- q[0] = 0, W[0] = 0;
865
- for (let u = 1; u < O; ++u)
866
- q[u - 1] = j[u - 1] / P * o >>> 0, W[u] = W[u - 1] + q[u - 1];
867
- q[O - 1] = j[O - 1] / P * o >>> 0;
868
- const F = L / O;
869
- for (let u = 0; u < R; ++u) {
870
- const I = u * 3, Y = t[I + 0], G = t[I + 1], ne = t[I + 2], X = Y * E + G * w + ne * M, oe = (_ - X) / F, ee = Math.max(
953
+ let O = 0;
954
+ for (let h = 0; h < A; ++h) O += q[h];
955
+ N[0] = 0, W[0] = 0;
956
+ for (let h = 1; h < A; ++h)
957
+ N[h - 1] = q[h - 1] / O * s >>> 0, W[h] = W[h - 1] + N[h - 1];
958
+ N[A - 1] = q[A - 1] / O * s >>> 0;
959
+ const L = j / A;
960
+ for (let h = 0; h < S; ++h) {
961
+ const z = h * 3, G = t[z + 0], $ = t[z + 1], oe = t[z + 2], Z = G * C + $ * _ + oe * I, ne = (m - Z) / L, K = Math.max(
871
962
  0,
872
963
  Math.min(
873
- O - 1,
874
- Math.floor(oe)
964
+ A - 1,
965
+ Math.floor(ne)
875
966
  )
876
- ), ie = oe - ee, ce = W[ee] + q[ee] * ie >>> 0, Q = Math.min(ce, o - 1);
877
- f[u] = Q, T[Q]++;
967
+ ), ie = ne - K, ce = W[K] + N[K] * ie >>> 0, Q = Math.min(ce, s - 1);
968
+ E[h] = Q, d[Q]++;
878
969
  }
879
970
  } else {
880
- const h = (o - 1) / L;
881
- for (let P = 0; P < R; ++P) {
882
- const F = P * 3, u = t[F + 0], I = t[F + 1], Y = t[F + 2], G = u * E + I * w + Y * M, X = (_ - G) * h >>> 0, J = Math.min(X, o - 1);
883
- f[P] = J, T[J]++;
971
+ const x = (s - 1) / j;
972
+ for (let O = 0; O < S; ++O) {
973
+ const L = O * 3, h = t[L + 0], z = t[L + 1], G = t[L + 2], $ = h * C + z * _ + G * I, Z = (m - $) * x >>> 0, J = Math.min(Z, s - 1);
974
+ E[O] = J, d[J]++;
884
975
  }
885
976
  }
886
- for (let h = 1; h < o; h++)
887
- T[h] += T[h - 1];
888
- for (let h = R - 1; h >= 0; h--) {
889
- const P = f[h], F = --T[P];
890
- n[F] = a ? a[h] : h;
977
+ for (let x = 1; x < s; x++)
978
+ d[x] += d[x - 1];
979
+ for (let x = S - 1; x >= 0; x--) {
980
+ const O = E[x], L = --d[O];
981
+ o[L] = a ? a[x] : x;
891
982
  }
892
- const d = D * E + k * w + B * M, A = (h) => {
893
- if (!n) return -1 / 0;
894
- const P = n[h], F = P;
895
- if (!t || F * 3 + 2 >= t.length)
983
+ const u = B * C + T * _ + U * I, R = (x) => {
984
+ if (!o) return -1 / 0;
985
+ const O = o[x], L = O;
986
+ if (!t || L * 3 + 2 >= t.length)
896
987
  return -1 / 0;
897
- const u = F * 3;
898
- return t[u] * E + t[u + 1] * w + t[u + 2] * M - d;
988
+ const h = L * 3;
989
+ return t[h] * C + t[h + 1] * _ + t[h + 2] * I - u;
899
990
  };
900
- let z = R;
901
- if (R > 0 && A(R - 1) < 0) {
902
- const h = H(
991
+ let D = S;
992
+ if (S > 0 && R(S - 1) < 0) {
993
+ const x = F(
903
994
  0,
904
- R - 1,
905
- A
995
+ S - 1,
996
+ R
906
997
  );
907
- z = h < 0 ? ~h : h;
998
+ D = x < 0 ? ~x : x;
908
999
  }
909
- const N = {
910
- order: n.buffer,
911
- count: z
1000
+ const H = {
1001
+ order: o.buffer,
1002
+ count: D
912
1003
  };
913
- self.postMessage(N, [n.buffer]), n = null;
1004
+ self.postMessage(H, [o.buffer]), o = null;
914
1005
  };
915
- self.onmessage = (D) => {
916
- const k = D.data;
917
- k.order && (n = new Uint32Array(k.order));
918
- let B = !1;
919
- if (k.centers && (t = new Float32Array(k.centers), B = !0, m = !0), Object.prototype.hasOwnProperty.call(k, "mapping") && (a = k.mapping ? new Uint32Array(k.mapping) : null, m = !0), k.chunks) {
920
- if (r = new Float32Array(k.chunks), r.length > 0 && r[3] > 0)
921
- for (let E = 0; E < r.length / 6; ++E) {
922
- const w = E * 6, M = r[w + 0], U = r[w + 1], V = r[w + 2], g = r[w + 3], y = r[w + 4], _ = r[w + 5];
923
- r[w + 0] = (M + g) * 0.5, r[w + 1] = (U + y) * 0.5, r[w + 2] = (V + _) * 0.5, r[w + 3] = Math.sqrt(
924
- (g - M) ** 2 + (y - U) ** 2 + (_ - V) ** 2
1006
+ self.onmessage = (B) => {
1007
+ const T = B.data;
1008
+ T.order && (o = new Uint32Array(T.order));
1009
+ let U = !1;
1010
+ if (T.centers && (t = new Float32Array(T.centers), U = !0, g = !0), Object.prototype.hasOwnProperty.call(T, "mapping") && (a = T.mapping ? new Uint32Array(T.mapping) : null, g = !0), T.chunks) {
1011
+ if (n = new Float32Array(T.chunks), n.length > 0 && n[3] > 0)
1012
+ for (let C = 0; C < n.length / 6; ++C) {
1013
+ const _ = C * 6, I = n[_ + 0], P = n[_ + 1], V = n[_ + 2], k = n[_ + 3], f = n[_ + 4], m = n[_ + 5];
1014
+ n[_ + 0] = (I + k) * 0.5, n[_ + 1] = (P + f) * 0.5, n[_ + 2] = (V + m) * 0.5, n[_ + 3] = Math.sqrt(
1015
+ (k - I) ** 2 + (f - P) ** 2 + (m - V) ** 2
925
1016
  ) * 0.5;
926
1017
  }
927
- m = !0;
1018
+ g = !0;
928
1019
  }
929
- if (B && t && t.length > 0) {
930
- p.x = x.x = t[0], p.y = x.y = t[1], p.z = x.z = t[2];
931
- for (let E = 1; E < t.length / 3; E++) {
932
- const w = E * 3;
933
- p.x = Math.min(p.x, t[w + 0]), x.x = Math.max(x.x, t[w + 0]), p.y = Math.min(p.y, t[w + 1]), x.y = Math.max(x.y, t[w + 1]), p.z = Math.min(p.z, t[w + 2]), x.z = Math.max(x.z, t[w + 2]);
1020
+ if (U && t && t.length > 0) {
1021
+ b.x = p.x = t[0], b.y = p.y = t[1], b.z = p.z = t[2];
1022
+ for (let C = 1; C < t.length / 3; C++) {
1023
+ const _ = C * 3;
1024
+ b.x = Math.min(b.x, t[_ + 0]), p.x = Math.max(p.x, t[_ + 0]), b.y = Math.min(b.y, t[_ + 1]), p.y = Math.max(p.y, t[_ + 1]), b.z = Math.min(b.z, t[_ + 2]), p.z = Math.max(p.z, t[_ + 2]);
934
1025
  }
935
- } else B && t && t.length === 0 && (p.x = x.x = p.y = x.y = p.z = x.z = 0);
936
- k.cameraPosition && (c = k.cameraPosition), k.cameraDirection && (l = k.cameraDirection), $();
1026
+ } else U && t && t.length === 0 && (b.x = p.x = b.y = p.y = b.z = p.z = 0);
1027
+ T.cameraPosition && (i = T.cameraPosition), T.cameraDirection && (l = T.cameraDirection), Y();
937
1028
  };
938
1029
  }).toString()})();`;
939
1030
  }
940
1031
  }
941
- const Re = (C, e) => {
942
- const s = de(C), n = de(e);
943
- return s | n << 16;
1032
+ const Re = (M, e) => {
1033
+ const r = he(M), o = he(e);
1034
+ return r | o << 16;
944
1035
  };
945
- function de(C) {
946
- const e = new Float32Array([C]), n = new Int32Array(e.buffer)[0];
947
- let t = n >> 16 & 32768, r = n >> 12 & 2047;
948
- const a = n >> 23 & 255;
949
- return a < 103 ? t : a > 142 ? (t |= 31744, t |= (a === 255 ? 0 : 1) && n & 8388607, t) : a < 113 ? (r |= 2048, t |= (r >> 114 - a) + (r >> 113 - a & 1), t) : (t |= a - 112 << 10 | r >> 1, t += r & 1, t);
1036
+ function he(M) {
1037
+ const e = new Float32Array([M]), o = new Int32Array(e.buffer)[0];
1038
+ let t = o >> 16 & 32768, n = o >> 12 & 2047;
1039
+ const a = o >> 23 & 255;
1040
+ return a < 103 ? t : a > 142 ? (t |= 31744, t |= (a === 255 ? 0 : 1) && o & 8388607, t) : a < 113 ? (n |= 2048, t |= (n >> 114 - a) + (n >> 113 - a & 1), t) : (t |= a - 112 << 10 | n >> 1, t += n & 1, t);
950
1041
  }
951
- const ze = new ArrayBuffer(4), pe = new DataView(ze), Pe = (C) => (pe.setUint32(0, C, !0), pe.getFloat32(0, !0));
952
- class Oe {
1042
+ const Pe = new ArrayBuffer(4), pe = new DataView(Pe), Ie = (M) => (pe.setUint32(0, M, !0), pe.getFloat32(0, !0));
1043
+ class ke {
953
1044
  /**
954
1045
  * Create a new TextureManager for a set of splats
955
1046
  * @param splatData The splat data to manage textures for
956
1047
  */
957
1048
  constructor(e) {
958
- v(this, "transformA");
1049
+ w(this, "transformA");
959
1050
  // position xyz and rotation quaternion y,z components
960
- v(this, "transformB");
1051
+ w(this, "transformB");
961
1052
  // rotation quaternion x and scale xyz
962
- v(this, "colorTexture");
1053
+ w(this, "colorTexture");
963
1054
  // color an opacity
964
- v(this, "orderTexture");
965
- v(this, "textureWidth");
966
- v(this, "textureHeight");
967
- const s = e.numSplats;
968
- this.textureWidth = Math.ceil(Math.sqrt(s)), this.textureHeight = Math.ceil(s / this.textureWidth), this.transformA = this.createTransformATexture(e), this.transformB = this.createTransformBTexture(e), this.colorTexture = this.createColorTexture(e), this.orderTexture = this.createOrderTexture(s);
1055
+ w(this, "orderTexture");
1056
+ w(this, "textureWidth");
1057
+ w(this, "textureHeight");
1058
+ const r = e.numSplats;
1059
+ this.textureWidth = Math.ceil(Math.sqrt(r)), this.textureHeight = Math.ceil(r / this.textureWidth), this.transformA = this.createTransformATexture(e), this.transformB = this.createTransformBTexture(e), this.colorTexture = this.createColorTexture(e), this.orderTexture = this.createOrderTexture(r);
969
1060
  }
970
1061
  /**
971
1062
  * Create the transform A texture (positions and quaternion w component)
@@ -973,24 +1064,24 @@ class Oe {
973
1064
  * @returns DataTexture containing position data
974
1065
  */
975
1066
  createTransformATexture(e) {
976
- const s = e.numSplats, n = new Float32Array(
1067
+ const r = e.numSplats, o = new Float32Array(
977
1068
  this.textureWidth * this.textureHeight * 4
978
1069
  );
979
- for (let r = 0; r < s; r++) {
980
- const a = r * 4, c = r * 3, l = r * 4;
981
- n[a] = e.positions[c], n[a + 1] = e.positions[c + 1], n[a + 2] = e.positions[c + 2];
982
- const m = e.rotations[l + 0], S = e.rotations[l + 1], b = Re(m, S);
983
- n[a + 3] = Pe(b);
1070
+ for (let n = 0; n < r; n++) {
1071
+ const a = n * 4, i = n * 3, l = n * 4;
1072
+ o[a] = e.positions[i], o[a + 1] = e.positions[i + 1], o[a + 2] = e.positions[i + 2];
1073
+ const g = e.rotations[l + 0], y = e.rotations[l + 1], v = Re(g, y);
1074
+ o[a + 3] = Ie(v);
984
1075
  }
985
- const t = new i.DataTexture(
986
- n,
1076
+ const t = new c.DataTexture(
1077
+ o,
987
1078
  this.textureWidth,
988
1079
  this.textureHeight,
989
- i.RGBAFormat,
990
- i.FloatType
1080
+ c.RGBAFormat,
1081
+ c.FloatType
991
1082
  // Store as Float32, shader will reinterpret bits
992
1083
  );
993
- return t.needsUpdate = !0, t.magFilter = i.NearestFilter, t.minFilter = i.NearestFilter, t;
1084
+ return t.needsUpdate = !0, t.magFilter = c.NearestFilter, t.minFilter = c.NearestFilter, t;
994
1085
  }
995
1086
  /**
996
1087
  * Create the transform B texture (scale and rotation xyz)
@@ -998,21 +1089,21 @@ class Oe {
998
1089
  * @returns DataTexture containing scale and rotation data
999
1090
  */
1000
1091
  createTransformBTexture(e) {
1001
- const s = e.numSplats, n = new Float32Array(
1092
+ const r = e.numSplats, o = new Float32Array(
1002
1093
  this.textureWidth * this.textureHeight * 4
1003
1094
  );
1004
- for (let r = 0; r < s; r++) {
1005
- const a = r * 4, c = r * 3, l = r * 4;
1006
- n[a] = e.scales[c], n[a + 1] = e.scales[c + 1], n[a + 2] = e.scales[c + 2], n[a + 3] = e.rotations[l + 2];
1095
+ for (let n = 0; n < r; n++) {
1096
+ const a = n * 4, i = n * 3, l = n * 4;
1097
+ o[a] = e.scales[i], o[a + 1] = e.scales[i + 1], o[a + 2] = e.scales[i + 2], o[a + 3] = e.rotations[l + 2];
1007
1098
  }
1008
- const t = new i.DataTexture(
1009
- n,
1099
+ const t = new c.DataTexture(
1100
+ o,
1010
1101
  this.textureWidth,
1011
1102
  this.textureHeight,
1012
- i.RGBAFormat,
1013
- i.FloatType
1103
+ c.RGBAFormat,
1104
+ c.FloatType
1014
1105
  );
1015
- return t.needsUpdate = !0, t.magFilter = i.NearestFilter, t.minFilter = i.NearestFilter, t;
1106
+ return t.needsUpdate = !0, t.magFilter = c.NearestFilter, t.minFilter = c.NearestFilter, t;
1016
1107
  }
1017
1108
  /**
1018
1109
  * Create the color texture (RGB and opacity)
@@ -1020,19 +1111,19 @@ class Oe {
1020
1111
  * @returns DataTexture containing color data
1021
1112
  */
1022
1113
  createColorTexture(e) {
1023
- const s = e.numSplats, n = new Float32Array(
1114
+ const r = e.numSplats, o = new Float32Array(
1024
1115
  this.textureWidth * this.textureHeight * 4
1025
1116
  );
1026
- for (let r = 0; r < s; r++) {
1027
- const a = r * 4, c = r * 3;
1028
- n[a] = e.colors[c], n[a + 1] = e.colors[c + 1], n[a + 2] = e.colors[c + 2], n[a + 3] = e.opacities[r];
1117
+ for (let n = 0; n < r; n++) {
1118
+ const a = n * 4, i = n * 3;
1119
+ o[a] = e.colors[i], o[a + 1] = e.colors[i + 1], o[a + 2] = e.colors[i + 2], o[a + 3] = e.opacities[n];
1029
1120
  }
1030
- const t = new i.DataTexture(
1031
- n,
1121
+ const t = new c.DataTexture(
1122
+ o,
1032
1123
  this.textureWidth,
1033
1124
  this.textureHeight,
1034
- i.RGBAFormat,
1035
- i.FloatType
1125
+ c.RGBAFormat,
1126
+ c.FloatType
1036
1127
  );
1037
1128
  return t.needsUpdate = !0, t;
1038
1129
  }
@@ -1042,23 +1133,23 @@ class Oe {
1042
1133
  * @returns DataTexture for storing order indices
1043
1134
  */
1044
1135
  createOrderTexture(e) {
1045
- const s = new Uint32Array(this.textureWidth * this.textureHeight);
1136
+ const r = new Uint32Array(this.textureWidth * this.textureHeight);
1046
1137
  for (let t = 0; t < e; t++)
1047
- s[t] = t;
1048
- const n = new i.DataTexture(
1049
- s,
1138
+ r[t] = t;
1139
+ const o = new c.DataTexture(
1140
+ r,
1050
1141
  this.textureWidth,
1051
1142
  this.textureHeight,
1052
- i.RedIntegerFormat,
1053
- i.UnsignedIntType
1143
+ c.RedIntegerFormat,
1144
+ c.UnsignedIntType
1054
1145
  );
1055
- return n.needsUpdate = !0, n;
1146
+ return o.needsUpdate = !0, o;
1056
1147
  }
1057
1148
  dispose() {
1058
1149
  this.transformA.dispose(), this.transformB.dispose(), this.colorTexture.dispose(), this.orderTexture.dispose();
1059
1150
  }
1060
1151
  }
1061
- const Be = (
1152
+ const ze = (
1062
1153
  /* glsl */
1063
1154
  `
1064
1155
  precision highp float;
@@ -1264,6 +1355,10 @@ void main(void) {
1264
1355
  float l1 = sqrt(lambda1) * scaleFactor; // scaleX
1265
1356
  float l2 = sqrt(lambda2) * scaleFactor; // scaleY
1266
1357
 
1358
+ float vmin = min(512.0, min(viewport.x, viewport.y));
1359
+ l1 = min(l1, 2.0 * vmin);
1360
+ l2 = min(l2, 2.0 * vmin);
1361
+
1267
1362
  // Early out tiny splats
1268
1363
  if (l1 < 2.0 && l2 < 2.0) { // Check if smaller than ~2 pixel
1269
1364
  gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
@@ -1274,14 +1369,15 @@ void main(void) {
1274
1369
  vec2 v1_scaled = l1 * v1_eigen;
1275
1370
  vec2 v2_scaled = l2 * v2_eigen;
1276
1371
 
1277
- // --- FRUSTUM CHECK ---
1372
+ // --- FRUSTUM CHECK (laxo, estilo PlayCanvas) ---
1278
1373
 
1279
- vec2 clipRadius = vec2(max(l1, l2)) * (centerClip.w / viewport);
1374
+ vec2 c = centerClip.ww / viewport; // pixel to clip
1375
+ float r = max(l1, l2); // radius in pixels
1280
1376
 
1281
- // Check if the bounding circle's edge is outside the [-w, w] range in clip space for x or y
1282
- if (any(greaterThan(abs(centerClip.xy) + clipRadius, vec2(abs(centerClip.w))))) {
1283
- gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Off-screen
1284
- return;
1377
+ // Remove if the center - radius is already out of -w..w
1378
+ if (any(greaterThan(abs(centerClip.xy) - vec2(r) * c, centerClip.ww))) {
1379
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
1380
+ return;
1285
1381
  }
1286
1382
 
1287
1383
  // --- END FRUSTUM CHECK ---
@@ -1311,7 +1407,7 @@ void main(void) {
1311
1407
  vUv = clippedCornerOffset;
1312
1408
  }
1313
1409
  `
1314
- ), Fe = (
1410
+ ), De = (
1315
1411
  /* glsl */
1316
1412
  `
1317
1413
  precision highp float;
@@ -1319,6 +1415,14 @@ precision highp float;
1319
1415
  varying vec4 vColor; // Color and opacity passed from vertex shader
1320
1416
  varying vec2 vUv; // Quad UV coordinates (-1 to 1) passed from vertex shader
1321
1417
 
1418
+ // Fast approximate e^x based on https://nic.schraudolph.org/pubs/Schraudolph99.pdf
1419
+ const float EXP_A = 12102203.0; // ≈ 2^23 / ln(2)
1420
+ const int EXP_BC_RMS = 1064866808; // (127 << 23) - 60801 * 8
1421
+ float fastExp(float x) {
1422
+ int i = int(EXP_A * x) + EXP_BC_RMS;
1423
+ return intBitsToFloat(i);
1424
+ }
1425
+
1322
1426
  void main(void) {
1323
1427
 
1324
1428
  float distSq = dot(vUv, vUv); // Calculate squared distance from center (in the quad's coordinate system)
@@ -1328,7 +1432,7 @@ void main(void) {
1328
1432
  // The factor 4.0 corresponds to the original implementation's scaling.
1329
1433
  // factor = 1 / (2 * sigma^2), where sigma controls the spread.
1330
1434
  // Using 4.0 implies sigma^2 = 1/8.
1331
- float alpha = exp(-distSq * 4.0) * vColor.a;
1435
+ float alpha = fastExp(-distSq * 4.0) * vColor.a;
1332
1436
 
1333
1437
  if (alpha < 1.0 / 255.0) discard; // Discard fragments with very low alpha
1334
1438
 
@@ -1337,56 +1441,56 @@ void main(void) {
1337
1441
  }
1338
1442
  `
1339
1443
  );
1340
- class De extends i.ShaderMaterial {
1444
+ class Oe extends c.ShaderMaterial {
1341
1445
  constructor(e = {}) {
1342
- const s = {
1446
+ const r = {
1343
1447
  // Textures (values set via methods)
1344
1448
  transformA: { value: null },
1345
1449
  transformB: { value: null },
1346
1450
  splatColor: { value: null },
1347
1451
  splatOrder: { value: null },
1348
1452
  // Other uniforms
1349
- viewport: { value: new i.Vector2(1, 1) },
1453
+ viewport: { value: new c.Vector2(1, 1) },
1350
1454
  // Will be updated
1351
1455
  numSplats: { value: 0 }
1352
1456
  // Max splats to render (updated by sorter)
1353
1457
  };
1354
1458
  super({
1355
- vertexShader: Be,
1356
- fragmentShader: Fe,
1357
- uniforms: s,
1459
+ vertexShader: ze,
1460
+ fragmentShader: De,
1461
+ uniforms: r,
1358
1462
  transparent: !0,
1359
- blending: i.CustomBlending,
1463
+ blending: c.CustomBlending,
1360
1464
  // Premultiplied alpha blending:
1361
1465
  // color = src_color * src_alpha + dst_color * (1 - src_alpha)
1362
1466
  // alpha = src_alpha * 1 + dst_alpha * (1 - src_alpha)
1363
- blendSrc: i.OneFactor,
1467
+ blendSrc: c.OneFactor,
1364
1468
  // Using ONE because shader outputs premultiplied color (color * alpha)
1365
- blendDst: i.OneMinusSrcAlphaFactor,
1366
- blendSrcAlpha: i.OneFactor,
1469
+ blendDst: c.OneMinusSrcAlphaFactor,
1470
+ blendSrcAlpha: c.OneFactor,
1367
1471
  // source alpha comes from shader
1368
- blendDstAlpha: i.OneMinusSrcAlphaFactor,
1369
- blendEquation: i.AddEquation,
1370
- blendEquationAlpha: i.AddEquation,
1472
+ blendDstAlpha: c.OneMinusSrcAlphaFactor,
1473
+ blendEquation: c.AddEquation,
1474
+ blendEquationAlpha: c.AddEquation,
1371
1475
  depthTest: !0,
1372
1476
  depthWrite: !1,
1373
1477
  // Disable depth write for transparency
1374
- side: i.DoubleSide,
1478
+ side: c.DoubleSide,
1375
1479
  // Render both sides (or CULLFACE_NONE equivalent)
1376
1480
  // Optional settings from constructor
1377
1481
  alphaTest: e.alphaTest !== void 0 ? e.alphaTest : 0,
1378
1482
  // Typically 0 for blending
1379
1483
  toneMapped: e.toneMapped !== void 0 ? e.toneMapped : !1
1380
1484
  // prettier-ignore
1381
- }), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = i.NoBlending);
1485
+ }), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = c.NoBlending);
1382
1486
  }
1383
1487
  /**
1384
1488
  * Update the viewport size
1385
1489
  * @param width Viewport width
1386
1490
  * @param height Viewport height
1387
1491
  */
1388
- updateViewport(e, s) {
1389
- this.uniforms.viewport.value.set(e, s);
1492
+ updateViewport(e, r) {
1493
+ this.uniforms.viewport.value.set(e, r);
1390
1494
  }
1391
1495
  /**
1392
1496
  * Set transform texture A (positions)
@@ -1424,38 +1528,59 @@ class De extends i.ShaderMaterial {
1424
1528
  this.uniforms.numSplats.value = e;
1425
1529
  }
1426
1530
  }
1427
- const K = class K extends i.Mesh {
1531
+ const X = class X extends c.Mesh {
1428
1532
  // Match shader constant
1429
1533
  /**
1430
1534
  * Create a new SplatMesh for rendering Gaussian splats
1431
1535
  * @param splatData The splat data to render
1432
1536
  * @param options Rendering options
1433
1537
  */
1434
- constructor(s, n = {}) {
1435
- const t = new De(n), r = K.createInstancedGeometry(s.numSplats, K.INSTANCE_SIZE);
1436
- super(r, t);
1437
- v(this, "sorter");
1438
- v(this, "splatData");
1439
- v(this, "options");
1440
- v(this, "textureManager");
1441
- v(this, "material");
1442
- v(this, "geometry");
1443
- v(this, "lastCameraPositionLocal", new i.Vector3());
1444
- v(this, "lastCameraDirectionLocal", new i.Vector3());
1445
- v(this, "invModelMatrix", new i.Matrix4());
1446
- this.geometry = r, this.material = t, this.splatData = s, this.frustumCulled = !1, this.options = { autoSort: !0, ...n }, this.textureManager = new Oe(s), this.sorter = new Ie();
1447
- let a = this.createChunks() || void 0;
1448
- a === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), a = void 0, this.sorter.init(
1538
+ constructor(r, o = {}) {
1539
+ const t = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0;
1540
+ t && console.debug(
1541
+ "[1/8] MESH SplatMesh: creating mesh with",
1542
+ r.numSplats,
1543
+ "splats"
1544
+ );
1545
+ const n = new Oe(o), a = X.createInstancedGeometry(r.numSplats, X.INSTANCE_SIZE);
1546
+ t && console.debug(
1547
+ "[2/8] MESH SplatMesh: created instanced geometry with",
1548
+ Math.ceil(r.numSplats / X.INSTANCE_SIZE),
1549
+ "instances"
1550
+ );
1551
+ super(a, n);
1552
+ w(this, "sorter");
1553
+ w(this, "splatData");
1554
+ w(this, "options");
1555
+ w(this, "textureManager");
1556
+ w(this, "material");
1557
+ w(this, "geometry");
1558
+ w(this, "lastCameraPositionLocal", new c.Vector3());
1559
+ w(this, "lastCameraDirectionLocal", new c.Vector3());
1560
+ w(this, "invModelMatrix", new c.Matrix4());
1561
+ this.geometry = a, this.material = n, this.splatData = r, this.frustumCulled = !1, this.options = { autoSort: !0, ...o }, t && console.debug("[3/8] MESH SplatMesh: initializing texture manager"), this.textureManager = new ke(r), this.sorter = new Ce(), t && console.debug("[4/8] MESH SplatMesh: creating chunks for sorter");
1562
+ let i = this.createChunks() || void 0;
1563
+ i === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), i = void 0, t && console.debug(
1564
+ "[5/8] MESH SplatMesh: initializing sorter with",
1565
+ i ? "chunks" : "no chunks"
1566
+ ), this.sorter.init(
1449
1567
  this.textureManager.orderTexture,
1450
1568
  this.splatData.centers,
1451
- a ?? void 0
1569
+ i ?? void 0
1452
1570
  ), this.sorter.addEventListener(
1453
1571
  "updated",
1454
- (c) => {
1455
- const l = c.count;
1456
- this.geometry.instanceCount = Math.ceil(l / K.INSTANCE_SIZE), this.material.setNumSplats(l);
1572
+ (l) => {
1573
+ const g = l.count;
1574
+ t && console.debug(
1575
+ "[6/8] MESH SplatMesh: sorter updated, rendering",
1576
+ g,
1577
+ "splats"
1578
+ ), this.geometry.instanceCount = Math.ceil(g / X.INSTANCE_SIZE), this.material.setNumSplats(g);
1457
1579
  }
1458
- ), this.material.setTransformA(this.textureManager.transformA), this.material.setTransformB(this.textureManager.transformB), this.material.setColorTexture(this.textureManager.colorTexture), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setNumSplats(0), this.geometry.boundingBox = s.boundingBox.toBox3(), this.geometry.boundingSphere = new i.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere);
1580
+ ), t && console.debug("[7/8] MESH SplatMesh: setting up material textures"), this.material.setTransformA(this.textureManager.transformA), this.material.setTransformB(this.textureManager.transformB), this.material.setColorTexture(this.textureManager.colorTexture), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setNumSplats(0), this.geometry.boundingBox = r.boundingBox.toBox3(), this.geometry.boundingSphere = new c.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), t && console.debug(
1581
+ "[8/8] MESH SplatMesh: mesh initialization complete, bounding box:",
1582
+ r.boundingBox
1583
+ );
1459
1584
  }
1460
1585
  /**
1461
1586
  * Creates the instanced geometry for rendering splats.
@@ -1463,8 +1588,16 @@ const K = class K extends i.Mesh {
1463
1588
  * @param instanceSize Number of splats per instance.
1464
1589
  * @returns InstancedBufferGeometry
1465
1590
  */
1466
- static createInstancedGeometry(s, n) {
1467
- const t = Math.ceil(s / n), r = new i.BufferGeometry(), a = new Float32Array([
1591
+ static createInstancedGeometry(r, o) {
1592
+ const t = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0, n = Math.ceil(r / o);
1593
+ t && console.debug(
1594
+ "MESH createInstancedGeometry: creating geometry for",
1595
+ r,
1596
+ "splats,",
1597
+ n,
1598
+ "instances"
1599
+ );
1600
+ const a = new c.BufferGeometry(), i = new Float32Array([
1468
1601
  // x, y, splat_index_in_instance
1469
1602
  -1,
1470
1603
  -1,
@@ -1478,57 +1611,79 @@ const K = class K extends i.Mesh {
1478
1611
  -1,
1479
1612
  1,
1480
1613
  0
1481
- ]), c = new Uint16Array([0, 1, 2, 0, 2, 3]), l = new Float32Array(4 * 3 * n);
1482
- for (let p = 0; p < n; p++) {
1483
- const x = p * 4 * 3;
1484
- for (let f = 0; f < 4; f++)
1485
- l[x + f * 3 + 0] = a[f * 3 + 0], l[x + f * 3 + 1] = a[f * 3 + 1], l[x + f * 3 + 2] = p;
1614
+ ]), l = new Uint16Array([0, 1, 2, 0, 2, 3]), g = new Float32Array(4 * 3 * o);
1615
+ for (let p = 0; p < o; p++) {
1616
+ const E = p * 4 * 3;
1617
+ for (let d = 0; d < 4; d++)
1618
+ g[E + d * 3 + 0] = i[d * 3 + 0], g[E + d * 3 + 1] = i[d * 3 + 1], g[E + d * 3 + 2] = p;
1486
1619
  }
1487
- const m = new Uint32Array(6 * n);
1488
- for (let p = 0; p < n; p++) {
1489
- const x = p * 6, f = p * 4;
1490
- m[x + 0] = c[0] + f, m[x + 1] = c[1] + f, m[x + 2] = c[2] + f, m[x + 3] = c[3] + f, m[x + 4] = c[4] + f, m[x + 5] = c[5] + f;
1620
+ const y = new Uint32Array(6 * o);
1621
+ for (let p = 0; p < o; p++) {
1622
+ const E = p * 6, d = p * 4;
1623
+ y[E + 0] = l[0] + d, y[E + 1] = l[1] + d, y[E + 2] = l[2] + d, y[E + 3] = l[3] + d, y[E + 4] = l[4] + d, y[E + 5] = l[5] + d;
1491
1624
  }
1492
- r.setAttribute("position", new i.BufferAttribute(l, 3)), r.setIndex(new i.BufferAttribute(m, 1));
1493
- const S = new i.InstancedBufferGeometry();
1494
- S.index = r.index, S.setAttribute("position", r.getAttribute("position"));
1495
- const b = new Uint32Array(t);
1496
- for (let p = 0; p < t; p++)
1497
- b[p] = p * n;
1498
- return S.setAttribute("splatInstanceIndex", new i.InstancedBufferAttribute(b, 1, !1)), S.instanceCount = 0, S;
1625
+ a.setAttribute("position", new c.BufferAttribute(g, 3)), a.setIndex(new c.BufferAttribute(y, 1));
1626
+ const v = new c.InstancedBufferGeometry();
1627
+ v.index = a.index, v.setAttribute("position", a.getAttribute("position"));
1628
+ const b = new Uint32Array(n);
1629
+ for (let p = 0; p < n; p++)
1630
+ b[p] = p * o;
1631
+ return v.setAttribute("splatInstanceIndex", new c.InstancedBufferAttribute(b, 1, !1)), v.instanceCount = 0, t && console.debug(
1632
+ "MESH createInstancedGeometry: geometry created with",
1633
+ v.attributes.position.count,
1634
+ "vertices"
1635
+ ), v;
1499
1636
  }
1500
1637
  /**
1501
1638
  * Create chunks data (bounding box min/max) for the sorter.
1502
1639
  * @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
1503
1640
  */
1504
1641
  createChunks() {
1505
- const s = this.splatData.boundingBox;
1506
- return s.min.x === 1 / 0 || s.max.x === -1 / 0 ? null : new Float32Array([
1507
- s.min.x,
1508
- s.min.y,
1509
- s.min.z,
1510
- s.max.x,
1511
- s.max.y,
1512
- s.max.z
1642
+ const r = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0, o = this.splatData.boundingBox;
1643
+ if (o.min.x === 1 / 0 || o.max.x === -1 / 0)
1644
+ return r && console.debug(
1645
+ "MESH createChunks: invalid bounding box, cannot create chunks"
1646
+ ), null;
1647
+ const t = new Float32Array([
1648
+ o.min.x,
1649
+ o.min.y,
1650
+ o.min.z,
1651
+ o.max.x,
1652
+ o.max.y,
1653
+ o.max.z
1513
1654
  ]);
1655
+ return r && console.debug(
1656
+ "MESH createChunks: created chunks with bounding box",
1657
+ o
1658
+ ), t;
1514
1659
  }
1515
1660
  /**
1516
1661
  * Update the viewport size
1517
1662
  * @param width Viewport width
1518
1663
  * @param height Viewport height
1519
1664
  */
1520
- updateViewport(s, n) {
1521
- this.material.updateViewport(s, n);
1665
+ updateViewport(r, o) {
1666
+ (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0 && console.debug(
1667
+ "MESH updateViewport: updating viewport to",
1668
+ r,
1669
+ "x",
1670
+ o
1671
+ ), this.material.updateViewport(r, o);
1522
1672
  }
1523
1673
  /**
1524
1674
  * Sorts splats based on camera position and direction.
1525
1675
  * @param camera The camera to sort against.
1526
1676
  */
1527
- sort(s) {
1528
- const n = new i.Vector3(), t = new i.Vector3();
1529
- s.getWorldPosition(n), s.getWorldDirection(t), this.invModelMatrix.copy(this.matrixWorld).invert();
1530
- const r = n.applyMatrix4(this.invModelMatrix), a = t.transformDirection(this.invModelMatrix), c = this.lastCameraPositionLocal.distanceToSquared(r) > 1e-6, l = this.lastCameraDirectionLocal.dot(a) < 0.999;
1531
- this.options.autoSort && (c || l) && (this.lastCameraPositionLocal.copy(r), this.lastCameraDirectionLocal.copy(a), this.sorter.setCamera(r, a));
1677
+ sort(r) {
1678
+ const o = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0, t = new c.Vector3(), n = new c.Vector3();
1679
+ r.getWorldPosition(t), r.getWorldDirection(n), this.invModelMatrix.copy(this.matrixWorld).invert();
1680
+ const a = t.applyMatrix4(this.invModelMatrix), i = n.transformDirection(this.invModelMatrix), l = this.lastCameraPositionLocal.distanceToSquared(a) > 1e-6, g = this.lastCameraDirectionLocal.dot(i) < 0.999;
1681
+ this.options.autoSort && (l || g) && (o && console.debug(
1682
+ "MESH sort: camera changed, triggering sort. Position changed:",
1683
+ l,
1684
+ "Direction changed:",
1685
+ g
1686
+ ), this.lastCameraPositionLocal.copy(a), this.lastCameraDirectionLocal.copy(i), this.sorter.setCamera(a, i));
1532
1687
  }
1533
1688
  /**
1534
1689
  * THREE.js hook called before rendering the object.
@@ -1539,49 +1694,57 @@ const K = class K extends i.Mesh {
1539
1694
  */
1540
1695
  // prettier-ignore
1541
1696
  // @ts-expect-error scene is not used
1542
- onBeforeRender(s, n, t) {
1697
+ onBeforeRender(r, o, t) {
1543
1698
  this.sort(t);
1544
- const r = s.getSize(new i.Vector2());
1545
- let { width: a, height: c } = r;
1546
- const l = s.xr;
1699
+ const n = r.getSize(new c.Vector2());
1700
+ let { width: a, height: i } = n;
1701
+ const l = r.xr;
1547
1702
  if (l.enabled && l.isPresenting) {
1548
- const m = l.getCamera().cameras[0].view;
1549
- m && (a = m.width, c = m.height);
1703
+ const g = l.getCamera().cameras[0].view;
1704
+ g && (a = g.width, i = g.height);
1550
1705
  }
1551
- this.updateViewport(a, c);
1706
+ this.updateViewport(a, i);
1552
1707
  }
1553
1708
  /**
1554
1709
  * Dispose of resources
1555
1710
  */
1556
1711
  dispose() {
1557
- this.sorter.dispose(), this.geometry.dispose(), this.material.dispose(), this.textureManager.dispose();
1712
+ const r = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0;
1713
+ r && console.debug("MESH dispose: cleaning up mesh resources"), this.sorter.dispose(), this.geometry.dispose(), this.material.dispose(), this.textureManager.dispose(), r && console.debug("MESH dispose: mesh resources cleaned up");
1558
1714
  }
1559
1715
  };
1560
1716
  // Cached inverse matrix
1561
1717
  /** Number of splats combined into a single instanced draw call. */
1562
- v(K, "INSTANCE_SIZE", 128);
1563
- let ae = K, me = !1;
1564
- typeof window < "u" && !me && (Se({ splatPrimitive: ae }), me = !0);
1565
- const je = ({
1566
- plyUrl: C,
1567
- splatOptions: e = {},
1568
- ...s
1718
+ w(X, "INSTANCE_SIZE", 128);
1719
+ let ae = X;
1720
+ const Be = Symbol.for("@speridlabs/visus/SplatMesh");
1721
+ try {
1722
+ Object.defineProperty(ae.prototype, Be, {
1723
+ value: !0,
1724
+ configurable: !1,
1725
+ enumerable: !1,
1726
+ writable: !1
1727
+ });
1728
+ } catch {
1729
+ console.warn("Couldn't define Visus SplatMesh symbol");
1730
+ }
1731
+ const Ve = ({
1732
+ plyUrl: M,
1733
+ debug: e = !1,
1734
+ splatOptions: r = {},
1735
+ ...o
1569
1736
  }) => {
1570
- const n = ve(null), t = Te(ke, C), r = we(
1571
- () => [t, e || {}],
1572
- [t, e]
1737
+ typeof window < "u" && e && (window.__VISUS_SPLAT_DEBUG__ = !0), e && console.debug("SPLAT: rendering", { plyUrl: M, splatOptions: r, meshProps: o });
1738
+ const t = ye(null), n = be(Te, M), a = ve(
1739
+ () => new ae(n, r || {}),
1740
+ [n, r]
1573
1741
  );
1574
- return be(() => {
1575
- const a = n.current;
1576
- return a && !(a instanceof ae) && console.warn(
1577
- "Visus: The 'Splat' component's internal mesh ref is not an instance of the core SplatMesh. This usually means `extend` was not called correctly. Please ensure you have called `extend({ splatPrimitive: SplatMesh })` in your R3F setup, where 'SplatMesh' is the class imported from 'visus' (or 'visus/react')."
1578
- ), () => {
1579
- a && typeof a.dispose == "function" && a.dispose();
1580
- };
1581
- }, []), /* @__PURE__ */ Ee.jsx("splatPrimitive", { ref: n, args: r, ...s });
1742
+ return we(() => () => {
1743
+ e && console.debug("SPLAT: disposing mesh for", M), typeof (a == null ? void 0 : a.dispose) == "function" && a.dispose();
1744
+ }, [a]), /* @__PURE__ */ Ae.jsx("primitive", { ref: t, object: a, ...o });
1582
1745
  };
1583
1746
  export {
1584
- ke as PlyLoader,
1585
- je as Splat,
1747
+ Te as PlyLoader,
1748
+ Ve as Splat,
1586
1749
  ae as SplatMesh
1587
1750
  };