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