@speridlabs/visus 2.1.0 → 2.1.1
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.d.ts +2 -2
- package/dist/main.es.js +255 -251
- package/dist/main.umd.js +5 -5
- package/dist/react.es.js +356 -352
- package/package.json +1 -1
package/dist/react.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var ve = Object.defineProperty;
|
|
2
2
|
var we = (A, e, n) => e in A ? ve(A, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : A[e] = n;
|
|
3
|
-
var
|
|
3
|
+
var h = (A, e, n) => we(A, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import be, { useRef as Se, useMemo as Me, useEffect as _e } from "react";
|
|
5
5
|
import { useLoader as Ae } from "@react-three/fiber";
|
|
6
6
|
import * as l from "three";
|
|
@@ -15,23 +15,23 @@ var ce = { exports: {} }, ae = {};
|
|
|
15
15
|
* LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/
|
|
17
17
|
var pe;
|
|
18
|
-
function
|
|
18
|
+
function Te() {
|
|
19
19
|
if (pe) return ae;
|
|
20
20
|
pe = 1;
|
|
21
21
|
var A = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
22
|
-
function n(t, o
|
|
22
|
+
function n(r, t, o) {
|
|
23
23
|
var a = null;
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
for (var i in
|
|
27
|
-
i !== "key" && (
|
|
28
|
-
} else
|
|
29
|
-
return
|
|
24
|
+
if (o !== void 0 && (a = "" + o), t.key !== void 0 && (a = "" + t.key), "key" in t) {
|
|
25
|
+
o = {};
|
|
26
|
+
for (var i in t)
|
|
27
|
+
i !== "key" && (o[i] = t[i]);
|
|
28
|
+
} else o = t;
|
|
29
|
+
return t = o.ref, {
|
|
30
30
|
$$typeof: A,
|
|
31
|
-
type:
|
|
31
|
+
type: r,
|
|
32
32
|
key: a,
|
|
33
|
-
ref:
|
|
34
|
-
props:
|
|
33
|
+
ref: t !== void 0 ? t : null,
|
|
34
|
+
props: o
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return ae.Fragment = e, ae.jsx = n, ae.jsxs = n, ae;
|
|
@@ -47,12 +47,12 @@ var ie = {};
|
|
|
47
47
|
* LICENSE file in the root directory of this source tree.
|
|
48
48
|
*/
|
|
49
49
|
var me;
|
|
50
|
-
function
|
|
50
|
+
function Ce() {
|
|
51
51
|
return me || (me = 1, process.env.NODE_ENV !== "production" && function() {
|
|
52
52
|
function A(s) {
|
|
53
53
|
if (s == null) return null;
|
|
54
54
|
if (typeof s == "function")
|
|
55
|
-
return s.$$typeof ===
|
|
55
|
+
return s.$$typeof === y ? null : s.displayName || s.name || null;
|
|
56
56
|
if (typeof s == "string") return s;
|
|
57
57
|
switch (s) {
|
|
58
58
|
case I:
|
|
@@ -61,11 +61,11 @@ function Te() {
|
|
|
61
61
|
return "Profiler";
|
|
62
62
|
case z:
|
|
63
63
|
return "StrictMode";
|
|
64
|
-
case
|
|
64
|
+
case W:
|
|
65
65
|
return "Suspense";
|
|
66
66
|
case _:
|
|
67
67
|
return "SuspenseList";
|
|
68
|
-
case
|
|
68
|
+
case T:
|
|
69
69
|
return "Activity";
|
|
70
70
|
}
|
|
71
71
|
if (typeof s == "object")
|
|
@@ -74,7 +74,7 @@ function Te() {
|
|
|
74
74
|
), s.$$typeof) {
|
|
75
75
|
case b:
|
|
76
76
|
return "Portal";
|
|
77
|
-
case
|
|
77
|
+
case L:
|
|
78
78
|
return (s.displayName || "Context") + ".Provider";
|
|
79
79
|
case H:
|
|
80
80
|
return (s._context.displayName || "Context") + ".Consumer";
|
|
@@ -112,7 +112,7 @@ function Te() {
|
|
|
112
112
|
), e(s);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function r(s) {
|
|
116
116
|
if (s === I) return "<>";
|
|
117
117
|
if (typeof s == "object" && s !== null && s.$$typeof === D)
|
|
118
118
|
return "<...>";
|
|
@@ -123,11 +123,11 @@ function Te() {
|
|
|
123
123
|
return "<...>";
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function t() {
|
|
127
127
|
var s = R.A;
|
|
128
128
|
return s === null ? null : s.getOwner();
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function o() {
|
|
131
131
|
return Error("react-stack-top-frame");
|
|
132
132
|
}
|
|
133
133
|
function a(s) {
|
|
@@ -155,7 +155,7 @@ function Te() {
|
|
|
155
155
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
156
156
|
)), s = this.props.ref, s !== void 0 ? s : null;
|
|
157
157
|
}
|
|
158
|
-
function v(s, p, S, E, m, c,
|
|
158
|
+
function v(s, p, S, E, m, c, g, P) {
|
|
159
159
|
return S = c.ref, s = {
|
|
160
160
|
$$typeof: w,
|
|
161
161
|
type: s,
|
|
@@ -179,7 +179,7 @@ function Te() {
|
|
|
179
179
|
configurable: !1,
|
|
180
180
|
enumerable: !1,
|
|
181
181
|
writable: !0,
|
|
182
|
-
value:
|
|
182
|
+
value: g
|
|
183
183
|
}), Object.defineProperty(s, "_debugTask", {
|
|
184
184
|
configurable: !1,
|
|
185
185
|
enumerable: !1,
|
|
@@ -187,25 +187,25 @@ function Te() {
|
|
|
187
187
|
value: P
|
|
188
188
|
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
|
|
189
189
|
}
|
|
190
|
-
function M(s, p, S, E, m, c,
|
|
191
|
-
var
|
|
192
|
-
if (
|
|
190
|
+
function M(s, p, S, E, m, c, g, P) {
|
|
191
|
+
var f = p.children;
|
|
192
|
+
if (f !== void 0)
|
|
193
193
|
if (E)
|
|
194
|
-
if (X(
|
|
195
|
-
for (E = 0; E <
|
|
196
|
-
|
|
197
|
-
Object.freeze && Object.freeze(
|
|
194
|
+
if (X(f)) {
|
|
195
|
+
for (E = 0; E < f.length; E++)
|
|
196
|
+
C(f[E]);
|
|
197
|
+
Object.freeze && Object.freeze(f);
|
|
198
198
|
} else
|
|
199
199
|
console.error(
|
|
200
200
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
201
201
|
);
|
|
202
|
-
else
|
|
202
|
+
else C(f);
|
|
203
203
|
if (B.call(p, "key")) {
|
|
204
|
-
|
|
204
|
+
f = A(s);
|
|
205
205
|
var k = Object.keys(p).filter(function(V) {
|
|
206
206
|
return V !== "key";
|
|
207
207
|
});
|
|
208
|
-
E = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", te[
|
|
208
|
+
E = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", te[f + E] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
209
209
|
`A props object containing a "key" prop is being spread into JSX:
|
|
210
210
|
let props = %s;
|
|
211
211
|
<%s {...props} />
|
|
@@ -213,45 +213,45 @@ React keys must be passed directly to JSX without using spread:
|
|
|
213
213
|
let props = %s;
|
|
214
214
|
<%s key={someKey} {...props} />`,
|
|
215
215
|
E,
|
|
216
|
-
|
|
216
|
+
f,
|
|
217
217
|
k,
|
|
218
|
-
|
|
219
|
-
), te[
|
|
218
|
+
f
|
|
219
|
+
), te[f + E] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
221
|
+
if (f = null, S !== void 0 && (n(S), f = "" + S), a(p) && (n(p.key), f = "" + p.key), "key" in p) {
|
|
222
222
|
S = {};
|
|
223
223
|
for (var O in p)
|
|
224
224
|
O !== "key" && (S[O] = p[O]);
|
|
225
225
|
} else S = p;
|
|
226
|
-
return
|
|
226
|
+
return f && i(
|
|
227
227
|
S,
|
|
228
228
|
typeof s == "function" ? s.displayName || s.name || "Unknown" : s
|
|
229
229
|
), v(
|
|
230
230
|
s,
|
|
231
|
-
|
|
231
|
+
f,
|
|
232
232
|
c,
|
|
233
233
|
m,
|
|
234
|
-
|
|
234
|
+
t(),
|
|
235
235
|
S,
|
|
236
|
-
|
|
236
|
+
g,
|
|
237
237
|
P
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function C(s) {
|
|
241
241
|
typeof s == "object" && s !== null && s.$$typeof === w && s._store && (s._store.validated = 1);
|
|
242
242
|
}
|
|
243
|
-
var
|
|
243
|
+
var d = be, w = Symbol.for("react.transitional.element"), b = Symbol.for("react.portal"), I = Symbol.for("react.fragment"), z = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), H = Symbol.for("react.consumer"), L = Symbol.for("react.context"), ne = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), _ = Symbol.for("react.suspense_list"), x = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), T = Symbol.for("react.activity"), y = Symbol.for("react.client.reference"), R = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, X = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
244
244
|
return null;
|
|
245
245
|
};
|
|
246
|
-
|
|
246
|
+
d = {
|
|
247
247
|
"react-stack-bottom-frame": function(s) {
|
|
248
248
|
return s();
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
var Z, U = {}, F =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
)(), N = $(
|
|
251
|
+
var Z, U = {}, F = d["react-stack-bottom-frame"].bind(
|
|
252
|
+
d,
|
|
253
|
+
o
|
|
254
|
+
)(), N = $(r(o)), te = {};
|
|
255
255
|
ie.Fragment = I, ie.jsx = function(s, p, S, E, m) {
|
|
256
256
|
var c = 1e4 > R.recentlyCreatedOwnerStacks++;
|
|
257
257
|
return M(
|
|
@@ -262,7 +262,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
262
262
|
E,
|
|
263
263
|
m,
|
|
264
264
|
c ? Error("react-stack-top-frame") : F,
|
|
265
|
-
c ? $(
|
|
265
|
+
c ? $(r(s)) : N
|
|
266
266
|
);
|
|
267
267
|
}, ie.jsxs = function(s, p, S, E, m) {
|
|
268
268
|
var c = 1e4 > R.recentlyCreatedOwnerStacks++;
|
|
@@ -274,23 +274,23 @@ React keys must be passed directly to JSX without using spread:
|
|
|
274
274
|
E,
|
|
275
275
|
m,
|
|
276
276
|
c ? Error("react-stack-top-frame") : F,
|
|
277
|
-
c ? $(
|
|
277
|
+
c ? $(r(s)) : N
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
280
|
}()), ie;
|
|
281
281
|
}
|
|
282
282
|
var xe;
|
|
283
283
|
function ke() {
|
|
284
|
-
return xe || (xe = 1, process.env.NODE_ENV === "production" ? ce.exports =
|
|
284
|
+
return xe || (xe = 1, process.env.NODE_ENV === "production" ? ce.exports = Te() : ce.exports = Ce()), ce.exports;
|
|
285
285
|
}
|
|
286
286
|
var Ee = ke();
|
|
287
|
-
class
|
|
287
|
+
class fe {
|
|
288
288
|
constructor() {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
h(this, "min", new l.Vector3(1 / 0, 1 / 0, 1 / 0));
|
|
290
|
+
h(this, "max", new l.Vector3(-1 / 0, -1 / 0, -1 / 0));
|
|
291
|
+
h(this, "center", new l.Vector3());
|
|
292
292
|
/** Half extents (size/2) */
|
|
293
|
-
|
|
293
|
+
h(this, "halfExtents", new l.Vector3());
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Reset the bounding box to its initial state
|
|
@@ -338,20 +338,20 @@ class he {
|
|
|
338
338
|
* @returns New bounding box with the same values
|
|
339
339
|
*/
|
|
340
340
|
clone() {
|
|
341
|
-
const e = new
|
|
341
|
+
const e = new fe();
|
|
342
342
|
return e.min.copy(this.min), e.max.copy(this.max), e.center.copy(this.center), e.halfExtents.copy(this.halfExtents), e;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
class Ie {
|
|
346
346
|
// TODO: there is no sh spherical harmonics
|
|
347
347
|
constructor(e = 0) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
348
|
+
h(this, "numSplats", 0);
|
|
349
|
+
h(this, "positions");
|
|
350
|
+
h(this, "rotations");
|
|
351
|
+
h(this, "scales");
|
|
352
|
+
h(this, "colors");
|
|
353
|
+
h(this, "opacities");
|
|
354
|
+
h(this, "boundingBox", new fe());
|
|
355
355
|
this.numSplats = e, this.allocateBuffers(e);
|
|
356
356
|
}
|
|
357
357
|
allocateBuffers(e) {
|
|
@@ -366,13 +366,13 @@ class Ie {
|
|
|
366
366
|
* @param color Color
|
|
367
367
|
* @param opacity Opacity value
|
|
368
368
|
*/
|
|
369
|
-
setSplat(e, n, t, o,
|
|
369
|
+
setSplat(e, n, r, t, o, a) {
|
|
370
370
|
if (e >= this.numSplats)
|
|
371
371
|
throw new Error(
|
|
372
372
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
373
373
|
);
|
|
374
374
|
const i = e * 3, u = e * 4, v = e * 3, M = e * 3;
|
|
375
|
-
this.positions[i] = n.x, this.positions[i + 1] = n.y, this.positions[i + 2] = n.z, this.rotations[u] =
|
|
375
|
+
this.positions[i] = n.x, this.positions[i + 1] = n.y, this.positions[i + 2] = n.z, this.rotations[u] = r.x, this.rotations[u + 1] = r.y, this.rotations[u + 2] = r.z, this.rotations[u + 3] = r.w, this.scales[v] = t.x, this.scales[v + 1] = t.y, this.scales[v + 2] = t.z, this.colors[M] = o.r, this.colors[M + 1] = o.g, this.colors[M + 2] = o.b, this.opacities[e] = a;
|
|
376
376
|
}
|
|
377
377
|
/**
|
|
378
378
|
* Get a splat's data
|
|
@@ -384,7 +384,7 @@ class Ie {
|
|
|
384
384
|
throw new Error(
|
|
385
385
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
386
386
|
);
|
|
387
|
-
const n = e * 3,
|
|
387
|
+
const n = e * 3, r = e * 4, t = e * 3, o = e * 3;
|
|
388
388
|
return {
|
|
389
389
|
position: new l.Vector3(
|
|
390
390
|
this.positions[n],
|
|
@@ -392,21 +392,21 @@ class Ie {
|
|
|
392
392
|
this.positions[n + 2]
|
|
393
393
|
),
|
|
394
394
|
rotation: new l.Quaternion(
|
|
395
|
-
this.rotations[
|
|
396
|
-
this.rotations[
|
|
397
|
-
this.rotations[
|
|
398
|
-
this.rotations[
|
|
395
|
+
this.rotations[r],
|
|
396
|
+
this.rotations[r + 1],
|
|
397
|
+
this.rotations[r + 2],
|
|
398
|
+
this.rotations[r + 3]
|
|
399
399
|
),
|
|
400
400
|
// Convert log scale back to linear scale for external use
|
|
401
401
|
scale: new l.Vector3(
|
|
402
|
-
Math.exp(this.scales[
|
|
403
|
-
Math.exp(this.scales[
|
|
404
|
-
Math.exp(this.scales[
|
|
402
|
+
Math.exp(this.scales[t]),
|
|
403
|
+
Math.exp(this.scales[t + 1]),
|
|
404
|
+
Math.exp(this.scales[t + 2])
|
|
405
405
|
),
|
|
406
406
|
color: new l.Color(
|
|
407
|
-
this.colors[
|
|
408
|
-
this.colors[
|
|
409
|
-
this.colors[
|
|
407
|
+
this.colors[o],
|
|
408
|
+
this.colors[o + 1],
|
|
409
|
+
this.colors[o + 2]
|
|
410
410
|
),
|
|
411
411
|
opacity: this.opacities[e]
|
|
412
412
|
};
|
|
@@ -419,11 +419,11 @@ class Ie {
|
|
|
419
419
|
this.boundingBox.reset();
|
|
420
420
|
const e = new l.Vector3();
|
|
421
421
|
for (let n = 0; n < this.numSplats; n++) {
|
|
422
|
-
const
|
|
422
|
+
const r = n * 3;
|
|
423
423
|
e.set(
|
|
424
|
-
this.positions[
|
|
425
|
-
this.positions[
|
|
426
|
-
this.positions[
|
|
424
|
+
this.positions[r],
|
|
425
|
+
this.positions[r + 1],
|
|
426
|
+
this.positions[r + 2]
|
|
427
427
|
), this.boundingBox.expandByPoint(e);
|
|
428
428
|
}
|
|
429
429
|
return this.boundingBox;
|
|
@@ -438,15 +438,15 @@ class Ie {
|
|
|
438
438
|
"position",
|
|
439
439
|
new l.BufferAttribute(this.positions, 3)
|
|
440
440
|
);
|
|
441
|
-
const n = new Float32Array(this.numSplats * 3),
|
|
442
|
-
for (let
|
|
443
|
-
const a =
|
|
444
|
-
|
|
441
|
+
const n = new Float32Array(this.numSplats * 3), r = new l.Quaternion(), t = new l.Euler();
|
|
442
|
+
for (let o = 0; o < this.numSplats; o++) {
|
|
443
|
+
const a = o * 4, i = o * 3;
|
|
444
|
+
r.set(
|
|
445
445
|
this.rotations[a],
|
|
446
446
|
this.rotations[a + 1],
|
|
447
447
|
this.rotations[a + 2],
|
|
448
448
|
this.rotations[a + 3]
|
|
449
|
-
),
|
|
449
|
+
), t.setFromQuaternion(r), n[i] = t.x, n[i + 1] = t.y, n[i + 2] = t.z;
|
|
450
450
|
}
|
|
451
451
|
return e.setAttribute(
|
|
452
452
|
"rotation",
|
|
@@ -466,32 +466,32 @@ class Ie {
|
|
|
466
466
|
class Re extends l.Loader {
|
|
467
467
|
constructor(n) {
|
|
468
468
|
super(n);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
const
|
|
473
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
469
|
+
h(this, "requestId", 0);
|
|
470
|
+
h(this, "worker");
|
|
471
|
+
h(this, "pendingCallbacks", /* @__PURE__ */ new Map());
|
|
472
|
+
const r = this.createWorkerCode(), t = new Blob([r], { type: "application/javascript" });
|
|
473
|
+
this.worker = new Worker(URL.createObjectURL(t)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
474
474
|
}
|
|
475
475
|
/**
|
|
476
476
|
* Handles messages received from the parsing worker
|
|
477
477
|
* @param event The message event from the worker
|
|
478
478
|
*/
|
|
479
479
|
onWorkerMessage(n) {
|
|
480
|
-
const { requestId:
|
|
481
|
-
if (!a) return console.warn(`PlyLoader: Received response for unknown request ${
|
|
482
|
-
if (this.pendingCallbacks.delete(
|
|
483
|
-
if (!
|
|
480
|
+
const { requestId: r, error: t, result: o } = n.data, a = this.pendingCallbacks.get(r);
|
|
481
|
+
if (!a) return console.warn(`PlyLoader: Received response for unknown request ${r}`);
|
|
482
|
+
if (this.pendingCallbacks.delete(r), t) return a.reject(new Error(t));
|
|
483
|
+
if (!o) return a.reject(new Error("Worker returned no result"));
|
|
484
484
|
try {
|
|
485
485
|
const i = new Ie(0);
|
|
486
|
-
i.numSplats =
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
i.numSplats = o.numSplats, i.positions = new Float32Array(o.positions), i.rotations = new Float32Array(o.rotations), i.scales = new Float32Array(o.scales), i.colors = new Float32Array(o.colors), i.opacities = new Float32Array(o.opacities), i.boundingBox.min.set(
|
|
487
|
+
o.boundingBox.minX,
|
|
488
|
+
o.boundingBox.minY,
|
|
489
|
+
o.boundingBox.minZ
|
|
490
490
|
), i.boundingBox.max.set(
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
), a.resolve(i);
|
|
491
|
+
o.boundingBox.maxX,
|
|
492
|
+
o.boundingBox.maxY,
|
|
493
|
+
o.boundingBox.maxZ
|
|
494
|
+
), this.worker.terminate(), a.resolve(i);
|
|
495
495
|
} catch (i) {
|
|
496
496
|
a.reject(i);
|
|
497
497
|
}
|
|
@@ -503,19 +503,19 @@ class Re extends l.Loader {
|
|
|
503
503
|
* @param onProgress Optional progress callback
|
|
504
504
|
* @param onError Optional error callback
|
|
505
505
|
*/
|
|
506
|
-
load(n, t, o
|
|
506
|
+
load(n, r, t, o) {
|
|
507
507
|
const a = new l.FileLoader(this.manager);
|
|
508
508
|
a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
|
|
509
509
|
n,
|
|
510
510
|
(i) => {
|
|
511
511
|
this.parseAsync(i).then((u) => {
|
|
512
|
-
|
|
512
|
+
r && r(u);
|
|
513
513
|
}).catch((u) => {
|
|
514
|
-
|
|
514
|
+
o ? o(u) : console.error(u), this.manager.itemError(n);
|
|
515
515
|
});
|
|
516
516
|
},
|
|
517
|
-
|
|
518
|
-
|
|
517
|
+
t,
|
|
518
|
+
o
|
|
519
519
|
);
|
|
520
520
|
}
|
|
521
521
|
/**
|
|
@@ -524,19 +524,19 @@ class Re extends l.Loader {
|
|
|
524
524
|
* @param onProgress Optional progress callback
|
|
525
525
|
* @returns A Promise that resolves with the parsed SplatData
|
|
526
526
|
*/
|
|
527
|
-
loadAsync(n,
|
|
528
|
-
return new Promise((
|
|
527
|
+
loadAsync(n, r) {
|
|
528
|
+
return new Promise((t, o) => {
|
|
529
529
|
const a = new l.FileLoader(this.manager);
|
|
530
530
|
a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
|
|
531
531
|
n,
|
|
532
532
|
(i) => {
|
|
533
|
-
this.parseAsync(i).then(
|
|
534
|
-
|
|
533
|
+
this.parseAsync(i).then(t).catch((u) => {
|
|
534
|
+
o(u), this.manager.itemError(n);
|
|
535
535
|
});
|
|
536
536
|
},
|
|
537
|
-
|
|
537
|
+
r,
|
|
538
538
|
(i) => {
|
|
539
|
-
|
|
539
|
+
o(i), this.manager.itemError(n);
|
|
540
540
|
}
|
|
541
541
|
);
|
|
542
542
|
});
|
|
@@ -547,11 +547,11 @@ class Re extends l.Loader {
|
|
|
547
547
|
* @returns Promise that resolves with parsed SplatData
|
|
548
548
|
*/
|
|
549
549
|
parseAsync(n) {
|
|
550
|
-
return new Promise((
|
|
551
|
-
const
|
|
552
|
-
this.pendingCallbacks.set(
|
|
550
|
+
return new Promise((r, t) => {
|
|
551
|
+
const o = this.requestId++;
|
|
552
|
+
this.pendingCallbacks.set(o, { resolve: r, reject: t });
|
|
553
553
|
const a = {
|
|
554
|
-
requestId:
|
|
554
|
+
requestId: o,
|
|
555
555
|
buffer: n
|
|
556
556
|
};
|
|
557
557
|
this.worker.postMessage(a, [n]);
|
|
@@ -569,11 +569,11 @@ class Re extends l.Loader {
|
|
|
569
569
|
*/
|
|
570
570
|
createWorkerCode() {
|
|
571
571
|
return `(${(function() {
|
|
572
|
-
self.onmessage = (
|
|
573
|
-
const { requestId:
|
|
572
|
+
self.onmessage = (t) => {
|
|
573
|
+
const { requestId: o, buffer: a } = t.data;
|
|
574
574
|
try {
|
|
575
|
-
const i =
|
|
576
|
-
requestId:
|
|
575
|
+
const i = r(a), u = {
|
|
576
|
+
requestId: o,
|
|
577
577
|
result: i
|
|
578
578
|
};
|
|
579
579
|
self.postMessage(u, [
|
|
@@ -585,14 +585,14 @@ class Re extends l.Loader {
|
|
|
585
585
|
]);
|
|
586
586
|
} catch (i) {
|
|
587
587
|
const u = {
|
|
588
|
-
requestId:
|
|
588
|
+
requestId: o,
|
|
589
589
|
error: i instanceof Error ? i.message : String(i)
|
|
590
590
|
};
|
|
591
591
|
self.postMessage(u);
|
|
592
592
|
}
|
|
593
593
|
};
|
|
594
|
-
function t
|
|
595
|
-
const
|
|
594
|
+
function r(t) {
|
|
595
|
+
const o = new TextDecoder(), a = new Uint8Array(t), i = [112, 108, 121, 10], u = `
|
|
596
596
|
end_header
|
|
597
597
|
`;
|
|
598
598
|
for (let m = 0; m < i.length; m++)
|
|
@@ -603,8 +603,8 @@ end_header
|
|
|
603
603
|
let v = 0;
|
|
604
604
|
for (let m = 0; m < a.length - u.length; m++) {
|
|
605
605
|
let c = !0;
|
|
606
|
-
for (let
|
|
607
|
-
if (a[m +
|
|
606
|
+
for (let g = 0; g < u.length; g++)
|
|
607
|
+
if (a[m + g] !== u.charCodeAt(g)) {
|
|
608
608
|
c = !1;
|
|
609
609
|
break;
|
|
610
610
|
}
|
|
@@ -617,50 +617,50 @@ end_header
|
|
|
617
617
|
throw new Error(
|
|
618
618
|
"Invalid PLY file: Could not find end of header"
|
|
619
619
|
);
|
|
620
|
-
const
|
|
620
|
+
const C = o.decode(
|
|
621
621
|
a.subarray(0, v)
|
|
622
622
|
).split(`
|
|
623
|
-
`),
|
|
623
|
+
`), d = [];
|
|
624
624
|
let w = null;
|
|
625
|
-
for (let m = 1; m <
|
|
626
|
-
const c =
|
|
625
|
+
for (let m = 1; m < C.length; m++) {
|
|
626
|
+
const c = C[m].trim();
|
|
627
627
|
if (c === "" || c === "end_header") continue;
|
|
628
|
-
const
|
|
629
|
-
switch (
|
|
628
|
+
const g = c.split(" ");
|
|
629
|
+
switch (g[0]) {
|
|
630
630
|
case "format":
|
|
631
|
-
w =
|
|
631
|
+
w = g[1];
|
|
632
632
|
break;
|
|
633
633
|
case "element":
|
|
634
|
-
|
|
635
|
-
name:
|
|
636
|
-
count: parseInt(
|
|
634
|
+
d.push({
|
|
635
|
+
name: g[1],
|
|
636
|
+
count: parseInt(g[2], 10),
|
|
637
637
|
properties: []
|
|
638
638
|
});
|
|
639
639
|
break;
|
|
640
640
|
case "property":
|
|
641
|
-
if (
|
|
641
|
+
if (d.length === 0)
|
|
642
642
|
throw new Error(
|
|
643
643
|
"Invalid PLY file: Property without element"
|
|
644
644
|
);
|
|
645
|
-
|
|
646
|
-
type:
|
|
647
|
-
name:
|
|
645
|
+
d[d.length - 1].properties.push({
|
|
646
|
+
type: g[1],
|
|
647
|
+
name: g[2]
|
|
648
648
|
});
|
|
649
649
|
break;
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
if (w !== "binary_little_endian")
|
|
653
653
|
throw new Error(`Unsupported PLY format: ${w}`);
|
|
654
|
-
const b =
|
|
654
|
+
const b = d.find((m) => m.name === "vertex");
|
|
655
655
|
if (!b)
|
|
656
656
|
throw new Error(
|
|
657
657
|
"Invalid PLY file: No vertex element found"
|
|
658
658
|
);
|
|
659
|
-
const I = b.count, z = new Float32Array(I * 3), j = new Float32Array(I * 4), H = new Float32Array(I * 3),
|
|
659
|
+
const I = b.count, z = new Float32Array(I * 3), j = new Float32Array(I * 4), H = new Float32Array(I * 3), L = new Float32Array(I * 3), ne = new Float32Array(I), W = new DataView(t);
|
|
660
660
|
let _ = v;
|
|
661
661
|
const x = (m) => b.properties.findIndex(
|
|
662
662
|
(c) => c.name === m
|
|
663
|
-
), D = x("x"),
|
|
663
|
+
), D = x("x"), T = x("y"), y = x("z"), R = [
|
|
664
664
|
x("rot_0"),
|
|
665
665
|
x("rot_1"),
|
|
666
666
|
x("rot_2"),
|
|
@@ -676,8 +676,8 @@ end_header
|
|
|
676
676
|
], $ = x("opacity");
|
|
677
677
|
if ([
|
|
678
678
|
D,
|
|
679
|
-
|
|
680
|
-
|
|
679
|
+
T,
|
|
680
|
+
y,
|
|
681
681
|
...R,
|
|
682
682
|
...B,
|
|
683
683
|
...X,
|
|
@@ -694,43 +694,43 @@ end_header
|
|
|
694
694
|
let N = 1 / 0, te = 1 / 0, s = 1 / 0, p = -1 / 0, S = -1 / 0, E = -1 / 0;
|
|
695
695
|
for (let m = 0; m < I; m++) {
|
|
696
696
|
const c = [];
|
|
697
|
-
for (let
|
|
698
|
-
const
|
|
697
|
+
for (let de = 0; de < b.properties.length; de++) {
|
|
698
|
+
const he = b.properties[de].type;
|
|
699
699
|
let ee;
|
|
700
|
-
switch (
|
|
700
|
+
switch (he) {
|
|
701
701
|
case "char":
|
|
702
|
-
ee =
|
|
702
|
+
ee = W.getInt8(_), _ += 1;
|
|
703
703
|
break;
|
|
704
704
|
case "uchar":
|
|
705
|
-
ee =
|
|
705
|
+
ee = W.getUint8(_), _ += 1;
|
|
706
706
|
break;
|
|
707
707
|
case "short":
|
|
708
|
-
ee =
|
|
708
|
+
ee = W.getInt16(_, !0), _ += 2;
|
|
709
709
|
break;
|
|
710
710
|
case "ushort":
|
|
711
|
-
ee =
|
|
711
|
+
ee = W.getUint16(_, !0), _ += 2;
|
|
712
712
|
break;
|
|
713
713
|
case "int":
|
|
714
|
-
ee =
|
|
714
|
+
ee = W.getInt32(_, !0), _ += 4;
|
|
715
715
|
break;
|
|
716
716
|
case "uint":
|
|
717
|
-
ee =
|
|
717
|
+
ee = W.getUint32(_, !0), _ += 4;
|
|
718
718
|
break;
|
|
719
719
|
case "float":
|
|
720
|
-
ee =
|
|
720
|
+
ee = W.getFloat32(_, !0), _ += 4;
|
|
721
721
|
break;
|
|
722
722
|
case "double":
|
|
723
|
-
ee =
|
|
723
|
+
ee = W.getFloat64(_, !0), _ += 8;
|
|
724
724
|
break;
|
|
725
725
|
default:
|
|
726
726
|
throw new Error(
|
|
727
|
-
`Unsupported property type: ${
|
|
727
|
+
`Unsupported property type: ${he}`
|
|
728
728
|
);
|
|
729
729
|
}
|
|
730
730
|
c.push(ee);
|
|
731
731
|
}
|
|
732
|
-
const
|
|
733
|
-
z[k] =
|
|
732
|
+
const g = c[D], P = c[T], f = c[y], k = m * 3;
|
|
733
|
+
z[k] = g, z[k + 1] = P, z[k + 2] = f, N = Math.min(N, g), te = Math.min(te, P), s = Math.min(s, f), p = Math.max(p, g), S = Math.max(S, P), E = Math.max(E, f);
|
|
734
734
|
let O = c[R[1]], V = c[R[2]], G = c[R[3]], q = c[R[0]];
|
|
735
735
|
const Y = Math.sqrt(
|
|
736
736
|
O * O + V * V + G * G + q * q
|
|
@@ -743,14 +743,14 @@ end_header
|
|
|
743
743
|
let re = 0.5 + c[X[0]] * U, oe = 0.5 + c[X[1]] * U, J = 0.5 + c[X[2]] * U;
|
|
744
744
|
re = Math.max(0, Math.min(1, re)), oe = Math.max(0, Math.min(1, oe)), J = Math.max(0, Math.min(1, J));
|
|
745
745
|
const ue = m * 3;
|
|
746
|
-
|
|
746
|
+
L[ue] = re, L[ue + 1] = oe, L[ue + 2] = J, ne[m] = F(c[$]);
|
|
747
747
|
}
|
|
748
748
|
return {
|
|
749
749
|
numSplats: I,
|
|
750
750
|
positions: z.buffer,
|
|
751
751
|
rotations: j.buffer,
|
|
752
752
|
scales: H.buffer,
|
|
753
|
-
colors:
|
|
753
|
+
colors: L.buffer,
|
|
754
754
|
opacities: ne.buffer,
|
|
755
755
|
boundingBox: {
|
|
756
756
|
minX: N,
|
|
@@ -768,15 +768,15 @@ end_header
|
|
|
768
768
|
class Pe extends l.EventDispatcher {
|
|
769
769
|
constructor() {
|
|
770
770
|
super();
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
771
|
+
h(this, "worker");
|
|
772
|
+
h(this, "centers", null);
|
|
773
|
+
h(this, "orderTexture", null);
|
|
774
774
|
/** Bounding box data for optimization */
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
const n = this.createWorkerCode(),
|
|
779
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
775
|
+
h(this, "chunks", null);
|
|
776
|
+
h(this, "lastCameraPosition", new l.Vector3());
|
|
777
|
+
h(this, "lastCameraDirection", new l.Vector3());
|
|
778
|
+
const n = this.createWorkerCode(), r = new Blob([n], { type: "application/javascript" });
|
|
779
|
+
this.worker = new Worker(URL.createObjectURL(r)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
780
780
|
}
|
|
781
781
|
/**
|
|
782
782
|
* Handles messages received from the sorting worker.
|
|
@@ -785,14 +785,14 @@ class Pe extends l.EventDispatcher {
|
|
|
785
785
|
onWorkerMessage(n) {
|
|
786
786
|
if (!this.orderTexture || !this.orderTexture.image)
|
|
787
787
|
return console.error("SplatSorter: Order texture not initialized!");
|
|
788
|
-
const { order:
|
|
789
|
-
if (!(
|
|
788
|
+
const { order: r, count: t } = n.data, o = this.orderTexture.image.data;
|
|
789
|
+
if (!(o instanceof Uint32Array))
|
|
790
790
|
return console.error(
|
|
791
791
|
"SplatSorter: Order texture data is not a Uint32Array!"
|
|
792
792
|
);
|
|
793
|
-
|
|
794
|
-
const a =
|
|
795
|
-
this.worker.postMessage(i, [a]), this.dispatchEvent({ type: "updated", count:
|
|
793
|
+
o.set(new Uint32Array(r)), this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
|
|
794
|
+
const a = o.buffer.slice(0), i = { order: a };
|
|
795
|
+
this.worker.postMessage(i, [a]), this.dispatchEvent({ type: "updated", count: t });
|
|
796
796
|
}
|
|
797
797
|
/**
|
|
798
798
|
* Initializes the sorter with necessary data and textures.
|
|
@@ -801,31 +801,35 @@ class Pe extends l.EventDispatcher {
|
|
|
801
801
|
* @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
|
|
802
802
|
* @param transferOwnership Optional: If true, transfers ownership of centers buffer to worker (saves memory, main thread loses access). Default: false.
|
|
803
803
|
*/
|
|
804
|
-
init(n, t, o
|
|
804
|
+
init(n, r, t, o = !1) {
|
|
805
805
|
if (!n || !(n.image.data instanceof Uint32Array))
|
|
806
806
|
throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
|
|
807
|
-
if (!
|
|
807
|
+
if (!r || r.length % 3 !== 0)
|
|
808
808
|
throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
|
|
809
|
-
if (n.image.data.length <
|
|
809
|
+
if (n.image.data.length < r.length / 3)
|
|
810
810
|
throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
|
|
811
|
-
|
|
812
|
-
|
|
811
|
+
if (r.buffer.byteLength === 0)
|
|
812
|
+
throw new Error(
|
|
813
|
+
"SplatSorter: positions buffer is detached (likely React StrictMode + cached asset). "
|
|
814
|
+
);
|
|
815
|
+
const a = r.length / 3;
|
|
816
|
+
this.orderTexture = n, o ? this.centers = null : this.centers = r.slice();
|
|
813
817
|
const i = this.orderTexture.image.data;
|
|
814
|
-
for (let
|
|
815
|
-
this.orderTexture.needsUpdate = !0;
|
|
816
|
-
const u = i.buffer.slice(0), v =
|
|
818
|
+
for (let d = 0; d < a; d++) i[d] = d;
|
|
819
|
+
this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
|
|
820
|
+
const u = i.buffer.slice(0), v = o ? r.buffer : r.buffer.slice(0), M = {
|
|
817
821
|
order: u,
|
|
818
822
|
centers: v
|
|
819
|
-
},
|
|
823
|
+
}, C = [
|
|
820
824
|
u,
|
|
821
825
|
v
|
|
822
826
|
];
|
|
823
|
-
if (
|
|
824
|
-
this.chunks =
|
|
825
|
-
const
|
|
826
|
-
M.chunks =
|
|
827
|
+
if (t) {
|
|
828
|
+
this.chunks = t.slice();
|
|
829
|
+
const d = this.chunks.buffer.slice(0);
|
|
830
|
+
M.chunks = d, C.push(d);
|
|
827
831
|
}
|
|
828
|
-
this.worker.postMessage(M,
|
|
832
|
+
this.worker.postMessage(M, C), queueMicrotask(() => {
|
|
829
833
|
this.dispatchEvent({
|
|
830
834
|
type: "updated",
|
|
831
835
|
count: a
|
|
@@ -842,16 +846,16 @@ class Pe extends l.EventDispatcher {
|
|
|
842
846
|
return console.warn(
|
|
843
847
|
"SplatSorter: Cannot set mapping before initialization."
|
|
844
848
|
);
|
|
845
|
-
let
|
|
846
|
-
const
|
|
849
|
+
let r;
|
|
850
|
+
const t = [];
|
|
847
851
|
if (!n) {
|
|
848
852
|
const u = this.centers.buffer.slice(0);
|
|
849
|
-
return
|
|
853
|
+
return r = {
|
|
850
854
|
centers: u,
|
|
851
855
|
mapping: null
|
|
852
|
-
},
|
|
856
|
+
}, t.push(u), this.worker.postMessage(r, t);
|
|
853
857
|
}
|
|
854
|
-
const
|
|
858
|
+
const o = new Float32Array(n.length * 3);
|
|
855
859
|
for (let u = 0; u < n.length; u++) {
|
|
856
860
|
const v = n[u];
|
|
857
861
|
if (v * 3 + 2 >= this.centers.length) {
|
|
@@ -860,28 +864,28 @@ class Pe extends l.EventDispatcher {
|
|
|
860
864
|
);
|
|
861
865
|
continue;
|
|
862
866
|
}
|
|
863
|
-
const M = v * 3,
|
|
864
|
-
|
|
867
|
+
const M = v * 3, C = u * 3;
|
|
868
|
+
o[C + 0] = this.centers[M + 0], o[C + 1] = this.centers[M + 1], o[C + 2] = this.centers[M + 2];
|
|
865
869
|
}
|
|
866
|
-
const a =
|
|
867
|
-
|
|
870
|
+
const a = o.buffer.slice(0), i = n.buffer.slice(0);
|
|
871
|
+
r = {
|
|
868
872
|
centers: a,
|
|
869
873
|
mapping: i
|
|
870
|
-
},
|
|
874
|
+
}, t.push(a, i), this.worker.postMessage(r, t);
|
|
871
875
|
}
|
|
872
876
|
/**
|
|
873
877
|
* Updates the camera parameters used for sorting.
|
|
874
878
|
* @param position The camera's position in the sorter's local coordinate space.
|
|
875
879
|
* @param direction The camera's forward direction in the sorter's local coordinate space.
|
|
876
880
|
*/
|
|
877
|
-
setCamera(n,
|
|
878
|
-
const
|
|
879
|
-
if (!
|
|
881
|
+
setCamera(n, r) {
|
|
882
|
+
const t = this.lastCameraPosition.distanceToSquared(n) > 1e-7, o = this.lastCameraDirection.dot(r) < 0.9999;
|
|
883
|
+
if (!t && !o)
|
|
880
884
|
return;
|
|
881
|
-
this.lastCameraPosition.copy(n), this.lastCameraDirection.copy(
|
|
885
|
+
this.lastCameraPosition.copy(n), this.lastCameraDirection.copy(r);
|
|
882
886
|
const a = {
|
|
883
887
|
cameraPosition: { x: n.x, y: n.y, z: n.z },
|
|
884
|
-
cameraDirection: { x:
|
|
888
|
+
cameraDirection: { x: r.x, y: r.y, z: r.z }
|
|
885
889
|
};
|
|
886
890
|
this.worker.postMessage(a);
|
|
887
891
|
}
|
|
@@ -897,49 +901,49 @@ class Pe extends l.EventDispatcher {
|
|
|
897
901
|
*/
|
|
898
902
|
createWorkerCode() {
|
|
899
903
|
return `(${(function() {
|
|
900
|
-
let
|
|
901
|
-
const M = { x: 0, y: 0, z: 0 },
|
|
904
|
+
let r = null, t = null, o = null, a = null, i = null, u = null, v = !1;
|
|
905
|
+
const M = { x: 0, y: 0, z: 0 }, C = { x: 0, y: 0, z: 0 }, d = { x: 0, y: 0, z: 0 }, w = { x: 0, y: 0, z: 0 };
|
|
902
906
|
let b = null, I = null;
|
|
903
|
-
const z = 32, j = new Array(z).fill(0), H = new Array(z).fill(0),
|
|
907
|
+
const z = 32, j = new Array(z).fill(0), H = new Array(z).fill(0), L = new Array(z).fill(0), ne = (_, x, D) => {
|
|
904
908
|
for (; _ <= x; ) {
|
|
905
|
-
const
|
|
906
|
-
if (
|
|
907
|
-
else if (
|
|
908
|
-
else return
|
|
909
|
+
const T = x + _ >> 1, y = D(T);
|
|
910
|
+
if (y > 0) _ = T + 1;
|
|
911
|
+
else if (y < 0) x = T - 1;
|
|
912
|
+
else return T;
|
|
909
913
|
}
|
|
910
914
|
return ~_;
|
|
911
|
-
},
|
|
912
|
-
if (!
|
|
915
|
+
}, W = () => {
|
|
916
|
+
if (!r || !t || !i || !u)
|
|
913
917
|
return;
|
|
914
|
-
if (
|
|
918
|
+
if (t.length === 0) {
|
|
915
919
|
const c = {
|
|
916
|
-
order:
|
|
920
|
+
order: r.buffer,
|
|
917
921
|
count: 0
|
|
918
922
|
};
|
|
919
|
-
self.postMessage(c, [
|
|
923
|
+
self.postMessage(c, [r.buffer]), r = null;
|
|
920
924
|
return;
|
|
921
925
|
}
|
|
922
|
-
const _ = i.x, x = i.y, D = i.z,
|
|
926
|
+
const _ = i.x, x = i.y, D = i.z, T = u.x, y = u.y, R = u.z, B = 1e-4, X = Math.abs(_ - M.x) > B || Math.abs(x - M.y) > B || Math.abs(D - M.z) > B, $ = Math.abs(T - C.x) > B || Math.abs(y - C.y) > B || Math.abs(R - C.z) > B;
|
|
923
927
|
if (!v && !X && !$)
|
|
924
928
|
return;
|
|
925
|
-
v = !1, M.x = _, M.y = x, M.z = D,
|
|
929
|
+
v = !1, M.x = _, M.y = x, M.z = D, C.x = T, C.y = y, C.z = R;
|
|
926
930
|
let Z = 1 / 0, U = -1 / 0;
|
|
927
931
|
for (let c = 0; c < 8; ++c) {
|
|
928
|
-
const
|
|
932
|
+
const g = c & 1 ? d.x : w.x, P = c & 2 ? d.y : w.y, f = c & 4 ? d.z : w.z, k = g * T + P * y + f * R;
|
|
929
933
|
Z = Math.min(Z, k), U = Math.max(U, k);
|
|
930
934
|
}
|
|
931
|
-
const F =
|
|
935
|
+
const F = t.length / 3, N = U - Z, s = (1 << Math.max(
|
|
932
936
|
10,
|
|
933
937
|
Math.min(20, Math.ceil(Math.log2(F / 4)))
|
|
934
938
|
)) + 1;
|
|
935
939
|
if ((!b || b.length !== F) && (b = new Uint32Array(F)), !I || I.length !== s ? I = new Uint32Array(s) : I.fill(0), N < 1e-7) {
|
|
936
940
|
for (let c = 0; c < F; ++c) b[c] = 0;
|
|
937
941
|
I[0] = F;
|
|
938
|
-
} else if (
|
|
939
|
-
const c =
|
|
942
|
+
} else if (o && o.length > 0) {
|
|
943
|
+
const c = o.length / 6;
|
|
940
944
|
j.fill(0);
|
|
941
|
-
for (let
|
|
942
|
-
const k =
|
|
945
|
+
for (let f = 0; f < c; ++f) {
|
|
946
|
+
const k = f * 6, O = o[k + 0], V = o[k + 1], G = o[k + 2], q = o[k + 3], Y = O * T + V * y + G * R - Z, Q = Y - q, K = Y + q, re = Math.max(
|
|
943
947
|
0,
|
|
944
948
|
Math.floor(Q * z / N)
|
|
945
949
|
), oe = Math.min(
|
|
@@ -949,43 +953,43 @@ class Pe extends l.EventDispatcher {
|
|
|
949
953
|
for (let J = re; J < oe; ++J)
|
|
950
954
|
j[J]++;
|
|
951
955
|
}
|
|
952
|
-
let
|
|
953
|
-
for (let
|
|
954
|
-
|
|
955
|
-
for (let
|
|
956
|
-
|
|
957
|
-
|
|
956
|
+
let g = 0;
|
|
957
|
+
for (let f = 0; f < z; ++f) g += j[f];
|
|
958
|
+
L[0] = 0, H[0] = 0;
|
|
959
|
+
for (let f = 1; f < z; ++f)
|
|
960
|
+
L[f - 1] = j[f - 1] / g * s >>> 0, H[f] = H[f - 1] + L[f - 1];
|
|
961
|
+
L[z - 1] = j[z - 1] / g * s >>> 0;
|
|
958
962
|
const P = N / z;
|
|
959
|
-
for (let
|
|
960
|
-
const k =
|
|
963
|
+
for (let f = 0; f < F; ++f) {
|
|
964
|
+
const k = f * 3, O = t[k + 0], V = t[k + 1], G = t[k + 2], q = O * T + V * y + G * R, Q = (U - q) / P, K = Math.max(
|
|
961
965
|
0,
|
|
962
966
|
Math.min(
|
|
963
967
|
z - 1,
|
|
964
968
|
Math.floor(Q)
|
|
965
969
|
)
|
|
966
|
-
), re = Q - K, oe = H[K] +
|
|
967
|
-
b[
|
|
970
|
+
), re = Q - K, oe = H[K] + L[K] * re >>> 0, J = Math.min(oe, s - 1);
|
|
971
|
+
b[f] = J, I[J]++;
|
|
968
972
|
}
|
|
969
973
|
} else {
|
|
970
974
|
const c = (s - 1) / N;
|
|
971
|
-
for (let
|
|
972
|
-
const P =
|
|
973
|
-
b[
|
|
975
|
+
for (let g = 0; g < F; ++g) {
|
|
976
|
+
const P = g * 3, f = t[P + 0], k = t[P + 1], O = t[P + 2], V = f * T + k * y + O * R, q = (U - V) * c >>> 0, Y = Math.min(q, s - 1);
|
|
977
|
+
b[g] = Y, I[Y]++;
|
|
974
978
|
}
|
|
975
979
|
}
|
|
976
980
|
for (let c = 1; c < s; c++)
|
|
977
981
|
I[c] += I[c - 1];
|
|
978
982
|
for (let c = F - 1; c >= 0; c--) {
|
|
979
|
-
const
|
|
980
|
-
|
|
983
|
+
const g = b[c], P = --I[g];
|
|
984
|
+
r[P] = a ? a[c] : c;
|
|
981
985
|
}
|
|
982
|
-
const p = _ *
|
|
983
|
-
if (!
|
|
984
|
-
const
|
|
985
|
-
if (!
|
|
986
|
+
const p = _ * T + x * y + D * R, S = (c) => {
|
|
987
|
+
if (!r) return -1 / 0;
|
|
988
|
+
const g = r[c], P = g;
|
|
989
|
+
if (!t || P * 3 + 2 >= t.length)
|
|
986
990
|
return -1 / 0;
|
|
987
|
-
const
|
|
988
|
-
return
|
|
991
|
+
const f = P * 3;
|
|
992
|
+
return t[f] * T + t[f + 1] * y + t[f + 2] * R - p;
|
|
989
993
|
};
|
|
990
994
|
let E = F;
|
|
991
995
|
if (F > 0 && S(F - 1) < 0) {
|
|
@@ -997,63 +1001,63 @@ class Pe extends l.EventDispatcher {
|
|
|
997
1001
|
E = c < 0 ? ~c : c;
|
|
998
1002
|
}
|
|
999
1003
|
const m = {
|
|
1000
|
-
order:
|
|
1004
|
+
order: r.buffer,
|
|
1001
1005
|
count: E
|
|
1002
1006
|
};
|
|
1003
|
-
self.postMessage(m, [
|
|
1007
|
+
self.postMessage(m, [r.buffer]), r = null;
|
|
1004
1008
|
};
|
|
1005
1009
|
self.onmessage = (_) => {
|
|
1006
1010
|
const x = _.data;
|
|
1007
|
-
x.order && (
|
|
1011
|
+
x.order && (r = new Uint32Array(x.order));
|
|
1008
1012
|
let D = !1;
|
|
1009
|
-
if (x.centers && (
|
|
1010
|
-
if (
|
|
1011
|
-
for (let
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1013
|
+
if (x.centers && (t = new Float32Array(x.centers), D = !0, v = !0), Object.prototype.hasOwnProperty.call(x, "mapping") && (a = x.mapping ? new Uint32Array(x.mapping) : null, v = !0), x.chunks) {
|
|
1014
|
+
if (o = new Float32Array(x.chunks), o.length > 0 && o[3] > 0)
|
|
1015
|
+
for (let T = 0; T < o.length / 6; ++T) {
|
|
1016
|
+
const y = T * 6, R = o[y + 0], B = o[y + 1], X = o[y + 2], $ = o[y + 3], Z = o[y + 4], U = o[y + 5];
|
|
1017
|
+
o[y + 0] = (R + $) * 0.5, o[y + 1] = (B + Z) * 0.5, o[y + 2] = (X + U) * 0.5, o[y + 3] = Math.sqrt(
|
|
1014
1018
|
($ - R) ** 2 + (Z - B) ** 2 + (U - X) ** 2
|
|
1015
1019
|
) * 0.5;
|
|
1016
1020
|
}
|
|
1017
1021
|
v = !0;
|
|
1018
1022
|
}
|
|
1019
|
-
if (D &&
|
|
1020
|
-
|
|
1021
|
-
for (let
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1023
|
+
if (D && t && t.length > 0) {
|
|
1024
|
+
d.x = w.x = t[0], d.y = w.y = t[1], d.z = w.z = t[2];
|
|
1025
|
+
for (let T = 1; T < t.length / 3; T++) {
|
|
1026
|
+
const y = T * 3;
|
|
1027
|
+
d.x = Math.min(d.x, t[y + 0]), w.x = Math.max(w.x, t[y + 0]), d.y = Math.min(d.y, t[y + 1]), w.y = Math.max(w.y, t[y + 1]), d.z = Math.min(d.z, t[y + 2]), w.z = Math.max(w.z, t[y + 2]);
|
|
1024
1028
|
}
|
|
1025
|
-
} else D &&
|
|
1026
|
-
x.cameraPosition && (i = x.cameraPosition), x.cameraDirection && (u = x.cameraDirection),
|
|
1029
|
+
} else D && t && t.length === 0 && (d.x = w.x = d.y = w.y = d.z = w.z = 0);
|
|
1030
|
+
x.cameraPosition && (i = x.cameraPosition), x.cameraDirection && (u = x.cameraDirection), W();
|
|
1027
1031
|
};
|
|
1028
1032
|
}).toString()})();`;
|
|
1029
1033
|
}
|
|
1030
1034
|
}
|
|
1031
1035
|
const ze = (A, e) => {
|
|
1032
|
-
const n =
|
|
1033
|
-
return n |
|
|
1036
|
+
const n = ge(A), r = ge(e);
|
|
1037
|
+
return n | r << 16;
|
|
1034
1038
|
};
|
|
1035
|
-
function
|
|
1036
|
-
const e = new Float32Array([A]),
|
|
1037
|
-
let
|
|
1038
|
-
const a =
|
|
1039
|
-
return a < 103 ?
|
|
1039
|
+
function ge(A) {
|
|
1040
|
+
const e = new Float32Array([A]), r = new Int32Array(e.buffer)[0];
|
|
1041
|
+
let t = r >> 16 & 32768, o = r >> 12 & 2047;
|
|
1042
|
+
const a = r >> 23 & 255;
|
|
1043
|
+
return a < 103 ? t : a > 142 ? (t |= 31744, t |= (a === 255 ? 0 : 1) && r & 8388607, t) : a < 113 ? (o |= 2048, t |= (o >> 114 - a) + (o >> 113 - a & 1), t) : (t |= a - 112 << 10 | o >> 1, t += o & 1, t);
|
|
1040
1044
|
}
|
|
1041
|
-
const Be = new ArrayBuffer(4),
|
|
1045
|
+
const Be = new ArrayBuffer(4), ye = new DataView(Be), Fe = (A) => (ye.setUint32(0, A, !0), ye.getFloat32(0, !0));
|
|
1042
1046
|
class Oe {
|
|
1043
1047
|
/**
|
|
1044
1048
|
* Create a new TextureManager for a set of splats
|
|
1045
1049
|
* @param splatData The splat data to manage textures for
|
|
1046
1050
|
*/
|
|
1047
1051
|
constructor(e) {
|
|
1048
|
-
|
|
1052
|
+
h(this, "textureWidth");
|
|
1053
|
+
h(this, "textureHeight");
|
|
1054
|
+
h(this, "transformA");
|
|
1049
1055
|
// position xyz and rotation quaternion y,z components
|
|
1050
|
-
|
|
1056
|
+
h(this, "transformB");
|
|
1051
1057
|
// rotation quaternion x and scale xyz
|
|
1052
|
-
|
|
1058
|
+
h(this, "colorTexture");
|
|
1053
1059
|
// color an opacity
|
|
1054
|
-
|
|
1055
|
-
d(this, "textureWidth");
|
|
1056
|
-
d(this, "textureHeight");
|
|
1060
|
+
h(this, "orderTexture");
|
|
1057
1061
|
const n = e.numSplats;
|
|
1058
1062
|
this.textureWidth = Math.ceil(Math.sqrt(n)), this.textureHeight = Math.ceil(n / this.textureWidth), this.transformA = this.createTransformATexture(e), this.transformB = this.createTransformBTexture(e), this.colorTexture = this.createColorTexture(e), this.orderTexture = this.createOrderTexture(n);
|
|
1059
1063
|
}
|
|
@@ -1063,24 +1067,24 @@ class Oe {
|
|
|
1063
1067
|
* @returns DataTexture containing position data
|
|
1064
1068
|
*/
|
|
1065
1069
|
createTransformATexture(e) {
|
|
1066
|
-
const n = e.numSplats,
|
|
1070
|
+
const n = e.numSplats, r = new Float32Array(
|
|
1067
1071
|
this.textureWidth * this.textureHeight * 4
|
|
1068
1072
|
);
|
|
1069
|
-
for (let
|
|
1070
|
-
const a =
|
|
1071
|
-
|
|
1072
|
-
const v = e.rotations[u + 0], M = e.rotations[u + 1],
|
|
1073
|
-
|
|
1073
|
+
for (let o = 0; o < n; o++) {
|
|
1074
|
+
const a = o * 4, i = o * 3, u = o * 4;
|
|
1075
|
+
r[a] = e.positions[i], r[a + 1] = e.positions[i + 1], r[a + 2] = e.positions[i + 2];
|
|
1076
|
+
const v = e.rotations[u + 0], M = e.rotations[u + 1], C = ze(v, M);
|
|
1077
|
+
r[a + 3] = Fe(C);
|
|
1074
1078
|
}
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1079
|
+
const t = new l.DataTexture(
|
|
1080
|
+
r,
|
|
1077
1081
|
this.textureWidth,
|
|
1078
1082
|
this.textureHeight,
|
|
1079
1083
|
l.RGBAFormat,
|
|
1080
1084
|
l.FloatType
|
|
1081
1085
|
// Store as Float32, shader will reinterpret bits
|
|
1082
1086
|
);
|
|
1083
|
-
return
|
|
1087
|
+
return t.magFilter = l.NearestFilter, t.minFilter = l.NearestFilter, t.source.data.updateRanges || (t.source.data.updateRanges = []), t.needsUpdate = !0, t;
|
|
1084
1088
|
}
|
|
1085
1089
|
/**
|
|
1086
1090
|
* Create the transform B texture (scale and rotation xyz)
|
|
@@ -1088,21 +1092,21 @@ class Oe {
|
|
|
1088
1092
|
* @returns DataTexture containing scale and rotation data
|
|
1089
1093
|
*/
|
|
1090
1094
|
createTransformBTexture(e) {
|
|
1091
|
-
const n = e.numSplats,
|
|
1095
|
+
const n = e.numSplats, r = new Float32Array(
|
|
1092
1096
|
this.textureWidth * this.textureHeight * 4
|
|
1093
1097
|
);
|
|
1094
|
-
for (let
|
|
1095
|
-
const a =
|
|
1096
|
-
|
|
1098
|
+
for (let o = 0; o < n; o++) {
|
|
1099
|
+
const a = o * 4, i = o * 3, u = o * 4;
|
|
1100
|
+
r[a] = e.scales[i], r[a + 1] = e.scales[i + 1], r[a + 2] = e.scales[i + 2], r[a + 3] = e.rotations[u + 2];
|
|
1097
1101
|
}
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1102
|
+
const t = new l.DataTexture(
|
|
1103
|
+
r,
|
|
1100
1104
|
this.textureWidth,
|
|
1101
1105
|
this.textureHeight,
|
|
1102
1106
|
l.RGBAFormat,
|
|
1103
1107
|
l.FloatType
|
|
1104
1108
|
);
|
|
1105
|
-
return
|
|
1109
|
+
return t.magFilter = l.NearestFilter, t.minFilter = l.NearestFilter, t.source.data.updateRanges || (t.source.data.updateRanges = []), t.needsUpdate = !0, t;
|
|
1106
1110
|
}
|
|
1107
1111
|
/**
|
|
1108
1112
|
* Create the color texture (RGB and opacity)
|
|
@@ -1110,21 +1114,21 @@ class Oe {
|
|
|
1110
1114
|
* @returns DataTexture containing color data
|
|
1111
1115
|
*/
|
|
1112
1116
|
createColorTexture(e) {
|
|
1113
|
-
const n = e.numSplats,
|
|
1117
|
+
const n = e.numSplats, r = new Float32Array(
|
|
1114
1118
|
this.textureWidth * this.textureHeight * 4
|
|
1115
1119
|
);
|
|
1116
|
-
for (let
|
|
1117
|
-
const a =
|
|
1118
|
-
|
|
1120
|
+
for (let o = 0; o < n; o++) {
|
|
1121
|
+
const a = o * 4, i = o * 3;
|
|
1122
|
+
r[a] = e.colors[i], r[a + 1] = e.colors[i + 1], r[a + 2] = e.colors[i + 2], r[a + 3] = e.opacities[o];
|
|
1119
1123
|
}
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1124
|
+
const t = new l.DataTexture(
|
|
1125
|
+
r,
|
|
1122
1126
|
this.textureWidth,
|
|
1123
1127
|
this.textureHeight,
|
|
1124
1128
|
l.RGBAFormat,
|
|
1125
1129
|
l.FloatType
|
|
1126
1130
|
);
|
|
1127
|
-
return
|
|
1131
|
+
return t.source.data.updateRanges || (t.source.data.updateRanges = []), t.needsUpdate = !0, t;
|
|
1128
1132
|
}
|
|
1129
1133
|
/**
|
|
1130
1134
|
* Create the order texture for sorting
|
|
@@ -1133,16 +1137,16 @@ class Oe {
|
|
|
1133
1137
|
*/
|
|
1134
1138
|
createOrderTexture(e) {
|
|
1135
1139
|
const n = new Uint32Array(this.textureWidth * this.textureHeight);
|
|
1136
|
-
for (let
|
|
1137
|
-
n[
|
|
1138
|
-
const
|
|
1140
|
+
for (let t = 0; t < e; t++)
|
|
1141
|
+
n[t] = t;
|
|
1142
|
+
const r = new l.DataTexture(
|
|
1139
1143
|
n,
|
|
1140
1144
|
this.textureWidth,
|
|
1141
1145
|
this.textureHeight,
|
|
1142
1146
|
l.RedIntegerFormat,
|
|
1143
1147
|
l.UnsignedIntType
|
|
1144
1148
|
);
|
|
1145
|
-
return
|
|
1149
|
+
return r.source.data.updateRanges || (r.source.data.updateRanges = []), r.needsUpdate = !0, r;
|
|
1146
1150
|
}
|
|
1147
1151
|
dispose() {
|
|
1148
1152
|
this.transformA.dispose(), this.transformB.dispose(), this.colorTexture.dispose(), this.orderTexture.dispose();
|
|
@@ -1534,33 +1538,33 @@ const se = class se extends l.Mesh {
|
|
|
1534
1538
|
* @param splatData The splat data to render
|
|
1535
1539
|
* @param options Rendering options
|
|
1536
1540
|
*/
|
|
1537
|
-
constructor(n,
|
|
1538
|
-
const
|
|
1539
|
-
super(
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1541
|
+
constructor(n, r = {}) {
|
|
1542
|
+
const t = new Ve(r), o = se.createInstancedGeometry(n.numSplats, se.INSTANCE_SIZE);
|
|
1543
|
+
super(o, t);
|
|
1544
|
+
h(this, "sorter");
|
|
1545
|
+
h(this, "splatData");
|
|
1546
|
+
h(this, "options");
|
|
1547
|
+
h(this, "textureManager");
|
|
1548
|
+
h(this, "material");
|
|
1549
|
+
h(this, "geometry");
|
|
1550
|
+
h(this, "lastCameraPositionLocal", new l.Vector3());
|
|
1551
|
+
h(this, "lastCameraDirectionLocal", new l.Vector3());
|
|
1552
|
+
h(this, "invModelMatrix", new l.Matrix4());
|
|
1549
1553
|
// Cached inverse matrix
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
const
|
|
1559
|
-
this.geometry.instanceCount = Math.ceil(
|
|
1554
|
+
h(this, "_vpW", -1);
|
|
1555
|
+
h(this, "_vpH", -1);
|
|
1556
|
+
h(this, "_size", new l.Vector2());
|
|
1557
|
+
h(this, "_camPosW", new l.Vector3());
|
|
1558
|
+
h(this, "_camDirW", new l.Vector3());
|
|
1559
|
+
h(this, "_camPosL", new l.Vector3());
|
|
1560
|
+
h(this, "_camDirL", new l.Vector3());
|
|
1561
|
+
h(this, "onSorterUpdated", (n) => {
|
|
1562
|
+
const r = n.count;
|
|
1563
|
+
this.geometry.instanceCount = Math.ceil(r / se.INSTANCE_SIZE), this.material.setNumSplats(r);
|
|
1560
1564
|
});
|
|
1561
|
-
this.geometry =
|
|
1565
|
+
this.geometry = o, this.material = t, this.splatData = n, this.frustumCulled = !1, this.options = {
|
|
1562
1566
|
autoSort: !0,
|
|
1563
|
-
...
|
|
1567
|
+
...r
|
|
1564
1568
|
}, this.textureManager = new Oe(n), this.sorter = new Pe();
|
|
1565
1569
|
let a = this.createChunks() || void 0;
|
|
1566
1570
|
a === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), a = void 0, this.sorter.addEventListener("updated", this.onSorterUpdated), this.sorter.init(
|
|
@@ -1576,8 +1580,8 @@ const se = class se extends l.Mesh {
|
|
|
1576
1580
|
* @param instanceSize Number of splats per instance.
|
|
1577
1581
|
* @returns InstancedBufferGeometry
|
|
1578
1582
|
*/
|
|
1579
|
-
static createInstancedGeometry(n,
|
|
1580
|
-
const
|
|
1583
|
+
static createInstancedGeometry(n, r) {
|
|
1584
|
+
const t = Math.ceil(n / r), o = new l.BufferGeometry(), a = new Float32Array([
|
|
1581
1585
|
// x, y, splat_index_in_instance
|
|
1582
1586
|
-1,
|
|
1583
1587
|
-1,
|
|
@@ -1591,24 +1595,24 @@ const se = class se extends l.Mesh {
|
|
|
1591
1595
|
-1,
|
|
1592
1596
|
1,
|
|
1593
1597
|
0
|
|
1594
|
-
]), i = new Uint16Array([0, 1, 2, 0, 2, 3]), u = new Float32Array(4 * 3 *
|
|
1595
|
-
for (let
|
|
1596
|
-
const w =
|
|
1598
|
+
]), i = new Uint16Array([0, 1, 2, 0, 2, 3]), u = new Float32Array(4 * 3 * r);
|
|
1599
|
+
for (let d = 0; d < r; d++) {
|
|
1600
|
+
const w = d * 4 * 3;
|
|
1597
1601
|
for (let b = 0; b < 4; b++)
|
|
1598
|
-
u[w + b * 3 + 0] = a[b * 3 + 0], u[w + b * 3 + 1] = a[b * 3 + 1], u[w + b * 3 + 2] =
|
|
1602
|
+
u[w + b * 3 + 0] = a[b * 3 + 0], u[w + b * 3 + 1] = a[b * 3 + 1], u[w + b * 3 + 2] = d;
|
|
1599
1603
|
}
|
|
1600
|
-
const v = new Uint32Array(6 *
|
|
1601
|
-
for (let
|
|
1602
|
-
const w =
|
|
1604
|
+
const v = new Uint32Array(6 * r);
|
|
1605
|
+
for (let d = 0; d < r; d++) {
|
|
1606
|
+
const w = d * 6, b = d * 4;
|
|
1603
1607
|
v[w + 0] = i[0] + b, v[w + 1] = i[1] + b, v[w + 2] = i[2] + b, v[w + 3] = i[3] + b, v[w + 4] = i[4] + b, v[w + 5] = i[5] + b;
|
|
1604
1608
|
}
|
|
1605
|
-
|
|
1609
|
+
o.setAttribute("position", new l.BufferAttribute(u, 3)), o.setIndex(new l.BufferAttribute(v, 1));
|
|
1606
1610
|
const M = new l.InstancedBufferGeometry();
|
|
1607
|
-
M.index =
|
|
1608
|
-
const
|
|
1609
|
-
for (let
|
|
1610
|
-
|
|
1611
|
-
return M.setAttribute("splatInstanceIndex", new l.InstancedBufferAttribute(
|
|
1611
|
+
M.index = o.index, M.setAttribute("position", o.getAttribute("position"));
|
|
1612
|
+
const C = new Uint32Array(t);
|
|
1613
|
+
for (let d = 0; d < t; d++)
|
|
1614
|
+
C[d] = d * r;
|
|
1615
|
+
return M.setAttribute("splatInstanceIndex", new l.InstancedBufferAttribute(C, 1, !1)), M.instanceCount = 0, M;
|
|
1612
1616
|
}
|
|
1613
1617
|
/**
|
|
1614
1618
|
* Create chunks data (bounding box min/max) for the sorter.
|
|
@@ -1632,8 +1636,8 @@ const se = class se extends l.Mesh {
|
|
|
1632
1636
|
* @param width Viewport width
|
|
1633
1637
|
* @param height Viewport height
|
|
1634
1638
|
*/
|
|
1635
|
-
updateViewport(n,
|
|
1636
|
-
n === this._vpW &&
|
|
1639
|
+
updateViewport(n, r) {
|
|
1640
|
+
n === this._vpW && r === this._vpH || (this._vpW = n, this._vpH = r, this.material.updateViewport(n, r));
|
|
1637
1641
|
}
|
|
1638
1642
|
/**
|
|
1639
1643
|
* Sorts splats based on camera position and direction.
|
|
@@ -1641,8 +1645,8 @@ const se = class se extends l.Mesh {
|
|
|
1641
1645
|
*/
|
|
1642
1646
|
sort(n) {
|
|
1643
1647
|
n.getWorldPosition(this._camPosW), n.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);
|
|
1644
|
-
const
|
|
1645
|
-
this.options.autoSort && (
|
|
1648
|
+
const r = this.lastCameraPositionLocal.distanceToSquared(this._camPosL) > 1e-6, t = this.lastCameraDirectionLocal.dot(this._camDirL) < 0.999;
|
|
1649
|
+
this.options.autoSort && (r || t) && (this.lastCameraPositionLocal.copy(this._camPosL), this.lastCameraDirectionLocal.copy(this._camDirL), this.sorter.setCamera(this._camPosL, this._camDirL));
|
|
1646
1650
|
}
|
|
1647
1651
|
/**
|
|
1648
1652
|
* THREE.js hook called before rendering the object.
|
|
@@ -1653,8 +1657,8 @@ const se = class se extends l.Mesh {
|
|
|
1653
1657
|
*/
|
|
1654
1658
|
// prettier-ignore
|
|
1655
1659
|
// @ts-expect-error scene is not used
|
|
1656
|
-
onBeforeRender(n,
|
|
1657
|
-
this.sort(
|
|
1660
|
+
onBeforeRender(n, r, t) {
|
|
1661
|
+
this.sort(t), n.getSize(this._size), this.updateViewport(this._size.x, this._size.y);
|
|
1658
1662
|
}
|
|
1659
1663
|
/**
|
|
1660
1664
|
* Dispose of resources
|
|
@@ -1664,7 +1668,7 @@ const se = class se extends l.Mesh {
|
|
|
1664
1668
|
}
|
|
1665
1669
|
};
|
|
1666
1670
|
/** Number of splats combined into a single instanced draw call. */
|
|
1667
|
-
|
|
1671
|
+
h(se, "INSTANCE_SIZE", 128);
|
|
1668
1672
|
let le = se;
|
|
1669
1673
|
const qe = Symbol.for("@speridlabs/visus/SplatMesh");
|
|
1670
1674
|
try {
|
|
@@ -1681,16 +1685,16 @@ const Ye = ({
|
|
|
1681
1685
|
plyUrl: A,
|
|
1682
1686
|
debug: e = !1,
|
|
1683
1687
|
splatOptions: n = {},
|
|
1684
|
-
...
|
|
1688
|
+
...r
|
|
1685
1689
|
}) => {
|
|
1686
|
-
typeof window < "u" && e && (window.__VISUS_SPLAT_DEBUG__ = !0), e && console.debug("SPLAT: rendering", { plyUrl: A, splatOptions: n, meshProps:
|
|
1687
|
-
const
|
|
1688
|
-
() => new le(
|
|
1689
|
-
[
|
|
1690
|
+
typeof window < "u" && e && (window.__VISUS_SPLAT_DEBUG__ = !0), e && console.debug("SPLAT: rendering", { plyUrl: A, splatOptions: n, meshProps: r });
|
|
1691
|
+
const t = Se(null), o = Ae(Re, A), a = Me(
|
|
1692
|
+
() => new le(o, n || {}),
|
|
1693
|
+
[o, n]
|
|
1690
1694
|
);
|
|
1691
1695
|
return _e(() => () => {
|
|
1692
1696
|
e && console.debug("SPLAT: disposing mesh for", A), typeof (a == null ? void 0 : a.dispose) == "function" && a.dispose();
|
|
1693
|
-
}, [a]), /* @__PURE__ */ Ee.jsx("primitive", { ref:
|
|
1697
|
+
}, [a]), /* @__PURE__ */ Ee.jsx("primitive", { ref: t, object: a, ...r });
|
|
1694
1698
|
};
|
|
1695
1699
|
export {
|
|
1696
1700
|
Re as PlyLoader,
|