@speridlabs/visus 1.0.1 → 1.0.3
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 +328 -0
- package/dist/main.es.js +1307 -0
- package/dist/main.umd.js +5 -5
- package/dist/react.d.ts +1 -0
- package/dist/react.es.js +535 -531
- package/package.json +1 -1
package/dist/react.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var me = Object.defineProperty;
|
|
2
|
-
var xe = (
|
|
3
|
-
var
|
|
4
|
-
import
|
|
2
|
+
var xe = (T, e, o) => e in T ? me(T, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : T[e] = o;
|
|
3
|
+
var h = (T, e, o) => xe(T, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
import ve, { useRef as ye, useMemo as ge, useEffect as we } from "react";
|
|
5
5
|
import { useLoader as be } from "@react-three/fiber";
|
|
6
6
|
import * as i from "three";
|
|
7
7
|
var se = { exports: {} }, te = {};
|
|
@@ -18,23 +18,23 @@ var ue;
|
|
|
18
18
|
function Se() {
|
|
19
19
|
if (ue) return te;
|
|
20
20
|
ue = 1;
|
|
21
|
-
var
|
|
22
|
-
function
|
|
21
|
+
var T = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
22
|
+
function o(t, r, n) {
|
|
23
23
|
var a = null;
|
|
24
|
-
if (
|
|
25
|
-
|
|
24
|
+
if (n !== void 0 && (a = "" + n), r.key !== void 0 && (a = "" + r.key), "key" in r) {
|
|
25
|
+
n = {};
|
|
26
26
|
for (var c in r)
|
|
27
|
-
c !== "key" && (
|
|
28
|
-
} else
|
|
29
|
-
return r =
|
|
30
|
-
$$typeof:
|
|
31
|
-
type:
|
|
27
|
+
c !== "key" && (n[c] = r[c]);
|
|
28
|
+
} else n = r;
|
|
29
|
+
return r = n.ref, {
|
|
30
|
+
$$typeof: T,
|
|
31
|
+
type: t,
|
|
32
32
|
key: a,
|
|
33
33
|
ref: r !== void 0 ? r : null,
|
|
34
|
-
props:
|
|
34
|
+
props: n
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
return te.Fragment = e, te.jsx =
|
|
37
|
+
return te.Fragment = e, te.jsx = o, te.jsxs = o, te;
|
|
38
38
|
}
|
|
39
39
|
var re = {};
|
|
40
40
|
/**
|
|
@@ -46,251 +46,251 @@ var re = {};
|
|
|
46
46
|
* This source code is licensed under the MIT license found in the
|
|
47
47
|
* LICENSE file in the root directory of this source tree.
|
|
48
48
|
*/
|
|
49
|
-
var
|
|
50
|
-
function
|
|
51
|
-
return
|
|
52
|
-
function
|
|
53
|
-
if (
|
|
54
|
-
if (typeof
|
|
55
|
-
return
|
|
56
|
-
if (typeof
|
|
57
|
-
switch (
|
|
58
|
-
case
|
|
49
|
+
var he;
|
|
50
|
+
function _e() {
|
|
51
|
+
return he || (he = 1, process.env.NODE_ENV !== "production" && function() {
|
|
52
|
+
function T(s) {
|
|
53
|
+
if (s == null) return null;
|
|
54
|
+
if (typeof s == "function")
|
|
55
|
+
return s.$$typeof === w ? null : s.displayName || s.name || null;
|
|
56
|
+
if (typeof s == "string") return s;
|
|
57
|
+
switch (s) {
|
|
58
|
+
case _:
|
|
59
59
|
return "Fragment";
|
|
60
60
|
case q:
|
|
61
61
|
return "Profiler";
|
|
62
|
-
case
|
|
62
|
+
case B:
|
|
63
63
|
return "StrictMode";
|
|
64
64
|
case $:
|
|
65
65
|
return "Suspense";
|
|
66
|
-
case
|
|
66
|
+
case F:
|
|
67
67
|
return "SuspenseList";
|
|
68
|
-
case
|
|
68
|
+
case A:
|
|
69
69
|
return "Activity";
|
|
70
70
|
}
|
|
71
|
-
if (typeof
|
|
72
|
-
switch (typeof
|
|
71
|
+
if (typeof s == "object")
|
|
72
|
+
switch (typeof s.tag == "number" && console.error(
|
|
73
73
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
74
|
-
),
|
|
75
|
-
case
|
|
74
|
+
), s.$$typeof) {
|
|
75
|
+
case f:
|
|
76
76
|
return "Portal";
|
|
77
77
|
case j:
|
|
78
|
-
return (
|
|
78
|
+
return (s.displayName || "Context") + ".Provider";
|
|
79
79
|
case W:
|
|
80
|
-
return (
|
|
80
|
+
return (s._context.displayName || "Context") + ".Consumer";
|
|
81
81
|
case H:
|
|
82
|
-
var d =
|
|
83
|
-
return
|
|
84
|
-
case
|
|
85
|
-
return d =
|
|
86
|
-
case
|
|
87
|
-
d =
|
|
82
|
+
var d = s.render;
|
|
83
|
+
return s = s.displayName, s || (s = d.displayName || d.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
|
|
84
|
+
case E:
|
|
85
|
+
return d = s.displayName || null, d !== null ? d : T(s.type) || "Memo";
|
|
86
|
+
case O:
|
|
87
|
+
d = s._payload, s = s._init;
|
|
88
88
|
try {
|
|
89
|
-
return
|
|
89
|
+
return T(s(d));
|
|
90
90
|
} catch {
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
|
-
function e(
|
|
96
|
-
return "" +
|
|
95
|
+
function e(s) {
|
|
96
|
+
return "" + s;
|
|
97
97
|
}
|
|
98
|
-
function s
|
|
98
|
+
function o(s) {
|
|
99
99
|
try {
|
|
100
|
-
e(
|
|
100
|
+
e(s);
|
|
101
101
|
var d = !1;
|
|
102
102
|
} catch {
|
|
103
103
|
d = !0;
|
|
104
104
|
}
|
|
105
105
|
if (d) {
|
|
106
106
|
d = console;
|
|
107
|
-
var
|
|
108
|
-
return
|
|
107
|
+
var M = d.error, R = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
|
|
108
|
+
return M.call(
|
|
109
109
|
d,
|
|
110
110
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
111
|
-
|
|
112
|
-
), e(
|
|
111
|
+
R
|
|
112
|
+
), e(s);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
if (typeof
|
|
115
|
+
function t(s) {
|
|
116
|
+
if (s === _) return "<>";
|
|
117
|
+
if (typeof s == "object" && s !== null && s.$$typeof === O)
|
|
118
118
|
return "<...>";
|
|
119
119
|
try {
|
|
120
|
-
var d =
|
|
120
|
+
var d = T(s);
|
|
121
121
|
return d ? "<" + d + ">" : "<...>";
|
|
122
122
|
} catch {
|
|
123
123
|
return "<...>";
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
function r() {
|
|
127
|
-
var
|
|
128
|
-
return
|
|
127
|
+
var s = P.A;
|
|
128
|
+
return s === null ? null : s.getOwner();
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function n() {
|
|
131
131
|
return Error("react-stack-top-frame");
|
|
132
132
|
}
|
|
133
|
-
function a(
|
|
134
|
-
if (U.call(
|
|
135
|
-
var d = Object.getOwnPropertyDescriptor(
|
|
133
|
+
function a(s) {
|
|
134
|
+
if (U.call(s, "key")) {
|
|
135
|
+
var d = Object.getOwnPropertyDescriptor(s, "key").get;
|
|
136
136
|
if (d && d.isReactWarning) return !1;
|
|
137
137
|
}
|
|
138
|
-
return
|
|
138
|
+
return s.key !== void 0;
|
|
139
139
|
}
|
|
140
|
-
function c(
|
|
141
|
-
function
|
|
142
|
-
|
|
140
|
+
function c(s, d) {
|
|
141
|
+
function M() {
|
|
142
|
+
x || (x = !0, console.error(
|
|
143
143
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
144
144
|
d
|
|
145
145
|
));
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
get:
|
|
147
|
+
M.isReactWarning = !0, Object.defineProperty(s, "key", {
|
|
148
|
+
get: M,
|
|
149
149
|
configurable: !0
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
var
|
|
154
|
-
return
|
|
152
|
+
function v() {
|
|
153
|
+
var s = T(this.type);
|
|
154
|
+
return C[s] || (C[s] = !0, console.error(
|
|
155
155
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
156
|
-
)),
|
|
156
|
+
)), s = this.props.ref, s !== void 0 ? s : null;
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
160
|
-
$$typeof:
|
|
161
|
-
type:
|
|
158
|
+
function g(s, d, M, R, L, u, z, D) {
|
|
159
|
+
return M = u.ref, s = {
|
|
160
|
+
$$typeof: m,
|
|
161
|
+
type: s,
|
|
162
162
|
key: d,
|
|
163
|
-
props:
|
|
164
|
-
_owner:
|
|
165
|
-
}, (
|
|
163
|
+
props: u,
|
|
164
|
+
_owner: L
|
|
165
|
+
}, (M !== void 0 ? M : null) !== null ? Object.defineProperty(s, "ref", {
|
|
166
166
|
enumerable: !1,
|
|
167
|
-
get:
|
|
168
|
-
}) : Object.defineProperty(
|
|
167
|
+
get: v
|
|
168
|
+
}) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
|
|
169
169
|
configurable: !1,
|
|
170
170
|
enumerable: !1,
|
|
171
171
|
writable: !0,
|
|
172
172
|
value: 0
|
|
173
|
-
}), Object.defineProperty(
|
|
173
|
+
}), Object.defineProperty(s, "_debugInfo", {
|
|
174
174
|
configurable: !1,
|
|
175
175
|
enumerable: !1,
|
|
176
176
|
writable: !0,
|
|
177
177
|
value: null
|
|
178
|
-
}), Object.defineProperty(
|
|
178
|
+
}), Object.defineProperty(s, "_debugStack", {
|
|
179
179
|
configurable: !1,
|
|
180
180
|
enumerable: !1,
|
|
181
181
|
writable: !0,
|
|
182
|
-
value:
|
|
183
|
-
}), Object.defineProperty(
|
|
182
|
+
value: z
|
|
183
|
+
}), Object.defineProperty(s, "_debugTask", {
|
|
184
184
|
configurable: !1,
|
|
185
185
|
enumerable: !1,
|
|
186
186
|
writable: !0,
|
|
187
|
-
value:
|
|
188
|
-
}), Object.freeze && (Object.freeze(
|
|
187
|
+
value: D
|
|
188
|
+
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
|
|
189
189
|
}
|
|
190
|
-
function S(
|
|
191
|
-
var
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
if (V(
|
|
195
|
-
for (
|
|
196
|
-
b(
|
|
197
|
-
Object.freeze && Object.freeze(
|
|
190
|
+
function S(s, d, M, R, L, u, z, D) {
|
|
191
|
+
var l = d.children;
|
|
192
|
+
if (l !== void 0)
|
|
193
|
+
if (R)
|
|
194
|
+
if (V(l)) {
|
|
195
|
+
for (R = 0; R < l.length; R++)
|
|
196
|
+
b(l[R]);
|
|
197
|
+
Object.freeze && Object.freeze(l);
|
|
198
198
|
} else
|
|
199
199
|
console.error(
|
|
200
200
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
201
201
|
);
|
|
202
|
-
else b(
|
|
202
|
+
else b(l);
|
|
203
203
|
if (U.call(d, "key")) {
|
|
204
|
-
|
|
205
|
-
var
|
|
204
|
+
l = T(s);
|
|
205
|
+
var k = Object.keys(d).filter(function(X) {
|
|
206
206
|
return X !== "key";
|
|
207
207
|
});
|
|
208
|
-
|
|
208
|
+
R = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", G[l + R] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
209
209
|
`A props object containing a "key" prop is being spread into JSX:
|
|
210
210
|
let props = %s;
|
|
211
211
|
<%s {...props} />
|
|
212
212
|
React keys must be passed directly to JSX without using spread:
|
|
213
213
|
let props = %s;
|
|
214
214
|
<%s key={someKey} {...props} />`,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
), G[
|
|
215
|
+
R,
|
|
216
|
+
l,
|
|
217
|
+
k,
|
|
218
|
+
l
|
|
219
|
+
), G[l + R] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
222
|
-
|
|
221
|
+
if (l = null, M !== void 0 && (o(M), l = "" + M), a(d) && (o(d.key), l = "" + d.key), "key" in d) {
|
|
222
|
+
M = {};
|
|
223
223
|
for (var Y in d)
|
|
224
|
-
Y !== "key" && (
|
|
225
|
-
} else
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
typeof
|
|
229
|
-
),
|
|
230
|
-
|
|
224
|
+
Y !== "key" && (M[Y] = d[Y]);
|
|
225
|
+
} else M = d;
|
|
226
|
+
return l && c(
|
|
227
|
+
M,
|
|
228
|
+
typeof s == "function" ? s.displayName || s.name || "Unknown" : s
|
|
229
|
+
), g(
|
|
230
|
+
s,
|
|
231
|
+
l,
|
|
231
232
|
u,
|
|
232
|
-
|
|
233
|
-
N,
|
|
233
|
+
L,
|
|
234
234
|
r(),
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
M,
|
|
236
|
+
z,
|
|
237
|
+
D
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
-
function b(
|
|
241
|
-
typeof
|
|
240
|
+
function b(s) {
|
|
241
|
+
typeof s == "object" && s !== null && s.$$typeof === m && s._store && (s._store.validated = 1);
|
|
242
242
|
}
|
|
243
|
-
var p =
|
|
243
|
+
var p = ve, m = Symbol.for("react.transitional.element"), f = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), B = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), j = Symbol.for("react.context"), H = Symbol.for("react.forward_ref"), $ = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), A = Symbol.for("react.activity"), w = Symbol.for("react.client.reference"), P = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, V = Array.isArray, y = console.createTask ? console.createTask : function() {
|
|
244
244
|
return null;
|
|
245
245
|
};
|
|
246
246
|
p = {
|
|
247
|
-
"react-stack-bottom-frame": function(
|
|
248
|
-
return
|
|
247
|
+
"react-stack-bottom-frame": function(s) {
|
|
248
|
+
return s();
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
var
|
|
251
|
+
var x, C = {}, I = p["react-stack-bottom-frame"].bind(
|
|
252
252
|
p,
|
|
253
|
-
|
|
254
|
-
)(),
|
|
255
|
-
re.Fragment =
|
|
256
|
-
var
|
|
253
|
+
n
|
|
254
|
+
)(), N = y(t(n)), G = {};
|
|
255
|
+
re.Fragment = _, re.jsx = function(s, d, M, R, L) {
|
|
256
|
+
var u = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
257
257
|
return S(
|
|
258
|
-
|
|
258
|
+
s,
|
|
259
259
|
d,
|
|
260
|
-
|
|
260
|
+
M,
|
|
261
261
|
!1,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
R,
|
|
263
|
+
L,
|
|
264
|
+
u ? Error("react-stack-top-frame") : I,
|
|
265
|
+
u ? y(t(s)) : N
|
|
266
266
|
);
|
|
267
|
-
}, re.jsxs = function(
|
|
268
|
-
var
|
|
267
|
+
}, re.jsxs = function(s, d, M, R, L) {
|
|
268
|
+
var u = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
269
269
|
return S(
|
|
270
|
-
|
|
270
|
+
s,
|
|
271
271
|
d,
|
|
272
|
-
|
|
272
|
+
M,
|
|
273
273
|
!0,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
R,
|
|
275
|
+
L,
|
|
276
|
+
u ? Error("react-stack-top-frame") : I,
|
|
277
|
+
u ? y(t(s)) : N
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
280
|
}()), re;
|
|
281
281
|
}
|
|
282
|
-
var
|
|
283
|
-
function
|
|
284
|
-
return
|
|
282
|
+
var fe;
|
|
283
|
+
function Te() {
|
|
284
|
+
return fe || (fe = 1, process.env.NODE_ENV === "production" ? se.exports = Se() : se.exports = _e()), se.exports;
|
|
285
285
|
}
|
|
286
|
-
var Me =
|
|
286
|
+
var Me = Te();
|
|
287
287
|
class le {
|
|
288
288
|
constructor() {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
h(this, "min", new i.Vector3(1 / 0, 1 / 0, 1 / 0));
|
|
290
|
+
h(this, "max", new i.Vector3(-1 / 0, -1 / 0, -1 / 0));
|
|
291
|
+
h(this, "center", new i.Vector3());
|
|
292
292
|
/** Half extents (size/2) */
|
|
293
|
-
|
|
293
|
+
h(this, "halfExtents", new i.Vector3());
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Reset the bounding box to its initial state
|
|
@@ -345,14 +345,14 @@ class le {
|
|
|
345
345
|
class Ae {
|
|
346
346
|
// TODO: there is no sh spherical harmonics
|
|
347
347
|
constructor(e = 0) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
348
|
+
h(this, "numSplats", 0);
|
|
349
|
+
h(this, "positions");
|
|
350
|
+
h(this, "rotations");
|
|
351
|
+
h(this, "scales");
|
|
352
|
+
h(this, "colors");
|
|
353
|
+
h(this, "opacities");
|
|
354
|
+
h(this, "centers");
|
|
355
|
+
h(this, "boundingBox", new le());
|
|
356
356
|
this.numSplats = e, this.allocateBuffers(e);
|
|
357
357
|
}
|
|
358
358
|
allocateBuffers(e) {
|
|
@@ -367,13 +367,13 @@ class Ae {
|
|
|
367
367
|
* @param color Color
|
|
368
368
|
* @param opacity Opacity value
|
|
369
369
|
*/
|
|
370
|
-
setSplat(e,
|
|
370
|
+
setSplat(e, o, t, r, n, a) {
|
|
371
371
|
if (e >= this.numSplats)
|
|
372
372
|
throw new Error(
|
|
373
373
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
374
374
|
);
|
|
375
|
-
const c = e * 3,
|
|
376
|
-
this.positions[c] =
|
|
375
|
+
const c = e * 3, v = e * 4, g = e * 3, S = e * 3;
|
|
376
|
+
this.positions[c] = o.x, this.positions[c + 1] = o.y, this.positions[c + 2] = o.z, this.rotations[v] = t.x, this.rotations[v + 1] = t.y, this.rotations[v + 2] = t.z, this.rotations[v + 3] = t.w, this.scales[g] = r.x, this.scales[g + 1] = r.y, this.scales[g + 2] = r.z, this.colors[S] = n.r, this.colors[S + 1] = n.g, this.colors[S + 2] = n.b, this.opacities[e] = a, this.centers[c] = o.x, this.centers[c + 1] = o.y, this.centers[c + 2] = o.z;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* Get a splat's data
|
|
@@ -385,18 +385,18 @@ class Ae {
|
|
|
385
385
|
throw new Error(
|
|
386
386
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
387
387
|
);
|
|
388
|
-
const
|
|
388
|
+
const o = e * 3, t = e * 4, r = e * 3, n = e * 3;
|
|
389
389
|
return {
|
|
390
390
|
position: new i.Vector3(
|
|
391
|
-
this.positions[
|
|
392
|
-
this.positions[
|
|
393
|
-
this.positions[
|
|
391
|
+
this.positions[o],
|
|
392
|
+
this.positions[o + 1],
|
|
393
|
+
this.positions[o + 2]
|
|
394
394
|
),
|
|
395
395
|
rotation: new i.Quaternion(
|
|
396
|
-
this.rotations[
|
|
397
|
-
this.rotations[
|
|
398
|
-
this.rotations[
|
|
399
|
-
this.rotations[
|
|
396
|
+
this.rotations[t],
|
|
397
|
+
this.rotations[t + 1],
|
|
398
|
+
this.rotations[t + 2],
|
|
399
|
+
this.rotations[t + 3]
|
|
400
400
|
),
|
|
401
401
|
// Convert log scale back to linear scale for external use
|
|
402
402
|
scale: new i.Vector3(
|
|
@@ -405,9 +405,9 @@ class Ae {
|
|
|
405
405
|
Math.exp(this.scales[r + 2])
|
|
406
406
|
),
|
|
407
407
|
color: new i.Color(
|
|
408
|
-
this.colors[
|
|
409
|
-
this.colors[
|
|
410
|
-
this.colors[
|
|
408
|
+
this.colors[n],
|
|
409
|
+
this.colors[n + 1],
|
|
410
|
+
this.colors[n + 2]
|
|
411
411
|
),
|
|
412
412
|
opacity: this.opacities[e]
|
|
413
413
|
};
|
|
@@ -419,12 +419,12 @@ class Ae {
|
|
|
419
419
|
calculateBoundingBox() {
|
|
420
420
|
this.boundingBox.reset();
|
|
421
421
|
const e = new i.Vector3();
|
|
422
|
-
for (let
|
|
423
|
-
const
|
|
422
|
+
for (let o = 0; o < this.numSplats; o++) {
|
|
423
|
+
const t = o * 3;
|
|
424
424
|
e.set(
|
|
425
|
-
this.positions[
|
|
426
|
-
this.positions[
|
|
427
|
-
this.positions[
|
|
425
|
+
this.positions[t],
|
|
426
|
+
this.positions[t + 1],
|
|
427
|
+
this.positions[t + 2]
|
|
428
428
|
), this.boundingBox.expandByPoint(e);
|
|
429
429
|
}
|
|
430
430
|
return this.boundingBox;
|
|
@@ -439,19 +439,19 @@ class Ae {
|
|
|
439
439
|
"position",
|
|
440
440
|
new i.BufferAttribute(this.positions, 3)
|
|
441
441
|
);
|
|
442
|
-
const
|
|
443
|
-
for (let
|
|
444
|
-
const a =
|
|
445
|
-
|
|
442
|
+
const o = new Float32Array(this.numSplats * 3), t = new i.Quaternion(), r = new i.Euler();
|
|
443
|
+
for (let n = 0; n < this.numSplats; n++) {
|
|
444
|
+
const a = n * 4, c = n * 3;
|
|
445
|
+
t.set(
|
|
446
446
|
this.rotations[a],
|
|
447
447
|
this.rotations[a + 1],
|
|
448
448
|
this.rotations[a + 2],
|
|
449
449
|
this.rotations[a + 3]
|
|
450
|
-
), r.setFromQuaternion(
|
|
450
|
+
), r.setFromQuaternion(t), o[c] = r.x, o[c + 1] = r.y, o[c + 2] = r.z;
|
|
451
451
|
}
|
|
452
452
|
return e.setAttribute(
|
|
453
453
|
"rotation",
|
|
454
|
-
new i.BufferAttribute(
|
|
454
|
+
new i.BufferAttribute(o, 3)
|
|
455
455
|
), e.setAttribute(
|
|
456
456
|
"scale",
|
|
457
457
|
new i.BufferAttribute(this.scales, 3)
|
|
@@ -464,7 +464,7 @@ class Ae {
|
|
|
464
464
|
), e;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class
|
|
467
|
+
class Ce extends i.Loader {
|
|
468
468
|
/**
|
|
469
469
|
* Load a PLY file with Gaussian Splat data
|
|
470
470
|
* @param url URL of the PLY file
|
|
@@ -472,21 +472,21 @@ class Ee extends i.Loader {
|
|
|
472
472
|
* @param onProgress Optional progress callback
|
|
473
473
|
* @param onError Optional error callback
|
|
474
474
|
*/
|
|
475
|
-
load(e,
|
|
476
|
-
const
|
|
477
|
-
|
|
475
|
+
load(e, o, t, r) {
|
|
476
|
+
const n = new i.FileLoader(this.manager);
|
|
477
|
+
n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
478
478
|
e,
|
|
479
479
|
(a) => {
|
|
480
480
|
try {
|
|
481
|
-
if (
|
|
481
|
+
if (o) {
|
|
482
482
|
const c = this.parse(a);
|
|
483
|
-
|
|
483
|
+
o(c);
|
|
484
484
|
}
|
|
485
485
|
} catch (c) {
|
|
486
486
|
r ? r(c) : console.error(c), this.manager.itemError(e);
|
|
487
487
|
}
|
|
488
488
|
},
|
|
489
|
-
|
|
489
|
+
t,
|
|
490
490
|
r
|
|
491
491
|
);
|
|
492
492
|
}
|
|
@@ -496,20 +496,20 @@ class Ee extends i.Loader {
|
|
|
496
496
|
* @param onProgress Optional progress callback
|
|
497
497
|
* @returns A Promise that resolves with the parsed SplatData
|
|
498
498
|
*/
|
|
499
|
-
loadAsync(e,
|
|
500
|
-
return new Promise((
|
|
501
|
-
const
|
|
502
|
-
|
|
499
|
+
loadAsync(e, o) {
|
|
500
|
+
return new Promise((t, r) => {
|
|
501
|
+
const n = new i.FileLoader(this.manager);
|
|
502
|
+
n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
503
503
|
e,
|
|
504
504
|
(a) => {
|
|
505
505
|
try {
|
|
506
506
|
const c = this.parse(a);
|
|
507
|
-
|
|
507
|
+
t(c);
|
|
508
508
|
} catch (c) {
|
|
509
509
|
r(c), this.manager.itemError(e);
|
|
510
510
|
}
|
|
511
511
|
},
|
|
512
|
-
|
|
512
|
+
o,
|
|
513
513
|
(a) => {
|
|
514
514
|
r(a), this.manager.itemError(e);
|
|
515
515
|
}
|
|
@@ -522,55 +522,53 @@ class Ee extends i.Loader {
|
|
|
522
522
|
* @returns Parsed SplatData
|
|
523
523
|
*/
|
|
524
524
|
parse(e) {
|
|
525
|
-
const
|
|
525
|
+
const o = new TextDecoder(), t = new Uint8Array(e), r = [112, 108, 121, 10], n = `
|
|
526
526
|
end_header
|
|
527
527
|
`;
|
|
528
|
-
for (let
|
|
529
|
-
if (
|
|
528
|
+
for (let y = 0; y < r.length; y++)
|
|
529
|
+
if (t[y] !== r[y])
|
|
530
530
|
throw new Error("Invalid PLY file: Missing magic bytes");
|
|
531
531
|
let a = 0;
|
|
532
|
-
for (let
|
|
533
|
-
let
|
|
534
|
-
for (let
|
|
535
|
-
if (
|
|
536
|
-
|
|
532
|
+
for (let y = 0; y < t.length - n.length; y++) {
|
|
533
|
+
let x = !0;
|
|
534
|
+
for (let C = 0; C < n.length; C++)
|
|
535
|
+
if (t[y + C] !== n.charCodeAt(C)) {
|
|
536
|
+
x = !1;
|
|
537
537
|
break;
|
|
538
538
|
}
|
|
539
|
-
if (
|
|
540
|
-
a =
|
|
539
|
+
if (x) {
|
|
540
|
+
a = y + n.length;
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
if (a === 0)
|
|
545
545
|
throw new Error("Invalid PLY file: Could not find end of header");
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
).split(`
|
|
549
|
-
`), m = [];
|
|
546
|
+
const v = o.decode(t.subarray(0, a)).split(`
|
|
547
|
+
`), g = [];
|
|
550
548
|
let S = null;
|
|
551
|
-
for (let
|
|
552
|
-
const
|
|
553
|
-
if (
|
|
554
|
-
const
|
|
555
|
-
switch (
|
|
549
|
+
for (let y = 1; y < v.length; y++) {
|
|
550
|
+
const x = v[y].trim();
|
|
551
|
+
if (x === "" || x === "end_header") continue;
|
|
552
|
+
const C = x.split(" ");
|
|
553
|
+
switch (C[0]) {
|
|
556
554
|
case "format":
|
|
557
|
-
S =
|
|
555
|
+
S = C[1];
|
|
558
556
|
break;
|
|
559
557
|
case "element":
|
|
560
|
-
|
|
561
|
-
name:
|
|
562
|
-
count: parseInt(
|
|
558
|
+
g.push({
|
|
559
|
+
name: C[1],
|
|
560
|
+
count: parseInt(C[2], 10),
|
|
563
561
|
properties: []
|
|
564
562
|
});
|
|
565
563
|
break;
|
|
566
564
|
case "property":
|
|
567
|
-
if (
|
|
565
|
+
if (g.length === 0)
|
|
568
566
|
throw new Error(
|
|
569
567
|
"Invalid PLY file: Property without element"
|
|
570
568
|
);
|
|
571
|
-
|
|
572
|
-
type:
|
|
573
|
-
name:
|
|
569
|
+
g[g.length - 1].properties.push({
|
|
570
|
+
type: C[1],
|
|
571
|
+
name: C[2],
|
|
574
572
|
storage: null
|
|
575
573
|
});
|
|
576
574
|
break;
|
|
@@ -578,136 +576,136 @@ end_header
|
|
|
578
576
|
}
|
|
579
577
|
if (S !== "binary_little_endian")
|
|
580
578
|
throw new Error(`Unsupported PLY format: ${S}`);
|
|
581
|
-
const b =
|
|
579
|
+
const b = g.find((y) => y.name === "vertex");
|
|
582
580
|
if (!b)
|
|
583
581
|
throw new Error("Invalid PLY file: No vertex element found");
|
|
584
|
-
const p = new Ae(b.count),
|
|
585
|
-
let
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
582
|
+
const p = new Ae(b.count), m = new DataView(e);
|
|
583
|
+
let f = a;
|
|
584
|
+
const _ = (y) => b.properties.findIndex((x) => x.name === y), B = _("x"), q = _("y"), W = _("z"), j = [
|
|
585
|
+
_("rot_0"),
|
|
586
|
+
_("rot_1"),
|
|
587
|
+
_("rot_2"),
|
|
588
|
+
_("rot_3")
|
|
591
589
|
], H = [
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
590
|
+
_("scale_0"),
|
|
591
|
+
_("scale_1"),
|
|
592
|
+
_("scale_2")
|
|
595
593
|
], $ = [
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
],
|
|
594
|
+
_("f_dc_0"),
|
|
595
|
+
_("f_dc_1"),
|
|
596
|
+
_("f_dc_2")
|
|
597
|
+
], F = _("opacity");
|
|
600
598
|
if ([
|
|
601
|
-
|
|
599
|
+
B,
|
|
602
600
|
q,
|
|
603
601
|
W,
|
|
604
602
|
...j,
|
|
605
603
|
...H,
|
|
606
604
|
...$,
|
|
607
|
-
|
|
608
|
-
].some((
|
|
605
|
+
F
|
|
606
|
+
].some((y) => y === -1))
|
|
609
607
|
throw new Error("Invalid PLY file: Missing required properties");
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
return
|
|
614
|
-
}, w = new i.Vector3(),
|
|
615
|
-
for (let
|
|
616
|
-
const
|
|
617
|
-
for (let
|
|
618
|
-
const G = b.properties[
|
|
619
|
-
let
|
|
608
|
+
const O = 0.28209479177387814, A = (y) => {
|
|
609
|
+
if (y > 0) return 1 / (1 + Math.exp(-y));
|
|
610
|
+
const x = Math.exp(y);
|
|
611
|
+
return x / (1 + x);
|
|
612
|
+
}, w = new i.Vector3(), P = new i.Quaternion(), U = new i.Vector3(), V = new i.Color();
|
|
613
|
+
for (let y = 0; y < b.count; y++) {
|
|
614
|
+
const x = [];
|
|
615
|
+
for (let I = 0; I < b.properties.length; I++) {
|
|
616
|
+
const G = b.properties[I].type;
|
|
617
|
+
let s;
|
|
620
618
|
switch (G) {
|
|
621
619
|
case "char":
|
|
622
|
-
|
|
620
|
+
s = m.getInt8(f), f += 1;
|
|
623
621
|
break;
|
|
624
622
|
case "uchar":
|
|
625
|
-
|
|
623
|
+
s = m.getUint8(f), f += 1;
|
|
626
624
|
break;
|
|
627
625
|
case "short":
|
|
628
|
-
|
|
626
|
+
s = m.getInt16(f, !0), f += 2;
|
|
629
627
|
break;
|
|
630
628
|
case "ushort":
|
|
631
|
-
|
|
629
|
+
s = m.getUint16(f, !0), f += 2;
|
|
632
630
|
break;
|
|
633
631
|
case "int":
|
|
634
|
-
|
|
632
|
+
s = m.getInt32(f, !0), f += 4;
|
|
635
633
|
break;
|
|
636
634
|
case "uint":
|
|
637
|
-
|
|
635
|
+
s = m.getUint32(f, !0), f += 4;
|
|
638
636
|
break;
|
|
639
637
|
case "float":
|
|
640
|
-
|
|
638
|
+
s = m.getFloat32(f, !0), f += 4;
|
|
641
639
|
break;
|
|
642
640
|
case "double":
|
|
643
|
-
|
|
641
|
+
s = m.getFloat64(f, !0), f += 8;
|
|
644
642
|
break;
|
|
645
643
|
default:
|
|
646
644
|
throw new Error(`Unsupported property type: ${G}`);
|
|
647
645
|
}
|
|
648
|
-
|
|
646
|
+
x.push(s);
|
|
649
647
|
}
|
|
650
648
|
w.set(
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
),
|
|
655
|
-
|
|
649
|
+
x[B],
|
|
650
|
+
x[q],
|
|
651
|
+
x[W]
|
|
652
|
+
), P.set(
|
|
653
|
+
x[j[1]],
|
|
656
654
|
// PLY stores rot 1,2,3,0 (x,y,z,w)
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
).normalize(),
|
|
661
|
-
|
|
655
|
+
x[j[2]],
|
|
656
|
+
x[j[3]],
|
|
657
|
+
x[j[0]]
|
|
658
|
+
).normalize(), U.set(
|
|
659
|
+
x[H[0]],
|
|
662
660
|
// Read directly assuming it's log scale
|
|
663
|
-
|
|
664
|
-
|
|
661
|
+
x[H[1]],
|
|
662
|
+
x[H[2]]
|
|
665
663
|
), V.set(
|
|
666
|
-
0.5 +
|
|
667
|
-
0.5 +
|
|
668
|
-
0.5 +
|
|
664
|
+
0.5 + x[$[0]] * O,
|
|
665
|
+
0.5 + x[$[1]] * O,
|
|
666
|
+
0.5 + x[$[2]] * O
|
|
669
667
|
), V.r = Math.max(0, Math.min(1, V.r)), V.g = Math.max(0, Math.min(1, V.g)), V.b = Math.max(0, Math.min(1, V.b));
|
|
670
|
-
const
|
|
668
|
+
const C = A(x[F]);
|
|
671
669
|
p.setSplat(
|
|
672
|
-
|
|
670
|
+
y,
|
|
673
671
|
w,
|
|
674
|
-
|
|
672
|
+
P,
|
|
675
673
|
U,
|
|
676
674
|
// Pass log scale directly
|
|
677
675
|
V,
|
|
678
|
-
|
|
676
|
+
C
|
|
679
677
|
);
|
|
680
678
|
}
|
|
681
679
|
return p.calculateBoundingBox(), p;
|
|
682
680
|
}
|
|
683
681
|
}
|
|
684
|
-
class
|
|
682
|
+
class Ee extends i.EventDispatcher {
|
|
685
683
|
constructor() {
|
|
686
684
|
super();
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
685
|
+
h(this, "worker");
|
|
686
|
+
h(this, "centers", null);
|
|
687
|
+
h(this, "orderTexture", null);
|
|
690
688
|
/** Bounding box data for optimization */
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
const
|
|
695
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
689
|
+
h(this, "chunks", null);
|
|
690
|
+
h(this, "lastCameraPosition", new i.Vector3());
|
|
691
|
+
h(this, "lastCameraDirection", new i.Vector3());
|
|
692
|
+
const o = this.createWorkerCode(), t = new Blob([o], { type: "application/javascript" });
|
|
693
|
+
this.worker = new Worker(URL.createObjectURL(t)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
696
694
|
}
|
|
697
695
|
/**
|
|
698
696
|
* Handles messages received from the sorting worker.
|
|
699
697
|
* @param event The message event from the worker.
|
|
700
698
|
*/
|
|
701
|
-
onWorkerMessage(
|
|
699
|
+
onWorkerMessage(o) {
|
|
702
700
|
if (!this.orderTexture || !this.orderTexture.image)
|
|
703
701
|
return console.error("SplatSorter: Order texture not initialized!");
|
|
704
|
-
const { order:
|
|
705
|
-
if (!(
|
|
702
|
+
const { order: t, count: r } = o.data, n = this.orderTexture.image.data;
|
|
703
|
+
if (!(n instanceof Uint32Array))
|
|
706
704
|
return console.error(
|
|
707
705
|
"SplatSorter: Order texture data is not a Uint32Array!"
|
|
708
706
|
);
|
|
709
|
-
|
|
710
|
-
const a =
|
|
707
|
+
n.set(new Uint32Array(t)), this.orderTexture.needsUpdate = !0;
|
|
708
|
+
const a = n.buffer.slice(0), c = { order: a };
|
|
711
709
|
this.worker.postMessage(c, [a]), this.dispatchEvent({ type: "updated", count: r });
|
|
712
710
|
}
|
|
713
711
|
/**
|
|
@@ -716,82 +714,87 @@ class _e extends i.EventDispatcher {
|
|
|
716
714
|
* @param centers A Float32Array containing the center position (x, y, z) for each splat.
|
|
717
715
|
* @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
|
|
718
716
|
*/
|
|
719
|
-
init(
|
|
720
|
-
if (!
|
|
717
|
+
init(o, t, r) {
|
|
718
|
+
if (!o || !(o.image.data instanceof Uint32Array))
|
|
721
719
|
throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
|
|
722
|
-
if (!
|
|
720
|
+
if (!t || t.length % 3 !== 0)
|
|
723
721
|
throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
|
|
724
|
-
if (
|
|
722
|
+
if (o.image.data.length < t.length / 3)
|
|
725
723
|
throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
|
|
726
|
-
const
|
|
727
|
-
this.orderTexture =
|
|
724
|
+
const n = t.length / 3;
|
|
725
|
+
this.orderTexture = o, this.centers = t.slice();
|
|
728
726
|
const a = this.orderTexture.image.data;
|
|
729
|
-
for (let b = 0; b <
|
|
727
|
+
for (let b = 0; b < n; b++) a[b] = b;
|
|
730
728
|
this.orderTexture.needsUpdate = !0;
|
|
731
|
-
const c = a.buffer.slice(0),
|
|
729
|
+
const c = a.buffer.slice(0), v = this.centers.buffer.slice(0), g = {
|
|
732
730
|
order: c,
|
|
733
|
-
centers:
|
|
731
|
+
centers: v
|
|
734
732
|
}, S = [
|
|
735
733
|
c,
|
|
736
|
-
|
|
734
|
+
v
|
|
737
735
|
];
|
|
738
736
|
if (r) {
|
|
739
737
|
this.chunks = r.slice();
|
|
740
738
|
const b = this.chunks.buffer.slice(0);
|
|
741
|
-
|
|
739
|
+
g.chunks = b, S.push(b);
|
|
742
740
|
}
|
|
743
|
-
this.worker.postMessage(
|
|
741
|
+
this.worker.postMessage(g, S), queueMicrotask(() => {
|
|
742
|
+
this.dispatchEvent({
|
|
743
|
+
type: "updated",
|
|
744
|
+
count: n
|
|
745
|
+
});
|
|
746
|
+
});
|
|
744
747
|
}
|
|
745
748
|
/**
|
|
746
749
|
* Applies an optional mapping to filter or reorder splats before sorting.
|
|
747
750
|
* The sorter will only consider splats whose original indices are present in the mapping.
|
|
748
751
|
* @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
|
|
749
752
|
*/
|
|
750
|
-
setMapping(
|
|
753
|
+
setMapping(o) {
|
|
751
754
|
if (!this.centers)
|
|
752
755
|
return console.warn(
|
|
753
756
|
"SplatSorter: Cannot set mapping before initialization."
|
|
754
757
|
);
|
|
755
|
-
let
|
|
758
|
+
let t;
|
|
756
759
|
const r = [];
|
|
757
|
-
if (!
|
|
758
|
-
const
|
|
759
|
-
return
|
|
760
|
-
centers:
|
|
760
|
+
if (!o) {
|
|
761
|
+
const v = this.centers.buffer.slice(0);
|
|
762
|
+
return t = {
|
|
763
|
+
centers: v,
|
|
761
764
|
mapping: null
|
|
762
|
-
}, r.push(
|
|
765
|
+
}, r.push(v), this.worker.postMessage(t, r);
|
|
763
766
|
}
|
|
764
|
-
const
|
|
765
|
-
for (let
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
767
|
+
const n = new Float32Array(o.length * 3);
|
|
768
|
+
for (let v = 0; v < o.length; v++) {
|
|
769
|
+
const g = o[v];
|
|
770
|
+
if (g * 3 + 2 >= this.centers.length) {
|
|
768
771
|
console.warn(
|
|
769
|
-
`SplatSorter: Mapping index ${
|
|
772
|
+
`SplatSorter: Mapping index ${g} out of bounds.`
|
|
770
773
|
);
|
|
771
774
|
continue;
|
|
772
775
|
}
|
|
773
|
-
const S =
|
|
774
|
-
|
|
776
|
+
const S = g * 3, b = v * 3;
|
|
777
|
+
n[b + 0] = this.centers[S + 0], n[b + 1] = this.centers[S + 1], n[b + 2] = this.centers[S + 2];
|
|
775
778
|
}
|
|
776
|
-
const a =
|
|
777
|
-
|
|
779
|
+
const a = n.buffer.slice(0), c = o.buffer.slice(0);
|
|
780
|
+
t = {
|
|
778
781
|
centers: a,
|
|
779
782
|
mapping: c
|
|
780
|
-
}, r.push(a, c), this.worker.postMessage(
|
|
783
|
+
}, r.push(a, c), this.worker.postMessage(t, r);
|
|
781
784
|
}
|
|
782
785
|
/**
|
|
783
786
|
* Updates the camera parameters used for sorting.
|
|
784
787
|
* @param position The camera's position in the sorter's local coordinate space.
|
|
785
788
|
* @param direction The camera's forward direction in the sorter's local coordinate space.
|
|
786
789
|
*/
|
|
787
|
-
setCamera(
|
|
788
|
-
const r = this.lastCameraPosition.distanceToSquared(
|
|
789
|
-
if (!r && !
|
|
790
|
+
setCamera(o, t) {
|
|
791
|
+
const r = this.lastCameraPosition.distanceToSquared(o) > 1e-7, n = this.lastCameraDirection.dot(t) < 0.9999;
|
|
792
|
+
if (!r && !n)
|
|
790
793
|
return;
|
|
791
|
-
this.lastCameraPosition.copy(
|
|
794
|
+
this.lastCameraPosition.copy(o), this.lastCameraDirection.copy(t);
|
|
792
795
|
const a = {
|
|
793
|
-
cameraPosition: { x:
|
|
794
|
-
cameraDirection: { x:
|
|
796
|
+
cameraPosition: { x: o.x, y: o.y, z: o.z },
|
|
797
|
+
cameraDirection: { x: t.x, y: t.y, z: t.z }
|
|
795
798
|
};
|
|
796
799
|
this.worker.postMessage(a);
|
|
797
800
|
}
|
|
@@ -807,165 +810,165 @@ class _e extends i.EventDispatcher {
|
|
|
807
810
|
*/
|
|
808
811
|
createWorkerCode() {
|
|
809
812
|
return `(${(function() {
|
|
810
|
-
let
|
|
811
|
-
const S = { x: 0, y: 0, z: 0 }, b = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 },
|
|
812
|
-
let
|
|
813
|
-
const
|
|
814
|
-
for (;
|
|
815
|
-
const
|
|
816
|
-
if (w > 0)
|
|
817
|
-
else if (w < 0)
|
|
818
|
-
else return
|
|
813
|
+
let t = null, r = null, n = null, a = null, c = null, v = null, g = !1;
|
|
814
|
+
const S = { x: 0, y: 0, z: 0 }, b = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 }, m = { x: 0, y: 0, z: 0 };
|
|
815
|
+
let f = null, _ = null;
|
|
816
|
+
const B = 32, q = new Array(B).fill(0), W = new Array(B).fill(0), j = new Array(B).fill(0), H = (F, E, O) => {
|
|
817
|
+
for (; F <= E; ) {
|
|
818
|
+
const A = E + F >> 1, w = O(A);
|
|
819
|
+
if (w > 0) F = A + 1;
|
|
820
|
+
else if (w < 0) E = A - 1;
|
|
821
|
+
else return A;
|
|
819
822
|
}
|
|
820
|
-
return ~
|
|
823
|
+
return ~F;
|
|
821
824
|
}, $ = () => {
|
|
822
|
-
if (!
|
|
825
|
+
if (!t || !r || !c || !v)
|
|
823
826
|
return;
|
|
824
827
|
if (r.length === 0) {
|
|
825
|
-
const
|
|
826
|
-
order:
|
|
828
|
+
const u = {
|
|
829
|
+
order: t.buffer,
|
|
827
830
|
count: 0
|
|
828
831
|
};
|
|
829
|
-
self.postMessage(
|
|
832
|
+
self.postMessage(u, [t.buffer]), t = null;
|
|
830
833
|
return;
|
|
831
834
|
}
|
|
832
|
-
const
|
|
833
|
-
if (!
|
|
835
|
+
const F = c.x, E = c.y, O = c.z, A = v.x, w = v.y, P = v.z, U = 1e-4, V = Math.abs(F - S.x) > U || Math.abs(E - S.y) > U || Math.abs(O - S.z) > U, y = Math.abs(A - b.x) > U || Math.abs(w - b.y) > U || Math.abs(P - b.z) > U;
|
|
836
|
+
if (!g && !V && !y)
|
|
834
837
|
return;
|
|
835
|
-
|
|
836
|
-
let
|
|
837
|
-
for (let
|
|
838
|
-
const
|
|
839
|
-
|
|
838
|
+
g = !1, S.x = F, S.y = E, S.z = O, b.x = A, b.y = w, b.z = P;
|
|
839
|
+
let x = 1 / 0, C = -1 / 0;
|
|
840
|
+
for (let u = 0; u < 8; ++u) {
|
|
841
|
+
const z = u & 1 ? p.x : m.x, D = u & 2 ? p.y : m.y, l = u & 4 ? p.z : m.z, k = z * A + D * w + l * P;
|
|
842
|
+
x = Math.min(x, k), C = Math.max(C, k);
|
|
840
843
|
}
|
|
841
|
-
const
|
|
844
|
+
const I = r.length / 3, N = C - x, s = (1 << Math.max(
|
|
842
845
|
10,
|
|
843
|
-
Math.min(20, Math.ceil(Math.log2(
|
|
846
|
+
Math.min(20, Math.ceil(Math.log2(I / 4)))
|
|
844
847
|
)) + 1;
|
|
845
|
-
if ((!
|
|
846
|
-
for (let
|
|
847
|
-
|
|
848
|
-
} else if (
|
|
849
|
-
const
|
|
848
|
+
if ((!f || f.length !== I) && (f = new Uint32Array(I)), !_ || _.length !== s ? _ = new Uint32Array(s) : _.fill(0), N < 1e-7) {
|
|
849
|
+
for (let u = 0; u < I; ++u) f[u] = 0;
|
|
850
|
+
_[0] = I;
|
|
851
|
+
} else if (n && n.length > 0) {
|
|
852
|
+
const u = n.length / 6;
|
|
850
853
|
q.fill(0);
|
|
851
|
-
for (let
|
|
852
|
-
const
|
|
854
|
+
for (let l = 0; l < u; ++l) {
|
|
855
|
+
const k = l * 6, Y = n[k + 0], X = n[k + 1], ne = n[k + 2], Z = n[k + 3], J = Y * A + X * w + ne * P - x, oe = J - Z, ee = J + Z, ie = Math.max(
|
|
853
856
|
0,
|
|
854
|
-
Math.floor(oe *
|
|
857
|
+
Math.floor(oe * B / N)
|
|
855
858
|
), ce = Math.min(
|
|
856
|
-
|
|
857
|
-
Math.ceil(ee *
|
|
859
|
+
B,
|
|
860
|
+
Math.ceil(ee * B / N)
|
|
858
861
|
);
|
|
859
862
|
for (let Q = ie; Q < ce; ++Q)
|
|
860
863
|
q[Q]++;
|
|
861
864
|
}
|
|
862
|
-
let
|
|
863
|
-
for (let
|
|
865
|
+
let z = 0;
|
|
866
|
+
for (let l = 0; l < B; ++l) z += q[l];
|
|
864
867
|
j[0] = 0, W[0] = 0;
|
|
865
|
-
for (let
|
|
866
|
-
j[
|
|
867
|
-
j[
|
|
868
|
-
const
|
|
869
|
-
for (let
|
|
870
|
-
const
|
|
868
|
+
for (let l = 1; l < B; ++l)
|
|
869
|
+
j[l - 1] = q[l - 1] / z * s >>> 0, W[l] = W[l - 1] + j[l - 1];
|
|
870
|
+
j[B - 1] = q[B - 1] / z * s >>> 0;
|
|
871
|
+
const D = N / B;
|
|
872
|
+
for (let l = 0; l < I; ++l) {
|
|
873
|
+
const k = l * 3, Y = r[k + 0], X = r[k + 1], ne = r[k + 2], Z = Y * A + X * w + ne * P, oe = (C - Z) / D, ee = Math.max(
|
|
871
874
|
0,
|
|
872
875
|
Math.min(
|
|
873
|
-
|
|
876
|
+
B - 1,
|
|
874
877
|
Math.floor(oe)
|
|
875
878
|
)
|
|
876
|
-
), ie = oe - ee, ce = W[ee] + j[ee] * ie >>> 0, Q = Math.min(ce,
|
|
877
|
-
|
|
879
|
+
), ie = oe - ee, ce = W[ee] + j[ee] * ie >>> 0, Q = Math.min(ce, s - 1);
|
|
880
|
+
f[l] = Q, _[Q]++;
|
|
878
881
|
}
|
|
879
882
|
} else {
|
|
880
|
-
const
|
|
881
|
-
for (let
|
|
882
|
-
const
|
|
883
|
-
|
|
883
|
+
const u = (s - 1) / N;
|
|
884
|
+
for (let z = 0; z < I; ++z) {
|
|
885
|
+
const D = z * 3, l = r[D + 0], k = r[D + 1], Y = r[D + 2], X = l * A + k * w + Y * P, Z = (C - X) * u >>> 0, J = Math.min(Z, s - 1);
|
|
886
|
+
f[z] = J, _[J]++;
|
|
884
887
|
}
|
|
885
888
|
}
|
|
886
|
-
for (let
|
|
887
|
-
|
|
888
|
-
for (let
|
|
889
|
-
const
|
|
890
|
-
|
|
889
|
+
for (let u = 1; u < s; u++)
|
|
890
|
+
_[u] += _[u - 1];
|
|
891
|
+
for (let u = I - 1; u >= 0; u--) {
|
|
892
|
+
const z = f[u], D = --_[z];
|
|
893
|
+
t[D] = a ? a[u] : u;
|
|
891
894
|
}
|
|
892
|
-
const d =
|
|
893
|
-
if (!
|
|
894
|
-
const
|
|
895
|
-
if (!r ||
|
|
895
|
+
const d = F * A + E * w + O * P, M = (u) => {
|
|
896
|
+
if (!t) return -1 / 0;
|
|
897
|
+
const z = t[u], D = z;
|
|
898
|
+
if (!r || D * 3 + 2 >= r.length)
|
|
896
899
|
return -1 / 0;
|
|
897
|
-
const
|
|
898
|
-
return r[
|
|
900
|
+
const l = D * 3;
|
|
901
|
+
return r[l] * A + r[l + 1] * w + r[l + 2] * P - d;
|
|
899
902
|
};
|
|
900
|
-
let
|
|
901
|
-
if (
|
|
902
|
-
const
|
|
903
|
+
let R = I;
|
|
904
|
+
if (I > 0 && M(I - 1) < 0) {
|
|
905
|
+
const u = H(
|
|
903
906
|
0,
|
|
904
|
-
|
|
905
|
-
|
|
907
|
+
I - 1,
|
|
908
|
+
M
|
|
906
909
|
);
|
|
907
|
-
|
|
910
|
+
R = u < 0 ? ~u : u;
|
|
908
911
|
}
|
|
909
|
-
const
|
|
910
|
-
order:
|
|
911
|
-
count:
|
|
912
|
+
const L = {
|
|
913
|
+
order: t.buffer,
|
|
914
|
+
count: R
|
|
912
915
|
};
|
|
913
|
-
self.postMessage(
|
|
916
|
+
self.postMessage(L, [t.buffer]), t = null;
|
|
914
917
|
};
|
|
915
|
-
self.onmessage = (
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
let
|
|
919
|
-
if (
|
|
920
|
-
if (
|
|
921
|
-
for (let
|
|
922
|
-
const w =
|
|
923
|
-
|
|
924
|
-
(
|
|
918
|
+
self.onmessage = (F) => {
|
|
919
|
+
const E = F.data;
|
|
920
|
+
E.order && (t = new Uint32Array(E.order));
|
|
921
|
+
let O = !1;
|
|
922
|
+
if (E.centers && (r = new Float32Array(E.centers), O = !0, g = !0), Object.prototype.hasOwnProperty.call(E, "mapping") && (a = E.mapping ? new Uint32Array(E.mapping) : null, g = !0), E.chunks) {
|
|
923
|
+
if (n = new Float32Array(E.chunks), n.length > 0 && n[3] > 0)
|
|
924
|
+
for (let A = 0; A < n.length / 6; ++A) {
|
|
925
|
+
const w = A * 6, P = n[w + 0], U = n[w + 1], V = n[w + 2], y = n[w + 3], x = n[w + 4], C = n[w + 5];
|
|
926
|
+
n[w + 0] = (P + y) * 0.5, n[w + 1] = (U + x) * 0.5, n[w + 2] = (V + C) * 0.5, n[w + 3] = Math.sqrt(
|
|
927
|
+
(y - P) ** 2 + (x - U) ** 2 + (C - V) ** 2
|
|
925
928
|
) * 0.5;
|
|
926
929
|
}
|
|
927
|
-
|
|
930
|
+
g = !0;
|
|
928
931
|
}
|
|
929
|
-
if (
|
|
930
|
-
p.x =
|
|
931
|
-
for (let
|
|
932
|
-
const w =
|
|
933
|
-
p.x = Math.min(p.x, r[w + 0]),
|
|
932
|
+
if (O && r && r.length > 0) {
|
|
933
|
+
p.x = m.x = r[0], p.y = m.y = r[1], p.z = m.z = r[2];
|
|
934
|
+
for (let A = 1; A < r.length / 3; A++) {
|
|
935
|
+
const w = A * 3;
|
|
936
|
+
p.x = Math.min(p.x, r[w + 0]), m.x = Math.max(m.x, r[w + 0]), p.y = Math.min(p.y, r[w + 1]), m.y = Math.max(m.y, r[w + 1]), p.z = Math.min(p.z, r[w + 2]), m.z = Math.max(m.z, r[w + 2]);
|
|
934
937
|
}
|
|
935
|
-
} else
|
|
936
|
-
|
|
938
|
+
} else O && r && r.length === 0 && (p.x = m.x = p.y = m.y = p.z = m.z = 0);
|
|
939
|
+
E.cameraPosition && (c = E.cameraPosition), E.cameraDirection && (v = E.cameraDirection), $();
|
|
937
940
|
};
|
|
938
941
|
}).toString()})();`;
|
|
939
942
|
}
|
|
940
943
|
}
|
|
941
|
-
const ke = (
|
|
942
|
-
const
|
|
943
|
-
return
|
|
944
|
+
const ke = (T, e) => {
|
|
945
|
+
const o = de(T), t = de(e);
|
|
946
|
+
return o | t << 16;
|
|
944
947
|
};
|
|
945
|
-
function de(
|
|
946
|
-
const e = new Float32Array([
|
|
947
|
-
let r =
|
|
948
|
-
const a =
|
|
949
|
-
return a < 103 ? r : a > 142 ? (r |= 31744, r |= (a === 255 ? 0 : 1) &&
|
|
948
|
+
function de(T) {
|
|
949
|
+
const e = new Float32Array([T]), t = new Int32Array(e.buffer)[0];
|
|
950
|
+
let r = t >> 16 & 32768, n = t >> 12 & 2047;
|
|
951
|
+
const a = t >> 23 & 255;
|
|
952
|
+
return a < 103 ? r : a > 142 ? (r |= 31744, r |= (a === 255 ? 0 : 1) && t & 8388607, r) : a < 113 ? (n |= 2048, r |= (n >> 114 - a) + (n >> 113 - a & 1), r) : (r |= a - 112 << 10 | n >> 1, r += n & 1, r);
|
|
950
953
|
}
|
|
951
|
-
const Ie = new ArrayBuffer(4), pe = new DataView(Ie), Re = (
|
|
954
|
+
const Ie = new ArrayBuffer(4), pe = new DataView(Ie), Re = (T) => (pe.setUint32(0, T, !0), pe.getFloat32(0, !0));
|
|
952
955
|
class ze {
|
|
953
956
|
/**
|
|
954
957
|
* Create a new TextureManager for a set of splats
|
|
955
958
|
* @param splatData The splat data to manage textures for
|
|
956
959
|
*/
|
|
957
960
|
constructor(e) {
|
|
958
|
-
|
|
961
|
+
h(this, "transformA");
|
|
959
962
|
// position xyz and rotation quaternion y,z components
|
|
960
|
-
|
|
963
|
+
h(this, "transformB");
|
|
961
964
|
// rotation quaternion x and scale xyz
|
|
962
|
-
|
|
965
|
+
h(this, "colorTexture");
|
|
963
966
|
// color an opacity
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
const
|
|
968
|
-
this.textureWidth = Math.ceil(Math.sqrt(
|
|
967
|
+
h(this, "orderTexture");
|
|
968
|
+
h(this, "textureWidth");
|
|
969
|
+
h(this, "textureHeight");
|
|
970
|
+
const o = e.numSplats;
|
|
971
|
+
this.textureWidth = Math.ceil(Math.sqrt(o)), this.textureHeight = Math.ceil(o / this.textureWidth), this.transformA = this.createTransformATexture(e), this.transformB = this.createTransformBTexture(e), this.colorTexture = this.createColorTexture(e), this.orderTexture = this.createOrderTexture(o);
|
|
969
972
|
}
|
|
970
973
|
/**
|
|
971
974
|
* Create the transform A texture (positions and quaternion w component)
|
|
@@ -973,17 +976,17 @@ class ze {
|
|
|
973
976
|
* @returns DataTexture containing position data
|
|
974
977
|
*/
|
|
975
978
|
createTransformATexture(e) {
|
|
976
|
-
const
|
|
979
|
+
const o = e.numSplats, t = new Float32Array(
|
|
977
980
|
this.textureWidth * this.textureHeight * 4
|
|
978
981
|
);
|
|
979
|
-
for (let
|
|
980
|
-
const a =
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
|
|
982
|
+
for (let n = 0; n < o; n++) {
|
|
983
|
+
const a = n * 4, c = n * 3, v = n * 4;
|
|
984
|
+
t[a] = e.positions[c], t[a + 1] = e.positions[c + 1], t[a + 2] = e.positions[c + 2];
|
|
985
|
+
const g = e.rotations[v + 0], S = e.rotations[v + 1], b = ke(g, S);
|
|
986
|
+
t[a + 3] = Re(b);
|
|
984
987
|
}
|
|
985
988
|
const r = new i.DataTexture(
|
|
986
|
-
|
|
989
|
+
t,
|
|
987
990
|
this.textureWidth,
|
|
988
991
|
this.textureHeight,
|
|
989
992
|
i.RGBAFormat,
|
|
@@ -998,15 +1001,15 @@ class ze {
|
|
|
998
1001
|
* @returns DataTexture containing scale and rotation data
|
|
999
1002
|
*/
|
|
1000
1003
|
createTransformBTexture(e) {
|
|
1001
|
-
const
|
|
1004
|
+
const o = e.numSplats, t = new Float32Array(
|
|
1002
1005
|
this.textureWidth * this.textureHeight * 4
|
|
1003
1006
|
);
|
|
1004
|
-
for (let
|
|
1005
|
-
const a =
|
|
1006
|
-
|
|
1007
|
+
for (let n = 0; n < o; n++) {
|
|
1008
|
+
const a = n * 4, c = n * 3, v = n * 4;
|
|
1009
|
+
t[a] = e.scales[c], t[a + 1] = e.scales[c + 1], t[a + 2] = e.scales[c + 2], t[a + 3] = e.rotations[v + 2];
|
|
1007
1010
|
}
|
|
1008
1011
|
const r = new i.DataTexture(
|
|
1009
|
-
|
|
1012
|
+
t,
|
|
1010
1013
|
this.textureWidth,
|
|
1011
1014
|
this.textureHeight,
|
|
1012
1015
|
i.RGBAFormat,
|
|
@@ -1020,15 +1023,15 @@ class ze {
|
|
|
1020
1023
|
* @returns DataTexture containing color data
|
|
1021
1024
|
*/
|
|
1022
1025
|
createColorTexture(e) {
|
|
1023
|
-
const
|
|
1026
|
+
const o = e.numSplats, t = new Float32Array(
|
|
1024
1027
|
this.textureWidth * this.textureHeight * 4
|
|
1025
1028
|
);
|
|
1026
|
-
for (let
|
|
1027
|
-
const a =
|
|
1028
|
-
|
|
1029
|
+
for (let n = 0; n < o; n++) {
|
|
1030
|
+
const a = n * 4, c = n * 3;
|
|
1031
|
+
t[a] = e.colors[c], t[a + 1] = e.colors[c + 1], t[a + 2] = e.colors[c + 2], t[a + 3] = e.opacities[n];
|
|
1029
1032
|
}
|
|
1030
1033
|
const r = new i.DataTexture(
|
|
1031
|
-
|
|
1034
|
+
t,
|
|
1032
1035
|
this.textureWidth,
|
|
1033
1036
|
this.textureHeight,
|
|
1034
1037
|
i.RGBAFormat,
|
|
@@ -1042,17 +1045,17 @@ class ze {
|
|
|
1042
1045
|
* @returns DataTexture for storing order indices
|
|
1043
1046
|
*/
|
|
1044
1047
|
createOrderTexture(e) {
|
|
1045
|
-
const
|
|
1048
|
+
const o = new Uint32Array(this.textureWidth * this.textureHeight);
|
|
1046
1049
|
for (let r = 0; r < e; r++)
|
|
1047
|
-
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
+
o[r] = r;
|
|
1051
|
+
const t = new i.DataTexture(
|
|
1052
|
+
o,
|
|
1050
1053
|
this.textureWidth,
|
|
1051
1054
|
this.textureHeight,
|
|
1052
1055
|
i.RedIntegerFormat,
|
|
1053
1056
|
i.UnsignedIntType
|
|
1054
1057
|
);
|
|
1055
|
-
return
|
|
1058
|
+
return t.needsUpdate = !0, t;
|
|
1056
1059
|
}
|
|
1057
1060
|
dispose() {
|
|
1058
1061
|
this.transformA.dispose(), this.transformB.dispose(), this.colorTexture.dispose(), this.orderTexture.dispose();
|
|
@@ -1316,7 +1319,7 @@ void main(void) {
|
|
|
1316
1319
|
vUv = clippedCornerOffset;
|
|
1317
1320
|
}
|
|
1318
1321
|
`
|
|
1319
|
-
),
|
|
1322
|
+
), Be = (
|
|
1320
1323
|
/* glsl */
|
|
1321
1324
|
`
|
|
1322
1325
|
precision highp float;
|
|
@@ -1350,9 +1353,9 @@ void main(void) {
|
|
|
1350
1353
|
}
|
|
1351
1354
|
`
|
|
1352
1355
|
);
|
|
1353
|
-
class
|
|
1356
|
+
class Oe extends i.ShaderMaterial {
|
|
1354
1357
|
constructor(e = {}) {
|
|
1355
|
-
const
|
|
1358
|
+
const o = {
|
|
1356
1359
|
// Textures (values set via methods)
|
|
1357
1360
|
transformA: { value: null },
|
|
1358
1361
|
transformB: { value: null },
|
|
@@ -1366,8 +1369,8 @@ class Be extends i.ShaderMaterial {
|
|
|
1366
1369
|
};
|
|
1367
1370
|
super({
|
|
1368
1371
|
vertexShader: Pe,
|
|
1369
|
-
fragmentShader:
|
|
1370
|
-
uniforms:
|
|
1372
|
+
fragmentShader: Be,
|
|
1373
|
+
uniforms: o,
|
|
1371
1374
|
transparent: !0,
|
|
1372
1375
|
blending: i.CustomBlending,
|
|
1373
1376
|
// Premultiplied alpha blending:
|
|
@@ -1398,8 +1401,8 @@ class Be extends i.ShaderMaterial {
|
|
|
1398
1401
|
* @param width Viewport width
|
|
1399
1402
|
* @param height Viewport height
|
|
1400
1403
|
*/
|
|
1401
|
-
updateViewport(e,
|
|
1402
|
-
this.uniforms.viewport.value.set(e,
|
|
1404
|
+
updateViewport(e, o) {
|
|
1405
|
+
this.uniforms.viewport.value.set(e, o);
|
|
1403
1406
|
}
|
|
1404
1407
|
/**
|
|
1405
1408
|
* Set transform texture A (positions)
|
|
@@ -1444,31 +1447,40 @@ const K = class K extends i.Mesh {
|
|
|
1444
1447
|
* @param splatData The splat data to render
|
|
1445
1448
|
* @param options Rendering options
|
|
1446
1449
|
*/
|
|
1447
|
-
constructor(
|
|
1448
|
-
const r = new
|
|
1449
|
-
super(
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1450
|
+
constructor(o, t = {}) {
|
|
1451
|
+
const r = new Oe(t), n = K.createInstancedGeometry(o.numSplats, K.INSTANCE_SIZE);
|
|
1452
|
+
super(n, r);
|
|
1453
|
+
h(this, "sorter");
|
|
1454
|
+
h(this, "splatData");
|
|
1455
|
+
h(this, "options");
|
|
1456
|
+
h(this, "textureManager");
|
|
1457
|
+
h(this, "material");
|
|
1458
|
+
h(this, "geometry");
|
|
1459
|
+
h(this, "lastCameraPositionLocal", new i.Vector3());
|
|
1460
|
+
h(this, "lastCameraDirectionLocal", new i.Vector3());
|
|
1461
|
+
h(this, "invModelMatrix", new i.Matrix4());
|
|
1462
|
+
// Cached inverse matrix
|
|
1463
|
+
h(this, "_vpW", -1);
|
|
1464
|
+
h(this, "_vpH", -1);
|
|
1465
|
+
h(this, "_size", new i.Vector2());
|
|
1466
|
+
h(this, "_camPosW", new i.Vector3());
|
|
1467
|
+
h(this, "_camDirW", new i.Vector3());
|
|
1468
|
+
h(this, "_camPosL", new i.Vector3());
|
|
1469
|
+
h(this, "_camDirL", new i.Vector3());
|
|
1470
|
+
h(this, "onSorterUpdated", (o) => {
|
|
1471
|
+
const t = o.count;
|
|
1472
|
+
this.geometry.instanceCount = Math.ceil(t / K.INSTANCE_SIZE), this.material.setNumSplats(t);
|
|
1473
|
+
});
|
|
1474
|
+
this.geometry = n, this.material = r, this.splatData = o, this.frustumCulled = !1, this.options = {
|
|
1475
|
+
autoSort: !0,
|
|
1476
|
+
...t
|
|
1477
|
+
}, this.textureManager = new ze(o), this.sorter = new Ee();
|
|
1460
1478
|
let a = this.createChunks() || void 0;
|
|
1461
|
-
a === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), a = void 0, this.sorter.init(
|
|
1479
|
+
a === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), a = void 0, this.sorter.addEventListener("updated", this.onSorterUpdated), this.sorter.init(
|
|
1462
1480
|
this.textureManager.orderTexture,
|
|
1463
1481
|
this.splatData.centers,
|
|
1464
1482
|
a ?? void 0
|
|
1465
|
-
), this.
|
|
1466
|
-
"updated",
|
|
1467
|
-
(c) => {
|
|
1468
|
-
const l = c.count;
|
|
1469
|
-
this.geometry.instanceCount = Math.ceil(l / K.INSTANCE_SIZE), this.material.setNumSplats(l);
|
|
1470
|
-
}
|
|
1471
|
-
), this.material.setTransformA(this.textureManager.transformA), this.material.setTransformB(this.textureManager.transformB), this.material.setColorTexture(this.textureManager.colorTexture), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setNumSplats(0), this.geometry.boundingBox = s.boundingBox.toBox3(), this.geometry.boundingSphere = new i.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere);
|
|
1483
|
+
), this.material.setTransformA(this.textureManager.transformA), this.material.setTransformB(this.textureManager.transformB), this.material.setColorTexture(this.textureManager.colorTexture), this.material.setOrderTexture(this.textureManager.orderTexture), this.material.setNumSplats(0), this.geometry.boundingBox = o.boundingBox.toBox3(), this.geometry.boundingSphere = new i.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere);
|
|
1472
1484
|
}
|
|
1473
1485
|
/**
|
|
1474
1486
|
* Creates the instanced geometry for rendering splats.
|
|
@@ -1476,8 +1488,8 @@ const K = class K extends i.Mesh {
|
|
|
1476
1488
|
* @param instanceSize Number of splats per instance.
|
|
1477
1489
|
* @returns InstancedBufferGeometry
|
|
1478
1490
|
*/
|
|
1479
|
-
static createInstancedGeometry(
|
|
1480
|
-
const r = Math.ceil(
|
|
1491
|
+
static createInstancedGeometry(o, t) {
|
|
1492
|
+
const r = Math.ceil(o / t), n = new i.BufferGeometry(), a = new Float32Array([
|
|
1481
1493
|
// x, y, splat_index_in_instance
|
|
1482
1494
|
-1,
|
|
1483
1495
|
-1,
|
|
@@ -1491,23 +1503,23 @@ const K = class K extends i.Mesh {
|
|
|
1491
1503
|
-1,
|
|
1492
1504
|
1,
|
|
1493
1505
|
0
|
|
1494
|
-
]), c = new Uint16Array([0, 1, 2, 0, 2, 3]),
|
|
1495
|
-
for (let p = 0; p <
|
|
1496
|
-
const
|
|
1497
|
-
for (let
|
|
1498
|
-
|
|
1506
|
+
]), c = new Uint16Array([0, 1, 2, 0, 2, 3]), v = new Float32Array(4 * 3 * t);
|
|
1507
|
+
for (let p = 0; p < t; p++) {
|
|
1508
|
+
const m = p * 4 * 3;
|
|
1509
|
+
for (let f = 0; f < 4; f++)
|
|
1510
|
+
v[m + f * 3 + 0] = a[f * 3 + 0], v[m + f * 3 + 1] = a[f * 3 + 1], v[m + f * 3 + 2] = p;
|
|
1499
1511
|
}
|
|
1500
|
-
const
|
|
1501
|
-
for (let p = 0; p <
|
|
1502
|
-
const
|
|
1503
|
-
m
|
|
1512
|
+
const g = new Uint32Array(6 * t);
|
|
1513
|
+
for (let p = 0; p < t; p++) {
|
|
1514
|
+
const m = p * 6, f = p * 4;
|
|
1515
|
+
g[m + 0] = c[0] + f, g[m + 1] = c[1] + f, g[m + 2] = c[2] + f, g[m + 3] = c[3] + f, g[m + 4] = c[4] + f, g[m + 5] = c[5] + f;
|
|
1504
1516
|
}
|
|
1505
|
-
|
|
1517
|
+
n.setAttribute("position", new i.BufferAttribute(v, 3)), n.setIndex(new i.BufferAttribute(g, 1));
|
|
1506
1518
|
const S = new i.InstancedBufferGeometry();
|
|
1507
|
-
S.index =
|
|
1519
|
+
S.index = n.index, S.setAttribute("position", n.getAttribute("position"));
|
|
1508
1520
|
const b = new Uint32Array(r);
|
|
1509
1521
|
for (let p = 0; p < r; p++)
|
|
1510
|
-
b[p] = p *
|
|
1522
|
+
b[p] = p * t;
|
|
1511
1523
|
return S.setAttribute("splatInstanceIndex", new i.InstancedBufferAttribute(b, 1, !1)), S.instanceCount = 0, S;
|
|
1512
1524
|
}
|
|
1513
1525
|
/**
|
|
@@ -1515,14 +1527,14 @@ const K = class K extends i.Mesh {
|
|
|
1515
1527
|
* @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
|
|
1516
1528
|
*/
|
|
1517
1529
|
createChunks() {
|
|
1518
|
-
const
|
|
1519
|
-
return
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1530
|
+
const o = this.splatData.boundingBox;
|
|
1531
|
+
return o.min.x === 1 / 0 || o.max.x === -1 / 0 ? null : new Float32Array([
|
|
1532
|
+
o.min.x,
|
|
1533
|
+
o.min.y,
|
|
1534
|
+
o.min.z,
|
|
1535
|
+
o.max.x,
|
|
1536
|
+
o.max.y,
|
|
1537
|
+
o.max.z
|
|
1526
1538
|
]);
|
|
1527
1539
|
}
|
|
1528
1540
|
/**
|
|
@@ -1530,18 +1542,17 @@ const K = class K extends i.Mesh {
|
|
|
1530
1542
|
* @param width Viewport width
|
|
1531
1543
|
* @param height Viewport height
|
|
1532
1544
|
*/
|
|
1533
|
-
updateViewport(
|
|
1534
|
-
this.material.updateViewport(
|
|
1545
|
+
updateViewport(o, t) {
|
|
1546
|
+
o === this._vpW && t === this._vpH || (this._vpW = o, this._vpH = t, this.material.updateViewport(o, t));
|
|
1535
1547
|
}
|
|
1536
1548
|
/**
|
|
1537
1549
|
* Sorts splats based on camera position and direction.
|
|
1538
1550
|
* @param camera The camera to sort against.
|
|
1539
1551
|
*/
|
|
1540
|
-
sort(
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
this.options.autoSort && (c || l) && (this.lastCameraPositionLocal.copy(t), this.lastCameraDirectionLocal.copy(a), this.sorter.setCamera(t, a));
|
|
1552
|
+
sort(o) {
|
|
1553
|
+
o.getWorldPosition(this._camPosW), o.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);
|
|
1554
|
+
const t = this.lastCameraPositionLocal.distanceToSquared(this._camPosL) > 1e-6, r = this.lastCameraDirectionLocal.dot(this._camDirL) < 0.999;
|
|
1555
|
+
this.options.autoSort && (t || r) && (this.lastCameraPositionLocal.copy(this._camPosL), this.lastCameraDirectionLocal.copy(this._camDirL), this.sorter.setCamera(this._camPosL, this._camDirL));
|
|
1545
1556
|
}
|
|
1546
1557
|
/**
|
|
1547
1558
|
* THREE.js hook called before rendering the object.
|
|
@@ -1552,31 +1563,22 @@ const K = class K extends i.Mesh {
|
|
|
1552
1563
|
*/
|
|
1553
1564
|
// prettier-ignore
|
|
1554
1565
|
// @ts-expect-error scene is not used
|
|
1555
|
-
onBeforeRender(
|
|
1556
|
-
this.sort(r);
|
|
1557
|
-
const t = s.getSize(new i.Vector2());
|
|
1558
|
-
let { width: a, height: c } = t;
|
|
1559
|
-
const l = s.xr;
|
|
1560
|
-
if (l.enabled && l.isPresenting) {
|
|
1561
|
-
const m = l.getCamera().cameras[0].view;
|
|
1562
|
-
m && (a = m.width, c = m.height);
|
|
1563
|
-
}
|
|
1564
|
-
this.updateViewport(a, c);
|
|
1566
|
+
onBeforeRender(o, t, r) {
|
|
1567
|
+
this.sort(r), o.getSize(this._size), this.updateViewport(this._size.x, this._size.y);
|
|
1565
1568
|
}
|
|
1566
1569
|
/**
|
|
1567
1570
|
* Dispose of resources
|
|
1568
1571
|
*/
|
|
1569
1572
|
dispose() {
|
|
1570
|
-
this.sorter.dispose(), this.geometry.dispose(), this.material.dispose(), this.textureManager.dispose();
|
|
1573
|
+
this.sorter.removeEventListener("updated", this.onSorterUpdated), this.sorter.dispose(), this.geometry.dispose(), this.material.dispose(), this.textureManager.dispose();
|
|
1571
1574
|
}
|
|
1572
1575
|
};
|
|
1573
|
-
// Cached inverse matrix
|
|
1574
1576
|
/** Number of splats combined into a single instanced draw call. */
|
|
1575
|
-
|
|
1577
|
+
h(K, "INSTANCE_SIZE", 128);
|
|
1576
1578
|
let ae = K;
|
|
1577
|
-
const
|
|
1579
|
+
const De = Symbol.for("@speridlabs/visus/SplatMesh");
|
|
1578
1580
|
try {
|
|
1579
|
-
Object.defineProperty(ae.prototype,
|
|
1581
|
+
Object.defineProperty(ae.prototype, De, {
|
|
1580
1582
|
value: !0,
|
|
1581
1583
|
configurable: !1,
|
|
1582
1584
|
enumerable: !1,
|
|
@@ -1586,20 +1588,22 @@ try {
|
|
|
1586
1588
|
console.warn("Couldn't define Visus SplatMesh symbol");
|
|
1587
1589
|
}
|
|
1588
1590
|
const je = ({
|
|
1589
|
-
plyUrl:
|
|
1590
|
-
|
|
1591
|
-
|
|
1591
|
+
plyUrl: T,
|
|
1592
|
+
debug: e = !1,
|
|
1593
|
+
splatOptions: o = {},
|
|
1594
|
+
...t
|
|
1592
1595
|
}) => {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
+
typeof window < "u" && e && (window.__VISUS_SPLAT_DEBUG__ = !0), e && console.debug("SPLAT: rendering", { plyUrl: T, splatOptions: o, meshProps: t });
|
|
1597
|
+
const r = ye(null), n = be(Ce, T), a = ge(
|
|
1598
|
+
() => new ae(n, o || {}),
|
|
1599
|
+
[n, o]
|
|
1596
1600
|
);
|
|
1597
1601
|
return we(() => () => {
|
|
1598
|
-
typeof (
|
|
1599
|
-
}, [
|
|
1602
|
+
e && console.debug("SPLAT: disposing mesh for", T), typeof (a == null ? void 0 : a.dispose) == "function" && a.dispose();
|
|
1603
|
+
}, [a]), /* @__PURE__ */ Me.jsx("primitive", { ref: r, object: a, ...t });
|
|
1600
1604
|
};
|
|
1601
1605
|
export {
|
|
1602
|
-
|
|
1606
|
+
Ce as PlyLoader,
|
|
1603
1607
|
je as Splat,
|
|
1604
1608
|
ae as SplatMesh
|
|
1605
1609
|
};
|