@speridlabs/visus 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +1 -0
- package/dist/main.es.js +1075 -927
- package/dist/main.umd.js +6 -6
- package/dist/react.es.js +1215 -1067
- package/package.json +1 -1
package/dist/react.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
6
|
-
var
|
|
1
|
+
var Qe = Object.defineProperty;
|
|
2
|
+
var Ke = (a, e, t) => e in a ? Qe(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var w = (a, e, t) => Ke(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import et, { useState as tt, useRef as st, useEffect as rt } from "react";
|
|
5
|
+
import * as u from "three";
|
|
6
|
+
var Se = { exports: {} }, ge = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.js
|
|
@@ -13,29 +13,29 @@ var we = { exports: {} }, pe = {};
|
|
|
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(
|
|
16
|
+
var Oe;
|
|
17
|
+
function nt() {
|
|
18
|
+
if (Oe) return ge;
|
|
19
|
+
Oe = 1;
|
|
20
|
+
var a = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
21
|
+
function t(s, r, n) {
|
|
22
22
|
var o = null;
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
for (var
|
|
26
|
-
|
|
27
|
-
} else
|
|
28
|
-
return
|
|
29
|
-
$$typeof:
|
|
30
|
-
type:
|
|
23
|
+
if (n !== void 0 && (o = "" + n), r.key !== void 0 && (o = "" + r.key), "key" in r) {
|
|
24
|
+
n = {};
|
|
25
|
+
for (var c in r)
|
|
26
|
+
c !== "key" && (n[c] = r[c]);
|
|
27
|
+
} else n = r;
|
|
28
|
+
return r = n.ref, {
|
|
29
|
+
$$typeof: a,
|
|
30
|
+
type: s,
|
|
31
31
|
key: o,
|
|
32
|
-
ref:
|
|
33
|
-
props:
|
|
32
|
+
ref: r !== void 0 ? r : null,
|
|
33
|
+
props: n
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
return
|
|
36
|
+
return ge.Fragment = e, ge.jsx = t, ge.jsxs = t, ge;
|
|
37
37
|
}
|
|
38
|
-
var
|
|
38
|
+
var ye = {};
|
|
39
39
|
/**
|
|
40
40
|
* @license React
|
|
41
41
|
* react-jsx-runtime.development.js
|
|
@@ -45,251 +45,251 @@ var xe = {};
|
|
|
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 Ue;
|
|
49
|
+
function at() {
|
|
50
|
+
return Ue || (Ue = 1, process.env.NODE_ENV !== "production" && function() {
|
|
51
|
+
function a(i) {
|
|
52
|
+
if (i == null) return null;
|
|
53
|
+
if (typeof i == "function")
|
|
54
|
+
return i.$$typeof === y ? null : i.displayName || i.name || null;
|
|
55
|
+
if (typeof i == "string") return i;
|
|
56
|
+
switch (i) {
|
|
57
|
+
case C:
|
|
58
58
|
return "Fragment";
|
|
59
|
-
case
|
|
59
|
+
case B:
|
|
60
60
|
return "Profiler";
|
|
61
|
-
case
|
|
61
|
+
case k:
|
|
62
62
|
return "StrictMode";
|
|
63
|
-
case
|
|
63
|
+
case W:
|
|
64
64
|
return "Suspense";
|
|
65
|
-
case
|
|
65
|
+
case T:
|
|
66
66
|
return "SuspenseList";
|
|
67
|
-
case
|
|
67
|
+
case E:
|
|
68
68
|
return "Activity";
|
|
69
69
|
}
|
|
70
|
-
if (typeof
|
|
71
|
-
switch (typeof
|
|
70
|
+
if (typeof i == "object")
|
|
71
|
+
switch (typeof i.tag == "number" && console.error(
|
|
72
72
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
73
|
-
),
|
|
74
|
-
case
|
|
73
|
+
), i.$$typeof) {
|
|
74
|
+
case v:
|
|
75
75
|
return "Portal";
|
|
76
|
-
case
|
|
77
|
-
return (
|
|
78
|
-
case
|
|
79
|
-
return (
|
|
80
|
-
case
|
|
81
|
-
var
|
|
82
|
-
return
|
|
83
|
-
case
|
|
84
|
-
return
|
|
85
|
-
case
|
|
86
|
-
|
|
76
|
+
case F:
|
|
77
|
+
return (i.displayName || "Context") + ".Provider";
|
|
78
|
+
case U:
|
|
79
|
+
return (i._context.displayName || "Context") + ".Consumer";
|
|
80
|
+
case N:
|
|
81
|
+
var A = i.render;
|
|
82
|
+
return i = i.displayName, i || (i = A.displayName || A.name || "", i = i !== "" ? "ForwardRef(" + i + ")" : "ForwardRef"), i;
|
|
83
|
+
case S:
|
|
84
|
+
return A = i.displayName || null, A !== null ? A : a(i.type) || "Memo";
|
|
85
|
+
case z:
|
|
86
|
+
A = i._payload, i = i._init;
|
|
87
87
|
try {
|
|
88
|
-
return
|
|
88
|
+
return a(i(A));
|
|
89
89
|
} catch {
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
94
|
-
function e(
|
|
95
|
-
return "" +
|
|
94
|
+
function e(i) {
|
|
95
|
+
return "" + i;
|
|
96
96
|
}
|
|
97
|
-
function t(
|
|
97
|
+
function t(i) {
|
|
98
98
|
try {
|
|
99
|
-
e(
|
|
100
|
-
var
|
|
99
|
+
e(i);
|
|
100
|
+
var A = !1;
|
|
101
101
|
} catch {
|
|
102
|
-
|
|
102
|
+
A = !0;
|
|
103
103
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
var
|
|
107
|
-
return
|
|
108
|
-
|
|
104
|
+
if (A) {
|
|
105
|
+
A = console;
|
|
106
|
+
var q = A.error, O = typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object";
|
|
107
|
+
return q.call(
|
|
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
|
+
O
|
|
111
|
+
), e(i);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
if (
|
|
116
|
-
if (typeof
|
|
114
|
+
function s(i) {
|
|
115
|
+
if (i === C) return "<>";
|
|
116
|
+
if (typeof i == "object" && i !== null && i.$$typeof === z)
|
|
117
117
|
return "<...>";
|
|
118
118
|
try {
|
|
119
|
-
var
|
|
120
|
-
return
|
|
119
|
+
var A = a(i);
|
|
120
|
+
return A ? "<" + A + ">" : "<...>";
|
|
121
121
|
} catch {
|
|
122
122
|
return "<...>";
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
var
|
|
127
|
-
return
|
|
125
|
+
function r() {
|
|
126
|
+
var i = b.A;
|
|
127
|
+
return i === null ? null : i.getOwner();
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function n() {
|
|
130
130
|
return Error("react-stack-top-frame");
|
|
131
131
|
}
|
|
132
|
-
function o(
|
|
133
|
-
if (
|
|
134
|
-
var
|
|
135
|
-
if (
|
|
132
|
+
function o(i) {
|
|
133
|
+
if (j.call(i, "key")) {
|
|
134
|
+
var A = Object.getOwnPropertyDescriptor(i, "key").get;
|
|
135
|
+
if (A && A.isReactWarning) return !1;
|
|
136
136
|
}
|
|
137
|
-
return
|
|
137
|
+
return i.key !== void 0;
|
|
138
138
|
}
|
|
139
|
-
function i
|
|
140
|
-
function
|
|
141
|
-
|
|
139
|
+
function c(i, A) {
|
|
140
|
+
function q() {
|
|
141
|
+
D || (D = !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
|
+
q.isReactWarning = !0, Object.defineProperty(i, "key", {
|
|
147
|
+
get: q,
|
|
148
148
|
configurable: !0
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
var
|
|
153
|
-
return
|
|
151
|
+
function f() {
|
|
152
|
+
var i = a(this.type);
|
|
153
|
+
return x[i] || (x[i] = !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
|
+
)), i = this.props.ref, i !== void 0 ? i : null;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
return
|
|
159
|
-
$$typeof:
|
|
160
|
-
type:
|
|
161
|
-
key:
|
|
157
|
+
function g(i, A, q, O, R, d, P, G) {
|
|
158
|
+
return q = d.ref, i = {
|
|
159
|
+
$$typeof: p,
|
|
160
|
+
type: i,
|
|
161
|
+
key: A,
|
|
162
162
|
props: d,
|
|
163
|
-
_owner:
|
|
164
|
-
}, (
|
|
163
|
+
_owner: R
|
|
164
|
+
}, (q !== void 0 ? q : null) !== null ? Object.defineProperty(i, "ref", {
|
|
165
165
|
enumerable: !1,
|
|
166
|
-
get:
|
|
167
|
-
}) : Object.defineProperty(
|
|
166
|
+
get: f
|
|
167
|
+
}) : Object.defineProperty(i, "ref", { enumerable: !1, value: null }), i._store = {}, Object.defineProperty(i._store, "validated", {
|
|
168
168
|
configurable: !1,
|
|
169
169
|
enumerable: !1,
|
|
170
170
|
writable: !0,
|
|
171
171
|
value: 0
|
|
172
|
-
}), Object.defineProperty(
|
|
172
|
+
}), Object.defineProperty(i, "_debugInfo", {
|
|
173
173
|
configurable: !1,
|
|
174
174
|
enumerable: !1,
|
|
175
175
|
writable: !0,
|
|
176
176
|
value: null
|
|
177
|
-
}), Object.defineProperty(
|
|
177
|
+
}), Object.defineProperty(i, "_debugStack", {
|
|
178
178
|
configurable: !1,
|
|
179
179
|
enumerable: !1,
|
|
180
180
|
writable: !0,
|
|
181
|
-
value:
|
|
182
|
-
}), Object.defineProperty(
|
|
181
|
+
value: P
|
|
182
|
+
}), Object.defineProperty(i, "_debugTask", {
|
|
183
183
|
configurable: !1,
|
|
184
184
|
enumerable: !1,
|
|
185
185
|
writable: !0,
|
|
186
|
-
value:
|
|
187
|
-
}), Object.freeze && (Object.freeze(
|
|
186
|
+
value: G
|
|
187
|
+
}), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
var
|
|
191
|
-
if (
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
for (
|
|
195
|
-
l(
|
|
196
|
-
Object.freeze && Object.freeze(
|
|
189
|
+
function m(i, A, q, O, R, d, P, G) {
|
|
190
|
+
var M = A.children;
|
|
191
|
+
if (M !== void 0)
|
|
192
|
+
if (O)
|
|
193
|
+
if (L(M)) {
|
|
194
|
+
for (O = 0; O < M.length; O++)
|
|
195
|
+
l(M[O]);
|
|
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
|
-
else l(
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
var
|
|
205
|
-
return
|
|
201
|
+
else l(M);
|
|
202
|
+
if (j.call(A, "key")) {
|
|
203
|
+
M = a(i);
|
|
204
|
+
var V = Object.keys(A).filter(function(Z) {
|
|
205
|
+
return Z !== "key";
|
|
206
206
|
});
|
|
207
|
-
|
|
207
|
+
O = 0 < V.length ? "{key: someKey, " + V.join(": ..., ") + ": ...}" : "{key: someKey}", $[M + O] || (V = 0 < V.length ? "{" + V.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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
),
|
|
214
|
+
O,
|
|
215
|
+
M,
|
|
216
|
+
V,
|
|
217
|
+
M
|
|
218
|
+
), $[M + O] = !0);
|
|
219
219
|
}
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
for (var
|
|
223
|
-
|
|
224
|
-
} else
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
typeof
|
|
228
|
-
),
|
|
229
|
-
|
|
230
|
-
|
|
220
|
+
if (M = null, q !== void 0 && (t(q), M = "" + q), o(A) && (t(A.key), M = "" + A.key), "key" in A) {
|
|
221
|
+
q = {};
|
|
222
|
+
for (var H in A)
|
|
223
|
+
H !== "key" && (q[H] = A[H]);
|
|
224
|
+
} else q = A;
|
|
225
|
+
return M && c(
|
|
226
|
+
q,
|
|
227
|
+
typeof i == "function" ? i.displayName || i.name || "Unknown" : i
|
|
228
|
+
), g(
|
|
229
|
+
i,
|
|
230
|
+
M,
|
|
231
231
|
d,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
232
|
+
R,
|
|
233
|
+
r(),
|
|
234
|
+
q,
|
|
235
|
+
P,
|
|
236
|
+
G
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
|
-
function l(
|
|
240
|
-
typeof
|
|
239
|
+
function l(i) {
|
|
240
|
+
typeof i == "object" && i !== null && i.$$typeof === p && i._store && (i._store.validated = 1);
|
|
241
241
|
}
|
|
242
|
-
var
|
|
242
|
+
var h = et, p = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), B = Symbol.for("react.profiler"), U = Symbol.for("react.consumer"), F = Symbol.for("react.context"), N = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), z = Symbol.for("react.lazy"), E = Symbol.for("react.activity"), y = Symbol.for("react.client.reference"), b = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, L = Array.isArray, I = console.createTask ? console.createTask : function() {
|
|
243
243
|
return null;
|
|
244
244
|
};
|
|
245
|
-
|
|
246
|
-
"react-stack-bottom-frame": function(
|
|
247
|
-
return
|
|
245
|
+
h = {
|
|
246
|
+
"react-stack-bottom-frame": function(i) {
|
|
247
|
+
return i();
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
)(),
|
|
254
|
-
|
|
255
|
-
var d = 1e4 >
|
|
256
|
-
return
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
250
|
+
var D, x = {}, _ = h["react-stack-bottom-frame"].bind(
|
|
251
|
+
h,
|
|
252
|
+
n
|
|
253
|
+
)(), X = I(s(n)), $ = {};
|
|
254
|
+
ye.Fragment = C, ye.jsx = function(i, A, q, O, R) {
|
|
255
|
+
var d = 1e4 > b.recentlyCreatedOwnerStacks++;
|
|
256
|
+
return m(
|
|
257
|
+
i,
|
|
258
|
+
A,
|
|
259
|
+
q,
|
|
260
260
|
!1,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
d ? Error("react-stack-top-frame") :
|
|
264
|
-
d ?
|
|
261
|
+
O,
|
|
262
|
+
R,
|
|
263
|
+
d ? Error("react-stack-top-frame") : _,
|
|
264
|
+
d ? I(s(i)) : X
|
|
265
265
|
);
|
|
266
|
-
},
|
|
267
|
-
var d = 1e4 >
|
|
268
|
-
return
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
266
|
+
}, ye.jsxs = function(i, A, q, O, R) {
|
|
267
|
+
var d = 1e4 > b.recentlyCreatedOwnerStacks++;
|
|
268
|
+
return m(
|
|
269
|
+
i,
|
|
270
|
+
A,
|
|
271
|
+
q,
|
|
272
272
|
!0,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
d ? Error("react-stack-top-frame") :
|
|
276
|
-
d ?
|
|
273
|
+
O,
|
|
274
|
+
R,
|
|
275
|
+
d ? Error("react-stack-top-frame") : _,
|
|
276
|
+
d ? I(s(i)) : X
|
|
277
277
|
);
|
|
278
278
|
};
|
|
279
|
-
}()),
|
|
279
|
+
}()), ye;
|
|
280
280
|
}
|
|
281
|
-
var
|
|
282
|
-
function
|
|
283
|
-
return
|
|
281
|
+
var Ve;
|
|
282
|
+
function ot() {
|
|
283
|
+
return Ve || (Ve = 1, process.env.NODE_ENV === "production" ? Se.exports = nt() : Se.exports = at()), Se.exports;
|
|
284
284
|
}
|
|
285
|
-
var
|
|
285
|
+
var it = ot();
|
|
286
286
|
class be {
|
|
287
287
|
constructor() {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
w(this, "min", new u.Vector3(1 / 0, 1 / 0, 1 / 0));
|
|
289
|
+
w(this, "max", new u.Vector3(-1 / 0, -1 / 0, -1 / 0));
|
|
290
|
+
w(this, "center", new u.Vector3());
|
|
291
291
|
/** Half extents (size/2) */
|
|
292
|
-
|
|
292
|
+
w(this, "halfExtents", new u.Vector3());
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
295
|
* Reset the bounding box to its initial state
|
|
@@ -330,7 +330,7 @@ class be {
|
|
|
330
330
|
* @returns THREE.Box3 representation
|
|
331
331
|
*/
|
|
332
332
|
toBox3() {
|
|
333
|
-
return new
|
|
333
|
+
return new u.Box3().set(this.min, this.max);
|
|
334
334
|
}
|
|
335
335
|
/**
|
|
336
336
|
* Create a clone of this bounding box
|
|
@@ -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 ct {
|
|
345
345
|
constructor(e = 0) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
346
|
+
w(this, "numSplats", 0);
|
|
347
|
+
w(this, "positions");
|
|
348
|
+
w(this, "rotations");
|
|
349
|
+
w(this, "scales");
|
|
350
|
+
w(this, "colors");
|
|
351
|
+
w(this, "opacities");
|
|
352
|
+
w(this, "boundingBox", new be());
|
|
353
353
|
this.numSplats = e, this.allocateBuffers(e);
|
|
354
354
|
}
|
|
355
355
|
allocateBuffers(e) {
|
|
@@ -364,13 +364,13 @@ class rt {
|
|
|
364
364
|
* @param color Color
|
|
365
365
|
* @param opacity Opacity value
|
|
366
366
|
*/
|
|
367
|
-
setSplat(e, t,
|
|
367
|
+
setSplat(e, t, s, r, n, 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 c = e * 3, f = e * 4, g = e * 3, m = e * 3;
|
|
373
|
+
this.positions[c] = t.x, this.positions[c + 1] = t.y, this.positions[c + 2] = t.z, this.rotations[f] = s.x, this.rotations[f + 1] = s.y, this.rotations[f + 2] = s.z, this.rotations[f + 3] = s.w, this.scales[g] = r.x, this.scales[g + 1] = r.y, this.scales[g + 2] = r.z, this.colors[m] = n.r, this.colors[m + 1] = n.g, this.colors[m + 2] = n.b, this.opacities[e] = o;
|
|
374
374
|
}
|
|
375
375
|
/**
|
|
376
376
|
* Get a splat's data
|
|
@@ -382,29 +382,29 @@ class rt {
|
|
|
382
382
|
throw new Error(
|
|
383
383
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
384
384
|
);
|
|
385
|
-
const t = e * 3,
|
|
385
|
+
const t = e * 3, s = e * 4, r = e * 3, n = e * 3;
|
|
386
386
|
return {
|
|
387
|
-
position: new
|
|
387
|
+
position: new u.Vector3(
|
|
388
388
|
this.positions[t],
|
|
389
389
|
this.positions[t + 1],
|
|
390
390
|
this.positions[t + 2]
|
|
391
391
|
),
|
|
392
|
-
rotation: new
|
|
393
|
-
this.rotations[
|
|
394
|
-
this.rotations[
|
|
395
|
-
this.rotations[
|
|
396
|
-
this.rotations[
|
|
392
|
+
rotation: new u.Quaternion(
|
|
393
|
+
this.rotations[s],
|
|
394
|
+
this.rotations[s + 1],
|
|
395
|
+
this.rotations[s + 2],
|
|
396
|
+
this.rotations[s + 3]
|
|
397
397
|
),
|
|
398
398
|
// Convert log scale back to linear scale for external use
|
|
399
|
-
scale: new
|
|
400
|
-
Math.exp(this.scales[
|
|
401
|
-
Math.exp(this.scales[
|
|
402
|
-
Math.exp(this.scales[
|
|
399
|
+
scale: new u.Vector3(
|
|
400
|
+
Math.exp(this.scales[r]),
|
|
401
|
+
Math.exp(this.scales[r + 1]),
|
|
402
|
+
Math.exp(this.scales[r + 2])
|
|
403
403
|
),
|
|
404
|
-
color: new
|
|
405
|
-
this.colors[
|
|
406
|
-
this.colors[
|
|
407
|
-
this.colors[
|
|
404
|
+
color: new u.Color(
|
|
405
|
+
this.colors[n],
|
|
406
|
+
this.colors[n + 1],
|
|
407
|
+
this.colors[n + 2]
|
|
408
408
|
),
|
|
409
409
|
opacity: this.opacities[e]
|
|
410
410
|
};
|
|
@@ -415,13 +415,13 @@ class rt {
|
|
|
415
415
|
*/
|
|
416
416
|
calculateBoundingBox() {
|
|
417
417
|
this.boundingBox.reset();
|
|
418
|
-
const e = new
|
|
418
|
+
const e = new u.Vector3();
|
|
419
419
|
for (let t = 0; t < this.numSplats; t++) {
|
|
420
|
-
const
|
|
420
|
+
const s = t * 3;
|
|
421
421
|
e.set(
|
|
422
|
-
this.positions[
|
|
423
|
-
this.positions[
|
|
424
|
-
this.positions[
|
|
422
|
+
this.positions[s],
|
|
423
|
+
this.positions[s + 1],
|
|
424
|
+
this.positions[s + 2]
|
|
425
425
|
), this.boundingBox.expandByPoint(e);
|
|
426
426
|
}
|
|
427
427
|
return this.boundingBox;
|
|
@@ -431,97 +431,134 @@ class rt {
|
|
|
431
431
|
* This is for visualization/debugging purposes only, not for rendering
|
|
432
432
|
*/
|
|
433
433
|
createDebugGeometry() {
|
|
434
|
-
const e = new
|
|
434
|
+
const e = new u.BufferGeometry();
|
|
435
435
|
e.setAttribute(
|
|
436
436
|
"position",
|
|
437
|
-
new
|
|
437
|
+
new u.BufferAttribute(this.positions, 3)
|
|
438
438
|
);
|
|
439
|
-
const t = new Float32Array(this.numSplats * 3),
|
|
440
|
-
for (let
|
|
441
|
-
const o =
|
|
442
|
-
|
|
439
|
+
const t = new Float32Array(this.numSplats * 3), s = new u.Quaternion(), r = new u.Euler();
|
|
440
|
+
for (let n = 0; n < this.numSplats; n++) {
|
|
441
|
+
const o = n * 4, c = n * 3;
|
|
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
|
-
),
|
|
447
|
+
), r.setFromQuaternion(s), t[c] = r.x, t[c + 1] = r.y, t[c + 2] = r.z;
|
|
448
448
|
}
|
|
449
449
|
return e.setAttribute(
|
|
450
450
|
"rotation",
|
|
451
|
-
new
|
|
451
|
+
new u.BufferAttribute(t, 3)
|
|
452
452
|
), e.setAttribute(
|
|
453
453
|
"scale",
|
|
454
|
-
new
|
|
454
|
+
new u.BufferAttribute(this.scales, 3)
|
|
455
455
|
), e.setAttribute(
|
|
456
456
|
"color",
|
|
457
|
-
new
|
|
457
|
+
new u.BufferAttribute(this.colors, 3)
|
|
458
458
|
), e.setAttribute(
|
|
459
459
|
"opacity",
|
|
460
|
-
new
|
|
460
|
+
new u.BufferAttribute(this.opacities, 1)
|
|
461
461
|
), e;
|
|
462
462
|
}
|
|
463
463
|
dispose() {
|
|
464
464
|
this.numSplats = 0, this.scales = new Float32Array(0), this.colors = new Float32Array(0), this.positions = new Float32Array(0), this.rotations = new Float32Array(0), this.opacities = new Float32Array(0);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class
|
|
467
|
+
class Le {
|
|
468
|
+
// Upper 8 bits of 16-bit means
|
|
469
|
+
constructor(e, t, s) {
|
|
470
|
+
w(this, "ranges");
|
|
471
|
+
w(this, "version", 1);
|
|
472
|
+
w(this, "numSplats", 0);
|
|
473
|
+
w(this, "boundingBox", new be());
|
|
474
|
+
// Original SOGS textures
|
|
475
|
+
w(this, "sh0");
|
|
476
|
+
// SH DC coefficients + alpha
|
|
477
|
+
w(this, "quats");
|
|
478
|
+
// Quaternion components + mode
|
|
479
|
+
w(this, "scales");
|
|
480
|
+
// Scale values (8-bit)
|
|
481
|
+
w(this, "means_l");
|
|
482
|
+
// Lower 8 bits of 16-bit means
|
|
483
|
+
w(this, "means_u");
|
|
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
|
+
}
|
|
486
|
+
calculateBoundingBox() {
|
|
487
|
+
this.boundingBox.reset();
|
|
488
|
+
const { mins: e, maxs: t } = this.ranges.means, s = (r) => Math.sign(r) * (Math.exp(Math.abs(r)) - 1);
|
|
489
|
+
return this.boundingBox.center.set(
|
|
490
|
+
(s(e[0]) + s(t[0])) * 0.5,
|
|
491
|
+
(s(e[1]) + s(t[1])) * 0.5,
|
|
492
|
+
(s(e[2]) + s(t[2])) * 0.5
|
|
493
|
+
), this.boundingBox.halfExtents.set(
|
|
494
|
+
(s(t[0]) - s(e[0])) * 0.5,
|
|
495
|
+
(s(t[1]) - s(e[1])) * 0.5,
|
|
496
|
+
(s(t[2]) - s(e[2])) * 0.5
|
|
497
|
+
), this.boundingBox;
|
|
498
|
+
}
|
|
499
|
+
dispose() {
|
|
500
|
+
this.sh0.dispose(), this.quats.dispose(), this.scales.dispose(), this.means_l.dispose(), this.means_u.dispose();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
class We {
|
|
468
504
|
// Upper 8 bits of 16-bit means
|
|
469
|
-
constructor(e, t,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
505
|
+
constructor(e, t, s) {
|
|
506
|
+
w(this, "ranges");
|
|
507
|
+
w(this, "version", 2);
|
|
508
|
+
w(this, "numSplats", 0);
|
|
509
|
+
w(this, "boundingBox", new be());
|
|
473
510
|
// Original SOGS textures
|
|
474
|
-
|
|
511
|
+
w(this, "sh0");
|
|
475
512
|
// SH DC coefficients + alpha
|
|
476
|
-
|
|
513
|
+
w(this, "quats");
|
|
477
514
|
// Quaternion components + mode
|
|
478
|
-
|
|
515
|
+
w(this, "scales");
|
|
479
516
|
// Scale values (8-bit)
|
|
480
|
-
|
|
517
|
+
w(this, "means_l");
|
|
481
518
|
// Lower 8 bits of 16-bit means
|
|
482
|
-
|
|
483
|
-
this.ranges = t, this.numSplats = e, this.sh0 =
|
|
519
|
+
w(this, "means_u");
|
|
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();
|
|
484
521
|
}
|
|
485
522
|
calculateBoundingBox() {
|
|
486
523
|
this.boundingBox.reset();
|
|
487
|
-
const { mins: e, maxs: t } = this.ranges.means,
|
|
524
|
+
const { mins: e, maxs: t } = this.ranges.means, s = (r) => Math.sign(r) * (Math.exp(Math.abs(r)) - 1);
|
|
488
525
|
return this.boundingBox.center.set(
|
|
489
|
-
(
|
|
490
|
-
(
|
|
491
|
-
(
|
|
526
|
+
(s(e[0]) + s(t[0])) * 0.5,
|
|
527
|
+
(s(e[1]) + s(t[1])) * 0.5,
|
|
528
|
+
(s(e[2]) + s(t[2])) * 0.5
|
|
492
529
|
), this.boundingBox.halfExtents.set(
|
|
493
|
-
(
|
|
494
|
-
(
|
|
495
|
-
(
|
|
530
|
+
(s(t[0]) - s(e[0])) * 0.5,
|
|
531
|
+
(s(t[1]) - s(e[1])) * 0.5,
|
|
532
|
+
(s(t[2]) - s(e[2])) * 0.5
|
|
496
533
|
), this.boundingBox;
|
|
497
534
|
}
|
|
498
535
|
dispose() {
|
|
499
536
|
this.sh0.dispose(), this.quats.dispose(), this.scales.dispose(), this.means_l.dispose(), this.means_u.dispose();
|
|
500
537
|
}
|
|
501
538
|
}
|
|
502
|
-
class
|
|
539
|
+
class Ie {
|
|
503
540
|
// RGBA32UI - (Position + Rotation + Scale)
|
|
504
541
|
// RGBA32UI Texture Content:
|
|
505
542
|
// .r = Means Lower (RGB)
|
|
506
543
|
// .g = Means Upper (RGB)
|
|
507
544
|
// .b = Rotation (RGBA)
|
|
508
545
|
// .a = Scale (RGB)
|
|
509
|
-
constructor(e, t,
|
|
546
|
+
constructor(e, t, s, r, n, o, c, f) {
|
|
510
547
|
// Info data - cpu
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
548
|
+
w(this, "numSplats");
|
|
549
|
+
w(this, "textureWidth");
|
|
550
|
+
w(this, "textureHeight");
|
|
551
|
+
w(this, "ranges");
|
|
552
|
+
w(this, "centers");
|
|
516
553
|
// TODO: see if necesary or can be compressed somehow
|
|
517
|
-
|
|
554
|
+
w(this, "boundingBox");
|
|
518
555
|
// GPU Textures
|
|
519
|
-
|
|
556
|
+
w(this, "packedColor");
|
|
520
557
|
// RGBA8 - (Color + Opacity)
|
|
521
558
|
// RGBA8 Texture Content:
|
|
522
559
|
// .rgb = Color, .a = Opacity
|
|
523
|
-
|
|
524
|
-
this.numSplats = e, this.textureWidth = t, this.textureHeight =
|
|
560
|
+
w(this, "packedGeometry");
|
|
561
|
+
this.numSplats = e, this.textureWidth = t, this.textureHeight = s, this.boundingBox = f, this.ranges = c, this.centers = r, this.packedColor = o, this.packedGeometry = n;
|
|
525
562
|
}
|
|
526
563
|
/**
|
|
527
564
|
* Optional: Reconstruct a full JS object for a specific splat.
|
|
@@ -536,31 +573,31 @@ class qe {
|
|
|
536
573
|
// public abstract deserialize(): ISplat;
|
|
537
574
|
// public abstract returnPacked(): ISplat;
|
|
538
575
|
}
|
|
539
|
-
const
|
|
540
|
-
class
|
|
576
|
+
const de = 0.28209479177387814;
|
|
577
|
+
class we {
|
|
541
578
|
/**
|
|
542
579
|
* Packs PLY data (Float32) into the Unified SOGS-like Format.
|
|
543
580
|
*/
|
|
544
581
|
// prettier-ignore
|
|
545
582
|
static packPly(e) {
|
|
546
|
-
const t = e.numSplats,
|
|
583
|
+
const t = e.numSplats, s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s), n = s * r, { ranges: o, colorScale: c } = this.calculatePlyRanges(e), f = new Uint32Array(n * 4), g = new Uint8Array(n * 4), m = new u.Quaternion();
|
|
547
584
|
for (let l = 0; l < t; l++) {
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
let
|
|
551
|
-
const
|
|
552
|
-
let
|
|
553
|
-
|
|
554
|
-
let
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
|
|
585
|
+
const h = l * 4, p = l * 3, v = l * 4, C = e.positions[p + 0], k = e.positions[p + 1], B = e.positions[p + 2], U = this.clamp01(this.norm(C, o.means.min.x, o.means.max.x)), F = this.clamp01(this.norm(k, o.means.min.y, o.means.max.y)), N = this.clamp01(this.norm(B, o.means.min.z, o.means.max.z)), W = U * 65535 | 0, T = F * 65535 | 0, S = N * 65535 | 0;
|
|
586
|
+
f[h + 0] = this.pack4Bytes(W & 255, T & 255, S & 255, 0), f[h + 1] = this.pack4Bytes(W >> 8, T >> 8, S >> 8, 0), m.set(e.rotations[v], e.rotations[v + 1], e.rotations[v + 2], e.rotations[v + 3]).normalize();
|
|
587
|
+
let z = m.w, E = m.x, y = m.y, b = m.z;
|
|
588
|
+
const j = Math.abs(z), L = Math.abs(E), I = Math.abs(y), D = Math.abs(b);
|
|
589
|
+
let x = 0, _ = j;
|
|
590
|
+
L > _ && (_ = L, x = 1), I > _ && (_ = I, x = 2), D > _ && (_ = D, x = 3), (x === 0 ? z : x === 1 ? E : x === 2 ? y : b) < 0 && (z = -z, E = -E, y = -y, b = -b);
|
|
591
|
+
let $ = 0, i = 0, A = 0;
|
|
592
|
+
x === 0 && ($ = E, i = y, A = b), x === 1 && ($ = z, i = y, A = b), x === 2 && ($ = z, i = E, A = b), x === 3 && ($ = z, i = E, A = y);
|
|
593
|
+
const q = (te) => Math.min(255, Math.max(0, Math.round((0.5 + te / Math.SQRT2) * 255)));
|
|
594
|
+
f[h + 2] = this.pack4Bytes(q($), q(i), q(A), x);
|
|
595
|
+
const O = this.norm(e.scales[p + 0], o.scales.min.x, o.scales.max.x), R = this.norm(e.scales[p + 1], o.scales.min.y, o.scales.max.y), d = this.norm(e.scales[p + 2], o.scales.min.z, o.scales.max.z);
|
|
596
|
+
f[h + 3] = this.pack4Bytes(Math.floor(O * 255), Math.floor(R * 255), Math.floor(d * 255), 0);
|
|
597
|
+
const P = this.clamp01(e.colors[p + 0] * c), G = this.clamp01(e.colors[p + 1] * c), M = this.clamp01(e.colors[p + 2] * c), V = (P - 0.5) / de, H = (G - 0.5) / de, Z = (M - 0.5) / de, Q = this.clamp01(this.norm(V, o.sh0.min.x, o.sh0.max.x)), J = this.clamp01(this.norm(H, o.sh0.min.y, o.sh0.max.y)), K = this.clamp01(this.norm(Z, o.sh0.min.z, o.sh0.max.z)), ee = this.clamp01(e.opacities[l]);
|
|
598
|
+
g[h + 0] = Math.round(Q * 255), g[h + 1] = Math.round(J * 255), g[h + 2] = Math.round(K * 255), g[h + 3] = Math.round(ee * 255);
|
|
562
599
|
}
|
|
563
|
-
return new
|
|
600
|
+
return new Ie(t, s, r, e.positions, f, g, o, e.boundingBox);
|
|
564
601
|
}
|
|
565
602
|
/**
|
|
566
603
|
* Packs SOGS data.
|
|
@@ -569,46 +606,122 @@ class Ce {
|
|
|
569
606
|
*/
|
|
570
607
|
// prettier-ignore
|
|
571
608
|
static packSogs(e) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
609
|
+
var y, b, j;
|
|
610
|
+
const t = e.numSplats;
|
|
611
|
+
let s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s);
|
|
612
|
+
const n = ((y = e.means_l) == null ? void 0 : y.image) ?? ((b = e.sh0) == null ? void 0 : b.image) ?? ((j = e.quats) == null ? void 0 : j.image);
|
|
613
|
+
n && typeof n.width == "number" && typeof n.height == "number" && (s = n.width, r = n.height);
|
|
614
|
+
const o = s * r;
|
|
615
|
+
if (o < t) throw new Error(`SOG v1 texture too small: ${s}x${r}=${o} < count=${t}`);
|
|
616
|
+
const c = this.convertSogsRanges(e.ranges), f = e.ranges.means.mins[0], g = e.ranges.means.mins[1], m = e.ranges.means.mins[2], l = e.ranges.means.maxs[0], h = e.ranges.means.maxs[1], p = e.ranges.means.maxs[2], v = (L) => Math.sign(L) * (Math.exp(Math.abs(L)) - 1), C = new u.Vector3(
|
|
617
|
+
v(f),
|
|
618
|
+
v(g),
|
|
619
|
+
v(m)
|
|
620
|
+
), k = new u.Vector3(
|
|
621
|
+
v(l),
|
|
622
|
+
v(h),
|
|
623
|
+
v(p)
|
|
580
624
|
);
|
|
581
|
-
|
|
582
|
-
const
|
|
583
|
-
for (let
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
const
|
|
591
|
-
|
|
625
|
+
c.means.min.copy(C), c.means.max.copy(k);
|
|
626
|
+
const B = e, U = this.getPixels(B.means_l), F = this.getPixels(B.means_u), N = this.getPixels(B.quats), W = this.getPixels(B.scales), T = this.getPixels(B.sh0), S = new Uint32Array(o * 4), z = new Uint8Array(o * 4), E = new Float32Array(t * 3);
|
|
627
|
+
for (let L = 0; L < t; L++) {
|
|
628
|
+
const I = L * 4, D = F[I + 0], x = U[I + 0], _ = F[I + 1], X = U[I + 1], $ = F[I + 2], i = U[I + 2], A = (D << 8 | x) / 65535, q = (_ << 8 | X) / 65535, O = ($ << 8 | i) / 65535, R = this.sogsDecode(A, f, l), d = this.sogsDecode(q, g, h), P = this.sogsDecode(O, m, p);
|
|
629
|
+
E[L * 3 + 0] = R, E[L * 3 + 1] = d, E[L * 3 + 2] = P;
|
|
630
|
+
const G = this.clamp01(this.norm(R, C.x, k.x)) * 65535 | 0, M = this.clamp01(this.norm(d, C.y, k.y)) * 65535 | 0, V = this.clamp01(this.norm(P, C.z, k.z)) * 65535 | 0;
|
|
631
|
+
S[I + 0] = this.pack4Bytes(G & 255, M & 255, V & 255, 0), S[I + 1] = this.pack4Bytes(G >> 8, M >> 8, V >> 8, 0), S[I + 3] = this.pack4Bytes(W[I], W[I + 1], W[I + 2], 0);
|
|
632
|
+
const Z = N[I + 3] - 252;
|
|
633
|
+
S[I + 2] = this.pack4Bytes(N[I + 0], N[I + 1], N[I + 2], Z), z[I + 0] = T[I], z[I + 1] = T[I + 1], z[I + 2] = T[I + 2];
|
|
634
|
+
const Q = T[I + 3] / 255, J = e.ranges.sh0.mins[3] + (e.ranges.sh0.maxs[3] - e.ranges.sh0.mins[3]) * Q, K = 1 / (1 + Math.exp(-J));
|
|
635
|
+
z[I + 3] = Math.round(Math.max(0, Math.min(1, K)) * 255);
|
|
636
|
+
}
|
|
637
|
+
return new Ie(t, s, r, E, S, z, c, e.boundingBox);
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Packs SOG V2 data.
|
|
641
|
+
*/
|
|
642
|
+
static packSog2(e) {
|
|
643
|
+
var j, L, I;
|
|
644
|
+
const t = e.numSplats;
|
|
645
|
+
let s = Math.ceil(Math.sqrt(t)), r = Math.ceil(t / s);
|
|
646
|
+
const n = ((j = e.means_l) == null ? void 0 : j.image) ?? ((L = e.sh0) == null ? void 0 : L.image) ?? ((I = e.quats) == null ? void 0 : I.image);
|
|
647
|
+
n && typeof n.width == "number" && typeof n.height == "number" && (s = n.width, r = n.height);
|
|
648
|
+
const o = s * r;
|
|
649
|
+
if (o < t) throw new Error(`SOG v2 texture too small: ${s}x${r}=${o} < count=${t}`);
|
|
650
|
+
const c = e.ranges.means.mins[0], f = e.ranges.means.mins[1], g = e.ranges.means.mins[2], m = e.ranges.means.maxs[0], l = e.ranges.means.maxs[1], h = e.ranges.means.maxs[2], p = (D) => Math.sign(D) * (Math.exp(Math.abs(D)) - 1), v = new u.Vector3(
|
|
651
|
+
p(c),
|
|
652
|
+
p(f),
|
|
653
|
+
p(g)
|
|
654
|
+
), C = new u.Vector3(
|
|
655
|
+
p(m),
|
|
656
|
+
p(l),
|
|
657
|
+
p(h)
|
|
658
|
+
), k = (D) => {
|
|
659
|
+
let x = 1 / 0, _ = -1 / 0;
|
|
660
|
+
for (const i of D)
|
|
661
|
+
Number.isFinite(i) && (x = Math.min(x, i), _ = Math.max(_, i));
|
|
662
|
+
(!Number.isFinite(x) || !Number.isFinite(_)) && (x = 0, _ = 1);
|
|
663
|
+
const X = _ - x || 1, $ = new Uint8Array(256);
|
|
664
|
+
for (let i = 0; i < 256; i++) {
|
|
665
|
+
const q = ((i < D.length && Number.isFinite(D[i]) ? D[i] : x + (_ - x) * (i / 255)) - x) / X, O = Math.max(0, Math.min(255, Math.round(q * 255)));
|
|
666
|
+
$[i] = O;
|
|
667
|
+
}
|
|
668
|
+
return { cbMin: x, cbMax: _, lut: $ };
|
|
669
|
+
}, B = k(e.ranges.scales.codebook), U = k(e.ranges.sh0.codebook), F = {
|
|
670
|
+
means: { min: v.clone(), max: C.clone() },
|
|
671
|
+
scales: {
|
|
672
|
+
min: new u.Vector3(
|
|
673
|
+
B.cbMin,
|
|
674
|
+
B.cbMin,
|
|
675
|
+
B.cbMin
|
|
676
|
+
),
|
|
677
|
+
max: new u.Vector3(
|
|
678
|
+
B.cbMax,
|
|
679
|
+
B.cbMax,
|
|
680
|
+
B.cbMax
|
|
681
|
+
)
|
|
682
|
+
},
|
|
683
|
+
sh0: {
|
|
684
|
+
min: new u.Vector3(
|
|
685
|
+
U.cbMin,
|
|
686
|
+
U.cbMin,
|
|
687
|
+
U.cbMin
|
|
688
|
+
),
|
|
689
|
+
max: new u.Vector3(
|
|
690
|
+
U.cbMax,
|
|
691
|
+
U.cbMax,
|
|
692
|
+
U.cbMax
|
|
693
|
+
)
|
|
694
|
+
}
|
|
695
|
+
}, N = this.getPixels(e.means_l), W = this.getPixels(e.means_u), T = this.getPixels(e.quats), S = this.getPixels(e.scales), z = this.getPixels(e.sh0), E = new Uint32Array(o * 4), y = new Uint8Array(o * 4), b = new Float32Array(t * 3);
|
|
696
|
+
for (let D = 0; D < t; D++) {
|
|
697
|
+
const x = D * 4, _ = W[x + 0], X = N[x + 0], $ = W[x + 1], i = N[x + 1], A = W[x + 2], q = N[x + 2], O = (_ << 8 | X) / 65535, R = ($ << 8 | i) / 65535, d = (A << 8 | q) / 65535, P = this.sogsDecode(O, c, m), G = this.sogsDecode(R, f, l), M = this.sogsDecode(d, g, h);
|
|
698
|
+
b[D * 3 + 0] = P, b[D * 3 + 1] = G, b[D * 3 + 2] = M;
|
|
699
|
+
const V = this.clamp01(this.norm(P, v.x, C.x)) * 65535 | 0, H = this.clamp01(this.norm(G, v.y, C.y)) * 65535 | 0, Z = this.clamp01(this.norm(M, v.z, C.z)) * 65535 | 0;
|
|
700
|
+
E[x + 0] = this.pack4Bytes(V & 255, H & 255, Z & 255, 0), E[x + 1] = this.pack4Bytes(V >> 8, H >> 8, Z >> 8, 0);
|
|
701
|
+
const J = T[x + 3] - 252 & 3;
|
|
702
|
+
E[x + 2] = this.pack4Bytes(T[x + 0], T[x + 1], T[x + 2], J);
|
|
703
|
+
const K = B.lut[S[x + 0]], ee = B.lut[S[x + 1]], te = B.lut[S[x + 2]];
|
|
704
|
+
E[x + 3] = this.pack4Bytes(K, ee, te, 0), y[x + 0] = U.lut[z[x + 0]], y[x + 1] = U.lut[z[x + 1]], y[x + 2] = U.lut[z[x + 2]], y[x + 3] = z[x + 3];
|
|
592
705
|
}
|
|
593
|
-
return new
|
|
706
|
+
return new Ie(t, s, r, b, E, y, F, e.boundingBox);
|
|
594
707
|
}
|
|
595
708
|
// --- Helpers ---
|
|
596
709
|
// prettier-ignore
|
|
597
|
-
static pack4Bytes(e, t,
|
|
598
|
-
return (e & 255) << 24 | (t & 255) << 16 | (
|
|
710
|
+
static pack4Bytes(e, t, s, r) {
|
|
711
|
+
return (e & 255) << 24 | (t & 255) << 16 | (s & 255) << 8 | r & 255;
|
|
599
712
|
}
|
|
600
713
|
// prettier-ignore
|
|
601
714
|
static getPixels(e) {
|
|
602
|
-
const t = e.image,
|
|
715
|
+
const t = e.image, s = t.width, r = t.height;
|
|
603
716
|
if (t.data && (t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray)) return new Uint8Array(t.data);
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
const o =
|
|
717
|
+
const n = document.createElement("canvas");
|
|
718
|
+
n.width = s, n.height = r;
|
|
719
|
+
const o = n.getContext("2d", { willReadFrequently: !0 });
|
|
607
720
|
if (!o) throw new Error("Canvas init failed");
|
|
608
|
-
return o.drawImage(t, 0, 0), new Uint8Array(o.getImageData(0, 0,
|
|
721
|
+
return o.drawImage(t, 0, 0), new Uint8Array(o.getImageData(0, 0, s, r).data);
|
|
609
722
|
}
|
|
610
723
|
static convertSogsRanges(e) {
|
|
611
|
-
const t = (
|
|
724
|
+
const t = (s) => new u.Vector3(s[0], s[1], s[2]);
|
|
612
725
|
return {
|
|
613
726
|
sh0: { min: t(e.sh0.mins), max: t(e.sh0.maxs) },
|
|
614
727
|
means: { min: t(e.means.mins), max: t(e.means.maxs) },
|
|
@@ -616,28 +729,28 @@ class Ce {
|
|
|
616
729
|
};
|
|
617
730
|
}
|
|
618
731
|
static calculatePlyRanges(e) {
|
|
619
|
-
const t = new
|
|
620
|
-
let
|
|
621
|
-
for (let
|
|
622
|
-
const l =
|
|
623
|
-
t.x = Math.min(t.x,
|
|
624
|
-
|
|
732
|
+
const t = new u.Vector3(1 / 0, 1 / 0, 1 / 0), s = new u.Vector3(-1 / 0, -1 / 0, -1 / 0), r = new u.Vector3(1 / 0, 1 / 0, 1 / 0), n = new u.Vector3(-1 / 0, -1 / 0, -1 / 0), o = new u.Vector3(1 / 0, 1 / 0, 1 / 0), c = new u.Vector3(-1 / 0, -1 / 0, -1 / 0);
|
|
733
|
+
let f = 0;
|
|
734
|
+
for (let m = 0; m < e.numSplats; m++) {
|
|
735
|
+
const l = m * 3, h = e.positions[l + 0], p = e.positions[l + 1], v = e.positions[l + 2];
|
|
736
|
+
t.x = Math.min(t.x, h), s.x = Math.max(s.x, h), t.y = Math.min(t.y, p), s.y = Math.max(s.y, p), t.z = Math.min(t.z, v), s.z = Math.max(s.z, v), r.x = Math.min(r.x, e.scales[l]), n.x = Math.max(n.x, e.scales[l]), r.y = Math.min(r.y, e.scales[l + 1]), n.y = Math.max(n.y, e.scales[l + 1]), r.z = Math.min(r.z, e.scales[l + 2]), n.z = Math.max(n.z, e.scales[l + 2]), f = Math.max(
|
|
737
|
+
f,
|
|
625
738
|
e.colors[l],
|
|
626
739
|
e.colors[l + 1],
|
|
627
740
|
e.colors[l + 2]
|
|
628
741
|
);
|
|
629
742
|
}
|
|
630
|
-
const
|
|
631
|
-
for (let
|
|
632
|
-
const l =
|
|
633
|
-
o.x = Math.min(o.x,
|
|
743
|
+
const g = f > 1.5 ? 1 / 255 : 1;
|
|
744
|
+
for (let m = 0; m < e.numSplats; m++) {
|
|
745
|
+
const l = m * 3, h = this.clamp01(e.colors[l + 0] * g), p = this.clamp01(e.colors[l + 1] * g), v = this.clamp01(e.colors[l + 2] * g), C = (h - 0.5) / de, k = (p - 0.5) / de, B = (v - 0.5) / de;
|
|
746
|
+
o.x = Math.min(o.x, C), c.x = Math.max(c.x, C), o.y = Math.min(o.y, k), c.y = Math.max(c.y, k), o.z = Math.min(o.z, B), c.z = Math.max(c.z, B);
|
|
634
747
|
}
|
|
635
748
|
return {
|
|
636
|
-
colorScale:
|
|
749
|
+
colorScale: g,
|
|
637
750
|
ranges: {
|
|
638
|
-
sh0: { min: o, max:
|
|
639
|
-
means: { min: t, max:
|
|
640
|
-
scales: { min:
|
|
751
|
+
sh0: { min: o, max: c },
|
|
752
|
+
means: { min: t, max: s },
|
|
753
|
+
scales: { min: r, max: n }
|
|
641
754
|
}
|
|
642
755
|
};
|
|
643
756
|
}
|
|
@@ -647,49 +760,49 @@ class Ce {
|
|
|
647
760
|
// prettier-ignore
|
|
648
761
|
// private static lerp(a: number, b: number, t: number) { return a + (b - a) * t; } // prettier-ignore
|
|
649
762
|
// private static invSogsMap(v: number) { return Math.sign(v) * Math.log(Math.abs(v) + 1) } // prettier-ignore
|
|
650
|
-
static norm(e, t,
|
|
651
|
-
return (e - t) / (
|
|
763
|
+
static norm(e, t, s) {
|
|
764
|
+
return (e - t) / (s - t || 1);
|
|
652
765
|
}
|
|
653
766
|
// prettier-ignore
|
|
654
|
-
static sogsDecode(e, t,
|
|
655
|
-
const
|
|
656
|
-
return Math.sign(
|
|
767
|
+
static sogsDecode(e, t, s) {
|
|
768
|
+
const r = t + (s - t) * e;
|
|
769
|
+
return Math.sign(r) * (Math.exp(Math.abs(r)) - 1);
|
|
657
770
|
}
|
|
658
771
|
}
|
|
659
|
-
class
|
|
772
|
+
class lt extends u.Loader {
|
|
660
773
|
constructor(t) {
|
|
661
774
|
super(t);
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
775
|
+
w(this, "requestId", 0);
|
|
776
|
+
w(this, "worker");
|
|
777
|
+
w(this, "pendingCallbacks", /* @__PURE__ */ new Map());
|
|
665
778
|
this.withCredentials = !0;
|
|
666
|
-
const
|
|
667
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
779
|
+
const s = this.createWorkerCode(), r = new Blob([s], { type: "application/javascript" });
|
|
780
|
+
this.worker = new Worker(URL.createObjectURL(r)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
668
781
|
}
|
|
669
782
|
/**
|
|
670
783
|
* Handles messages received from the parsing worker
|
|
671
784
|
* @param event The message event from the worker
|
|
672
785
|
*/
|
|
673
786
|
onWorkerMessage(t) {
|
|
674
|
-
const { requestId:
|
|
675
|
-
if (!o) return console.warn(`PlyLoader: Received response for unknown request ${
|
|
676
|
-
if (this.pendingCallbacks.delete(
|
|
677
|
-
if (!
|
|
787
|
+
const { requestId: s, error: r, result: n } = t.data, o = this.pendingCallbacks.get(s);
|
|
788
|
+
if (!o) return console.warn(`PlyLoader: Received response for unknown request ${s}`);
|
|
789
|
+
if (this.pendingCallbacks.delete(s), r) return o.reject(new Error(r));
|
|
790
|
+
if (!n) return o.reject(new Error("Worker returned no result"));
|
|
678
791
|
try {
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
792
|
+
const c = new ct(0);
|
|
793
|
+
c.numSplats = n.numSplats, c.positions = new Float32Array(n.positions), c.rotations = new Float32Array(n.rotations), c.scales = new Float32Array(n.scales), c.colors = new Float32Array(n.colors), c.opacities = new Float32Array(n.opacities), c.boundingBox.min.set(
|
|
794
|
+
n.boundingBox.minX,
|
|
795
|
+
n.boundingBox.minY,
|
|
796
|
+
n.boundingBox.minZ
|
|
797
|
+
), c.boundingBox.max.set(
|
|
798
|
+
n.boundingBox.maxX,
|
|
799
|
+
n.boundingBox.maxY,
|
|
800
|
+
n.boundingBox.maxZ
|
|
688
801
|
), this.worker.terminate();
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
} catch (
|
|
692
|
-
o.reject(
|
|
802
|
+
const f = we.packPly(c);
|
|
803
|
+
c.dispose(), o.resolve(f);
|
|
804
|
+
} catch (c) {
|
|
805
|
+
o.reject(c);
|
|
693
806
|
}
|
|
694
807
|
}
|
|
695
808
|
/**
|
|
@@ -699,19 +812,19 @@ class st extends h.Loader {
|
|
|
699
812
|
* @param onProgress Optional progress callback
|
|
700
813
|
* @param onError Optional error callback
|
|
701
814
|
*/
|
|
702
|
-
load(t,
|
|
703
|
-
const o = new
|
|
815
|
+
load(t, s, r, n) {
|
|
816
|
+
const o = new u.FileLoader(this.manager);
|
|
704
817
|
o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
|
|
705
818
|
t,
|
|
706
|
-
(
|
|
707
|
-
this.parseAsync(
|
|
708
|
-
|
|
709
|
-
}).catch((
|
|
710
|
-
|
|
819
|
+
(c) => {
|
|
820
|
+
this.parseAsync(c).then((f) => {
|
|
821
|
+
s && s(f);
|
|
822
|
+
}).catch((f) => {
|
|
823
|
+
n ? n(f) : console.error(f), this.manager.itemError(t);
|
|
711
824
|
});
|
|
712
825
|
},
|
|
713
|
-
|
|
714
|
-
|
|
826
|
+
r,
|
|
827
|
+
n
|
|
715
828
|
);
|
|
716
829
|
}
|
|
717
830
|
/**
|
|
@@ -720,19 +833,19 @@ class st extends h.Loader {
|
|
|
720
833
|
* @param onProgress Optional progress callback
|
|
721
834
|
* @returns A Promise that resolves with the parsed SplatData
|
|
722
835
|
*/
|
|
723
|
-
loadAsync(t,
|
|
724
|
-
return new Promise((
|
|
725
|
-
const o = new
|
|
836
|
+
loadAsync(t, s) {
|
|
837
|
+
return new Promise((r, n) => {
|
|
838
|
+
const o = new u.FileLoader(this.manager);
|
|
726
839
|
o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setPath(this.path), o.setWithCredentials(this.withCredentials), o.load(
|
|
727
840
|
t,
|
|
728
|
-
(
|
|
729
|
-
this.parseAsync(
|
|
730
|
-
|
|
841
|
+
(c) => {
|
|
842
|
+
this.parseAsync(c).then(r).catch((f) => {
|
|
843
|
+
n(f), this.manager.itemError(t);
|
|
731
844
|
});
|
|
732
845
|
},
|
|
733
|
-
|
|
734
|
-
(
|
|
735
|
-
|
|
846
|
+
s,
|
|
847
|
+
(c) => {
|
|
848
|
+
n(c), this.manager.itemError(t);
|
|
736
849
|
}
|
|
737
850
|
);
|
|
738
851
|
});
|
|
@@ -743,11 +856,11 @@ class st extends h.Loader {
|
|
|
743
856
|
* @returns Promise that resolves with parsed SplatData
|
|
744
857
|
*/
|
|
745
858
|
parseAsync(t) {
|
|
746
|
-
return new Promise((
|
|
747
|
-
const
|
|
748
|
-
this.pendingCallbacks.set(
|
|
859
|
+
return new Promise((s, r) => {
|
|
860
|
+
const n = this.requestId++;
|
|
861
|
+
this.pendingCallbacks.set(n, { resolve: s, reject: r });
|
|
749
862
|
const o = {
|
|
750
|
-
requestId:
|
|
863
|
+
requestId: n,
|
|
751
864
|
buffer: t
|
|
752
865
|
};
|
|
753
866
|
this.worker.postMessage(o, [t]);
|
|
@@ -765,203 +878,203 @@ class st extends h.Loader {
|
|
|
765
878
|
*/
|
|
766
879
|
createWorkerCode() {
|
|
767
880
|
return `(${(function() {
|
|
768
|
-
self.onmessage = (
|
|
769
|
-
const { requestId:
|
|
881
|
+
self.onmessage = (r) => {
|
|
882
|
+
const { requestId: n, buffer: o } = r.data;
|
|
770
883
|
try {
|
|
771
|
-
const
|
|
772
|
-
requestId:
|
|
773
|
-
result:
|
|
884
|
+
const c = s(o), f = {
|
|
885
|
+
requestId: n,
|
|
886
|
+
result: c
|
|
774
887
|
};
|
|
775
|
-
self.postMessage(
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
888
|
+
self.postMessage(f, [
|
|
889
|
+
c.positions,
|
|
890
|
+
c.rotations,
|
|
891
|
+
c.scales,
|
|
892
|
+
c.colors,
|
|
893
|
+
c.opacities
|
|
781
894
|
]);
|
|
782
|
-
} catch (
|
|
783
|
-
const
|
|
784
|
-
requestId:
|
|
785
|
-
error:
|
|
895
|
+
} catch (c) {
|
|
896
|
+
const f = {
|
|
897
|
+
requestId: n,
|
|
898
|
+
error: c instanceof Error ? c.message : String(c)
|
|
786
899
|
};
|
|
787
|
-
self.postMessage(
|
|
900
|
+
self.postMessage(f);
|
|
788
901
|
}
|
|
789
902
|
};
|
|
790
|
-
function r
|
|
791
|
-
const
|
|
903
|
+
function s(r) {
|
|
904
|
+
const n = new TextDecoder(), o = new Uint8Array(r), c = [112, 108, 121, 10], f = `
|
|
792
905
|
end_header
|
|
793
906
|
`;
|
|
794
|
-
for (let
|
|
795
|
-
if (o[
|
|
907
|
+
for (let R = 0; R < c.length; R++)
|
|
908
|
+
if (o[R] !== c[R])
|
|
796
909
|
throw new Error(
|
|
797
910
|
"Invalid PLY file: Missing magic bytes"
|
|
798
911
|
);
|
|
799
|
-
let
|
|
800
|
-
for (let
|
|
912
|
+
let g = 0;
|
|
913
|
+
for (let R = 0; R < o.length - f.length; R++) {
|
|
801
914
|
let d = !0;
|
|
802
|
-
for (let
|
|
803
|
-
if (o[
|
|
915
|
+
for (let P = 0; P < f.length; P++)
|
|
916
|
+
if (o[R + P] !== f.charCodeAt(P)) {
|
|
804
917
|
d = !1;
|
|
805
918
|
break;
|
|
806
919
|
}
|
|
807
920
|
if (d) {
|
|
808
|
-
|
|
921
|
+
g = R + f.length;
|
|
809
922
|
break;
|
|
810
923
|
}
|
|
811
924
|
}
|
|
812
|
-
if (
|
|
925
|
+
if (g === 0)
|
|
813
926
|
throw new Error(
|
|
814
927
|
"Invalid PLY file: Could not find end of header"
|
|
815
928
|
);
|
|
816
|
-
const l =
|
|
817
|
-
o.subarray(0,
|
|
929
|
+
const l = n.decode(
|
|
930
|
+
o.subarray(0, g)
|
|
818
931
|
).split(`
|
|
819
|
-
`),
|
|
820
|
-
let
|
|
821
|
-
for (let
|
|
822
|
-
const d = l[
|
|
932
|
+
`), h = [];
|
|
933
|
+
let p = null;
|
|
934
|
+
for (let R = 1; R < l.length; R++) {
|
|
935
|
+
const d = l[R].trim();
|
|
823
936
|
if (d === "" || d === "end_header") continue;
|
|
824
|
-
const
|
|
825
|
-
switch (
|
|
937
|
+
const P = d.split(" ");
|
|
938
|
+
switch (P[0]) {
|
|
826
939
|
case "format":
|
|
827
|
-
|
|
940
|
+
p = P[1];
|
|
828
941
|
break;
|
|
829
942
|
case "element":
|
|
830
|
-
|
|
831
|
-
name:
|
|
832
|
-
count: parseInt(
|
|
943
|
+
h.push({
|
|
944
|
+
name: P[1],
|
|
945
|
+
count: parseInt(P[2], 10),
|
|
833
946
|
properties: []
|
|
834
947
|
});
|
|
835
948
|
break;
|
|
836
949
|
case "property":
|
|
837
|
-
if (
|
|
950
|
+
if (h.length === 0)
|
|
838
951
|
throw new Error(
|
|
839
952
|
"Invalid PLY file: Property without element"
|
|
840
953
|
);
|
|
841
|
-
|
|
842
|
-
type:
|
|
843
|
-
name:
|
|
954
|
+
h[h.length - 1].properties.push({
|
|
955
|
+
type: P[1],
|
|
956
|
+
name: P[2]
|
|
844
957
|
});
|
|
845
958
|
break;
|
|
846
959
|
}
|
|
847
960
|
}
|
|
848
|
-
if (
|
|
849
|
-
throw new Error(`Unsupported PLY format: ${
|
|
850
|
-
const
|
|
851
|
-
if (!
|
|
961
|
+
if (p !== "binary_little_endian")
|
|
962
|
+
throw new Error(`Unsupported PLY format: ${p}`);
|
|
963
|
+
const v = h.find((R) => R.name === "vertex");
|
|
964
|
+
if (!v)
|
|
852
965
|
throw new Error(
|
|
853
966
|
"Invalid PLY file: No vertex element found"
|
|
854
967
|
);
|
|
855
|
-
const
|
|
856
|
-
let
|
|
857
|
-
const
|
|
858
|
-
(d) => d.name ===
|
|
859
|
-
),
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
], q = [
|
|
865
|
-
C("scale_0"),
|
|
866
|
-
C("scale_1"),
|
|
867
|
-
C("scale_2")
|
|
968
|
+
const C = v.count, k = new Float32Array(C * 3), B = new Float32Array(C * 4), U = new Float32Array(C * 3), F = new Float32Array(C * 3), N = new Float32Array(C), W = new DataView(r);
|
|
969
|
+
let T = g;
|
|
970
|
+
const S = (R) => v.properties.findIndex(
|
|
971
|
+
(d) => d.name === R
|
|
972
|
+
), z = S("x"), E = S("y"), y = S("z"), b = [
|
|
973
|
+
S("rot_0"),
|
|
974
|
+
S("rot_1"),
|
|
975
|
+
S("rot_2"),
|
|
976
|
+
S("rot_3")
|
|
868
977
|
], j = [
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
],
|
|
978
|
+
S("scale_0"),
|
|
979
|
+
S("scale_1"),
|
|
980
|
+
S("scale_2")
|
|
981
|
+
], L = [
|
|
982
|
+
S("f_dc_0"),
|
|
983
|
+
S("f_dc_1"),
|
|
984
|
+
S("f_dc_2")
|
|
985
|
+
], I = S("opacity");
|
|
873
986
|
if ([
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
...
|
|
878
|
-
...q,
|
|
987
|
+
z,
|
|
988
|
+
E,
|
|
989
|
+
y,
|
|
990
|
+
...b,
|
|
879
991
|
...j,
|
|
880
|
-
|
|
881
|
-
|
|
992
|
+
...L,
|
|
993
|
+
I
|
|
994
|
+
].some((R) => R === -1))
|
|
882
995
|
throw new Error(
|
|
883
996
|
"Invalid PLY file: Missing required properties"
|
|
884
997
|
);
|
|
885
|
-
const
|
|
886
|
-
if (
|
|
887
|
-
const d = Math.exp(
|
|
998
|
+
const x = 0.28209479177387814, _ = (R) => {
|
|
999
|
+
if (R > 0) return 1 / (1 + Math.exp(-R));
|
|
1000
|
+
const d = Math.exp(R);
|
|
888
1001
|
return d / (1 + d);
|
|
889
1002
|
};
|
|
890
|
-
let
|
|
891
|
-
for (let
|
|
1003
|
+
let X = 1 / 0, $ = 1 / 0, i = 1 / 0, A = -1 / 0, q = -1 / 0, O = -1 / 0;
|
|
1004
|
+
for (let R = 0; R < C; R++) {
|
|
892
1005
|
const d = [];
|
|
893
|
-
for (let
|
|
894
|
-
const
|
|
1006
|
+
for (let Ce = 0; Ce < v.properties.length; Ce++) {
|
|
1007
|
+
const Fe = v.properties[Ce].type;
|
|
895
1008
|
let ce;
|
|
896
|
-
switch (
|
|
1009
|
+
switch (Fe) {
|
|
897
1010
|
case "char":
|
|
898
|
-
ce =
|
|
1011
|
+
ce = W.getInt8(T), T += 1;
|
|
899
1012
|
break;
|
|
900
1013
|
case "uchar":
|
|
901
|
-
ce =
|
|
1014
|
+
ce = W.getUint8(T), T += 1;
|
|
902
1015
|
break;
|
|
903
1016
|
case "short":
|
|
904
|
-
ce =
|
|
1017
|
+
ce = W.getInt16(T, !0), T += 2;
|
|
905
1018
|
break;
|
|
906
1019
|
case "ushort":
|
|
907
|
-
ce =
|
|
1020
|
+
ce = W.getUint16(T, !0), T += 2;
|
|
908
1021
|
break;
|
|
909
1022
|
case "int":
|
|
910
|
-
ce =
|
|
1023
|
+
ce = W.getInt32(T, !0), T += 4;
|
|
911
1024
|
break;
|
|
912
1025
|
case "uint":
|
|
913
|
-
ce =
|
|
1026
|
+
ce = W.getUint32(T, !0), T += 4;
|
|
914
1027
|
break;
|
|
915
1028
|
case "float":
|
|
916
|
-
ce =
|
|
1029
|
+
ce = W.getFloat32(T, !0), T += 4;
|
|
917
1030
|
break;
|
|
918
1031
|
case "double":
|
|
919
|
-
ce =
|
|
1032
|
+
ce = W.getFloat64(T, !0), T += 8;
|
|
920
1033
|
break;
|
|
921
1034
|
default:
|
|
922
1035
|
throw new Error(
|
|
923
|
-
`Unsupported property type: ${
|
|
1036
|
+
`Unsupported property type: ${Fe}`
|
|
924
1037
|
);
|
|
925
1038
|
}
|
|
926
1039
|
d.push(ce);
|
|
927
1040
|
}
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
let
|
|
1041
|
+
const P = d[z], G = d[E], M = d[y], V = R * 3;
|
|
1042
|
+
k[V] = P, k[V + 1] = G, k[V + 2] = M, X = Math.min(X, P), $ = Math.min($, G), i = Math.min(i, M), A = Math.max(A, P), q = Math.max(q, G), O = Math.max(O, M);
|
|
1043
|
+
let H = d[b[1]], Z = d[b[2]], Q = d[b[3]], J = d[b[0]];
|
|
931
1044
|
const K = Math.sqrt(
|
|
932
|
-
|
|
1045
|
+
H * H + Z * Z + Q * Q + J * J
|
|
933
1046
|
);
|
|
934
|
-
K > 0 && (
|
|
935
|
-
const
|
|
936
|
-
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
let
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
|
|
1047
|
+
K > 0 && (H /= K, Z /= K, Q /= K, J /= K), J < 0 && (H = -H, Z = -Z, Q = -Q, J = -J);
|
|
1048
|
+
const ee = R * 4;
|
|
1049
|
+
B[ee] = H, B[ee + 1] = Z, B[ee + 2] = Q, B[ee + 3] = J;
|
|
1050
|
+
const te = R * 3;
|
|
1051
|
+
U[te] = d[j[0]], U[te + 1] = d[j[1]], U[te + 2] = d[j[2]];
|
|
1052
|
+
let me = 0.5 + d[L[0]] * x, fe = 0.5 + d[L[1]] * x, oe = 0.5 + d[L[2]] * x;
|
|
1053
|
+
me = Math.max(0, Math.min(1, me)), fe = Math.max(0, Math.min(1, fe)), oe = Math.max(0, Math.min(1, oe));
|
|
1054
|
+
const Ee = R * 3;
|
|
1055
|
+
F[Ee] = me, F[Ee + 1] = fe, F[Ee + 2] = oe, N[R] = _(d[I]);
|
|
943
1056
|
}
|
|
944
1057
|
return {
|
|
945
|
-
numSplats:
|
|
946
|
-
positions:
|
|
947
|
-
rotations:
|
|
948
|
-
scales:
|
|
949
|
-
colors:
|
|
950
|
-
opacities:
|
|
1058
|
+
numSplats: C,
|
|
1059
|
+
positions: k.buffer,
|
|
1060
|
+
rotations: B.buffer,
|
|
1061
|
+
scales: U.buffer,
|
|
1062
|
+
colors: F.buffer,
|
|
1063
|
+
opacities: N.buffer,
|
|
951
1064
|
boundingBox: {
|
|
952
|
-
minX:
|
|
953
|
-
minY:
|
|
954
|
-
minZ:
|
|
955
|
-
maxX:
|
|
956
|
-
maxY:
|
|
957
|
-
maxZ:
|
|
1065
|
+
minX: X,
|
|
1066
|
+
minY: $,
|
|
1067
|
+
minZ: i,
|
|
1068
|
+
maxX: A,
|
|
1069
|
+
maxY: q,
|
|
1070
|
+
maxZ: O
|
|
958
1071
|
}
|
|
959
1072
|
};
|
|
960
1073
|
}
|
|
961
1074
|
}).toString()})();`;
|
|
962
1075
|
}
|
|
963
1076
|
}
|
|
964
|
-
var
|
|
1077
|
+
var se = Uint8Array, pe = Uint16Array, ht = Int32Array, Ne = new se([
|
|
965
1078
|
0,
|
|
966
1079
|
0,
|
|
967
1080
|
0,
|
|
@@ -996,7 +1109,7 @@ var ee = Uint8Array, fe = Uint16Array, nt = Int32Array, Ue = new ee([
|
|
|
996
1109
|
0,
|
|
997
1110
|
/* impossible */
|
|
998
1111
|
0
|
|
999
|
-
]),
|
|
1112
|
+
]), $e = new se([
|
|
1000
1113
|
0,
|
|
1001
1114
|
0,
|
|
1002
1115
|
0,
|
|
@@ -1030,65 +1143,65 @@ var ee = Uint8Array, fe = Uint16Array, nt = Int32Array, Ue = new ee([
|
|
|
1030
1143
|
/* unused */
|
|
1031
1144
|
0,
|
|
1032
1145
|
0
|
|
1033
|
-
]),
|
|
1034
|
-
for (var t = new
|
|
1035
|
-
t[
|
|
1036
|
-
for (var
|
|
1037
|
-
for (var
|
|
1038
|
-
|
|
1039
|
-
return { b: t, r
|
|
1040
|
-
},
|
|
1041
|
-
|
|
1042
|
-
var
|
|
1043
|
-
for (var
|
|
1044
|
-
var le = (
|
|
1045
|
-
le = (le & 52428) >> 2 | (le & 13107) << 2, le = (le & 61680) >> 4 | (le & 3855) << 4,
|
|
1146
|
+
]), ut = new se([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Ye = function(a, e) {
|
|
1147
|
+
for (var t = new pe(31), s = 0; s < 31; ++s)
|
|
1148
|
+
t[s] = e += 1 << a[s - 1];
|
|
1149
|
+
for (var r = new ht(t[30]), s = 1; s < 30; ++s)
|
|
1150
|
+
for (var n = t[s]; n < t[s + 1]; ++n)
|
|
1151
|
+
r[n] = n - t[s] << 5 | s;
|
|
1152
|
+
return { b: t, r };
|
|
1153
|
+
}, Xe = Ye(Ne, 2), He = Xe.b, mt = Xe.r;
|
|
1154
|
+
He[28] = 258, mt[258] = 28;
|
|
1155
|
+
var ft = Ye($e, 0), dt = ft.b, Be = new pe(32768);
|
|
1156
|
+
for (var Y = 0; Y < 32768; ++Y) {
|
|
1157
|
+
var le = (Y & 43690) >> 1 | (Y & 21845) << 1;
|
|
1158
|
+
le = (le & 52428) >> 2 | (le & 13107) << 2, le = (le & 61680) >> 4 | (le & 3855) << 4, Be[Y] = ((le & 65280) >> 8 | (le & 255) << 8) >> 1;
|
|
1046
1159
|
}
|
|
1047
|
-
var
|
|
1048
|
-
for (var
|
|
1049
|
-
|
|
1050
|
-
var o = new
|
|
1051
|
-
for (
|
|
1052
|
-
o[
|
|
1053
|
-
var
|
|
1160
|
+
var ve = function(a, e, t) {
|
|
1161
|
+
for (var s = a.length, r = 0, n = new pe(e); r < s; ++r)
|
|
1162
|
+
a[r] && ++n[a[r] - 1];
|
|
1163
|
+
var o = new pe(e);
|
|
1164
|
+
for (r = 1; r < e; ++r)
|
|
1165
|
+
o[r] = o[r - 1] + n[r - 1] << 1;
|
|
1166
|
+
var c;
|
|
1054
1167
|
if (t) {
|
|
1055
|
-
|
|
1056
|
-
var
|
|
1057
|
-
for (
|
|
1058
|
-
if (
|
|
1059
|
-
for (var
|
|
1060
|
-
|
|
1168
|
+
c = new pe(1 << e);
|
|
1169
|
+
var f = 15 - e;
|
|
1170
|
+
for (r = 0; r < s; ++r)
|
|
1171
|
+
if (a[r])
|
|
1172
|
+
for (var g = r << 4 | a[r], m = e - a[r], l = o[a[r] - 1]++ << m, h = l | (1 << m) - 1; l <= h; ++l)
|
|
1173
|
+
c[Be[l] >> f] = g;
|
|
1061
1174
|
} else
|
|
1062
|
-
for (
|
|
1063
|
-
|
|
1064
|
-
return
|
|
1065
|
-
},
|
|
1066
|
-
for (var
|
|
1067
|
-
|
|
1068
|
-
for (var
|
|
1069
|
-
|
|
1070
|
-
for (var
|
|
1071
|
-
|
|
1072
|
-
for (var
|
|
1073
|
-
|
|
1074
|
-
var
|
|
1075
|
-
for (var
|
|
1076
|
-
|
|
1077
|
-
var
|
|
1078
|
-
for (var e =
|
|
1079
|
-
|
|
1175
|
+
for (c = new pe(s), r = 0; r < s; ++r)
|
|
1176
|
+
a[r] && (c[r] = Be[o[a[r] - 1]++] >> 15 - a[r]);
|
|
1177
|
+
return c;
|
|
1178
|
+
}, Me = new se(288);
|
|
1179
|
+
for (var Y = 0; Y < 144; ++Y)
|
|
1180
|
+
Me[Y] = 8;
|
|
1181
|
+
for (var Y = 144; Y < 256; ++Y)
|
|
1182
|
+
Me[Y] = 9;
|
|
1183
|
+
for (var Y = 256; Y < 280; ++Y)
|
|
1184
|
+
Me[Y] = 7;
|
|
1185
|
+
for (var Y = 280; Y < 288; ++Y)
|
|
1186
|
+
Me[Y] = 8;
|
|
1187
|
+
var Ze = new se(32);
|
|
1188
|
+
for (var Y = 0; Y < 32; ++Y)
|
|
1189
|
+
Ze[Y] = 5;
|
|
1190
|
+
var pt = /* @__PURE__ */ ve(Me, 9, 1), xt = /* @__PURE__ */ ve(Ze, 5, 1), Re = function(a) {
|
|
1191
|
+
for (var e = a[0], t = 1; t < a.length; ++t)
|
|
1192
|
+
a[t] > e && (e = a[t]);
|
|
1080
1193
|
return e;
|
|
1081
|
-
}, ne = function(
|
|
1082
|
-
var
|
|
1083
|
-
return (
|
|
1084
|
-
},
|
|
1194
|
+
}, ne = function(a, e, t) {
|
|
1195
|
+
var s = e / 8 | 0;
|
|
1196
|
+
return (a[s] | a[s + 1] << 8) >> (e & 7) & t;
|
|
1197
|
+
}, _e = function(a, e) {
|
|
1085
1198
|
var t = e / 8 | 0;
|
|
1086
|
-
return (
|
|
1087
|
-
},
|
|
1088
|
-
return (
|
|
1089
|
-
},
|
|
1090
|
-
return (e == null || e < 0) && (e = 0), (t == null || t >
|
|
1091
|
-
},
|
|
1199
|
+
return (a[t] | a[t + 1] << 8 | a[t + 2] << 16) >> (e & 7);
|
|
1200
|
+
}, gt = function(a) {
|
|
1201
|
+
return (a + 7) / 8 | 0;
|
|
1202
|
+
}, qe = function(a, e, t) {
|
|
1203
|
+
return (e == null || e < 0) && (e = 0), (t == null || t > a.length) && (t = a.length), new se(a.subarray(e, t));
|
|
1204
|
+
}, yt = [
|
|
1092
1205
|
"unexpected EOF",
|
|
1093
1206
|
"invalid block type",
|
|
1094
1207
|
"invalid length/literal",
|
|
@@ -1104,239 +1217,264 @@ var lt = /* @__PURE__ */ ye(ge, 9, 1), ut = /* @__PURE__ */ ye(Ge, 5, 1), Ae = f
|
|
|
1104
1217
|
"stream finishing",
|
|
1105
1218
|
"invalid zip data"
|
|
1106
1219
|
// determined by unknown compression method
|
|
1107
|
-
],
|
|
1108
|
-
var
|
|
1109
|
-
if (
|
|
1110
|
-
throw
|
|
1111
|
-
return
|
|
1112
|
-
},
|
|
1113
|
-
var
|
|
1114
|
-
if (!
|
|
1115
|
-
return t || new
|
|
1116
|
-
var o = !t,
|
|
1117
|
-
o && (t = new
|
|
1118
|
-
var
|
|
1220
|
+
], re = function(a, e, t) {
|
|
1221
|
+
var s = new Error(e || yt[a]);
|
|
1222
|
+
if (s.code = a, Error.captureStackTrace && Error.captureStackTrace(s, re), !t)
|
|
1223
|
+
throw s;
|
|
1224
|
+
return s;
|
|
1225
|
+
}, wt = function(a, e, t, s) {
|
|
1226
|
+
var r = a.length, n = s ? s.length : 0;
|
|
1227
|
+
if (!r || e.f && !e.l)
|
|
1228
|
+
return t || new se(0);
|
|
1229
|
+
var o = !t, c = o || e.i != 2, f = e.i;
|
|
1230
|
+
o && (t = new se(r * 3));
|
|
1231
|
+
var g = function(Z) {
|
|
1119
1232
|
var Q = t.length;
|
|
1120
|
-
if (
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1233
|
+
if (Z > Q) {
|
|
1234
|
+
var J = new se(Math.max(Q * 2, Z));
|
|
1235
|
+
J.set(t), t = J;
|
|
1123
1236
|
}
|
|
1124
|
-
},
|
|
1237
|
+
}, m = e.f || 0, l = e.p || 0, h = e.b || 0, p = e.l, v = e.d, C = e.m, k = e.n, B = r * 8;
|
|
1125
1238
|
do {
|
|
1126
|
-
if (!
|
|
1127
|
-
|
|
1128
|
-
var
|
|
1129
|
-
if (l += 3,
|
|
1130
|
-
if (
|
|
1131
|
-
|
|
1132
|
-
else if (
|
|
1133
|
-
var
|
|
1239
|
+
if (!p) {
|
|
1240
|
+
m = ne(a, l, 1);
|
|
1241
|
+
var U = ne(a, l + 1, 3);
|
|
1242
|
+
if (l += 3, U)
|
|
1243
|
+
if (U == 1)
|
|
1244
|
+
p = pt, v = xt, C = 9, k = 5;
|
|
1245
|
+
else if (U == 2) {
|
|
1246
|
+
var T = ne(a, l, 31) + 257, S = ne(a, l + 10, 15) + 4, z = T + ne(a, l + 5, 31) + 1;
|
|
1134
1247
|
l += 14;
|
|
1135
|
-
for (var
|
|
1136
|
-
|
|
1137
|
-
l +=
|
|
1138
|
-
for (var
|
|
1139
|
-
var
|
|
1140
|
-
l +=
|
|
1141
|
-
var
|
|
1142
|
-
if (
|
|
1143
|
-
|
|
1248
|
+
for (var E = new se(z), y = new se(19), b = 0; b < S; ++b)
|
|
1249
|
+
y[ut[b]] = ne(a, l + b * 3, 7);
|
|
1250
|
+
l += S * 3;
|
|
1251
|
+
for (var j = Re(y), L = (1 << j) - 1, I = ve(y, j, 1), b = 0; b < z; ) {
|
|
1252
|
+
var D = I[ne(a, l, L)];
|
|
1253
|
+
l += D & 15;
|
|
1254
|
+
var F = D >> 4;
|
|
1255
|
+
if (F < 16)
|
|
1256
|
+
E[b++] = F;
|
|
1144
1257
|
else {
|
|
1145
|
-
var
|
|
1146
|
-
for (
|
|
1147
|
-
|
|
1258
|
+
var x = 0, _ = 0;
|
|
1259
|
+
for (F == 16 ? (_ = 3 + ne(a, l, 3), l += 2, x = E[b - 1]) : F == 17 ? (_ = 3 + ne(a, l, 7), l += 3) : F == 18 && (_ = 11 + ne(a, l, 127), l += 7); _--; )
|
|
1260
|
+
E[b++] = x;
|
|
1148
1261
|
}
|
|
1149
1262
|
}
|
|
1150
|
-
var
|
|
1151
|
-
|
|
1263
|
+
var X = E.subarray(0, T), $ = E.subarray(T);
|
|
1264
|
+
C = Re(X), k = Re($), p = ve(X, C, 1), v = ve($, k, 1);
|
|
1152
1265
|
} else
|
|
1153
|
-
|
|
1266
|
+
re(1);
|
|
1154
1267
|
else {
|
|
1155
|
-
var
|
|
1156
|
-
if (
|
|
1157
|
-
|
|
1268
|
+
var F = gt(l) + 4, N = a[F - 4] | a[F - 3] << 8, W = F + N;
|
|
1269
|
+
if (W > r) {
|
|
1270
|
+
f && re(0);
|
|
1158
1271
|
break;
|
|
1159
1272
|
}
|
|
1160
|
-
|
|
1273
|
+
c && g(h + N), t.set(a.subarray(F, W), h), e.b = h += N, e.p = l = W * 8, e.f = m;
|
|
1161
1274
|
continue;
|
|
1162
1275
|
}
|
|
1163
|
-
if (l >
|
|
1164
|
-
|
|
1276
|
+
if (l > B) {
|
|
1277
|
+
f && re(0);
|
|
1165
1278
|
break;
|
|
1166
1279
|
}
|
|
1167
1280
|
}
|
|
1168
|
-
|
|
1169
|
-
for (var
|
|
1170
|
-
var
|
|
1171
|
-
if (l +=
|
|
1172
|
-
|
|
1281
|
+
c && g(h + 131072);
|
|
1282
|
+
for (var i = (1 << C) - 1, A = (1 << k) - 1, q = l; ; q = l) {
|
|
1283
|
+
var x = p[_e(a, l) & i], O = x >> 4;
|
|
1284
|
+
if (l += x & 15, l > B) {
|
|
1285
|
+
f && re(0);
|
|
1173
1286
|
break;
|
|
1174
1287
|
}
|
|
1175
|
-
if (
|
|
1176
|
-
t[
|
|
1177
|
-
else if (
|
|
1178
|
-
|
|
1288
|
+
if (x || re(2), O < 256)
|
|
1289
|
+
t[h++] = O;
|
|
1290
|
+
else if (O == 256) {
|
|
1291
|
+
q = l, p = null;
|
|
1179
1292
|
break;
|
|
1180
1293
|
} else {
|
|
1181
|
-
var
|
|
1182
|
-
if (
|
|
1183
|
-
var
|
|
1184
|
-
|
|
1294
|
+
var R = O - 254;
|
|
1295
|
+
if (O > 264) {
|
|
1296
|
+
var b = O - 257, d = Ne[b];
|
|
1297
|
+
R = ne(a, l, (1 << d) - 1) + He[b], l += d;
|
|
1185
1298
|
}
|
|
1186
|
-
var
|
|
1187
|
-
|
|
1188
|
-
var
|
|
1189
|
-
if (
|
|
1190
|
-
var d =
|
|
1191
|
-
|
|
1299
|
+
var P = v[_e(a, l) & A], G = P >> 4;
|
|
1300
|
+
P || re(3), l += P & 15;
|
|
1301
|
+
var $ = dt[G];
|
|
1302
|
+
if (G > 3) {
|
|
1303
|
+
var d = $e[G];
|
|
1304
|
+
$ += _e(a, l) & (1 << d) - 1, l += d;
|
|
1192
1305
|
}
|
|
1193
|
-
if (l >
|
|
1194
|
-
|
|
1306
|
+
if (l > B) {
|
|
1307
|
+
f && re(0);
|
|
1195
1308
|
break;
|
|
1196
1309
|
}
|
|
1197
|
-
|
|
1198
|
-
var
|
|
1199
|
-
if (
|
|
1200
|
-
var
|
|
1201
|
-
for (
|
|
1202
|
-
t[
|
|
1310
|
+
c && g(h + 131072);
|
|
1311
|
+
var M = h + R;
|
|
1312
|
+
if (h < $) {
|
|
1313
|
+
var V = n - $, H = Math.min($, M);
|
|
1314
|
+
for (V + h < 0 && re(3); h < H; ++h)
|
|
1315
|
+
t[h] = s[V + h];
|
|
1203
1316
|
}
|
|
1204
|
-
for (;
|
|
1205
|
-
t[
|
|
1317
|
+
for (; h < M; ++h)
|
|
1318
|
+
t[h] = t[h - $];
|
|
1206
1319
|
}
|
|
1207
1320
|
}
|
|
1208
|
-
e.l =
|
|
1209
|
-
} while (!
|
|
1210
|
-
return
|
|
1211
|
-
},
|
|
1212
|
-
return
|
|
1213
|
-
}, ae = function(
|
|
1214
|
-
return (
|
|
1215
|
-
},
|
|
1216
|
-
return ae(
|
|
1321
|
+
e.l = p, e.p = q, e.b = h, e.f = m, p && (m = 1, e.m = C, e.d = v, e.n = k);
|
|
1322
|
+
} while (!m);
|
|
1323
|
+
return h != t.length && o ? qe(t, 0, h) : t.subarray(0, h);
|
|
1324
|
+
}, vt = /* @__PURE__ */ new se(0), ie = function(a, e) {
|
|
1325
|
+
return a[e] | a[e + 1] << 8;
|
|
1326
|
+
}, ae = function(a, e) {
|
|
1327
|
+
return (a[e] | a[e + 1] << 8 | a[e + 2] << 16 | a[e + 3] << 24) >>> 0;
|
|
1328
|
+
}, Te = function(a, e) {
|
|
1329
|
+
return ae(a, e) + ae(a, e + 4) * 4294967296;
|
|
1217
1330
|
};
|
|
1218
|
-
function
|
|
1219
|
-
return
|
|
1331
|
+
function bt(a, e) {
|
|
1332
|
+
return wt(a, { i: 2 }, e && e.out, e && e.dictionary);
|
|
1220
1333
|
}
|
|
1221
|
-
var
|
|
1334
|
+
var Pe = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Mt = 0;
|
|
1222
1335
|
try {
|
|
1223
|
-
|
|
1336
|
+
Pe.decode(vt, { stream: !0 }), Mt = 1;
|
|
1224
1337
|
} catch {
|
|
1225
1338
|
}
|
|
1226
|
-
var
|
|
1339
|
+
var St = function(a) {
|
|
1227
1340
|
for (var e = "", t = 0; ; ) {
|
|
1228
|
-
var
|
|
1229
|
-
if (t +
|
|
1230
|
-
return { s: e, r:
|
|
1231
|
-
|
|
1341
|
+
var s = a[t++], r = (s > 127) + (s > 223) + (s > 239);
|
|
1342
|
+
if (t + r > a.length)
|
|
1343
|
+
return { s: e, r: qe(a, t - 1) };
|
|
1344
|
+
r ? r == 3 ? (s = ((s & 15) << 18 | (a[t++] & 63) << 12 | (a[t++] & 63) << 6 | a[t++] & 63) - 65536, e += String.fromCharCode(55296 | s >> 10, 56320 | s & 1023)) : r & 1 ? e += String.fromCharCode((s & 31) << 6 | a[t++] & 63) : e += String.fromCharCode((s & 15) << 12 | (a[t++] & 63) << 6 | a[t++] & 63) : e += String.fromCharCode(s);
|
|
1232
1345
|
}
|
|
1233
1346
|
};
|
|
1234
|
-
function
|
|
1347
|
+
function At(a, e) {
|
|
1235
1348
|
if (e) {
|
|
1236
|
-
for (var t = "",
|
|
1237
|
-
t += String.fromCharCode.apply(null,
|
|
1349
|
+
for (var t = "", s = 0; s < a.length; s += 16384)
|
|
1350
|
+
t += String.fromCharCode.apply(null, a.subarray(s, s + 16384));
|
|
1238
1351
|
return t;
|
|
1239
1352
|
} else {
|
|
1240
|
-
if (
|
|
1241
|
-
return
|
|
1242
|
-
var
|
|
1243
|
-
return t.length &&
|
|
1353
|
+
if (Pe)
|
|
1354
|
+
return Pe.decode(a);
|
|
1355
|
+
var r = St(a), n = r.s, t = r.r;
|
|
1356
|
+
return t.length && re(8), n;
|
|
1244
1357
|
}
|
|
1245
1358
|
}
|
|
1246
|
-
var
|
|
1247
|
-
return e + 30 + ie(
|
|
1248
|
-
},
|
|
1249
|
-
var
|
|
1250
|
-
return [ie(
|
|
1251
|
-
},
|
|
1252
|
-
for (; ie(
|
|
1359
|
+
var kt = function(a, e) {
|
|
1360
|
+
return e + 30 + ie(a, e + 26) + ie(a, e + 28);
|
|
1361
|
+
}, Et = function(a, e, t) {
|
|
1362
|
+
var s = ie(a, e + 28), r = At(a.subarray(e + 46, e + 46 + s), !(ie(a, e + 8) & 2048)), n = e + 46 + s, o = ae(a, e + 20), c = t && o == 4294967295 ? Ct(a, n) : [o, ae(a, e + 24), ae(a, e + 42)], f = c[0], g = c[1], m = c[2];
|
|
1363
|
+
return [ie(a, e + 10), f, g, r, n + ie(a, e + 30) + ie(a, e + 32), m];
|
|
1364
|
+
}, Ct = function(a, e) {
|
|
1365
|
+
for (; ie(a, e) != 1; e += 4 + ie(a, e + 2))
|
|
1253
1366
|
;
|
|
1254
|
-
return [
|
|
1367
|
+
return [Te(a, e + 12), Te(a, e + 4), Te(a, e + 20)];
|
|
1255
1368
|
};
|
|
1256
|
-
function
|
|
1257
|
-
for (var t = {},
|
|
1258
|
-
(!
|
|
1259
|
-
var
|
|
1260
|
-
if (!
|
|
1369
|
+
function It(a, e) {
|
|
1370
|
+
for (var t = {}, s = a.length - 22; ae(a, s) != 101010256; --s)
|
|
1371
|
+
(!s || a.length - s > 65558) && re(13);
|
|
1372
|
+
var r = ie(a, s + 8);
|
|
1373
|
+
if (!r)
|
|
1261
1374
|
return {};
|
|
1262
|
-
var
|
|
1375
|
+
var n = ae(a, s + 16), o = n == 4294967295 || r == 65535;
|
|
1263
1376
|
if (o) {
|
|
1264
|
-
var
|
|
1265
|
-
o = ae(
|
|
1377
|
+
var c = ae(a, s - 12);
|
|
1378
|
+
o = ae(a, c) == 101075792, o && (r = ae(a, c + 32), n = ae(a, c + 48));
|
|
1266
1379
|
}
|
|
1267
|
-
for (var
|
|
1268
|
-
var
|
|
1269
|
-
|
|
1380
|
+
for (var f = 0; f < r; ++f) {
|
|
1381
|
+
var g = Et(a, n, o), m = g[0], l = g[1], h = g[2], p = g[3], v = g[4], C = g[5], k = kt(a, C);
|
|
1382
|
+
n = v, m ? m == 8 ? t[p] = bt(a.subarray(k, k + l), { out: new se(h) }) : re(14, "unknown compression type " + m) : t[p] = qe(a, k, k + l);
|
|
1270
1383
|
}
|
|
1271
1384
|
return t;
|
|
1272
1385
|
}
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
if (
|
|
1283
|
-
throw new Error(
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
)
|
|
1313
|
-
|
|
1386
|
+
const ke = (a) => typeof a == "number" && Number.isFinite(a), he = (a, e) => {
|
|
1387
|
+
const t = a[e];
|
|
1388
|
+
if (typeof t != "object" || t === null)
|
|
1389
|
+
throw new Error(`Invalid SOG metadata section: ${e}`);
|
|
1390
|
+
return t;
|
|
1391
|
+
}, ue = (a, e) => {
|
|
1392
|
+
const t = a.files;
|
|
1393
|
+
if (!Array.isArray(t))
|
|
1394
|
+
throw new Error(`${e}.files is not an array`);
|
|
1395
|
+
if (!t.every((s) => typeof s == "string"))
|
|
1396
|
+
throw new Error(`${e}.files contains non-strings`);
|
|
1397
|
+
return t;
|
|
1398
|
+
}, ze = (a, e) => {
|
|
1399
|
+
const t = a.mins, s = a.maxs;
|
|
1400
|
+
if (!Array.isArray(t) || t.length !== 3)
|
|
1401
|
+
throw new Error(`${e}.mins must be length-3`);
|
|
1402
|
+
if (!Array.isArray(s) || s.length !== 3)
|
|
1403
|
+
throw new Error(`${e}.maxs must be length-3`);
|
|
1404
|
+
if (![...t, ...s].every(ke))
|
|
1405
|
+
throw new Error(`${e}.mins/maxs must be finite numbers`);
|
|
1406
|
+
return {
|
|
1407
|
+
mins: [t[0], t[1], t[2]],
|
|
1408
|
+
maxs: [s[0], s[1], s[2]]
|
|
1409
|
+
};
|
|
1410
|
+
}, Rt = (a, e) => {
|
|
1411
|
+
const t = a.mins, s = a.maxs;
|
|
1412
|
+
if (!Array.isArray(t) || t.length !== 4)
|
|
1413
|
+
throw new Error(`${e}.mins must be length-4`);
|
|
1414
|
+
if (!Array.isArray(s) || s.length !== 4)
|
|
1415
|
+
throw new Error(`${e}.maxs must be length-4`);
|
|
1416
|
+
if (![...t, ...s].every(ke))
|
|
1417
|
+
throw new Error(`${e}.mins/maxs must be finite numbers`);
|
|
1418
|
+
return {
|
|
1419
|
+
mins: [t[0], t[1], t[2], t[3]],
|
|
1420
|
+
maxs: [s[0], s[1], s[2], s[3]]
|
|
1421
|
+
};
|
|
1422
|
+
}, je = (a, e) => {
|
|
1423
|
+
const t = a.codebook;
|
|
1424
|
+
if (!Array.isArray(t))
|
|
1425
|
+
throw new Error(`${e}.codebook is not an array`);
|
|
1426
|
+
if (!t.every(ke))
|
|
1427
|
+
throw new Error(`${e}.codebook contains non-finite numbers`);
|
|
1428
|
+
return t;
|
|
1429
|
+
}, Ge = (a) => {
|
|
1430
|
+
if (typeof a != "object" || a === null) throw new Error("Invalid SOG metadata: not an object");
|
|
1431
|
+
const e = a, t = e.version ?? 1;
|
|
1432
|
+
if (t !== 1 && t !== 2) throw new Error(`Unsupported SOG version: ${String(t)}`);
|
|
1433
|
+
if (t === 1) {
|
|
1434
|
+
const m = he(e, "means"), l = he(e, "sh0"), h = he(e, "quats"), p = he(e, "scales"), v = typeof e.count == "number" && Number.isFinite(e.count) ? e.count : void 0, C = Array.isArray(m.shape) ? m.shape : void 0, k = C && typeof C[0] == "number" ? C[0] : void 0;
|
|
1435
|
+
if (v === void 0 && k === void 0) throw new Error("Invalid SOGS metadata: unable to determine splat count");
|
|
1436
|
+
if (v !== void 0 && k !== void 0 && v !== k) throw new Error("Inconsistent SOGS metadata: count does not match means.shape[0]");
|
|
1314
1437
|
return {
|
|
1315
|
-
|
|
1316
|
-
|
|
1438
|
+
version: 1,
|
|
1439
|
+
numSplats: (v ?? k) | 0,
|
|
1440
|
+
files: {
|
|
1441
|
+
sh0: ue(l, "sh0"),
|
|
1442
|
+
means: ue(m, "means"),
|
|
1443
|
+
quats: ue(h, "quats"),
|
|
1444
|
+
scales: ue(p, "scales")
|
|
1445
|
+
},
|
|
1446
|
+
ranges: {
|
|
1447
|
+
sh0: Rt(l, "sh0"),
|
|
1448
|
+
means: ze(m, "means"),
|
|
1449
|
+
scales: ze(p, "scales")
|
|
1450
|
+
}
|
|
1317
1451
|
};
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
return E;
|
|
1323
|
-
};
|
|
1452
|
+
}
|
|
1453
|
+
const s = e.count;
|
|
1454
|
+
if (!ke(s)) throw new Error('Invalid SOG v2 metadata: missing/invalid "count"');
|
|
1455
|
+
const r = s | 0, n = he(e, "means"), o = he(e, "sh0"), c = he(e, "quats"), f = he(e, "scales");
|
|
1324
1456
|
return {
|
|
1325
|
-
|
|
1457
|
+
version: 2,
|
|
1458
|
+
numSplats: r,
|
|
1326
1459
|
files: {
|
|
1327
|
-
sh0:
|
|
1328
|
-
means:
|
|
1329
|
-
quats:
|
|
1330
|
-
scales:
|
|
1460
|
+
sh0: ue(o, "sh0"),
|
|
1461
|
+
means: ue(n, "means"),
|
|
1462
|
+
quats: ue(c, "quats"),
|
|
1463
|
+
scales: ue(f, "scales")
|
|
1331
1464
|
},
|
|
1332
1465
|
ranges: {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
scales:
|
|
1336
|
-
}
|
|
1466
|
+
means: ze(n, "means"),
|
|
1467
|
+
sh0: { codebook: je(o, "sh0") },
|
|
1468
|
+
scales: { codebook: je(f, "scales") }
|
|
1469
|
+
},
|
|
1470
|
+
antialias: typeof e.antialias == "boolean" ? e.antialias : void 0
|
|
1471
|
+
// prettier-ignore
|
|
1337
1472
|
};
|
|
1338
1473
|
};
|
|
1339
|
-
class
|
|
1474
|
+
class _t extends u.Loader {
|
|
1475
|
+
constructor(e) {
|
|
1476
|
+
super(e), this.withCredentials = !0;
|
|
1477
|
+
}
|
|
1340
1478
|
/**
|
|
1341
1479
|
* Detect if a buffer is a ZIP file by checking magic bytes
|
|
1342
1480
|
* ZIP files start with signature: PK\x03\x04 (0x50 0x4B 0x03 0x04)
|
|
@@ -1353,19 +1491,19 @@ class St extends h.Loader {
|
|
|
1353
1491
|
* @param onProgress Optional progress callback
|
|
1354
1492
|
* @param onError Optional error callback
|
|
1355
1493
|
*/
|
|
1356
|
-
load(e, t,
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1494
|
+
load(e, t, s, r) {
|
|
1495
|
+
const n = new u.FileLoader(this.manager);
|
|
1496
|
+
n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
1359
1497
|
e,
|
|
1360
1498
|
(o) => {
|
|
1361
|
-
this.parseAsync(e, o).then((
|
|
1362
|
-
t && t(
|
|
1363
|
-
}).catch((
|
|
1364
|
-
this.manager.itemError(e),
|
|
1499
|
+
this.parseAsync(e, o).then((c) => {
|
|
1500
|
+
t && t(c);
|
|
1501
|
+
}).catch((c) => {
|
|
1502
|
+
this.manager.itemError(e), r && r(c), console.error("Error loading SOGS meta:", c);
|
|
1365
1503
|
});
|
|
1366
1504
|
},
|
|
1367
|
-
|
|
1368
|
-
|
|
1505
|
+
s,
|
|
1506
|
+
r
|
|
1369
1507
|
);
|
|
1370
1508
|
}
|
|
1371
1509
|
/**
|
|
@@ -1375,18 +1513,18 @@ class St extends h.Loader {
|
|
|
1375
1513
|
* @returns A Promise that resolves with the parsed SplatData
|
|
1376
1514
|
*/
|
|
1377
1515
|
loadAsync(e, t) {
|
|
1378
|
-
return new Promise((
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1516
|
+
return new Promise((s, r) => {
|
|
1517
|
+
const n = new u.FileLoader(this.manager);
|
|
1518
|
+
n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
1381
1519
|
e,
|
|
1382
1520
|
(o) => {
|
|
1383
|
-
this.parseAsync(e, o).then(
|
|
1384
|
-
|
|
1521
|
+
this.parseAsync(e, o).then(s).catch((c) => {
|
|
1522
|
+
r(c), this.manager.itemError(e);
|
|
1385
1523
|
});
|
|
1386
1524
|
},
|
|
1387
1525
|
t,
|
|
1388
1526
|
(o) => {
|
|
1389
|
-
|
|
1527
|
+
r(o), this.manager.itemError(e);
|
|
1390
1528
|
}
|
|
1391
1529
|
);
|
|
1392
1530
|
});
|
|
@@ -1394,117 +1532,127 @@ class St extends h.Loader {
|
|
|
1394
1532
|
async parseAsync(e, t) {
|
|
1395
1533
|
if (!(t instanceof ArrayBuffer)) throw new Error("SOGS loader: expected ArrayBuffer payload");
|
|
1396
1534
|
if (this.isZipBuffer(t)) return this.parseZipAsync(t);
|
|
1397
|
-
const
|
|
1398
|
-
return this.parseMetaAsync(e,
|
|
1535
|
+
const r = new TextDecoder("utf-8").decode(t), n = JSON.parse(r);
|
|
1536
|
+
return this.parseMetaAsync(e, n);
|
|
1399
1537
|
}
|
|
1400
1538
|
async parseMetaAsync(e, t) {
|
|
1401
|
-
const { numSplats: r, files:
|
|
1402
|
-
|
|
1403
|
-
const
|
|
1539
|
+
const s = Ge(t), { numSplats: r, files: n, ranges: o, version: c } = s, f = new u.TextureLoader(this.manager);
|
|
1540
|
+
f.setPath(this.path), f.setRequestHeader(this.requestHeader), f.setWithCredentials(this.withCredentials);
|
|
1541
|
+
const g = (F, N) => {
|
|
1404
1542
|
try {
|
|
1405
|
-
return new URL(
|
|
1543
|
+
return new URL(N, F).toString();
|
|
1406
1544
|
} catch {
|
|
1407
|
-
return
|
|
1545
|
+
return F.substring(0, F.lastIndexOf("/") + 1) + N;
|
|
1408
1546
|
}
|
|
1409
|
-
}, m = (
|
|
1410
|
-
const
|
|
1411
|
-
return new Promise((
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
(
|
|
1415
|
-
|
|
1547
|
+
}, m = (F, N) => {
|
|
1548
|
+
const W = g(e, F);
|
|
1549
|
+
return new Promise((T, S) => {
|
|
1550
|
+
f.load(
|
|
1551
|
+
W,
|
|
1552
|
+
(z) => {
|
|
1553
|
+
z.generateMipmaps = !1, z.magFilter = u.NearestFilter, z.minFilter = u.NearestFilter, z.flipY = !1, T(z);
|
|
1416
1554
|
},
|
|
1417
1555
|
void 0,
|
|
1418
|
-
(
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1556
|
+
(z) => {
|
|
1557
|
+
const E = z instanceof Error ? z.message : String(z);
|
|
1558
|
+
S(
|
|
1421
1559
|
new Error(
|
|
1422
|
-
`SOGS loader: failed to load ${
|
|
1560
|
+
`SOGS loader: failed to load ${N} (${F}): ${E}`
|
|
1423
1561
|
)
|
|
1424
1562
|
);
|
|
1425
1563
|
}
|
|
1426
1564
|
);
|
|
1427
1565
|
});
|
|
1428
1566
|
};
|
|
1429
|
-
if (!Array.isArray(
|
|
1430
|
-
if (!Array.isArray(
|
|
1431
|
-
if (!Array.isArray(
|
|
1432
|
-
if (!Array.isArray(
|
|
1433
|
-
const [
|
|
1434
|
-
m(
|
|
1435
|
-
m(
|
|
1436
|
-
m(
|
|
1437
|
-
m(
|
|
1438
|
-
m(
|
|
1439
|
-
]),
|
|
1440
|
-
|
|
1567
|
+
if (!Array.isArray(n.sh0) || n.sh0.length < 1) throw new Error("SOGS loader: files.sh0 must have at least 1 entry (sh0)");
|
|
1568
|
+
if (!Array.isArray(n.means) || n.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
|
|
1569
|
+
if (!Array.isArray(n.quats) || n.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
|
|
1570
|
+
if (!Array.isArray(n.scales) || n.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
|
|
1571
|
+
const [l, h, p, v, C] = await Promise.all([
|
|
1572
|
+
m(n.means[0], "means_l"),
|
|
1573
|
+
m(n.means[1], "means_u"),
|
|
1574
|
+
m(n.quats[0], "quats"),
|
|
1575
|
+
m(n.scales[0], "scales"),
|
|
1576
|
+
m(n.sh0[0], "sh0")
|
|
1577
|
+
]), k = { means_l: l, means_u: h, quats: p, scales: v, sh0: C };
|
|
1578
|
+
if (c === 1) {
|
|
1579
|
+
const F = new Le(r, o, k), N = we.packSogs(F);
|
|
1580
|
+
return F.dispose(), N;
|
|
1581
|
+
}
|
|
1582
|
+
const B = new We(r, o, k), U = we.packSog2(B);
|
|
1583
|
+
return B.dispose(), U;
|
|
1441
1584
|
}
|
|
1442
1585
|
async parseZipAsync(e) {
|
|
1443
|
-
const t =
|
|
1444
|
-
if (!
|
|
1445
|
-
const
|
|
1446
|
-
const
|
|
1447
|
-
for (const
|
|
1448
|
-
const
|
|
1449
|
-
if (
|
|
1586
|
+
const t = It(new Uint8Array(e)), s = Object.keys(t), r = s.find((y) => y.toLowerCase().endsWith("meta.json")) ?? null;
|
|
1587
|
+
if (!r) throw new Error("SOGS loader: zip missing meta.json");
|
|
1588
|
+
const n = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "", o = new TextDecoder(), c = JSON.parse(o.decode(t[r])), f = Ge(c), { numSplats: g, files: m, ranges: l, version: h } = f, p = (y) => y.replace(/\\/g, "/").replace(/^\.?\//, ""), v = (y) => {
|
|
1589
|
+
const b = p(y), j = [p(n + b), b];
|
|
1590
|
+
for (const D of j) {
|
|
1591
|
+
const x = t[D];
|
|
1592
|
+
if (x) return x;
|
|
1450
1593
|
}
|
|
1451
|
-
const
|
|
1452
|
-
if (
|
|
1453
|
-
throw new Error(`SOGS loader: zip missing file "${
|
|
1454
|
-
},
|
|
1455
|
-
const
|
|
1456
|
-
return
|
|
1457
|
-
},
|
|
1458
|
-
|
|
1459
|
-
const
|
|
1460
|
-
const
|
|
1461
|
-
type:
|
|
1462
|
-
}),
|
|
1463
|
-
return new Promise((
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
(
|
|
1467
|
-
URL.revokeObjectURL(
|
|
1594
|
+
const L = b.split("/").pop(), I = s.find((D) => p(D).endsWith("/" + b)) ?? s.find((D) => p(D).endsWith("/" + L)) ?? s.find((D) => p(D) === L) ?? null;
|
|
1595
|
+
if (I) return t[I];
|
|
1596
|
+
throw new Error(`SOGS loader: zip missing file "${y}"`);
|
|
1597
|
+
}, C = (y) => {
|
|
1598
|
+
const b = y.toLowerCase();
|
|
1599
|
+
return b.endsWith(".png") ? "image/png" : b.endsWith(".jpg") || b.endsWith(".jpeg") ? "image/jpeg" : b.endsWith(".webp") ? "image/webp" : "application/octet-stream";
|
|
1600
|
+
}, k = new u.TextureLoader(this.manager);
|
|
1601
|
+
k.setRequestHeader(this.requestHeader), k.setWithCredentials(this.withCredentials);
|
|
1602
|
+
const B = (y, b) => {
|
|
1603
|
+
const j = v(y), L = new Blob([j], {
|
|
1604
|
+
type: C(y)
|
|
1605
|
+
}), I = URL.createObjectURL(L);
|
|
1606
|
+
return new Promise((D, x) => {
|
|
1607
|
+
k.load(
|
|
1608
|
+
I,
|
|
1609
|
+
(_) => {
|
|
1610
|
+
URL.revokeObjectURL(I), _.generateMipmaps = !1, _.magFilter = u.NearestFilter, _.minFilter = u.NearestFilter, _.flipY = !1, D(_);
|
|
1468
1611
|
},
|
|
1469
1612
|
void 0,
|
|
1470
|
-
(
|
|
1471
|
-
URL.revokeObjectURL(
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1613
|
+
(_) => {
|
|
1614
|
+
URL.revokeObjectURL(I);
|
|
1615
|
+
const X = _ instanceof Error ? _.message : String(_);
|
|
1616
|
+
x(
|
|
1474
1617
|
new Error(
|
|
1475
|
-
`SOGS loader: failed to load ${
|
|
1618
|
+
`SOGS loader: failed to load ${b} from zip (${y}): ${X}`
|
|
1476
1619
|
)
|
|
1477
1620
|
);
|
|
1478
1621
|
}
|
|
1479
1622
|
);
|
|
1480
1623
|
});
|
|
1481
1624
|
};
|
|
1482
|
-
if (!Array.isArray(
|
|
1483
|
-
if (!Array.isArray(
|
|
1484
|
-
if (!Array.isArray(
|
|
1485
|
-
if (!Array.isArray(
|
|
1486
|
-
const [
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
]),
|
|
1493
|
-
|
|
1625
|
+
if (!Array.isArray(m.sh0) || m.sh0.length < 1) throw new Error("SOGS loader: files.sh0 must have at least 1 entry (sh0)");
|
|
1626
|
+
if (!Array.isArray(m.means) || m.means.length < 2) throw new Error("SOGS loader: files.means must have at least 2 entries (means_l, means_u)");
|
|
1627
|
+
if (!Array.isArray(m.quats) || m.quats.length < 1) throw new Error("SOGS loader: files.quats must have at least 1 entry");
|
|
1628
|
+
if (!Array.isArray(m.scales) || m.scales.length < 1) throw new Error("SOGS loader: files.scales must have at least 1 entry");
|
|
1629
|
+
const [U, F, N, W, T] = await Promise.all([
|
|
1630
|
+
B(m.means[0], "means_l"),
|
|
1631
|
+
B(m.means[1], "means_u"),
|
|
1632
|
+
B(m.quats[0], "quats"),
|
|
1633
|
+
B(m.scales[0], "scales"),
|
|
1634
|
+
B(m.sh0[0], "sh0")
|
|
1635
|
+
]), S = { means_l: U, means_u: F, quats: N, scales: W, sh0: T };
|
|
1636
|
+
if (h === 1) {
|
|
1637
|
+
const y = new Le(g, l, S), b = we.packSogs(y);
|
|
1638
|
+
return y.dispose(), b;
|
|
1639
|
+
}
|
|
1640
|
+
const z = new We(g, l, S), E = we.packSog2(z);
|
|
1641
|
+
return z.dispose(), E;
|
|
1494
1642
|
}
|
|
1495
1643
|
}
|
|
1496
|
-
class
|
|
1644
|
+
class Tt extends u.EventDispatcher {
|
|
1497
1645
|
constructor() {
|
|
1498
1646
|
super();
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1647
|
+
w(this, "worker");
|
|
1648
|
+
w(this, "centers", null);
|
|
1649
|
+
w(this, "orderTexture", null);
|
|
1502
1650
|
/** Bounding box data for optimization */
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
const t = this.createWorkerCode(),
|
|
1507
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
1651
|
+
w(this, "chunks", null);
|
|
1652
|
+
w(this, "lastCameraPosition", new u.Vector3());
|
|
1653
|
+
w(this, "lastCameraDirection", new u.Vector3());
|
|
1654
|
+
const t = this.createWorkerCode(), s = new Blob([t], { type: "application/javascript" });
|
|
1655
|
+
this.worker = new Worker(URL.createObjectURL(s)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
1508
1656
|
}
|
|
1509
1657
|
/**
|
|
1510
1658
|
* Handles messages received from the sorting worker.
|
|
@@ -1513,14 +1661,14 @@ class At extends h.EventDispatcher {
|
|
|
1513
1661
|
onWorkerMessage(t) {
|
|
1514
1662
|
if (!this.orderTexture || !this.orderTexture.image)
|
|
1515
1663
|
return console.error("SplatSorter: Order texture not initialized!");
|
|
1516
|
-
const { order:
|
|
1517
|
-
if (!(
|
|
1664
|
+
const { order: s, count: r } = t.data, n = this.orderTexture.image.data;
|
|
1665
|
+
if (!(n instanceof Uint32Array))
|
|
1518
1666
|
return console.error(
|
|
1519
1667
|
"SplatSorter: Order texture data is not a Uint32Array!"
|
|
1520
1668
|
);
|
|
1521
|
-
|
|
1522
|
-
const o =
|
|
1523
|
-
this.worker.postMessage(
|
|
1669
|
+
n.set(new Uint32Array(s)), this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
|
|
1670
|
+
const o = n.buffer.slice(0), c = { order: o };
|
|
1671
|
+
this.worker.postMessage(c, [o]), this.dispatchEvent({ type: "updated", count: r });
|
|
1524
1672
|
}
|
|
1525
1673
|
/**
|
|
1526
1674
|
* Initializes the sorter with necessary data and textures.
|
|
@@ -1529,35 +1677,35 @@ class At extends h.EventDispatcher {
|
|
|
1529
1677
|
* @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
|
|
1530
1678
|
* @param transferOwnership Optional: If true, transfers ownership of centers buffer to worker (saves memory, main thread loses access). Default: false.
|
|
1531
1679
|
*/
|
|
1532
|
-
init(t,
|
|
1680
|
+
init(t, s, r, n = !1) {
|
|
1533
1681
|
if (!t || !(t.image.data instanceof Uint32Array))
|
|
1534
1682
|
throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
|
|
1535
|
-
if (!
|
|
1683
|
+
if (!s || s.length % 3 !== 0)
|
|
1536
1684
|
throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
|
|
1537
|
-
if (t.image.data.length <
|
|
1685
|
+
if (t.image.data.length < s.length / 3)
|
|
1538
1686
|
throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
|
|
1539
|
-
if (
|
|
1687
|
+
if (s.buffer.byteLength === 0)
|
|
1540
1688
|
throw new Error(
|
|
1541
1689
|
"SplatSorter: positions buffer is detached (likely React StrictMode + cached asset). "
|
|
1542
1690
|
);
|
|
1543
|
-
const o =
|
|
1544
|
-
this.orderTexture = t,
|
|
1545
|
-
const
|
|
1546
|
-
for (let
|
|
1691
|
+
const o = s.length / 3;
|
|
1692
|
+
this.orderTexture = t, n ? this.centers = null : this.centers = s.slice();
|
|
1693
|
+
const c = this.orderTexture.image.data;
|
|
1694
|
+
for (let h = 0; h < o; h++) c[h] = h;
|
|
1547
1695
|
this.orderTexture.source.data.updateRanges || (this.orderTexture.source.data.updateRanges = []), this.orderTexture.needsUpdate = !0;
|
|
1548
|
-
const
|
|
1549
|
-
order:
|
|
1550
|
-
centers:
|
|
1696
|
+
const f = c.buffer.slice(0), g = n ? s.buffer : s.buffer.slice(0), m = {
|
|
1697
|
+
order: f,
|
|
1698
|
+
centers: g
|
|
1551
1699
|
}, l = [
|
|
1552
|
-
|
|
1553
|
-
|
|
1700
|
+
f,
|
|
1701
|
+
g
|
|
1554
1702
|
];
|
|
1555
|
-
if (
|
|
1556
|
-
this.chunks =
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1703
|
+
if (r) {
|
|
1704
|
+
this.chunks = r.slice();
|
|
1705
|
+
const h = this.chunks.buffer.slice(0);
|
|
1706
|
+
m.chunks = h, l.push(h);
|
|
1559
1707
|
}
|
|
1560
|
-
this.worker.postMessage(
|
|
1708
|
+
this.worker.postMessage(m, l), queueMicrotask(() => {
|
|
1561
1709
|
this.dispatchEvent({
|
|
1562
1710
|
type: "updated",
|
|
1563
1711
|
count: o
|
|
@@ -1574,46 +1722,46 @@ class At extends h.EventDispatcher {
|
|
|
1574
1722
|
return console.warn(
|
|
1575
1723
|
"SplatSorter: Cannot set mapping before initialization."
|
|
1576
1724
|
);
|
|
1577
|
-
let
|
|
1578
|
-
const
|
|
1725
|
+
let s;
|
|
1726
|
+
const r = [];
|
|
1579
1727
|
if (!t) {
|
|
1580
|
-
const
|
|
1581
|
-
return
|
|
1582
|
-
centers:
|
|
1728
|
+
const f = this.centers.buffer.slice(0);
|
|
1729
|
+
return s = {
|
|
1730
|
+
centers: f,
|
|
1583
1731
|
mapping: null
|
|
1584
|
-
},
|
|
1732
|
+
}, r.push(f), this.worker.postMessage(s, r);
|
|
1585
1733
|
}
|
|
1586
|
-
const
|
|
1587
|
-
for (let
|
|
1588
|
-
const
|
|
1589
|
-
if (
|
|
1734
|
+
const n = new Float32Array(t.length * 3);
|
|
1735
|
+
for (let f = 0; f < t.length; f++) {
|
|
1736
|
+
const g = t[f];
|
|
1737
|
+
if (g * 3 + 2 >= this.centers.length) {
|
|
1590
1738
|
console.warn(
|
|
1591
|
-
`SplatSorter: Mapping index ${
|
|
1739
|
+
`SplatSorter: Mapping index ${g} out of bounds.`
|
|
1592
1740
|
);
|
|
1593
1741
|
continue;
|
|
1594
1742
|
}
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1743
|
+
const m = g * 3, l = f * 3;
|
|
1744
|
+
n[l + 0] = this.centers[m + 0], n[l + 1] = this.centers[m + 1], n[l + 2] = this.centers[m + 2];
|
|
1597
1745
|
}
|
|
1598
|
-
const o =
|
|
1599
|
-
|
|
1746
|
+
const o = n.buffer.slice(0), c = t.buffer.slice(0);
|
|
1747
|
+
s = {
|
|
1600
1748
|
centers: o,
|
|
1601
|
-
mapping:
|
|
1602
|
-
},
|
|
1749
|
+
mapping: c
|
|
1750
|
+
}, r.push(o, c), this.worker.postMessage(s, r);
|
|
1603
1751
|
}
|
|
1604
1752
|
/**
|
|
1605
1753
|
* Updates the camera parameters used for sorting.
|
|
1606
1754
|
* @param position The camera's position in the sorter's local coordinate space.
|
|
1607
1755
|
* @param direction The camera's forward direction in the sorter's local coordinate space.
|
|
1608
1756
|
*/
|
|
1609
|
-
setCamera(t,
|
|
1610
|
-
const
|
|
1611
|
-
if (!
|
|
1757
|
+
setCamera(t, s) {
|
|
1758
|
+
const r = this.lastCameraPosition.distanceToSquared(t) > 1e-7, n = this.lastCameraDirection.dot(s) < 0.9999;
|
|
1759
|
+
if (!r && !n)
|
|
1612
1760
|
return;
|
|
1613
|
-
this.lastCameraPosition.copy(t), this.lastCameraDirection.copy(
|
|
1761
|
+
this.lastCameraPosition.copy(t), this.lastCameraDirection.copy(s);
|
|
1614
1762
|
const o = {
|
|
1615
1763
|
cameraPosition: { x: t.x, y: t.y, z: t.z },
|
|
1616
|
-
cameraDirection: { x:
|
|
1764
|
+
cameraDirection: { x: s.x, y: s.y, z: s.z }
|
|
1617
1765
|
};
|
|
1618
1766
|
this.worker.postMessage(o);
|
|
1619
1767
|
}
|
|
@@ -1629,186 +1777,186 @@ class At extends h.EventDispatcher {
|
|
|
1629
1777
|
*/
|
|
1630
1778
|
createWorkerCode() {
|
|
1631
1779
|
return `(${(function() {
|
|
1632
|
-
let
|
|
1633
|
-
const
|
|
1634
|
-
let
|
|
1635
|
-
const
|
|
1636
|
-
for (;
|
|
1637
|
-
const
|
|
1638
|
-
if (
|
|
1639
|
-
else if (
|
|
1640
|
-
else return
|
|
1780
|
+
let s = null, r = null, n = null, o = null, c = null, f = null, g = !1;
|
|
1781
|
+
const m = { x: 0, y: 0, z: 0 }, l = { x: 0, y: 0, z: 0 }, h = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 };
|
|
1782
|
+
let v = null, C = null;
|
|
1783
|
+
const k = 32, B = new Array(k).fill(0), U = new Array(k).fill(0), F = new Array(k).fill(0), N = (T, S, z) => {
|
|
1784
|
+
for (; T <= S; ) {
|
|
1785
|
+
const E = S + T >> 1, y = z(E);
|
|
1786
|
+
if (y > 0) T = E + 1;
|
|
1787
|
+
else if (y < 0) S = E - 1;
|
|
1788
|
+
else return E;
|
|
1641
1789
|
}
|
|
1642
|
-
return ~
|
|
1643
|
-
},
|
|
1644
|
-
if (!
|
|
1790
|
+
return ~T;
|
|
1791
|
+
}, W = () => {
|
|
1792
|
+
if (!s || !r || !c || !f)
|
|
1645
1793
|
return;
|
|
1646
|
-
if (
|
|
1794
|
+
if (r.length === 0) {
|
|
1647
1795
|
const d = {
|
|
1648
|
-
order:
|
|
1796
|
+
order: s.buffer,
|
|
1649
1797
|
count: 0
|
|
1650
1798
|
};
|
|
1651
|
-
self.postMessage(d, [
|
|
1799
|
+
self.postMessage(d, [s.buffer]), s = null;
|
|
1652
1800
|
return;
|
|
1653
1801
|
}
|
|
1654
|
-
const
|
|
1655
|
-
if (!
|
|
1802
|
+
const T = c.x, S = c.y, z = c.z, E = f.x, y = f.y, b = f.z, j = 1e-4, L = Math.abs(T - m.x) > j || Math.abs(S - m.y) > j || Math.abs(z - m.z) > j, I = Math.abs(E - l.x) > j || Math.abs(y - l.y) > j || Math.abs(b - l.z) > j;
|
|
1803
|
+
if (!g && !L && !I)
|
|
1656
1804
|
return;
|
|
1657
|
-
|
|
1658
|
-
let
|
|
1805
|
+
g = !1, m.x = T, m.y = S, m.z = z, l.x = E, l.y = y, l.z = b;
|
|
1806
|
+
let D = 1 / 0, x = -1 / 0;
|
|
1659
1807
|
for (let d = 0; d < 8; ++d) {
|
|
1660
|
-
const
|
|
1661
|
-
|
|
1808
|
+
const P = d & 1 ? h.x : p.x, G = d & 2 ? h.y : p.y, M = d & 4 ? h.z : p.z, V = P * E + G * y + M * b;
|
|
1809
|
+
D = Math.min(D, V), x = Math.max(x, V);
|
|
1662
1810
|
}
|
|
1663
|
-
const
|
|
1811
|
+
const _ = r.length / 3, X = x - D, i = (1 << Math.max(
|
|
1664
1812
|
10,
|
|
1665
|
-
Math.min(20, Math.ceil(Math.log2(
|
|
1813
|
+
Math.min(20, Math.ceil(Math.log2(_ / 4)))
|
|
1666
1814
|
)) + 1;
|
|
1667
|
-
if ((!
|
|
1668
|
-
for (let d = 0; d <
|
|
1669
|
-
|
|
1670
|
-
} else if (
|
|
1671
|
-
const d =
|
|
1672
|
-
|
|
1673
|
-
for (let
|
|
1674
|
-
const
|
|
1815
|
+
if ((!v || v.length !== _) && (v = new Uint32Array(_)), !C || C.length !== i ? C = new Uint32Array(i) : C.fill(0), X < 1e-7) {
|
|
1816
|
+
for (let d = 0; d < _; ++d) v[d] = 0;
|
|
1817
|
+
C[0] = _;
|
|
1818
|
+
} else if (n && n.length > 0) {
|
|
1819
|
+
const d = n.length / 6;
|
|
1820
|
+
B.fill(0);
|
|
1821
|
+
for (let M = 0; M < d; ++M) {
|
|
1822
|
+
const V = M * 6, H = n[V + 0], Z = n[V + 1], Q = n[V + 2], J = n[V + 3], K = H * E + Z * y + Q * b - D, ee = K - J, te = K + J, me = Math.max(
|
|
1675
1823
|
0,
|
|
1676
|
-
Math.floor(
|
|
1677
|
-
),
|
|
1678
|
-
|
|
1679
|
-
Math.ceil(
|
|
1824
|
+
Math.floor(ee * k / X)
|
|
1825
|
+
), fe = Math.min(
|
|
1826
|
+
k,
|
|
1827
|
+
Math.ceil(te * k / X)
|
|
1680
1828
|
);
|
|
1681
|
-
for (let oe =
|
|
1682
|
-
|
|
1829
|
+
for (let oe = me; oe < fe; ++oe)
|
|
1830
|
+
B[oe]++;
|
|
1683
1831
|
}
|
|
1684
|
-
let
|
|
1685
|
-
for (let
|
|
1686
|
-
|
|
1687
|
-
for (let
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
const
|
|
1691
|
-
for (let
|
|
1692
|
-
const
|
|
1832
|
+
let P = 0;
|
|
1833
|
+
for (let M = 0; M < k; ++M) P += B[M];
|
|
1834
|
+
F[0] = 0, U[0] = 0;
|
|
1835
|
+
for (let M = 1; M < k; ++M)
|
|
1836
|
+
F[M - 1] = B[M - 1] / P * i >>> 0, U[M] = U[M - 1] + F[M - 1];
|
|
1837
|
+
F[k - 1] = B[k - 1] / P * i >>> 0;
|
|
1838
|
+
const G = X / k;
|
|
1839
|
+
for (let M = 0; M < _; ++M) {
|
|
1840
|
+
const V = M * 3, H = r[V + 0], Z = r[V + 1], Q = r[V + 2], J = H * E + Z * y + Q * b, ee = (x - J) / G, te = Math.max(
|
|
1693
1841
|
0,
|
|
1694
1842
|
Math.min(
|
|
1695
|
-
|
|
1696
|
-
Math.floor(
|
|
1843
|
+
k - 1,
|
|
1844
|
+
Math.floor(ee)
|
|
1697
1845
|
)
|
|
1698
|
-
),
|
|
1699
|
-
|
|
1846
|
+
), me = ee - te, fe = U[te] + F[te] * me >>> 0, oe = Math.min(fe, i - 1);
|
|
1847
|
+
v[M] = oe, C[oe]++;
|
|
1700
1848
|
}
|
|
1701
1849
|
} else {
|
|
1702
|
-
const d = (
|
|
1703
|
-
for (let
|
|
1704
|
-
const
|
|
1705
|
-
|
|
1850
|
+
const d = (i - 1) / X;
|
|
1851
|
+
for (let P = 0; P < _; ++P) {
|
|
1852
|
+
const G = P * 3, M = r[G + 0], V = r[G + 1], H = r[G + 2], Z = M * E + V * y + H * b, J = (x - Z) * d >>> 0, K = Math.min(J, i - 1);
|
|
1853
|
+
v[P] = K, C[K]++;
|
|
1706
1854
|
}
|
|
1707
1855
|
}
|
|
1708
|
-
for (let d = 1; d <
|
|
1709
|
-
|
|
1710
|
-
for (let d =
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1856
|
+
for (let d = 1; d < i; d++)
|
|
1857
|
+
C[d] += C[d - 1];
|
|
1858
|
+
for (let d = _ - 1; d >= 0; d--) {
|
|
1859
|
+
const P = v[d], G = --C[P];
|
|
1860
|
+
s[G] = o ? o[d] : d;
|
|
1713
1861
|
}
|
|
1714
|
-
const
|
|
1715
|
-
if (!
|
|
1716
|
-
const
|
|
1717
|
-
if (!
|
|
1862
|
+
const A = T * E + S * y + z * b, q = (d) => {
|
|
1863
|
+
if (!s) return -1 / 0;
|
|
1864
|
+
const P = s[d], G = P;
|
|
1865
|
+
if (!r || G * 3 + 2 >= r.length)
|
|
1718
1866
|
return -1 / 0;
|
|
1719
|
-
const
|
|
1720
|
-
return
|
|
1867
|
+
const M = G * 3;
|
|
1868
|
+
return r[M] * E + r[M + 1] * y + r[M + 2] * b - A;
|
|
1721
1869
|
};
|
|
1722
|
-
let
|
|
1723
|
-
if (
|
|
1724
|
-
const d =
|
|
1870
|
+
let O = _;
|
|
1871
|
+
if (_ > 0 && q(_ - 1) < 0) {
|
|
1872
|
+
const d = N(
|
|
1725
1873
|
0,
|
|
1726
|
-
|
|
1727
|
-
|
|
1874
|
+
_ - 1,
|
|
1875
|
+
q
|
|
1728
1876
|
);
|
|
1729
|
-
|
|
1877
|
+
O = d < 0 ? ~d : d;
|
|
1730
1878
|
}
|
|
1731
|
-
const
|
|
1732
|
-
order:
|
|
1733
|
-
count:
|
|
1879
|
+
const R = {
|
|
1880
|
+
order: s.buffer,
|
|
1881
|
+
count: O
|
|
1734
1882
|
};
|
|
1735
|
-
self.postMessage(
|
|
1883
|
+
self.postMessage(R, [s.buffer]), s = null;
|
|
1736
1884
|
};
|
|
1737
|
-
self.onmessage = (
|
|
1738
|
-
const
|
|
1739
|
-
|
|
1740
|
-
let
|
|
1741
|
-
if (
|
|
1742
|
-
if (
|
|
1743
|
-
for (let
|
|
1744
|
-
const
|
|
1745
|
-
|
|
1746
|
-
(
|
|
1885
|
+
self.onmessage = (T) => {
|
|
1886
|
+
const S = T.data;
|
|
1887
|
+
S.order && (s = new Uint32Array(S.order));
|
|
1888
|
+
let z = !1;
|
|
1889
|
+
if (S.centers && (r = new Float32Array(S.centers), z = !0, g = !0), Object.prototype.hasOwnProperty.call(S, "mapping") && (o = S.mapping ? new Uint32Array(S.mapping) : null, g = !0), S.chunks) {
|
|
1890
|
+
if (n = new Float32Array(S.chunks), n.length > 0 && n[3] > 0)
|
|
1891
|
+
for (let E = 0; E < n.length / 6; ++E) {
|
|
1892
|
+
const y = E * 6, b = n[y + 0], j = n[y + 1], L = n[y + 2], I = n[y + 3], D = n[y + 4], x = n[y + 5];
|
|
1893
|
+
n[y + 0] = (b + I) * 0.5, n[y + 1] = (j + D) * 0.5, n[y + 2] = (L + x) * 0.5, n[y + 3] = Math.sqrt(
|
|
1894
|
+
(I - b) ** 2 + (D - j) ** 2 + (x - L) ** 2
|
|
1747
1895
|
) * 0.5;
|
|
1748
1896
|
}
|
|
1749
|
-
|
|
1897
|
+
g = !0;
|
|
1750
1898
|
}
|
|
1751
|
-
if (
|
|
1752
|
-
|
|
1753
|
-
for (let
|
|
1754
|
-
const
|
|
1755
|
-
|
|
1899
|
+
if (z && r && r.length > 0) {
|
|
1900
|
+
h.x = p.x = r[0], h.y = p.y = r[1], h.z = p.z = r[2];
|
|
1901
|
+
for (let E = 1; E < r.length / 3; E++) {
|
|
1902
|
+
const y = E * 3;
|
|
1903
|
+
h.x = Math.min(h.x, r[y + 0]), p.x = Math.max(p.x, r[y + 0]), h.y = Math.min(h.y, r[y + 1]), p.y = Math.max(p.y, r[y + 1]), h.z = Math.min(h.z, r[y + 2]), p.z = Math.max(p.z, r[y + 2]);
|
|
1756
1904
|
}
|
|
1757
|
-
} else
|
|
1758
|
-
|
|
1905
|
+
} else z && r && r.length === 0 && (h.x = p.x = h.y = p.y = h.z = p.z = 0);
|
|
1906
|
+
S.cameraPosition && (c = S.cameraPosition), S.cameraDirection && (f = S.cameraDirection), W();
|
|
1759
1907
|
};
|
|
1760
1908
|
}).toString()})();`;
|
|
1761
1909
|
}
|
|
1762
1910
|
}
|
|
1763
|
-
class
|
|
1911
|
+
class zt {
|
|
1764
1912
|
constructor(e) {
|
|
1765
|
-
|
|
1913
|
+
w(this, "packedGeometry");
|
|
1766
1914
|
// RGBA32UI
|
|
1767
|
-
|
|
1915
|
+
w(this, "packedColor");
|
|
1768
1916
|
// RGBA8
|
|
1769
|
-
|
|
1917
|
+
w(this, "orderTexture");
|
|
1770
1918
|
// RB32UI
|
|
1771
|
-
|
|
1772
|
-
|
|
1919
|
+
w(this, "width");
|
|
1920
|
+
w(this, "height");
|
|
1773
1921
|
this.width = e.textureWidth, this.height = e.textureHeight, this.packedColor = this.createColorTexture(e), this.packedGeometry = this.createGeometryTexture(e), this.orderTexture = this.createOrderTexture(e.numSplats);
|
|
1774
1922
|
}
|
|
1775
1923
|
createGeometryTexture(e) {
|
|
1776
|
-
const t = new
|
|
1924
|
+
const t = new u.DataTexture(
|
|
1777
1925
|
e.packedGeometry,
|
|
1778
1926
|
this.width,
|
|
1779
1927
|
this.height,
|
|
1780
|
-
|
|
1781
|
-
|
|
1928
|
+
u.RGBAIntegerFormat,
|
|
1929
|
+
u.UnsignedIntType
|
|
1782
1930
|
);
|
|
1783
|
-
return t.internalFormat = "RGBA32UI", t.minFilter =
|
|
1931
|
+
return t.internalFormat = "RGBA32UI", t.minFilter = u.NearestFilter, t.magFilter = u.NearestFilter, t.needsUpdate = !0, t;
|
|
1784
1932
|
}
|
|
1785
1933
|
createColorTexture(e) {
|
|
1786
|
-
const t = new
|
|
1934
|
+
const t = new u.DataTexture(
|
|
1787
1935
|
e.packedColor,
|
|
1788
1936
|
this.width,
|
|
1789
1937
|
this.height,
|
|
1790
|
-
|
|
1791
|
-
|
|
1938
|
+
u.RGBAFormat,
|
|
1939
|
+
u.UnsignedByteType
|
|
1792
1940
|
);
|
|
1793
|
-
return t.minFilter =
|
|
1941
|
+
return t.minFilter = u.NearestFilter, t.magFilter = u.NearestFilter, t.needsUpdate = !0, t;
|
|
1794
1942
|
}
|
|
1795
1943
|
createOrderTexture(e) {
|
|
1796
1944
|
const t = new Uint32Array(this.width * this.height);
|
|
1797
|
-
for (let
|
|
1798
|
-
const
|
|
1945
|
+
for (let r = 0; r < e; r++) t[r] = r;
|
|
1946
|
+
const s = new u.DataTexture(
|
|
1799
1947
|
t,
|
|
1800
1948
|
this.width,
|
|
1801
1949
|
this.height,
|
|
1802
|
-
|
|
1803
|
-
|
|
1950
|
+
u.RedIntegerFormat,
|
|
1951
|
+
u.UnsignedIntType
|
|
1804
1952
|
);
|
|
1805
|
-
return
|
|
1953
|
+
return s.minFilter = u.NearestFilter, s.magFilter = u.NearestFilter, s.needsUpdate = !0, s;
|
|
1806
1954
|
}
|
|
1807
1955
|
dispose() {
|
|
1808
1956
|
this.packedGeometry.dispose(), this.packedColor.dispose(), this.orderTexture.dispose();
|
|
1809
1957
|
}
|
|
1810
1958
|
}
|
|
1811
|
-
const
|
|
1959
|
+
const Bt = (
|
|
1812
1960
|
/* glsl */
|
|
1813
1961
|
`
|
|
1814
1962
|
precision highp float;
|
|
@@ -2033,7 +2181,7 @@ void main() {
|
|
|
2033
2181
|
vColor = vec4(max(clr.rgb, vec3(0.0)), clr.a);
|
|
2034
2182
|
}
|
|
2035
2183
|
`
|
|
2036
|
-
),
|
|
2184
|
+
), Pt = (
|
|
2037
2185
|
/* glsl */
|
|
2038
2186
|
`
|
|
2039
2187
|
precision highp float;
|
|
@@ -2069,7 +2217,7 @@ void main(void) {
|
|
|
2069
2217
|
}
|
|
2070
2218
|
`
|
|
2071
2219
|
);
|
|
2072
|
-
class
|
|
2220
|
+
class Dt extends u.ShaderMaterial {
|
|
2073
2221
|
constructor(e = {}) {
|
|
2074
2222
|
const t = {
|
|
2075
2223
|
// Packed Textures
|
|
@@ -2080,36 +2228,36 @@ class It extends h.ShaderMaterial {
|
|
|
2080
2228
|
splatOrder: { value: null },
|
|
2081
2229
|
// Index map
|
|
2082
2230
|
// Decompression Ranges
|
|
2083
|
-
meansMin: { value: new
|
|
2084
|
-
meansMax: { value: new
|
|
2085
|
-
scalesMin: { value: new
|
|
2086
|
-
scalesMax: { value: new
|
|
2087
|
-
sh0Min: { value: new
|
|
2088
|
-
sh0Max: { value: new
|
|
2231
|
+
meansMin: { value: new u.Vector3() },
|
|
2232
|
+
meansMax: { value: new u.Vector3() },
|
|
2233
|
+
scalesMin: { value: new u.Vector3() },
|
|
2234
|
+
scalesMax: { value: new u.Vector3() },
|
|
2235
|
+
sh0Min: { value: new u.Vector3() },
|
|
2236
|
+
sh0Max: { value: new u.Vector3() },
|
|
2089
2237
|
// Render State
|
|
2090
2238
|
texWidth: { value: 0 },
|
|
2091
|
-
viewport: { value: new
|
|
2239
|
+
viewport: { value: new u.Vector2(1, 1) },
|
|
2092
2240
|
numSplats: { value: 0 }
|
|
2093
2241
|
};
|
|
2094
2242
|
super({
|
|
2095
2243
|
uniforms: t,
|
|
2096
|
-
vertexShader:
|
|
2097
|
-
fragmentShader:
|
|
2244
|
+
vertexShader: Bt,
|
|
2245
|
+
fragmentShader: Pt,
|
|
2098
2246
|
transparent: !0,
|
|
2099
|
-
glslVersion:
|
|
2100
|
-
blendSrc:
|
|
2101
|
-
blendSrcAlpha:
|
|
2102
|
-
blending:
|
|
2103
|
-
blendEquation:
|
|
2104
|
-
blendEquationAlpha:
|
|
2105
|
-
blendDst:
|
|
2106
|
-
blendDstAlpha:
|
|
2247
|
+
glslVersion: u.GLSL3,
|
|
2248
|
+
blendSrc: u.OneFactor,
|
|
2249
|
+
blendSrcAlpha: u.OneFactor,
|
|
2250
|
+
blending: u.CustomBlending,
|
|
2251
|
+
blendEquation: u.AddEquation,
|
|
2252
|
+
blendEquationAlpha: u.AddEquation,
|
|
2253
|
+
blendDst: u.OneMinusSrcAlphaFactor,
|
|
2254
|
+
blendDstAlpha: u.OneMinusSrcAlphaFactor,
|
|
2107
2255
|
depthTest: !0,
|
|
2108
2256
|
depthWrite: !1,
|
|
2109
|
-
side:
|
|
2257
|
+
side: u.DoubleSide,
|
|
2110
2258
|
alphaTest: e.alphaTest ?? 0,
|
|
2111
2259
|
toneMapped: e.toneMapped ?? !1
|
|
2112
|
-
}), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending =
|
|
2260
|
+
}), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = u.NoBlending);
|
|
2113
2261
|
}
|
|
2114
2262
|
setTexWidth(e) {
|
|
2115
2263
|
this.uniforms.texWidth.value = e | 0;
|
|
@@ -2154,40 +2302,40 @@ class It extends h.ShaderMaterial {
|
|
|
2154
2302
|
this.uniforms.numSplats.value = e;
|
|
2155
2303
|
}
|
|
2156
2304
|
}
|
|
2157
|
-
const
|
|
2305
|
+
const xe = class xe extends u.Mesh {
|
|
2158
2306
|
// Match shader constant
|
|
2159
2307
|
/**
|
|
2160
2308
|
* Create a new SplatMesh for rendering Gaussian splats
|
|
2161
2309
|
* @param splatData The splat data to render
|
|
2162
2310
|
* @param options Rendering options
|
|
2163
2311
|
*/
|
|
2164
|
-
constructor(t,
|
|
2165
|
-
const
|
|
2166
|
-
super(
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2312
|
+
constructor(t, s = {}) {
|
|
2313
|
+
const r = new Dt(s), n = xe.createInstancedGeometry(t.numSplats, xe.INSTANCE_SIZE);
|
|
2314
|
+
super(n, r);
|
|
2315
|
+
w(this, "sorter");
|
|
2316
|
+
w(this, "options");
|
|
2317
|
+
w(this, "splatData");
|
|
2318
|
+
w(this, "textureManager");
|
|
2319
|
+
w(this, "material");
|
|
2320
|
+
w(this, "geometry");
|
|
2321
|
+
w(this, "lastCameraPositionLocal", new u.Vector3());
|
|
2322
|
+
w(this, "lastCameraDirectionLocal", new u.Vector3());
|
|
2323
|
+
w(this, "invModelMatrix", new u.Matrix4());
|
|
2176
2324
|
// Cached inverse matrix
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
const
|
|
2186
|
-
this.geometry.instanceCount = Math.ceil(
|
|
2325
|
+
w(this, "_vpW", -1);
|
|
2326
|
+
w(this, "_vpH", -1);
|
|
2327
|
+
w(this, "_size", new u.Vector2());
|
|
2328
|
+
w(this, "_camPosW", new u.Vector3());
|
|
2329
|
+
w(this, "_camDirW", new u.Vector3());
|
|
2330
|
+
w(this, "_camPosL", new u.Vector3());
|
|
2331
|
+
w(this, "_camDirL", new u.Vector3());
|
|
2332
|
+
w(this, "onSorterUpdated", (t) => {
|
|
2333
|
+
const s = t.count;
|
|
2334
|
+
this.geometry.instanceCount = Math.ceil(s / xe.INSTANCE_SIZE), this.material.setNumSplats(s);
|
|
2187
2335
|
});
|
|
2188
|
-
this.geometry =
|
|
2336
|
+
this.geometry = n, this.material = r, this.options = { autoSort: !0, ...s }, this.splatData = t, this.frustumCulled = !1, this.sorter = new Tt(), this.textureManager = new zt(t);
|
|
2189
2337
|
let o = this.createChunks() || void 0;
|
|
2190
|
-
o === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), o = void 0, this.sorter.addEventListener("updated", this.onSorterUpdated), this.sorter.init(this.textureManager.orderTexture, this.splatData.centers, o ?? void 0, !this.options.keepSplatData), this.material.setRanges(t.ranges), this.material.setTexWidth(t.textureWidth), this.material.setPackedColor(this.textureManager.packedColor), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setPackedGeometry(this.textureManager.packedGeometry), this.material.setNumSplats(0), this.geometry.boundingBox = t.boundingBox.toBox3(), this.geometry.boundingSphere = new
|
|
2338
|
+
o === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), o = void 0, this.sorter.addEventListener("updated", this.onSorterUpdated), this.sorter.init(this.textureManager.orderTexture, this.splatData.centers, o ?? void 0, !this.options.keepSplatData), this.material.setRanges(t.ranges), this.material.setTexWidth(t.textureWidth), this.material.setPackedColor(this.textureManager.packedColor), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setPackedGeometry(this.textureManager.packedGeometry), this.material.setNumSplats(0), this.geometry.boundingBox = t.boundingBox.toBox3(), this.geometry.boundingSphere = new u.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), this.options.keepSplatData || (this.splatData = null);
|
|
2191
2339
|
}
|
|
2192
2340
|
/**
|
|
2193
2341
|
* Creates the instanced geometry for rendering splats.
|
|
@@ -2195,8 +2343,8 @@ const de = class de extends h.Mesh {
|
|
|
2195
2343
|
* @param instanceSize Number of splats per instance.
|
|
2196
2344
|
* @returns InstancedBufferGeometry
|
|
2197
2345
|
*/
|
|
2198
|
-
static createInstancedGeometry(t,
|
|
2199
|
-
const
|
|
2346
|
+
static createInstancedGeometry(t, s) {
|
|
2347
|
+
const r = Math.ceil(t / s), n = new u.BufferGeometry(), o = new Float32Array([
|
|
2200
2348
|
// x, y, splat_index_in_instance
|
|
2201
2349
|
-1,
|
|
2202
2350
|
-1,
|
|
@@ -2210,24 +2358,24 @@ const de = class de extends h.Mesh {
|
|
|
2210
2358
|
-1,
|
|
2211
2359
|
1,
|
|
2212
2360
|
0
|
|
2213
|
-
]),
|
|
2214
|
-
for (let
|
|
2215
|
-
const
|
|
2216
|
-
for (let
|
|
2217
|
-
|
|
2361
|
+
]), c = new Uint16Array([0, 1, 2, 0, 2, 3]), f = new Float32Array(4 * 3 * s);
|
|
2362
|
+
for (let h = 0; h < s; h++) {
|
|
2363
|
+
const p = h * 4 * 3;
|
|
2364
|
+
for (let v = 0; v < 4; v++)
|
|
2365
|
+
f[p + v * 3 + 0] = o[v * 3 + 0], f[p + v * 3 + 1] = o[v * 3 + 1], f[p + v * 3 + 2] = h;
|
|
2218
2366
|
}
|
|
2219
|
-
const
|
|
2220
|
-
for (let
|
|
2221
|
-
const
|
|
2222
|
-
|
|
2367
|
+
const g = new Uint32Array(6 * s);
|
|
2368
|
+
for (let h = 0; h < s; h++) {
|
|
2369
|
+
const p = h * 6, v = h * 4;
|
|
2370
|
+
g[p + 0] = c[0] + v, g[p + 1] = c[1] + v, g[p + 2] = c[2] + v, g[p + 3] = c[3] + v, g[p + 4] = c[4] + v, g[p + 5] = c[5] + v;
|
|
2223
2371
|
}
|
|
2224
|
-
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2227
|
-
const l = new Uint32Array(
|
|
2228
|
-
for (let
|
|
2229
|
-
l[
|
|
2230
|
-
return
|
|
2372
|
+
n.setAttribute("position", new u.BufferAttribute(f, 3)), n.setIndex(new u.BufferAttribute(g, 1));
|
|
2373
|
+
const m = new u.InstancedBufferGeometry();
|
|
2374
|
+
m.index = n.index, m.setAttribute("position", n.getAttribute("position"));
|
|
2375
|
+
const l = new Uint32Array(r);
|
|
2376
|
+
for (let h = 0; h < r; h++)
|
|
2377
|
+
l[h] = h * s;
|
|
2378
|
+
return m.setAttribute("splatInstanceIndex", new u.InstancedBufferAttribute(l, 1, !1)), m.instanceCount = 0, m;
|
|
2231
2379
|
}
|
|
2232
2380
|
/**
|
|
2233
2381
|
* Create chunks data (bounding box min/max) for the sorter.
|
|
@@ -2251,8 +2399,8 @@ const de = class de extends h.Mesh {
|
|
|
2251
2399
|
* @param width Viewport width
|
|
2252
2400
|
* @param height Viewport height
|
|
2253
2401
|
*/
|
|
2254
|
-
updateViewport(t,
|
|
2255
|
-
t === this._vpW &&
|
|
2402
|
+
updateViewport(t, s) {
|
|
2403
|
+
t === this._vpW && s === this._vpH || (this._vpW = t, this._vpH = s, this.material.updateViewport(t, s));
|
|
2256
2404
|
}
|
|
2257
2405
|
/**
|
|
2258
2406
|
* Sorts splats based on camera position and direction.
|
|
@@ -2260,8 +2408,8 @@ const de = class de extends h.Mesh {
|
|
|
2260
2408
|
*/
|
|
2261
2409
|
sort(t) {
|
|
2262
2410
|
t.getWorldPosition(this._camPosW), t.getWorldDirection(this._camDirW), this.invModelMatrix.copy(this.matrixWorld).invert(), this._camPosL.copy(this._camPosW).applyMatrix4(this.invModelMatrix), this._camDirL.copy(this._camDirW).transformDirection(this.invModelMatrix);
|
|
2263
|
-
const
|
|
2264
|
-
this.options.autoSort && (
|
|
2411
|
+
const s = this.lastCameraPositionLocal.distanceToSquared(this._camPosL) > 1e-6, r = this.lastCameraDirectionLocal.dot(this._camDirL) < 0.999;
|
|
2412
|
+
this.options.autoSort && (s || r) && (this.lastCameraPositionLocal.copy(this._camPosL), this.lastCameraDirectionLocal.copy(this._camDirL), this.sorter.setCamera(this._camPosL, this._camDirL));
|
|
2265
2413
|
}
|
|
2266
2414
|
/**
|
|
2267
2415
|
* THREE.js hook called before rendering the object.
|
|
@@ -2272,8 +2420,8 @@ const de = class de extends h.Mesh {
|
|
|
2272
2420
|
*/
|
|
2273
2421
|
// prettier-ignore
|
|
2274
2422
|
// @ts-expect-error scene is not used
|
|
2275
|
-
onBeforeRender(t,
|
|
2276
|
-
this.sort(
|
|
2423
|
+
onBeforeRender(t, s, r) {
|
|
2424
|
+
this.sort(r), t.getSize(this._size), this.updateViewport(this._size.x, this._size.y);
|
|
2277
2425
|
}
|
|
2278
2426
|
/**
|
|
2279
2427
|
* Dispose of resources
|
|
@@ -2283,51 +2431,51 @@ const de = class de extends h.Mesh {
|
|
|
2283
2431
|
}
|
|
2284
2432
|
};
|
|
2285
2433
|
/** Number of splats combined into a single instanced draw call. */
|
|
2286
|
-
|
|
2287
|
-
let
|
|
2288
|
-
const
|
|
2289
|
-
url:
|
|
2434
|
+
w(xe, "INSTANCE_SIZE", 128);
|
|
2435
|
+
let De = xe;
|
|
2436
|
+
const Ae = /* @__PURE__ */ new Map(), jt = ({
|
|
2437
|
+
url: a,
|
|
2290
2438
|
type: e,
|
|
2291
2439
|
debug: t = !1,
|
|
2292
|
-
splatOptions:
|
|
2293
|
-
...
|
|
2440
|
+
splatOptions: s = {},
|
|
2441
|
+
...r
|
|
2294
2442
|
}) => {
|
|
2295
|
-
if (!
|
|
2296
|
-
const
|
|
2297
|
-
t && console.debug("SPLAT: rendering", { url:
|
|
2298
|
-
const [o,
|
|
2299
|
-
return
|
|
2300
|
-
const
|
|
2301
|
-
return
|
|
2302
|
-
(
|
|
2303
|
-
|
|
2443
|
+
if (!a) throw new Error('Splat component requires either "url" or "plyUrl" prop');
|
|
2444
|
+
const n = Ft(a, e);
|
|
2445
|
+
t && console.debug("SPLAT: rendering", { url: a, type: n, splatOptions: s, meshProps: r });
|
|
2446
|
+
const [o, c] = tt(null), f = st(null);
|
|
2447
|
+
return rt(() => {
|
|
2448
|
+
const g = Je(a, n, s);
|
|
2449
|
+
return Ot(a, n, s).then(
|
|
2450
|
+
(m) => {
|
|
2451
|
+
c(m);
|
|
2304
2452
|
}
|
|
2305
2453
|
), () => {
|
|
2306
|
-
t && console.debug("SPLAT: releasing mesh for",
|
|
2454
|
+
t && console.debug("SPLAT: releasing mesh for", a), Ut(g);
|
|
2307
2455
|
};
|
|
2308
|
-
}, [
|
|
2309
|
-
},
|
|
2310
|
-
const e =
|
|
2311
|
-
return e.endsWith(".ply") ? "ply" : e.endsWith(".sogs") || e.endsWith(".zip") || e.endsWith(".json") ? "sogs" : null;
|
|
2312
|
-
},
|
|
2456
|
+
}, [a, n, s, t]), o ? /* @__PURE__ */ it.jsx("primitive", { ref: f, object: o, ...r }) : null;
|
|
2457
|
+
}, qt = (a) => {
|
|
2458
|
+
const e = a.toLowerCase();
|
|
2459
|
+
return e.endsWith(".ply") ? "ply" : e.endsWith(".sogs") || e.endsWith(".zip") || e.endsWith(".json") || e.endsWith(".sog") || e.endsWith(".sogs") || e.endsWith(".zip") ? "sogs" : null;
|
|
2460
|
+
}, Ft = (a, e) => {
|
|
2313
2461
|
if (e) return e;
|
|
2314
|
-
const t =
|
|
2462
|
+
const t = qt(a);
|
|
2315
2463
|
if (t) return t;
|
|
2316
|
-
throw new Error(`Cannot determine file type from URL: "${
|
|
2317
|
-
},
|
|
2318
|
-
const
|
|
2319
|
-
if (
|
|
2320
|
-
return
|
|
2321
|
-
const o = await (e === "ply" ? new
|
|
2322
|
-
return
|
|
2464
|
+
throw new Error(`Cannot determine file type from URL: "${a}". `);
|
|
2465
|
+
}, Je = (a, e, t) => `${a}:${e}:${JSON.stringify(t)}`, Ot = async (a, e, t) => {
|
|
2466
|
+
const s = Je(a, e, t), r = Ae.get(s);
|
|
2467
|
+
if (r)
|
|
2468
|
+
return r.refCount++, r.mesh;
|
|
2469
|
+
const o = await (e === "ply" ? new lt() : new _t()).loadAsync(a), c = new De(o, t);
|
|
2470
|
+
return Ae.set(s, { mesh: c, refCount: 1 }), c;
|
|
2323
2471
|
};
|
|
2324
|
-
function
|
|
2325
|
-
const e =
|
|
2326
|
-
e && (e.refCount--, e.refCount <= 0 && (e.mesh.dispose(),
|
|
2472
|
+
function Ut(a) {
|
|
2473
|
+
const e = Ae.get(a);
|
|
2474
|
+
e && (e.refCount--, e.refCount <= 0 && (e.mesh.dispose(), Ae.delete(a)));
|
|
2327
2475
|
}
|
|
2328
2476
|
export {
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2477
|
+
lt as PlyLoader,
|
|
2478
|
+
_t as SogsLoader,
|
|
2479
|
+
jt as Splat,
|
|
2480
|
+
De as SplatMesh
|
|
2333
2481
|
};
|