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