@speridlabs/visus 2.4.1 → 2.4.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/main.es.js CHANGED
@@ -1,14 +1,14 @@
1
- var _e = Object.defineProperty;
2
- var Ve = (a, e, t) => e in a ? _e(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var w = (a, e, t) => Ve(a, typeof e != "symbol" ? e + "" : e, t);
4
- import * as h from "three";
5
- class ye {
1
+ var Nt = Object.defineProperty;
2
+ var $t = (a, t, e) => t in a ? Nt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var x = (a, t, e) => $t(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import * as l from "three";
5
+ class wt {
6
6
  constructor() {
7
- w(this, "min", new h.Vector3(1 / 0, 1 / 0, 1 / 0));
8
- w(this, "max", new h.Vector3(-1 / 0, -1 / 0, -1 / 0));
9
- w(this, "center", new h.Vector3());
7
+ x(this, "min", new l.Vector3(1 / 0, 1 / 0, 1 / 0));
8
+ x(this, "max", new l.Vector3(-1 / 0, -1 / 0, -1 / 0));
9
+ x(this, "center", new l.Vector3());
10
10
  /** Half extents (size/2) */
11
- w(this, "halfExtents", new h.Vector3());
11
+ x(this, "halfExtents", new l.Vector3());
12
12
  }
13
13
  /**
14
14
  * Reset the bounding box to its initial state
@@ -20,15 +20,15 @@ class ye {
20
20
  * Expand the bounding box to include the given point
21
21
  * @param point Point to include in the bounding box
22
22
  */
23
- expandByPoint(e) {
24
- this.min.x = Math.min(this.min.x, e.x), this.min.y = Math.min(this.min.y, e.y), this.min.z = Math.min(this.min.z, e.z), this.max.x = Math.max(this.max.x, e.x), this.max.y = Math.max(this.max.y, e.y), this.max.z = Math.max(this.max.z, e.z), this.updateDerived();
23
+ expandByPoint(t) {
24
+ this.min.x = Math.min(this.min.x, t.x), this.min.y = Math.min(this.min.y, t.y), this.min.z = Math.min(this.min.z, t.z), this.max.x = Math.max(this.max.x, t.x), this.max.y = Math.max(this.max.y, t.y), this.max.z = Math.max(this.max.z, t.z), this.updateDerived();
25
25
  }
26
26
  /**
27
27
  * Expand this bounding box to include another bounding box
28
28
  * @param box Bounding box to include
29
29
  */
30
- expandByBox(e) {
31
- this.min.x = Math.min(this.min.x, e.min.x), this.min.y = Math.min(this.min.y, e.min.y), this.min.z = Math.min(this.min.z, e.min.z), this.max.x = Math.max(this.max.x, e.max.x), this.max.y = Math.max(this.max.y, e.max.y), this.max.z = Math.max(this.max.z, e.max.z), this.updateDerived();
30
+ expandByBox(t) {
31
+ this.min.x = Math.min(this.min.x, t.min.x), this.min.y = Math.min(this.min.y, t.min.y), this.min.z = Math.min(this.min.z, t.min.z), this.max.x = Math.max(this.max.x, t.max.x), this.max.y = Math.max(this.max.y, t.max.y), this.max.z = Math.max(this.max.z, t.max.z), this.updateDerived();
32
32
  }
33
33
  /**
34
34
  * Update the center and half extents based on min/max
@@ -41,38 +41,38 @@ class ye {
41
41
  * @param point Point to check
42
42
  * @returns True if the point is inside the box
43
43
  */
44
- containsPoint(e) {
45
- return e.x >= this.min.x && e.x <= this.max.x && e.y >= this.min.y && e.y <= this.max.y && e.z >= this.min.z && e.z <= this.max.z;
44
+ containsPoint(t) {
45
+ return t.x >= this.min.x && t.x <= this.max.x && t.y >= this.min.y && t.y <= this.max.y && t.z >= this.min.z && t.z <= this.max.z;
46
46
  }
47
47
  /**
48
48
  * Create a Three.js Box3 from this bounding box
49
49
  * @returns THREE.Box3 representation
50
50
  */
51
51
  toBox3() {
52
- return new h.Box3().set(this.min, this.max);
52
+ return new l.Box3().set(this.min, this.max);
53
53
  }
54
54
  /**
55
55
  * Create a clone of this bounding box
56
56
  * @returns New bounding box with the same values
57
57
  */
58
58
  clone() {
59
- const e = new ye();
60
- return e.min.copy(this.min), e.max.copy(this.max), e.center.copy(this.center), e.halfExtents.copy(this.halfExtents), e;
59
+ const t = new wt();
60
+ return t.min.copy(this.min), t.max.copy(this.max), t.center.copy(this.center), t.halfExtents.copy(this.halfExtents), t;
61
61
  }
62
62
  }
63
- class Oe {
64
- constructor(e = 0) {
65
- w(this, "numSplats", 0);
66
- w(this, "positions");
67
- w(this, "rotations");
68
- w(this, "scales");
69
- w(this, "colors");
70
- w(this, "opacities");
71
- w(this, "boundingBox", new ye());
72
- this.numSplats = e, this.allocateBuffers(e);
73
- }
74
- allocateBuffers(e) {
75
- this.positions = new Float32Array(e * 3), this.rotations = new Float32Array(e * 4), this.scales = new Float32Array(e * 3), this.colors = new Float32Array(e * 3), this.opacities = new Float32Array(e);
63
+ class jt {
64
+ constructor(t = 0) {
65
+ x(this, "numSplats", 0);
66
+ x(this, "positions");
67
+ x(this, "rotations");
68
+ x(this, "scales");
69
+ x(this, "colors");
70
+ x(this, "opacities");
71
+ x(this, "boundingBox", new wt());
72
+ this.numSplats = t, this.allocateBuffers(t);
73
+ }
74
+ allocateBuffers(t) {
75
+ this.positions = new Float32Array(t * 3), this.rotations = new Float32Array(t * 4), this.scales = new Float32Array(t * 3), this.colors = new Float32Array(t * 3), this.opacities = new Float32Array(t);
76
76
  }
77
77
  /**
78
78
  * Set data for a specific splat
@@ -83,49 +83,49 @@ class Oe {
83
83
  * @param color Color
84
84
  * @param opacity Opacity value
85
85
  */
86
- setSplat(e, t, s, r, n, o) {
87
- if (e >= this.numSplats)
86
+ setSplat(t, e, s, n, r, o) {
87
+ if (t >= this.numSplats)
88
88
  throw new Error(
89
- `Splat index out of bounds: ${e} >= ${this.numSplats}`
89
+ `Splat index out of bounds: ${t} >= ${this.numSplats}`
90
90
  );
91
- const i = e * 3, u = e * 4, m = e * 3, x = e * 3;
92
- this.positions[i] = t.x, this.positions[i + 1] = t.y, this.positions[i + 2] = t.z, this.rotations[u] = s.x, this.rotations[u + 1] = s.y, this.rotations[u + 2] = s.z, this.rotations[u + 3] = s.w, this.scales[m] = r.x, this.scales[m + 1] = r.y, this.scales[m + 2] = r.z, this.colors[x] = n.r, this.colors[x + 1] = n.g, this.colors[x + 2] = n.b, this.opacities[e] = o;
91
+ const i = t * 3, u = t * 4, y = t * 3, m = t * 3;
92
+ this.positions[i] = e.x, this.positions[i + 1] = e.y, this.positions[i + 2] = e.z, this.rotations[u] = s.x, this.rotations[u + 1] = s.y, this.rotations[u + 2] = s.z, this.rotations[u + 3] = s.w, this.scales[y] = n.x, this.scales[y + 1] = n.y, this.scales[y + 2] = n.z, this.colors[m] = r.r, this.colors[m + 1] = r.g, this.colors[m + 2] = r.b, this.opacities[t] = o;
93
93
  }
94
94
  /**
95
95
  * Get a splat's data
96
96
  * @param index Splat index
97
97
  * @returns Object containing splat data (linear scale)
98
98
  */
99
- getSplat(e) {
100
- if (e >= this.numSplats)
99
+ getSplat(t) {
100
+ if (t >= this.numSplats)
101
101
  throw new Error(
102
- `Splat index out of bounds: ${e} >= ${this.numSplats}`
102
+ `Splat index out of bounds: ${t} >= ${this.numSplats}`
103
103
  );
104
- const t = e * 3, s = e * 4, r = e * 3, n = e * 3;
104
+ const e = t * 3, s = t * 4, n = t * 3, r = t * 3;
105
105
  return {
106
- position: new h.Vector3(
107
- this.positions[t],
108
- this.positions[t + 1],
109
- this.positions[t + 2]
106
+ position: new l.Vector3(
107
+ this.positions[e],
108
+ this.positions[e + 1],
109
+ this.positions[e + 2]
110
110
  ),
111
- rotation: new h.Quaternion(
111
+ rotation: new l.Quaternion(
112
112
  this.rotations[s],
113
113
  this.rotations[s + 1],
114
114
  this.rotations[s + 2],
115
115
  this.rotations[s + 3]
116
116
  ),
117
117
  // Convert log scale back to linear scale for external use
118
- scale: new h.Vector3(
119
- Math.exp(this.scales[r]),
120
- Math.exp(this.scales[r + 1]),
121
- Math.exp(this.scales[r + 2])
118
+ scale: new l.Vector3(
119
+ Math.exp(this.scales[n]),
120
+ Math.exp(this.scales[n + 1]),
121
+ Math.exp(this.scales[n + 2])
122
122
  ),
123
- color: new h.Color(
124
- this.colors[n],
125
- this.colors[n + 1],
126
- this.colors[n + 2]
123
+ color: new l.Color(
124
+ this.colors[r],
125
+ this.colors[r + 1],
126
+ this.colors[r + 2]
127
127
  ),
128
- opacity: this.opacities[e]
128
+ opacity: this.opacities[t]
129
129
  };
130
130
  }
131
131
  /**
@@ -134,14 +134,14 @@ class Oe {
134
134
  */
135
135
  calculateBoundingBox() {
136
136
  this.boundingBox.reset();
137
- const e = new h.Vector3();
138
- for (let t = 0; t < this.numSplats; t++) {
139
- const s = t * 3;
140
- e.set(
137
+ const t = new l.Vector3();
138
+ for (let e = 0; e < this.numSplats; e++) {
139
+ const s = e * 3;
140
+ t.set(
141
141
  this.positions[s],
142
142
  this.positions[s + 1],
143
143
  this.positions[s + 2]
144
- ), this.boundingBox.expandByPoint(e);
144
+ ), this.boundingBox.expandByPoint(t);
145
145
  }
146
146
  return this.boundingBox;
147
147
  }
@@ -150,97 +150,134 @@ class Oe {
150
150
  * This is for visualization/debugging purposes only, not for rendering
151
151
  */
152
152
  createDebugGeometry() {
153
- const e = new h.BufferGeometry();
154
- e.setAttribute(
153
+ const t = new l.BufferGeometry();
154
+ t.setAttribute(
155
155
  "position",
156
- new h.BufferAttribute(this.positions, 3)
156
+ new l.BufferAttribute(this.positions, 3)
157
157
  );
158
- const t = new Float32Array(this.numSplats * 3), s = new h.Quaternion(), r = new h.Euler();
159
- for (let n = 0; n < this.numSplats; n++) {
160
- const o = n * 4, i = n * 3;
158
+ const e = new Float32Array(this.numSplats * 3), s = new l.Quaternion(), n = new l.Euler();
159
+ for (let r = 0; r < this.numSplats; r++) {
160
+ const o = r * 4, i = r * 3;
161
161
  s.set(
162
162
  this.rotations[o],
163
163
  this.rotations[o + 1],
164
164
  this.rotations[o + 2],
165
165
  this.rotations[o + 3]
166
- ), r.setFromQuaternion(s), t[i] = r.x, t[i + 1] = r.y, t[i + 2] = r.z;
166
+ ), n.setFromQuaternion(s), e[i] = n.x, e[i + 1] = n.y, e[i + 2] = n.z;
167
167
  }
168
- return e.setAttribute(
168
+ return t.setAttribute(
169
169
  "rotation",
170
- new h.BufferAttribute(t, 3)
171
- ), e.setAttribute(
170
+ new l.BufferAttribute(e, 3)
171
+ ), t.setAttribute(
172
172
  "scale",
173
- new h.BufferAttribute(this.scales, 3)
174
- ), e.setAttribute(
173
+ new l.BufferAttribute(this.scales, 3)
174
+ ), t.setAttribute(
175
175
  "color",
176
- new h.BufferAttribute(this.colors, 3)
177
- ), e.setAttribute(
176
+ new l.BufferAttribute(this.colors, 3)
177
+ ), t.setAttribute(
178
178
  "opacity",
179
- new h.BufferAttribute(this.opacities, 1)
180
- ), e;
179
+ new l.BufferAttribute(this.opacities, 1)
180
+ ), t;
181
181
  }
182
182
  dispose() {
183
183
  this.numSplats = 0, this.scales = new Float32Array(0), this.colors = new Float32Array(0), this.positions = new Float32Array(0), this.rotations = new Float32Array(0), this.opacities = new Float32Array(0);
184
184
  }
185
185
  }
186
- class ze {
186
+ class Ft {
187
187
  // Upper 8 bits of 16-bit means
188
- constructor(e, t, s) {
189
- w(this, "ranges");
190
- w(this, "numSplats", 0);
191
- w(this, "boundingBox", new ye());
188
+ constructor(t, e, s) {
189
+ x(this, "ranges");
190
+ x(this, "version", 1);
191
+ x(this, "numSplats", 0);
192
+ x(this, "boundingBox", new wt());
192
193
  // Original SOGS textures
193
- w(this, "sh0");
194
+ x(this, "sh0");
194
195
  // SH DC coefficients + alpha
195
- w(this, "quats");
196
+ x(this, "quats");
196
197
  // Quaternion components + mode
197
- w(this, "scales");
198
+ x(this, "scales");
198
199
  // Scale values (8-bit)
199
- w(this, "means_l");
200
+ x(this, "means_l");
200
201
  // Lower 8 bits of 16-bit means
201
- w(this, "means_u");
202
- 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();
202
+ x(this, "means_u");
203
+ this.ranges = e, this.numSplats = t, 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();
203
204
  }
204
205
  calculateBoundingBox() {
205
206
  this.boundingBox.reset();
206
- const { mins: e, maxs: t } = this.ranges.means, s = (r) => Math.sign(r) * (Math.exp(Math.abs(r)) - 1);
207
+ const { mins: t, maxs: e } = this.ranges.means, s = (n) => Math.sign(n) * (Math.exp(Math.abs(n)) - 1);
207
208
  return this.boundingBox.center.set(
208
- (s(e[0]) + s(t[0])) * 0.5,
209
- (s(e[1]) + s(t[1])) * 0.5,
210
- (s(e[2]) + s(t[2])) * 0.5
209
+ (s(t[0]) + s(e[0])) * 0.5,
210
+ (s(t[1]) + s(e[1])) * 0.5,
211
+ (s(t[2]) + s(e[2])) * 0.5
211
212
  ), this.boundingBox.halfExtents.set(
212
- (s(t[0]) - s(e[0])) * 0.5,
213
- (s(t[1]) - s(e[1])) * 0.5,
214
- (s(t[2]) - s(e[2])) * 0.5
213
+ (s(e[0]) - s(t[0])) * 0.5,
214
+ (s(e[1]) - s(t[1])) * 0.5,
215
+ (s(e[2]) - s(t[2])) * 0.5
215
216
  ), this.boundingBox;
216
217
  }
217
218
  dispose() {
218
219
  this.sh0.dispose(), this.quats.dispose(), this.scales.dispose(), this.means_l.dispose(), this.means_u.dispose();
219
220
  }
220
221
  }
221
- class Be {
222
+ class Pt {
223
+ // Upper 8 bits of 16-bit means
224
+ constructor(t, e, s) {
225
+ x(this, "ranges");
226
+ x(this, "version", 2);
227
+ x(this, "numSplats", 0);
228
+ x(this, "boundingBox", new wt());
229
+ // Original SOGS textures
230
+ x(this, "sh0");
231
+ // SH DC coefficients + alpha
232
+ x(this, "quats");
233
+ // Quaternion components + mode
234
+ x(this, "scales");
235
+ // Scale values (8-bit)
236
+ x(this, "means_l");
237
+ // Lower 8 bits of 16-bit means
238
+ x(this, "means_u");
239
+ this.ranges = e, this.numSplats = t, 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();
240
+ }
241
+ calculateBoundingBox() {
242
+ this.boundingBox.reset();
243
+ const { mins: t, maxs: e } = this.ranges.means, s = (n) => Math.sign(n) * (Math.exp(Math.abs(n)) - 1);
244
+ return this.boundingBox.center.set(
245
+ (s(t[0]) + s(e[0])) * 0.5,
246
+ (s(t[1]) + s(e[1])) * 0.5,
247
+ (s(t[2]) + s(e[2])) * 0.5
248
+ ), this.boundingBox.halfExtents.set(
249
+ (s(e[0]) - s(t[0])) * 0.5,
250
+ (s(e[1]) - s(t[1])) * 0.5,
251
+ (s(e[2]) - s(t[2])) * 0.5
252
+ ), this.boundingBox;
253
+ }
254
+ dispose() {
255
+ this.sh0.dispose(), this.quats.dispose(), this.scales.dispose(), this.means_l.dispose(), this.means_u.dispose();
256
+ }
257
+ }
258
+ class At {
222
259
  // RGBA32UI - (Position + Rotation + Scale)
223
260
  // RGBA32UI Texture Content:
224
261
  // .r = Means Lower (RGB)
225
262
  // .g = Means Upper (RGB)
226
263
  // .b = Rotation (RGBA)
227
264
  // .a = Scale (RGB)
228
- constructor(e, t, s, r, n, o, i, u) {
265
+ constructor(t, e, s, n, r, o, i, u) {
229
266
  // Info data - cpu
230
- w(this, "numSplats");
231
- w(this, "textureWidth");
232
- w(this, "textureHeight");
233
- w(this, "ranges");
234
- w(this, "centers");
267
+ x(this, "numSplats");
268
+ x(this, "textureWidth");
269
+ x(this, "textureHeight");
270
+ x(this, "ranges");
271
+ x(this, "centers");
235
272
  // TODO: see if necesary or can be compressed somehow
236
- w(this, "boundingBox");
273
+ x(this, "boundingBox");
237
274
  // GPU Textures
238
- w(this, "packedColor");
275
+ x(this, "packedColor");
239
276
  // RGBA8 - (Color + Opacity)
240
277
  // RGBA8 Texture Content:
241
278
  // .rgb = Color, .a = Opacity
242
- w(this, "packedGeometry");
243
- this.numSplats = e, this.textureWidth = t, this.textureHeight = s, this.boundingBox = u, this.ranges = i, this.centers = r, this.packedColor = o, this.packedGeometry = n;
279
+ x(this, "packedGeometry");
280
+ this.numSplats = t, this.textureWidth = e, this.textureHeight = s, this.boundingBox = u, this.ranges = i, this.centers = n, this.packedColor = o, this.packedGeometry = r;
244
281
  }
245
282
  /**
246
283
  * Optional: Reconstruct a full JS object for a specific splat.
@@ -255,34 +292,34 @@ class Be {
255
292
  // public abstract deserialize(): ISplat;
256
293
  // public abstract returnPacked(): ISplat;
257
294
  }
258
- class Le extends h.EventDispatcher {
295
+ class Yt extends l.EventDispatcher {
259
296
  constructor() {
260
297
  super();
261
- w(this, "worker");
262
- w(this, "centers", null);
263
- w(this, "orderTexture", null);
298
+ x(this, "worker");
299
+ x(this, "centers", null);
300
+ x(this, "orderTexture", null);
264
301
  /** Bounding box data for optimization */
265
- w(this, "chunks", null);
266
- w(this, "lastCameraPosition", new h.Vector3());
267
- w(this, "lastCameraDirection", new h.Vector3());
268
- const t = this.createWorkerCode(), s = new Blob([t], { type: "application/javascript" });
302
+ x(this, "chunks", null);
303
+ x(this, "lastCameraPosition", new l.Vector3());
304
+ x(this, "lastCameraDirection", new l.Vector3());
305
+ const e = this.createWorkerCode(), s = new Blob([e], { type: "application/javascript" });
269
306
  this.worker = new Worker(URL.createObjectURL(s)), this.worker.onmessage = this.onWorkerMessage.bind(this);
270
307
  }
271
308
  /**
272
309
  * Handles messages received from the sorting worker.
273
310
  * @param event The message event from the worker.
274
311
  */
275
- onWorkerMessage(t) {
312
+ onWorkerMessage(e) {
276
313
  if (!this.orderTexture || !this.orderTexture.image)
277
314
  return console.error("SplatSorter: Order texture not initialized!");
278
- const { order: s, count: r } = t.data, n = this.orderTexture.image.data;
279
- if (!(n instanceof Uint32Array))
315
+ const { order: s, count: n } = e.data, r = this.orderTexture.image.data;
316
+ if (!(r instanceof Uint32Array))
280
317
  return console.error(
281
318
  "SplatSorter: Order texture data is not a Uint32Array!"
282
319
  );
283
- n.set(new Uint32Array(s)), this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
284
- const o = n.buffer.slice(0), i = { order: o };
285
- this.worker.postMessage(i, [o]), this.dispatchEvent({ type: "updated", count: r });
320
+ r.set(new Uint32Array(s)), this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
321
+ const o = r.buffer.slice(0), i = { order: o };
322
+ this.worker.postMessage(i, [o]), this.dispatchEvent({ type: "updated", count: n });
286
323
  }
287
324
  /**
288
325
  * Initializes the sorter with necessary data and textures.
@@ -291,35 +328,35 @@ class Le extends h.EventDispatcher {
291
328
  * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
292
329
  * @param transferOwnership Optional: If true, transfers ownership of centers buffer to worker (saves memory, main thread loses access). Default: false.
293
330
  */
294
- init(t, s, r, n = !1) {
295
- if (!t || !(t.image.data instanceof Uint32Array))
331
+ init(e, s, n, r = !1) {
332
+ if (!e || !(e.image.data instanceof Uint32Array))
296
333
  throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
297
334
  if (!s || s.length % 3 !== 0)
298
335
  throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
299
- if (t.image.data.length < s.length / 3)
336
+ if (e.image.data.length < s.length / 3)
300
337
  throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
301
338
  if (s.buffer.byteLength === 0)
302
339
  throw new Error(
303
340
  "SplatSorter: positions buffer is detached (likely React StrictMode + cached asset). "
304
341
  );
305
342
  const o = s.length / 3;
306
- this.orderTexture = t, n ? this.centers = null : this.centers = s.slice();
343
+ this.orderTexture = e, r ? this.centers = null : this.centers = s.slice();
307
344
  const i = this.orderTexture.image.data;
308
- for (let l = 0; l < o; l++) i[l] = l;
345
+ for (let h = 0; h < o; h++) i[h] = h;
309
346
  this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
310
- const u = i.buffer.slice(0), m = n ? s.buffer : s.buffer.slice(0), x = {
347
+ const u = i.buffer.slice(0), y = r ? s.buffer : s.buffer.slice(0), m = {
311
348
  order: u,
312
- centers: m
349
+ centers: y
313
350
  }, c = [
314
351
  u,
315
- m
352
+ y
316
353
  ];
317
- if (r) {
318
- this.chunks = r.slice();
319
- const l = this.chunks.buffer.slice(0);
320
- x.chunks = l, c.push(l);
354
+ if (n) {
355
+ this.chunks = n.slice();
356
+ const h = this.chunks.buffer.slice(0);
357
+ m.chunks = h, c.push(h);
321
358
  }
322
- this.worker.postMessage(x, c), queueMicrotask(() => {
359
+ this.worker.postMessage(m, c), queueMicrotask(() => {
323
360
  this.dispatchEvent({
324
361
  type: "updated",
325
362
  count: o
@@ -331,50 +368,50 @@ class Le extends h.EventDispatcher {
331
368
  * The sorter will only consider splats whose original indices are present in the mapping.
332
369
  * @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
333
370
  */
334
- setMapping(t) {
371
+ setMapping(e) {
335
372
  if (!this.centers)
336
373
  return console.warn(
337
374
  "SplatSorter: Cannot set mapping before initialization."
338
375
  );
339
376
  let s;
340
- const r = [];
341
- if (!t) {
377
+ const n = [];
378
+ if (!e) {
342
379
  const u = this.centers.buffer.slice(0);
343
380
  return s = {
344
381
  centers: u,
345
382
  mapping: null
346
- }, r.push(u), this.worker.postMessage(s, r);
383
+ }, n.push(u), this.worker.postMessage(s, n);
347
384
  }
348
- const n = new Float32Array(t.length * 3);
349
- for (let u = 0; u < t.length; u++) {
350
- const m = t[u];
351
- if (m * 3 + 2 >= this.centers.length) {
385
+ const r = new Float32Array(e.length * 3);
386
+ for (let u = 0; u < e.length; u++) {
387
+ const y = e[u];
388
+ if (y * 3 + 2 >= this.centers.length) {
352
389
  console.warn(
353
- `SplatSorter: Mapping index ${m} out of bounds.`
390
+ `SplatSorter: Mapping index ${y} out of bounds.`
354
391
  );
355
392
  continue;
356
393
  }
357
- const x = m * 3, c = u * 3;
358
- n[c + 0] = this.centers[x + 0], n[c + 1] = this.centers[x + 1], n[c + 2] = this.centers[x + 2];
394
+ const m = y * 3, c = u * 3;
395
+ r[c + 0] = this.centers[m + 0], r[c + 1] = this.centers[m + 1], r[c + 2] = this.centers[m + 2];
359
396
  }
360
- const o = n.buffer.slice(0), i = t.buffer.slice(0);
397
+ const o = r.buffer.slice(0), i = e.buffer.slice(0);
361
398
  s = {
362
399
  centers: o,
363
400
  mapping: i
364
- }, r.push(o, i), this.worker.postMessage(s, r);
401
+ }, n.push(o, i), this.worker.postMessage(s, n);
365
402
  }
366
403
  /**
367
404
  * Updates the camera parameters used for sorting.
368
405
  * @param position The camera's position in the sorter's local coordinate space.
369
406
  * @param direction The camera's forward direction in the sorter's local coordinate space.
370
407
  */
371
- setCamera(t, s) {
372
- const r = this.lastCameraPosition.distanceToSquared(t) > 1e-7, n = this.lastCameraDirection.dot(s) < 0.9999;
373
- if (!r && !n)
408
+ setCamera(e, s) {
409
+ const n = this.lastCameraPosition.distanceToSquared(e) > 1e-7, r = this.lastCameraDirection.dot(s) < 0.9999;
410
+ if (!n && !r)
374
411
  return;
375
- this.lastCameraPosition.copy(t), this.lastCameraDirection.copy(s);
412
+ this.lastCameraPosition.copy(e), this.lastCameraDirection.copy(s);
376
413
  const o = {
377
- cameraPosition: { x: t.x, y: t.y, z: t.z },
414
+ cameraPosition: { x: e.x, y: e.y, z: e.z },
378
415
  cameraDirection: { x: s.x, y: s.y, z: s.z }
379
416
  };
380
417
  this.worker.postMessage(o);
@@ -391,186 +428,186 @@ class Le extends h.EventDispatcher {
391
428
  */
392
429
  createWorkerCode() {
393
430
  return `(${(function() {
394
- let s = null, r = null, n = null, o = null, i = null, u = null, m = !1;
395
- const x = { x: 0, y: 0, z: 0 }, c = { x: 0, y: 0, z: 0 }, l = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 };
396
- let y = null, M = null;
397
- const v = 32, S = new Array(v).fill(0), k = new Array(v).fill(0), B = new Array(v).fill(0), j = (b, A, C) => {
398
- for (; b <= A; ) {
399
- const g = A + b >> 1, d = C(g);
400
- if (d > 0) b = g + 1;
401
- else if (d < 0) A = g - 1;
402
- else return g;
431
+ let s = null, n = null, r = null, o = null, i = null, u = null, y = !1;
432
+ const m = { x: 0, y: 0, z: 0 }, c = { x: 0, y: 0, z: 0 }, h = { x: 0, y: 0, z: 0 }, d = { x: 0, y: 0, z: 0 };
433
+ let w = null, A = null;
434
+ const b = 32, z = new Array(b).fill(0), _ = new Array(b).fill(0), F = new Array(b).fill(0), O = (k, M, B) => {
435
+ for (; k <= M; ) {
436
+ const S = M + k >> 1, g = B(S);
437
+ if (g > 0) k = S + 1;
438
+ else if (g < 0) M = S - 1;
439
+ else return S;
403
440
  }
404
- return ~b;
405
- }, R = () => {
406
- if (!s || !r || !i || !u)
441
+ return ~k;
442
+ }, V = () => {
443
+ if (!s || !n || !i || !u)
407
444
  return;
408
- if (r.length === 0) {
409
- const f = {
445
+ if (n.length === 0) {
446
+ const p = {
410
447
  order: s.buffer,
411
448
  count: 0
412
449
  };
413
- self.postMessage(f, [s.buffer]), s = null;
450
+ self.postMessage(p, [s.buffer]), s = null;
414
451
  return;
415
452
  }
416
- const b = i.x, A = i.y, C = i.z, g = u.x, d = u.y, I = u.z, q = 1e-4, T = Math.abs(b - x.x) > q || Math.abs(A - x.y) > q || Math.abs(C - x.z) > q, W = Math.abs(g - c.x) > q || Math.abs(d - c.y) > q || Math.abs(I - c.z) > q;
417
- if (!m && !T && !W)
453
+ const k = i.x, M = i.y, B = i.z, S = u.x, g = u.y, v = u.z, T = 1e-4, U = Math.abs(k - m.x) > T || Math.abs(M - m.y) > T || Math.abs(B - m.z) > T, I = Math.abs(S - c.x) > T || Math.abs(g - c.y) > T || Math.abs(v - c.z) > T;
454
+ if (!y && !U && !I)
418
455
  return;
419
- m = !1, x.x = b, x.y = A, x.z = C, c.x = g, c.y = d, c.z = I;
420
- let U = 1 / 0, F = -1 / 0;
421
- for (let f = 0; f < 8; ++f) {
422
- const E = f & 1 ? l.x : p.x, V = f & 2 ? l.y : p.y, D = f & 4 ? l.z : p.z, O = E * g + V * d + D * I;
423
- U = Math.min(U, O), F = Math.max(F, O);
456
+ y = !1, m.x = k, m.y = M, m.z = B, c.x = S, c.y = g, c.z = v;
457
+ let P = 1 / 0, f = -1 / 0;
458
+ for (let p = 0; p < 8; ++p) {
459
+ const q = p & 1 ? h.x : d.x, L = p & 2 ? h.y : d.y, E = p & 4 ? h.z : d.z, G = q * S + L * g + E * v;
460
+ P = Math.min(P, G), f = Math.max(f, G);
424
461
  }
425
- const P = r.length / 3, J = F - U, L = (1 << Math.max(
462
+ const C = n.length / 3, Y = f - P, R = (1 << Math.max(
426
463
  10,
427
- Math.min(20, Math.ceil(Math.log2(P / 4)))
464
+ Math.min(20, Math.ceil(Math.log2(C / 4)))
428
465
  )) + 1;
429
- if ((!y || y.length !== P) && (y = new Uint32Array(P)), !M || M.length !== L ? M = new Uint32Array(L) : M.fill(0), J < 1e-7) {
430
- for (let f = 0; f < P; ++f) y[f] = 0;
431
- M[0] = P;
432
- } else if (n && n.length > 0) {
433
- const f = n.length / 6;
434
- S.fill(0);
435
- for (let D = 0; D < f; ++D) {
436
- const O = D * 6, Y = n[O + 0], Z = n[O + 1], Q = n[O + 2], N = n[O + 3], K = Y * g + Z * d + Q * I - U, se = K - N, re = K + N, he = Math.max(
466
+ if ((!w || w.length !== C) && (w = new Uint32Array(C)), !A || A.length !== R ? A = new Uint32Array(R) : A.fill(0), Y < 1e-7) {
467
+ for (let p = 0; p < C; ++p) w[p] = 0;
468
+ A[0] = C;
469
+ } else if (r && r.length > 0) {
470
+ const p = r.length / 6;
471
+ z.fill(0);
472
+ for (let E = 0; E < p; ++E) {
473
+ const G = E * 6, X = r[G + 0], j = r[G + 1], Q = r[G + 2], $ = r[G + 3], K = X * S + j * g + Q * v - P, tt = K - $, et = K + $, mt = Math.max(
437
474
  0,
438
- Math.floor(se * v / J)
439
- ), ue = Math.min(
440
- v,
441
- Math.ceil(re * v / J)
475
+ Math.floor(tt * b / Y)
476
+ ), dt = Math.min(
477
+ b,
478
+ Math.ceil(et * b / Y)
442
479
  );
443
- for (let oe = he; oe < ue; ++oe)
444
- S[oe]++;
480
+ for (let ot = mt; ot < dt; ++ot)
481
+ z[ot]++;
445
482
  }
446
- let E = 0;
447
- for (let D = 0; D < v; ++D) E += S[D];
448
- B[0] = 0, k[0] = 0;
449
- for (let D = 1; D < v; ++D)
450
- B[D - 1] = S[D - 1] / E * L >>> 0, k[D] = k[D - 1] + B[D - 1];
451
- B[v - 1] = S[v - 1] / E * L >>> 0;
452
- const V = J / v;
453
- for (let D = 0; D < P; ++D) {
454
- const O = D * 3, Y = r[O + 0], Z = r[O + 1], Q = r[O + 2], N = Y * g + Z * d + Q * I, se = (F - N) / V, re = Math.max(
483
+ let q = 0;
484
+ for (let E = 0; E < b; ++E) q += z[E];
485
+ F[0] = 0, _[0] = 0;
486
+ for (let E = 1; E < b; ++E)
487
+ F[E - 1] = z[E - 1] / q * R >>> 0, _[E] = _[E - 1] + F[E - 1];
488
+ F[b - 1] = z[b - 1] / q * R >>> 0;
489
+ const L = Y / b;
490
+ for (let E = 0; E < C; ++E) {
491
+ const G = E * 3, X = n[G + 0], j = n[G + 1], Q = n[G + 2], $ = X * S + j * g + Q * v, tt = (f - $) / L, et = Math.max(
455
492
  0,
456
493
  Math.min(
457
- v - 1,
458
- Math.floor(se)
494
+ b - 1,
495
+ Math.floor(tt)
459
496
  )
460
- ), he = se - re, ue = k[re] + B[re] * he >>> 0, oe = Math.min(ue, L - 1);
461
- y[D] = oe, M[oe]++;
497
+ ), mt = tt - et, dt = _[et] + F[et] * mt >>> 0, ot = Math.min(dt, R - 1);
498
+ w[E] = ot, A[ot]++;
462
499
  }
463
500
  } else {
464
- const f = (L - 1) / J;
465
- for (let E = 0; E < P; ++E) {
466
- const V = E * 3, D = r[V + 0], O = r[V + 1], Y = r[V + 2], Z = D * g + O * d + Y * I, N = (F - Z) * f >>> 0, K = Math.min(N, L - 1);
467
- y[E] = K, M[K]++;
501
+ const p = (R - 1) / Y;
502
+ for (let q = 0; q < C; ++q) {
503
+ const L = q * 3, E = n[L + 0], G = n[L + 1], X = n[L + 2], j = E * S + G * g + X * v, $ = (f - j) * p >>> 0, K = Math.min($, R - 1);
504
+ w[q] = K, A[K]++;
468
505
  }
469
506
  }
470
- for (let f = 1; f < L; f++)
471
- M[f] += M[f - 1];
472
- for (let f = P - 1; f >= 0; f--) {
473
- const E = y[f], V = --M[E];
474
- s[V] = o ? o[f] : f;
507
+ for (let p = 1; p < R; p++)
508
+ A[p] += A[p - 1];
509
+ for (let p = C - 1; p >= 0; p--) {
510
+ const q = w[p], L = --A[q];
511
+ s[L] = o ? o[p] : p;
475
512
  }
476
- const X = b * g + A * d + C * I, $ = (f) => {
513
+ const J = k * S + M * g + B * v, Z = (p) => {
477
514
  if (!s) return -1 / 0;
478
- const E = s[f], V = E;
479
- if (!r || V * 3 + 2 >= r.length)
515
+ const q = s[p], L = q;
516
+ if (!n || L * 3 + 2 >= n.length)
480
517
  return -1 / 0;
481
- const D = V * 3;
482
- return r[D] * g + r[D + 1] * d + r[D + 2] * I - X;
518
+ const E = L * 3;
519
+ return n[E] * S + n[E + 1] * g + n[E + 2] * v - J;
483
520
  };
484
- let H = P;
485
- if (P > 0 && $(P - 1) < 0) {
486
- const f = j(
521
+ let H = C;
522
+ if (C > 0 && Z(C - 1) < 0) {
523
+ const p = O(
487
524
  0,
488
- P - 1,
489
- $
525
+ C - 1,
526
+ Z
490
527
  );
491
- H = f < 0 ? ~f : f;
528
+ H = p < 0 ? ~p : p;
492
529
  }
493
- const z = {
530
+ const D = {
494
531
  order: s.buffer,
495
532
  count: H
496
533
  };
497
- self.postMessage(z, [s.buffer]), s = null;
534
+ self.postMessage(D, [s.buffer]), s = null;
498
535
  };
499
- self.onmessage = (b) => {
500
- const A = b.data;
501
- A.order && (s = new Uint32Array(A.order));
502
- let C = !1;
503
- if (A.centers && (r = new Float32Array(A.centers), C = !0, m = !0), Object.prototype.hasOwnProperty.call(A, "mapping") && (o = A.mapping ? new Uint32Array(A.mapping) : null, m = !0), A.chunks) {
504
- if (n = new Float32Array(A.chunks), n.length > 0 && n[3] > 0)
505
- for (let g = 0; g < n.length / 6; ++g) {
506
- const d = g * 6, I = n[d + 0], q = n[d + 1], T = n[d + 2], W = n[d + 3], U = n[d + 4], F = n[d + 5];
507
- n[d + 0] = (I + W) * 0.5, n[d + 1] = (q + U) * 0.5, n[d + 2] = (T + F) * 0.5, n[d + 3] = Math.sqrt(
508
- (W - I) ** 2 + (U - q) ** 2 + (F - T) ** 2
536
+ self.onmessage = (k) => {
537
+ const M = k.data;
538
+ M.order && (s = new Uint32Array(M.order));
539
+ let B = !1;
540
+ if (M.centers && (n = new Float32Array(M.centers), B = !0, y = !0), Object.prototype.hasOwnProperty.call(M, "mapping") && (o = M.mapping ? new Uint32Array(M.mapping) : null, y = !0), M.chunks) {
541
+ if (r = new Float32Array(M.chunks), r.length > 0 && r[3] > 0)
542
+ for (let S = 0; S < r.length / 6; ++S) {
543
+ const g = S * 6, v = r[g + 0], T = r[g + 1], U = r[g + 2], I = r[g + 3], P = r[g + 4], f = r[g + 5];
544
+ r[g + 0] = (v + I) * 0.5, r[g + 1] = (T + P) * 0.5, r[g + 2] = (U + f) * 0.5, r[g + 3] = Math.sqrt(
545
+ (I - v) ** 2 + (P - T) ** 2 + (f - U) ** 2
509
546
  ) * 0.5;
510
547
  }
511
- m = !0;
548
+ y = !0;
512
549
  }
513
- if (C && r && r.length > 0) {
514
- l.x = p.x = r[0], l.y = p.y = r[1], l.z = p.z = r[2];
515
- for (let g = 1; g < r.length / 3; g++) {
516
- const d = g * 3;
517
- l.x = Math.min(l.x, r[d + 0]), p.x = Math.max(p.x, r[d + 0]), l.y = Math.min(l.y, r[d + 1]), p.y = Math.max(p.y, r[d + 1]), l.z = Math.min(l.z, r[d + 2]), p.z = Math.max(p.z, r[d + 2]);
550
+ if (B && n && n.length > 0) {
551
+ h.x = d.x = n[0], h.y = d.y = n[1], h.z = d.z = n[2];
552
+ for (let S = 1; S < n.length / 3; S++) {
553
+ const g = S * 3;
554
+ h.x = Math.min(h.x, n[g + 0]), d.x = Math.max(d.x, n[g + 0]), h.y = Math.min(h.y, n[g + 1]), d.y = Math.max(d.y, n[g + 1]), h.z = Math.min(h.z, n[g + 2]), d.z = Math.max(d.z, n[g + 2]);
518
555
  }
519
- } else C && r && r.length === 0 && (l.x = p.x = l.y = p.y = l.z = p.z = 0);
520
- A.cameraPosition && (i = A.cameraPosition), A.cameraDirection && (u = A.cameraDirection), R();
556
+ } else B && n && n.length === 0 && (h.x = d.x = h.y = d.y = h.z = d.z = 0);
557
+ M.cameraPosition && (i = M.cameraPosition), M.cameraDirection && (u = M.cameraDirection), V();
521
558
  };
522
559
  }).toString()})();`;
523
560
  }
524
561
  }
525
- class Ge {
526
- constructor(e) {
527
- w(this, "packedGeometry");
562
+ class Ht {
563
+ constructor(t) {
564
+ x(this, "packedGeometry");
528
565
  // RGBA32UI
529
- w(this, "packedColor");
566
+ x(this, "packedColor");
530
567
  // RGBA8
531
- w(this, "orderTexture");
568
+ x(this, "orderTexture");
532
569
  // RB32UI
533
- w(this, "width");
534
- w(this, "height");
535
- this.width = e.textureWidth, this.height = e.textureHeight, this.packedColor = this.createColorTexture(e), this.packedGeometry = this.createGeometryTexture(e), this.orderTexture = this.createOrderTexture(e.numSplats);
570
+ x(this, "width");
571
+ x(this, "height");
572
+ this.width = t.textureWidth, this.height = t.textureHeight, this.packedColor = this.createColorTexture(t), this.packedGeometry = this.createGeometryTexture(t), this.orderTexture = this.createOrderTexture(t.numSplats);
536
573
  }
537
- createGeometryTexture(e) {
538
- const t = new h.DataTexture(
539
- e.packedGeometry,
574
+ createGeometryTexture(t) {
575
+ const e = new l.DataTexture(
576
+ t.packedGeometry,
540
577
  this.width,
541
578
  this.height,
542
- h.RGBAIntegerFormat,
543
- h.UnsignedIntType
579
+ l.RGBAIntegerFormat,
580
+ l.UnsignedIntType
544
581
  );
545
- return t.internalFormat = "RGBA32UI", t.minFilter = h.NearestFilter, t.magFilter = h.NearestFilter, t.needsUpdate = !0, t;
582
+ return e.internalFormat = "RGBA32UI", e.minFilter = l.NearestFilter, e.magFilter = l.NearestFilter, e.needsUpdate = !0, e;
546
583
  }
547
- createColorTexture(e) {
548
- const t = new h.DataTexture(
549
- e.packedColor,
584
+ createColorTexture(t) {
585
+ const e = new l.DataTexture(
586
+ t.packedColor,
550
587
  this.width,
551
588
  this.height,
552
- h.RGBAFormat,
553
- h.UnsignedByteType
589
+ l.RGBAFormat,
590
+ l.UnsignedByteType
554
591
  );
555
- return t.minFilter = h.NearestFilter, t.magFilter = h.NearestFilter, t.needsUpdate = !0, t;
592
+ return e.minFilter = l.NearestFilter, e.magFilter = l.NearestFilter, e.needsUpdate = !0, e;
556
593
  }
557
- createOrderTexture(e) {
558
- const t = new Uint32Array(this.width * this.height);
559
- for (let r = 0; r < e; r++) t[r] = r;
560
- const s = new h.DataTexture(
561
- t,
594
+ createOrderTexture(t) {
595
+ const e = new Uint32Array(this.width * this.height);
596
+ for (let n = 0; n < t; n++) e[n] = n;
597
+ const s = new l.DataTexture(
598
+ e,
562
599
  this.width,
563
600
  this.height,
564
- h.RedIntegerFormat,
565
- h.UnsignedIntType
601
+ l.RedIntegerFormat,
602
+ l.UnsignedIntType
566
603
  );
567
- return s.minFilter = h.NearestFilter, s.magFilter = h.NearestFilter, s.needsUpdate = !0, s;
604
+ return s.minFilter = l.NearestFilter, s.magFilter = l.NearestFilter, s.needsUpdate = !0, s;
568
605
  }
569
606
  dispose() {
570
607
  this.packedGeometry.dispose(), this.packedColor.dispose(), this.orderTexture.dispose();
571
608
  }
572
609
  }
573
- const We = (
610
+ const Zt = (
574
611
  /* glsl */
575
612
  `
576
613
  precision highp float;
@@ -795,7 +832,7 @@ void main() {
795
832
  vColor = vec4(max(clr.rgb, vec3(0.0)), clr.a);
796
833
  }
797
834
  `
798
- ), Ne = (
835
+ ), Xt = (
799
836
  /* glsl */
800
837
  `
801
838
  precision highp float;
@@ -831,9 +868,9 @@ void main(void) {
831
868
  }
832
869
  `
833
870
  );
834
- class je extends h.ShaderMaterial {
835
- constructor(e = {}) {
836
- const t = {
871
+ class Qt extends l.ShaderMaterial {
872
+ constructor(t = {}) {
873
+ const e = {
837
874
  // Packed Textures
838
875
  packedGeometry: { value: null },
839
876
  // RGBA32UI: .r=MeansLow, .g=MeansHigh, .b=Quats, .a=Scales
@@ -842,114 +879,114 @@ class je extends h.ShaderMaterial {
842
879
  splatOrder: { value: null },
843
880
  // Index map
844
881
  // Decompression Ranges
845
- meansMin: { value: new h.Vector3() },
846
- meansMax: { value: new h.Vector3() },
847
- scalesMin: { value: new h.Vector3() },
848
- scalesMax: { value: new h.Vector3() },
849
- sh0Min: { value: new h.Vector3() },
850
- sh0Max: { value: new h.Vector3() },
882
+ meansMin: { value: new l.Vector3() },
883
+ meansMax: { value: new l.Vector3() },
884
+ scalesMin: { value: new l.Vector3() },
885
+ scalesMax: { value: new l.Vector3() },
886
+ sh0Min: { value: new l.Vector3() },
887
+ sh0Max: { value: new l.Vector3() },
851
888
  // Render State
852
889
  texWidth: { value: 0 },
853
- viewport: { value: new h.Vector2(1, 1) },
890
+ viewport: { value: new l.Vector2(1, 1) },
854
891
  numSplats: { value: 0 }
855
892
  };
856
893
  super({
857
- uniforms: t,
858
- vertexShader: We,
859
- fragmentShader: Ne,
894
+ uniforms: e,
895
+ vertexShader: Zt,
896
+ fragmentShader: Xt,
860
897
  transparent: !0,
861
- glslVersion: h.GLSL3,
862
- blendSrc: h.OneFactor,
863
- blendSrcAlpha: h.OneFactor,
864
- blending: h.CustomBlending,
865
- blendEquation: h.AddEquation,
866
- blendEquationAlpha: h.AddEquation,
867
- blendDst: h.OneMinusSrcAlphaFactor,
868
- blendDstAlpha: h.OneMinusSrcAlphaFactor,
898
+ glslVersion: l.GLSL3,
899
+ blendSrc: l.OneFactor,
900
+ blendSrcAlpha: l.OneFactor,
901
+ blending: l.CustomBlending,
902
+ blendEquation: l.AddEquation,
903
+ blendEquationAlpha: l.AddEquation,
904
+ blendDst: l.OneMinusSrcAlphaFactor,
905
+ blendDstAlpha: l.OneMinusSrcAlphaFactor,
869
906
  depthTest: !0,
870
907
  depthWrite: !1,
871
- side: h.DoubleSide,
872
- alphaTest: e.alphaTest ?? 0,
873
- toneMapped: e.toneMapped ?? !1
874
- }), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = h.NoBlending);
908
+ side: l.DoubleSide,
909
+ alphaTest: t.alphaTest ?? 0,
910
+ toneMapped: t.toneMapped ?? !1
911
+ }), t.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = l.NoBlending);
875
912
  }
876
- setTexWidth(e) {
877
- this.uniforms.texWidth.value = e | 0;
913
+ setTexWidth(t) {
914
+ this.uniforms.texWidth.value = t | 0;
878
915
  }
879
916
  /**
880
917
  * Update the viewport size
881
918
  * @param width Viewport width
882
919
  * @param height Viewport height
883
920
  */
884
- updateViewport(e, t) {
885
- this.uniforms.viewport.value.set(e, t);
921
+ updateViewport(t, e) {
922
+ this.uniforms.viewport.value.set(t, e);
886
923
  }
887
924
  /**
888
925
  * Set the main packed geometry texture (RGBA32UI)
889
926
  */
890
- setPackedGeometry(e) {
891
- this.uniforms.packedGeometry.value = e;
927
+ setPackedGeometry(t) {
928
+ this.uniforms.packedGeometry.value = t;
892
929
  }
893
930
  /**
894
931
  * Set the packed color texture (RGBA8)
895
932
  */
896
- setPackedColor(e) {
897
- this.uniforms.packedColor.value = e;
933
+ setPackedColor(t) {
934
+ this.uniforms.packedColor.value = t;
898
935
  }
899
936
  /**
900
937
  * Set order texture for sorting
901
938
  */
902
- setOrderTexture(e) {
903
- this.uniforms.splatOrder.value = e;
939
+ setOrderTexture(t) {
940
+ this.uniforms.splatOrder.value = t;
904
941
  }
905
942
  /**
906
943
  * Set the ranges needed to decompress the packed floats
907
944
  */
908
- setRanges(e) {
909
- 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);
945
+ setRanges(t) {
946
+ 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);
910
947
  }
911
948
  /**
912
949
  * Set number of splats to render
913
950
  * @param count Number of splats
914
951
  */
915
- setNumSplats(e) {
916
- this.uniforms.numSplats.value = e;
952
+ setNumSplats(t) {
953
+ this.uniforms.numSplats.value = t;
917
954
  }
918
955
  }
919
- const fe = class fe extends h.Mesh {
956
+ const xt = class xt extends l.Mesh {
920
957
  // Match shader constant
921
958
  /**
922
959
  * Create a new SplatMesh for rendering Gaussian splats
923
960
  * @param splatData The splat data to render
924
961
  * @param options Rendering options
925
962
  */
926
- constructor(t, s = {}) {
927
- const r = new je(s), n = fe.createInstancedGeometry(t.numSplats, fe.INSTANCE_SIZE);
928
- super(n, r);
929
- w(this, "sorter");
930
- w(this, "options");
931
- w(this, "splatData");
932
- w(this, "textureManager");
933
- w(this, "material");
934
- w(this, "geometry");
935
- w(this, "lastCameraPositionLocal", new h.Vector3());
936
- w(this, "lastCameraDirectionLocal", new h.Vector3());
937
- w(this, "invModelMatrix", new h.Matrix4());
963
+ constructor(e, s = {}) {
964
+ const n = new Qt(s), r = xt.createInstancedGeometry(e.numSplats, xt.INSTANCE_SIZE);
965
+ super(r, n);
966
+ x(this, "sorter");
967
+ x(this, "options");
968
+ x(this, "splatData");
969
+ x(this, "textureManager");
970
+ x(this, "material");
971
+ x(this, "geometry");
972
+ x(this, "lastCameraPositionLocal", new l.Vector3());
973
+ x(this, "lastCameraDirectionLocal", new l.Vector3());
974
+ x(this, "invModelMatrix", new l.Matrix4());
938
975
  // Cached inverse matrix
939
- w(this, "_vpW", -1);
940
- w(this, "_vpH", -1);
941
- w(this, "_size", new h.Vector2());
942
- w(this, "_camPosW", new h.Vector3());
943
- w(this, "_camDirW", new h.Vector3());
944
- w(this, "_camPosL", new h.Vector3());
945
- w(this, "_camDirL", new h.Vector3());
946
- w(this, "onSorterUpdated", (t) => {
947
- const s = t.count;
948
- this.geometry.instanceCount = Math.ceil(s / fe.INSTANCE_SIZE), this.material.setNumSplats(s);
976
+ x(this, "_vpW", -1);
977
+ x(this, "_vpH", -1);
978
+ x(this, "_size", new l.Vector2());
979
+ x(this, "_camPosW", new l.Vector3());
980
+ x(this, "_camDirW", new l.Vector3());
981
+ x(this, "_camPosL", new l.Vector3());
982
+ x(this, "_camDirL", new l.Vector3());
983
+ x(this, "onSorterUpdated", (e) => {
984
+ const s = e.count;
985
+ this.geometry.instanceCount = Math.ceil(s / xt.INSTANCE_SIZE), this.material.setNumSplats(s);
949
986
  });
950
- this.geometry = n, this.material = r, this.options = { autoSort: !0, ...s }, this.splatData = t, this.frustumCulled = !1, this.sorter = new Le(), this.textureManager = new Ge(t);
987
+ this.geometry = r, this.material = n, this.options = { autoSort: !0, ...s }, this.splatData = e, this.frustumCulled = !1, this.sorter = new Yt(), this.textureManager = new Ht(e);
951
988
  let o = this.createChunks() || void 0;
952
- 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 h.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), this.options.keepSplatData || (this.splatData = null);
989
+ 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(e.ranges), this.material.setTexWidth(e.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 = e.boundingBox.toBox3(), this.geometry.boundingSphere = new l.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), this.options.keepSplatData || (this.splatData = null);
953
990
  }
954
991
  /**
955
992
  * Creates the instanced geometry for rendering splats.
@@ -957,8 +994,8 @@ const fe = class fe extends h.Mesh {
957
994
  * @param instanceSize Number of splats per instance.
958
995
  * @returns InstancedBufferGeometry
959
996
  */
960
- static createInstancedGeometry(t, s) {
961
- const r = Math.ceil(t / s), n = new h.BufferGeometry(), o = new Float32Array([
997
+ static createInstancedGeometry(e, s) {
998
+ const n = Math.ceil(e / s), r = new l.BufferGeometry(), o = new Float32Array([
962
999
  // x, y, splat_index_in_instance
963
1000
  -1,
964
1001
  -1,
@@ -973,23 +1010,23 @@ const fe = class fe extends h.Mesh {
973
1010
  1,
974
1011
  0
975
1012
  ]), i = new Uint16Array([0, 1, 2, 0, 2, 3]), u = new Float32Array(4 * 3 * s);
976
- for (let l = 0; l < s; l++) {
977
- const p = l * 4 * 3;
978
- for (let y = 0; y < 4; y++)
979
- u[p + y * 3 + 0] = o[y * 3 + 0], u[p + y * 3 + 1] = o[y * 3 + 1], u[p + y * 3 + 2] = l;
1013
+ for (let h = 0; h < s; h++) {
1014
+ const d = h * 4 * 3;
1015
+ for (let w = 0; w < 4; w++)
1016
+ u[d + w * 3 + 0] = o[w * 3 + 0], u[d + w * 3 + 1] = o[w * 3 + 1], u[d + w * 3 + 2] = h;
980
1017
  }
981
- const m = new Uint32Array(6 * s);
982
- for (let l = 0; l < s; l++) {
983
- const p = l * 6, y = l * 4;
984
- m[p + 0] = i[0] + y, m[p + 1] = i[1] + y, m[p + 2] = i[2] + y, m[p + 3] = i[3] + y, m[p + 4] = i[4] + y, m[p + 5] = i[5] + y;
1018
+ const y = new Uint32Array(6 * s);
1019
+ for (let h = 0; h < s; h++) {
1020
+ const d = h * 6, w = h * 4;
1021
+ y[d + 0] = i[0] + w, y[d + 1] = i[1] + w, y[d + 2] = i[2] + w, y[d + 3] = i[3] + w, y[d + 4] = i[4] + w, y[d + 5] = i[5] + w;
985
1022
  }
986
- n.setAttribute("position", new h.BufferAttribute(u, 3)), n.setIndex(new h.BufferAttribute(m, 1));
987
- const x = new h.InstancedBufferGeometry();
988
- x.index = n.index, x.setAttribute("position", n.getAttribute("position"));
989
- const c = new Uint32Array(r);
990
- for (let l = 0; l < r; l++)
991
- c[l] = l * s;
992
- return x.setAttribute("splatInstanceIndex", new h.InstancedBufferAttribute(c, 1, !1)), x.instanceCount = 0, x;
1023
+ r.setAttribute("position", new l.BufferAttribute(u, 3)), r.setIndex(new l.BufferAttribute(y, 1));
1024
+ const m = new l.InstancedBufferGeometry();
1025
+ m.index = r.index, m.setAttribute("position", r.getAttribute("position"));
1026
+ const c = new Uint32Array(n);
1027
+ for (let h = 0; h < n; h++)
1028
+ c[h] = h * s;
1029
+ return m.setAttribute("splatInstanceIndex", new l.InstancedBufferAttribute(c, 1, !1)), m.instanceCount = 0, m;
993
1030
  }
994
1031
  /**
995
1032
  * Create chunks data (bounding box min/max) for the sorter.
@@ -998,14 +1035,14 @@ const fe = class fe extends h.Mesh {
998
1035
  createChunks() {
999
1036
  if (!this.splatData)
1000
1037
  return null;
1001
- const t = this.splatData.boundingBox;
1002
- return t.min.x === 1 / 0 || t.max.x === -1 / 0 ? null : new Float32Array([
1003
- t.min.x,
1004
- t.min.y,
1005
- t.min.z,
1006
- t.max.x,
1007
- t.max.y,
1008
- t.max.z
1038
+ const e = this.splatData.boundingBox;
1039
+ return e.min.x === 1 / 0 || e.max.x === -1 / 0 ? null : new Float32Array([
1040
+ e.min.x,
1041
+ e.min.y,
1042
+ e.min.z,
1043
+ e.max.x,
1044
+ e.max.y,
1045
+ e.max.z
1009
1046
  ]);
1010
1047
  }
1011
1048
  /**
@@ -1013,17 +1050,17 @@ const fe = class fe extends h.Mesh {
1013
1050
  * @param width Viewport width
1014
1051
  * @param height Viewport height
1015
1052
  */
1016
- updateViewport(t, s) {
1017
- t === this._vpW && s === this._vpH || (this._vpW = t, this._vpH = s, this.material.updateViewport(t, s));
1053
+ updateViewport(e, s) {
1054
+ e === this._vpW && s === this._vpH || (this._vpW = e, this._vpH = s, this.material.updateViewport(e, s));
1018
1055
  }
1019
1056
  /**
1020
1057
  * Sorts splats based on camera position and direction.
1021
1058
  * @param camera The camera to sort against.
1022
1059
  */
1023
- sort(t) {
1024
- t.getWorldPosition(this._camPosW), t.getWorldDirection(this._camDirW), this.invModelMatrix.copy(this.matrixWorld).invert(), this._camPosL.copy(this._camPosW).applyMatrix4(this.invModelMatrix), this._camDirL.copy(this._camDirW).transformDirection(this.invModelMatrix);
1025
- const s = this.lastCameraPositionLocal.distanceToSquared(this._camPosL) > 1e-6, r = this.lastCameraDirectionLocal.dot(this._camDirL) < 0.999;
1026
- this.options.autoSort && (s || r) && (this.lastCameraPositionLocal.copy(this._camPosL), this.lastCameraDirectionLocal.copy(this._camDirL), this.sorter.setCamera(this._camPosL, this._camDirL));
1060
+ sort(e) {
1061
+ e.getWorldPosition(this._camPosW), e.getWorldDirection(this._camDirW), this.invModelMatrix.copy(this.matrixWorld).invert(), this._camPosL.copy(this._camPosW).applyMatrix4(this.invModelMatrix), this._camDirL.copy(this._camDirW).transformDirection(this.invModelMatrix);
1062
+ const s = this.lastCameraPositionLocal.distanceToSquared(this._camPosL) > 1e-6, n = this.lastCameraDirectionLocal.dot(this._camDirL) < 0.999;
1063
+ this.options.autoSort && (s || n) && (this.lastCameraPositionLocal.copy(this._camPosL), this.lastCameraDirectionLocal.copy(this._camDirL), this.sorter.setCamera(this._camPosL, this._camDirL));
1027
1064
  }
1028
1065
  /**
1029
1066
  * THREE.js hook called before rendering the object.
@@ -1034,8 +1071,8 @@ const fe = class fe extends h.Mesh {
1034
1071
  */
1035
1072
  // prettier-ignore
1036
1073
  // @ts-expect-error scene is not used
1037
- onBeforeRender(t, s, r) {
1038
- this.sort(r), t.getSize(this._size), this.updateViewport(this._size.x, this._size.y);
1074
+ onBeforeRender(e, s, n) {
1075
+ this.sort(n), e.getSize(this._size), this.updateViewport(this._size.x, this._size.y);
1039
1076
  }
1040
1077
  /**
1041
1078
  * Dispose of resources
@@ -1045,33 +1082,33 @@ const fe = class fe extends h.Mesh {
1045
1082
  }
1046
1083
  };
1047
1084
  /** Number of splats combined into a single instanced draw call. */
1048
- w(fe, "INSTANCE_SIZE", 128);
1049
- let De = fe;
1050
- const me = 0.28209479177387814;
1051
- class Se {
1085
+ x(xt, "INSTANCE_SIZE", 128);
1086
+ let Rt = xt;
1087
+ const ft = 0.28209479177387814;
1088
+ class gt {
1052
1089
  /**
1053
1090
  * Packs PLY data (Float32) into the Unified SOGS-like Format.
1054
1091
  */
1055
1092
  // prettier-ignore
1056
- static packPly(e) {
1057
- const t = e.numSplats, s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s), n = s * r, { ranges: o, colorScale: i } = this.calculatePlyRanges(e), u = new Uint32Array(n * 4), m = new Uint8Array(n * 4), x = new h.Quaternion();
1058
- for (let c = 0; c < t; c++) {
1059
- const l = c * 4, p = c * 3, y = c * 4, M = e.positions[p + 0], v = e.positions[p + 1], S = e.positions[p + 2], k = this.clamp01(this.norm(M, o.means.min.x, o.means.max.x)), B = this.clamp01(this.norm(v, o.means.min.y, o.means.max.y)), j = this.clamp01(this.norm(S, o.means.min.z, o.means.max.z)), R = k * 65535 | 0, b = B * 65535 | 0, A = j * 65535 | 0;
1060
- u[l + 0] = this.pack4Bytes(R & 255, b & 255, A & 255, 0), u[l + 1] = this.pack4Bytes(R >> 8, b >> 8, A >> 8, 0), x.set(e.rotations[y], e.rotations[y + 1], e.rotations[y + 2], e.rotations[y + 3]).normalize();
1061
- let C = x.w, g = x.x, d = x.y, I = x.z;
1062
- const q = Math.abs(C), T = Math.abs(g), W = Math.abs(d), U = Math.abs(I);
1063
- let F = 0, P = q;
1064
- T > P && (P = T, F = 1), W > P && (P = W, F = 2), U > P && (P = U, F = 3), (F === 0 ? C : F === 1 ? g : F === 2 ? d : I) < 0 && (C = -C, g = -g, d = -d, I = -I);
1065
- let G = 0, L = 0, X = 0;
1066
- F === 0 && (G = g, L = d, X = I), F === 1 && (G = C, L = d, X = I), F === 2 && (G = C, L = g, X = I), F === 3 && (G = C, L = g, X = d);
1067
- const $ = (re) => Math.min(255, Math.max(0, Math.round((0.5 + re / Math.SQRT2) * 255)));
1068
- u[l + 2] = this.pack4Bytes($(G), $(L), $(X), F);
1069
- const H = this.norm(e.scales[p + 0], o.scales.min.x, o.scales.max.x), z = this.norm(e.scales[p + 1], o.scales.min.y, o.scales.max.y), f = this.norm(e.scales[p + 2], o.scales.min.z, o.scales.max.z);
1070
- u[l + 3] = this.pack4Bytes(Math.floor(H * 255), Math.floor(z * 255), Math.floor(f * 255), 0);
1071
- const E = this.clamp01(e.colors[p + 0] * i), V = this.clamp01(e.colors[p + 1] * i), D = this.clamp01(e.colors[p + 2] * i), O = (E - 0.5) / me, Y = (V - 0.5) / me, Z = (D - 0.5) / me, Q = this.clamp01(this.norm(O, o.sh0.min.x, o.sh0.max.x)), N = this.clamp01(this.norm(Y, o.sh0.min.y, o.sh0.max.y)), K = this.clamp01(this.norm(Z, o.sh0.min.z, o.sh0.max.z)), se = this.clamp01(e.opacities[c]);
1072
- m[l + 0] = Math.round(Q * 255), m[l + 1] = Math.round(N * 255), m[l + 2] = Math.round(K * 255), m[l + 3] = Math.round(se * 255);
1093
+ static packPly(t) {
1094
+ const e = t.numSplats, s = Math.ceil(Math.sqrt(e)), n = Math.ceil(e / s), r = s * n, { ranges: o, colorScale: i } = this.calculatePlyRanges(t), u = new Uint32Array(r * 4), y = new Uint8Array(r * 4), m = new l.Quaternion();
1095
+ for (let c = 0; c < e; c++) {
1096
+ const h = c * 4, d = c * 3, w = c * 4, A = t.positions[d + 0], b = t.positions[d + 1], z = t.positions[d + 2], _ = this.clamp01(this.norm(A, o.means.min.x, o.means.max.x)), F = this.clamp01(this.norm(b, o.means.min.y, o.means.max.y)), O = this.clamp01(this.norm(z, o.means.min.z, o.means.max.z)), V = _ * 65535 | 0, k = F * 65535 | 0, M = O * 65535 | 0;
1097
+ u[h + 0] = this.pack4Bytes(V & 255, k & 255, M & 255, 0), u[h + 1] = this.pack4Bytes(V >> 8, k >> 8, M >> 8, 0), m.set(t.rotations[w], t.rotations[w + 1], t.rotations[w + 2], t.rotations[w + 3]).normalize();
1098
+ let B = m.w, S = m.x, g = m.y, v = m.z;
1099
+ const T = Math.abs(B), U = Math.abs(S), I = Math.abs(g), P = Math.abs(v);
1100
+ let f = 0, C = T;
1101
+ U > C && (C = U, f = 1), I > C && (C = I, f = 2), P > C && (C = P, f = 3), (f === 0 ? B : f === 1 ? S : f === 2 ? g : v) < 0 && (B = -B, S = -S, g = -g, v = -v);
1102
+ let W = 0, R = 0, J = 0;
1103
+ f === 0 && (W = S, R = g, J = v), f === 1 && (W = B, R = g, J = v), f === 2 && (W = B, R = S, J = v), f === 3 && (W = B, R = S, J = g);
1104
+ const Z = (et) => Math.min(255, Math.max(0, Math.round((0.5 + et / Math.SQRT2) * 255)));
1105
+ u[h + 2] = this.pack4Bytes(Z(W), Z(R), Z(J), f);
1106
+ const H = this.norm(t.scales[d + 0], o.scales.min.x, o.scales.max.x), D = this.norm(t.scales[d + 1], o.scales.min.y, o.scales.max.y), p = this.norm(t.scales[d + 2], o.scales.min.z, o.scales.max.z);
1107
+ u[h + 3] = this.pack4Bytes(Math.floor(H * 255), Math.floor(D * 255), Math.floor(p * 255), 0);
1108
+ const q = this.clamp01(t.colors[d + 0] * i), L = this.clamp01(t.colors[d + 1] * i), E = this.clamp01(t.colors[d + 2] * i), G = (q - 0.5) / ft, X = (L - 0.5) / ft, j = (E - 0.5) / ft, Q = this.clamp01(this.norm(G, o.sh0.min.x, o.sh0.max.x)), $ = this.clamp01(this.norm(X, o.sh0.min.y, o.sh0.max.y)), K = this.clamp01(this.norm(j, o.sh0.min.z, o.sh0.max.z)), tt = this.clamp01(t.opacities[c]);
1109
+ y[h + 0] = Math.round(Q * 255), y[h + 1] = Math.round($ * 255), y[h + 2] = Math.round(K * 255), y[h + 3] = Math.round(tt * 255);
1073
1110
  }
1074
- return new Be(t, s, r, e.positions, u, m, o, e.boundingBox);
1111
+ return new At(e, s, n, t.positions, u, y, o, t.boundingBox);
1075
1112
  }
1076
1113
  /**
1077
1114
  * Packs SOGS data.
@@ -1079,125 +1116,201 @@ class Se {
1079
1116
  * Decodes centers for sorting.
1080
1117
  */
1081
1118
  // prettier-ignore
1082
- static packSogs(e) {
1083
- const t = e.numSplats, s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s), n = s * r, o = this.convertSogsRanges(e.ranges), i = e.ranges.means.mins[0], u = e.ranges.means.mins[1], m = e.ranges.means.mins[2], x = e.ranges.means.maxs[0], c = e.ranges.means.maxs[1], l = e.ranges.means.maxs[2], p = (g) => Math.sign(g) * (Math.exp(Math.abs(g)) - 1), y = new h.Vector3(
1084
- p(i),
1085
- p(u),
1086
- p(m)
1087
- ), M = new h.Vector3(
1088
- p(x),
1089
- p(c),
1090
- p(l)
1119
+ static packSogs(t) {
1120
+ var g, v, T;
1121
+ const e = t.numSplats;
1122
+ let s = Math.ceil(Math.sqrt(e)), n = Math.ceil(e / s);
1123
+ const r = ((g = t.means_l) == null ? void 0 : g.image) ?? ((v = t.sh0) == null ? void 0 : v.image) ?? ((T = t.quats) == null ? void 0 : T.image);
1124
+ r && typeof r.width == "number" && typeof r.height == "number" && (s = r.width, n = r.height);
1125
+ const o = s * n;
1126
+ if (o < e) throw new Error(`SOG v1 texture too small: ${s}x${n}=${o} < count=${e}`);
1127
+ const i = this.convertSogsRanges(t.ranges), u = t.ranges.means.mins[0], y = t.ranges.means.mins[1], m = t.ranges.means.mins[2], c = t.ranges.means.maxs[0], h = t.ranges.means.maxs[1], d = t.ranges.means.maxs[2], w = (U) => Math.sign(U) * (Math.exp(Math.abs(U)) - 1), A = new l.Vector3(
1128
+ w(u),
1129
+ w(y),
1130
+ w(m)
1131
+ ), b = new l.Vector3(
1132
+ w(c),
1133
+ w(h),
1134
+ w(d)
1091
1135
  );
1092
- o.means.min.copy(y), o.means.max.copy(M);
1093
- const v = e, S = this.getPixels(v.means_l), k = this.getPixels(v.means_u), B = this.getPixels(v.quats), j = this.getPixels(v.scales), R = this.getPixels(v.sh0), b = new Uint32Array(n * 4), A = new Uint8Array(n * 4), C = new Float32Array(t * 3);
1094
- for (let g = 0; g < t; g++) {
1095
- const d = g * 4, I = k[d + 0], q = S[d + 0], T = k[d + 1], W = S[d + 1], U = k[d + 2], F = S[d + 2], P = (I << 8 | q) / 65535, J = (T << 8 | W) / 65535, G = (U << 8 | F) / 65535, L = this.sogsDecode(P, i, x), X = this.sogsDecode(J, u, c), $ = this.sogsDecode(G, m, l);
1096
- C[g * 3 + 0] = L, C[g * 3 + 1] = X, C[g * 3 + 2] = $;
1097
- const H = this.clamp01(this.norm(L, y.x, M.x)) * 65535 | 0, z = this.clamp01(this.norm(X, y.y, M.y)) * 65535 | 0, f = this.clamp01(this.norm($, y.z, M.z)) * 65535 | 0;
1098
- b[d + 0] = this.pack4Bytes(H & 255, z & 255, f & 255, 0), b[d + 1] = this.pack4Bytes(H >> 8, z >> 8, f >> 8, 0), b[d + 3] = this.pack4Bytes(j[d], j[d + 1], j[d + 2], 0);
1099
- const V = B[d + 3] - 252;
1100
- b[d + 2] = this.pack4Bytes(B[d + 0], B[d + 1], B[d + 2], V), A[d + 0] = R[d], A[d + 1] = R[d + 1], A[d + 2] = R[d + 2];
1101
- const D = R[d + 3] / 255, O = e.ranges.sh0.mins[3] + (e.ranges.sh0.maxs[3] - e.ranges.sh0.mins[3]) * D, Y = 1 / (1 + Math.exp(-O));
1102
- A[d + 3] = Math.round(Math.max(0, Math.min(1, Y)) * 255);
1136
+ i.means.min.copy(A), i.means.max.copy(b);
1137
+ const z = t, _ = this.getPixels(z.means_l), F = this.getPixels(z.means_u), O = this.getPixels(z.quats), V = this.getPixels(z.scales), k = this.getPixels(z.sh0), M = new Uint32Array(o * 4), B = new Uint8Array(o * 4), S = new Float32Array(e * 3);
1138
+ for (let U = 0; U < e; U++) {
1139
+ const I = U * 4, P = F[I + 0], f = _[I + 0], C = F[I + 1], Y = _[I + 1], W = F[I + 2], R = _[I + 2], J = (P << 8 | f) / 65535, Z = (C << 8 | Y) / 65535, H = (W << 8 | R) / 65535, D = this.sogsDecode(J, u, c), p = this.sogsDecode(Z, y, h), q = this.sogsDecode(H, m, d);
1140
+ S[U * 3 + 0] = D, S[U * 3 + 1] = p, S[U * 3 + 2] = q;
1141
+ const L = this.clamp01(this.norm(D, A.x, b.x)) * 65535 | 0, E = this.clamp01(this.norm(p, A.y, b.y)) * 65535 | 0, G = this.clamp01(this.norm(q, A.z, b.z)) * 65535 | 0;
1142
+ M[I + 0] = this.pack4Bytes(L & 255, E & 255, G & 255, 0), M[I + 1] = this.pack4Bytes(L >> 8, E >> 8, G >> 8, 0), M[I + 3] = this.pack4Bytes(V[I], V[I + 1], V[I + 2], 0);
1143
+ const j = O[I + 3] - 252;
1144
+ M[I + 2] = this.pack4Bytes(O[I + 0], O[I + 1], O[I + 2], j), B[I + 0] = k[I], B[I + 1] = k[I + 1], B[I + 2] = k[I + 2];
1145
+ const Q = k[I + 3] / 255, $ = t.ranges.sh0.mins[3] + (t.ranges.sh0.maxs[3] - t.ranges.sh0.mins[3]) * Q, K = 1 / (1 + Math.exp(-$));
1146
+ B[I + 3] = Math.round(Math.max(0, Math.min(1, K)) * 255);
1147
+ }
1148
+ return new At(e, s, n, S, M, B, i, t.boundingBox);
1149
+ }
1150
+ /**
1151
+ * Packs SOG V2 data.
1152
+ */
1153
+ static packSog2(t) {
1154
+ var T, U, I;
1155
+ const e = t.numSplats;
1156
+ let s = Math.ceil(Math.sqrt(e)), n = Math.ceil(e / s);
1157
+ const r = ((T = t.means_l) == null ? void 0 : T.image) ?? ((U = t.sh0) == null ? void 0 : U.image) ?? ((I = t.quats) == null ? void 0 : I.image);
1158
+ r && typeof r.width == "number" && typeof r.height == "number" && (s = r.width, n = r.height);
1159
+ const o = s * n;
1160
+ if (o < e) throw new Error(`SOG v2 texture too small: ${s}x${n}=${o} < count=${e}`);
1161
+ const i = t.ranges.means.mins[0], u = t.ranges.means.mins[1], y = t.ranges.means.mins[2], m = t.ranges.means.maxs[0], c = t.ranges.means.maxs[1], h = t.ranges.means.maxs[2], d = (P) => Math.sign(P) * (Math.exp(Math.abs(P)) - 1), w = new l.Vector3(
1162
+ d(i),
1163
+ d(u),
1164
+ d(y)
1165
+ ), A = new l.Vector3(
1166
+ d(m),
1167
+ d(c),
1168
+ d(h)
1169
+ ), b = (P) => {
1170
+ let f = 1 / 0, C = -1 / 0;
1171
+ for (const R of P)
1172
+ Number.isFinite(R) && (f = Math.min(f, R), C = Math.max(C, R));
1173
+ (!Number.isFinite(f) || !Number.isFinite(C)) && (f = 0, C = 1);
1174
+ const Y = C - f || 1, W = new Uint8Array(256);
1175
+ for (let R = 0; R < 256; R++) {
1176
+ const Z = ((R < P.length && Number.isFinite(P[R]) ? P[R] : f + (C - f) * (R / 255)) - f) / Y, H = Math.max(0, Math.min(255, Math.round(Z * 255)));
1177
+ W[R] = H;
1178
+ }
1179
+ return { cbMin: f, cbMax: C, lut: W };
1180
+ }, z = b(t.ranges.scales.codebook), _ = b(t.ranges.sh0.codebook), F = {
1181
+ means: { min: w.clone(), max: A.clone() },
1182
+ scales: {
1183
+ min: new l.Vector3(
1184
+ z.cbMin,
1185
+ z.cbMin,
1186
+ z.cbMin
1187
+ ),
1188
+ max: new l.Vector3(
1189
+ z.cbMax,
1190
+ z.cbMax,
1191
+ z.cbMax
1192
+ )
1193
+ },
1194
+ sh0: {
1195
+ min: new l.Vector3(
1196
+ _.cbMin,
1197
+ _.cbMin,
1198
+ _.cbMin
1199
+ ),
1200
+ max: new l.Vector3(
1201
+ _.cbMax,
1202
+ _.cbMax,
1203
+ _.cbMax
1204
+ )
1205
+ }
1206
+ }, O = this.getPixels(t.means_l), V = this.getPixels(t.means_u), k = this.getPixels(t.quats), M = this.getPixels(t.scales), B = this.getPixels(t.sh0), S = new Uint32Array(o * 4), g = new Uint8Array(o * 4), v = new Float32Array(e * 3);
1207
+ for (let P = 0; P < e; P++) {
1208
+ const f = P * 4, C = V[f + 0], Y = O[f + 0], W = V[f + 1], R = O[f + 1], J = V[f + 2], Z = O[f + 2], H = (C << 8 | Y) / 65535, D = (W << 8 | R) / 65535, p = (J << 8 | Z) / 65535, q = this.sogsDecode(H, i, m), L = this.sogsDecode(D, u, c), E = this.sogsDecode(p, y, h);
1209
+ v[P * 3 + 0] = q, v[P * 3 + 1] = L, v[P * 3 + 2] = E;
1210
+ const G = this.clamp01(this.norm(q, w.x, A.x)) * 65535 | 0, X = this.clamp01(this.norm(L, w.y, A.y)) * 65535 | 0, j = this.clamp01(this.norm(E, w.z, A.z)) * 65535 | 0;
1211
+ S[f + 0] = this.pack4Bytes(G & 255, X & 255, j & 255, 0), S[f + 1] = this.pack4Bytes(G >> 8, X >> 8, j >> 8, 0);
1212
+ const $ = k[f + 3] - 252 & 3;
1213
+ S[f + 2] = this.pack4Bytes(k[f + 0], k[f + 1], k[f + 2], $);
1214
+ const K = z.lut[M[f + 0]], tt = z.lut[M[f + 1]], et = z.lut[M[f + 2]];
1215
+ S[f + 3] = this.pack4Bytes(K, tt, et, 0), g[f + 0] = _.lut[B[f + 0]], g[f + 1] = _.lut[B[f + 1]], g[f + 2] = _.lut[B[f + 2]], g[f + 3] = B[f + 3];
1103
1216
  }
1104
- return new Be(t, s, r, C, b, A, o, e.boundingBox);
1217
+ return new At(e, s, n, v, S, g, F, t.boundingBox);
1105
1218
  }
1106
1219
  // --- Helpers ---
1107
1220
  // prettier-ignore
1108
- static pack4Bytes(e, t, s, r) {
1109
- return (e & 255) << 24 | (t & 255) << 16 | (s & 255) << 8 | r & 255;
1221
+ static pack4Bytes(t, e, s, n) {
1222
+ return (t & 255) << 24 | (e & 255) << 16 | (s & 255) << 8 | n & 255;
1110
1223
  }
1111
1224
  // prettier-ignore
1112
- static getPixels(e) {
1113
- const t = e.image, s = t.width, r = t.height;
1114
- if (t.data && (t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray)) return new Uint8Array(t.data);
1115
- const n = document.createElement("canvas");
1116
- n.width = s, n.height = r;
1117
- const o = n.getContext("2d", { willReadFrequently: !0 });
1225
+ static getPixels(t) {
1226
+ const e = t.image, s = e.width, n = e.height;
1227
+ if (e.data && (e.data instanceof Uint8Array || e.data instanceof Uint8ClampedArray)) return new Uint8Array(e.data);
1228
+ const r = document.createElement("canvas");
1229
+ r.width = s, r.height = n;
1230
+ const o = r.getContext("2d", { willReadFrequently: !0 });
1118
1231
  if (!o) throw new Error("Canvas init failed");
1119
- return o.drawImage(t, 0, 0), new Uint8Array(o.getImageData(0, 0, s, r).data);
1232
+ return o.drawImage(e, 0, 0), new Uint8Array(o.getImageData(0, 0, s, n).data);
1120
1233
  }
1121
- static convertSogsRanges(e) {
1122
- const t = (s) => new h.Vector3(s[0], s[1], s[2]);
1234
+ static convertSogsRanges(t) {
1235
+ const e = (s) => new l.Vector3(s[0], s[1], s[2]);
1123
1236
  return {
1124
- sh0: { min: t(e.sh0.mins), max: t(e.sh0.maxs) },
1125
- means: { min: t(e.means.mins), max: t(e.means.maxs) },
1126
- scales: { min: t(e.scales.mins), max: t(e.scales.maxs) }
1237
+ sh0: { min: e(t.sh0.mins), max: e(t.sh0.maxs) },
1238
+ means: { min: e(t.means.mins), max: e(t.means.maxs) },
1239
+ scales: { min: e(t.scales.mins), max: e(t.scales.maxs) }
1127
1240
  };
1128
1241
  }
1129
- static calculatePlyRanges(e) {
1130
- const t = new h.Vector3(1 / 0, 1 / 0, 1 / 0), s = new h.Vector3(-1 / 0, -1 / 0, -1 / 0), r = new h.Vector3(1 / 0, 1 / 0, 1 / 0), n = new h.Vector3(-1 / 0, -1 / 0, -1 / 0), o = new h.Vector3(1 / 0, 1 / 0, 1 / 0), i = new h.Vector3(-1 / 0, -1 / 0, -1 / 0);
1242
+ static calculatePlyRanges(t) {
1243
+ const e = new l.Vector3(1 / 0, 1 / 0, 1 / 0), s = new l.Vector3(-1 / 0, -1 / 0, -1 / 0), n = new l.Vector3(1 / 0, 1 / 0, 1 / 0), r = new l.Vector3(-1 / 0, -1 / 0, -1 / 0), o = new l.Vector3(1 / 0, 1 / 0, 1 / 0), i = new l.Vector3(-1 / 0, -1 / 0, -1 / 0);
1131
1244
  let u = 0;
1132
- for (let x = 0; x < e.numSplats; x++) {
1133
- const c = x * 3, l = e.positions[c + 0], p = e.positions[c + 1], y = e.positions[c + 2];
1134
- t.x = Math.min(t.x, l), s.x = Math.max(s.x, l), t.y = Math.min(t.y, p), s.y = Math.max(s.y, p), t.z = Math.min(t.z, y), s.z = Math.max(s.z, y), r.x = Math.min(r.x, e.scales[c]), n.x = Math.max(n.x, e.scales[c]), r.y = Math.min(r.y, e.scales[c + 1]), n.y = Math.max(n.y, e.scales[c + 1]), r.z = Math.min(r.z, e.scales[c + 2]), n.z = Math.max(n.z, e.scales[c + 2]), u = Math.max(
1245
+ for (let m = 0; m < t.numSplats; m++) {
1246
+ const c = m * 3, h = t.positions[c + 0], d = t.positions[c + 1], w = t.positions[c + 2];
1247
+ e.x = Math.min(e.x, h), s.x = Math.max(s.x, h), e.y = Math.min(e.y, d), s.y = Math.max(s.y, d), e.z = Math.min(e.z, w), s.z = Math.max(s.z, w), n.x = Math.min(n.x, t.scales[c]), r.x = Math.max(r.x, t.scales[c]), n.y = Math.min(n.y, t.scales[c + 1]), r.y = Math.max(r.y, t.scales[c + 1]), n.z = Math.min(n.z, t.scales[c + 2]), r.z = Math.max(r.z, t.scales[c + 2]), u = Math.max(
1135
1248
  u,
1136
- e.colors[c],
1137
- e.colors[c + 1],
1138
- e.colors[c + 2]
1249
+ t.colors[c],
1250
+ t.colors[c + 1],
1251
+ t.colors[c + 2]
1139
1252
  );
1140
1253
  }
1141
- const m = u > 1.5 ? 1 / 255 : 1;
1142
- for (let x = 0; x < e.numSplats; x++) {
1143
- const c = x * 3, l = this.clamp01(e.colors[c + 0] * m), p = this.clamp01(e.colors[c + 1] * m), y = this.clamp01(e.colors[c + 2] * m), M = (l - 0.5) / me, v = (p - 0.5) / me, S = (y - 0.5) / me;
1144
- o.x = Math.min(o.x, M), i.x = Math.max(i.x, M), o.y = Math.min(o.y, v), i.y = Math.max(i.y, v), o.z = Math.min(o.z, S), i.z = Math.max(i.z, S);
1254
+ const y = u > 1.5 ? 1 / 255 : 1;
1255
+ for (let m = 0; m < t.numSplats; m++) {
1256
+ const c = m * 3, h = this.clamp01(t.colors[c + 0] * y), d = this.clamp01(t.colors[c + 1] * y), w = this.clamp01(t.colors[c + 2] * y), A = (h - 0.5) / ft, b = (d - 0.5) / ft, z = (w - 0.5) / ft;
1257
+ o.x = Math.min(o.x, A), i.x = Math.max(i.x, A), o.y = Math.min(o.y, b), i.y = Math.max(i.y, b), o.z = Math.min(o.z, z), i.z = Math.max(i.z, z);
1145
1258
  }
1146
1259
  return {
1147
- colorScale: m,
1260
+ colorScale: y,
1148
1261
  ranges: {
1149
1262
  sh0: { min: o, max: i },
1150
- means: { min: t, max: s },
1151
- scales: { min: r, max: n }
1263
+ means: { min: e, max: s },
1264
+ scales: { min: n, max: r }
1152
1265
  }
1153
1266
  };
1154
1267
  }
1155
- static clamp01(e) {
1156
- return Math.max(0, Math.min(1, e));
1268
+ static clamp01(t) {
1269
+ return Math.max(0, Math.min(1, t));
1157
1270
  }
1158
1271
  // prettier-ignore
1159
1272
  // private static lerp(a: number, b: number, t: number) { return a + (b - a) * t; } // prettier-ignore
1160
1273
  // private static invSogsMap(v: number) { return Math.sign(v) * Math.log(Math.abs(v) + 1) } // prettier-ignore
1161
- static norm(e, t, s) {
1162
- return (e - t) / (s - t || 1);
1274
+ static norm(t, e, s) {
1275
+ return (t - e) / (s - e || 1);
1163
1276
  }
1164
1277
  // prettier-ignore
1165
- static sogsDecode(e, t, s) {
1166
- const r = t + (s - t) * e;
1167
- return Math.sign(r) * (Math.exp(Math.abs(r)) - 1);
1278
+ static sogsDecode(t, e, s) {
1279
+ const n = e + (s - e) * t;
1280
+ return Math.sign(n) * (Math.exp(Math.abs(n)) - 1);
1168
1281
  }
1169
1282
  }
1170
- class dt extends h.Loader {
1171
- constructor(t) {
1172
- super(t);
1173
- w(this, "requestId", 0);
1174
- w(this, "worker");
1175
- w(this, "pendingCallbacks", /* @__PURE__ */ new Map());
1283
+ class ve extends l.Loader {
1284
+ constructor(e) {
1285
+ super(e);
1286
+ x(this, "requestId", 0);
1287
+ x(this, "worker");
1288
+ x(this, "pendingCallbacks", /* @__PURE__ */ new Map());
1176
1289
  this.withCredentials = !0;
1177
- const s = this.createWorkerCode(), r = new Blob([s], { type: "application/javascript" });
1178
- this.worker = new Worker(URL.createObjectURL(r)), this.worker.onmessage = this.onWorkerMessage.bind(this);
1290
+ const s = this.createWorkerCode(), n = new Blob([s], { type: "application/javascript" });
1291
+ this.worker = new Worker(URL.createObjectURL(n)), this.worker.onmessage = this.onWorkerMessage.bind(this);
1179
1292
  }
1180
1293
  /**
1181
1294
  * Handles messages received from the parsing worker
1182
1295
  * @param event The message event from the worker
1183
1296
  */
1184
- onWorkerMessage(t) {
1185
- const { requestId: s, error: r, result: n } = t.data, o = this.pendingCallbacks.get(s);
1297
+ onWorkerMessage(e) {
1298
+ const { requestId: s, error: n, result: r } = e.data, o = this.pendingCallbacks.get(s);
1186
1299
  if (!o) return console.warn(`PlyLoader: Received response for unknown request ${s}`);
1187
- if (this.pendingCallbacks.delete(s), r) return o.reject(new Error(r));
1188
- if (!n) return o.reject(new Error("Worker returned no result"));
1300
+ if (this.pendingCallbacks.delete(s), n) return o.reject(new Error(n));
1301
+ if (!r) return o.reject(new Error("Worker returned no result"));
1189
1302
  try {
1190
- const i = new Oe(0);
1191
- i.numSplats = n.numSplats, i.positions = new Float32Array(n.positions), i.rotations = new Float32Array(n.rotations), i.scales = new Float32Array(n.scales), i.colors = new Float32Array(n.colors), i.opacities = new Float32Array(n.opacities), i.boundingBox.min.set(
1192
- n.boundingBox.minX,
1193
- n.boundingBox.minY,
1194
- n.boundingBox.minZ
1303
+ const i = new jt(0);
1304
+ i.numSplats = r.numSplats, i.positions = new Float32Array(r.positions), i.rotations = new Float32Array(r.rotations), i.scales = new Float32Array(r.scales), i.colors = new Float32Array(r.colors), i.opacities = new Float32Array(r.opacities), i.boundingBox.min.set(
1305
+ r.boundingBox.minX,
1306
+ r.boundingBox.minY,
1307
+ r.boundingBox.minZ
1195
1308
  ), i.boundingBox.max.set(
1196
- n.boundingBox.maxX,
1197
- n.boundingBox.maxY,
1198
- n.boundingBox.maxZ
1309
+ r.boundingBox.maxX,
1310
+ r.boundingBox.maxY,
1311
+ r.boundingBox.maxZ
1199
1312
  ), this.worker.terminate();
1200
- const u = Se.packPly(i);
1313
+ const u = gt.packPly(i);
1201
1314
  i.dispose(), o.resolve(u);
1202
1315
  } catch (i) {
1203
1316
  o.reject(i);
@@ -1210,19 +1323,19 @@ class dt extends h.Loader {
1210
1323
  * @param onProgress Optional progress callback
1211
1324
  * @param onError Optional error callback
1212
1325
  */
1213
- load(t, s, r, n) {
1214
- const o = new h.FileLoader(this.manager);
1326
+ load(e, s, n, r) {
1327
+ const o = new l.FileLoader(this.manager);
1215
1328
  o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
1216
- t,
1329
+ e,
1217
1330
  (i) => {
1218
1331
  this.parseAsync(i).then((u) => {
1219
1332
  s && s(u);
1220
1333
  }).catch((u) => {
1221
- n ? n(u) : console.error(u), this.manager.itemError(t);
1334
+ r ? r(u) : console.error(u), this.manager.itemError(e);
1222
1335
  });
1223
1336
  },
1224
- r,
1225
- n
1337
+ n,
1338
+ r
1226
1339
  );
1227
1340
  }
1228
1341
  /**
@@ -1231,19 +1344,19 @@ class dt extends h.Loader {
1231
1344
  * @param onProgress Optional progress callback
1232
1345
  * @returns A Promise that resolves with the parsed SplatData
1233
1346
  */
1234
- loadAsync(t, s) {
1235
- return new Promise((r, n) => {
1236
- const o = new h.FileLoader(this.manager);
1347
+ loadAsync(e, s) {
1348
+ return new Promise((n, r) => {
1349
+ const o = new l.FileLoader(this.manager);
1237
1350
  o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
1238
- t,
1351
+ e,
1239
1352
  (i) => {
1240
- this.parseAsync(i).then(r).catch((u) => {
1241
- n(u), this.manager.itemError(t);
1353
+ this.parseAsync(i).then(n).catch((u) => {
1354
+ r(u), this.manager.itemError(e);
1242
1355
  });
1243
1356
  },
1244
1357
  s,
1245
1358
  (i) => {
1246
- n(i), this.manager.itemError(t);
1359
+ r(i), this.manager.itemError(e);
1247
1360
  }
1248
1361
  );
1249
1362
  });
@@ -1253,15 +1366,15 @@ class dt extends h.Loader {
1253
1366
  * @param buffer ArrayBuffer containing PLY data
1254
1367
  * @returns Promise that resolves with parsed SplatData
1255
1368
  */
1256
- parseAsync(t) {
1257
- return new Promise((s, r) => {
1258
- const n = this.requestId++;
1259
- this.pendingCallbacks.set(n, { resolve: s, reject: r });
1369
+ parseAsync(e) {
1370
+ return new Promise((s, n) => {
1371
+ const r = this.requestId++;
1372
+ this.pendingCallbacks.set(r, { resolve: s, reject: n });
1260
1373
  const o = {
1261
- requestId: n,
1262
- buffer: t
1374
+ requestId: r,
1375
+ buffer: e
1263
1376
  };
1264
- this.worker.postMessage(o, [t]);
1377
+ this.worker.postMessage(o, [e]);
1265
1378
  });
1266
1379
  }
1267
1380
  /**
@@ -1276,11 +1389,11 @@ class dt extends h.Loader {
1276
1389
  */
1277
1390
  createWorkerCode() {
1278
1391
  return `(${(function() {
1279
- self.onmessage = (r) => {
1280
- const { requestId: n, buffer: o } = r.data;
1392
+ self.onmessage = (n) => {
1393
+ const { requestId: r, buffer: o } = n.data;
1281
1394
  try {
1282
1395
  const i = s(o), u = {
1283
- requestId: n,
1396
+ requestId: r,
1284
1397
  result: i
1285
1398
  };
1286
1399
  self.postMessage(u, [
@@ -1292,179 +1405,179 @@ class dt extends h.Loader {
1292
1405
  ]);
1293
1406
  } catch (i) {
1294
1407
  const u = {
1295
- requestId: n,
1408
+ requestId: r,
1296
1409
  error: i instanceof Error ? i.message : String(i)
1297
1410
  };
1298
1411
  self.postMessage(u);
1299
1412
  }
1300
1413
  };
1301
- function s(r) {
1302
- const n = new TextDecoder(), o = new Uint8Array(r), i = [112, 108, 121, 10], u = `
1414
+ function s(n) {
1415
+ const r = new TextDecoder(), o = new Uint8Array(n), i = [112, 108, 121, 10], u = `
1303
1416
  end_header
1304
1417
  `;
1305
- for (let z = 0; z < i.length; z++)
1306
- if (o[z] !== i[z])
1418
+ for (let D = 0; D < i.length; D++)
1419
+ if (o[D] !== i[D])
1307
1420
  throw new Error(
1308
1421
  "Invalid PLY file: Missing magic bytes"
1309
1422
  );
1310
- let m = 0;
1311
- for (let z = 0; z < o.length - u.length; z++) {
1312
- let f = !0;
1313
- for (let E = 0; E < u.length; E++)
1314
- if (o[z + E] !== u.charCodeAt(E)) {
1315
- f = !1;
1423
+ let y = 0;
1424
+ for (let D = 0; D < o.length - u.length; D++) {
1425
+ let p = !0;
1426
+ for (let q = 0; q < u.length; q++)
1427
+ if (o[D + q] !== u.charCodeAt(q)) {
1428
+ p = !1;
1316
1429
  break;
1317
1430
  }
1318
- if (f) {
1319
- m = z + u.length;
1431
+ if (p) {
1432
+ y = D + u.length;
1320
1433
  break;
1321
1434
  }
1322
1435
  }
1323
- if (m === 0)
1436
+ if (y === 0)
1324
1437
  throw new Error(
1325
1438
  "Invalid PLY file: Could not find end of header"
1326
1439
  );
1327
- const c = n.decode(
1328
- o.subarray(0, m)
1440
+ const c = r.decode(
1441
+ o.subarray(0, y)
1329
1442
  ).split(`
1330
- `), l = [];
1331
- let p = null;
1332
- for (let z = 1; z < c.length; z++) {
1333
- const f = c[z].trim();
1334
- if (f === "" || f === "end_header") continue;
1335
- const E = f.split(" ");
1336
- switch (E[0]) {
1443
+ `), h = [];
1444
+ let d = null;
1445
+ for (let D = 1; D < c.length; D++) {
1446
+ const p = c[D].trim();
1447
+ if (p === "" || p === "end_header") continue;
1448
+ const q = p.split(" ");
1449
+ switch (q[0]) {
1337
1450
  case "format":
1338
- p = E[1];
1451
+ d = q[1];
1339
1452
  break;
1340
1453
  case "element":
1341
- l.push({
1342
- name: E[1],
1343
- count: parseInt(E[2], 10),
1454
+ h.push({
1455
+ name: q[1],
1456
+ count: parseInt(q[2], 10),
1344
1457
  properties: []
1345
1458
  });
1346
1459
  break;
1347
1460
  case "property":
1348
- if (l.length === 0)
1461
+ if (h.length === 0)
1349
1462
  throw new Error(
1350
1463
  "Invalid PLY file: Property without element"
1351
1464
  );
1352
- l[l.length - 1].properties.push({
1353
- type: E[1],
1354
- name: E[2]
1465
+ h[h.length - 1].properties.push({
1466
+ type: q[1],
1467
+ name: q[2]
1355
1468
  });
1356
1469
  break;
1357
1470
  }
1358
1471
  }
1359
- if (p !== "binary_little_endian")
1360
- throw new Error(`Unsupported PLY format: ${p}`);
1361
- const y = l.find((z) => z.name === "vertex");
1362
- if (!y)
1472
+ if (d !== "binary_little_endian")
1473
+ throw new Error(`Unsupported PLY format: ${d}`);
1474
+ const w = h.find((D) => D.name === "vertex");
1475
+ if (!w)
1363
1476
  throw new Error(
1364
1477
  "Invalid PLY file: No vertex element found"
1365
1478
  );
1366
- const M = y.count, v = new Float32Array(M * 3), S = new Float32Array(M * 4), k = new Float32Array(M * 3), B = new Float32Array(M * 3), j = new Float32Array(M), R = new DataView(r);
1367
- let b = m;
1368
- const A = (z) => y.properties.findIndex(
1369
- (f) => f.name === z
1370
- ), C = A("x"), g = A("y"), d = A("z"), I = [
1371
- A("rot_0"),
1372
- A("rot_1"),
1373
- A("rot_2"),
1374
- A("rot_3")
1375
- ], q = [
1376
- A("scale_0"),
1377
- A("scale_1"),
1378
- A("scale_2")
1479
+ const A = w.count, b = new Float32Array(A * 3), z = new Float32Array(A * 4), _ = new Float32Array(A * 3), F = new Float32Array(A * 3), O = new Float32Array(A), V = new DataView(n);
1480
+ let k = y;
1481
+ const M = (D) => w.properties.findIndex(
1482
+ (p) => p.name === D
1483
+ ), B = M("x"), S = M("y"), g = M("z"), v = [
1484
+ M("rot_0"),
1485
+ M("rot_1"),
1486
+ M("rot_2"),
1487
+ M("rot_3")
1379
1488
  ], T = [
1380
- A("f_dc_0"),
1381
- A("f_dc_1"),
1382
- A("f_dc_2")
1383
- ], W = A("opacity");
1489
+ M("scale_0"),
1490
+ M("scale_1"),
1491
+ M("scale_2")
1492
+ ], U = [
1493
+ M("f_dc_0"),
1494
+ M("f_dc_1"),
1495
+ M("f_dc_2")
1496
+ ], I = M("opacity");
1384
1497
  if ([
1385
- C,
1498
+ B,
1499
+ S,
1386
1500
  g,
1387
- d,
1388
- ...I,
1389
- ...q,
1501
+ ...v,
1390
1502
  ...T,
1391
- W
1392
- ].some((z) => z === -1))
1503
+ ...U,
1504
+ I
1505
+ ].some((D) => D === -1))
1393
1506
  throw new Error(
1394
1507
  "Invalid PLY file: Missing required properties"
1395
1508
  );
1396
- const F = 0.28209479177387814, P = (z) => {
1397
- if (z > 0) return 1 / (1 + Math.exp(-z));
1398
- const f = Math.exp(z);
1399
- return f / (1 + f);
1509
+ const f = 0.28209479177387814, C = (D) => {
1510
+ if (D > 0) return 1 / (1 + Math.exp(-D));
1511
+ const p = Math.exp(D);
1512
+ return p / (1 + p);
1400
1513
  };
1401
- let J = 1 / 0, G = 1 / 0, L = 1 / 0, X = -1 / 0, $ = -1 / 0, H = -1 / 0;
1402
- for (let z = 0; z < M; z++) {
1403
- const f = [];
1404
- for (let we = 0; we < y.properties.length; we++) {
1405
- const Ce = y.properties[we].type;
1406
- let ce;
1407
- switch (Ce) {
1514
+ let Y = 1 / 0, W = 1 / 0, R = 1 / 0, J = -1 / 0, Z = -1 / 0, H = -1 / 0;
1515
+ for (let D = 0; D < A; D++) {
1516
+ const p = [];
1517
+ for (let St = 0; St < w.properties.length; St++) {
1518
+ const Et = w.properties[St].type;
1519
+ let ct;
1520
+ switch (Et) {
1408
1521
  case "char":
1409
- ce = R.getInt8(b), b += 1;
1522
+ ct = V.getInt8(k), k += 1;
1410
1523
  break;
1411
1524
  case "uchar":
1412
- ce = R.getUint8(b), b += 1;
1525
+ ct = V.getUint8(k), k += 1;
1413
1526
  break;
1414
1527
  case "short":
1415
- ce = R.getInt16(b, !0), b += 2;
1528
+ ct = V.getInt16(k, !0), k += 2;
1416
1529
  break;
1417
1530
  case "ushort":
1418
- ce = R.getUint16(b, !0), b += 2;
1531
+ ct = V.getUint16(k, !0), k += 2;
1419
1532
  break;
1420
1533
  case "int":
1421
- ce = R.getInt32(b, !0), b += 4;
1534
+ ct = V.getInt32(k, !0), k += 4;
1422
1535
  break;
1423
1536
  case "uint":
1424
- ce = R.getUint32(b, !0), b += 4;
1537
+ ct = V.getUint32(k, !0), k += 4;
1425
1538
  break;
1426
1539
  case "float":
1427
- ce = R.getFloat32(b, !0), b += 4;
1540
+ ct = V.getFloat32(k, !0), k += 4;
1428
1541
  break;
1429
1542
  case "double":
1430
- ce = R.getFloat64(b, !0), b += 8;
1543
+ ct = V.getFloat64(k, !0), k += 8;
1431
1544
  break;
1432
1545
  default:
1433
1546
  throw new Error(
1434
- `Unsupported property type: ${Ce}`
1547
+ `Unsupported property type: ${Et}`
1435
1548
  );
1436
1549
  }
1437
- f.push(ce);
1550
+ p.push(ct);
1438
1551
  }
1439
- const E = f[C], V = f[g], D = f[d], O = z * 3;
1440
- v[O] = E, v[O + 1] = V, v[O + 2] = D, J = Math.min(J, E), G = Math.min(G, V), L = Math.min(L, D), X = Math.max(X, E), $ = Math.max($, V), H = Math.max(H, D);
1441
- let Y = f[I[1]], Z = f[I[2]], Q = f[I[3]], N = f[I[0]];
1552
+ const q = p[B], L = p[S], E = p[g], G = D * 3;
1553
+ b[G] = q, b[G + 1] = L, b[G + 2] = E, Y = Math.min(Y, q), W = Math.min(W, L), R = Math.min(R, E), J = Math.max(J, q), Z = Math.max(Z, L), H = Math.max(H, E);
1554
+ let X = p[v[1]], j = p[v[2]], Q = p[v[3]], $ = p[v[0]];
1442
1555
  const K = Math.sqrt(
1443
- Y * Y + Z * Z + Q * Q + N * N
1556
+ X * X + j * j + Q * Q + $ * $
1444
1557
  );
1445
- K > 0 && (Y /= K, Z /= K, Q /= K, N /= K), N < 0 && (Y = -Y, Z = -Z, Q = -Q, N = -N);
1446
- const se = z * 4;
1447
- S[se] = Y, S[se + 1] = Z, S[se + 2] = Q, S[se + 3] = N;
1448
- const re = z * 3;
1449
- k[re] = f[q[0]], k[re + 1] = f[q[1]], k[re + 2] = f[q[2]];
1450
- let he = 0.5 + f[T[0]] * F, ue = 0.5 + f[T[1]] * F, oe = 0.5 + f[T[2]] * F;
1451
- he = Math.max(0, Math.min(1, he)), ue = Math.max(0, Math.min(1, ue)), oe = Math.max(0, Math.min(1, oe));
1452
- const ge = z * 3;
1453
- B[ge] = he, B[ge + 1] = ue, B[ge + 2] = oe, j[z] = P(f[W]);
1558
+ K > 0 && (X /= K, j /= K, Q /= K, $ /= K), $ < 0 && (X = -X, j = -j, Q = -Q, $ = -$);
1559
+ const tt = D * 4;
1560
+ z[tt] = X, z[tt + 1] = j, z[tt + 2] = Q, z[tt + 3] = $;
1561
+ const et = D * 3;
1562
+ _[et] = p[T[0]], _[et + 1] = p[T[1]], _[et + 2] = p[T[2]];
1563
+ let mt = 0.5 + p[U[0]] * f, dt = 0.5 + p[U[1]] * f, ot = 0.5 + p[U[2]] * f;
1564
+ mt = Math.max(0, Math.min(1, mt)), dt = Math.max(0, Math.min(1, dt)), ot = Math.max(0, Math.min(1, ot));
1565
+ const bt = D * 3;
1566
+ F[bt] = mt, F[bt + 1] = dt, F[bt + 2] = ot, O[D] = C(p[I]);
1454
1567
  }
1455
1568
  return {
1456
- numSplats: M,
1457
- positions: v.buffer,
1458
- rotations: S.buffer,
1459
- scales: k.buffer,
1460
- colors: B.buffer,
1461
- opacities: j.buffer,
1569
+ numSplats: A,
1570
+ positions: b.buffer,
1571
+ rotations: z.buffer,
1572
+ scales: _.buffer,
1573
+ colors: F.buffer,
1574
+ opacities: O.buffer,
1462
1575
  boundingBox: {
1463
- minX: J,
1464
- minY: G,
1465
- minZ: L,
1466
- maxX: X,
1467
- maxY: $,
1576
+ minX: Y,
1577
+ minY: W,
1578
+ minZ: R,
1579
+ maxX: J,
1580
+ maxY: Z,
1468
1581
  maxZ: H
1469
1582
  }
1470
1583
  };
@@ -1472,7 +1585,7 @@ end_header
1472
1585
  }).toString()})();`;
1473
1586
  }
1474
1587
  }
1475
- var ee = Uint8Array, de = Uint16Array, He = Int32Array, Fe = new ee([
1588
+ var st = Uint8Array, pt = Uint16Array, Jt = Int32Array, Vt = new st([
1476
1589
  0,
1477
1590
  0,
1478
1591
  0,
@@ -1507,7 +1620,7 @@ var ee = Uint8Array, de = Uint16Array, He = Int32Array, Fe = new ee([
1507
1620
  0,
1508
1621
  /* impossible */
1509
1622
  0
1510
- ]), qe = new ee([
1623
+ ]), Tt = new st([
1511
1624
  0,
1512
1625
  0,
1513
1626
  0,
@@ -1541,65 +1654,65 @@ var ee = Uint8Array, de = Uint16Array, He = Int32Array, Fe = new ee([
1541
1654
  /* unused */
1542
1655
  0,
1543
1656
  0
1544
- ]), Ye = new ee([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Pe = function(a, e) {
1545
- for (var t = new de(31), s = 0; s < 31; ++s)
1546
- t[s] = e += 1 << a[s - 1];
1547
- for (var r = new He(t[30]), s = 1; s < 30; ++s)
1548
- for (var n = t[s]; n < t[s + 1]; ++n)
1549
- r[n] = n - t[s] << 5 | s;
1550
- return { b: t, r };
1551
- }, Re = Pe(Fe, 2), Te = Re.b, $e = Re.r;
1552
- Te[28] = 258, $e[258] = 28;
1553
- var Ze = Pe(qe, 0), Xe = Ze.b, Ae = new de(32768);
1554
- for (var _ = 0; _ < 32768; ++_) {
1555
- var le = (_ & 43690) >> 1 | (_ & 21845) << 1;
1556
- le = (le & 52428) >> 2 | (le & 13107) << 2, le = (le & 61680) >> 4 | (le & 3855) << 4, Ae[_] = ((le & 65280) >> 8 | (le & 255) << 8) >> 1;
1657
+ ]), Kt = new st([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Ot = function(a, t) {
1658
+ for (var e = new pt(31), s = 0; s < 31; ++s)
1659
+ e[s] = t += 1 << a[s - 1];
1660
+ for (var n = new Jt(e[30]), s = 1; s < 30; ++s)
1661
+ for (var r = e[s]; r < e[s + 1]; ++r)
1662
+ n[r] = r - e[s] << 5 | s;
1663
+ return { b: e, r: n };
1664
+ }, Lt = Ot(Vt, 2), Gt = Lt.b, te = Lt.r;
1665
+ Gt[28] = 258, te[258] = 28;
1666
+ var ee = Ot(Tt, 0), se = ee.b, zt = new pt(32768);
1667
+ for (var N = 0; N < 32768; ++N) {
1668
+ var lt = (N & 43690) >> 1 | (N & 21845) << 1;
1669
+ lt = (lt & 52428) >> 2 | (lt & 13107) << 2, lt = (lt & 61680) >> 4 | (lt & 3855) << 4, zt[N] = ((lt & 65280) >> 8 | (lt & 255) << 8) >> 1;
1557
1670
  }
1558
- var pe = function(a, e, t) {
1559
- for (var s = a.length, r = 0, n = new de(e); r < s; ++r)
1560
- a[r] && ++n[a[r] - 1];
1561
- var o = new de(e);
1562
- for (r = 1; r < e; ++r)
1563
- o[r] = o[r - 1] + n[r - 1] << 1;
1671
+ var yt = function(a, t, e) {
1672
+ for (var s = a.length, n = 0, r = new pt(t); n < s; ++n)
1673
+ a[n] && ++r[a[n] - 1];
1674
+ var o = new pt(t);
1675
+ for (n = 1; n < t; ++n)
1676
+ o[n] = o[n - 1] + r[n - 1] << 1;
1564
1677
  var i;
1565
- if (t) {
1566
- i = new de(1 << e);
1567
- var u = 15 - e;
1568
- for (r = 0; r < s; ++r)
1569
- if (a[r])
1570
- for (var m = r << 4 | a[r], x = e - a[r], c = o[a[r] - 1]++ << x, l = c | (1 << x) - 1; c <= l; ++c)
1571
- i[Ae[c] >> u] = m;
1678
+ if (e) {
1679
+ i = new pt(1 << t);
1680
+ var u = 15 - t;
1681
+ for (n = 0; n < s; ++n)
1682
+ if (a[n])
1683
+ for (var y = n << 4 | a[n], m = t - a[n], c = o[a[n] - 1]++ << m, h = c | (1 << m) - 1; c <= h; ++c)
1684
+ i[zt[c] >> u] = y;
1572
1685
  } else
1573
- for (i = new de(s), r = 0; r < s; ++r)
1574
- a[r] && (i[r] = Ae[o[a[r] - 1]++] >> 15 - a[r]);
1686
+ for (i = new pt(s), n = 0; n < s; ++n)
1687
+ a[n] && (i[n] = zt[o[a[n] - 1]++] >> 15 - a[n]);
1575
1688
  return i;
1576
- }, xe = new ee(288);
1577
- for (var _ = 0; _ < 144; ++_)
1578
- xe[_] = 8;
1579
- for (var _ = 144; _ < 256; ++_)
1580
- xe[_] = 9;
1581
- for (var _ = 256; _ < 280; ++_)
1582
- xe[_] = 7;
1583
- for (var _ = 280; _ < 288; ++_)
1584
- xe[_] = 8;
1585
- var Ue = new ee(32);
1586
- for (var _ = 0; _ < 32; ++_)
1587
- Ue[_] = 5;
1588
- var Qe = /* @__PURE__ */ pe(xe, 9, 1), Je = /* @__PURE__ */ pe(Ue, 5, 1), ve = function(a) {
1589
- for (var e = a[0], t = 1; t < a.length; ++t)
1590
- a[t] > e && (e = a[t]);
1591
- return e;
1592
- }, ne = function(a, e, t) {
1593
- var s = e / 8 | 0;
1594
- return (a[s] | a[s + 1] << 8) >> (e & 7) & t;
1595
- }, Me = function(a, e) {
1596
- var t = e / 8 | 0;
1597
- return (a[t] | a[t + 1] << 8 | a[t + 2] << 16) >> (e & 7);
1598
- }, Ke = function(a) {
1689
+ }, vt = new st(288);
1690
+ for (var N = 0; N < 144; ++N)
1691
+ vt[N] = 8;
1692
+ for (var N = 144; N < 256; ++N)
1693
+ vt[N] = 9;
1694
+ for (var N = 256; N < 280; ++N)
1695
+ vt[N] = 7;
1696
+ for (var N = 280; N < 288; ++N)
1697
+ vt[N] = 8;
1698
+ var Wt = new st(32);
1699
+ for (var N = 0; N < 32; ++N)
1700
+ Wt[N] = 5;
1701
+ var ne = /* @__PURE__ */ yt(vt, 9, 1), re = /* @__PURE__ */ yt(Wt, 5, 1), kt = function(a) {
1702
+ for (var t = a[0], e = 1; e < a.length; ++e)
1703
+ a[e] > t && (t = a[e]);
1704
+ return t;
1705
+ }, rt = function(a, t, e) {
1706
+ var s = t / 8 | 0;
1707
+ return (a[s] | a[s + 1] << 8) >> (t & 7) & e;
1708
+ }, It = function(a, t) {
1709
+ var e = t / 8 | 0;
1710
+ return (a[e] | a[e + 1] << 8 | a[e + 2] << 16) >> (t & 7);
1711
+ }, ae = function(a) {
1599
1712
  return (a + 7) / 8 | 0;
1600
- }, ke = function(a, e, t) {
1601
- return (e == null || e < 0) && (e = 0), (t == null || t > a.length) && (t = a.length), new ee(a.subarray(e, t));
1602
- }, et = [
1713
+ }, qt = function(a, t, e) {
1714
+ return (t == null || t < 0) && (t = 0), (e == null || e > a.length) && (e = a.length), new st(a.subarray(t, e));
1715
+ }, oe = [
1603
1716
  "unexpected EOF",
1604
1717
  "invalid block type",
1605
1718
  "invalid length/literal",
@@ -1615,250 +1728,272 @@ var Qe = /* @__PURE__ */ pe(xe, 9, 1), Je = /* @__PURE__ */ pe(Ue, 5, 1), ve = f
1615
1728
  "stream finishing",
1616
1729
  "invalid zip data"
1617
1730
  // determined by unknown compression method
1618
- ], te = function(a, e, t) {
1619
- var s = new Error(e || et[a]);
1620
- if (s.code = a, Error.captureStackTrace && Error.captureStackTrace(s, te), !t)
1731
+ ], nt = function(a, t, e) {
1732
+ var s = new Error(t || oe[a]);
1733
+ if (s.code = a, Error.captureStackTrace && Error.captureStackTrace(s, nt), !e)
1621
1734
  throw s;
1622
1735
  return s;
1623
- }, tt = function(a, e, t, s) {
1624
- var r = a.length, n = s ? s.length : 0;
1625
- if (!r || e.f && !e.l)
1626
- return t || new ee(0);
1627
- var o = !t, i = o || e.i != 2, u = e.i;
1628
- o && (t = new ee(r * 3));
1629
- var m = function(Z) {
1630
- var Q = t.length;
1631
- if (Z > Q) {
1632
- var N = new ee(Math.max(Q * 2, Z));
1633
- N.set(t), t = N;
1736
+ }, ie = function(a, t, e, s) {
1737
+ var n = a.length, r = s ? s.length : 0;
1738
+ if (!n || t.f && !t.l)
1739
+ return e || new st(0);
1740
+ var o = !e, i = o || t.i != 2, u = t.i;
1741
+ o && (e = new st(n * 3));
1742
+ var y = function(j) {
1743
+ var Q = e.length;
1744
+ if (j > Q) {
1745
+ var $ = new st(Math.max(Q * 2, j));
1746
+ $.set(e), e = $;
1634
1747
  }
1635
- }, x = e.f || 0, c = e.p || 0, l = e.b || 0, p = e.l, y = e.d, M = e.m, v = e.n, S = r * 8;
1748
+ }, m = t.f || 0, c = t.p || 0, h = t.b || 0, d = t.l, w = t.d, A = t.m, b = t.n, z = n * 8;
1636
1749
  do {
1637
- if (!p) {
1638
- x = ne(a, c, 1);
1639
- var k = ne(a, c + 1, 3);
1640
- if (c += 3, k)
1641
- if (k == 1)
1642
- p = Qe, y = Je, M = 9, v = 5;
1643
- else if (k == 2) {
1644
- var b = ne(a, c, 31) + 257, A = ne(a, c + 10, 15) + 4, C = b + ne(a, c + 5, 31) + 1;
1750
+ if (!d) {
1751
+ m = rt(a, c, 1);
1752
+ var _ = rt(a, c + 1, 3);
1753
+ if (c += 3, _)
1754
+ if (_ == 1)
1755
+ d = ne, w = re, A = 9, b = 5;
1756
+ else if (_ == 2) {
1757
+ var k = rt(a, c, 31) + 257, M = rt(a, c + 10, 15) + 4, B = k + rt(a, c + 5, 31) + 1;
1645
1758
  c += 14;
1646
- for (var g = new ee(C), d = new ee(19), I = 0; I < A; ++I)
1647
- d[Ye[I]] = ne(a, c + I * 3, 7);
1648
- c += A * 3;
1649
- for (var q = ve(d), T = (1 << q) - 1, W = pe(d, q, 1), I = 0; I < C; ) {
1650
- var U = W[ne(a, c, T)];
1651
- c += U & 15;
1652
- var B = U >> 4;
1653
- if (B < 16)
1654
- g[I++] = B;
1759
+ for (var S = new st(B), g = new st(19), v = 0; v < M; ++v)
1760
+ g[Kt[v]] = rt(a, c + v * 3, 7);
1761
+ c += M * 3;
1762
+ for (var T = kt(g), U = (1 << T) - 1, I = yt(g, T, 1), v = 0; v < B; ) {
1763
+ var P = I[rt(a, c, U)];
1764
+ c += P & 15;
1765
+ var F = P >> 4;
1766
+ if (F < 16)
1767
+ S[v++] = F;
1655
1768
  else {
1656
- var F = 0, P = 0;
1657
- for (B == 16 ? (P = 3 + ne(a, c, 3), c += 2, F = g[I - 1]) : B == 17 ? (P = 3 + ne(a, c, 7), c += 3) : B == 18 && (P = 11 + ne(a, c, 127), c += 7); P--; )
1658
- g[I++] = F;
1769
+ var f = 0, C = 0;
1770
+ for (F == 16 ? (C = 3 + rt(a, c, 3), c += 2, f = S[v - 1]) : F == 17 ? (C = 3 + rt(a, c, 7), c += 3) : F == 18 && (C = 11 + rt(a, c, 127), c += 7); C--; )
1771
+ S[v++] = f;
1659
1772
  }
1660
1773
  }
1661
- var J = g.subarray(0, b), G = g.subarray(b);
1662
- M = ve(J), v = ve(G), p = pe(J, M, 1), y = pe(G, v, 1);
1774
+ var Y = S.subarray(0, k), W = S.subarray(k);
1775
+ A = kt(Y), b = kt(W), d = yt(Y, A, 1), w = yt(W, b, 1);
1663
1776
  } else
1664
- te(1);
1777
+ nt(1);
1665
1778
  else {
1666
- var B = Ke(c) + 4, j = a[B - 4] | a[B - 3] << 8, R = B + j;
1667
- if (R > r) {
1668
- u && te(0);
1779
+ var F = ae(c) + 4, O = a[F - 4] | a[F - 3] << 8, V = F + O;
1780
+ if (V > n) {
1781
+ u && nt(0);
1669
1782
  break;
1670
1783
  }
1671
- i && m(l + j), t.set(a.subarray(B, R), l), e.b = l += j, e.p = c = R * 8, e.f = x;
1784
+ i && y(h + O), e.set(a.subarray(F, V), h), t.b = h += O, t.p = c = V * 8, t.f = m;
1672
1785
  continue;
1673
1786
  }
1674
- if (c > S) {
1675
- u && te(0);
1787
+ if (c > z) {
1788
+ u && nt(0);
1676
1789
  break;
1677
1790
  }
1678
1791
  }
1679
- i && m(l + 131072);
1680
- for (var L = (1 << M) - 1, X = (1 << v) - 1, $ = c; ; $ = c) {
1681
- var F = p[Me(a, c) & L], H = F >> 4;
1682
- if (c += F & 15, c > S) {
1683
- u && te(0);
1792
+ i && y(h + 131072);
1793
+ for (var R = (1 << A) - 1, J = (1 << b) - 1, Z = c; ; Z = c) {
1794
+ var f = d[It(a, c) & R], H = f >> 4;
1795
+ if (c += f & 15, c > z) {
1796
+ u && nt(0);
1684
1797
  break;
1685
1798
  }
1686
- if (F || te(2), H < 256)
1687
- t[l++] = H;
1799
+ if (f || nt(2), H < 256)
1800
+ e[h++] = H;
1688
1801
  else if (H == 256) {
1689
- $ = c, p = null;
1802
+ Z = c, d = null;
1690
1803
  break;
1691
1804
  } else {
1692
- var z = H - 254;
1805
+ var D = H - 254;
1693
1806
  if (H > 264) {
1694
- var I = H - 257, f = Fe[I];
1695
- z = ne(a, c, (1 << f) - 1) + Te[I], c += f;
1807
+ var v = H - 257, p = Vt[v];
1808
+ D = rt(a, c, (1 << p) - 1) + Gt[v], c += p;
1696
1809
  }
1697
- var E = y[Me(a, c) & X], V = E >> 4;
1698
- E || te(3), c += E & 15;
1699
- var G = Xe[V];
1700
- if (V > 3) {
1701
- var f = qe[V];
1702
- G += Me(a, c) & (1 << f) - 1, c += f;
1810
+ var q = w[It(a, c) & J], L = q >> 4;
1811
+ q || nt(3), c += q & 15;
1812
+ var W = se[L];
1813
+ if (L > 3) {
1814
+ var p = Tt[L];
1815
+ W += It(a, c) & (1 << p) - 1, c += p;
1703
1816
  }
1704
- if (c > S) {
1705
- u && te(0);
1817
+ if (c > z) {
1818
+ u && nt(0);
1706
1819
  break;
1707
1820
  }
1708
- i && m(l + 131072);
1709
- var D = l + z;
1710
- if (l < G) {
1711
- var O = n - G, Y = Math.min(G, D);
1712
- for (O + l < 0 && te(3); l < Y; ++l)
1713
- t[l] = s[O + l];
1821
+ i && y(h + 131072);
1822
+ var E = h + D;
1823
+ if (h < W) {
1824
+ var G = r - W, X = Math.min(W, E);
1825
+ for (G + h < 0 && nt(3); h < X; ++h)
1826
+ e[h] = s[G + h];
1714
1827
  }
1715
- for (; l < D; ++l)
1716
- t[l] = t[l - G];
1828
+ for (; h < E; ++h)
1829
+ e[h] = e[h - W];
1717
1830
  }
1718
1831
  }
1719
- e.l = p, e.p = $, e.b = l, e.f = x, p && (x = 1, e.m = M, e.d = y, e.n = v);
1720
- } while (!x);
1721
- return l != t.length && o ? ke(t, 0, l) : t.subarray(0, l);
1722
- }, st = /* @__PURE__ */ new ee(0), ie = function(a, e) {
1723
- return a[e] | a[e + 1] << 8;
1724
- }, ae = function(a, e) {
1725
- return (a[e] | a[e + 1] << 8 | a[e + 2] << 16 | a[e + 3] << 24) >>> 0;
1726
- }, be = function(a, e) {
1727
- return ae(a, e) + ae(a, e + 4) * 4294967296;
1832
+ t.l = d, t.p = Z, t.b = h, t.f = m, d && (m = 1, t.m = A, t.d = w, t.n = b);
1833
+ } while (!m);
1834
+ return h != e.length && o ? qt(e, 0, h) : e.subarray(0, h);
1835
+ }, ce = /* @__PURE__ */ new st(0), it = function(a, t) {
1836
+ return a[t] | a[t + 1] << 8;
1837
+ }, at = function(a, t) {
1838
+ return (a[t] | a[t + 1] << 8 | a[t + 2] << 16 | a[t + 3] << 24) >>> 0;
1839
+ }, Ct = function(a, t) {
1840
+ return at(a, t) + at(a, t + 4) * 4294967296;
1728
1841
  };
1729
- function rt(a, e) {
1730
- return tt(a, { i: 2 }, e && e.out, e && e.dictionary);
1842
+ function le(a, t) {
1843
+ return ie(a, { i: 2 }, t && t.out, t && t.dictionary);
1731
1844
  }
1732
- var Ie = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), nt = 0;
1845
+ var Dt = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), he = 0;
1733
1846
  try {
1734
- Ie.decode(st, { stream: !0 }), nt = 1;
1847
+ Dt.decode(ce, { stream: !0 }), he = 1;
1735
1848
  } catch {
1736
1849
  }
1737
- var at = function(a) {
1738
- for (var e = "", t = 0; ; ) {
1739
- var s = a[t++], r = (s > 127) + (s > 223) + (s > 239);
1740
- if (t + r > a.length)
1741
- return { s: e, r: ke(a, t - 1) };
1742
- 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);
1850
+ var ue = function(a) {
1851
+ for (var t = "", e = 0; ; ) {
1852
+ var s = a[e++], n = (s > 127) + (s > 223) + (s > 239);
1853
+ if (e + n > a.length)
1854
+ return { s: t, r: qt(a, e - 1) };
1855
+ n ? n == 3 ? (s = ((s & 15) << 18 | (a[e++] & 63) << 12 | (a[e++] & 63) << 6 | a[e++] & 63) - 65536, t += String.fromCharCode(55296 | s >> 10, 56320 | s & 1023)) : n & 1 ? t += String.fromCharCode((s & 31) << 6 | a[e++] & 63) : t += String.fromCharCode((s & 15) << 12 | (a[e++] & 63) << 6 | a[e++] & 63) : t += String.fromCharCode(s);
1743
1856
  }
1744
1857
  };
1745
- function ot(a, e) {
1746
- if (e) {
1747
- for (var t = "", s = 0; s < a.length; s += 16384)
1748
- t += String.fromCharCode.apply(null, a.subarray(s, s + 16384));
1749
- return t;
1858
+ function me(a, t) {
1859
+ if (t) {
1860
+ for (var e = "", s = 0; s < a.length; s += 16384)
1861
+ e += String.fromCharCode.apply(null, a.subarray(s, s + 16384));
1862
+ return e;
1750
1863
  } else {
1751
- if (Ie)
1752
- return Ie.decode(a);
1753
- var r = at(a), n = r.s, t = r.r;
1754
- return t.length && te(8), n;
1864
+ if (Dt)
1865
+ return Dt.decode(a);
1866
+ var n = ue(a), r = n.s, e = n.r;
1867
+ return e.length && nt(8), r;
1755
1868
  }
1756
1869
  }
1757
- var it = function(a, e) {
1758
- return e + 30 + ie(a, e + 26) + ie(a, e + 28);
1759
- }, ct = function(a, e, t) {
1760
- var s = ie(a, e + 28), r = ot(a.subarray(e + 46, e + 46 + s), !(ie(a, e + 8) & 2048)), n = e + 46 + s, o = ae(a, e + 20), i = t && o == 4294967295 ? lt(a, n) : [o, ae(a, e + 24), ae(a, e + 42)], u = i[0], m = i[1], x = i[2];
1761
- return [ie(a, e + 10), u, m, r, n + ie(a, e + 30) + ie(a, e + 32), x];
1762
- }, lt = function(a, e) {
1763
- for (; ie(a, e) != 1; e += 4 + ie(a, e + 2))
1870
+ var de = function(a, t) {
1871
+ return t + 30 + it(a, t + 26) + it(a, t + 28);
1872
+ }, fe = function(a, t, e) {
1873
+ var s = it(a, t + 28), n = me(a.subarray(t + 46, t + 46 + s), !(it(a, t + 8) & 2048)), r = t + 46 + s, o = at(a, t + 20), i = e && o == 4294967295 ? pe(a, r) : [o, at(a, t + 24), at(a, t + 42)], u = i[0], y = i[1], m = i[2];
1874
+ return [it(a, t + 10), u, y, n, r + it(a, t + 30) + it(a, t + 32), m];
1875
+ }, pe = function(a, t) {
1876
+ for (; it(a, t) != 1; t += 4 + it(a, t + 2))
1764
1877
  ;
1765
- return [be(a, e + 12), be(a, e + 4), be(a, e + 20)];
1878
+ return [Ct(a, t + 12), Ct(a, t + 4), Ct(a, t + 20)];
1766
1879
  };
1767
- function ht(a, e) {
1768
- for (var t = {}, s = a.length - 22; ae(a, s) != 101010256; --s)
1769
- (!s || a.length - s > 65558) && te(13);
1770
- var r = ie(a, s + 8);
1771
- if (!r)
1880
+ function xe(a, t) {
1881
+ for (var e = {}, s = a.length - 22; at(a, s) != 101010256; --s)
1882
+ (!s || a.length - s > 65558) && nt(13);
1883
+ var n = it(a, s + 8);
1884
+ if (!n)
1772
1885
  return {};
1773
- var n = ae(a, s + 16), o = n == 4294967295 || r == 65535;
1886
+ var r = at(a, s + 16), o = r == 4294967295 || n == 65535;
1774
1887
  if (o) {
1775
- var i = ae(a, s - 12);
1776
- o = ae(a, i) == 101075792, o && (r = ae(a, i + 32), n = ae(a, i + 48));
1888
+ var i = at(a, s - 12);
1889
+ o = at(a, i) == 101075792, o && (n = at(a, i + 32), r = at(a, i + 48));
1777
1890
  }
1778
- for (var u = 0; u < r; ++u) {
1779
- var m = ct(a, n, o), x = m[0], c = m[1], l = m[2], p = m[3], y = m[4], M = m[5], v = it(a, M);
1780
- n = y, x ? x == 8 ? t[p] = rt(a.subarray(v, v + c), { out: new ee(l) }) : te(14, "unknown compression type " + x) : t[p] = ke(a, v, v + c);
1891
+ for (var u = 0; u < n; ++u) {
1892
+ var y = fe(a, r, o), m = y[0], c = y[1], h = y[2], d = y[3], w = y[4], A = y[5], b = de(a, A);
1893
+ r = w, m ? m == 8 ? e[d] = le(a.subarray(b, b + c), { out: new st(h) }) : nt(14, "unknown compression type " + m) : e[d] = qt(a, b, b + c);
1781
1894
  }
1782
- return t;
1895
+ return e;
1783
1896
  }
1784
- const Ee = (a) => {
1785
- if (typeof a != "object" || a === null) throw new Error("Invalid SOGS metadata: not an object");
1786
- const e = a, t = e.version ?? 1;
1787
- if (t !== 1) throw new Error(`Unsupported SOGS version: ${String(t)}`);
1788
- const s = (M) => {
1789
- const v = e[M];
1790
- if (typeof v != "object" || v === null) throw new Error(`Invalid SOGS metadata section: ${M}`);
1791
- return v;
1792
- }, r = s("means"), n = s("sh0"), o = s("quats"), i = s("scales"), u = typeof e.count == "number" && Number.isFinite(e.count) ? e.count : void 0, m = Array.isArray(r.shape) ? r.shape : void 0, x = m && typeof m[0] == "number" ? m[0] : void 0;
1793
- if (u === void 0 && x === void 0)
1794
- throw new Error(
1795
- "Invalid SOGS metadata: unable to determine splat count"
1796
- );
1797
- if (u !== void 0 && x !== void 0 && u !== x)
1798
- throw new Error(
1799
- "Inconsistent SOGS metadata: count does not match means.shape[0]"
1800
- );
1801
- const c = u ?? x, l = (M, v) => {
1802
- const S = M.mins, k = M.maxs;
1803
- if (!Array.isArray(S) || S.length !== 3)
1804
- throw new Error(`${v}.mins must be length-3`);
1805
- if (!Array.isArray(k) || k.length !== 3)
1806
- throw new Error(`${v}.maxs must be length-3`);
1807
- if (![...S, ...k].every(
1808
- (B) => typeof B == "number" && Number.isFinite(B)
1809
- ))
1810
- throw new Error(`${v}.mins/maxs must be finite numbers`);
1811
- return {
1812
- mins: [S[0], S[1], S[2]],
1813
- maxs: [k[0], k[1], k[2]]
1814
- };
1815
- }, p = (M, v) => {
1816
- const S = M.mins, k = M.maxs;
1817
- if (!Array.isArray(S) || S.length !== 4)
1818
- throw new Error(`${v}.mins must be length-4`);
1819
- if (!Array.isArray(k) || k.length !== 4)
1820
- throw new Error(`${v}.maxs must be length-4`);
1821
- if (![...S, ...k].every(
1822
- (B) => typeof B == "number" && Number.isFinite(B)
1823
- ))
1824
- throw new Error(`${v}.mins/maxs must be finite numbers`);
1897
+ const Mt = (a) => typeof a == "number" && Number.isFinite(a), ht = (a, t) => {
1898
+ const e = a[t];
1899
+ if (typeof e != "object" || e === null)
1900
+ throw new Error(`Invalid SOG metadata section: ${t}`);
1901
+ return e;
1902
+ }, ut = (a, t) => {
1903
+ const e = a.files;
1904
+ if (!Array.isArray(e))
1905
+ throw new Error(`${t}.files is not an array`);
1906
+ if (!e.every((s) => typeof s == "string"))
1907
+ throw new Error(`${t}.files contains non-strings`);
1908
+ return e;
1909
+ }, Bt = (a, t) => {
1910
+ const e = a.mins, s = a.maxs;
1911
+ if (!Array.isArray(e) || e.length !== 3)
1912
+ throw new Error(`${t}.mins must be length-3`);
1913
+ if (!Array.isArray(s) || s.length !== 3)
1914
+ throw new Error(`${t}.maxs must be length-3`);
1915
+ if (![...e, ...s].every(Mt))
1916
+ throw new Error(`${t}.mins/maxs must be finite numbers`);
1917
+ return {
1918
+ mins: [e[0], e[1], e[2]],
1919
+ maxs: [s[0], s[1], s[2]]
1920
+ };
1921
+ }, ge = (a, t) => {
1922
+ const e = a.mins, s = a.maxs;
1923
+ if (!Array.isArray(e) || e.length !== 4)
1924
+ throw new Error(`${t}.mins must be length-4`);
1925
+ if (!Array.isArray(s) || s.length !== 4)
1926
+ throw new Error(`${t}.maxs must be length-4`);
1927
+ if (![...e, ...s].every(Mt))
1928
+ throw new Error(`${t}.mins/maxs must be finite numbers`);
1929
+ return {
1930
+ mins: [e[0], e[1], e[2], e[3]],
1931
+ maxs: [s[0], s[1], s[2], s[3]]
1932
+ };
1933
+ }, _t = (a, t) => {
1934
+ const e = a.codebook;
1935
+ if (!Array.isArray(e))
1936
+ throw new Error(`${t}.codebook is not an array`);
1937
+ if (!e.every(Mt))
1938
+ throw new Error(`${t}.codebook contains non-finite numbers`);
1939
+ return e;
1940
+ }, Ut = (a) => {
1941
+ if (typeof a != "object" || a === null) throw new Error("Invalid SOG metadata: not an object");
1942
+ const t = a, e = t.version ?? 1;
1943
+ if (e !== 1 && e !== 2) throw new Error(`Unsupported SOG version: ${String(e)}`);
1944
+ if (e === 1) {
1945
+ const m = ht(t, "means"), c = ht(t, "sh0"), h = ht(t, "quats"), d = ht(t, "scales"), w = typeof t.count == "number" && Number.isFinite(t.count) ? t.count : void 0, A = Array.isArray(m.shape) ? m.shape : void 0, b = A && typeof A[0] == "number" ? A[0] : void 0;
1946
+ if (w === void 0 && b === void 0) throw new Error("Invalid SOGS metadata: unable to determine splat count");
1947
+ if (w !== void 0 && b !== void 0 && w !== b) throw new Error("Inconsistent SOGS metadata: count does not match means.shape[0]");
1825
1948
  return {
1826
- mins: [S[0], S[1], S[2], S[3]],
1827
- maxs: [k[0], k[1], k[2], k[3]]
1949
+ version: 1,
1950
+ numSplats: (w ?? b) | 0,
1951
+ files: {
1952
+ sh0: ut(c, "sh0"),
1953
+ means: ut(m, "means"),
1954
+ quats: ut(h, "quats"),
1955
+ scales: ut(d, "scales")
1956
+ },
1957
+ ranges: {
1958
+ sh0: ge(c, "sh0"),
1959
+ means: Bt(m, "means"),
1960
+ scales: Bt(d, "scales")
1961
+ }
1828
1962
  };
1829
- }, y = (M, v) => {
1830
- const S = M.files;
1831
- if (!Array.isArray(S)) throw new Error(`${v}.files is not an array`);
1832
- if (!S.every((k) => typeof k == "string")) throw new Error(`${v}.files contains non-strings`);
1833
- return S;
1834
- };
1963
+ }
1964
+ const s = t.count;
1965
+ if (!Mt(s)) throw new Error('Invalid SOG v2 metadata: missing/invalid "count"');
1966
+ const n = s | 0, r = ht(t, "means"), o = ht(t, "sh0"), i = ht(t, "quats"), u = ht(t, "scales");
1835
1967
  return {
1836
- numSplats: c,
1968
+ version: 2,
1969
+ numSplats: n,
1837
1970
  files: {
1838
- sh0: y(n, "sh0"),
1839
- means: y(r, "means"),
1840
- quats: y(o, "quats"),
1841
- scales: y(i, "scales")
1971
+ sh0: ut(o, "sh0"),
1972
+ means: ut(r, "means"),
1973
+ quats: ut(i, "quats"),
1974
+ scales: ut(u, "scales")
1842
1975
  },
1843
1976
  ranges: {
1844
- sh0: p(n, "sh0"),
1845
- means: l(r, "means"),
1846
- scales: l(i, "scales")
1847
- }
1977
+ means: Bt(r, "means"),
1978
+ sh0: { codebook: _t(o, "sh0") },
1979
+ scales: { codebook: _t(u, "scales") }
1980
+ },
1981
+ antialias: typeof t.antialias == "boolean" ? t.antialias : void 0
1982
+ // prettier-ignore
1848
1983
  };
1849
1984
  };
1850
- class ft extends h.Loader {
1851
- constructor(e) {
1852
- super(e), this.withCredentials = !0;
1985
+ class Me extends l.Loader {
1986
+ constructor(t) {
1987
+ super(t), this.withCredentials = !0;
1853
1988
  }
1854
1989
  /**
1855
1990
  * Detect if a buffer is a ZIP file by checking magic bytes
1856
1991
  * ZIP files start with signature: PK\x03\x04 (0x50 0x4B 0x03 0x04)
1857
1992
  */
1858
- isZipBuffer(e) {
1859
- if (e.byteLength < 4) return !1;
1860
- const t = new Uint8Array(e, 0, 4);
1861
- return t[0] === 80 && t[1] === 75 && t[2] === 3 && t[3] === 4;
1993
+ isZipBuffer(t) {
1994
+ if (t.byteLength < 4) return !1;
1995
+ const e = new Uint8Array(t, 0, 4);
1996
+ return e[0] === 80 && e[1] === 75 && e[2] === 3 && e[3] === 4;
1862
1997
  }
1863
1998
  /**
1864
1999
  * Load a SOGS file (meta.json + textures)
@@ -1867,19 +2002,19 @@ class ft extends h.Loader {
1867
2002
  * @param onProgress Optional progress callback
1868
2003
  * @param onError Optional error callback
1869
2004
  */
1870
- load(e, t, s, r) {
1871
- const n = new h.FileLoader(this.manager);
1872
- n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
1873
- e,
2005
+ load(t, e, s, n) {
2006
+ const r = new l.FileLoader(this.manager);
2007
+ r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
2008
+ t,
1874
2009
  (o) => {
1875
- this.parseAsync(e, o).then((i) => {
1876
- t && t(i);
2010
+ this.parseAsync(t, o).then((i) => {
2011
+ e && e(i);
1877
2012
  }).catch((i) => {
1878
- this.manager.itemError(e), r && r(i), console.error("Error loading SOGS meta:", i);
2013
+ this.manager.itemError(t), n && n(i), console.error("Error loading SOGS meta:", i);
1879
2014
  });
1880
2015
  },
1881
2016
  s,
1882
- r
2017
+ n
1883
2018
  );
1884
2019
  }
1885
2020
  /**
@@ -1888,52 +2023,52 @@ class ft extends h.Loader {
1888
2023
  * @param onProgress Optional progress callback
1889
2024
  * @returns A Promise that resolves with the parsed SplatData
1890
2025
  */
1891
- loadAsync(e, t) {
1892
- return new Promise((s, r) => {
1893
- const n = new h.FileLoader(this.manager);
1894
- n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
1895
- e,
2026
+ loadAsync(t, e) {
2027
+ return new Promise((s, n) => {
2028
+ const r = new l.FileLoader(this.manager);
2029
+ r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
2030
+ t,
1896
2031
  (o) => {
1897
- this.parseAsync(e, o).then(s).catch((i) => {
1898
- r(i), this.manager.itemError(e);
2032
+ this.parseAsync(t, o).then(s).catch((i) => {
2033
+ n(i), this.manager.itemError(t);
1899
2034
  });
1900
2035
  },
1901
- t,
2036
+ e,
1902
2037
  (o) => {
1903
- r(o), this.manager.itemError(e);
2038
+ n(o), this.manager.itemError(t);
1904
2039
  }
1905
2040
  );
1906
2041
  });
1907
2042
  }
1908
- async parseAsync(e, t) {
1909
- if (!(t instanceof ArrayBuffer)) throw new Error("SOGS loader: expected ArrayBuffer payload");
1910
- if (this.isZipBuffer(t)) return this.parseZipAsync(t);
1911
- const r = new TextDecoder("utf-8").decode(t), n = JSON.parse(r);
1912
- return this.parseMetaAsync(e, n);
2043
+ async parseAsync(t, e) {
2044
+ if (!(e instanceof ArrayBuffer)) throw new Error("SOGS loader: expected ArrayBuffer payload");
2045
+ if (this.isZipBuffer(e)) return this.parseZipAsync(e);
2046
+ const n = new TextDecoder("utf-8").decode(e), r = JSON.parse(n);
2047
+ return this.parseMetaAsync(t, r);
1913
2048
  }
1914
- async parseMetaAsync(e, t) {
1915
- const { numSplats: s, files: r, ranges: n } = Ee(t), o = new h.TextureLoader(this.manager);
1916
- o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials);
1917
- const i = (S, k) => {
2049
+ async parseMetaAsync(t, e) {
2050
+ const s = Ut(e), { numSplats: n, files: r, ranges: o, version: i } = s, u = new l.TextureLoader(this.manager);
2051
+ u.setPath(this.path), u.setRequestHeader(this.requestHeader), u.setWithCredentials(this.withCredentials);
2052
+ const y = (F, O) => {
1918
2053
  try {
1919
- return new URL(k, S).toString();
2054
+ return new URL(O, F).toString();
1920
2055
  } catch {
1921
- return S.substring(0, S.lastIndexOf("/") + 1) + k;
2056
+ return F.substring(0, F.lastIndexOf("/") + 1) + O;
1922
2057
  }
1923
- }, u = (S, k) => {
1924
- const B = i(e, S);
1925
- return new Promise((j, R) => {
1926
- o.load(
1927
- B,
1928
- (b) => {
1929
- b.generateMipmaps = !1, b.magFilter = h.NearestFilter, b.minFilter = h.NearestFilter, b.flipY = !1, j(b);
2058
+ }, m = (F, O) => {
2059
+ const V = y(t, F);
2060
+ return new Promise((k, M) => {
2061
+ u.load(
2062
+ V,
2063
+ (B) => {
2064
+ B.generateMipmaps = !1, B.magFilter = l.NearestFilter, B.minFilter = l.NearestFilter, B.flipY = !1, k(B);
1930
2065
  },
1931
2066
  void 0,
1932
- (b) => {
1933
- const A = b instanceof Error ? b.message : String(b);
1934
- R(
2067
+ (B) => {
2068
+ const S = B instanceof Error ? B.message : String(B);
2069
+ M(
1935
2070
  new Error(
1936
- `SOGS loader: failed to load ${k} (${S}): ${A}`
2071
+ `SOGS loader: failed to load ${O} (${F}): ${S}`
1937
2072
  )
1938
2073
  );
1939
2074
  }
@@ -1944,49 +2079,54 @@ class ft extends h.Loader {
1944
2079
  if (!Array.isArray(r.means) || r.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
1945
2080
  if (!Array.isArray(r.quats) || r.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
1946
2081
  if (!Array.isArray(r.scales) || r.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
1947
- const [m, x, c, l, p] = await Promise.all([
1948
- u(r.means[0], "means_l"),
1949
- u(r.means[1], "means_u"),
1950
- u(r.quats[0], "quats"),
1951
- u(r.scales[0], "scales"),
1952
- u(r.sh0[0], "sh0")
1953
- ]), y = { means_l: m, means_u: x, quats: c, scales: l, sh0: p }, M = new ze(s, n, y), v = Se.packSogs(M);
1954
- return M.dispose(), v;
1955
- }
1956
- async parseZipAsync(e) {
1957
- const t = ht(new Uint8Array(e)), s = Object.keys(t), r = s.find((C) => C.toLowerCase().endsWith("meta.json")) ?? null;
1958
- if (!r) throw new Error("SOGS loader: zip missing meta.json");
1959
- const n = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "", o = new TextDecoder(), i = JSON.parse(o.decode(t[r])), { numSplats: u, files: m, ranges: x } = Ee(i), c = (C) => C.replace(/\\/g, "/").replace(/^\.?\//, ""), l = (C) => {
1960
- const g = c(C), d = [c(n + g), g];
1961
- for (const T of d) {
1962
- const W = t[T];
1963
- if (W) return W;
2082
+ const [c, h, d, w, A] = await Promise.all([
2083
+ m(r.means[0], "means_l"),
2084
+ m(r.means[1], "means_u"),
2085
+ m(r.quats[0], "quats"),
2086
+ m(r.scales[0], "scales"),
2087
+ m(r.sh0[0], "sh0")
2088
+ ]), b = { means_l: c, means_u: h, quats: d, scales: w, sh0: A };
2089
+ if (i === 1) {
2090
+ const F = new Ft(n, o, b), O = gt.packSogs(F);
2091
+ return F.dispose(), O;
2092
+ }
2093
+ const z = new Pt(n, o, b), _ = gt.packSog2(z);
2094
+ return z.dispose(), _;
2095
+ }
2096
+ async parseZipAsync(t) {
2097
+ const e = xe(new Uint8Array(t)), s = Object.keys(e), n = s.find((g) => g.toLowerCase().endsWith("meta.json")) ?? null;
2098
+ if (!n) throw new Error("SOGS loader: zip missing meta.json");
2099
+ const r = n.includes("/") ? n.slice(0, n.lastIndexOf("/") + 1) : "", o = new TextDecoder(), i = JSON.parse(o.decode(e[n])), u = Ut(i), { numSplats: y, files: m, ranges: c, version: h } = u, d = (g) => g.replace(/\\/g, "/").replace(/^\.?\//, ""), w = (g) => {
2100
+ const v = d(g), T = [d(r + v), v];
2101
+ for (const P of T) {
2102
+ const f = e[P];
2103
+ if (f) return f;
1964
2104
  }
1965
- const I = g.split("/").pop(), q = s.find((T) => c(T).endsWith("/" + g)) ?? s.find((T) => c(T).endsWith("/" + I)) ?? s.find((T) => c(T) === I) ?? null;
1966
- if (q) return t[q];
1967
- throw new Error(`SOGS loader: zip missing file "${C}"`);
1968
- }, p = (C) => {
1969
- const g = C.toLowerCase();
1970
- return g.endsWith(".png") ? "image/png" : g.endsWith(".jpg") || g.endsWith(".jpeg") ? "image/jpeg" : g.endsWith(".webp") ? "image/webp" : "application/octet-stream";
1971
- }, y = new h.TextureLoader(this.manager);
1972
- y.setRequestHeader(this.requestHeader), y.setWithCredentials(this.withCredentials);
1973
- const M = (C, g) => {
1974
- const d = l(C), I = new Blob([d], {
1975
- type: p(C)
1976
- }), q = URL.createObjectURL(I);
1977
- return new Promise((T, W) => {
1978
- y.load(
1979
- q,
1980
- (U) => {
1981
- URL.revokeObjectURL(q), U.generateMipmaps = !1, U.magFilter = h.NearestFilter, U.minFilter = h.NearestFilter, U.flipY = !1, T(U);
2105
+ const U = v.split("/").pop(), I = s.find((P) => d(P).endsWith("/" + v)) ?? s.find((P) => d(P).endsWith("/" + U)) ?? s.find((P) => d(P) === U) ?? null;
2106
+ if (I) return e[I];
2107
+ throw new Error(`SOGS loader: zip missing file "${g}"`);
2108
+ }, A = (g) => {
2109
+ const v = g.toLowerCase();
2110
+ return v.endsWith(".png") ? "image/png" : v.endsWith(".jpg") || v.endsWith(".jpeg") ? "image/jpeg" : v.endsWith(".webp") ? "image/webp" : "application/octet-stream";
2111
+ }, b = new l.TextureLoader(this.manager);
2112
+ b.setRequestHeader(this.requestHeader), b.setWithCredentials(this.withCredentials);
2113
+ const z = (g, v) => {
2114
+ const T = w(g), U = new Blob([T], {
2115
+ type: A(g)
2116
+ }), I = URL.createObjectURL(U);
2117
+ return new Promise((P, f) => {
2118
+ b.load(
2119
+ I,
2120
+ (C) => {
2121
+ URL.revokeObjectURL(I), C.generateMipmaps = !1, C.magFilter = l.NearestFilter, C.minFilter = l.NearestFilter, C.flipY = !1, P(C);
1982
2122
  },
1983
2123
  void 0,
1984
- (U) => {
1985
- URL.revokeObjectURL(q);
1986
- const F = U instanceof Error ? U.message : String(U);
1987
- W(
2124
+ (C) => {
2125
+ URL.revokeObjectURL(I);
2126
+ const Y = C instanceof Error ? C.message : String(C);
2127
+ f(
1988
2128
  new Error(
1989
- `SOGS loader: failed to load ${g} from zip (${C}): ${F}`
2129
+ `SOGS loader: failed to load ${v} from zip (${g}): ${Y}`
1990
2130
  )
1991
2131
  );
1992
2132
  }
@@ -1997,25 +2137,30 @@ class ft extends h.Loader {
1997
2137
  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)");
1998
2138
  if (!Array.isArray(m.quats) || m.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
1999
2139
  if (!Array.isArray(m.scales) || m.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
2000
- const [v, S, k, B, j] = await Promise.all([
2001
- M(m.means[0], "means_l"),
2002
- M(m.means[1], "means_u"),
2003
- M(m.quats[0], "quats"),
2004
- M(m.scales[0], "scales"),
2005
- M(m.sh0[0], "sh0")
2006
- ]), R = { means_l: v, means_u: S, quats: k, scales: B, sh0: j }, b = new ze(u, x, R), A = Se.packSogs(b);
2007
- return b.dispose(), A;
2140
+ const [_, F, O, V, k] = await Promise.all([
2141
+ z(m.means[0], "means_l"),
2142
+ z(m.means[1], "means_u"),
2143
+ z(m.quats[0], "quats"),
2144
+ z(m.scales[0], "scales"),
2145
+ z(m.sh0[0], "sh0")
2146
+ ]), M = { means_l: _, means_u: F, quats: O, scales: V, sh0: k };
2147
+ if (h === 1) {
2148
+ const g = new Ft(y, c, M), v = gt.packSogs(g);
2149
+ return g.dispose(), v;
2150
+ }
2151
+ const B = new Pt(y, c, M), S = gt.packSog2(B);
2152
+ return B.dispose(), S;
2008
2153
  }
2009
2154
  }
2010
- const pt = "0.3.0";
2155
+ const be = "0.3.0";
2011
2156
  export {
2012
- ye as BoundingBox,
2013
- dt as PlyLoader,
2014
- ft as SogsLoader,
2015
- Be as SplatData,
2016
- je as SplatMaterial,
2017
- De as SplatMesh,
2018
- Le as SplatSorter,
2019
- Ge as TextureManager,
2020
- pt as VERSION
2157
+ wt as BoundingBox,
2158
+ ve as PlyLoader,
2159
+ Me as SogsLoader,
2160
+ At as SplatData,
2161
+ Qt as SplatMaterial,
2162
+ Rt as SplatMesh,
2163
+ Yt as SplatSorter,
2164
+ Ht as TextureManager,
2165
+ be as VERSION
2021
2166
  };