@speridlabs/visus 1.0.1 → 1.0.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 +320 -0
- package/dist/main.es.js +1448 -0
- package/dist/main.umd.js +6 -6
- package/dist/react.d.ts +1 -0
- package/dist/react.es.js +789 -644
- package/package.json +1 -1
package/dist/react.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var me = Object.defineProperty;
|
|
2
|
-
var xe = (M, e,
|
|
3
|
-
var
|
|
4
|
-
import
|
|
2
|
+
var xe = (M, e, r) => e in M ? me(M, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : M[e] = r;
|
|
3
|
+
var w = (M, e, r) => xe(M, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import ge, { useRef as ye, useMemo as ve, useEffect as we } from "react";
|
|
5
5
|
import { useLoader as be } from "@react-three/fiber";
|
|
6
|
-
import * as
|
|
7
|
-
var se = { exports: {} },
|
|
6
|
+
import * as c from "three";
|
|
7
|
+
var se = { exports: {} }, ee = {};
|
|
8
8
|
/**
|
|
9
9
|
* @license React
|
|
10
10
|
* react-jsx-runtime.production.js
|
|
@@ -16,27 +16,27 @@ var se = { exports: {} }, te = {};
|
|
|
16
16
|
*/
|
|
17
17
|
var ue;
|
|
18
18
|
function Se() {
|
|
19
|
-
if (ue) return
|
|
19
|
+
if (ue) return ee;
|
|
20
20
|
ue = 1;
|
|
21
21
|
var M = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
22
|
-
function
|
|
22
|
+
function r(o, t, n) {
|
|
23
23
|
var a = null;
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
for (var
|
|
27
|
-
|
|
28
|
-
} else
|
|
29
|
-
return
|
|
24
|
+
if (n !== void 0 && (a = "" + n), t.key !== void 0 && (a = "" + t.key), "key" in t) {
|
|
25
|
+
n = {};
|
|
26
|
+
for (var i in t)
|
|
27
|
+
i !== "key" && (n[i] = t[i]);
|
|
28
|
+
} else n = t;
|
|
29
|
+
return t = n.ref, {
|
|
30
30
|
$$typeof: M,
|
|
31
|
-
type:
|
|
31
|
+
type: o,
|
|
32
32
|
key: a,
|
|
33
|
-
ref:
|
|
34
|
-
props:
|
|
33
|
+
ref: t !== void 0 ? t : null,
|
|
34
|
+
props: n
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return ee.Fragment = e, ee.jsx = r, ee.jsxs = r, ee;
|
|
38
38
|
}
|
|
39
|
-
var
|
|
39
|
+
var te = {};
|
|
40
40
|
/**
|
|
41
41
|
* @license React
|
|
42
42
|
* react-jsx-runtime.development.js
|
|
@@ -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 M(
|
|
53
|
-
if (
|
|
54
|
-
if (typeof
|
|
55
|
-
return
|
|
56
|
-
if (typeof
|
|
57
|
-
switch (
|
|
58
|
-
case
|
|
49
|
+
var de;
|
|
50
|
+
function _e() {
|
|
51
|
+
return de || (de = 1, process.env.NODE_ENV !== "production" && function() {
|
|
52
|
+
function M(s) {
|
|
53
|
+
if (s == null) return null;
|
|
54
|
+
if (typeof s == "function")
|
|
55
|
+
return s.$$typeof === _ ? null : s.displayName || s.name || null;
|
|
56
|
+
if (typeof s == "string") return s;
|
|
57
|
+
switch (s) {
|
|
58
|
+
case d:
|
|
59
59
|
return "Fragment";
|
|
60
60
|
case q:
|
|
61
61
|
return "Profiler";
|
|
62
|
-
case
|
|
62
|
+
case A:
|
|
63
63
|
return "StrictMode";
|
|
64
|
-
case
|
|
64
|
+
case Y:
|
|
65
65
|
return "Suspense";
|
|
66
|
-
case
|
|
66
|
+
case B:
|
|
67
67
|
return "SuspenseList";
|
|
68
|
-
case
|
|
68
|
+
case C:
|
|
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 E:
|
|
76
76
|
return "Portal";
|
|
77
|
-
case
|
|
78
|
-
return (
|
|
77
|
+
case N:
|
|
78
|
+
return (s.displayName || "Context") + ".Provider";
|
|
79
79
|
case W:
|
|
80
|
-
return (
|
|
81
|
-
case
|
|
82
|
-
var
|
|
83
|
-
return
|
|
84
|
-
case
|
|
85
|
-
return
|
|
86
|
-
case
|
|
87
|
-
|
|
80
|
+
return (s._context.displayName || "Context") + ".Consumer";
|
|
81
|
+
case F:
|
|
82
|
+
var u = s.render;
|
|
83
|
+
return s = s.displayName, s || (s = u.displayName || u.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
|
|
84
|
+
case T:
|
|
85
|
+
return u = s.displayName || null, u !== null ? u : M(s.type) || "Memo";
|
|
86
|
+
case U:
|
|
87
|
+
u = s._payload, s = s._init;
|
|
88
88
|
try {
|
|
89
|
-
return M(
|
|
89
|
+
return M(s(u));
|
|
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 r(s) {
|
|
99
99
|
try {
|
|
100
|
-
e(
|
|
101
|
-
var
|
|
100
|
+
e(s);
|
|
101
|
+
var u = !1;
|
|
102
102
|
} catch {
|
|
103
|
-
|
|
103
|
+
u = !0;
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
return
|
|
109
|
-
|
|
105
|
+
if (u) {
|
|
106
|
+
u = console;
|
|
107
|
+
var R = u.error, D = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
|
|
108
|
+
return R.call(
|
|
109
|
+
u,
|
|
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
|
+
D
|
|
112
|
+
), e(s);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
if (
|
|
117
|
-
if (typeof
|
|
115
|
+
function o(s) {
|
|
116
|
+
if (s === d) return "<>";
|
|
117
|
+
if (typeof s == "object" && s !== null && s.$$typeof === U)
|
|
118
118
|
return "<...>";
|
|
119
119
|
try {
|
|
120
|
-
var
|
|
121
|
-
return
|
|
120
|
+
var u = M(s);
|
|
121
|
+
return u ? "<" + u + ">" : "<...>";
|
|
122
122
|
} catch {
|
|
123
123
|
return "<...>";
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function r() {
|
|
127
|
-
var o = C.A;
|
|
128
|
-
return o === null ? null : o.getOwner();
|
|
129
|
-
}
|
|
130
126
|
function t() {
|
|
127
|
+
var s = I.A;
|
|
128
|
+
return s === null ? null : s.getOwner();
|
|
129
|
+
}
|
|
130
|
+
function n() {
|
|
131
131
|
return Error("react-stack-top-frame");
|
|
132
132
|
}
|
|
133
|
-
function a(
|
|
134
|
-
if (
|
|
135
|
-
var
|
|
136
|
-
if (
|
|
133
|
+
function a(s) {
|
|
134
|
+
if (P.call(s, "key")) {
|
|
135
|
+
var u = Object.getOwnPropertyDescriptor(s, "key").get;
|
|
136
|
+
if (u && u.isReactWarning) return !1;
|
|
137
137
|
}
|
|
138
|
-
return
|
|
138
|
+
return s.key !== void 0;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
function
|
|
142
|
-
|
|
140
|
+
function i(s, u) {
|
|
141
|
+
function R() {
|
|
142
|
+
f || (f = !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
|
+
u
|
|
145
145
|
));
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
get:
|
|
147
|
+
R.isReactWarning = !0, Object.defineProperty(s, "key", {
|
|
148
|
+
get: R,
|
|
149
149
|
configurable: !0
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
function l() {
|
|
153
|
-
var
|
|
154
|
-
return
|
|
153
|
+
var s = M(this.type);
|
|
154
|
+
return m[s] || (m[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:
|
|
162
|
-
key:
|
|
163
|
-
props:
|
|
164
|
-
_owner:
|
|
165
|
-
}, (
|
|
158
|
+
function g(s, u, R, D, H, x, O, L) {
|
|
159
|
+
return R = x.ref, s = {
|
|
160
|
+
$$typeof: p,
|
|
161
|
+
type: s,
|
|
162
|
+
key: u,
|
|
163
|
+
props: x,
|
|
164
|
+
_owner: H
|
|
165
|
+
}, (R !== void 0 ? R : null) !== null ? Object.defineProperty(s, "ref", {
|
|
166
166
|
enumerable: !1,
|
|
167
167
|
get: l
|
|
168
|
-
}) : Object.defineProperty(
|
|
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: O
|
|
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: L
|
|
188
|
+
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
var
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
if (V(
|
|
195
|
-
for (
|
|
196
|
-
|
|
197
|
-
Object.freeze && Object.freeze(
|
|
190
|
+
function y(s, u, R, D, H, x, O, L) {
|
|
191
|
+
var h = u.children;
|
|
192
|
+
if (h !== void 0)
|
|
193
|
+
if (D)
|
|
194
|
+
if (V(h)) {
|
|
195
|
+
for (D = 0; D < h.length; D++)
|
|
196
|
+
v(h[D]);
|
|
197
|
+
Object.freeze && Object.freeze(h);
|
|
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
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
var
|
|
206
|
-
return
|
|
202
|
+
else v(h);
|
|
203
|
+
if (P.call(u, "key")) {
|
|
204
|
+
h = M(s);
|
|
205
|
+
var z = Object.keys(u).filter(function($) {
|
|
206
|
+
return $ !== "key";
|
|
207
207
|
});
|
|
208
|
-
|
|
208
|
+
D = 0 < z.length ? "{key: someKey, " + z.join(": ..., ") + ": ...}" : "{key: someKey}", re[h + D] || (z = 0 < z.length ? "{" + z.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
|
+
D,
|
|
216
|
+
h,
|
|
215
217
|
z,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
u
|
|
219
|
-
), G[u + z] = !0);
|
|
218
|
+
h
|
|
219
|
+
), re[h + D] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
for (var
|
|
224
|
-
|
|
225
|
-
} else
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
typeof
|
|
229
|
-
),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
221
|
+
if (h = null, R !== void 0 && (r(R), h = "" + R), a(u) && (r(u.key), h = "" + u.key), "key" in u) {
|
|
222
|
+
R = {};
|
|
223
|
+
for (var G in u)
|
|
224
|
+
G !== "key" && (R[G] = u[G]);
|
|
225
|
+
} else R = u;
|
|
226
|
+
return h && i(
|
|
227
|
+
R,
|
|
228
|
+
typeof s == "function" ? s.displayName || s.name || "Unknown" : s
|
|
229
|
+
), g(
|
|
230
|
+
s,
|
|
231
|
+
h,
|
|
232
|
+
x,
|
|
233
|
+
H,
|
|
234
|
+
t(),
|
|
235
|
+
R,
|
|
236
|
+
O,
|
|
237
|
+
L
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
typeof
|
|
240
|
+
function v(s) {
|
|
241
|
+
typeof s == "object" && s !== null && s.$$typeof === p && s._store && (s._store.validated = 1);
|
|
242
242
|
}
|
|
243
|
-
var
|
|
243
|
+
var b = ge, p = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), A = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), N = Symbol.for("react.context"), F = Symbol.for("react.forward_ref"), Y = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), U = Symbol.for("react.lazy"), C = Symbol.for("react.activity"), _ = Symbol.for("react.client.reference"), I = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, V = Array.isArray, k = console.createTask ? console.createTask : function() {
|
|
244
244
|
return null;
|
|
245
245
|
};
|
|
246
|
-
|
|
247
|
-
"react-stack-bottom-frame": function(
|
|
248
|
-
return
|
|
246
|
+
b = {
|
|
247
|
+
"react-stack-bottom-frame": function(s) {
|
|
248
|
+
return s();
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
)(),
|
|
255
|
-
|
|
256
|
-
var
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
251
|
+
var f, m = {}, S = b["react-stack-bottom-frame"].bind(
|
|
252
|
+
b,
|
|
253
|
+
n
|
|
254
|
+
)(), j = k(o(n)), re = {};
|
|
255
|
+
te.Fragment = d, te.jsx = function(s, u, R, D, H) {
|
|
256
|
+
var x = 1e4 > I.recentlyCreatedOwnerStacks++;
|
|
257
|
+
return y(
|
|
258
|
+
s,
|
|
259
|
+
u,
|
|
260
|
+
R,
|
|
261
261
|
!1,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
D,
|
|
263
|
+
H,
|
|
264
|
+
x ? Error("react-stack-top-frame") : S,
|
|
265
|
+
x ? k(o(s)) : j
|
|
266
266
|
);
|
|
267
|
-
},
|
|
268
|
-
var
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
}, te.jsxs = function(s, u, R, D, H) {
|
|
268
|
+
var x = 1e4 > I.recentlyCreatedOwnerStacks++;
|
|
269
|
+
return y(
|
|
270
|
+
s,
|
|
271
|
+
u,
|
|
272
|
+
R,
|
|
273
273
|
!0,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
D,
|
|
275
|
+
H,
|
|
276
|
+
x ? Error("react-stack-top-frame") : S,
|
|
277
|
+
x ? k(o(s)) : j
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
|
-
}()),
|
|
280
|
+
}()), te;
|
|
281
281
|
}
|
|
282
|
-
var
|
|
283
|
-
function
|
|
284
|
-
return
|
|
282
|
+
var fe;
|
|
283
|
+
function Ee() {
|
|
284
|
+
return fe || (fe = 1, process.env.NODE_ENV === "production" ? se.exports = Se() : se.exports = _e()), se.exports;
|
|
285
285
|
}
|
|
286
|
-
var
|
|
286
|
+
var Ae = Ee();
|
|
287
287
|
class le {
|
|
288
288
|
constructor() {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
w(this, "min", new c.Vector3(1 / 0, 1 / 0, 1 / 0));
|
|
290
|
+
w(this, "max", new c.Vector3(-1 / 0, -1 / 0, -1 / 0));
|
|
291
|
+
w(this, "center", new c.Vector3());
|
|
292
292
|
/** Half extents (size/2) */
|
|
293
|
-
|
|
293
|
+
w(this, "halfExtents", new c.Vector3());
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Reset the bounding box to its initial state
|
|
@@ -331,7 +331,7 @@ class le {
|
|
|
331
331
|
* @returns THREE.Box3 representation
|
|
332
332
|
*/
|
|
333
333
|
toBox3() {
|
|
334
|
-
return new
|
|
334
|
+
return new c.Box3().set(this.min, this.max);
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
337
|
* Create a clone of this bounding box
|
|
@@ -342,17 +342,17 @@ class le {
|
|
|
342
342
|
return e.min.copy(this.min), e.max.copy(this.max), e.center.copy(this.center), e.halfExtents.copy(this.halfExtents), e;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
class
|
|
345
|
+
class Me {
|
|
346
346
|
// TODO: there is no sh spherical harmonics
|
|
347
347
|
constructor(e = 0) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
348
|
+
w(this, "numSplats", 0);
|
|
349
|
+
w(this, "positions");
|
|
350
|
+
w(this, "rotations");
|
|
351
|
+
w(this, "scales");
|
|
352
|
+
w(this, "colors");
|
|
353
|
+
w(this, "opacities");
|
|
354
|
+
w(this, "centers");
|
|
355
|
+
w(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, r, o, t, 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
|
|
376
|
-
this.positions[
|
|
375
|
+
const i = e * 3, l = e * 4, g = e * 3, y = e * 3;
|
|
376
|
+
this.positions[i] = r.x, this.positions[i + 1] = r.y, this.positions[i + 2] = r.z, this.rotations[l] = o.x, this.rotations[l + 1] = o.y, this.rotations[l + 2] = o.z, this.rotations[l + 3] = o.w, this.scales[g] = t.x, this.scales[g + 1] = t.y, this.scales[g + 2] = t.z, this.colors[y] = n.r, this.colors[y + 1] = n.g, this.colors[y + 2] = n.b, this.opacities[e] = a, this.centers[i] = r.x, this.centers[i + 1] = r.y, this.centers[i + 2] = r.z;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* Get a splat's data
|
|
@@ -385,29 +385,29 @@ class Ae {
|
|
|
385
385
|
throw new Error(
|
|
386
386
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
387
387
|
);
|
|
388
|
-
const
|
|
388
|
+
const r = e * 3, o = e * 4, t = e * 3, n = e * 3;
|
|
389
389
|
return {
|
|
390
|
-
position: new
|
|
391
|
-
this.positions[
|
|
392
|
-
this.positions[
|
|
393
|
-
this.positions[
|
|
390
|
+
position: new c.Vector3(
|
|
391
|
+
this.positions[r],
|
|
392
|
+
this.positions[r + 1],
|
|
393
|
+
this.positions[r + 2]
|
|
394
394
|
),
|
|
395
|
-
rotation: new
|
|
396
|
-
this.rotations[
|
|
397
|
-
this.rotations[
|
|
398
|
-
this.rotations[
|
|
399
|
-
this.rotations[
|
|
395
|
+
rotation: new c.Quaternion(
|
|
396
|
+
this.rotations[o],
|
|
397
|
+
this.rotations[o + 1],
|
|
398
|
+
this.rotations[o + 2],
|
|
399
|
+
this.rotations[o + 3]
|
|
400
400
|
),
|
|
401
401
|
// Convert log scale back to linear scale for external use
|
|
402
|
-
scale: new
|
|
403
|
-
Math.exp(this.scales[
|
|
404
|
-
Math.exp(this.scales[
|
|
405
|
-
Math.exp(this.scales[
|
|
402
|
+
scale: new c.Vector3(
|
|
403
|
+
Math.exp(this.scales[t]),
|
|
404
|
+
Math.exp(this.scales[t + 1]),
|
|
405
|
+
Math.exp(this.scales[t + 2])
|
|
406
406
|
),
|
|
407
|
-
color: new
|
|
408
|
-
this.colors[
|
|
409
|
-
this.colors[
|
|
410
|
-
this.colors[
|
|
407
|
+
color: new c.Color(
|
|
408
|
+
this.colors[n],
|
|
409
|
+
this.colors[n + 1],
|
|
410
|
+
this.colors[n + 2]
|
|
411
411
|
),
|
|
412
412
|
opacity: this.opacities[e]
|
|
413
413
|
};
|
|
@@ -418,13 +418,13 @@ class Ae {
|
|
|
418
418
|
*/
|
|
419
419
|
calculateBoundingBox() {
|
|
420
420
|
this.boundingBox.reset();
|
|
421
|
-
const e = new
|
|
422
|
-
for (let
|
|
423
|
-
const
|
|
421
|
+
const e = new c.Vector3();
|
|
422
|
+
for (let r = 0; r < this.numSplats; r++) {
|
|
423
|
+
const o = r * 3;
|
|
424
424
|
e.set(
|
|
425
|
-
this.positions[
|
|
426
|
-
this.positions[
|
|
427
|
-
this.positions[
|
|
425
|
+
this.positions[o],
|
|
426
|
+
this.positions[o + 1],
|
|
427
|
+
this.positions[o + 2]
|
|
428
428
|
), this.boundingBox.expandByPoint(e);
|
|
429
429
|
}
|
|
430
430
|
return this.boundingBox;
|
|
@@ -434,37 +434,37 @@ class Ae {
|
|
|
434
434
|
* This is for visualization/debugging purposes only, not for rendering
|
|
435
435
|
*/
|
|
436
436
|
createDebugGeometry() {
|
|
437
|
-
const e = new
|
|
437
|
+
const e = new c.BufferGeometry();
|
|
438
438
|
e.setAttribute(
|
|
439
439
|
"position",
|
|
440
|
-
new
|
|
440
|
+
new c.BufferAttribute(this.positions, 3)
|
|
441
441
|
);
|
|
442
|
-
const
|
|
443
|
-
for (let
|
|
444
|
-
const a =
|
|
445
|
-
|
|
442
|
+
const r = new Float32Array(this.numSplats * 3), o = new c.Quaternion(), t = new c.Euler();
|
|
443
|
+
for (let n = 0; n < this.numSplats; n++) {
|
|
444
|
+
const a = n * 4, i = n * 3;
|
|
445
|
+
o.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
|
-
),
|
|
450
|
+
), t.setFromQuaternion(o), r[i] = t.x, r[i + 1] = t.y, r[i + 2] = t.z;
|
|
451
451
|
}
|
|
452
452
|
return e.setAttribute(
|
|
453
453
|
"rotation",
|
|
454
|
-
new
|
|
454
|
+
new c.BufferAttribute(r, 3)
|
|
455
455
|
), e.setAttribute(
|
|
456
456
|
"scale",
|
|
457
|
-
new
|
|
457
|
+
new c.BufferAttribute(this.scales, 3)
|
|
458
458
|
), e.setAttribute(
|
|
459
459
|
"color",
|
|
460
|
-
new
|
|
460
|
+
new c.BufferAttribute(this.colors, 3)
|
|
461
461
|
), e.setAttribute(
|
|
462
462
|
"opacity",
|
|
463
|
-
new
|
|
463
|
+
new c.BufferAttribute(this.opacities, 1)
|
|
464
464
|
), e;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class
|
|
467
|
+
class Te extends c.Loader {
|
|
468
468
|
/**
|
|
469
469
|
* Load a PLY file with Gaussian Splat data
|
|
470
470
|
* @param url URL of the PLY file
|
|
@@ -472,22 +472,23 @@ 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
|
-
|
|
477
|
-
|
|
475
|
+
load(e, r, o, t) {
|
|
476
|
+
(typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0 && console.debug("[1/12] LOADER PlyLoader: loading", e);
|
|
477
|
+
const a = new c.FileLoader(this.manager);
|
|
478
|
+
a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setPath(this.path), a.setWithCredentials(this.withCredentials), a.load(
|
|
478
479
|
e,
|
|
479
|
-
(
|
|
480
|
+
(i) => {
|
|
480
481
|
try {
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
|
|
482
|
+
if (r) {
|
|
483
|
+
const l = this.parse(i);
|
|
484
|
+
r(l);
|
|
484
485
|
}
|
|
485
|
-
} catch (
|
|
486
|
-
|
|
486
|
+
} catch (l) {
|
|
487
|
+
t ? t(l) : console.error(l), this.manager.itemError(e);
|
|
487
488
|
}
|
|
488
489
|
},
|
|
489
|
-
|
|
490
|
-
|
|
490
|
+
o,
|
|
491
|
+
t
|
|
491
492
|
);
|
|
492
493
|
}
|
|
493
494
|
/**
|
|
@@ -496,22 +497,22 @@ class Ee extends i.Loader {
|
|
|
496
497
|
* @param onProgress Optional progress callback
|
|
497
498
|
* @returns A Promise that resolves with the parsed SplatData
|
|
498
499
|
*/
|
|
499
|
-
loadAsync(e,
|
|
500
|
-
return new Promise((
|
|
501
|
-
const
|
|
502
|
-
|
|
500
|
+
loadAsync(e, r) {
|
|
501
|
+
return new Promise((o, t) => {
|
|
502
|
+
const n = new c.FileLoader(this.manager);
|
|
503
|
+
n.setResponseType("arraybuffer"), n.setRequestHeader(this.requestHeader), n.setPath(this.path), n.setWithCredentials(this.withCredentials), n.load(
|
|
503
504
|
e,
|
|
504
505
|
(a) => {
|
|
505
506
|
try {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
} catch (
|
|
509
|
-
|
|
507
|
+
const i = this.parse(a);
|
|
508
|
+
o(i);
|
|
509
|
+
} catch (i) {
|
|
510
|
+
t(i), this.manager.itemError(e);
|
|
510
511
|
}
|
|
511
512
|
},
|
|
512
|
-
|
|
513
|
+
r,
|
|
513
514
|
(a) => {
|
|
514
|
-
|
|
515
|
+
t(a), this.manager.itemError(e);
|
|
515
516
|
}
|
|
516
517
|
);
|
|
517
518
|
});
|
|
@@ -522,193 +523,283 @@ class Ee extends i.Loader {
|
|
|
522
523
|
* @returns Parsed SplatData
|
|
523
524
|
*/
|
|
524
525
|
parse(e) {
|
|
525
|
-
const
|
|
526
|
+
const r = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0;
|
|
527
|
+
r && console.debug(
|
|
528
|
+
"[2/12] LOADER PlyLoader: starting parse, buffer size:",
|
|
529
|
+
e.byteLength
|
|
530
|
+
);
|
|
531
|
+
const o = new TextDecoder(), t = new Uint8Array(e), n = [112, 108, 121, 10], a = `
|
|
526
532
|
end_header
|
|
527
533
|
`;
|
|
528
|
-
for (let
|
|
529
|
-
if (
|
|
534
|
+
for (let f = 0; f < n.length; f++)
|
|
535
|
+
if (t[f] !== n[f])
|
|
530
536
|
throw new Error("Invalid PLY file: Missing magic bytes");
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
+
r && console.debug("[3/12] LOADER PlyLoader: PLY magic bytes verified");
|
|
538
|
+
let i = 0;
|
|
539
|
+
for (let f = 0; f < t.length - a.length; f++) {
|
|
540
|
+
let m = !0;
|
|
541
|
+
for (let S = 0; S < a.length; S++)
|
|
542
|
+
if (t[f + S] !== a.charCodeAt(S)) {
|
|
543
|
+
m = !1;
|
|
537
544
|
break;
|
|
538
545
|
}
|
|
539
|
-
if (
|
|
540
|
-
|
|
546
|
+
if (m) {
|
|
547
|
+
i = f + a.length;
|
|
541
548
|
break;
|
|
542
549
|
}
|
|
543
550
|
}
|
|
544
|
-
if (
|
|
551
|
+
if (i === 0)
|
|
545
552
|
throw new Error("Invalid PLY file: Could not find end of header");
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
553
|
+
r && console.debug(
|
|
554
|
+
"[4/12] LOADER PlyLoader: header length:",
|
|
555
|
+
i
|
|
556
|
+
);
|
|
557
|
+
const l = o.decode(t.subarray(0, i));
|
|
558
|
+
r && console.debug("[5/12] LOADER PlyLoader: header text:", l);
|
|
559
|
+
const g = l.split(`
|
|
560
|
+
`), y = [];
|
|
561
|
+
let v = null;
|
|
562
|
+
for (let f = 1; f < g.length; f++) {
|
|
563
|
+
const m = g[f].trim();
|
|
564
|
+
if (m === "" || m === "end_header") continue;
|
|
565
|
+
const S = m.split(" ");
|
|
566
|
+
switch (S[0]) {
|
|
556
567
|
case "format":
|
|
557
|
-
|
|
568
|
+
v = S[1], r && console.debug(
|
|
569
|
+
"[6/12] LOADER PlyLoader: format detected:",
|
|
570
|
+
v
|
|
571
|
+
);
|
|
558
572
|
break;
|
|
559
573
|
case "element":
|
|
560
|
-
|
|
561
|
-
name:
|
|
562
|
-
count: parseInt(
|
|
574
|
+
y.push({
|
|
575
|
+
name: S[1],
|
|
576
|
+
count: parseInt(S[2], 10),
|
|
563
577
|
properties: []
|
|
564
|
-
})
|
|
578
|
+
}), r && console.debug(
|
|
579
|
+
"[6/12] LOADER PlyLoader: element found:",
|
|
580
|
+
S[1],
|
|
581
|
+
"count:",
|
|
582
|
+
S[2]
|
|
583
|
+
);
|
|
565
584
|
break;
|
|
566
585
|
case "property":
|
|
567
|
-
if (
|
|
586
|
+
if (y.length === 0)
|
|
568
587
|
throw new Error(
|
|
569
588
|
"Invalid PLY file: Property without element"
|
|
570
589
|
);
|
|
571
|
-
|
|
572
|
-
type:
|
|
573
|
-
name:
|
|
590
|
+
y[y.length - 1].properties.push({
|
|
591
|
+
type: S[1],
|
|
592
|
+
name: S[2],
|
|
574
593
|
storage: null
|
|
575
|
-
})
|
|
594
|
+
}), r && console.debug(
|
|
595
|
+
"[6/12] LOADER PlyLoader: property found:",
|
|
596
|
+
S[2],
|
|
597
|
+
"type:",
|
|
598
|
+
S[1]
|
|
599
|
+
);
|
|
576
600
|
break;
|
|
577
601
|
}
|
|
578
602
|
}
|
|
579
|
-
if (
|
|
580
|
-
throw new Error(`Unsupported PLY format: ${
|
|
581
|
-
const b =
|
|
603
|
+
if (v !== "binary_little_endian")
|
|
604
|
+
throw new Error(`Unsupported PLY format: ${v}`);
|
|
605
|
+
const b = y.find((f) => f.name === "vertex");
|
|
582
606
|
if (!b)
|
|
583
607
|
throw new Error("Invalid PLY file: No vertex element found");
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
608
|
+
r && console.debug(
|
|
609
|
+
"[7/12] LOADER PlyLoader: vertex element properties:",
|
|
610
|
+
b.properties.map((f) => f.name)
|
|
611
|
+
);
|
|
612
|
+
const p = new Me(b.count);
|
|
613
|
+
r && console.debug(
|
|
614
|
+
"[8/12] LOADER PlyLoader: created SplatData for",
|
|
615
|
+
b.count,
|
|
616
|
+
"splats"
|
|
617
|
+
);
|
|
618
|
+
const E = new DataView(e);
|
|
619
|
+
let d = i;
|
|
620
|
+
const A = (f) => b.properties.findIndex((m) => m.name === f), q = A("x"), W = A("y"), N = A("z"), F = [
|
|
621
|
+
A("rot_0"),
|
|
622
|
+
A("rot_1"),
|
|
623
|
+
A("rot_2"),
|
|
624
|
+
A("rot_3")
|
|
625
|
+
], Y = [
|
|
626
|
+
A("scale_0"),
|
|
627
|
+
A("scale_1"),
|
|
628
|
+
A("scale_2")
|
|
629
|
+
], B = [
|
|
630
|
+
A("f_dc_0"),
|
|
631
|
+
A("f_dc_1"),
|
|
632
|
+
A("f_dc_2")
|
|
633
|
+
], T = A("opacity");
|
|
634
|
+
if (r && console.debug("[9/12] LOADER PlyLoader: property indices:", {
|
|
635
|
+
position: [q, W, N],
|
|
636
|
+
rotation: F,
|
|
637
|
+
scale: Y,
|
|
638
|
+
color: B,
|
|
639
|
+
opacity: T
|
|
640
|
+
}), [
|
|
602
641
|
q,
|
|
603
642
|
W,
|
|
604
|
-
|
|
605
|
-
...
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
643
|
+
N,
|
|
644
|
+
...F,
|
|
645
|
+
...Y,
|
|
646
|
+
...B,
|
|
647
|
+
T
|
|
648
|
+
].some((f) => f === -1))
|
|
609
649
|
throw new Error("Invalid PLY file: Missing required properties");
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
return
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
650
|
+
const C = 0.28209479177387814, _ = (f) => {
|
|
651
|
+
if (f > 0) return 1 / (1 + Math.exp(-f));
|
|
652
|
+
const m = Math.exp(f);
|
|
653
|
+
return m / (1 + m);
|
|
654
|
+
};
|
|
655
|
+
r && console.debug(
|
|
656
|
+
"[10/12] LOADER PlyLoader: starting binary data parsing, offset:",
|
|
657
|
+
d
|
|
658
|
+
);
|
|
659
|
+
const I = new c.Vector3(), P = new c.Quaternion(), V = new c.Vector3(), k = new c.Color();
|
|
660
|
+
for (let f = 0; f < b.count; f++) {
|
|
661
|
+
r && f % 1e4 === 0 && console.debug(
|
|
662
|
+
`[10/12] LOADER PlyLoader: processing splat ${f}/${b.count} (${(f / b.count * 100).toFixed(1)}%)`
|
|
663
|
+
);
|
|
664
|
+
const m = [];
|
|
665
|
+
for (let j = 0; j < b.properties.length; j++) {
|
|
666
|
+
const s = b.properties[j].type;
|
|
667
|
+
let u;
|
|
668
|
+
switch (s) {
|
|
621
669
|
case "char":
|
|
622
|
-
|
|
670
|
+
u = E.getInt8(d), d += 1;
|
|
623
671
|
break;
|
|
624
672
|
case "uchar":
|
|
625
|
-
|
|
673
|
+
u = E.getUint8(d), d += 1;
|
|
626
674
|
break;
|
|
627
675
|
case "short":
|
|
628
|
-
|
|
676
|
+
u = E.getInt16(d, !0), d += 2;
|
|
629
677
|
break;
|
|
630
678
|
case "ushort":
|
|
631
|
-
|
|
679
|
+
u = E.getUint16(d, !0), d += 2;
|
|
632
680
|
break;
|
|
633
681
|
case "int":
|
|
634
|
-
|
|
682
|
+
u = E.getInt32(d, !0), d += 4;
|
|
635
683
|
break;
|
|
636
684
|
case "uint":
|
|
637
|
-
|
|
685
|
+
u = E.getUint32(d, !0), d += 4;
|
|
638
686
|
break;
|
|
639
687
|
case "float":
|
|
640
|
-
|
|
688
|
+
u = E.getFloat32(d, !0), d += 4;
|
|
641
689
|
break;
|
|
642
690
|
case "double":
|
|
643
|
-
|
|
691
|
+
u = E.getFloat64(d, !0), d += 8;
|
|
644
692
|
break;
|
|
645
693
|
default:
|
|
646
|
-
throw new Error(`Unsupported property type: ${
|
|
694
|
+
throw new Error(`Unsupported property type: ${s}`);
|
|
647
695
|
}
|
|
648
|
-
|
|
696
|
+
m.push(u);
|
|
649
697
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
),
|
|
655
|
-
|
|
698
|
+
I.set(
|
|
699
|
+
m[q],
|
|
700
|
+
m[W],
|
|
701
|
+
m[N]
|
|
702
|
+
), P.set(
|
|
703
|
+
m[F[1]],
|
|
656
704
|
// PLY stores rot 1,2,3,0 (x,y,z,w)
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
).normalize(),
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
705
|
+
m[F[2]],
|
|
706
|
+
m[F[3]],
|
|
707
|
+
m[F[0]]
|
|
708
|
+
).normalize(), r && f < 5 && console.debug(
|
|
709
|
+
`[10/12] LOADER PlyLoader: splat ${f} rotation:`,
|
|
710
|
+
{
|
|
711
|
+
original: [
|
|
712
|
+
m[F[0]],
|
|
713
|
+
m[F[1]],
|
|
714
|
+
m[F[2]],
|
|
715
|
+
m[F[3]]
|
|
716
|
+
],
|
|
717
|
+
processed: [
|
|
718
|
+
P.x,
|
|
719
|
+
P.y,
|
|
720
|
+
P.z,
|
|
721
|
+
P.w
|
|
722
|
+
]
|
|
723
|
+
}
|
|
665
724
|
), V.set(
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
725
|
+
m[Y[0]],
|
|
726
|
+
// Read directly assuming it's log scale
|
|
727
|
+
m[Y[1]],
|
|
728
|
+
m[Y[2]]
|
|
729
|
+
), k.set(
|
|
730
|
+
0.5 + m[B[0]] * C,
|
|
731
|
+
0.5 + m[B[1]] * C,
|
|
732
|
+
0.5 + m[B[2]] * C
|
|
733
|
+
), k.r = Math.max(0, Math.min(1, k.r)), k.g = Math.max(0, Math.min(1, k.g)), k.b = Math.max(0, Math.min(1, k.b));
|
|
734
|
+
const S = _(m[T]);
|
|
735
|
+
r && f < 3 && console.debug(`[10/12] LOADER PlyLoader: splat ${f} data:`, {
|
|
736
|
+
position: [I.x, I.y, I.z],
|
|
737
|
+
rotation: [
|
|
738
|
+
P.x,
|
|
739
|
+
P.y,
|
|
740
|
+
P.z,
|
|
741
|
+
P.w
|
|
742
|
+
],
|
|
743
|
+
scale: [V.x, V.y, V.z],
|
|
744
|
+
color: [k.r, k.g, k.b],
|
|
745
|
+
opacity: S
|
|
746
|
+
}), p.setSplat(
|
|
747
|
+
f,
|
|
748
|
+
I,
|
|
749
|
+
P,
|
|
677
750
|
V,
|
|
678
|
-
|
|
751
|
+
// Pass log scale directly
|
|
752
|
+
k,
|
|
753
|
+
S
|
|
679
754
|
);
|
|
680
755
|
}
|
|
681
|
-
return
|
|
756
|
+
return r && console.debug(
|
|
757
|
+
"[11/12] LOADER PlyLoader: finished parsing all splats, calculating bounding box"
|
|
758
|
+
), p.calculateBoundingBox(), r && console.debug(
|
|
759
|
+
"[12/12] LOADER PlyLoader: parsing complete, bounding box:",
|
|
760
|
+
{
|
|
761
|
+
min: [
|
|
762
|
+
p.boundingBox.min.x,
|
|
763
|
+
p.boundingBox.min.y,
|
|
764
|
+
p.boundingBox.min.z
|
|
765
|
+
],
|
|
766
|
+
max: [
|
|
767
|
+
p.boundingBox.max.x,
|
|
768
|
+
p.boundingBox.max.y,
|
|
769
|
+
p.boundingBox.max.z
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
), p;
|
|
682
773
|
}
|
|
683
774
|
}
|
|
684
|
-
class
|
|
775
|
+
class Ce extends c.EventDispatcher {
|
|
685
776
|
constructor() {
|
|
686
777
|
super();
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
778
|
+
w(this, "worker");
|
|
779
|
+
w(this, "centers", null);
|
|
780
|
+
w(this, "orderTexture", null);
|
|
690
781
|
/** Bounding box data for optimization */
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
const
|
|
695
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
782
|
+
w(this, "chunks", null);
|
|
783
|
+
w(this, "lastCameraPosition", new c.Vector3());
|
|
784
|
+
w(this, "lastCameraDirection", new c.Vector3());
|
|
785
|
+
const r = this.createWorkerCode(), o = new Blob([r], { type: "application/javascript" });
|
|
786
|
+
this.worker = new Worker(URL.createObjectURL(o)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
696
787
|
}
|
|
697
788
|
/**
|
|
698
789
|
* Handles messages received from the sorting worker.
|
|
699
790
|
* @param event The message event from the worker.
|
|
700
791
|
*/
|
|
701
|
-
onWorkerMessage(
|
|
792
|
+
onWorkerMessage(r) {
|
|
702
793
|
if (!this.orderTexture || !this.orderTexture.image)
|
|
703
794
|
return console.error("SplatSorter: Order texture not initialized!");
|
|
704
|
-
const { order:
|
|
705
|
-
if (!(
|
|
795
|
+
const { order: o, count: t } = r.data, n = this.orderTexture.image.data;
|
|
796
|
+
if (!(n instanceof Uint32Array))
|
|
706
797
|
return console.error(
|
|
707
798
|
"SplatSorter: Order texture data is not a Uint32Array!"
|
|
708
799
|
);
|
|
709
|
-
|
|
710
|
-
const a =
|
|
711
|
-
this.worker.postMessage(
|
|
800
|
+
n.set(new Uint32Array(o)), this.orderTexture.needsUpdate = !0;
|
|
801
|
+
const a = n.buffer.slice(0), i = { order: a };
|
|
802
|
+
this.worker.postMessage(i, [a]), this.dispatchEvent({ type: "updated", count: t });
|
|
712
803
|
}
|
|
713
804
|
/**
|
|
714
805
|
* Initializes the sorter with necessary data and textures.
|
|
@@ -716,82 +807,82 @@ class _e extends i.EventDispatcher {
|
|
|
716
807
|
* @param centers A Float32Array containing the center position (x, y, z) for each splat.
|
|
717
808
|
* @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
|
|
718
809
|
*/
|
|
719
|
-
init(
|
|
720
|
-
if (!
|
|
810
|
+
init(r, o, t) {
|
|
811
|
+
if (!r || !(r.image.data instanceof Uint32Array))
|
|
721
812
|
throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
|
|
722
|
-
if (!
|
|
813
|
+
if (!o || o.length % 3 !== 0)
|
|
723
814
|
throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
|
|
724
|
-
if (
|
|
815
|
+
if (r.image.data.length < o.length / 3)
|
|
725
816
|
throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
|
|
726
|
-
const
|
|
727
|
-
this.orderTexture =
|
|
817
|
+
const n = o.length / 3;
|
|
818
|
+
this.orderTexture = r, this.centers = o.slice();
|
|
728
819
|
const a = this.orderTexture.image.data;
|
|
729
|
-
for (let
|
|
820
|
+
for (let v = 0; v < n; v++) a[v] = v;
|
|
730
821
|
this.orderTexture.needsUpdate = !0;
|
|
731
|
-
const
|
|
732
|
-
order:
|
|
822
|
+
const i = a.buffer.slice(0), l = this.centers.buffer.slice(0), g = {
|
|
823
|
+
order: i,
|
|
733
824
|
centers: l
|
|
734
|
-
},
|
|
735
|
-
|
|
825
|
+
}, y = [
|
|
826
|
+
i,
|
|
736
827
|
l
|
|
737
828
|
];
|
|
738
|
-
if (
|
|
739
|
-
this.chunks =
|
|
740
|
-
const
|
|
741
|
-
|
|
829
|
+
if (t) {
|
|
830
|
+
this.chunks = t.slice();
|
|
831
|
+
const v = this.chunks.buffer.slice(0);
|
|
832
|
+
g.chunks = v, y.push(v);
|
|
742
833
|
}
|
|
743
|
-
this.worker.postMessage(
|
|
834
|
+
this.worker.postMessage(g, y);
|
|
744
835
|
}
|
|
745
836
|
/**
|
|
746
837
|
* Applies an optional mapping to filter or reorder splats before sorting.
|
|
747
838
|
* The sorter will only consider splats whose original indices are present in the mapping.
|
|
748
839
|
* @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
|
|
749
840
|
*/
|
|
750
|
-
setMapping(
|
|
841
|
+
setMapping(r) {
|
|
751
842
|
if (!this.centers)
|
|
752
843
|
return console.warn(
|
|
753
844
|
"SplatSorter: Cannot set mapping before initialization."
|
|
754
845
|
);
|
|
755
|
-
let
|
|
756
|
-
const
|
|
757
|
-
if (!
|
|
846
|
+
let o;
|
|
847
|
+
const t = [];
|
|
848
|
+
if (!r) {
|
|
758
849
|
const l = this.centers.buffer.slice(0);
|
|
759
|
-
return
|
|
850
|
+
return o = {
|
|
760
851
|
centers: l,
|
|
761
852
|
mapping: null
|
|
762
|
-
},
|
|
853
|
+
}, t.push(l), this.worker.postMessage(o, t);
|
|
763
854
|
}
|
|
764
|
-
const
|
|
765
|
-
for (let l = 0; l <
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
855
|
+
const n = new Float32Array(r.length * 3);
|
|
856
|
+
for (let l = 0; l < r.length; l++) {
|
|
857
|
+
const g = r[l];
|
|
858
|
+
if (g * 3 + 2 >= this.centers.length) {
|
|
768
859
|
console.warn(
|
|
769
|
-
`SplatSorter: Mapping index ${
|
|
860
|
+
`SplatSorter: Mapping index ${g} out of bounds.`
|
|
770
861
|
);
|
|
771
862
|
continue;
|
|
772
863
|
}
|
|
773
|
-
const
|
|
774
|
-
|
|
864
|
+
const y = g * 3, v = l * 3;
|
|
865
|
+
n[v + 0] = this.centers[y + 0], n[v + 1] = this.centers[y + 1], n[v + 2] = this.centers[y + 2];
|
|
775
866
|
}
|
|
776
|
-
const a =
|
|
777
|
-
|
|
867
|
+
const a = n.buffer.slice(0), i = r.buffer.slice(0);
|
|
868
|
+
o = {
|
|
778
869
|
centers: a,
|
|
779
|
-
mapping:
|
|
780
|
-
},
|
|
870
|
+
mapping: i
|
|
871
|
+
}, t.push(a, i), this.worker.postMessage(o, t);
|
|
781
872
|
}
|
|
782
873
|
/**
|
|
783
874
|
* Updates the camera parameters used for sorting.
|
|
784
875
|
* @param position The camera's position in the sorter's local coordinate space.
|
|
785
876
|
* @param direction The camera's forward direction in the sorter's local coordinate space.
|
|
786
877
|
*/
|
|
787
|
-
setCamera(
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
878
|
+
setCamera(r, o) {
|
|
879
|
+
const t = this.lastCameraPosition.distanceToSquared(r) > 1e-7, n = this.lastCameraDirection.dot(o) < 0.9999;
|
|
880
|
+
if (!t && !n)
|
|
790
881
|
return;
|
|
791
|
-
this.lastCameraPosition.copy(
|
|
882
|
+
this.lastCameraPosition.copy(r), this.lastCameraDirection.copy(o);
|
|
792
883
|
const a = {
|
|
793
|
-
cameraPosition: { x:
|
|
794
|
-
cameraDirection: { x:
|
|
884
|
+
cameraPosition: { x: r.x, y: r.y, z: r.z },
|
|
885
|
+
cameraDirection: { x: o.x, y: o.y, z: o.z }
|
|
795
886
|
};
|
|
796
887
|
this.worker.postMessage(a);
|
|
797
888
|
}
|
|
@@ -807,165 +898,165 @@ class _e extends i.EventDispatcher {
|
|
|
807
898
|
*/
|
|
808
899
|
createWorkerCode() {
|
|
809
900
|
return `(${(function() {
|
|
810
|
-
let
|
|
811
|
-
const
|
|
812
|
-
let
|
|
813
|
-
const
|
|
814
|
-
for (;
|
|
815
|
-
const
|
|
816
|
-
if (
|
|
817
|
-
else if (
|
|
818
|
-
else return
|
|
901
|
+
let o = null, t = null, n = null, a = null, i = null, l = null, g = !1;
|
|
902
|
+
const y = { x: 0, y: 0, z: 0 }, v = { x: 0, y: 0, z: 0 }, b = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 };
|
|
903
|
+
let E = null, d = null;
|
|
904
|
+
const A = 32, q = new Array(A).fill(0), W = new Array(A).fill(0), N = new Array(A).fill(0), F = (B, T, U) => {
|
|
905
|
+
for (; B <= T; ) {
|
|
906
|
+
const C = T + B >> 1, _ = U(C);
|
|
907
|
+
if (_ > 0) B = C + 1;
|
|
908
|
+
else if (_ < 0) T = C - 1;
|
|
909
|
+
else return C;
|
|
819
910
|
}
|
|
820
|
-
return ~
|
|
821
|
-
},
|
|
822
|
-
if (!
|
|
911
|
+
return ~B;
|
|
912
|
+
}, Y = () => {
|
|
913
|
+
if (!o || !t || !i || !l)
|
|
823
914
|
return;
|
|
824
|
-
if (
|
|
825
|
-
const
|
|
826
|
-
order:
|
|
915
|
+
if (t.length === 0) {
|
|
916
|
+
const x = {
|
|
917
|
+
order: o.buffer,
|
|
827
918
|
count: 0
|
|
828
919
|
};
|
|
829
|
-
self.postMessage(
|
|
920
|
+
self.postMessage(x, [o.buffer]), o = null;
|
|
830
921
|
return;
|
|
831
922
|
}
|
|
832
|
-
const
|
|
833
|
-
if (!
|
|
923
|
+
const B = i.x, T = i.y, U = i.z, C = l.x, _ = l.y, I = l.z, P = 1e-4, V = Math.abs(B - y.x) > P || Math.abs(T - y.y) > P || Math.abs(U - y.z) > P, k = Math.abs(C - v.x) > P || Math.abs(_ - v.y) > P || Math.abs(I - v.z) > P;
|
|
924
|
+
if (!g && !V && !k)
|
|
834
925
|
return;
|
|
835
|
-
|
|
836
|
-
let
|
|
837
|
-
for (let
|
|
838
|
-
const
|
|
839
|
-
|
|
926
|
+
g = !1, y.x = B, y.y = T, y.z = U, v.x = C, v.y = _, v.z = I;
|
|
927
|
+
let f = 1 / 0, m = -1 / 0;
|
|
928
|
+
for (let x = 0; x < 8; ++x) {
|
|
929
|
+
const O = x & 1 ? b.x : p.x, L = x & 2 ? b.y : p.y, h = x & 4 ? b.z : p.z, z = O * C + L * _ + h * I;
|
|
930
|
+
f = Math.min(f, z), m = Math.max(m, z);
|
|
840
931
|
}
|
|
841
|
-
const
|
|
932
|
+
const S = t.length / 3, j = m - f, s = (1 << Math.max(
|
|
842
933
|
10,
|
|
843
|
-
Math.min(20, Math.ceil(Math.log2(
|
|
934
|
+
Math.min(20, Math.ceil(Math.log2(S / 4)))
|
|
844
935
|
)) + 1;
|
|
845
|
-
if ((!
|
|
846
|
-
for (let
|
|
847
|
-
|
|
848
|
-
} else if (
|
|
849
|
-
const
|
|
936
|
+
if ((!E || E.length !== S) && (E = new Uint32Array(S)), !d || d.length !== s ? d = new Uint32Array(s) : d.fill(0), j < 1e-7) {
|
|
937
|
+
for (let x = 0; x < S; ++x) E[x] = 0;
|
|
938
|
+
d[0] = S;
|
|
939
|
+
} else if (n && n.length > 0) {
|
|
940
|
+
const x = n.length / 6;
|
|
850
941
|
q.fill(0);
|
|
851
|
-
for (let
|
|
852
|
-
const
|
|
942
|
+
for (let h = 0; h < x; ++h) {
|
|
943
|
+
const z = h * 6, G = n[z + 0], $ = n[z + 1], oe = n[z + 2], Z = n[z + 3], J = G * C + $ * _ + oe * I - f, ne = J - Z, K = J + Z, ie = Math.max(
|
|
853
944
|
0,
|
|
854
|
-
Math.floor(
|
|
945
|
+
Math.floor(ne * A / j)
|
|
855
946
|
), ce = Math.min(
|
|
856
|
-
|
|
857
|
-
Math.ceil(
|
|
947
|
+
A,
|
|
948
|
+
Math.ceil(K * A / j)
|
|
858
949
|
);
|
|
859
950
|
for (let Q = ie; Q < ce; ++Q)
|
|
860
951
|
q[Q]++;
|
|
861
952
|
}
|
|
862
|
-
let
|
|
863
|
-
for (let
|
|
864
|
-
|
|
865
|
-
for (let
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
for (let
|
|
870
|
-
const
|
|
953
|
+
let O = 0;
|
|
954
|
+
for (let h = 0; h < A; ++h) O += q[h];
|
|
955
|
+
N[0] = 0, W[0] = 0;
|
|
956
|
+
for (let h = 1; h < A; ++h)
|
|
957
|
+
N[h - 1] = q[h - 1] / O * s >>> 0, W[h] = W[h - 1] + N[h - 1];
|
|
958
|
+
N[A - 1] = q[A - 1] / O * s >>> 0;
|
|
959
|
+
const L = j / A;
|
|
960
|
+
for (let h = 0; h < S; ++h) {
|
|
961
|
+
const z = h * 3, G = t[z + 0], $ = t[z + 1], oe = t[z + 2], Z = G * C + $ * _ + oe * I, ne = (m - Z) / L, K = Math.max(
|
|
871
962
|
0,
|
|
872
963
|
Math.min(
|
|
873
|
-
|
|
874
|
-
Math.floor(
|
|
964
|
+
A - 1,
|
|
965
|
+
Math.floor(ne)
|
|
875
966
|
)
|
|
876
|
-
), ie =
|
|
877
|
-
h
|
|
967
|
+
), ie = ne - K, ce = W[K] + N[K] * ie >>> 0, Q = Math.min(ce, s - 1);
|
|
968
|
+
E[h] = Q, d[Q]++;
|
|
878
969
|
}
|
|
879
970
|
} else {
|
|
880
|
-
const
|
|
881
|
-
for (let
|
|
882
|
-
const
|
|
883
|
-
|
|
971
|
+
const x = (s - 1) / j;
|
|
972
|
+
for (let O = 0; O < S; ++O) {
|
|
973
|
+
const L = O * 3, h = t[L + 0], z = t[L + 1], G = t[L + 2], $ = h * C + z * _ + G * I, Z = (m - $) * x >>> 0, J = Math.min(Z, s - 1);
|
|
974
|
+
E[O] = J, d[J]++;
|
|
884
975
|
}
|
|
885
976
|
}
|
|
886
|
-
for (let
|
|
887
|
-
|
|
888
|
-
for (let
|
|
889
|
-
const
|
|
890
|
-
|
|
977
|
+
for (let x = 1; x < s; x++)
|
|
978
|
+
d[x] += d[x - 1];
|
|
979
|
+
for (let x = S - 1; x >= 0; x--) {
|
|
980
|
+
const O = E[x], L = --d[O];
|
|
981
|
+
o[L] = a ? a[x] : x;
|
|
891
982
|
}
|
|
892
|
-
const
|
|
893
|
-
if (!
|
|
894
|
-
const
|
|
895
|
-
if (!
|
|
983
|
+
const u = B * C + T * _ + U * I, R = (x) => {
|
|
984
|
+
if (!o) return -1 / 0;
|
|
985
|
+
const O = o[x], L = O;
|
|
986
|
+
if (!t || L * 3 + 2 >= t.length)
|
|
896
987
|
return -1 / 0;
|
|
897
|
-
const
|
|
898
|
-
return
|
|
988
|
+
const h = L * 3;
|
|
989
|
+
return t[h] * C + t[h + 1] * _ + t[h + 2] * I - u;
|
|
899
990
|
};
|
|
900
|
-
let
|
|
901
|
-
if (
|
|
902
|
-
const
|
|
991
|
+
let D = S;
|
|
992
|
+
if (S > 0 && R(S - 1) < 0) {
|
|
993
|
+
const x = F(
|
|
903
994
|
0,
|
|
904
|
-
|
|
905
|
-
|
|
995
|
+
S - 1,
|
|
996
|
+
R
|
|
906
997
|
);
|
|
907
|
-
|
|
998
|
+
D = x < 0 ? ~x : x;
|
|
908
999
|
}
|
|
909
|
-
const
|
|
910
|
-
order:
|
|
911
|
-
count:
|
|
1000
|
+
const H = {
|
|
1001
|
+
order: o.buffer,
|
|
1002
|
+
count: D
|
|
912
1003
|
};
|
|
913
|
-
self.postMessage(
|
|
1004
|
+
self.postMessage(H, [o.buffer]), o = null;
|
|
914
1005
|
};
|
|
915
|
-
self.onmessage = (
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
let
|
|
919
|
-
if (
|
|
920
|
-
if (
|
|
921
|
-
for (let
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
(
|
|
1006
|
+
self.onmessage = (B) => {
|
|
1007
|
+
const T = B.data;
|
|
1008
|
+
T.order && (o = new Uint32Array(T.order));
|
|
1009
|
+
let U = !1;
|
|
1010
|
+
if (T.centers && (t = new Float32Array(T.centers), U = !0, g = !0), Object.prototype.hasOwnProperty.call(T, "mapping") && (a = T.mapping ? new Uint32Array(T.mapping) : null, g = !0), T.chunks) {
|
|
1011
|
+
if (n = new Float32Array(T.chunks), n.length > 0 && n[3] > 0)
|
|
1012
|
+
for (let C = 0; C < n.length / 6; ++C) {
|
|
1013
|
+
const _ = C * 6, I = n[_ + 0], P = n[_ + 1], V = n[_ + 2], k = n[_ + 3], f = n[_ + 4], m = n[_ + 5];
|
|
1014
|
+
n[_ + 0] = (I + k) * 0.5, n[_ + 1] = (P + f) * 0.5, n[_ + 2] = (V + m) * 0.5, n[_ + 3] = Math.sqrt(
|
|
1015
|
+
(k - I) ** 2 + (f - P) ** 2 + (m - V) ** 2
|
|
925
1016
|
) * 0.5;
|
|
926
1017
|
}
|
|
927
|
-
|
|
1018
|
+
g = !0;
|
|
928
1019
|
}
|
|
929
|
-
if (
|
|
930
|
-
|
|
931
|
-
for (let
|
|
932
|
-
const
|
|
933
|
-
|
|
1020
|
+
if (U && t && t.length > 0) {
|
|
1021
|
+
b.x = p.x = t[0], b.y = p.y = t[1], b.z = p.z = t[2];
|
|
1022
|
+
for (let C = 1; C < t.length / 3; C++) {
|
|
1023
|
+
const _ = C * 3;
|
|
1024
|
+
b.x = Math.min(b.x, t[_ + 0]), p.x = Math.max(p.x, t[_ + 0]), b.y = Math.min(b.y, t[_ + 1]), p.y = Math.max(p.y, t[_ + 1]), b.z = Math.min(b.z, t[_ + 2]), p.z = Math.max(p.z, t[_ + 2]);
|
|
934
1025
|
}
|
|
935
|
-
} else
|
|
936
|
-
|
|
1026
|
+
} else U && t && t.length === 0 && (b.x = p.x = b.y = p.y = b.z = p.z = 0);
|
|
1027
|
+
T.cameraPosition && (i = T.cameraPosition), T.cameraDirection && (l = T.cameraDirection), Y();
|
|
937
1028
|
};
|
|
938
1029
|
}).toString()})();`;
|
|
939
1030
|
}
|
|
940
1031
|
}
|
|
941
|
-
const
|
|
942
|
-
const
|
|
943
|
-
return
|
|
1032
|
+
const Re = (M, e) => {
|
|
1033
|
+
const r = he(M), o = he(e);
|
|
1034
|
+
return r | o << 16;
|
|
944
1035
|
};
|
|
945
|
-
function
|
|
946
|
-
const e = new Float32Array([M]),
|
|
947
|
-
let
|
|
948
|
-
const a =
|
|
949
|
-
return a < 103 ?
|
|
1036
|
+
function he(M) {
|
|
1037
|
+
const e = new Float32Array([M]), o = new Int32Array(e.buffer)[0];
|
|
1038
|
+
let t = o >> 16 & 32768, n = o >> 12 & 2047;
|
|
1039
|
+
const a = o >> 23 & 255;
|
|
1040
|
+
return a < 103 ? t : a > 142 ? (t |= 31744, t |= (a === 255 ? 0 : 1) && o & 8388607, t) : a < 113 ? (n |= 2048, t |= (n >> 114 - a) + (n >> 113 - a & 1), t) : (t |= a - 112 << 10 | n >> 1, t += n & 1, t);
|
|
950
1041
|
}
|
|
951
|
-
const
|
|
952
|
-
class
|
|
1042
|
+
const Pe = new ArrayBuffer(4), pe = new DataView(Pe), Ie = (M) => (pe.setUint32(0, M, !0), pe.getFloat32(0, !0));
|
|
1043
|
+
class ke {
|
|
953
1044
|
/**
|
|
954
1045
|
* Create a new TextureManager for a set of splats
|
|
955
1046
|
* @param splatData The splat data to manage textures for
|
|
956
1047
|
*/
|
|
957
1048
|
constructor(e) {
|
|
958
|
-
|
|
1049
|
+
w(this, "transformA");
|
|
959
1050
|
// position xyz and rotation quaternion y,z components
|
|
960
|
-
|
|
1051
|
+
w(this, "transformB");
|
|
961
1052
|
// rotation quaternion x and scale xyz
|
|
962
|
-
|
|
1053
|
+
w(this, "colorTexture");
|
|
963
1054
|
// color an opacity
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
const
|
|
968
|
-
this.textureWidth = Math.ceil(Math.sqrt(
|
|
1055
|
+
w(this, "orderTexture");
|
|
1056
|
+
w(this, "textureWidth");
|
|
1057
|
+
w(this, "textureHeight");
|
|
1058
|
+
const r = e.numSplats;
|
|
1059
|
+
this.textureWidth = Math.ceil(Math.sqrt(r)), this.textureHeight = Math.ceil(r / this.textureWidth), this.transformA = this.createTransformATexture(e), this.transformB = this.createTransformBTexture(e), this.colorTexture = this.createColorTexture(e), this.orderTexture = this.createOrderTexture(r);
|
|
969
1060
|
}
|
|
970
1061
|
/**
|
|
971
1062
|
* Create the transform A texture (positions and quaternion w component)
|
|
@@ -973,24 +1064,24 @@ class ze {
|
|
|
973
1064
|
* @returns DataTexture containing position data
|
|
974
1065
|
*/
|
|
975
1066
|
createTransformATexture(e) {
|
|
976
|
-
const
|
|
1067
|
+
const r = e.numSplats, o = new Float32Array(
|
|
977
1068
|
this.textureWidth * this.textureHeight * 4
|
|
978
1069
|
);
|
|
979
|
-
for (let
|
|
980
|
-
const a =
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
|
|
1070
|
+
for (let n = 0; n < r; n++) {
|
|
1071
|
+
const a = n * 4, i = n * 3, l = n * 4;
|
|
1072
|
+
o[a] = e.positions[i], o[a + 1] = e.positions[i + 1], o[a + 2] = e.positions[i + 2];
|
|
1073
|
+
const g = e.rotations[l + 0], y = e.rotations[l + 1], v = Re(g, y);
|
|
1074
|
+
o[a + 3] = Ie(v);
|
|
984
1075
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
1076
|
+
const t = new c.DataTexture(
|
|
1077
|
+
o,
|
|
987
1078
|
this.textureWidth,
|
|
988
1079
|
this.textureHeight,
|
|
989
|
-
|
|
990
|
-
|
|
1080
|
+
c.RGBAFormat,
|
|
1081
|
+
c.FloatType
|
|
991
1082
|
// Store as Float32, shader will reinterpret bits
|
|
992
1083
|
);
|
|
993
|
-
return
|
|
1084
|
+
return t.needsUpdate = !0, t.magFilter = c.NearestFilter, t.minFilter = c.NearestFilter, t;
|
|
994
1085
|
}
|
|
995
1086
|
/**
|
|
996
1087
|
* Create the transform B texture (scale and rotation xyz)
|
|
@@ -998,21 +1089,21 @@ class ze {
|
|
|
998
1089
|
* @returns DataTexture containing scale and rotation data
|
|
999
1090
|
*/
|
|
1000
1091
|
createTransformBTexture(e) {
|
|
1001
|
-
const
|
|
1092
|
+
const r = e.numSplats, o = new Float32Array(
|
|
1002
1093
|
this.textureWidth * this.textureHeight * 4
|
|
1003
1094
|
);
|
|
1004
|
-
for (let
|
|
1005
|
-
const a =
|
|
1006
|
-
|
|
1095
|
+
for (let n = 0; n < r; n++) {
|
|
1096
|
+
const a = n * 4, i = n * 3, l = n * 4;
|
|
1097
|
+
o[a] = e.scales[i], o[a + 1] = e.scales[i + 1], o[a + 2] = e.scales[i + 2], o[a + 3] = e.rotations[l + 2];
|
|
1007
1098
|
}
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1099
|
+
const t = new c.DataTexture(
|
|
1100
|
+
o,
|
|
1010
1101
|
this.textureWidth,
|
|
1011
1102
|
this.textureHeight,
|
|
1012
|
-
|
|
1013
|
-
|
|
1103
|
+
c.RGBAFormat,
|
|
1104
|
+
c.FloatType
|
|
1014
1105
|
);
|
|
1015
|
-
return
|
|
1106
|
+
return t.needsUpdate = !0, t.magFilter = c.NearestFilter, t.minFilter = c.NearestFilter, t;
|
|
1016
1107
|
}
|
|
1017
1108
|
/**
|
|
1018
1109
|
* Create the color texture (RGB and opacity)
|
|
@@ -1020,21 +1111,21 @@ class ze {
|
|
|
1020
1111
|
* @returns DataTexture containing color data
|
|
1021
1112
|
*/
|
|
1022
1113
|
createColorTexture(e) {
|
|
1023
|
-
const
|
|
1114
|
+
const r = e.numSplats, o = new Float32Array(
|
|
1024
1115
|
this.textureWidth * this.textureHeight * 4
|
|
1025
1116
|
);
|
|
1026
|
-
for (let
|
|
1027
|
-
const a =
|
|
1028
|
-
|
|
1117
|
+
for (let n = 0; n < r; n++) {
|
|
1118
|
+
const a = n * 4, i = n * 3;
|
|
1119
|
+
o[a] = e.colors[i], o[a + 1] = e.colors[i + 1], o[a + 2] = e.colors[i + 2], o[a + 3] = e.opacities[n];
|
|
1029
1120
|
}
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1121
|
+
const t = new c.DataTexture(
|
|
1122
|
+
o,
|
|
1032
1123
|
this.textureWidth,
|
|
1033
1124
|
this.textureHeight,
|
|
1034
|
-
|
|
1035
|
-
|
|
1125
|
+
c.RGBAFormat,
|
|
1126
|
+
c.FloatType
|
|
1036
1127
|
);
|
|
1037
|
-
return
|
|
1128
|
+
return t.needsUpdate = !0, t;
|
|
1038
1129
|
}
|
|
1039
1130
|
/**
|
|
1040
1131
|
* Create the order texture for sorting
|
|
@@ -1042,23 +1133,23 @@ class ze {
|
|
|
1042
1133
|
* @returns DataTexture for storing order indices
|
|
1043
1134
|
*/
|
|
1044
1135
|
createOrderTexture(e) {
|
|
1045
|
-
const
|
|
1046
|
-
for (let
|
|
1047
|
-
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1136
|
+
const r = new Uint32Array(this.textureWidth * this.textureHeight);
|
|
1137
|
+
for (let t = 0; t < e; t++)
|
|
1138
|
+
r[t] = t;
|
|
1139
|
+
const o = new c.DataTexture(
|
|
1140
|
+
r,
|
|
1050
1141
|
this.textureWidth,
|
|
1051
1142
|
this.textureHeight,
|
|
1052
|
-
|
|
1053
|
-
|
|
1143
|
+
c.RedIntegerFormat,
|
|
1144
|
+
c.UnsignedIntType
|
|
1054
1145
|
);
|
|
1055
|
-
return
|
|
1146
|
+
return o.needsUpdate = !0, o;
|
|
1056
1147
|
}
|
|
1057
1148
|
dispose() {
|
|
1058
1149
|
this.transformA.dispose(), this.transformB.dispose(), this.colorTexture.dispose(), this.orderTexture.dispose();
|
|
1059
1150
|
}
|
|
1060
1151
|
}
|
|
1061
|
-
const
|
|
1152
|
+
const ze = (
|
|
1062
1153
|
/* glsl */
|
|
1063
1154
|
`
|
|
1064
1155
|
precision highp float;
|
|
@@ -1316,7 +1407,7 @@ void main(void) {
|
|
|
1316
1407
|
vUv = clippedCornerOffset;
|
|
1317
1408
|
}
|
|
1318
1409
|
`
|
|
1319
|
-
),
|
|
1410
|
+
), De = (
|
|
1320
1411
|
/* glsl */
|
|
1321
1412
|
`
|
|
1322
1413
|
precision highp float;
|
|
@@ -1350,56 +1441,56 @@ void main(void) {
|
|
|
1350
1441
|
}
|
|
1351
1442
|
`
|
|
1352
1443
|
);
|
|
1353
|
-
class
|
|
1444
|
+
class Oe extends c.ShaderMaterial {
|
|
1354
1445
|
constructor(e = {}) {
|
|
1355
|
-
const
|
|
1446
|
+
const r = {
|
|
1356
1447
|
// Textures (values set via methods)
|
|
1357
1448
|
transformA: { value: null },
|
|
1358
1449
|
transformB: { value: null },
|
|
1359
1450
|
splatColor: { value: null },
|
|
1360
1451
|
splatOrder: { value: null },
|
|
1361
1452
|
// Other uniforms
|
|
1362
|
-
viewport: { value: new
|
|
1453
|
+
viewport: { value: new c.Vector2(1, 1) },
|
|
1363
1454
|
// Will be updated
|
|
1364
1455
|
numSplats: { value: 0 }
|
|
1365
1456
|
// Max splats to render (updated by sorter)
|
|
1366
1457
|
};
|
|
1367
1458
|
super({
|
|
1368
|
-
vertexShader:
|
|
1369
|
-
fragmentShader:
|
|
1370
|
-
uniforms:
|
|
1459
|
+
vertexShader: ze,
|
|
1460
|
+
fragmentShader: De,
|
|
1461
|
+
uniforms: r,
|
|
1371
1462
|
transparent: !0,
|
|
1372
|
-
blending:
|
|
1463
|
+
blending: c.CustomBlending,
|
|
1373
1464
|
// Premultiplied alpha blending:
|
|
1374
1465
|
// color = src_color * src_alpha + dst_color * (1 - src_alpha)
|
|
1375
1466
|
// alpha = src_alpha * 1 + dst_alpha * (1 - src_alpha)
|
|
1376
|
-
blendSrc:
|
|
1467
|
+
blendSrc: c.OneFactor,
|
|
1377
1468
|
// Using ONE because shader outputs premultiplied color (color * alpha)
|
|
1378
|
-
blendDst:
|
|
1379
|
-
blendSrcAlpha:
|
|
1469
|
+
blendDst: c.OneMinusSrcAlphaFactor,
|
|
1470
|
+
blendSrcAlpha: c.OneFactor,
|
|
1380
1471
|
// source alpha comes from shader
|
|
1381
|
-
blendDstAlpha:
|
|
1382
|
-
blendEquation:
|
|
1383
|
-
blendEquationAlpha:
|
|
1472
|
+
blendDstAlpha: c.OneMinusSrcAlphaFactor,
|
|
1473
|
+
blendEquation: c.AddEquation,
|
|
1474
|
+
blendEquationAlpha: c.AddEquation,
|
|
1384
1475
|
depthTest: !0,
|
|
1385
1476
|
depthWrite: !1,
|
|
1386
1477
|
// Disable depth write for transparency
|
|
1387
|
-
side:
|
|
1478
|
+
side: c.DoubleSide,
|
|
1388
1479
|
// Render both sides (or CULLFACE_NONE equivalent)
|
|
1389
1480
|
// Optional settings from constructor
|
|
1390
1481
|
alphaTest: e.alphaTest !== void 0 ? e.alphaTest : 0,
|
|
1391
1482
|
// Typically 0 for blending
|
|
1392
1483
|
toneMapped: e.toneMapped !== void 0 ? e.toneMapped : !1
|
|
1393
1484
|
// prettier-ignore
|
|
1394
|
-
}), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending =
|
|
1485
|
+
}), e.alphaHash && (this.alphaHash = !0, this.depthWrite = !0, this.blending = c.NoBlending);
|
|
1395
1486
|
}
|
|
1396
1487
|
/**
|
|
1397
1488
|
* Update the viewport size
|
|
1398
1489
|
* @param width Viewport width
|
|
1399
1490
|
* @param height Viewport height
|
|
1400
1491
|
*/
|
|
1401
|
-
updateViewport(e,
|
|
1402
|
-
this.uniforms.viewport.value.set(e,
|
|
1492
|
+
updateViewport(e, r) {
|
|
1493
|
+
this.uniforms.viewport.value.set(e, r);
|
|
1403
1494
|
}
|
|
1404
1495
|
/**
|
|
1405
1496
|
* Set transform texture A (positions)
|
|
@@ -1437,38 +1528,59 @@ class Be extends i.ShaderMaterial {
|
|
|
1437
1528
|
this.uniforms.numSplats.value = e;
|
|
1438
1529
|
}
|
|
1439
1530
|
}
|
|
1440
|
-
const
|
|
1531
|
+
const X = class X extends c.Mesh {
|
|
1441
1532
|
// Match shader constant
|
|
1442
1533
|
/**
|
|
1443
1534
|
* Create a new SplatMesh for rendering Gaussian splats
|
|
1444
1535
|
* @param splatData The splat data to render
|
|
1445
1536
|
* @param options Rendering options
|
|
1446
1537
|
*/
|
|
1447
|
-
constructor(
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1538
|
+
constructor(r, o = {}) {
|
|
1539
|
+
const t = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0;
|
|
1540
|
+
t && console.debug(
|
|
1541
|
+
"[1/8] MESH SplatMesh: creating mesh with",
|
|
1542
|
+
r.numSplats,
|
|
1543
|
+
"splats"
|
|
1544
|
+
);
|
|
1545
|
+
const n = new Oe(o), a = X.createInstancedGeometry(r.numSplats, X.INSTANCE_SIZE);
|
|
1546
|
+
t && console.debug(
|
|
1547
|
+
"[2/8] MESH SplatMesh: created instanced geometry with",
|
|
1548
|
+
Math.ceil(r.numSplats / X.INSTANCE_SIZE),
|
|
1549
|
+
"instances"
|
|
1550
|
+
);
|
|
1551
|
+
super(a, n);
|
|
1552
|
+
w(this, "sorter");
|
|
1553
|
+
w(this, "splatData");
|
|
1554
|
+
w(this, "options");
|
|
1555
|
+
w(this, "textureManager");
|
|
1556
|
+
w(this, "material");
|
|
1557
|
+
w(this, "geometry");
|
|
1558
|
+
w(this, "lastCameraPositionLocal", new c.Vector3());
|
|
1559
|
+
w(this, "lastCameraDirectionLocal", new c.Vector3());
|
|
1560
|
+
w(this, "invModelMatrix", new c.Matrix4());
|
|
1561
|
+
this.geometry = a, this.material = n, this.splatData = r, this.frustumCulled = !1, this.options = { autoSort: !0, ...o }, t && console.debug("[3/8] MESH SplatMesh: initializing texture manager"), this.textureManager = new ke(r), this.sorter = new Ce(), t && console.debug("[4/8] MESH SplatMesh: creating chunks for sorter");
|
|
1562
|
+
let i = this.createChunks() || void 0;
|
|
1563
|
+
i === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), i = void 0, t && console.debug(
|
|
1564
|
+
"[5/8] MESH SplatMesh: initializing sorter with",
|
|
1565
|
+
i ? "chunks" : "no chunks"
|
|
1566
|
+
), this.sorter.init(
|
|
1462
1567
|
this.textureManager.orderTexture,
|
|
1463
1568
|
this.splatData.centers,
|
|
1464
|
-
|
|
1569
|
+
i ?? void 0
|
|
1465
1570
|
), this.sorter.addEventListener(
|
|
1466
1571
|
"updated",
|
|
1467
|
-
(
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1572
|
+
(l) => {
|
|
1573
|
+
const g = l.count;
|
|
1574
|
+
t && console.debug(
|
|
1575
|
+
"[6/8] MESH SplatMesh: sorter updated, rendering",
|
|
1576
|
+
g,
|
|
1577
|
+
"splats"
|
|
1578
|
+
), this.geometry.instanceCount = Math.ceil(g / X.INSTANCE_SIZE), this.material.setNumSplats(g);
|
|
1470
1579
|
}
|
|
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 =
|
|
1580
|
+
), t && console.debug("[7/8] MESH SplatMesh: setting up material textures"), 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 = r.boundingBox.toBox3(), this.geometry.boundingSphere = new c.Sphere(), this.geometry.boundingBox.getBoundingSphere(this.geometry.boundingSphere), t && console.debug(
|
|
1581
|
+
"[8/8] MESH SplatMesh: mesh initialization complete, bounding box:",
|
|
1582
|
+
r.boundingBox
|
|
1583
|
+
);
|
|
1472
1584
|
}
|
|
1473
1585
|
/**
|
|
1474
1586
|
* Creates the instanced geometry for rendering splats.
|
|
@@ -1476,8 +1588,16 @@ const K = class K extends i.Mesh {
|
|
|
1476
1588
|
* @param instanceSize Number of splats per instance.
|
|
1477
1589
|
* @returns InstancedBufferGeometry
|
|
1478
1590
|
*/
|
|
1479
|
-
static createInstancedGeometry(
|
|
1480
|
-
const
|
|
1591
|
+
static createInstancedGeometry(r, o) {
|
|
1592
|
+
const t = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0, n = Math.ceil(r / o);
|
|
1593
|
+
t && console.debug(
|
|
1594
|
+
"MESH createInstancedGeometry: creating geometry for",
|
|
1595
|
+
r,
|
|
1596
|
+
"splats,",
|
|
1597
|
+
n,
|
|
1598
|
+
"instances"
|
|
1599
|
+
);
|
|
1600
|
+
const a = new c.BufferGeometry(), i = new Float32Array([
|
|
1481
1601
|
// x, y, splat_index_in_instance
|
|
1482
1602
|
-1,
|
|
1483
1603
|
-1,
|
|
@@ -1491,57 +1611,79 @@ const K = class K extends i.Mesh {
|
|
|
1491
1611
|
-1,
|
|
1492
1612
|
1,
|
|
1493
1613
|
0
|
|
1494
|
-
]),
|
|
1495
|
-
for (let p = 0; p <
|
|
1496
|
-
const
|
|
1497
|
-
for (let
|
|
1498
|
-
|
|
1614
|
+
]), l = new Uint16Array([0, 1, 2, 0, 2, 3]), g = new Float32Array(4 * 3 * o);
|
|
1615
|
+
for (let p = 0; p < o; p++) {
|
|
1616
|
+
const E = p * 4 * 3;
|
|
1617
|
+
for (let d = 0; d < 4; d++)
|
|
1618
|
+
g[E + d * 3 + 0] = i[d * 3 + 0], g[E + d * 3 + 1] = i[d * 3 + 1], g[E + d * 3 + 2] = p;
|
|
1499
1619
|
}
|
|
1500
|
-
const
|
|
1501
|
-
for (let p = 0; p <
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1620
|
+
const y = new Uint32Array(6 * o);
|
|
1621
|
+
for (let p = 0; p < o; p++) {
|
|
1622
|
+
const E = p * 6, d = p * 4;
|
|
1623
|
+
y[E + 0] = l[0] + d, y[E + 1] = l[1] + d, y[E + 2] = l[2] + d, y[E + 3] = l[3] + d, y[E + 4] = l[4] + d, y[E + 5] = l[5] + d;
|
|
1504
1624
|
}
|
|
1505
|
-
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
const b = new Uint32Array(
|
|
1509
|
-
for (let p = 0; p <
|
|
1510
|
-
b[p] = p *
|
|
1511
|
-
return
|
|
1625
|
+
a.setAttribute("position", new c.BufferAttribute(g, 3)), a.setIndex(new c.BufferAttribute(y, 1));
|
|
1626
|
+
const v = new c.InstancedBufferGeometry();
|
|
1627
|
+
v.index = a.index, v.setAttribute("position", a.getAttribute("position"));
|
|
1628
|
+
const b = new Uint32Array(n);
|
|
1629
|
+
for (let p = 0; p < n; p++)
|
|
1630
|
+
b[p] = p * o;
|
|
1631
|
+
return v.setAttribute("splatInstanceIndex", new c.InstancedBufferAttribute(b, 1, !1)), v.instanceCount = 0, t && console.debug(
|
|
1632
|
+
"MESH createInstancedGeometry: geometry created with",
|
|
1633
|
+
v.attributes.position.count,
|
|
1634
|
+
"vertices"
|
|
1635
|
+
), v;
|
|
1512
1636
|
}
|
|
1513
1637
|
/**
|
|
1514
1638
|
* Create chunks data (bounding box min/max) for the sorter.
|
|
1515
1639
|
* @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
|
|
1516
1640
|
*/
|
|
1517
1641
|
createChunks() {
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1642
|
+
const r = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0, o = this.splatData.boundingBox;
|
|
1643
|
+
if (o.min.x === 1 / 0 || o.max.x === -1 / 0)
|
|
1644
|
+
return r && console.debug(
|
|
1645
|
+
"MESH createChunks: invalid bounding box, cannot create chunks"
|
|
1646
|
+
), null;
|
|
1647
|
+
const t = new Float32Array([
|
|
1648
|
+
o.min.x,
|
|
1649
|
+
o.min.y,
|
|
1650
|
+
o.min.z,
|
|
1651
|
+
o.max.x,
|
|
1652
|
+
o.max.y,
|
|
1653
|
+
o.max.z
|
|
1526
1654
|
]);
|
|
1655
|
+
return r && console.debug(
|
|
1656
|
+
"MESH createChunks: created chunks with bounding box",
|
|
1657
|
+
o
|
|
1658
|
+
), t;
|
|
1527
1659
|
}
|
|
1528
1660
|
/**
|
|
1529
1661
|
* Update the viewport size
|
|
1530
1662
|
* @param width Viewport width
|
|
1531
1663
|
* @param height Viewport height
|
|
1532
1664
|
*/
|
|
1533
|
-
updateViewport(
|
|
1534
|
-
|
|
1665
|
+
updateViewport(r, o) {
|
|
1666
|
+
(typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0 && console.debug(
|
|
1667
|
+
"MESH updateViewport: updating viewport to",
|
|
1668
|
+
r,
|
|
1669
|
+
"x",
|
|
1670
|
+
o
|
|
1671
|
+
), this.material.updateViewport(r, o);
|
|
1535
1672
|
}
|
|
1536
1673
|
/**
|
|
1537
1674
|
* Sorts splats based on camera position and direction.
|
|
1538
1675
|
* @param camera The camera to sort against.
|
|
1539
1676
|
*/
|
|
1540
|
-
sort(
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
this.options.autoSort && (
|
|
1677
|
+
sort(r) {
|
|
1678
|
+
const o = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0, t = new c.Vector3(), n = new c.Vector3();
|
|
1679
|
+
r.getWorldPosition(t), r.getWorldDirection(n), this.invModelMatrix.copy(this.matrixWorld).invert();
|
|
1680
|
+
const a = t.applyMatrix4(this.invModelMatrix), i = n.transformDirection(this.invModelMatrix), l = this.lastCameraPositionLocal.distanceToSquared(a) > 1e-6, g = this.lastCameraDirectionLocal.dot(i) < 0.999;
|
|
1681
|
+
this.options.autoSort && (l || g) && (o && console.debug(
|
|
1682
|
+
"MESH sort: camera changed, triggering sort. Position changed:",
|
|
1683
|
+
l,
|
|
1684
|
+
"Direction changed:",
|
|
1685
|
+
g
|
|
1686
|
+
), this.lastCameraPositionLocal.copy(a), this.lastCameraDirectionLocal.copy(i), this.sorter.setCamera(a, i));
|
|
1545
1687
|
}
|
|
1546
1688
|
/**
|
|
1547
1689
|
* THREE.js hook called before rendering the object.
|
|
@@ -1552,31 +1694,32 @@ const K = class K extends i.Mesh {
|
|
|
1552
1694
|
*/
|
|
1553
1695
|
// prettier-ignore
|
|
1554
1696
|
// @ts-expect-error scene is not used
|
|
1555
|
-
onBeforeRender(
|
|
1556
|
-
this.sort(
|
|
1557
|
-
const
|
|
1558
|
-
let { width: a, height:
|
|
1559
|
-
const l =
|
|
1697
|
+
onBeforeRender(r, o, t) {
|
|
1698
|
+
this.sort(t);
|
|
1699
|
+
const n = r.getSize(new c.Vector2());
|
|
1700
|
+
let { width: a, height: i } = n;
|
|
1701
|
+
const l = r.xr;
|
|
1560
1702
|
if (l.enabled && l.isPresenting) {
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1703
|
+
const g = l.getCamera().cameras[0].view;
|
|
1704
|
+
g && (a = g.width, i = g.height);
|
|
1563
1705
|
}
|
|
1564
|
-
this.updateViewport(a,
|
|
1706
|
+
this.updateViewport(a, i);
|
|
1565
1707
|
}
|
|
1566
1708
|
/**
|
|
1567
1709
|
* Dispose of resources
|
|
1568
1710
|
*/
|
|
1569
1711
|
dispose() {
|
|
1570
|
-
|
|
1712
|
+
const r = (typeof window < "u" && window.__VISUS_SPLAT_DEBUG__) === !0;
|
|
1713
|
+
r && console.debug("MESH dispose: cleaning up mesh resources"), this.sorter.dispose(), this.geometry.dispose(), this.material.dispose(), this.textureManager.dispose(), r && console.debug("MESH dispose: mesh resources cleaned up");
|
|
1571
1714
|
}
|
|
1572
1715
|
};
|
|
1573
1716
|
// Cached inverse matrix
|
|
1574
1717
|
/** Number of splats combined into a single instanced draw call. */
|
|
1575
|
-
|
|
1576
|
-
let ae =
|
|
1577
|
-
const
|
|
1718
|
+
w(X, "INSTANCE_SIZE", 128);
|
|
1719
|
+
let ae = X;
|
|
1720
|
+
const Be = Symbol.for("@speridlabs/visus/SplatMesh");
|
|
1578
1721
|
try {
|
|
1579
|
-
Object.defineProperty(ae.prototype,
|
|
1722
|
+
Object.defineProperty(ae.prototype, Be, {
|
|
1580
1723
|
value: !0,
|
|
1581
1724
|
configurable: !1,
|
|
1582
1725
|
enumerable: !1,
|
|
@@ -1585,21 +1728,23 @@ try {
|
|
|
1585
1728
|
} catch {
|
|
1586
1729
|
console.warn("Couldn't define Visus SplatMesh symbol");
|
|
1587
1730
|
}
|
|
1588
|
-
const
|
|
1731
|
+
const Ve = ({
|
|
1589
1732
|
plyUrl: M,
|
|
1590
|
-
|
|
1591
|
-
|
|
1733
|
+
debug: e = !1,
|
|
1734
|
+
splatOptions: r = {},
|
|
1735
|
+
...o
|
|
1592
1736
|
}) => {
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1737
|
+
typeof window < "u" && e && (window.__VISUS_SPLAT_DEBUG__ = !0), e && console.debug("SPLAT: rendering", { plyUrl: M, splatOptions: r, meshProps: o });
|
|
1738
|
+
const t = ye(null), n = be(Te, M), a = ve(
|
|
1739
|
+
() => new ae(n, r || {}),
|
|
1740
|
+
[n, r]
|
|
1596
1741
|
);
|
|
1597
1742
|
return we(() => () => {
|
|
1598
|
-
typeof (
|
|
1599
|
-
}, [
|
|
1743
|
+
e && console.debug("SPLAT: disposing mesh for", M), typeof (a == null ? void 0 : a.dispose) == "function" && a.dispose();
|
|
1744
|
+
}, [a]), /* @__PURE__ */ Ae.jsx("primitive", { ref: t, object: a, ...o });
|
|
1600
1745
|
};
|
|
1601
1746
|
export {
|
|
1602
|
-
|
|
1603
|
-
|
|
1747
|
+
Te as PlyLoader,
|
|
1748
|
+
Ve as Splat,
|
|
1604
1749
|
ae as SplatMesh
|
|
1605
1750
|
};
|