@speridlabs/visus 0.2.0 → 1.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/README.md +85 -117
- package/dist/main.d.ts +1 -1
- package/dist/main.es.js +385 -394
- package/dist/main.umd.js +42 -51
- package/dist/react.es.js +464 -473
- package/package.json +1 -1
package/dist/react.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var v = (
|
|
4
|
-
import
|
|
5
|
-
import { extend as
|
|
1
|
+
var xe = Object.defineProperty;
|
|
2
|
+
var ye = (C, e, s) => e in C ? xe(C, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : C[e] = s;
|
|
3
|
+
var v = (C, e, s) => ye(C, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
import ge, { useRef as ve, useMemo as we, useEffect as be } from "react";
|
|
5
|
+
import { extend as Se, useLoader as Te } from "@react-three/fiber";
|
|
6
6
|
import * as i from "three";
|
|
7
7
|
var se = { exports: {} }, te = {};
|
|
8
8
|
/**
|
|
@@ -15,23 +15,23 @@ var se = { exports: {} }, te = {};
|
|
|
15
15
|
* LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/
|
|
17
17
|
var ue;
|
|
18
|
-
function
|
|
18
|
+
function Me() {
|
|
19
19
|
if (ue) return te;
|
|
20
20
|
ue = 1;
|
|
21
|
-
var
|
|
22
|
-
function s(
|
|
21
|
+
var C = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
22
|
+
function s(n, t, r) {
|
|
23
23
|
var a = null;
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
for (var c in
|
|
27
|
-
c !== "key" && (
|
|
28
|
-
} else
|
|
29
|
-
return
|
|
30
|
-
$$typeof:
|
|
31
|
-
type:
|
|
24
|
+
if (r !== void 0 && (a = "" + r), t.key !== void 0 && (a = "" + t.key), "key" in t) {
|
|
25
|
+
r = {};
|
|
26
|
+
for (var c in t)
|
|
27
|
+
c !== "key" && (r[c] = t[c]);
|
|
28
|
+
} else r = t;
|
|
29
|
+
return t = r.ref, {
|
|
30
|
+
$$typeof: C,
|
|
31
|
+
type: n,
|
|
32
32
|
key: a,
|
|
33
|
-
ref:
|
|
34
|
-
props:
|
|
33
|
+
ref: t !== void 0 ? t : null,
|
|
34
|
+
props: r
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return te.Fragment = e, te.jsx = s, te.jsxs = s, te;
|
|
@@ -47,15 +47,15 @@ var re = {};
|
|
|
47
47
|
* LICENSE file in the root directory of this source tree.
|
|
48
48
|
*/
|
|
49
49
|
var he;
|
|
50
|
-
function
|
|
50
|
+
function Ce() {
|
|
51
51
|
return he || (he = 1, process.env.NODE_ENV !== "production" && function() {
|
|
52
|
-
function
|
|
53
|
-
if (
|
|
54
|
-
if (typeof
|
|
55
|
-
return
|
|
56
|
-
if (typeof
|
|
57
|
-
switch (
|
|
58
|
-
case
|
|
52
|
+
function C(o) {
|
|
53
|
+
if (o == null) return null;
|
|
54
|
+
if (typeof o == "function")
|
|
55
|
+
return o.$$typeof === w ? null : o.displayName || o.name || null;
|
|
56
|
+
if (typeof o == "string") return o;
|
|
57
|
+
switch (o) {
|
|
58
|
+
case T:
|
|
59
59
|
return "Fragment";
|
|
60
60
|
case j:
|
|
61
61
|
return "Profiler";
|
|
@@ -65,225 +65,225 @@ function Te() {
|
|
|
65
65
|
return "Suspense";
|
|
66
66
|
case D:
|
|
67
67
|
return "SuspenseList";
|
|
68
|
-
case
|
|
68
|
+
case E:
|
|
69
69
|
return "Activity";
|
|
70
70
|
}
|
|
71
|
-
if (typeof
|
|
72
|
-
switch (typeof
|
|
71
|
+
if (typeof o == "object")
|
|
72
|
+
switch (typeof o.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
|
+
), o.$$typeof) {
|
|
75
|
+
case f:
|
|
76
76
|
return "Portal";
|
|
77
77
|
case q:
|
|
78
|
-
return (
|
|
78
|
+
return (o.displayName || "Context") + ".Provider";
|
|
79
79
|
case W:
|
|
80
|
-
return (
|
|
80
|
+
return (o._context.displayName || "Context") + ".Consumer";
|
|
81
81
|
case H:
|
|
82
|
-
var
|
|
83
|
-
return
|
|
82
|
+
var d = o.render;
|
|
83
|
+
return o = o.displayName, o || (o = d.displayName || d.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
|
|
84
84
|
case k:
|
|
85
|
-
return
|
|
86
|
-
case
|
|
87
|
-
|
|
85
|
+
return d = o.displayName || null, d !== null ? d : C(o.type) || "Memo";
|
|
86
|
+
case B:
|
|
87
|
+
d = o._payload, o = o._init;
|
|
88
88
|
try {
|
|
89
|
-
return
|
|
89
|
+
return C(o(d));
|
|
90
90
|
} catch {
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
|
-
function e(
|
|
96
|
-
return "" +
|
|
95
|
+
function e(o) {
|
|
96
|
+
return "" + o;
|
|
97
97
|
}
|
|
98
|
-
function s(
|
|
98
|
+
function s(o) {
|
|
99
99
|
try {
|
|
100
|
-
e(
|
|
101
|
-
var
|
|
100
|
+
e(o);
|
|
101
|
+
var d = !1;
|
|
102
102
|
} catch {
|
|
103
|
-
|
|
103
|
+
d = !0;
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
return
|
|
109
|
-
|
|
105
|
+
if (d) {
|
|
106
|
+
d = console;
|
|
107
|
+
var A = d.error, z = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
|
|
108
|
+
return A.call(
|
|
109
|
+
d,
|
|
110
110
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
111
|
-
|
|
112
|
-
), e(
|
|
111
|
+
z
|
|
112
|
+
), e(o);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function o
|
|
116
|
-
if (
|
|
117
|
-
if (typeof
|
|
115
|
+
function n(o) {
|
|
116
|
+
if (o === T) return "<>";
|
|
117
|
+
if (typeof o == "object" && o !== null && o.$$typeof === B)
|
|
118
118
|
return "<...>";
|
|
119
119
|
try {
|
|
120
|
-
var
|
|
121
|
-
return
|
|
120
|
+
var d = C(o);
|
|
121
|
+
return d ? "<" + d + ">" : "<...>";
|
|
122
122
|
} catch {
|
|
123
123
|
return "<...>";
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function n() {
|
|
127
|
-
var r = P.A;
|
|
128
|
-
return r === null ? null : r.getOwner();
|
|
129
|
-
}
|
|
130
126
|
function t() {
|
|
127
|
+
var o = M.A;
|
|
128
|
+
return o === null ? null : o.getOwner();
|
|
129
|
+
}
|
|
130
|
+
function r() {
|
|
131
131
|
return Error("react-stack-top-frame");
|
|
132
132
|
}
|
|
133
|
-
function a(
|
|
134
|
-
if (
|
|
135
|
-
var
|
|
136
|
-
if (
|
|
133
|
+
function a(o) {
|
|
134
|
+
if (U.call(o, "key")) {
|
|
135
|
+
var d = Object.getOwnPropertyDescriptor(o, "key").get;
|
|
136
|
+
if (d && d.isReactWarning) return !1;
|
|
137
137
|
}
|
|
138
|
-
return
|
|
138
|
+
return o.key !== void 0;
|
|
139
139
|
}
|
|
140
|
-
function c(
|
|
141
|
-
function
|
|
140
|
+
function c(o, d) {
|
|
141
|
+
function A() {
|
|
142
142
|
y || (y = !0, console.error(
|
|
143
143
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
144
|
-
|
|
144
|
+
d
|
|
145
145
|
));
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
get:
|
|
147
|
+
A.isReactWarning = !0, Object.defineProperty(o, "key", {
|
|
148
|
+
get: A,
|
|
149
149
|
configurable: !0
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
function l() {
|
|
153
|
-
var
|
|
154
|
-
return
|
|
153
|
+
var o = C(this.type);
|
|
154
|
+
return _[o] || (_[o] = !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
|
+
)), o = this.props.ref, o !== void 0 ? o : null;
|
|
157
157
|
}
|
|
158
|
-
function m(
|
|
159
|
-
return
|
|
158
|
+
function m(o, d, A, z, N, h, P, F) {
|
|
159
|
+
return A = h.ref, o = {
|
|
160
160
|
$$typeof: x,
|
|
161
|
-
type:
|
|
162
|
-
key:
|
|
161
|
+
type: o,
|
|
162
|
+
key: d,
|
|
163
163
|
props: h,
|
|
164
164
|
_owner: N
|
|
165
|
-
}, (
|
|
165
|
+
}, (A !== void 0 ? A : null) !== null ? Object.defineProperty(o, "ref", {
|
|
166
166
|
enumerable: !1,
|
|
167
167
|
get: l
|
|
168
|
-
}) : Object.defineProperty(
|
|
168
|
+
}) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
|
|
169
169
|
configurable: !1,
|
|
170
170
|
enumerable: !1,
|
|
171
171
|
writable: !0,
|
|
172
172
|
value: 0
|
|
173
|
-
}), Object.defineProperty(
|
|
173
|
+
}), Object.defineProperty(o, "_debugInfo", {
|
|
174
174
|
configurable: !1,
|
|
175
175
|
enumerable: !1,
|
|
176
176
|
writable: !0,
|
|
177
177
|
value: null
|
|
178
|
-
}), Object.defineProperty(
|
|
178
|
+
}), Object.defineProperty(o, "_debugStack", {
|
|
179
179
|
configurable: !1,
|
|
180
180
|
enumerable: !1,
|
|
181
181
|
writable: !0,
|
|
182
|
-
value:
|
|
183
|
-
}), Object.defineProperty(
|
|
182
|
+
value: P
|
|
183
|
+
}), Object.defineProperty(o, "_debugTask", {
|
|
184
184
|
configurable: !1,
|
|
185
185
|
enumerable: !1,
|
|
186
186
|
writable: !0,
|
|
187
|
-
value:
|
|
188
|
-
}), Object.freeze && (Object.freeze(
|
|
187
|
+
value: F
|
|
188
|
+
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
var u =
|
|
190
|
+
function S(o, d, A, z, N, h, P, F) {
|
|
191
|
+
var u = d.children;
|
|
192
192
|
if (u !== void 0)
|
|
193
|
-
if (
|
|
194
|
-
if (
|
|
195
|
-
for (
|
|
196
|
-
b(u[
|
|
193
|
+
if (z)
|
|
194
|
+
if (V(u)) {
|
|
195
|
+
for (z = 0; z < u.length; z++)
|
|
196
|
+
b(u[z]);
|
|
197
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
202
|
else b(u);
|
|
203
|
-
if (
|
|
204
|
-
u =
|
|
205
|
-
var
|
|
203
|
+
if (U.call(d, "key")) {
|
|
204
|
+
u = C(o);
|
|
205
|
+
var I = Object.keys(d).filter(function(G) {
|
|
206
206
|
return G !== "key";
|
|
207
207
|
});
|
|
208
|
-
|
|
208
|
+
z = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", Z[u + z] || (I = 0 < I.length ? "{" + I.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
|
-
|
|
215
|
+
z,
|
|
216
216
|
u,
|
|
217
|
-
|
|
217
|
+
I,
|
|
218
218
|
u
|
|
219
|
-
),
|
|
219
|
+
), Z[u + z] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (u = null,
|
|
222
|
-
|
|
223
|
-
for (var Y in
|
|
224
|
-
Y !== "key" && (
|
|
225
|
-
} else
|
|
221
|
+
if (u = null, A !== void 0 && (s(A), u = "" + A), a(d) && (s(d.key), u = "" + d.key), "key" in d) {
|
|
222
|
+
A = {};
|
|
223
|
+
for (var Y in d)
|
|
224
|
+
Y !== "key" && (A[Y] = d[Y]);
|
|
225
|
+
} else A = d;
|
|
226
226
|
return u && c(
|
|
227
|
-
|
|
228
|
-
typeof
|
|
227
|
+
A,
|
|
228
|
+
typeof o == "function" ? o.displayName || o.name || "Unknown" : o
|
|
229
229
|
), m(
|
|
230
|
-
|
|
230
|
+
o,
|
|
231
231
|
u,
|
|
232
232
|
h,
|
|
233
233
|
N,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
t(),
|
|
235
|
+
A,
|
|
236
|
+
P,
|
|
237
|
+
F
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
-
function b(
|
|
241
|
-
typeof
|
|
240
|
+
function b(o) {
|
|
241
|
+
typeof o == "object" && o !== null && o.$$typeof === x && o._store && (o._store.validated = 1);
|
|
242
242
|
}
|
|
243
|
-
var p =
|
|
243
|
+
var p = ge, x = Symbol.for("react.transitional.element"), f = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), q = Symbol.for("react.context"), H = Symbol.for("react.forward_ref"), $ = Symbol.for("react.suspense"), D = Symbol.for("react.suspense_list"), k = Symbol.for("react.memo"), B = Symbol.for("react.lazy"), E = Symbol.for("react.activity"), w = Symbol.for("react.client.reference"), M = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, V = Array.isArray, g = console.createTask ? console.createTask : function() {
|
|
244
244
|
return null;
|
|
245
245
|
};
|
|
246
246
|
p = {
|
|
247
|
-
"react-stack-bottom-frame": function(
|
|
248
|
-
return
|
|
247
|
+
"react-stack-bottom-frame": function(o) {
|
|
248
|
+
return o();
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
var y,
|
|
251
|
+
var y, _ = {}, R = p["react-stack-bottom-frame"].bind(
|
|
252
252
|
p,
|
|
253
|
-
|
|
254
|
-
)(), L = g(
|
|
255
|
-
re.Fragment =
|
|
256
|
-
var h = 1e4 >
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
253
|
+
r
|
|
254
|
+
)(), L = g(n(r)), Z = {};
|
|
255
|
+
re.Fragment = T, re.jsx = function(o, d, A, z, N) {
|
|
256
|
+
var h = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
257
|
+
return S(
|
|
258
|
+
o,
|
|
259
|
+
d,
|
|
260
|
+
A,
|
|
261
261
|
!1,
|
|
262
|
-
|
|
262
|
+
z,
|
|
263
263
|
N,
|
|
264
|
-
h ? Error("react-stack-top-frame") :
|
|
265
|
-
h ? g(o
|
|
264
|
+
h ? Error("react-stack-top-frame") : R,
|
|
265
|
+
h ? g(n(o)) : L
|
|
266
266
|
);
|
|
267
|
-
}, re.jsxs = function(
|
|
268
|
-
var h = 1e4 >
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
}, re.jsxs = function(o, d, A, z, N) {
|
|
268
|
+
var h = 1e4 > M.recentlyCreatedOwnerStacks++;
|
|
269
|
+
return S(
|
|
270
|
+
o,
|
|
271
|
+
d,
|
|
272
|
+
A,
|
|
273
273
|
!0,
|
|
274
|
-
|
|
274
|
+
z,
|
|
275
275
|
N,
|
|
276
|
-
h ? Error("react-stack-top-frame") :
|
|
277
|
-
h ? g(o
|
|
276
|
+
h ? Error("react-stack-top-frame") : R,
|
|
277
|
+
h ? g(n(o)) : L
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
280
|
}()), re;
|
|
281
281
|
}
|
|
282
|
-
var
|
|
283
|
-
function
|
|
284
|
-
return
|
|
282
|
+
var fe;
|
|
283
|
+
function Ae() {
|
|
284
|
+
return fe || (fe = 1, process.env.NODE_ENV === "production" ? se.exports = Me() : se.exports = Ce()), se.exports;
|
|
285
285
|
}
|
|
286
|
-
var
|
|
286
|
+
var Ee = Ae();
|
|
287
287
|
class le {
|
|
288
288
|
constructor() {
|
|
289
289
|
v(this, "min", new i.Vector3(1 / 0, 1 / 0, 1 / 0));
|
|
@@ -342,7 +342,7 @@ 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 _e {
|
|
346
346
|
// TODO: there is no sh spherical harmonics
|
|
347
347
|
constructor(e = 0) {
|
|
348
348
|
v(this, "numSplats", 0);
|
|
@@ -367,13 +367,13 @@ class ze {
|
|
|
367
367
|
* @param color Color
|
|
368
368
|
* @param opacity Opacity value
|
|
369
369
|
*/
|
|
370
|
-
setSplat(e, s,
|
|
370
|
+
setSplat(e, s, n, t, r, a) {
|
|
371
371
|
if (e >= this.numSplats)
|
|
372
372
|
throw new Error(
|
|
373
373
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
374
374
|
);
|
|
375
|
-
const c = e * 3, l = e * 4, m = e * 3,
|
|
376
|
-
this.positions[c] = s.x, this.positions[c + 1] = s.y, this.positions[c + 2] = s.z, this.rotations[l] =
|
|
375
|
+
const c = e * 3, l = e * 4, m = e * 3, S = e * 3;
|
|
376
|
+
this.positions[c] = s.x, this.positions[c + 1] = s.y, this.positions[c + 2] = s.z, this.rotations[l] = n.x, this.rotations[l + 1] = n.y, this.rotations[l + 2] = n.z, this.rotations[l + 3] = n.w, this.scales[m] = t.x, this.scales[m + 1] = t.y, this.scales[m + 2] = t.z, this.colors[S] = r.r, this.colors[S + 1] = r.g, this.colors[S + 2] = r.b, this.opacities[e] = a, this.centers[c] = s.x, this.centers[c + 1] = s.y, this.centers[c + 2] = s.z;
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* Get a splat's data
|
|
@@ -385,7 +385,7 @@ class ze {
|
|
|
385
385
|
throw new Error(
|
|
386
386
|
`Splat index out of bounds: ${e} >= ${this.numSplats}`
|
|
387
387
|
);
|
|
388
|
-
const s = e * 3,
|
|
388
|
+
const s = e * 3, n = e * 4, t = e * 3, r = e * 3;
|
|
389
389
|
return {
|
|
390
390
|
position: new i.Vector3(
|
|
391
391
|
this.positions[s],
|
|
@@ -393,21 +393,21 @@ class ze {
|
|
|
393
393
|
this.positions[s + 2]
|
|
394
394
|
),
|
|
395
395
|
rotation: new i.Quaternion(
|
|
396
|
-
this.rotations[
|
|
397
|
-
this.rotations[
|
|
398
|
-
this.rotations[
|
|
399
|
-
this.rotations[
|
|
396
|
+
this.rotations[n],
|
|
397
|
+
this.rotations[n + 1],
|
|
398
|
+
this.rotations[n + 2],
|
|
399
|
+
this.rotations[n + 3]
|
|
400
400
|
),
|
|
401
401
|
// Convert log scale back to linear scale for external use
|
|
402
402
|
scale: new i.Vector3(
|
|
403
|
-
Math.exp(this.scales[
|
|
404
|
-
Math.exp(this.scales[
|
|
405
|
-
Math.exp(this.scales[
|
|
403
|
+
Math.exp(this.scales[t]),
|
|
404
|
+
Math.exp(this.scales[t + 1]),
|
|
405
|
+
Math.exp(this.scales[t + 2])
|
|
406
406
|
),
|
|
407
407
|
color: new i.Color(
|
|
408
|
-
this.colors[
|
|
409
|
-
this.colors[
|
|
410
|
-
this.colors[
|
|
408
|
+
this.colors[r],
|
|
409
|
+
this.colors[r + 1],
|
|
410
|
+
this.colors[r + 2]
|
|
411
411
|
),
|
|
412
412
|
opacity: this.opacities[e]
|
|
413
413
|
};
|
|
@@ -420,11 +420,11 @@ class ze {
|
|
|
420
420
|
this.boundingBox.reset();
|
|
421
421
|
const e = new i.Vector3();
|
|
422
422
|
for (let s = 0; s < this.numSplats; s++) {
|
|
423
|
-
const
|
|
423
|
+
const n = s * 3;
|
|
424
424
|
e.set(
|
|
425
|
-
this.positions[
|
|
426
|
-
this.positions[
|
|
427
|
-
this.positions[
|
|
425
|
+
this.positions[n],
|
|
426
|
+
this.positions[n + 1],
|
|
427
|
+
this.positions[n + 2]
|
|
428
428
|
), this.boundingBox.expandByPoint(e);
|
|
429
429
|
}
|
|
430
430
|
return this.boundingBox;
|
|
@@ -439,15 +439,15 @@ class ze {
|
|
|
439
439
|
"position",
|
|
440
440
|
new i.BufferAttribute(this.positions, 3)
|
|
441
441
|
);
|
|
442
|
-
const s = new Float32Array(this.numSplats * 3),
|
|
443
|
-
for (let
|
|
444
|
-
const a =
|
|
445
|
-
|
|
442
|
+
const s = new Float32Array(this.numSplats * 3), n = new i.Quaternion(), t = new i.Euler();
|
|
443
|
+
for (let r = 0; r < this.numSplats; r++) {
|
|
444
|
+
const a = r * 4, c = r * 3;
|
|
445
|
+
n.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(n), s[c] = t.x, s[c + 1] = t.y, s[c + 2] = t.z;
|
|
451
451
|
}
|
|
452
452
|
return e.setAttribute(
|
|
453
453
|
"rotation",
|
|
@@ -472,9 +472,9 @@ class ke extends i.Loader {
|
|
|
472
472
|
* @param onProgress Optional progress callback
|
|
473
473
|
* @param onError Optional error callback
|
|
474
474
|
*/
|
|
475
|
-
load(e, s,
|
|
476
|
-
const
|
|
477
|
-
|
|
475
|
+
load(e, s, n, t) {
|
|
476
|
+
const r = new i.FileLoader(this.manager);
|
|
477
|
+
r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
|
|
478
478
|
e,
|
|
479
479
|
(a) => {
|
|
480
480
|
try {
|
|
@@ -483,11 +483,11 @@ class ke extends i.Loader {
|
|
|
483
483
|
s(c);
|
|
484
484
|
}
|
|
485
485
|
} catch (c) {
|
|
486
|
-
|
|
486
|
+
t ? t(c) : console.error(c), this.manager.itemError(e);
|
|
487
487
|
}
|
|
488
488
|
},
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
n,
|
|
490
|
+
t
|
|
491
491
|
);
|
|
492
492
|
}
|
|
493
493
|
/**
|
|
@@ -497,21 +497,21 @@ class ke extends i.Loader {
|
|
|
497
497
|
* @returns A Promise that resolves with the parsed SplatData
|
|
498
498
|
*/
|
|
499
499
|
loadAsync(e, s) {
|
|
500
|
-
return new Promise((
|
|
501
|
-
const
|
|
502
|
-
|
|
500
|
+
return new Promise((n, t) => {
|
|
501
|
+
const r = new i.FileLoader(this.manager);
|
|
502
|
+
r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setPath(this.path), r.setWithCredentials(this.withCredentials), r.load(
|
|
503
503
|
e,
|
|
504
504
|
(a) => {
|
|
505
505
|
try {
|
|
506
506
|
const c = this.parse(a);
|
|
507
|
-
|
|
507
|
+
n(c);
|
|
508
508
|
} catch (c) {
|
|
509
|
-
|
|
509
|
+
t(c), this.manager.itemError(e);
|
|
510
510
|
}
|
|
511
511
|
},
|
|
512
512
|
s,
|
|
513
513
|
(a) => {
|
|
514
|
-
|
|
514
|
+
t(a), this.manager.itemError(e);
|
|
515
515
|
}
|
|
516
516
|
);
|
|
517
517
|
});
|
|
@@ -522,44 +522,44 @@ class ke extends i.Loader {
|
|
|
522
522
|
* @returns Parsed SplatData
|
|
523
523
|
*/
|
|
524
524
|
parse(e) {
|
|
525
|
-
const s = new TextDecoder(),
|
|
525
|
+
const s = new TextDecoder(), n = new Uint8Array(e), t = [112, 108, 121, 10], r = `
|
|
526
526
|
end_header
|
|
527
527
|
`;
|
|
528
|
-
for (let g = 0; g <
|
|
529
|
-
if (
|
|
528
|
+
for (let g = 0; g < t.length; g++)
|
|
529
|
+
if (n[g] !== t[g])
|
|
530
530
|
throw new Error("Invalid PLY file: Missing magic bytes");
|
|
531
531
|
let a = 0;
|
|
532
|
-
for (let g = 0; g <
|
|
532
|
+
for (let g = 0; g < n.length - r.length; g++) {
|
|
533
533
|
let y = !0;
|
|
534
|
-
for (let
|
|
535
|
-
if (
|
|
534
|
+
for (let _ = 0; _ < r.length; _++)
|
|
535
|
+
if (n[g + _] !== r.charCodeAt(_)) {
|
|
536
536
|
y = !1;
|
|
537
537
|
break;
|
|
538
538
|
}
|
|
539
539
|
if (y) {
|
|
540
|
-
a = g +
|
|
540
|
+
a = g + r.length;
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
if (a === 0)
|
|
545
545
|
throw new Error("Invalid PLY file: Could not find end of header");
|
|
546
546
|
const l = s.decode(
|
|
547
|
-
|
|
547
|
+
n.slice(0, a)
|
|
548
548
|
).split(`
|
|
549
549
|
`), m = [];
|
|
550
|
-
let
|
|
550
|
+
let S = null;
|
|
551
551
|
for (let g = 1; g < l.length; g++) {
|
|
552
552
|
const y = l[g].trim();
|
|
553
553
|
if (y === "" || y === "end_header") continue;
|
|
554
|
-
const
|
|
555
|
-
switch (
|
|
554
|
+
const _ = y.split(" ");
|
|
555
|
+
switch (_[0]) {
|
|
556
556
|
case "format":
|
|
557
|
-
|
|
557
|
+
S = _[1];
|
|
558
558
|
break;
|
|
559
559
|
case "element":
|
|
560
560
|
m.push({
|
|
561
|
-
name:
|
|
562
|
-
count: parseInt(
|
|
561
|
+
name: _[1],
|
|
562
|
+
count: parseInt(_[2], 10),
|
|
563
563
|
properties: []
|
|
564
564
|
});
|
|
565
565
|
break;
|
|
@@ -569,34 +569,34 @@ end_header
|
|
|
569
569
|
"Invalid PLY file: Property without element"
|
|
570
570
|
);
|
|
571
571
|
m[m.length - 1].properties.push({
|
|
572
|
-
type:
|
|
573
|
-
name:
|
|
572
|
+
type: _[1],
|
|
573
|
+
name: _[2],
|
|
574
574
|
storage: null
|
|
575
575
|
});
|
|
576
576
|
break;
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
if (
|
|
580
|
-
throw new Error(`Unsupported PLY format: ${
|
|
579
|
+
if (S !== "binary_little_endian")
|
|
580
|
+
throw new Error(`Unsupported PLY format: ${S}`);
|
|
581
581
|
const b = m.find((g) => g.name === "vertex");
|
|
582
582
|
if (!b)
|
|
583
583
|
throw new Error("Invalid PLY file: No vertex element found");
|
|
584
|
-
const p = new
|
|
585
|
-
let
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
584
|
+
const p = new _e(b.count), x = new DataView(e);
|
|
585
|
+
let f = a;
|
|
586
|
+
const T = (g) => b.properties.findIndex((y) => y.name === g), O = T("x"), j = T("y"), W = T("z"), q = [
|
|
587
|
+
T("rot_0"),
|
|
588
|
+
T("rot_1"),
|
|
589
|
+
T("rot_2"),
|
|
590
|
+
T("rot_3")
|
|
591
591
|
], H = [
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
592
|
+
T("scale_0"),
|
|
593
|
+
T("scale_1"),
|
|
594
|
+
T("scale_2")
|
|
595
595
|
], $ = [
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
], D =
|
|
596
|
+
T("f_dc_0"),
|
|
597
|
+
T("f_dc_1"),
|
|
598
|
+
T("f_dc_2")
|
|
599
|
+
], D = T("opacity");
|
|
600
600
|
if ([
|
|
601
601
|
O,
|
|
602
602
|
j,
|
|
@@ -607,82 +607,81 @@ end_header
|
|
|
607
607
|
D
|
|
608
608
|
].some((g) => g === -1))
|
|
609
609
|
throw new Error("Invalid PLY file: Missing required properties");
|
|
610
|
-
const
|
|
610
|
+
const B = 0.28209479177387814, E = (g) => {
|
|
611
611
|
if (g > 0) return 1 / (1 + Math.exp(-g));
|
|
612
612
|
const y = Math.exp(g);
|
|
613
613
|
return y / (1 + y);
|
|
614
|
-
}, w = new i.Vector3(),
|
|
614
|
+
}, w = new i.Vector3(), M = new i.Quaternion(), U = new i.Vector3(), V = new i.Color();
|
|
615
615
|
for (let g = 0; g < b.count; g++) {
|
|
616
616
|
const y = [];
|
|
617
|
-
for (let
|
|
618
|
-
const
|
|
619
|
-
let
|
|
620
|
-
switch (
|
|
617
|
+
for (let R = 0; R < b.properties.length; R++) {
|
|
618
|
+
const Z = b.properties[R].type;
|
|
619
|
+
let o;
|
|
620
|
+
switch (Z) {
|
|
621
621
|
case "char":
|
|
622
|
-
|
|
622
|
+
o = x.getInt8(f), f += 1;
|
|
623
623
|
break;
|
|
624
624
|
case "uchar":
|
|
625
|
-
|
|
625
|
+
o = x.getUint8(f), f += 1;
|
|
626
626
|
break;
|
|
627
627
|
case "short":
|
|
628
|
-
|
|
628
|
+
o = x.getInt16(f, !0), f += 2;
|
|
629
629
|
break;
|
|
630
630
|
case "ushort":
|
|
631
|
-
|
|
631
|
+
o = x.getUint16(f, !0), f += 2;
|
|
632
632
|
break;
|
|
633
633
|
case "int":
|
|
634
|
-
|
|
634
|
+
o = x.getInt32(f, !0), f += 4;
|
|
635
635
|
break;
|
|
636
636
|
case "uint":
|
|
637
|
-
|
|
637
|
+
o = x.getUint32(f, !0), f += 4;
|
|
638
638
|
break;
|
|
639
639
|
case "float":
|
|
640
|
-
|
|
640
|
+
o = x.getFloat32(f, !0), f += 4;
|
|
641
641
|
break;
|
|
642
642
|
case "double":
|
|
643
|
-
|
|
643
|
+
o = x.getFloat64(f, !0), f += 8;
|
|
644
644
|
break;
|
|
645
645
|
default:
|
|
646
|
-
throw new Error(`Unsupported property type: ${
|
|
646
|
+
throw new Error(`Unsupported property type: ${Z}`);
|
|
647
647
|
}
|
|
648
|
-
y.push(
|
|
648
|
+
y.push(o);
|
|
649
649
|
}
|
|
650
650
|
w.set(
|
|
651
651
|
y[O],
|
|
652
652
|
y[j],
|
|
653
653
|
y[W]
|
|
654
|
-
),
|
|
655
|
-
// TODO: dangerous see if true
|
|
654
|
+
), M.set(
|
|
656
655
|
y[q[1]],
|
|
657
|
-
// PLY stores rot
|
|
656
|
+
// PLY stores rot 1,2,3,0 (x,y,z,w)
|
|
658
657
|
y[q[2]],
|
|
659
658
|
y[q[3]],
|
|
660
659
|
y[q[0]]
|
|
661
|
-
).normalize(),
|
|
660
|
+
).normalize(), M.w < 0 && (M.x = -M.x, M.y = -M.y, M.z = -M.z, M.w = -M.w), U.set(
|
|
662
661
|
y[H[0]],
|
|
663
662
|
// Read directly assuming it's log scale
|
|
664
663
|
y[H[1]],
|
|
665
664
|
y[H[2]]
|
|
666
|
-
),
|
|
667
|
-
0.5 + y[$[0]] *
|
|
668
|
-
0.5 + y[$[1]] *
|
|
669
|
-
0.5 + y[$[2]] *
|
|
670
|
-
),
|
|
671
|
-
const
|
|
665
|
+
), V.set(
|
|
666
|
+
0.5 + y[$[0]] * B,
|
|
667
|
+
0.5 + y[$[1]] * B,
|
|
668
|
+
0.5 + y[$[2]] * B
|
|
669
|
+
), V.r = Math.max(0, Math.min(1, V.r)), V.g = Math.max(0, Math.min(1, V.g)), V.b = Math.max(0, Math.min(1, V.b));
|
|
670
|
+
const _ = E(y[D]);
|
|
672
671
|
p.setSplat(
|
|
673
672
|
g,
|
|
674
673
|
w,
|
|
675
|
-
|
|
676
|
-
V,
|
|
677
|
-
// Pass log scale directly
|
|
674
|
+
M,
|
|
678
675
|
U,
|
|
679
|
-
|
|
676
|
+
// Pass log scale directly
|
|
677
|
+
V,
|
|
678
|
+
_
|
|
680
679
|
);
|
|
681
680
|
}
|
|
682
681
|
return p.calculateBoundingBox(), p;
|
|
683
682
|
}
|
|
684
683
|
}
|
|
685
|
-
class
|
|
684
|
+
class Ie extends i.EventDispatcher {
|
|
686
685
|
constructor() {
|
|
687
686
|
super();
|
|
688
687
|
v(this, "worker");
|
|
@@ -692,8 +691,8 @@ class _e extends i.EventDispatcher {
|
|
|
692
691
|
v(this, "chunks", null);
|
|
693
692
|
v(this, "lastCameraPosition", new i.Vector3());
|
|
694
693
|
v(this, "lastCameraDirection", new i.Vector3());
|
|
695
|
-
const s = this.createWorkerCode(),
|
|
696
|
-
this.worker = new Worker(URL.createObjectURL(
|
|
694
|
+
const s = this.createWorkerCode(), n = new Blob([s], { type: "application/javascript" });
|
|
695
|
+
this.worker = new Worker(URL.createObjectURL(n)), this.worker.onmessage = this.onWorkerMessage.bind(this);
|
|
697
696
|
}
|
|
698
697
|
/**
|
|
699
698
|
* Handles messages received from the sorting worker.
|
|
@@ -702,14 +701,14 @@ class _e extends i.EventDispatcher {
|
|
|
702
701
|
onWorkerMessage(s) {
|
|
703
702
|
if (!this.orderTexture || !this.orderTexture.image)
|
|
704
703
|
return console.error("SplatSorter: Order texture not initialized!");
|
|
705
|
-
const { order:
|
|
706
|
-
if (!(
|
|
704
|
+
const { order: n, count: t } = s.data, r = this.orderTexture.image.data;
|
|
705
|
+
if (!(r instanceof Uint32Array))
|
|
707
706
|
return console.error(
|
|
708
707
|
"SplatSorter: Order texture data is not a Uint32Array!"
|
|
709
708
|
);
|
|
710
|
-
|
|
711
|
-
const a =
|
|
712
|
-
this.worker.postMessage(c, [a]), this.dispatchEvent({ type: "updated", count:
|
|
709
|
+
r.set(new Uint32Array(n)), this.orderTexture.needsUpdate = !0;
|
|
710
|
+
const a = r.buffer.slice(0), c = { order: a };
|
|
711
|
+
this.worker.postMessage(c, [a]), this.dispatchEvent({ type: "updated", count: t });
|
|
713
712
|
}
|
|
714
713
|
/**
|
|
715
714
|
* Initializes the sorter with necessary data and textures.
|
|
@@ -717,31 +716,31 @@ class _e extends i.EventDispatcher {
|
|
|
717
716
|
* @param centers A Float32Array containing the center position (x, y, z) for each splat.
|
|
718
717
|
* @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
|
|
719
718
|
*/
|
|
720
|
-
init(s,
|
|
719
|
+
init(s, n, t) {
|
|
721
720
|
if (!s || !(s.image.data instanceof Uint32Array))
|
|
722
721
|
throw new Error("SplatSorter: Invalid orderTexture provided. Must be DataTexture with Uint32Array data.");
|
|
723
|
-
if (!
|
|
722
|
+
if (!n || n.length % 3 !== 0)
|
|
724
723
|
throw new Error("SplatSorter: Invalid centers array provided. Length must be multiple of 3.");
|
|
725
|
-
if (s.image.data.length <
|
|
724
|
+
if (s.image.data.length < n.length / 3)
|
|
726
725
|
throw new Error("SplatSorter: orderTexture data buffer is smaller than the number of splats.");
|
|
727
|
-
const
|
|
728
|
-
this.orderTexture = s, this.centers =
|
|
726
|
+
const r = n.length / 3;
|
|
727
|
+
this.orderTexture = s, this.centers = n.slice();
|
|
729
728
|
const a = this.orderTexture.image.data;
|
|
730
|
-
for (let b = 0; b <
|
|
729
|
+
for (let b = 0; b < r; b++) a[b] = b;
|
|
731
730
|
this.orderTexture.needsUpdate = !0;
|
|
732
731
|
const c = a.buffer.slice(0), l = this.centers.buffer.slice(0), m = {
|
|
733
732
|
order: c,
|
|
734
733
|
centers: l
|
|
735
|
-
},
|
|
734
|
+
}, S = [
|
|
736
735
|
c,
|
|
737
736
|
l
|
|
738
737
|
];
|
|
739
|
-
if (
|
|
740
|
-
this.chunks =
|
|
738
|
+
if (t) {
|
|
739
|
+
this.chunks = t.slice();
|
|
741
740
|
const b = this.chunks.buffer.slice(0);
|
|
742
|
-
m.chunks = b,
|
|
741
|
+
m.chunks = b, S.push(b);
|
|
743
742
|
}
|
|
744
|
-
this.worker.postMessage(m,
|
|
743
|
+
this.worker.postMessage(m, S);
|
|
745
744
|
}
|
|
746
745
|
/**
|
|
747
746
|
* Applies an optional mapping to filter or reorder splats before sorting.
|
|
@@ -753,16 +752,16 @@ class _e extends i.EventDispatcher {
|
|
|
753
752
|
return console.warn(
|
|
754
753
|
"SplatSorter: Cannot set mapping before initialization."
|
|
755
754
|
);
|
|
756
|
-
let
|
|
757
|
-
const
|
|
755
|
+
let n;
|
|
756
|
+
const t = [];
|
|
758
757
|
if (!s) {
|
|
759
758
|
const l = this.centers.buffer.slice(0);
|
|
760
|
-
return
|
|
759
|
+
return n = {
|
|
761
760
|
centers: l,
|
|
762
761
|
mapping: null
|
|
763
|
-
},
|
|
762
|
+
}, t.push(l), this.worker.postMessage(n, t);
|
|
764
763
|
}
|
|
765
|
-
const
|
|
764
|
+
const r = new Float32Array(s.length * 3);
|
|
766
765
|
for (let l = 0; l < s.length; l++) {
|
|
767
766
|
const m = s[l];
|
|
768
767
|
if (m * 3 + 2 >= this.centers.length) {
|
|
@@ -771,28 +770,28 @@ class _e extends i.EventDispatcher {
|
|
|
771
770
|
);
|
|
772
771
|
continue;
|
|
773
772
|
}
|
|
774
|
-
const
|
|
775
|
-
|
|
773
|
+
const S = m * 3, b = l * 3;
|
|
774
|
+
r[b + 0] = this.centers[S + 0], r[b + 1] = this.centers[S + 1], r[b + 2] = this.centers[S + 2];
|
|
776
775
|
}
|
|
777
|
-
const a =
|
|
778
|
-
|
|
776
|
+
const a = r.buffer.slice(0), c = s.buffer.slice(0);
|
|
777
|
+
n = {
|
|
779
778
|
centers: a,
|
|
780
779
|
mapping: c
|
|
781
|
-
},
|
|
780
|
+
}, t.push(a, c), this.worker.postMessage(n, t);
|
|
782
781
|
}
|
|
783
782
|
/**
|
|
784
783
|
* Updates the camera parameters used for sorting.
|
|
785
784
|
* @param position The camera's position in the sorter's local coordinate space.
|
|
786
785
|
* @param direction The camera's forward direction in the sorter's local coordinate space.
|
|
787
786
|
*/
|
|
788
|
-
setCamera(s,
|
|
789
|
-
const
|
|
790
|
-
if (!
|
|
787
|
+
setCamera(s, n) {
|
|
788
|
+
const t = this.lastCameraPosition.distanceToSquared(s) > 1e-7, r = this.lastCameraDirection.dot(n) < 0.9999;
|
|
789
|
+
if (!t && !r)
|
|
791
790
|
return;
|
|
792
|
-
this.lastCameraPosition.copy(s), this.lastCameraDirection.copy(
|
|
791
|
+
this.lastCameraPosition.copy(s), this.lastCameraDirection.copy(n);
|
|
793
792
|
const a = {
|
|
794
793
|
cameraPosition: { x: s.x, y: s.y, z: s.z },
|
|
795
|
-
cameraDirection: { x:
|
|
794
|
+
cameraDirection: { x: n.x, y: n.y, z: n.z }
|
|
796
795
|
};
|
|
797
796
|
this.worker.postMessage(a);
|
|
798
797
|
}
|
|
@@ -808,49 +807,49 @@ class _e extends i.EventDispatcher {
|
|
|
808
807
|
*/
|
|
809
808
|
createWorkerCode() {
|
|
810
809
|
return `(${(function() {
|
|
811
|
-
let
|
|
812
|
-
const
|
|
813
|
-
let
|
|
814
|
-
const O = 32, j = new Array(O).fill(0), W = new Array(O).fill(0), q = new Array(O).fill(0), H = (D, k,
|
|
810
|
+
let n = null, t = null, r = null, a = null, c = null, l = null, m = !1;
|
|
811
|
+
const S = { x: 0, y: 0, z: 0 }, b = { x: 0, y: 0, z: 0 }, p = { x: 0, y: 0, z: 0 }, x = { x: 0, y: 0, z: 0 };
|
|
812
|
+
let f = null, T = null;
|
|
813
|
+
const O = 32, j = new Array(O).fill(0), W = new Array(O).fill(0), q = new Array(O).fill(0), H = (D, k, B) => {
|
|
815
814
|
for (; D <= k; ) {
|
|
816
|
-
const
|
|
817
|
-
if (w > 0) D =
|
|
818
|
-
else if (w < 0) k =
|
|
819
|
-
else return
|
|
815
|
+
const E = k + D >> 1, w = B(E);
|
|
816
|
+
if (w > 0) D = E + 1;
|
|
817
|
+
else if (w < 0) k = E - 1;
|
|
818
|
+
else return E;
|
|
820
819
|
}
|
|
821
820
|
return ~D;
|
|
822
821
|
}, $ = () => {
|
|
823
|
-
if (!
|
|
822
|
+
if (!n || !t || !c || !l)
|
|
824
823
|
return;
|
|
825
|
-
if (
|
|
824
|
+
if (t.length === 0) {
|
|
826
825
|
const h = {
|
|
827
|
-
order:
|
|
826
|
+
order: n.buffer,
|
|
828
827
|
count: 0
|
|
829
828
|
};
|
|
830
|
-
self.postMessage(h, [
|
|
829
|
+
self.postMessage(h, [n.buffer]), n = null;
|
|
831
830
|
return;
|
|
832
831
|
}
|
|
833
|
-
const D = c.x, k = c.y,
|
|
834
|
-
if (!m && !
|
|
832
|
+
const D = c.x, k = c.y, B = c.z, E = l.x, w = l.y, M = l.z, U = 1e-4, V = Math.abs(D - S.x) > U || Math.abs(k - S.y) > U || Math.abs(B - S.z) > U, g = Math.abs(E - b.x) > U || Math.abs(w - b.y) > U || Math.abs(M - b.z) > U;
|
|
833
|
+
if (!m && !V && !g)
|
|
835
834
|
return;
|
|
836
|
-
m = !1,
|
|
837
|
-
let y = 1 / 0,
|
|
835
|
+
m = !1, S.x = D, S.y = k, S.z = B, b.x = E, b.y = w, b.z = M;
|
|
836
|
+
let y = 1 / 0, _ = -1 / 0;
|
|
838
837
|
for (let h = 0; h < 8; ++h) {
|
|
839
|
-
const
|
|
840
|
-
y = Math.min(y,
|
|
838
|
+
const P = h & 1 ? p.x : x.x, F = h & 2 ? p.y : x.y, u = h & 4 ? p.z : x.z, I = P * E + F * w + u * M;
|
|
839
|
+
y = Math.min(y, I), _ = Math.max(_, I);
|
|
841
840
|
}
|
|
842
|
-
const
|
|
841
|
+
const R = t.length / 3, L = _ - y, o = (1 << Math.max(
|
|
843
842
|
10,
|
|
844
|
-
Math.min(20, Math.ceil(Math.log2(
|
|
843
|
+
Math.min(20, Math.ceil(Math.log2(R / 4)))
|
|
845
844
|
)) + 1;
|
|
846
|
-
if ((!
|
|
847
|
-
for (let h = 0; h <
|
|
848
|
-
|
|
849
|
-
} else if (
|
|
850
|
-
const h =
|
|
845
|
+
if ((!f || f.length !== R) && (f = new Uint32Array(R)), !T || T.length !== o ? T = new Uint32Array(o) : T.fill(0), L < 1e-7) {
|
|
846
|
+
for (let h = 0; h < R; ++h) f[h] = 0;
|
|
847
|
+
T[0] = R;
|
|
848
|
+
} else if (r && r.length > 0) {
|
|
849
|
+
const h = r.length / 6;
|
|
851
850
|
j.fill(0);
|
|
852
851
|
for (let u = 0; u < h; ++u) {
|
|
853
|
-
const
|
|
852
|
+
const I = u * 6, Y = r[I + 0], G = r[I + 1], ne = r[I + 2], X = r[I + 3], J = Y * E + G * w + ne * M - y, oe = J - X, ee = J + X, ie = Math.max(
|
|
854
853
|
0,
|
|
855
854
|
Math.floor(oe * O / L)
|
|
856
855
|
), ce = Math.min(
|
|
@@ -860,96 +859,97 @@ class _e extends i.EventDispatcher {
|
|
|
860
859
|
for (let Q = ie; Q < ce; ++Q)
|
|
861
860
|
j[Q]++;
|
|
862
861
|
}
|
|
863
|
-
let
|
|
864
|
-
for (let u = 0; u < O; ++u)
|
|
862
|
+
let P = 0;
|
|
863
|
+
for (let u = 0; u < O; ++u) P += j[u];
|
|
865
864
|
q[0] = 0, W[0] = 0;
|
|
866
865
|
for (let u = 1; u < O; ++u)
|
|
867
|
-
q[u - 1] = j[u - 1] /
|
|
868
|
-
q[O - 1] = j[O - 1] /
|
|
869
|
-
const
|
|
870
|
-
for (let u = 0; u <
|
|
871
|
-
const
|
|
866
|
+
q[u - 1] = j[u - 1] / P * o >>> 0, W[u] = W[u - 1] + q[u - 1];
|
|
867
|
+
q[O - 1] = j[O - 1] / P * o >>> 0;
|
|
868
|
+
const F = L / O;
|
|
869
|
+
for (let u = 0; u < R; ++u) {
|
|
870
|
+
const I = u * 3, Y = t[I + 0], G = t[I + 1], ne = t[I + 2], X = Y * E + G * w + ne * M, oe = (_ - X) / F, ee = Math.max(
|
|
872
871
|
0,
|
|
873
872
|
Math.min(
|
|
874
873
|
O - 1,
|
|
875
874
|
Math.floor(oe)
|
|
876
875
|
)
|
|
877
|
-
), ie = oe - ee, ce = W[ee] + q[ee] * ie >>> 0, Q = Math.min(ce,
|
|
878
|
-
|
|
876
|
+
), ie = oe - ee, ce = W[ee] + q[ee] * ie >>> 0, Q = Math.min(ce, o - 1);
|
|
877
|
+
f[u] = Q, T[Q]++;
|
|
879
878
|
}
|
|
880
879
|
} else {
|
|
881
|
-
const h = (
|
|
882
|
-
for (let
|
|
883
|
-
const
|
|
884
|
-
|
|
880
|
+
const h = (o - 1) / L;
|
|
881
|
+
for (let P = 0; P < R; ++P) {
|
|
882
|
+
const F = P * 3, u = t[F + 0], I = t[F + 1], Y = t[F + 2], G = u * E + I * w + Y * M, X = (_ - G) * h >>> 0, J = Math.min(X, o - 1);
|
|
883
|
+
f[P] = J, T[J]++;
|
|
885
884
|
}
|
|
886
885
|
}
|
|
887
|
-
for (let h = 1; h <
|
|
888
|
-
|
|
889
|
-
for (let h =
|
|
890
|
-
const
|
|
891
|
-
|
|
886
|
+
for (let h = 1; h < o; h++)
|
|
887
|
+
T[h] += T[h - 1];
|
|
888
|
+
for (let h = R - 1; h >= 0; h--) {
|
|
889
|
+
const P = f[h], F = --T[P];
|
|
890
|
+
n[F] = a ? a[h] : h;
|
|
892
891
|
}
|
|
893
|
-
const
|
|
894
|
-
if (!
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
892
|
+
const d = D * E + k * w + B * M, A = (h) => {
|
|
893
|
+
if (!n) return -1 / 0;
|
|
894
|
+
const P = n[h], F = P;
|
|
895
|
+
if (!t || F * 3 + 2 >= t.length)
|
|
897
896
|
return -1 / 0;
|
|
898
|
-
const u =
|
|
899
|
-
return
|
|
897
|
+
const u = F * 3;
|
|
898
|
+
return t[u] * E + t[u + 1] * w + t[u + 2] * M - d;
|
|
900
899
|
};
|
|
901
|
-
let
|
|
902
|
-
if (
|
|
900
|
+
let z = R;
|
|
901
|
+
if (R > 0 && A(R - 1) < 0) {
|
|
903
902
|
const h = H(
|
|
904
903
|
0,
|
|
905
|
-
|
|
906
|
-
|
|
904
|
+
R - 1,
|
|
905
|
+
A
|
|
907
906
|
);
|
|
908
|
-
|
|
907
|
+
z = h < 0 ? ~h : h;
|
|
909
908
|
}
|
|
910
909
|
const N = {
|
|
911
|
-
order:
|
|
912
|
-
count:
|
|
910
|
+
order: n.buffer,
|
|
911
|
+
count: z
|
|
913
912
|
};
|
|
914
|
-
self.postMessage(N, [
|
|
913
|
+
self.postMessage(N, [n.buffer]), n = null;
|
|
915
914
|
};
|
|
916
915
|
self.onmessage = (D) => {
|
|
917
916
|
const k = D.data;
|
|
918
|
-
k.order && (
|
|
919
|
-
let
|
|
920
|
-
if (k.centers && (
|
|
921
|
-
if (
|
|
922
|
-
for (let
|
|
923
|
-
const w =
|
|
924
|
-
|
|
925
|
-
(g -
|
|
917
|
+
k.order && (n = new Uint32Array(k.order));
|
|
918
|
+
let B = !1;
|
|
919
|
+
if (k.centers && (t = new Float32Array(k.centers), B = !0, m = !0), Object.prototype.hasOwnProperty.call(k, "mapping") && (a = k.mapping ? new Uint32Array(k.mapping) : null, m = !0), k.chunks) {
|
|
920
|
+
if (r = new Float32Array(k.chunks), r.length > 0 && r[3] > 0)
|
|
921
|
+
for (let E = 0; E < r.length / 6; ++E) {
|
|
922
|
+
const w = E * 6, M = r[w + 0], U = r[w + 1], V = r[w + 2], g = r[w + 3], y = r[w + 4], _ = r[w + 5];
|
|
923
|
+
r[w + 0] = (M + g) * 0.5, r[w + 1] = (U + y) * 0.5, r[w + 2] = (V + _) * 0.5, r[w + 3] = Math.sqrt(
|
|
924
|
+
(g - M) ** 2 + (y - U) ** 2 + (_ - V) ** 2
|
|
926
925
|
) * 0.5;
|
|
927
926
|
}
|
|
928
927
|
m = !0;
|
|
929
928
|
}
|
|
930
|
-
if (
|
|
931
|
-
p.x = x.x =
|
|
932
|
-
for (let
|
|
933
|
-
const w =
|
|
934
|
-
p.x = Math.min(p.x,
|
|
929
|
+
if (B && t && t.length > 0) {
|
|
930
|
+
p.x = x.x = t[0], p.y = x.y = t[1], p.z = x.z = t[2];
|
|
931
|
+
for (let E = 1; E < t.length / 3; E++) {
|
|
932
|
+
const w = E * 3;
|
|
933
|
+
p.x = Math.min(p.x, t[w + 0]), x.x = Math.max(x.x, t[w + 0]), p.y = Math.min(p.y, t[w + 1]), x.y = Math.max(x.y, t[w + 1]), p.z = Math.min(p.z, t[w + 2]), x.z = Math.max(x.z, t[w + 2]);
|
|
935
934
|
}
|
|
936
|
-
} else
|
|
935
|
+
} else B && t && t.length === 0 && (p.x = x.x = p.y = x.y = p.z = x.z = 0);
|
|
937
936
|
k.cameraPosition && (c = k.cameraPosition), k.cameraDirection && (l = k.cameraDirection), $();
|
|
938
937
|
};
|
|
939
938
|
}).toString()})();`;
|
|
940
939
|
}
|
|
941
940
|
}
|
|
942
|
-
const
|
|
943
|
-
const s =
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
return
|
|
951
|
-
}
|
|
952
|
-
|
|
941
|
+
const Re = (C, e) => {
|
|
942
|
+
const s = de(C), n = de(e);
|
|
943
|
+
return s | n << 16;
|
|
944
|
+
};
|
|
945
|
+
function de(C) {
|
|
946
|
+
const e = new Float32Array([C]), n = new Int32Array(e.buffer)[0];
|
|
947
|
+
let t = n >> 16 & 32768, r = n >> 12 & 2047;
|
|
948
|
+
const a = n >> 23 & 255;
|
|
949
|
+
return a < 103 ? t : a > 142 ? (t |= 31744, t |= (a === 255 ? 0 : 1) && n & 8388607, t) : a < 113 ? (r |= 2048, t |= (r >> 114 - a) + (r >> 113 - a & 1), t) : (t |= a - 112 << 10 | r >> 1, t += r & 1, t);
|
|
950
|
+
}
|
|
951
|
+
const ze = new ArrayBuffer(4), pe = new DataView(ze), Pe = (C) => (pe.setUint32(0, C, !0), pe.getFloat32(0, !0));
|
|
952
|
+
class Oe {
|
|
953
953
|
/**
|
|
954
954
|
* Create a new TextureManager for a set of splats
|
|
955
955
|
* @param splatData The splat data to manage textures for
|
|
@@ -973,24 +973,24 @@ class Pe {
|
|
|
973
973
|
* @returns DataTexture containing position data
|
|
974
974
|
*/
|
|
975
975
|
createTransformATexture(e) {
|
|
976
|
-
const s = e.numSplats,
|
|
976
|
+
const s = e.numSplats, n = new Float32Array(
|
|
977
977
|
this.textureWidth * this.textureHeight * 4
|
|
978
978
|
);
|
|
979
|
-
for (let
|
|
980
|
-
const a =
|
|
981
|
-
|
|
982
|
-
const m = e.rotations[l +
|
|
983
|
-
|
|
979
|
+
for (let r = 0; r < s; r++) {
|
|
980
|
+
const a = r * 4, c = r * 3, l = r * 4;
|
|
981
|
+
n[a] = e.positions[c], n[a + 1] = e.positions[c + 1], n[a + 2] = e.positions[c + 2];
|
|
982
|
+
const m = e.rotations[l + 0], S = e.rotations[l + 1], b = Re(m, S);
|
|
983
|
+
n[a + 3] = Pe(b);
|
|
984
984
|
}
|
|
985
|
-
const
|
|
986
|
-
|
|
985
|
+
const t = new i.DataTexture(
|
|
986
|
+
n,
|
|
987
987
|
this.textureWidth,
|
|
988
988
|
this.textureHeight,
|
|
989
989
|
i.RGBAFormat,
|
|
990
990
|
i.FloatType
|
|
991
991
|
// Store as Float32, shader will reinterpret bits
|
|
992
992
|
);
|
|
993
|
-
return
|
|
993
|
+
return t.needsUpdate = !0, t.magFilter = i.NearestFilter, t.minFilter = i.NearestFilter, t;
|
|
994
994
|
}
|
|
995
995
|
/**
|
|
996
996
|
* Create the transform B texture (scale and rotation xyz)
|
|
@@ -998,21 +998,21 @@ class Pe {
|
|
|
998
998
|
* @returns DataTexture containing scale and rotation data
|
|
999
999
|
*/
|
|
1000
1000
|
createTransformBTexture(e) {
|
|
1001
|
-
const s = e.numSplats,
|
|
1001
|
+
const s = e.numSplats, n = new Float32Array(
|
|
1002
1002
|
this.textureWidth * this.textureHeight * 4
|
|
1003
1003
|
);
|
|
1004
|
-
for (let
|
|
1005
|
-
const a =
|
|
1006
|
-
|
|
1004
|
+
for (let r = 0; r < s; r++) {
|
|
1005
|
+
const a = r * 4, c = r * 3, l = r * 4;
|
|
1006
|
+
n[a] = e.scales[c], n[a + 1] = e.scales[c + 1], n[a + 2] = e.scales[c + 2], n[a + 3] = e.rotations[l + 2];
|
|
1007
1007
|
}
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1008
|
+
const t = new i.DataTexture(
|
|
1009
|
+
n,
|
|
1010
1010
|
this.textureWidth,
|
|
1011
1011
|
this.textureHeight,
|
|
1012
1012
|
i.RGBAFormat,
|
|
1013
1013
|
i.FloatType
|
|
1014
1014
|
);
|
|
1015
|
-
return
|
|
1015
|
+
return t.needsUpdate = !0, t.magFilter = i.NearestFilter, t.minFilter = i.NearestFilter, t;
|
|
1016
1016
|
}
|
|
1017
1017
|
/**
|
|
1018
1018
|
* Create the color texture (RGB and opacity)
|
|
@@ -1020,21 +1020,21 @@ class Pe {
|
|
|
1020
1020
|
* @returns DataTexture containing color data
|
|
1021
1021
|
*/
|
|
1022
1022
|
createColorTexture(e) {
|
|
1023
|
-
const s = e.numSplats,
|
|
1023
|
+
const s = e.numSplats, n = new Float32Array(
|
|
1024
1024
|
this.textureWidth * this.textureHeight * 4
|
|
1025
1025
|
);
|
|
1026
|
-
for (let
|
|
1027
|
-
const a =
|
|
1028
|
-
|
|
1026
|
+
for (let r = 0; r < s; r++) {
|
|
1027
|
+
const a = r * 4, c = r * 3;
|
|
1028
|
+
n[a] = e.colors[c], n[a + 1] = e.colors[c + 1], n[a + 2] = e.colors[c + 2], n[a + 3] = e.opacities[r];
|
|
1029
1029
|
}
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1030
|
+
const t = new i.DataTexture(
|
|
1031
|
+
n,
|
|
1032
1032
|
this.textureWidth,
|
|
1033
1033
|
this.textureHeight,
|
|
1034
1034
|
i.RGBAFormat,
|
|
1035
1035
|
i.FloatType
|
|
1036
1036
|
);
|
|
1037
|
-
return
|
|
1037
|
+
return t.needsUpdate = !0, t;
|
|
1038
1038
|
}
|
|
1039
1039
|
/**
|
|
1040
1040
|
* Create the order texture for sorting
|
|
@@ -1043,22 +1043,22 @@ class Pe {
|
|
|
1043
1043
|
*/
|
|
1044
1044
|
createOrderTexture(e) {
|
|
1045
1045
|
const s = new Uint32Array(this.textureWidth * this.textureHeight);
|
|
1046
|
-
for (let
|
|
1047
|
-
s[
|
|
1048
|
-
const
|
|
1046
|
+
for (let t = 0; t < e; t++)
|
|
1047
|
+
s[t] = t;
|
|
1048
|
+
const n = new i.DataTexture(
|
|
1049
1049
|
s,
|
|
1050
1050
|
this.textureWidth,
|
|
1051
1051
|
this.textureHeight,
|
|
1052
1052
|
i.RedIntegerFormat,
|
|
1053
1053
|
i.UnsignedIntType
|
|
1054
1054
|
);
|
|
1055
|
-
return
|
|
1055
|
+
return n.needsUpdate = !0, n;
|
|
1056
1056
|
}
|
|
1057
1057
|
dispose() {
|
|
1058
1058
|
this.transformA.dispose(), this.transformB.dispose(), this.colorTexture.dispose(), this.orderTexture.dispose();
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
const
|
|
1061
|
+
const Be = (
|
|
1062
1062
|
/* glsl */
|
|
1063
1063
|
`
|
|
1064
1064
|
precision highp float;
|
|
@@ -1096,61 +1096,53 @@ varying vec2 vUv; // For gaussian calculation in fragment shader
|
|
|
1096
1096
|
|
|
1097
1097
|
// --- Helper Functions ---
|
|
1098
1098
|
|
|
1099
|
-
//
|
|
1100
|
-
vec2 unpackHalf2x16FromFloat(float packedFloat) {
|
|
1101
|
-
uint packedUInt = floatBitsToUint(packedFloat);
|
|
1102
|
-
uint y_bits = packedUInt >> 16;
|
|
1103
|
-
uint z_bits = packedUInt & uint(0xFFFF);
|
|
1104
|
-
|
|
1105
|
-
// NOTE: This assumes packing used "packNormalizedFloatToUint16Pair"
|
|
1106
|
-
// which maps [-1, 1] to [0, 65535]. Adjust if packing method changes.
|
|
1107
|
-
float y = (float(y_bits) / 65535.0) * 2.0 - 1.0;
|
|
1108
|
-
float z = (float(z_bits) / 65535.0) * 2.0 - 1.0;
|
|
1109
|
-
return vec2(y, z);
|
|
1110
|
-
}
|
|
1099
|
+
// Use GLSL built-in unpackHalf2x16 for proper half-float unpacking
|
|
1111
1100
|
|
|
1112
|
-
// Reconstruct quaternion from packed components (
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
float
|
|
1101
|
+
// Reconstruct quaternion from packed components (xy_packed, z)
|
|
1102
|
+
// Returns (w,x,y,z) format for quatToMat3 compatibility
|
|
1103
|
+
vec4 unpackRotation(float xy_packed, float z) {
|
|
1104
|
+
vec2 xy = unpackHalf2x16(floatBitsToUint(xy_packed));
|
|
1105
|
+
float x = xy.x;
|
|
1106
|
+
float y = xy.y;
|
|
1117
1107
|
float w_squared = 1.0 - x*x - y*y - z*z;
|
|
1118
|
-
float w = (w_squared < 0.0) ? 0.0 : sqrt(w_squared);
|
|
1119
|
-
return vec4(x, y, z
|
|
1108
|
+
float w = (w_squared < 0.0) ? 0.0 : sqrt(w_squared);
|
|
1109
|
+
return vec4(w, x, y, z); // Return (w,x,y,z)
|
|
1120
1110
|
}
|
|
1121
1111
|
|
|
1122
1112
|
// Convert quaternion to 3x3 rotation matrix
|
|
1123
|
-
mat3 quatToMat3(vec4
|
|
1124
|
-
|
|
1125
|
-
float
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
float
|
|
1113
|
+
mat3 quatToMat3(vec4 R) {
|
|
1114
|
+
vec4 R2 = R + R;
|
|
1115
|
+
float X = R2.x * R.w;
|
|
1116
|
+
vec4 Y = R2.y * R;
|
|
1117
|
+
vec4 Z = R2.z * R;
|
|
1118
|
+
float W = R2.w * R.w;
|
|
1129
1119
|
|
|
1130
1120
|
return mat3(
|
|
1131
|
-
1.0 -
|
|
1132
|
-
|
|
1133
|
-
|
|
1121
|
+
1.0 - Z.z - W,
|
|
1122
|
+
Y.z + X,
|
|
1123
|
+
Y.w - Z.x,
|
|
1124
|
+
Y.z - X,
|
|
1125
|
+
1.0 - Y.y - W,
|
|
1126
|
+
Z.w + Y.x,
|
|
1127
|
+
Y.w + Z.x,
|
|
1128
|
+
Z.w - Y.x,
|
|
1129
|
+
1.0 - Y.y - Z.z
|
|
1134
1130
|
);
|
|
1135
1131
|
}
|
|
1136
1132
|
|
|
1137
|
-
// Calculate model-space covariance components
|
|
1133
|
+
// Calculate model-space covariance components
|
|
1138
1134
|
void getModelCovariance(vec3 scale, vec4 rotation, out vec3 covA, out vec3 covB) {
|
|
1139
|
-
mat3
|
|
1140
|
-
|
|
1141
|
-
//
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
R[2][0] * scale.x, R[2][1] * scale.y, R[2][2] * scale.z // Row 2 = (R_row2 * S)
|
|
1148
|
-
);
|
|
1135
|
+
mat3 rot = quatToMat3(rotation);
|
|
1136
|
+
|
|
1137
|
+
// M = S * R (scale COLUMNS, then transpose)
|
|
1138
|
+
mat3 M = transpose(mat3(
|
|
1139
|
+
scale.x * rot[0], // scale.x * column 0
|
|
1140
|
+
scale.y * rot[1], // scale.y * column 1
|
|
1141
|
+
scale.z * rot[2] // scale.z * column 2
|
|
1142
|
+
));
|
|
1149
1143
|
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
covA = vec3(dot(M[0], M[0]), dot(M[0], M[1]), dot(M[0], M[2])); // Vrk[0][0], Vrk[0][1], Vrk[0][2]
|
|
1153
|
-
covB = vec3(dot(M[1], M[1]), dot(M[1], M[2]), dot(M[2], M[2])); // Vrk[1][1], Vrk[1][2], Vrk[2][2]
|
|
1144
|
+
covA = vec3(dot(M[0], M[0]), dot(M[0], M[1]), dot(M[0], M[2]));
|
|
1145
|
+
covB = vec3(dot(M[1], M[1]), dot(M[1], M[2]), dot(M[2], M[2]));
|
|
1154
1146
|
}
|
|
1155
1147
|
|
|
1156
1148
|
// --- Main Function ---
|
|
@@ -1179,7 +1171,7 @@ void main(void) {
|
|
|
1179
1171
|
|
|
1180
1172
|
vec3 splatPosition = texTransformA.xyz;
|
|
1181
1173
|
vec3 splatLogScale = texTransformB.xyz; // Assume stored as log scale
|
|
1182
|
-
vec4 splatRotation = unpackRotation(texTransformA.w, texTransformB.w); // Unpack rot
|
|
1174
|
+
vec4 splatRotation = unpackRotation(texTransformA.w, texTransformB.w); // Unpack rot xy, z
|
|
1183
1175
|
vec3 splatColor = texColor.rgb;
|
|
1184
1176
|
float splatOpacity = texColor.a;
|
|
1185
1177
|
|
|
@@ -1305,7 +1297,6 @@ void main(void) {
|
|
|
1305
1297
|
// Apply clip to the corner offset *before* calculating screen space offset
|
|
1306
1298
|
vec2 clippedCornerOffset = cornerOffset * clip;
|
|
1307
1299
|
vec2 screenOffsetPixels = clippedCornerOffset.x * v1_scaled + clippedCornerOffset.y * v2_scaled;
|
|
1308
|
-
//vec2 screenOffsetPixels = vec2(clippedCornerOffset.x, clippedCornerOffset.y);
|
|
1309
1300
|
|
|
1310
1301
|
// Convert pixel offset to clip space offset
|
|
1311
1302
|
vec2 clipOffset = screenOffsetPixels * (centerClip.w / viewport);
|
|
@@ -1346,7 +1337,7 @@ void main(void) {
|
|
|
1346
1337
|
}
|
|
1347
1338
|
`
|
|
1348
1339
|
);
|
|
1349
|
-
class
|
|
1340
|
+
class De extends i.ShaderMaterial {
|
|
1350
1341
|
constructor(e = {}) {
|
|
1351
1342
|
const s = {
|
|
1352
1343
|
// Textures (values set via methods)
|
|
@@ -1361,7 +1352,7 @@ class Be extends i.ShaderMaterial {
|
|
|
1361
1352
|
// Max splats to render (updated by sorter)
|
|
1362
1353
|
};
|
|
1363
1354
|
super({
|
|
1364
|
-
vertexShader:
|
|
1355
|
+
vertexShader: Be,
|
|
1365
1356
|
fragmentShader: Fe,
|
|
1366
1357
|
uniforms: s,
|
|
1367
1358
|
transparent: !0,
|
|
@@ -1440,9 +1431,9 @@ const K = class K extends i.Mesh {
|
|
|
1440
1431
|
* @param splatData The splat data to render
|
|
1441
1432
|
* @param options Rendering options
|
|
1442
1433
|
*/
|
|
1443
|
-
constructor(s,
|
|
1444
|
-
const
|
|
1445
|
-
super(
|
|
1434
|
+
constructor(s, n = {}) {
|
|
1435
|
+
const t = new De(n), r = K.createInstancedGeometry(s.numSplats, K.INSTANCE_SIZE);
|
|
1436
|
+
super(r, t);
|
|
1446
1437
|
v(this, "sorter");
|
|
1447
1438
|
v(this, "splatData");
|
|
1448
1439
|
v(this, "options");
|
|
@@ -1452,7 +1443,7 @@ const K = class K extends i.Mesh {
|
|
|
1452
1443
|
v(this, "lastCameraPositionLocal", new i.Vector3());
|
|
1453
1444
|
v(this, "lastCameraDirectionLocal", new i.Vector3());
|
|
1454
1445
|
v(this, "invModelMatrix", new i.Matrix4());
|
|
1455
|
-
this.geometry =
|
|
1446
|
+
this.geometry = r, this.material = t, this.splatData = s, this.frustumCulled = !1, this.options = { autoSort: !0, ...n }, this.textureManager = new Oe(s), this.sorter = new Ie();
|
|
1456
1447
|
let a = this.createChunks() || void 0;
|
|
1457
1448
|
a === null && console.warn("Visus: Could not create sorter chunks, bounding box might be invalid."), a = void 0, this.sorter.init(
|
|
1458
1449
|
this.textureManager.orderTexture,
|
|
@@ -1472,8 +1463,8 @@ const K = class K extends i.Mesh {
|
|
|
1472
1463
|
* @param instanceSize Number of splats per instance.
|
|
1473
1464
|
* @returns InstancedBufferGeometry
|
|
1474
1465
|
*/
|
|
1475
|
-
static createInstancedGeometry(s,
|
|
1476
|
-
const
|
|
1466
|
+
static createInstancedGeometry(s, n) {
|
|
1467
|
+
const t = Math.ceil(s / n), r = new i.BufferGeometry(), a = new Float32Array([
|
|
1477
1468
|
// x, y, splat_index_in_instance
|
|
1478
1469
|
-1,
|
|
1479
1470
|
-1,
|
|
@@ -1487,24 +1478,24 @@ const K = class K extends i.Mesh {
|
|
|
1487
1478
|
-1,
|
|
1488
1479
|
1,
|
|
1489
1480
|
0
|
|
1490
|
-
]), c = new Uint16Array([0, 1, 2, 0, 2, 3]), l = new Float32Array(4 * 3 *
|
|
1491
|
-
for (let p = 0; p <
|
|
1481
|
+
]), c = new Uint16Array([0, 1, 2, 0, 2, 3]), l = new Float32Array(4 * 3 * n);
|
|
1482
|
+
for (let p = 0; p < n; p++) {
|
|
1492
1483
|
const x = p * 4 * 3;
|
|
1493
|
-
for (let
|
|
1494
|
-
l[x +
|
|
1484
|
+
for (let f = 0; f < 4; f++)
|
|
1485
|
+
l[x + f * 3 + 0] = a[f * 3 + 0], l[x + f * 3 + 1] = a[f * 3 + 1], l[x + f * 3 + 2] = p;
|
|
1495
1486
|
}
|
|
1496
|
-
const m = new Uint32Array(6 *
|
|
1497
|
-
for (let p = 0; p <
|
|
1498
|
-
const x = p * 6,
|
|
1499
|
-
m[x + 0] = c[0] +
|
|
1487
|
+
const m = new Uint32Array(6 * n);
|
|
1488
|
+
for (let p = 0; p < n; p++) {
|
|
1489
|
+
const x = p * 6, f = p * 4;
|
|
1490
|
+
m[x + 0] = c[0] + f, m[x + 1] = c[1] + f, m[x + 2] = c[2] + f, m[x + 3] = c[3] + f, m[x + 4] = c[4] + f, m[x + 5] = c[5] + f;
|
|
1500
1491
|
}
|
|
1501
|
-
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1504
|
-
const b = new Uint32Array(
|
|
1505
|
-
for (let p = 0; p <
|
|
1506
|
-
b[p] = p *
|
|
1507
|
-
return
|
|
1492
|
+
r.setAttribute("position", new i.BufferAttribute(l, 3)), r.setIndex(new i.BufferAttribute(m, 1));
|
|
1493
|
+
const S = new i.InstancedBufferGeometry();
|
|
1494
|
+
S.index = r.index, S.setAttribute("position", r.getAttribute("position"));
|
|
1495
|
+
const b = new Uint32Array(t);
|
|
1496
|
+
for (let p = 0; p < t; p++)
|
|
1497
|
+
b[p] = p * n;
|
|
1498
|
+
return S.setAttribute("splatInstanceIndex", new i.InstancedBufferAttribute(b, 1, !1)), S.instanceCount = 0, S;
|
|
1508
1499
|
}
|
|
1509
1500
|
/**
|
|
1510
1501
|
* Create chunks data (bounding box min/max) for the sorter.
|
|
@@ -1526,18 +1517,18 @@ const K = class K extends i.Mesh {
|
|
|
1526
1517
|
* @param width Viewport width
|
|
1527
1518
|
* @param height Viewport height
|
|
1528
1519
|
*/
|
|
1529
|
-
updateViewport(s,
|
|
1530
|
-
this.material.updateViewport(s,
|
|
1520
|
+
updateViewport(s, n) {
|
|
1521
|
+
this.material.updateViewport(s, n);
|
|
1531
1522
|
}
|
|
1532
1523
|
/**
|
|
1533
1524
|
* Sorts splats based on camera position and direction.
|
|
1534
1525
|
* @param camera The camera to sort against.
|
|
1535
1526
|
*/
|
|
1536
1527
|
sort(s) {
|
|
1537
|
-
const
|
|
1538
|
-
s.getWorldPosition(
|
|
1539
|
-
const
|
|
1540
|
-
this.options.autoSort && (c || l) && (this.lastCameraPositionLocal.copy(
|
|
1528
|
+
const n = new i.Vector3(), t = new i.Vector3();
|
|
1529
|
+
s.getWorldPosition(n), s.getWorldDirection(t), this.invModelMatrix.copy(this.matrixWorld).invert();
|
|
1530
|
+
const r = n.applyMatrix4(this.invModelMatrix), a = t.transformDirection(this.invModelMatrix), c = this.lastCameraPositionLocal.distanceToSquared(r) > 1e-6, l = this.lastCameraDirectionLocal.dot(a) < 0.999;
|
|
1531
|
+
this.options.autoSort && (c || l) && (this.lastCameraPositionLocal.copy(r), this.lastCameraDirectionLocal.copy(a), this.sorter.setCamera(r, a));
|
|
1541
1532
|
}
|
|
1542
1533
|
/**
|
|
1543
1534
|
* THREE.js hook called before rendering the object.
|
|
@@ -1548,10 +1539,10 @@ const K = class K extends i.Mesh {
|
|
|
1548
1539
|
*/
|
|
1549
1540
|
// prettier-ignore
|
|
1550
1541
|
// @ts-expect-error scene is not used
|
|
1551
|
-
onBeforeRender(s,
|
|
1552
|
-
this.sort(
|
|
1553
|
-
const
|
|
1554
|
-
let { width: a, height: c } =
|
|
1542
|
+
onBeforeRender(s, n, t) {
|
|
1543
|
+
this.sort(t);
|
|
1544
|
+
const r = s.getSize(new i.Vector2());
|
|
1545
|
+
let { width: a, height: c } = r;
|
|
1555
1546
|
const l = s.xr;
|
|
1556
1547
|
if (l.enabled && l.isPresenting) {
|
|
1557
1548
|
const m = l.getCamera().cameras[0].view;
|
|
@@ -1569,28 +1560,28 @@ const K = class K extends i.Mesh {
|
|
|
1569
1560
|
// Cached inverse matrix
|
|
1570
1561
|
/** Number of splats combined into a single instanced draw call. */
|
|
1571
1562
|
v(K, "INSTANCE_SIZE", 128);
|
|
1572
|
-
let ae = K,
|
|
1573
|
-
typeof window < "u" && !
|
|
1574
|
-
const
|
|
1575
|
-
plyUrl:
|
|
1563
|
+
let ae = K, me = !1;
|
|
1564
|
+
typeof window < "u" && !me && (Se({ splatPrimitive: ae }), me = !0);
|
|
1565
|
+
const je = ({
|
|
1566
|
+
plyUrl: C,
|
|
1576
1567
|
splatOptions: e = {},
|
|
1577
1568
|
...s
|
|
1578
1569
|
}) => {
|
|
1579
|
-
const
|
|
1580
|
-
() => [
|
|
1581
|
-
[
|
|
1570
|
+
const n = ve(null), t = Te(ke, C), r = we(
|
|
1571
|
+
() => [t, e || {}],
|
|
1572
|
+
[t, e]
|
|
1582
1573
|
);
|
|
1583
|
-
return
|
|
1584
|
-
const a =
|
|
1574
|
+
return be(() => {
|
|
1575
|
+
const a = n.current;
|
|
1585
1576
|
return a && !(a instanceof ae) && console.warn(
|
|
1586
1577
|
"Visus: The 'Splat' component's internal mesh ref is not an instance of the core SplatMesh. This usually means `extend` was not called correctly. Please ensure you have called `extend({ splatPrimitive: SplatMesh })` in your R3F setup, where 'SplatMesh' is the class imported from 'visus' (or 'visus/react')."
|
|
1587
1578
|
), () => {
|
|
1588
1579
|
a && typeof a.dispose == "function" && a.dispose();
|
|
1589
1580
|
};
|
|
1590
|
-
}, []), /* @__PURE__ */
|
|
1581
|
+
}, []), /* @__PURE__ */ Ee.jsx("splatPrimitive", { ref: n, args: r, ...s });
|
|
1591
1582
|
};
|
|
1592
1583
|
export {
|
|
1593
1584
|
ke as PlyLoader,
|
|
1594
|
-
|
|
1585
|
+
je as Splat,
|
|
1595
1586
|
ae as SplatMesh
|
|
1596
1587
|
};
|